diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/COgreMeshFileLoader.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/COgreMeshFileLoader.h | 538 |
1 files changed, 269 insertions, 269 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/COgreMeshFileLoader.h b/libraries/irrlicht-1.8/source/Irrlicht/COgreMeshFileLoader.h index 8179285..71a8ac8 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/COgreMeshFileLoader.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/COgreMeshFileLoader.h | |||
@@ -1,269 +1,269 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | // orginally written by Christian Stehno, modified by Nikolaus Gebhardt | 4 | // orginally written by Christian Stehno, modified by Nikolaus Gebhardt |
5 | 5 | ||
6 | #ifndef __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ | 6 | #ifndef __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ |
7 | #define __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ | 7 | #define __C_OGRE_MESH_FILE_LOADER_H_INCLUDED__ |
8 | 8 | ||
9 | #include "IMeshLoader.h" | 9 | #include "IMeshLoader.h" |
10 | #include "IFileSystem.h" | 10 | #include "IFileSystem.h" |
11 | #include "IVideoDriver.h" | 11 | #include "IVideoDriver.h" |
12 | #include "irrString.h" | 12 | #include "irrString.h" |
13 | #include "SMesh.h" | 13 | #include "SMesh.h" |
14 | #include "SMeshBuffer.h" | 14 | #include "SMeshBuffer.h" |
15 | #include "SMeshBufferLightMap.h" | 15 | #include "SMeshBufferLightMap.h" |
16 | #include "IMeshManipulator.h" | 16 | #include "IMeshManipulator.h" |
17 | #include "matrix4.h" | 17 | #include "matrix4.h" |
18 | #include "quaternion.h" | 18 | #include "quaternion.h" |
19 | #include "CSkinnedMesh.h" | 19 | #include "CSkinnedMesh.h" |
20 | 20 | ||
21 | namespace irr | 21 | namespace irr |
22 | { | 22 | { |
23 | namespace scene | 23 | namespace scene |
24 | { | 24 | { |
25 | 25 | ||
26 | //! Meshloader capable of loading ogre meshes. | 26 | //! Meshloader capable of loading ogre meshes. |
27 | class COgreMeshFileLoader : public IMeshLoader | 27 | class COgreMeshFileLoader : public IMeshLoader |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | 30 | ||
31 | //! Constructor | 31 | //! Constructor |
32 | COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); | 32 | COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver); |
33 | 33 | ||
34 | //! destructor | 34 | //! destructor |
35 | virtual ~COgreMeshFileLoader(); | 35 | virtual ~COgreMeshFileLoader(); |
36 | 36 | ||
37 | //! returns true if the file maybe is able to be loaded by this class | 37 | //! returns true if the file maybe is able to be loaded by this class |
38 | //! based on the file extension (e.g. ".cob") | 38 | //! based on the file extension (e.g. ".cob") |
39 | virtual bool isALoadableFileExtension(const io::path& filename) const; | 39 | virtual bool isALoadableFileExtension(const io::path& filename) const; |
40 | 40 | ||
41 | //! creates/loads an animated mesh from the file. | 41 | //! creates/loads an animated mesh from the file. |
42 | //! \return Pointer to the created mesh. Returns 0 if loading failed. | 42 | //! \return Pointer to the created mesh. Returns 0 if loading failed. |
43 | //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). | 43 | //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). |
44 | //! See IReferenceCounted::drop() for more information. | 44 | //! See IReferenceCounted::drop() for more information. |
45 | virtual IAnimatedMesh* createMesh(io::IReadFile* file); | 45 | virtual IAnimatedMesh* createMesh(io::IReadFile* file); |
46 | 46 | ||
47 | private: | 47 | private: |
48 | 48 | ||
49 | // byte-align structures | 49 | // byte-align structures |
50 | #include "irrpack.h" | 50 | #include "irrpack.h" |
51 | 51 | ||
52 | struct ChunkHeader | 52 | struct ChunkHeader |
53 | { | 53 | { |
54 | u16 id; | 54 | u16 id; |
55 | u32 length; | 55 | u32 length; |
56 | } PACK_STRUCT; | 56 | } PACK_STRUCT; |
57 | 57 | ||
58 | // Default alignment | 58 | // Default alignment |
59 | #include "irrunpack.h" | 59 | #include "irrunpack.h" |
60 | 60 | ||
61 | 61 | ||
62 | struct ChunkData | 62 | struct ChunkData |
63 | { | 63 | { |
64 | ChunkData() : read(0) {} | 64 | ChunkData() : read(0) {} |
65 | 65 | ||
66 | ChunkHeader header; | 66 | ChunkHeader header; |
67 | u32 read; | 67 | u32 read; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct OgreTexture | 70 | struct OgreTexture |
71 | { | 71 | { |
72 | core::array<core::stringc> Filename; | 72 | core::array<core::stringc> Filename; |
73 | core::stringc Alias; | 73 | core::stringc Alias; |
74 | core::stringc CoordsType; | 74 | core::stringc CoordsType; |
75 | core::stringc MipMaps; | 75 | core::stringc MipMaps; |
76 | core::stringc Alpha; | 76 | core::stringc Alpha; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | struct OgrePass | 79 | struct OgrePass |
80 | { | 80 | { |
81 | OgrePass() : AmbientTokenColor(false), | 81 | OgrePass() : AmbientTokenColor(false), |
82 | DiffuseTokenColor(false), SpecularTokenColor(false), | 82 | DiffuseTokenColor(false), SpecularTokenColor(false), |
83 | EmissiveTokenColor(false), | 83 | EmissiveTokenColor(false), |
84 | MaxLights(8), PointSize(1.0f), PointSprites(false), | 84 | MaxLights(8), PointSize(1.0f), PointSprites(false), |
85 | PointSizeMin(0), PointSizeMax(0) {} | 85 | PointSizeMin(0), PointSizeMax(0) {} |
86 | 86 | ||
87 | video::SMaterial Material; | 87 | video::SMaterial Material; |
88 | OgreTexture Texture; | 88 | OgreTexture Texture; |
89 | bool AmbientTokenColor; | 89 | bool AmbientTokenColor; |
90 | bool DiffuseTokenColor; | 90 | bool DiffuseTokenColor; |
91 | bool SpecularTokenColor; | 91 | bool SpecularTokenColor; |
92 | bool EmissiveTokenColor; | 92 | bool EmissiveTokenColor; |
93 | u32 MaxLights; | 93 | u32 MaxLights; |
94 | f32 PointSize; | 94 | f32 PointSize; |
95 | bool PointSprites; | 95 | bool PointSprites; |
96 | u32 PointSizeMin; | 96 | u32 PointSizeMin; |
97 | u32 PointSizeMax; | 97 | u32 PointSizeMax; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | struct OgreTechnique | 100 | struct OgreTechnique |
101 | { | 101 | { |
102 | OgreTechnique() : Name(""), LODIndex(0) {} | 102 | OgreTechnique() : Name(""), LODIndex(0) {} |
103 | 103 | ||
104 | core::stringc Name; | 104 | core::stringc Name; |
105 | core::stringc Scheme; | 105 | core::stringc Scheme; |
106 | u16 LODIndex; | 106 | u16 LODIndex; |
107 | core::array<OgrePass> Passes; | 107 | core::array<OgrePass> Passes; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | struct OgreMaterial | 110 | struct OgreMaterial |
111 | { | 111 | { |
112 | OgreMaterial() : Name(""), ReceiveShadows(true), | 112 | OgreMaterial() : Name(""), ReceiveShadows(true), |
113 | TransparencyCastsShadows(false) {} | 113 | TransparencyCastsShadows(false) {} |
114 | 114 | ||
115 | core::stringc Name; | 115 | core::stringc Name; |
116 | bool ReceiveShadows; | 116 | bool ReceiveShadows; |
117 | bool TransparencyCastsShadows; | 117 | bool TransparencyCastsShadows; |
118 | core::array<f32> LODDistances; | 118 | core::array<f32> LODDistances; |
119 | core::array<OgreTechnique> Techniques; | 119 | core::array<OgreTechnique> Techniques; |
120 | }; | 120 | }; |
121 | 121 | ||
122 | struct OgreVertexBuffer | 122 | struct OgreVertexBuffer |
123 | { | 123 | { |
124 | OgreVertexBuffer() : BindIndex(0), VertexSize(0), Data(0) {} | 124 | OgreVertexBuffer() : BindIndex(0), VertexSize(0), Data(0) {} |
125 | 125 | ||
126 | u16 BindIndex; | 126 | u16 BindIndex; |
127 | u16 VertexSize; | 127 | u16 VertexSize; |
128 | core::array<f32> Data; | 128 | core::array<f32> Data; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | struct OgreVertexElement | 131 | struct OgreVertexElement |
132 | { | 132 | { |
133 | u16 Source, | 133 | u16 Source, |
134 | Type, | 134 | Type, |
135 | Semantic, | 135 | Semantic, |
136 | Offset, | 136 | Offset, |
137 | Index; | 137 | Index; |
138 | }; | 138 | }; |
139 | 139 | ||
140 | struct OgreGeometry | 140 | struct OgreGeometry |
141 | { | 141 | { |
142 | s32 NumVertex; | 142 | s32 NumVertex; |
143 | core::array<OgreVertexElement> Elements; | 143 | core::array<OgreVertexElement> Elements; |
144 | core::array<OgreVertexBuffer> Buffers; | 144 | core::array<OgreVertexBuffer> Buffers; |
145 | core::array<core::vector3df> Vertices; | 145 | core::array<core::vector3df> Vertices; |
146 | core::array<core::vector3df> Normals; | 146 | core::array<core::vector3df> Normals; |
147 | core::array<s32> Colors; | 147 | core::array<s32> Colors; |
148 | core::array<core::vector2df> TexCoords; | 148 | core::array<core::vector2df> TexCoords; |
149 | }; | 149 | }; |
150 | 150 | ||
151 | struct OgreTextureAlias | 151 | struct OgreTextureAlias |
152 | { | 152 | { |
153 | OgreTextureAlias() {}; | 153 | OgreTextureAlias() {}; |
154 | OgreTextureAlias(const core::stringc& a, const core::stringc& b) : Texture(a), Alias(b) {}; | 154 | OgreTextureAlias(const core::stringc& a, const core::stringc& b) : Texture(a), Alias(b) {}; |
155 | core::stringc Texture; | 155 | core::stringc Texture; |
156 | core::stringc Alias; | 156 | core::stringc Alias; |
157 | }; | 157 | }; |
158 | 158 | ||
159 | struct OgreBoneAssignment | 159 | struct OgreBoneAssignment |
160 | { | 160 | { |
161 | s32 VertexID; | 161 | s32 VertexID; |
162 | u16 BoneID; | 162 | u16 BoneID; |
163 | f32 Weight; | 163 | f32 Weight; |
164 | }; | 164 | }; |
165 | 165 | ||
166 | struct OgreSubMesh | 166 | struct OgreSubMesh |
167 | { | 167 | { |
168 | core::stringc Material; | 168 | core::stringc Material; |
169 | bool SharedVertices; | 169 | bool SharedVertices; |
170 | core::array<s32> Indices; | 170 | core::array<s32> Indices; |
171 | OgreGeometry Geometry; | 171 | OgreGeometry Geometry; |
172 | u16 Operation; | 172 | u16 Operation; |
173 | core::array<OgreTextureAlias> TextureAliases; | 173 | core::array<OgreTextureAlias> TextureAliases; |
174 | core::array<OgreBoneAssignment> BoneAssignments; | 174 | core::array<OgreBoneAssignment> BoneAssignments; |
175 | bool Indices32Bit; | 175 | bool Indices32Bit; |
176 | }; | 176 | }; |
177 | 177 | ||
178 | struct OgreMesh | 178 | struct OgreMesh |
179 | { | 179 | { |
180 | bool SkeletalAnimation; | 180 | bool SkeletalAnimation; |
181 | OgreGeometry Geometry; | 181 | OgreGeometry Geometry; |
182 | core::array<OgreSubMesh> SubMeshes; | 182 | core::array<OgreSubMesh> SubMeshes; |
183 | core::array<OgreBoneAssignment> BoneAssignments; | 183 | core::array<OgreBoneAssignment> BoneAssignments; |
184 | core::vector3df BBoxMinEdge; | 184 | core::vector3df BBoxMinEdge; |
185 | core::vector3df BBoxMaxEdge; | 185 | core::vector3df BBoxMaxEdge; |
186 | f32 BBoxRadius; | 186 | f32 BBoxRadius; |
187 | }; | 187 | }; |
188 | 188 | ||
189 | struct OgreBone | 189 | struct OgreBone |
190 | { | 190 | { |
191 | core::stringc Name; | 191 | core::stringc Name; |
192 | core::vector3df Position; | 192 | core::vector3df Position; |
193 | core::quaternion Orientation; | 193 | core::quaternion Orientation; |
194 | core::vector3df Scale; | 194 | core::vector3df Scale; |
195 | u16 Handle; | 195 | u16 Handle; |
196 | u16 Parent; | 196 | u16 Parent; |
197 | }; | 197 | }; |
198 | 198 | ||
199 | struct OgreKeyframe | 199 | struct OgreKeyframe |
200 | { | 200 | { |
201 | u16 BoneID; | 201 | u16 BoneID; |
202 | f32 Time; | 202 | f32 Time; |
203 | core::vector3df Position; | 203 | core::vector3df Position; |
204 | core::quaternion Orientation; | 204 | core::quaternion Orientation; |
205 | core::vector3df Scale; | 205 | core::vector3df Scale; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | struct OgreAnimation | 208 | struct OgreAnimation |
209 | { | 209 | { |
210 | core::stringc Name; | 210 | core::stringc Name; |
211 | f32 Length; | 211 | f32 Length; |
212 | core::array<OgreKeyframe> Keyframes; | 212 | core::array<OgreKeyframe> Keyframes; |
213 | }; | 213 | }; |
214 | 214 | ||
215 | struct OgreSkeleton | 215 | struct OgreSkeleton |
216 | { | 216 | { |
217 | core::array<OgreBone> Bones; | 217 | core::array<OgreBone> Bones; |
218 | core::array<OgreAnimation> Animations; | 218 | core::array<OgreAnimation> Animations; |
219 | }; | 219 | }; |
220 | 220 | ||
221 | bool readChunk(io::IReadFile* file); | 221 | bool readChunk(io::IReadFile* file); |
222 | bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh); | 222 | bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh); |
223 | bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); | 223 | bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); |
224 | bool readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); | 224 | bool readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); |
225 | bool readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); | 225 | bool readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry); |
226 | bool readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh); | 226 | bool readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh); |
227 | 227 | ||
228 | void readChunkData(io::IReadFile* file, ChunkData& data); | 228 | void readChunkData(io::IReadFile* file, ChunkData& data); |
229 | void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); | 229 | void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); |
230 | void readBool(io::IReadFile* file, ChunkData& data, bool& out); | 230 | void readBool(io::IReadFile* file, ChunkData& data, bool& out); |
231 | void readInt(io::IReadFile* file, ChunkData& data, s32* out, u32 num=1); | 231 | void readInt(io::IReadFile* file, ChunkData& data, s32* out, u32 num=1); |
232 | void readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num=1); | 232 | void readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num=1); |
233 | void readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num=1); | 233 | void readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num=1); |
234 | void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out); | 234 | void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out); |
235 | void readQuaternion(io::IReadFile* file, ChunkData& data, core::quaternion& out); | 235 | void readQuaternion(io::IReadFile* file, ChunkData& data, core::quaternion& out); |
236 | 236 | ||
237 | void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName); | 237 | void composeMeshBufferMaterial(scene::IMeshBuffer* mb, const core::stringc& materialName); |
238 | scene::SMeshBuffer* composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom); | 238 | scene::SMeshBuffer* composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom); |
239 | scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom); | 239 | scene::SMeshBufferLightMap* composeMeshBufferLightMap(const core::array<s32>& indices, const OgreGeometry& geom); |
240 | scene::IMeshBuffer* composeMeshBufferSkinned(scene::CSkinnedMesh& mesh, const core::array<s32>& indices, const OgreGeometry& geom); | 240 | scene::IMeshBuffer* composeMeshBufferSkinned(scene::CSkinnedMesh& mesh, const core::array<s32>& indices, const OgreGeometry& geom); |
241 | void composeObject(void); | 241 | void composeObject(void); |
242 | bool readColor(io::IReadFile* meshFile, video::SColor& col); | 242 | bool readColor(io::IReadFile* meshFile, video::SColor& col); |
243 | void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false); | 243 | void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false); |
244 | void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat); | 244 | void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat); |
245 | void readPass(io::IReadFile* file, OgreTechnique& technique); | 245 | void readPass(io::IReadFile* file, OgreTechnique& technique); |
246 | void loadMaterials(io::IReadFile* file); | 246 | void loadMaterials(io::IReadFile* file); |
247 | bool loadSkeleton(io::IReadFile* meshFile, const core::stringc& name); | 247 | bool loadSkeleton(io::IReadFile* meshFile, const core::stringc& name); |
248 | void clearMeshes(); | 248 | void clearMeshes(); |
249 | 249 | ||
250 | io::IFileSystem* FileSystem; | 250 | io::IFileSystem* FileSystem; |
251 | video::IVideoDriver* Driver; | 251 | video::IVideoDriver* Driver; |
252 | 252 | ||
253 | core::stringc Version; | 253 | core::stringc Version; |
254 | bool SwapEndian; | 254 | bool SwapEndian; |
255 | core::array<OgreMesh> Meshes; | 255 | core::array<OgreMesh> Meshes; |
256 | io::path CurrentlyLoadingFromPath; | 256 | io::path CurrentlyLoadingFromPath; |
257 | 257 | ||
258 | core::array<OgreMaterial> Materials; | 258 | core::array<OgreMaterial> Materials; |
259 | OgreSkeleton Skeleton; | 259 | OgreSkeleton Skeleton; |
260 | 260 | ||
261 | IMesh* Mesh; | 261 | IMesh* Mesh; |
262 | u32 NumUV; | 262 | u32 NumUV; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | } // end namespace scene | 265 | } // end namespace scene |
266 | } // end namespace irr | 266 | } // end namespace irr |
267 | 267 | ||
268 | #endif | 268 | #endif |
269 | 269 | ||