1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of LEXIExporter |
---|
4 | |
---|
5 | Copyright 2006 NDS Limited |
---|
6 | |
---|
7 | Author(s): |
---|
8 | Mark Folkenberg, |
---|
9 | Bo Krohn |
---|
10 | |
---|
11 | This program is free software; you can redistribute it and/or modify it under |
---|
12 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
13 | Foundation; either version 2 of the License, or (at your option) any later |
---|
14 | version. |
---|
15 | |
---|
16 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU Lesser General Public License along with |
---|
21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
23 | http://www.gnu.org/copyleft/lesser.txt. |
---|
24 | ----------------------------------------------------------------------------- |
---|
25 | */ |
---|
26 | |
---|
27 | #ifndef __NDS_LexiExporter_IntermediateBuilder__ |
---|
28 | #define __NDS_LexiExporter_IntermediateBuilder__ |
---|
29 | |
---|
30 | // |
---|
31 | |
---|
32 | class CIntermediateBuilderSkeleton; |
---|
33 | |
---|
34 | |
---|
35 | class CIntermediateBuilder { |
---|
36 | |
---|
37 | friend class CIntermediateMesh; |
---|
38 | |
---|
39 | public: |
---|
40 | |
---|
41 | // Constructor/Destructor |
---|
42 | CIntermediateBuilder(); |
---|
43 | ~CIntermediateBuilder(); |
---|
44 | |
---|
45 | // Get pointer to intermediate builder |
---|
46 | static CIntermediateBuilder* Get(); |
---|
47 | |
---|
48 | // Clear everything (cached materials, etc.) |
---|
49 | void Clear(); |
---|
50 | |
---|
51 | void CleanUpHierarchy( Ogre::SceneNode* pNode ); |
---|
52 | |
---|
53 | void SetConfig( CDDObject* pConfig ); |
---|
54 | |
---|
55 | // Get built hierarchy |
---|
56 | Ogre::SceneNode* CreateHierarchy(unsigned int iNodeID, bool bRecursive, bool bHidden); |
---|
57 | |
---|
58 | // Collapse hierarchy |
---|
59 | Ogre::SceneNode* CollapseHierarchy(Ogre::SceneNode* pHierarchy, const std::list<std::string>& Arrays, const char* pszName); |
---|
60 | |
---|
61 | // Get the list of active intermediate materials |
---|
62 | bool GetMaterials( std::map<Ogre::String, CIntermediateMaterial*>& materialMap ) const; |
---|
63 | |
---|
64 | // Transform Max coord system to Ogre |
---|
65 | static void Rotate90DegreesAroundX( Point3& inVec ); |
---|
66 | static void Rotate90DegreesAroundX( Quat& inQuat ); |
---|
67 | |
---|
68 | Ogre::String GetAnimationName( void ); |
---|
69 | float GetAnimationLength( void ); |
---|
70 | |
---|
71 | CIntermediateBuilderSkeleton* GetSkeletonBuilder( void ); |
---|
72 | |
---|
73 | // Material Map |
---|
74 | std::map<Ogre::String, CIntermediateMaterial*> m_lMaterials; |
---|
75 | |
---|
76 | |
---|
77 | protected: |
---|
78 | |
---|
79 | CMeshArray* BuildMeshArray(unsigned int iNodeID, const char* pszTypeName, TimeValue iTime); |
---|
80 | |
---|
81 | // Build and track Intermediate Materials |
---|
82 | CIntermediateMaterial* CreateMaterial( Mtl* pMaxMaterial ); |
---|
83 | |
---|
84 | void RegisterMaps( CIntermediateMaterial* pIMat, Mtl* pMaxMaterial ) ; |
---|
85 | |
---|
86 | private: |
---|
87 | |
---|
88 | Ogre::SceneNode* CreateHierarchy(unsigned int iNodeID, Ogre::SceneNode* pParent, bool bRecursive, bool bHidden); |
---|
89 | CIntermediateMesh* CreateMesh(unsigned int iNodeID); |
---|
90 | |
---|
91 | int m_iBoneIndex; |
---|
92 | bool FindSkinModifier(INode* nodePtr, Modifier** pSkinMod,ISkin** pSkin, ISkinContextData** pSkinContext); |
---|
93 | void CreateIntermediateBonePool(CIntermediateSkeleton* pSkel, ISkin* pSkin); |
---|
94 | void ConnectLinkedBones(CIntermediateSkeleton* pSkel); |
---|
95 | void BuildSkeleton( CIntermediateSkeleton* pSkel ); |
---|
96 | void AddFrame( CIntermediateSkeleton* pSkel, unsigned int meshNodeID, CAnimationSetting animSetting); |
---|
97 | void SetBindingPose( CIntermediateSkeleton* pISkel, unsigned int meshNodeID, unsigned int frame ); |
---|
98 | |
---|
99 | void CountTriangles(Ogre::SceneNode* pNode, unsigned int& iNumTriangles) const; |
---|
100 | void CollapseHierarchy(CIntermediateMesh* pMesh, unsigned int& iTriangleOffset, unsigned int& iVertexOffset, Ogre::SceneNode* pNode, const std::list<std::string>& Arrays, const Ogre::Matrix4& mat) const; |
---|
101 | |
---|
102 | static void Clamp( Point3& inVec, float threshold ); |
---|
103 | |
---|
104 | CIntermediateBuilderSkeleton* m_pSkeletonBuilder; |
---|
105 | |
---|
106 | CAnimSettings m_AnimationSetting; |
---|
107 | |
---|
108 | bool m_bExportSkeleton; |
---|
109 | int m_iAnimStart; |
---|
110 | int m_iAnimEnd; |
---|
111 | float m_fSampleRate; |
---|
112 | Ogre::String m_sAnimationName; |
---|
113 | float m_fAnimTotalLength; |
---|
114 | |
---|
115 | // record the created intermediate objects |
---|
116 | std::vector< CIntermediateMesh* > m_lIMPool; |
---|
117 | }; |
---|
118 | |
---|
119 | // |
---|
120 | |
---|
121 | #endif // __NDS_LexiExporter_IntermediateBuilder__ |
---|