[692] | 1 | #ifndef _SUBMESH_H
|
---|
| 2 | #define _SUBMESH_H
|
---|
| 3 |
|
---|
| 4 | #include "mayaExportLayer.h"
|
---|
| 5 | #include "paramList.h"
|
---|
| 6 | #include "materialSet.h"
|
---|
| 7 |
|
---|
| 8 | namespace OgreMayaExporter
|
---|
| 9 | {
|
---|
| 10 | /***** structure for uvsets info *****/
|
---|
| 11 | typedef struct uvsettag
|
---|
| 12 | {
|
---|
| 13 | short size; //number of coordinates (between 1 and 3)
|
---|
| 14 | } uvset;
|
---|
| 15 | /***** structure for texture coordinates *****/
|
---|
| 16 | typedef struct texcoordstag
|
---|
| 17 | {
|
---|
| 18 | double u, v, w; //texture coordinates
|
---|
| 19 | } texcoords;
|
---|
| 20 |
|
---|
| 21 | /***** structure for vertex bone assignements *****/
|
---|
| 22 | typedef struct vbatag
|
---|
| 23 | {
|
---|
| 24 | double weight; //weight
|
---|
| 25 | int jointIdx; //index of associated joint
|
---|
| 26 | } vba;
|
---|
| 27 |
|
---|
| 28 | /***** structure for vertex data *****/
|
---|
| 29 | typedef struct vertextag
|
---|
| 30 | {
|
---|
| 31 | double x, y, z; //vertex coordinates
|
---|
| 32 | MVector n; //vertex normal
|
---|
| 33 | float r,g,b,a; //vertex colour
|
---|
| 34 | std::vector<texcoords> texcoords; //vertex texture coordinates
|
---|
| 35 | std::vector<vba> vbas; //vertex bone assignements
|
---|
| 36 | } vertex;
|
---|
| 37 |
|
---|
| 38 | /***** structure for vertex info *****/
|
---|
| 39 | // used to hold indices to access MFnMesh data
|
---|
| 40 | typedef struct vertexInfotag
|
---|
| 41 | {
|
---|
| 42 | int pointIdx; //index to points list (position)
|
---|
| 43 | int normalIdx; //index to normals list
|
---|
| 44 | float r,g,b,a; //colour
|
---|
| 45 | std::vector<float> u; //u texture coordinates
|
---|
| 46 | std::vector<float> v; //v texture coordinates
|
---|
| 47 | std::vector<float> vba; //vertex bone assignements
|
---|
| 48 | std::vector<int> jointIds; //ids of joints affecting this vertex
|
---|
| 49 | int next; //index of next vertex with same position
|
---|
| 50 | } vertexInfo;
|
---|
| 51 |
|
---|
| 52 | /***** structure for face info *****/
|
---|
| 53 | typedef struct facetag
|
---|
| 54 | {
|
---|
| 55 | long v[3]; //vertex indices
|
---|
| 56 | } face;
|
---|
| 57 |
|
---|
| 58 | /***** array of face infos *****/
|
---|
| 59 | typedef std::vector<face> faceArray;
|
---|
| 60 |
|
---|
| 61 | /***** Class Submesh *****/
|
---|
| 62 | class Submesh
|
---|
| 63 | {
|
---|
| 64 | public:
|
---|
| 65 | //constructor
|
---|
| 66 | Submesh(const MString& name = "");
|
---|
| 67 | //destructor
|
---|
| 68 | ~Submesh();
|
---|
| 69 | //clear data
|
---|
| 70 | void clear();
|
---|
| 71 | //load data
|
---|
| 72 | MStatus loadMaterial(MObject& shader,MStringArray& uvsets,ParamList& params);
|
---|
| 73 | MStatus load(std::vector<face>& faces, std::vector<vertexInfo>& vertInfo, MFloatPointArray& points,
|
---|
| 74 | MFloatVectorArray& normals, MStringArray& texcoordsets,ParamList& params,bool opposite = false);
|
---|
| 75 | //get number of triangles composing the submesh
|
---|
| 76 | long numTriangles();
|
---|
| 77 | //get number of vertices
|
---|
| 78 | long numVertices();
|
---|
| 79 | //get submesh name
|
---|
| 80 | MString& name();
|
---|
| 81 | //write submesh data to Ogre XML
|
---|
| 82 | MStatus writeXML(ParamList ¶ms);
|
---|
| 83 |
|
---|
| 84 | protected:
|
---|
| 85 | //internal members
|
---|
| 86 | MString m_name;
|
---|
| 87 | Material* m_pMaterial;
|
---|
| 88 | long m_numTriangles;
|
---|
| 89 | long m_numVertices;
|
---|
| 90 | std::vector<vertex> m_vertices;
|
---|
| 91 | std::vector<face> m_faces;
|
---|
| 92 | std::vector<uvset> m_uvsets;
|
---|
| 93 | bool m_use32bitIndexes;
|
---|
| 94 | };
|
---|
| 95 |
|
---|
| 96 | }; // end of namespace
|
---|
| 97 |
|
---|
| 98 | #endif |
---|