1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __C_3DS_MESH_FILE_LOADER_H_INCLUDED__
6
#define __C_3DS_MESH_FILE_LOADER_H_INCLUDED__
8
#include "IMeshLoader.h"
9
#include "IFileSystem.h"
10
#include "ISceneManager.h"
11
#include "irrString.h"
20
//! Meshloader capable of loading 3ds meshes.
21
class C3DSMeshFileLoader : public IMeshLoader
26
C3DSMeshFileLoader(ISceneManager* smgr, io::IFileSystem* fs);
29
virtual ~C3DSMeshFileLoader();
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;
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);
43
// byte-align structures
44
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
45
# pragma pack( push, packing )
48
#elif defined( __GNUC__ )
49
# define PACK_STRUCT __attribute__((packed))
51
# error compiler not supported
61
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
62
# pragma pack( pop, packing )
70
ChunkData() : read(0) {}
76
struct SCurrentMaterial
79
Material=video::SMaterial();
93
video::SMaterial Material;
95
core::stringc Filename[5];
101
SMaterialGroup() : faceCount(0), faces(0) {};
103
SMaterialGroup(const SMaterialGroup& o)
120
void operator =(const SMaterialGroup& o)
122
MaterialName = o.MaterialName;
123
faceCount = o.faceCount;
124
faces = new u16[faceCount];
125
for (u32 i=0; i<faceCount; ++i)
126
faces[i] = o.faces[i];
129
core::stringc MaterialName;
134
bool readChunk(io::IReadFile* file, ChunkData* parent);
135
bool readMaterialChunk(io::IReadFile* file, ChunkData* parent);
136
bool readFrameChunk(io::IReadFile* file, ChunkData* parent);
137
bool readTrackChunk(io::IReadFile* file, ChunkData& data,
138
IMeshBuffer* mb, const core::vector3df& pivot);
139
bool readObjectChunk(io::IReadFile* file, ChunkData* parent);
140
bool readPercentageChunk(io::IReadFile* file, ChunkData* chunk, f32& percentage);
141
bool readColorChunk(io::IReadFile* file, ChunkData* chunk, video::SColor& out);
143
void readChunkData(io::IReadFile* file, ChunkData& data);
144
void readString(io::IReadFile* file, ChunkData& data, core::stringc& out);
145
void readVertices(io::IReadFile* file, ChunkData& data);
146
void readIndices(io::IReadFile* file, ChunkData& data);
147
void readMaterialGroup(io::IReadFile* file, ChunkData& data);
148
void readTextureCoords(io::IReadFile* file, ChunkData& data);
150
void composeObject(io::IReadFile* file, const core::stringc& name);
151
void loadMaterials(io::IReadFile* file);
154
scene::ISceneManager* SceneManager;
155
io::IFileSystem* FileSystem;
159
u32* SmoothingGroups;
160
core::array<u16> TempIndices;
163
u16 CountFaces; // = CountIndices/4
165
core::array<SMaterialGroup> MaterialGroups;
167
SCurrentMaterial CurrentMaterial;
168
core::array<SCurrentMaterial> Materials;
169
core::array<core::stringc> MeshBufferNames;
170
core::matrix4 TransformationMatrix;
175
} // end namespace scene
176
} // end namespace irr