| 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 __MaxExporter_IntermediateBone__ |
|---|
| 28 | #define __MaxExporter_IntermediateBone__ |
|---|
| 29 | |
|---|
| 30 | // |
|---|
| 31 | class CAnimationData |
|---|
| 32 | { |
|---|
| 33 | private: |
|---|
| 34 | std::vector<float> m_lTimes; |
|---|
| 35 | //unsigned int m_iNrFrames; |
|---|
| 36 | std::vector<Ogre::Vector3> m_lPositions; |
|---|
| 37 | std::vector<Ogre::Quaternion> m_lOrientations; |
|---|
| 38 | std::vector<Ogre::Vector3> m_lScales; |
|---|
| 39 | bool m_bOptimize; |
|---|
| 40 | |
|---|
| 41 | public: |
|---|
| 42 | |
|---|
| 43 | ~CAnimationData( void ) |
|---|
| 44 | { |
|---|
| 45 | m_lTimes.clear(); |
|---|
| 46 | m_lPositions.clear(); |
|---|
| 47 | m_lOrientations.clear(); |
|---|
| 48 | m_lScales.clear(); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | void AddFrame( float fTimeInSecs, Ogre::Vector3 vPos, Ogre::Quaternion qOrient, Ogre::Vector3 vScale ) |
|---|
| 52 | { |
|---|
| 53 | m_lTimes.push_back(fTimeInSecs); |
|---|
| 54 | m_lPositions.push_back(vPos); |
|---|
| 55 | m_lOrientations.push_back(qOrient); |
|---|
| 56 | m_lScales.push_back(vScale); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | bool GetFrame( unsigned int iFrame, float& fTimeInSecs, Ogre::Vector3& vPos, Ogre::Quaternion& qOrient, Ogre::Vector3& vScale ) const |
|---|
| 60 | { |
|---|
| 61 | if(iFrame > m_lPositions.size()) |
|---|
| 62 | return false; |
|---|
| 63 | |
|---|
| 64 | fTimeInSecs = m_lTimes[iFrame]; |
|---|
| 65 | vPos = m_lPositions[iFrame]; |
|---|
| 66 | qOrient = m_lOrientations[iFrame]; |
|---|
| 67 | vScale = m_lScales[iFrame]; |
|---|
| 68 | return true; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | bool GetOptimize( void ) |
|---|
| 72 | { |
|---|
| 73 | return m_bOptimize; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | void SetOptimize( bool opt ) |
|---|
| 77 | { |
|---|
| 78 | m_bOptimize = opt; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | unsigned int GetNrFrames( void ) |
|---|
| 82 | { |
|---|
| 83 | return m_lPositions.size(); |
|---|
| 84 | } |
|---|
| 85 | }; |
|---|
| 86 | |
|---|
| 87 | class CIntermediateBone { |
|---|
| 88 | |
|---|
| 89 | private: |
|---|
| 90 | |
|---|
| 91 | std::string m_sName; |
|---|
| 92 | |
|---|
| 93 | std::vector<CIntermediateBone*> m_Bones; |
|---|
| 94 | |
|---|
| 95 | std::map< Ogre::String, CAnimationData* > m_lAnimations; |
|---|
| 96 | |
|---|
| 97 | //std::vector<float> m_Times; |
|---|
| 98 | //std::vector<Ogre::Vector3> m_Positions; |
|---|
| 99 | //std::vector<Ogre::Quaternion> m_Orientations; |
|---|
| 100 | //std::vector<Ogre::Vector3> m_Scales; |
|---|
| 101 | |
|---|
| 102 | ULONG m_Handle; |
|---|
| 103 | ULONG m_ParentHandle; |
|---|
| 104 | unsigned int m_iIndex; |
|---|
| 105 | CIntermediateBone* m_pParent; |
|---|
| 106 | |
|---|
| 107 | // Binding data |
|---|
| 108 | Ogre::Vector3 m_bindingPos; |
|---|
| 109 | Ogre::Quaternion m_bindingOrientation; |
|---|
| 110 | Ogre::Vector3 m_bindingScale; |
|---|
| 111 | |
|---|
| 112 | public: |
|---|
| 113 | |
|---|
| 114 | // |
|---|
| 115 | // General |
|---|
| 116 | // |
|---|
| 117 | |
|---|
| 118 | // Constructor/Destructor |
|---|
| 119 | CIntermediateBone(const char* pszName); |
|---|
| 120 | ~CIntermediateBone(); |
|---|
| 121 | |
|---|
| 122 | // Clear everything |
|---|
| 123 | void clear(); |
|---|
| 124 | |
|---|
| 125 | // Get name |
|---|
| 126 | std::string GetName() const; |
|---|
| 127 | |
|---|
| 128 | void SetHandle( ULONG handle ); |
|---|
| 129 | ULONG GetHandle( void ); |
|---|
| 130 | |
|---|
| 131 | void SetParentHandle( ULONG handle ); |
|---|
| 132 | ULONG GetParentHandle( void ); |
|---|
| 133 | |
|---|
| 134 | void SetIndex( unsigned int index ); |
|---|
| 135 | unsigned int GetIndex( void ); |
|---|
| 136 | |
|---|
| 137 | // |
|---|
| 138 | // Bones |
|---|
| 139 | // |
|---|
| 140 | |
|---|
| 141 | // Get number of bones |
|---|
| 142 | unsigned int GetBoneCount() const; |
|---|
| 143 | |
|---|
| 144 | // Get bone |
|---|
| 145 | CIntermediateBone* GetBone(unsigned int iBone); |
|---|
| 146 | const CIntermediateBone* GetBone(unsigned int iBone) const; |
|---|
| 147 | |
|---|
| 148 | // Add bone |
|---|
| 149 | void AddBone(CIntermediateBone* pBone); |
|---|
| 150 | |
|---|
| 151 | // Get/Set Parent |
|---|
| 152 | CIntermediateBone* GetParent( void ); |
|---|
| 153 | void SetParent( CIntermediateBone* parent ); |
|---|
| 154 | |
|---|
| 155 | // |
|---|
| 156 | // Frames |
|---|
| 157 | // |
|---|
| 158 | |
|---|
| 159 | // Get number of frames |
|---|
| 160 | unsigned int GetFrameCount( Ogre::String animationName ) const; |
|---|
| 161 | |
|---|
| 162 | bool CreateAnimation( const CAnimationSetting animSetting ); |
|---|
| 163 | |
|---|
| 164 | // Get frame |
|---|
| 165 | bool GetFrame(Ogre::String animName, unsigned int iFrame, float& fTimeInSecs, Ogre::Vector3& vPos, Ogre::Quaternion& qOri, Ogre::Vector3& vScale) const; |
|---|
| 166 | |
|---|
| 167 | // Add frame |
|---|
| 168 | bool AddFrame( const Ogre::String animName, unsigned int frameNr, float timeInSecs, const Ogre::Vector3& vPos, const Ogre::Quaternion& qOri, const Ogre::Vector3& vScale); |
|---|
| 169 | |
|---|
| 170 | // Set initial bindind pose from which all transformations are relative to |
|---|
| 171 | void SetBindingPose(const Ogre::Vector3& vPos, const Ogre::Quaternion& qOri, const Ogre::Vector3& vScale); |
|---|
| 172 | |
|---|
| 173 | void GetBindingPose(Ogre::Vector3& vPos, Ogre::Quaternion& qOri, Ogre::Vector3& vScale) const; |
|---|
| 174 | |
|---|
| 175 | std::map< Ogre::String, CAnimationData* > GetAnimations( void ); |
|---|
| 176 | }; |
|---|
| 177 | |
|---|
| 178 | // |
|---|
| 179 | |
|---|
| 180 | #endif // __MaxExporter_IntermediateBone__ |
|---|