1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 // This file was originally written by ZDimitor.
\r
6 // I (Nikolaus Gebhardt) did some few changes to this:
\r
7 // - replaced logging calls to their os:: counterparts
\r
8 // - removed some logging calls
\r
9 // - removed setTexture path and replaced it with the directory of the mesh
\r
10 // - added EAMT_MY3D file type
\r
11 // - fixed a memory leak when decompressing RLE data.
\r
12 // - cleaned multi character constant problems with gcc
\r
13 // - removed octree child scene node generation because irrlicht is now able to draw
\r
14 // scene nodes with transparent and sold materials in them at the same time. (see changes.txt)
\r
15 // Thanks a lot to ZDimitor for his work on this and that he gave me
\r
16 // his permission to add it into Irrlicht.
\r
18 //--------------------------------------------------------------------------------
\r
19 // This tool created by ZDimitor everyone can use it as wants
\r
20 //--------------------------------------------------------------------------------
\r
22 #ifndef __CMY3D_MESH_FILE_LOADER_H_INCLUDED__
\r
23 #define __CMY3D_MESH_FILE_LOADER_H_INCLUDED__
\r
31 #include "IMeshLoader.h"
\r
33 #include "SMeshBufferLightMap.h"
\r
34 #include "IFileSystem.h"
\r
35 #include "IVideoDriver.h"
\r
36 #include "irrString.h"
\r
37 #include "ISceneManager.h"
\r
44 // byte-align structures
\r
45 #include "irrpack.h"
\r
49 SMyColor (s32 __R, s32 __G, s32 __B, s32 __A)
\r
50 : R(__R), G(__G), B(__B), A(__A) {}
\r
55 struct SMyMaterialHeader
\r
56 { c8 Name[256]; // material name
\r
58 SMyColor AmbientColor;
\r
59 SMyColor DiffuseColor;
\r
60 SMyColor EmissiveColor;
\r
61 SMyColor SpecularColor;
\r
64 u32 TextureCount; // texture count
\r
67 // Default alignment
\r
68 #include "irrunpack.h"
\r
70 class CMY3DMeshFileLoader : public IMeshLoader
\r
73 CMY3DMeshFileLoader(ISceneManager *scmgr, io::IFileSystem* fs);
\r
74 virtual ~CMY3DMeshFileLoader();
\r
76 virtual bool isALoadableFileExtension(const io::path& filename) const _IRR_OVERRIDE_;
\r
78 virtual IAnimatedMesh* createMesh(io::IReadFile* file) _IRR_OVERRIDE_;
\r
80 //! getting access to the nodes (with transparent material), creating
\r
81 //! while loading .my3d file
\r
82 const core::array<ISceneNode*>& getChildNodes() const;
\r
86 video::ITexture* readEmbeddedLightmap(io::IReadFile* file, char* namebuf);
\r
88 scene::ISceneManager* SceneManager;
\r
89 io::IFileSystem* FileSystem;
\r
91 struct SMyMaterialEntry
\r
94 : Texture1FileName("null"), Texture2FileName("null"),
\r
95 Texture1(0), Texture2(0), MaterialType(video::EMT_SOLID) {
\r
99 SMyMaterialHeader Header;
\r
100 core::stringc Texture1FileName;
\r
101 core::stringc Texture2FileName;
\r
102 video::ITexture *Texture1;
\r
103 video::ITexture *Texture2;
\r
104 video::E_MATERIAL_TYPE MaterialType;
\r
107 struct SMyMeshBufferEntry
\r
109 SMyMeshBufferEntry() : MaterialIndex(-1), MeshBuffer(0) {}
\r
110 SMyMeshBufferEntry(s32 mi, SMeshBufferLightMap* mb)
\r
111 : MaterialIndex(mi), MeshBuffer(mb) {}
\r
114 SMeshBufferLightMap* MeshBuffer;
\r
117 SMyMaterialEntry* getMaterialEntryByIndex (u32 matInd);
\r
118 SMeshBufferLightMap* getMeshBufferByMaterialIndex(u32 matInd);
\r
120 core::array<SMyMaterialEntry> MaterialEntry;
\r
121 core::array<SMyMeshBufferEntry> MeshBufferEntry;
\r
123 core::array<ISceneNode*> ChildNodes;
\r
127 } // end namespace scene
\r
128 } // end namespace irr
\r
131 #endif // __CMY3D_MESH_FILE_LOADER_H_INCLUDED__
\r