| 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_IntermediateClasses__ |
|---|
| 28 | #define __NDS_LexiExporter_IntermediateClasses__ |
|---|
| 29 | |
|---|
| 30 | // |
|---|
| 31 | |
|---|
| 32 | //enum AnimationTypes = { Bone=0, Morph=1, Pose=2 }; |
|---|
| 33 | |
|---|
| 34 | class CAnimationSetting |
|---|
| 35 | { |
|---|
| 36 | public: |
|---|
| 37 | std::string m_sAnimName; |
|---|
| 38 | std::string m_sType; |
|---|
| 39 | unsigned int m_iStartFrame; |
|---|
| 40 | unsigned int m_iEndFrame; |
|---|
| 41 | float m_fSampleRate; |
|---|
| 42 | bool m_bOptimize; |
|---|
| 43 | |
|---|
| 44 | Ogre::String ToString( void ) |
|---|
| 45 | { |
|---|
| 46 | //Ogre::LogManager::getSingleton().logMessage("CAnimationSetting::ToString() - Start"); |
|---|
| 47 | Ogre::StringUtil::StrStreamType str; |
|---|
| 48 | str << "AnimationSetting: " << m_sAnimName << " (" << m_sType << ") "; |
|---|
| 49 | |
|---|
| 50 | //Ogre::LogManager::getSingleton().logMessage("CAnimationSetting::ToString() - End"); |
|---|
| 51 | return str.str(); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | class CAnimSettings |
|---|
| 57 | { |
|---|
| 58 | public: |
|---|
| 59 | std::vector< CAnimationSetting > m_lSettings; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | }; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | // |
|---|
| 68 | |
|---|
| 69 | class CMeshArray { |
|---|
| 70 | |
|---|
| 71 | public: |
|---|
| 72 | |
|---|
| 73 | virtual ~CMeshArray() {}; |
|---|
| 74 | |
|---|
| 75 | virtual void Create(unsigned int iSize) = 0; |
|---|
| 76 | virtual void Create(unsigned int iSize, const void* pData) = 0; |
|---|
| 77 | |
|---|
| 78 | virtual void* Data() = 0; |
|---|
| 79 | virtual const void* Data() const = 0; |
|---|
| 80 | virtual void* Data(unsigned int iElement) = 0; |
|---|
| 81 | virtual const void* Data(unsigned int iElement) const = 0; |
|---|
| 82 | |
|---|
| 83 | virtual void Zero() = 0; |
|---|
| 84 | |
|---|
| 85 | virtual unsigned int Size() const = 0; |
|---|
| 86 | |
|---|
| 87 | virtual unsigned int ElementSize() const = 0; |
|---|
| 88 | |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | // |
|---|
| 92 | |
|---|
| 93 | template <class T> class CTMeshArray : public CMeshArray { |
|---|
| 94 | |
|---|
| 95 | private: |
|---|
| 96 | |
|---|
| 97 | T* m_pArray; |
|---|
| 98 | unsigned int m_iSize; |
|---|
| 99 | |
|---|
| 100 | public: |
|---|
| 101 | |
|---|
| 102 | CTMeshArray() |
|---|
| 103 | { |
|---|
| 104 | m_pArray = NULL; |
|---|
| 105 | m_iSize = 0; |
|---|
| 106 | } |
|---|
| 107 | CTMeshArray(unsigned int iSize) |
|---|
| 108 | { |
|---|
| 109 | m_pArray = NULL; |
|---|
| 110 | m_iSize = 0; |
|---|
| 111 | |
|---|
| 112 | Create(iSize); |
|---|
| 113 | } |
|---|
| 114 | virtual ~CTMeshArray() |
|---|
| 115 | { |
|---|
| 116 | if(m_pArray) delete []m_pArray; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | // |
|---|
| 120 | |
|---|
| 121 | void* Data() |
|---|
| 122 | { |
|---|
| 123 | return m_pArray; |
|---|
| 124 | } |
|---|
| 125 | const void* Data() const |
|---|
| 126 | { |
|---|
| 127 | return m_pArray; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | void* Data(unsigned int iElement) |
|---|
| 131 | { |
|---|
| 132 | return &m_pArray[iElement]; |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | const void* Data(unsigned int iElement) const |
|---|
| 136 | { |
|---|
| 137 | return &m_pArray[iElement]; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | unsigned int Size() const |
|---|
| 141 | { |
|---|
| 142 | return m_iSize; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | unsigned int ElementSize() const |
|---|
| 146 | { |
|---|
| 147 | return sizeof(T); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | // |
|---|
| 151 | |
|---|
| 152 | void Create(unsigned int iSize) |
|---|
| 153 | { |
|---|
| 154 | if(m_pArray) delete []m_pArray; |
|---|
| 155 | if(iSize) m_pArray = new T[iSize]; |
|---|
| 156 | else m_pArray = NULL; |
|---|
| 157 | m_iSize = iSize; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | void Create(unsigned int iSize, const void* pData) |
|---|
| 161 | { |
|---|
| 162 | Create(iSize); |
|---|
| 163 | memcpy(m_pArray, pData, m_iSize * sizeof(T)); |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | // |
|---|
| 167 | |
|---|
| 168 | void Zero() |
|---|
| 169 | { |
|---|
| 170 | memset(m_pArray, 0, m_iSize * sizeof(T)); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | // |
|---|
| 174 | |
|---|
| 175 | T& operator [] (unsigned int iIndex) |
|---|
| 176 | { |
|---|
| 177 | return m_pArray[iIndex]; |
|---|
| 178 | } |
|---|
| 179 | const T& operator [] (unsigned int iIndex) const |
|---|
| 180 | { |
|---|
| 181 | return m_pArray[iIndex]; |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | }; |
|---|
| 185 | |
|---|
| 186 | // |
|---|
| 187 | |
|---|
| 188 | typedef CTMeshArray<Ogre::Vector2> CVec2Array; |
|---|
| 189 | typedef CTMeshArray<Ogre::Vector3> CVec3Array; |
|---|
| 190 | typedef CTMeshArray<Ogre::Vector4> CVec4Array; |
|---|
| 191 | typedef CTMeshArray<float> CFloatArray; |
|---|
| 192 | typedef CTMeshArray<unsigned char> CUInt8Array; |
|---|
| 193 | |
|---|
| 194 | // |
|---|
| 195 | |
|---|
| 196 | class CTriangle { |
|---|
| 197 | |
|---|
| 198 | public: |
|---|
| 199 | |
|---|
| 200 | unsigned int m_Vertices[3]; |
|---|
| 201 | CIntermediateMaterial* m_pMaterial; |
|---|
| 202 | |
|---|
| 203 | }; |
|---|
| 204 | |
|---|
| 205 | typedef CTMeshArray<CTriangle> CTriangleArray; |
|---|
| 206 | |
|---|
| 207 | // |
|---|
| 208 | |
|---|
| 209 | #endif // __NDS_LexiExporter_IntermediateClasses__ |
|---|