aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/COBJMeshFileLoader.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/COBJMeshFileLoader.h244
1 files changed, 122 insertions, 122 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/COBJMeshFileLoader.h b/libraries/irrlicht-1.8/source/Irrlicht/COBJMeshFileLoader.h
index 06e71d6..0fa2ba6 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/COBJMeshFileLoader.h
+++ b/libraries/irrlicht-1.8/source/Irrlicht/COBJMeshFileLoader.h
@@ -1,122 +1,122 @@
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 4
5#ifndef __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ 5#ifndef __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__
6#define __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__ 6#define __C_OBJ_MESH_FILE_LOADER_H_INCLUDED__
7 7
8#include "IMeshLoader.h" 8#include "IMeshLoader.h"
9#include "IFileSystem.h" 9#include "IFileSystem.h"
10#include "ISceneManager.h" 10#include "ISceneManager.h"
11#include "irrString.h" 11#include "irrString.h"
12#include "SMeshBuffer.h" 12#include "SMeshBuffer.h"
13#include "irrMap.h" 13#include "irrMap.h"
14 14
15namespace irr 15namespace irr
16{ 16{
17namespace scene 17namespace scene
18{ 18{
19 19
20//! Meshloader capable of loading obj meshes. 20//! Meshloader capable of loading obj meshes.
21class COBJMeshFileLoader : public IMeshLoader 21class COBJMeshFileLoader : public IMeshLoader
22{ 22{
23public: 23public:
24 24
25 //! Constructor 25 //! Constructor
26 COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs); 26 COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs);
27 27
28 //! destructor 28 //! destructor
29 virtual ~COBJMeshFileLoader(); 29 virtual ~COBJMeshFileLoader();
30 30
31 //! returns true if the file maybe is able to be loaded by this class 31 //! returns true if the file maybe is able to be loaded by this class
32 //! based on the file extension (e.g. ".obj") 32 //! based on the file extension (e.g. ".obj")
33 virtual bool isALoadableFileExtension(const io::path& filename) const; 33 virtual bool isALoadableFileExtension(const io::path& filename) const;
34 34
35 //! creates/loads an animated mesh from the file. 35 //! creates/loads an animated mesh from the file.
36 //! \return Pointer to the created mesh. Returns 0 if loading failed. 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(). 37 //! If you no longer need the mesh, you should call IAnimatedMesh::drop().
38 //! See IReferenceCounted::drop() for more information. 38 //! See IReferenceCounted::drop() for more information.
39 virtual IAnimatedMesh* createMesh(io::IReadFile* file); 39 virtual IAnimatedMesh* createMesh(io::IReadFile* file);
40 40
41private: 41private:
42 42
43 struct SObjMtl 43 struct SObjMtl
44 { 44 {
45 SObjMtl() : Meshbuffer(0), Bumpiness (1.0f), Illumination(0), 45 SObjMtl() : Meshbuffer(0), Bumpiness (1.0f), Illumination(0),
46 RecalculateNormals(false) 46 RecalculateNormals(false)
47 { 47 {
48 Meshbuffer = new SMeshBuffer(); 48 Meshbuffer = new SMeshBuffer();
49 Meshbuffer->Material.Shininess = 0.0f; 49 Meshbuffer->Material.Shininess = 0.0f;
50 Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor(); 50 Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor();
51 Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor(); 51 Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor();
52 Meshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor(); 52 Meshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor();
53 } 53 }
54 54
55 SObjMtl(const SObjMtl& o) 55 SObjMtl(const SObjMtl& o)
56 : Name(o.Name), Group(o.Group), 56 : Name(o.Name), Group(o.Group),
57 Bumpiness(o.Bumpiness), Illumination(o.Illumination), 57 Bumpiness(o.Bumpiness), Illumination(o.Illumination),
58 RecalculateNormals(false) 58 RecalculateNormals(false)
59 { 59 {
60 Meshbuffer = new SMeshBuffer(); 60 Meshbuffer = new SMeshBuffer();
61 Meshbuffer->Material = o.Meshbuffer->Material; 61 Meshbuffer->Material = o.Meshbuffer->Material;
62 } 62 }
63 63
64 core::map<video::S3DVertex, int> VertMap; 64 core::map<video::S3DVertex, int> VertMap;
65 scene::SMeshBuffer *Meshbuffer; 65 scene::SMeshBuffer *Meshbuffer;
66 core::stringc Name; 66 core::stringc Name;
67 core::stringc Group; 67 core::stringc Group;
68 f32 Bumpiness; 68 f32 Bumpiness;
69 c8 Illumination; 69 c8 Illumination;
70 bool RecalculateNormals; 70 bool RecalculateNormals;
71 }; 71 };
72 72
73 // helper method for material reading 73 // helper method for material reading
74 const c8* readTextures(const c8* bufPtr, const c8* const bufEnd, SObjMtl* currMaterial, const io::path& relPath); 74 const c8* readTextures(const c8* bufPtr, const c8* const bufEnd, SObjMtl* currMaterial, const io::path& relPath);
75 75
76 // returns a pointer to the first printable character available in the buffer 76 // returns a pointer to the first printable character available in the buffer
77 const c8* goFirstWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines=true); 77 const c8* goFirstWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines=true);
78 // returns a pointer to the first printable character after the first non-printable 78 // returns a pointer to the first printable character after the first non-printable
79 const c8* goNextWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines=true); 79 const c8* goNextWord(const c8* buf, const c8* const bufEnd, bool acrossNewlines=true);
80 // returns a pointer to the next printable character after the first line break 80 // returns a pointer to the next printable character after the first line break
81 const c8* goNextLine(const c8* buf, const c8* const bufEnd); 81 const c8* goNextLine(const c8* buf, const c8* const bufEnd);
82 // copies the current word from the inBuf to the outBuf 82 // copies the current word from the inBuf to the outBuf
83 u32 copyWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); 83 u32 copyWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd);
84 // copies the current line from the inBuf to the outBuf 84 // copies the current line from the inBuf to the outBuf
85 core::stringc copyLine(const c8* inBuf, const c8* const bufEnd); 85 core::stringc copyLine(const c8* inBuf, const c8* const bufEnd);
86 86
87 // combination of goNextWord followed by copyWord 87 // combination of goNextWord followed by copyWord
88 const c8* goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd); 88 const c8* goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 outBufLength, const c8* const pBufEnd);
89 89
90 //! Read the material from the given file 90 //! Read the material from the given file
91 void readMTL(const c8* fileName, const io::path& relPath); 91 void readMTL(const c8* fileName, const io::path& relPath);
92 92
93 //! Find and return the material with the given name 93 //! Find and return the material with the given name
94 SObjMtl* findMtl(const core::stringc& mtlName, const core::stringc& grpName); 94 SObjMtl* findMtl(const core::stringc& mtlName, const core::stringc& grpName);
95 95
96 //! Read RGB color 96 //! Read RGB color
97 const c8* readColor(const c8* bufPtr, video::SColor& color, const c8* const pBufEnd); 97 const c8* readColor(const c8* bufPtr, video::SColor& color, const c8* const pBufEnd);
98 //! Read 3d vector of floats 98 //! Read 3d vector of floats
99 const c8* readVec3(const c8* bufPtr, core::vector3df& vec, const c8* const pBufEnd); 99 const c8* readVec3(const c8* bufPtr, core::vector3df& vec, const c8* const pBufEnd);
100 //! Read 2d vector of floats 100 //! Read 2d vector of floats
101 const c8* readUV(const c8* bufPtr, core::vector2df& vec, const c8* const pBufEnd); 101 const c8* readUV(const c8* bufPtr, core::vector2df& vec, const c8* const pBufEnd);
102 //! Read boolean value represented as 'on' or 'off' 102 //! Read boolean value represented as 'on' or 'off'
103 const c8* readBool(const c8* bufPtr, bool& tf, const c8* const bufEnd); 103 const c8* readBool(const c8* bufPtr, bool& tf, const c8* const bufEnd);
104 104
105 // reads and convert to integer the vertex indices in a line of obj file's face statement 105 // reads and convert to integer the vertex indices in a line of obj file's face statement
106 // -1 for the index if it doesn't exist 106 // -1 for the index if it doesn't exist
107 // indices are changed to 0-based index instead of 1-based from the obj file 107 // indices are changed to 0-based index instead of 1-based from the obj file
108 bool retrieveVertexIndices(c8* vertexData, s32* idx, const c8* bufEnd, u32 vbsize, u32 vtsize, u32 vnsize); 108 bool retrieveVertexIndices(c8* vertexData, s32* idx, const c8* bufEnd, u32 vbsize, u32 vtsize, u32 vnsize);
109 109
110 void cleanUp(); 110 void cleanUp();
111 111
112 scene::ISceneManager* SceneManager; 112 scene::ISceneManager* SceneManager;
113 io::IFileSystem* FileSystem; 113 io::IFileSystem* FileSystem;
114 114
115 core::array<SObjMtl*> Materials; 115 core::array<SObjMtl*> Materials;
116}; 116};
117 117
118} // end namespace scene 118} // end namespace scene
119} // end namespace irr 119} // end namespace irr
120 120
121#endif 121#endif
122 122