diff options
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/C3DSMeshFileLoader.h')
-rw-r--r-- | src/others/irrlicht-1.8.1/source/Irrlicht/C3DSMeshFileLoader.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/C3DSMeshFileLoader.h b/src/others/irrlicht-1.8.1/source/Irrlicht/C3DSMeshFileLoader.h new file mode 100644 index 0000000..2219251 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/C3DSMeshFileLoader.h | |||
@@ -0,0 +1,166 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #ifndef __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ | ||
6 | #define __C_3DS_MESH_FILE_LOADER_H_INCLUDED__ | ||
7 | |||
8 | #include "IMeshLoader.h" | ||
9 | #include "IFileSystem.h" | ||
10 | #include "ISceneManager.h" | ||
11 | #include "irrString.h" | ||
12 | #include "SMesh.h" | ||
13 | #include "matrix4.h" | ||
14 | |||
15 | namespace irr | ||
16 | { | ||
17 | namespace scene | ||
18 | { | ||
19 | |||
20 | //! Meshloader capable of loading 3ds meshes. | ||
21 | class C3DSMeshFileLoader : public IMeshLoader | ||
22 | { | ||
23 | public: | ||
24 | |||
25 | //! Constructor | ||
26 | C3DSMeshFileLoader(ISceneManager* smgr, io::IFileSystem* fs); | ||
27 | |||
28 | //! destructor | ||
29 | virtual ~C3DSMeshFileLoader(); | ||
30 | |||
31 | //! returns true if the file maybe is able to be loaded by this class | ||
32 | //! based on the file extension (e.g. ".cob") | ||
33 | virtual bool isALoadableFileExtension(const io::path& filename) const; | ||
34 | |||
35 | //! creates/loads an animated mesh from the file. | ||
36 | //! \return Pointer to the created mesh. Returns 0 if loading failed. | ||
37 | //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). | ||
38 | //! See IReferenceCounted::drop() for more information. | ||
39 | virtual IAnimatedMesh* createMesh(io::IReadFile* file); | ||
40 | |||
41 | private: | ||
42 | |||
43 | // byte-align structures | ||
44 | #include "irrpack.h" | ||
45 | |||
46 | struct ChunkHeader | ||
47 | { | ||
48 | u16 id; | ||
49 | s32 length; | ||
50 | } PACK_STRUCT; | ||
51 | |||
52 | // Default alignment | ||
53 | #include "irrunpack.h" | ||
54 | |||
55 | struct ChunkData | ||
56 | { | ||
57 | ChunkData() : read(0) {} | ||
58 | |||
59 | ChunkHeader header; | ||
60 | s32 read; | ||
61 | }; | ||
62 | |||
63 | struct SCurrentMaterial | ||
64 | { | ||
65 | void clear() { | ||
66 | Material=video::SMaterial(); | ||
67 | Name=""; | ||
68 | Filename[0]=""; | ||
69 | Filename[1]=""; | ||
70 | Filename[2]=""; | ||
71 | Filename[3]=""; | ||
72 | Filename[4]=""; | ||
73 | Strength[0]=0.f; | ||
74 | Strength[1]=0.f; | ||
75 | Strength[2]=0.f; | ||
76 | Strength[3]=0.f; | ||
77 | Strength[4]=0.f; | ||
78 | } | ||
79 | |||
80 | video::SMaterial Material; | ||
81 | core::stringc Name; | ||
82 | core::stringc Filename[5]; | ||
83 | f32 Strength[5]; | ||
84 | }; | ||
85 | |||
86 | struct SMaterialGroup | ||
87 | { | ||
88 | SMaterialGroup() : faceCount(0), faces(0) {}; | ||
89 | |||
90 | SMaterialGroup(const SMaterialGroup& o) | ||
91 | { | ||
92 | *this = o; | ||
93 | } | ||
94 | |||
95 | ~SMaterialGroup() | ||
96 | { | ||
97 | clear(); | ||
98 | } | ||
99 | |||
100 | void clear() | ||
101 | { | ||
102 | delete [] faces; | ||
103 | faces = 0; | ||
104 | faceCount = 0; | ||
105 | } | ||
106 | |||
107 | void operator =(const SMaterialGroup& o) | ||
108 | { | ||
109 | MaterialName = o.MaterialName; | ||
110 | faceCount = o.faceCount; | ||
111 | faces = new u16[faceCount]; | ||
112 | for (u16 i=0; i<faceCount; ++i) | ||
113 | faces[i] = o.faces[i]; | ||
114 | } | ||
115 | |||
116 | core::stringc MaterialName; | ||
117 | u16 faceCount; | ||
118 | u16* faces; | ||
119 | }; | ||
120 | |||
121 | bool readChunk(io::IReadFile* file, ChunkData* parent); | ||
122 | bool readMaterialChunk(io::IReadFile* file, ChunkData* parent); | ||
123 | bool readFrameChunk(io::IReadFile* file, ChunkData* parent); | ||
124 | bool readTrackChunk(io::IReadFile* file, ChunkData& data, | ||
125 | IMeshBuffer* mb, const core::vector3df& pivot); | ||
126 | bool readObjectChunk(io::IReadFile* file, ChunkData* parent); | ||
127 | bool readPercentageChunk(io::IReadFile* file, ChunkData* chunk, f32& percentage); | ||
128 | bool readColorChunk(io::IReadFile* file, ChunkData* chunk, video::SColor& out); | ||
129 | |||
130 | void readChunkData(io::IReadFile* file, ChunkData& data); | ||
131 | void readString(io::IReadFile* file, ChunkData& data, core::stringc& out); | ||
132 | void readVertices(io::IReadFile* file, ChunkData& data); | ||
133 | void readIndices(io::IReadFile* file, ChunkData& data); | ||
134 | void readMaterialGroup(io::IReadFile* file, ChunkData& data); | ||
135 | void readTextureCoords(io::IReadFile* file, ChunkData& data); | ||
136 | |||
137 | void composeObject(io::IReadFile* file, const core::stringc& name); | ||
138 | void loadMaterials(io::IReadFile* file); | ||
139 | void cleanUp(); | ||
140 | |||
141 | scene::ISceneManager* SceneManager; | ||
142 | io::IFileSystem* FileSystem; | ||
143 | |||
144 | f32* Vertices; | ||
145 | u16* Indices; | ||
146 | u32* SmoothingGroups; | ||
147 | core::array<u16> TempIndices; | ||
148 | f32* TCoords; | ||
149 | u16 CountVertices; | ||
150 | u16 CountFaces; // = CountIndices/4 | ||
151 | u16 CountTCoords; | ||
152 | core::array<SMaterialGroup> MaterialGroups; | ||
153 | |||
154 | SCurrentMaterial CurrentMaterial; | ||
155 | core::array<SCurrentMaterial> Materials; | ||
156 | core::array<core::stringc> MeshBufferNames; | ||
157 | core::matrix4 TransformationMatrix; | ||
158 | |||
159 | SMesh* Mesh; | ||
160 | }; | ||
161 | |||
162 | } // end namespace scene | ||
163 | } // end namespace irr | ||
164 | |||
165 | #endif | ||
166 | |||