00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef WMESH_H
00021 #define WMESH_H
00022
00023 #include "worldsimconfig.h"
00024 #include "world.h"
00025
00026 namespace farsa {
00027
00041 class FARSA_WSIM_API WMesh : public WObject {
00042 Q_OBJECT
00043 public:
00048 WMesh( World* world, QString name="unamed", const wMatrix& tm = wMatrix::identity() );
00050 virtual ~WMesh();
00052 bool loadMS3DModel( QString filename );
00056 void attachTo( WObject* obj );
00058 WObject* attachedTo() {
00059 return attacho;
00060 };
00062 struct Mesh {
00063 int m_materialIndex;
00064 int m_numTriangles;
00065 int *m_pTriangleIndices;
00066 };
00068 struct Material {
00069 float m_ambient[4], m_diffuse[4], m_specular[4], m_emissive[4];
00070 float m_shininess;
00071 QString m_pTextureFilename;
00072 };
00074 struct Triangle {
00075 float m_vertexNormals[3][3];
00076 float m_s[3], m_t[3];
00077 int m_vertexIndices[3];
00078 };
00080 struct Vertex {
00081 char m_boneID;
00082 float m_location[3];
00083 };
00084
00086 Mesh* meshes() {
00087 return m_pMeshes;
00088 };
00090 int meshesCount() {
00091 return m_numMeshes;
00092 };
00094 Material* materials() {
00095 return m_pMaterials;
00096 };
00098 int materialsCount() {
00099 return m_numMaterials;
00100 };
00102 Triangle* triangles() {
00103 return m_pTriangles;
00104 };
00106 int trianglesCount() {
00107 return m_numTriangles;
00108 };
00110 Vertex* vertices() {
00111 return m_pVertices;
00112 };
00114 int verticesCount() {
00115 return m_numVertices;
00116 };
00117 private:
00119 WObject* attacho;
00120
00121 int m_numMeshes;
00122 Mesh *m_pMeshes;
00123 int m_numMaterials;
00124 Material *m_pMaterials;
00125 int m_numTriangles;
00126 Triangle *m_pTriangles;
00127 int m_numVertices;
00128 Vertex *m_pVertices;
00129 };
00130
00131 }
00132
00133 #endif