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 // Because I (Nikolaus Gebhardt) did some changes to Murphy McCauley's loader, 6 // I'm writing this down here: 7 // - Replaced all dependencies to STL and stdio with irr:: methods/constructs 8 // - Disabled logging define 9 // - Changed some minor things (Don't remember what exactly.) 10 // Thanks a lot to Murphy McCauley for writing this loader. 11 12 // 13 // COCTLoader by Murphy McCauley (February 2005) 14 // An Irrlicht loader for OCT files 15 // 16 // OCT file format information comes from the sourcecode of the Fluid Studios 17 // Radiosity Processor by Paul Nettle. You can get that sourcecode from 18 // http://www.fluidstudios.com . 19 // 20 // Parts of this code are from Irrlicht's CQ3LevelMesh and C3DSMeshFileLoader, 21 // and are Copyright (C) 2002-2004 Nikolaus Gebhardt. 22 // 23 // Use of this code is subject to the following: 24 // 25 // This software is provided 'as-is', without any express or implied 26 // warranty. In no event will the authors be held liable for any damages 27 // arising from the use of this software. 28 // 29 // Permission is granted to anyone to use this software for any purpose, 30 // including commercial applications, and to alter it and redistribute it 31 // freely, subject to the following restrictions: 32 // 33 // 1. The origin of this software must not be misrepresented; you must not 34 // claim that you wrote the original software. If you use this software 35 // in a product, an acknowledgment in the product documentation would be 36 // appreciated but is not required. 37 // 2. Altered source versions must be plainly marked as such, and must not be 38 // misrepresented as being the original software. 39 // 3. This notice may not be removed or altered from any source distribution. 40 // 4. You may not use this software to directly or indirectly cause harm to others. 41 42 43 #ifndef __C_OCT_LOADER_H_INCLUDED__ 44 #define __C_OCT_LOADER_H_INCLUDED__ 45 46 #include "IMeshLoader.h" 47 #include "IReadFile.h" 48 #include "SMesh.h" 49 #include "irrString.h" 50 51 namespace irr 52 { 53 namespace io 54 { 55 class IFileSystem; 56 } // end namespace io 57 namespace scene 58 { 59 class ISceneManager; 60 class ISceneNode; 61 62 class COCTLoader : public IMeshLoader 63 { 64 public: 65 //! constructor 66 COCTLoader(ISceneManager* smgr, io::IFileSystem* fs); 67 68 //! destructor 69 virtual ~COCTLoader(); 70 71 //! returns true if the file maybe is able to be loaded by this class 72 //! based on the file extension (e.g. ".cob") 73 virtual bool isALoadableFileExtension(const io::path& filename) const; 74 75 //! creates/loads an animated mesh from the file. 76 //! \return Pointer to the created mesh. Returns 0 if loading failed. 77 //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). 78 //! See IReferenceCounted::drop() for more information. 79 virtual IAnimatedMesh* createMesh(io::IReadFile* file); 80 81 void OCTLoadLights(io::IReadFile* file, 82 ISceneNode * parent = 0, f32 radius = 500.0f, 83 f32 intensityScale = 0.0000001f*2.5, 84 bool rewind = true); 85 86 private: 87 struct octHeader { 88 u32 numVerts; 89 u32 numFaces; 90 u32 numTextures; 91 u32 numLightmaps; 92 u32 numLights; 93 }; 94 95 struct octHeaderEx { 96 u32 magic; // 'OCTX' - 0x4F435458L 97 u32 numLightmaps; 98 u32 lightmapWidth; 99 u32 lightmapHeight; 100 u32 containsVertexNormals; 101 }; 102 103 struct octFace { 104 u32 firstVert; 105 u32 numVerts; 106 u32 textureID; 107 u32 lightmapID; 108 f32 plane[4]; 109 }; 110 111 struct octVert { 112 f32 tc[2]; 113 f32 lc[2]; 114 f32 pos[3]; 115 }; 116 117 struct octTexture { 118 u32 id; 119 char fileName[64]; 120 }; 121 122 struct octLightmap { 123 u32 id; 124 u8 data[128][128][3]; 125 }; 126 127 struct octLight { 128 f32 pos[3]; 129 f32 color[3]; 130 u32 intensity; 131 }; 132 133 ISceneManager* SceneManager; 134 io::IFileSystem* FileSystem; 135 }; 136 137 } // end namespace scene 138 } // end namespace irr 139 140 #endif 141 142