1 | //////////////////////////////////////////////////////////////////////////////// |
---|
2 | // mesh.h |
---|
3 | // Author : Francesco Giordana |
---|
4 | // Start Date : January 13, 2005 |
---|
5 | // Copyright : (C) 2006 by Francesco Giordana |
---|
6 | // Email : fra.giordana@tiscali.it |
---|
7 | //////////////////////////////////////////////////////////////////////////////// |
---|
8 | |
---|
9 | /********************************************************************************* |
---|
10 | * * |
---|
11 | * This program is free software; you can redistribute it and/or modify * |
---|
12 | * it under the terms of the GNU Lesser General Public License as published by * |
---|
13 | * the Free Software Foundation; either version 2 of the License, or * |
---|
14 | * (at your option) any later version. * |
---|
15 | * * |
---|
16 | **********************************************************************************/ |
---|
17 | |
---|
18 | #ifndef _MESH_H |
---|
19 | #define _MESH_H |
---|
20 | |
---|
21 | #include "submesh.h" |
---|
22 | #include "skeleton.h" |
---|
23 | #include "mayaExportLayer.h" |
---|
24 | #include "vertex.h" |
---|
25 | |
---|
26 | namespace OgreMayaExporter |
---|
27 | { |
---|
28 | /***** structures to store shared geometry *****/ |
---|
29 | typedef struct dagInfotag |
---|
30 | { |
---|
31 | long offset; |
---|
32 | long numVertices; |
---|
33 | MDagPath dagPath; |
---|
34 | BlendShape* pBlendShape; |
---|
35 | } dagInfo; |
---|
36 | |
---|
37 | typedef struct sharedGeometrytag |
---|
38 | { |
---|
39 | std::vector<vertex> vertices; |
---|
40 | std::vector<dagInfo> dagMap; |
---|
41 | } sharedGeometry; |
---|
42 | |
---|
43 | |
---|
44 | /***** Class Mesh *****/ |
---|
45 | class Mesh |
---|
46 | { |
---|
47 | public: |
---|
48 | //constructor |
---|
49 | Mesh(const MString& name = ""); |
---|
50 | //destructor |
---|
51 | ~Mesh(); |
---|
52 | //clear data |
---|
53 | void clear(); |
---|
54 | //get pointer to linked skeleton |
---|
55 | Skeleton* getSkeleton(); |
---|
56 | //load mesh data from a maya Fn |
---|
57 | MStatus load(const MDagPath& meshDag,ParamList ¶ms); |
---|
58 | //load vertex animations |
---|
59 | MStatus loadAnims(ParamList ¶ms); |
---|
60 | //load blend shape deformers |
---|
61 | MStatus loadBlendShapes(ParamList ¶ms); |
---|
62 | //load blend shape animations |
---|
63 | MStatus loadBlendShapeAnimations(ParamList& params); |
---|
64 | //write to a OGRE binary mesh |
---|
65 | MStatus writeOgreBinary(ParamList ¶ms); |
---|
66 | |
---|
67 | protected: |
---|
68 | //get uvsets info from the maya mesh |
---|
69 | MStatus getUVSets(const MDagPath& meshDag); |
---|
70 | //get skin cluster linked to the maya mesh |
---|
71 | MStatus getSkinCluster(const MDagPath& meshDag,ParamList& params); |
---|
72 | //get blend shape deformer linked to the maya mesh |
---|
73 | MStatus getBlendShapeDeformer(const MDagPath& meshDag,ParamList& params); |
---|
74 | //get connected shaders |
---|
75 | MStatus getShaders(const MDagPath& meshDag); |
---|
76 | //get vertex data |
---|
77 | MStatus getVertices(const MDagPath& meshDag,ParamList& params); |
---|
78 | //get vertex bone assignements |
---|
79 | MStatus getVertexBoneWeights(const MDagPath& meshDag,OgreMayaExporter::ParamList ¶ms); |
---|
80 | //get faces data |
---|
81 | MStatus getFaces(const MDagPath& meshDag,ParamList& params); |
---|
82 | //build shared geometry |
---|
83 | MStatus buildSharedGeometry(const MDagPath& meshDag,ParamList& params); |
---|
84 | //create submeshes |
---|
85 | MStatus createSubmeshes(const MDagPath& meshDag,ParamList& params); |
---|
86 | //load a vertex animation clip |
---|
87 | MStatus loadClip(MString& clipName,float start,float stop,float rate,ParamList& params); |
---|
88 | //load a vertex animation track for the whole mesh |
---|
89 | MStatus loadMeshTrack(Animation& a,std::vector<float>& times,ParamList& params); |
---|
90 | //load all submesh animation tracks (one for each submesh) |
---|
91 | MStatus loadSubmeshTracks(Animation& a,std::vector<float>& times,ParamList& params); |
---|
92 | //load a keyframe for the whole mesh |
---|
93 | MStatus loadKeyframe(Track& t,float time,ParamList& params); |
---|
94 | //write shared geometry data to an Ogre compatible mesh |
---|
95 | MStatus createOgreSharedGeometry(Ogre::MeshPtr pMesh,ParamList& params); |
---|
96 | //create an Ogre compatible vertex buffer |
---|
97 | MStatus createOgreVertexBuffer(Ogre::MeshPtr pMesh,Ogre::VertexDeclaration* pDecl,const std::vector<vertex>& vertices); |
---|
98 | //create Ogre poses for pose animation |
---|
99 | MStatus createOgrePoses(Ogre::MeshPtr pMesh,ParamList& params); |
---|
100 | //create vertex animations for an Ogre mesh |
---|
101 | MStatus createOgreVertexAnimations(Ogre::MeshPtr pMesh,ParamList& params); |
---|
102 | //create pose animations for an Ogre mesh |
---|
103 | MStatus createOgrePoseAnimations(Ogre::MeshPtr pMesh,ParamList& params); |
---|
104 | |
---|
105 | //internal members |
---|
106 | MString m_name; |
---|
107 | long m_numTriangles; |
---|
108 | std::vector<uvset> m_uvsets; |
---|
109 | std::vector<Submesh*> m_submeshes; |
---|
110 | Skeleton* m_pSkeleton; |
---|
111 | sharedGeometry m_sharedGeom; |
---|
112 | std::vector<Animation> m_vertexClips; |
---|
113 | std::vector<Animation> m_BSClips; |
---|
114 | //temporary members (existing only during translation from maya mesh) |
---|
115 | std::vector<vertexInfo> newvertices; |
---|
116 | std::vector<MFloatArray> newweights; |
---|
117 | std::vector<MIntArray> newjointIds; |
---|
118 | MPointArray newpoints; |
---|
119 | MFloatVectorArray newnormals; |
---|
120 | MStringArray newuvsets; |
---|
121 | MFnSkinCluster* pSkinCluster; |
---|
122 | BlendShape* pBlendShape; |
---|
123 | MObjectArray shaders; |
---|
124 | MIntArray shaderPolygonMapping; |
---|
125 | std::vector<faceArray> polygonSets; |
---|
126 | bool opposite; |
---|
127 | }; |
---|
128 | |
---|
129 | }; // end of namespace |
---|
130 | |
---|
131 | #endif |
---|