aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CB3DMeshFileLoader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CB3DMeshFileLoader.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CB3DMeshFileLoader.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CB3DMeshFileLoader.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CB3DMeshFileLoader.h
new file mode 100644
index 0000000..6b3d4b8
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CB3DMeshFileLoader.h
@@ -0,0 +1,140 @@
1// Copyright (C) 2006-2012 Luke Hoschke
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5// B3D Mesh loader
6// File format designed by Mark Sibly for the Blitz3D engine and has been
7// declared public domain
8
9#include "IrrCompileConfig.h"
10
11#ifndef __C_B3D_MESH_LOADER_H_INCLUDED__
12#define __C_B3D_MESH_LOADER_H_INCLUDED__
13
14#include "IMeshLoader.h"
15#include "ISceneManager.h"
16#include "CSkinnedMesh.h"
17#include "IReadFile.h"
18
19namespace irr
20{
21
22namespace scene
23{
24
25//! Meshloader for B3D format
26class CB3DMeshFileLoader : public IMeshLoader
27{
28public:
29
30 //! Constructor
31 CB3DMeshFileLoader(scene::ISceneManager* smgr);
32
33 //! returns true if the file maybe is able to be loaded by this class
34 //! based on the file extension (e.g. ".bsp")
35 virtual bool isALoadableFileExtension(const io::path& filename) const;
36
37 //! creates/loads an animated mesh from the file.
38 //! \return Pointer to the created mesh. Returns 0 if loading failed.
39 //! If you no longer need the mesh, you should call IAnimatedMesh::drop().
40 //! See IReferenceCounted::drop() for more information.
41 virtual IAnimatedMesh* createMesh(io::IReadFile* file);
42
43private:
44
45 struct SB3dChunkHeader
46 {
47 c8 name[4];
48 s32 size;
49 };
50
51 struct SB3dChunk
52 {
53 SB3dChunk(const SB3dChunkHeader& header, long sp)
54 : length(header.size+8), startposition(sp)
55 {
56 name[0]=header.name[0];
57 name[1]=header.name[1];
58 name[2]=header.name[2];
59 name[3]=header.name[3];
60 }
61
62 c8 name[4];
63 s32 length;
64 long startposition;
65 };
66
67 struct SB3dTexture
68 {
69 core::stringc TextureName;
70 s32 Flags;
71 s32 Blend;
72 f32 Xpos;
73 f32 Ypos;
74 f32 Xscale;
75 f32 Yscale;
76 f32 Angle;
77 };
78
79 struct SB3dMaterial
80 {
81 SB3dMaterial() : red(1.0f), green(1.0f),
82 blue(1.0f), alpha(1.0f), shininess(0.0f), blend(1),
83 fx(0)
84 {
85 for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i)
86 Textures[i]=0;
87 }
88 video::SMaterial Material;
89 f32 red, green, blue, alpha;
90 f32 shininess;
91 s32 blend,fx;
92 SB3dTexture *Textures[video::MATERIAL_MAX_TEXTURES];
93 };
94
95 bool load();
96 bool readChunkNODE(CSkinnedMesh::SJoint* InJoint);
97 bool readChunkMESH(CSkinnedMesh::SJoint* InJoint);
98 bool readChunkVRTS(CSkinnedMesh::SJoint* InJoint);
99 bool readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 Vertices_Start);
100 bool readChunkBONE(CSkinnedMesh::SJoint* InJoint);
101 bool readChunkKEYS(CSkinnedMesh::SJoint* InJoint);
102 bool readChunkANIM();
103 bool readChunkTEXS();
104 bool readChunkBRUS();
105
106 void loadTextures(SB3dMaterial& material) const;
107
108 void readString(core::stringc& newstring);
109 void readFloats(f32* vec, u32 count);
110
111 core::array<SB3dChunk> B3dStack;
112
113 core::array<SB3dMaterial> Materials;
114 core::array<SB3dTexture> Textures;
115
116 core::array<s32> AnimatedVertices_VertexID;
117
118 core::array<s32> AnimatedVertices_BufferID;
119
120 core::array<video::S3DVertex2TCoords> BaseVertices;
121
122 ISceneManager* SceneManager;
123 CSkinnedMesh* AnimatedMesh;
124 io::IReadFile* B3DFile;
125
126 //B3Ds have Vertex ID's local within the mesh I don't want this
127 // Variable needs to be class member due to recursion in calls
128 u32 VerticesStart;
129
130 bool NormalsInFile;
131 bool HasVertexColors;
132 bool ShowWarning;
133};
134
135
136} // end namespace scene
137} // end namespace irr
138
139#endif // __C_B3D_MESH_LOADER_H_INCLUDED__
140