aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CBSPMeshFileLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CBSPMeshFileLoader.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CBSPMeshFileLoader.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CBSPMeshFileLoader.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CBSPMeshFileLoader.cpp
new file mode 100644
index 0000000..01ac04a
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CBSPMeshFileLoader.cpp
@@ -0,0 +1,107 @@
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#include "IrrCompileConfig.h"
6#ifdef _IRR_COMPILE_WITH_BSP_LOADER_
7
8#include "CBSPMeshFileLoader.h"
9#include "CQ3LevelMesh.h"
10
11namespace irr
12{
13namespace scene
14{
15
16//! Constructor
17CBSPMeshFileLoader::CBSPMeshFileLoader(scene::ISceneManager* smgr,
18 io::IFileSystem* fs)
19: FileSystem(fs), SceneManager(smgr)
20{
21
22 #ifdef _DEBUG
23 setDebugName("CBSPMeshFileLoader");
24 #endif
25
26 if (FileSystem)
27 FileSystem->grab();
28}
29
30
31//! destructor
32CBSPMeshFileLoader::~CBSPMeshFileLoader()
33{
34 if (FileSystem)
35 FileSystem->drop();
36}
37
38
39//! returns true if the file maybe is able to be loaded by this class
40//! based on the file extension (e.g. ".bsp")
41bool CBSPMeshFileLoader::isALoadableFileExtension(const io::path& filename) const
42{
43 return core::hasFileExtension ( filename, "bsp", "shader", "cfg" );
44}
45
46
47//! creates/loads an animated mesh from the file.
48//! \return Pointer to the created mesh. Returns 0 if loading failed.
49//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
50//! See IReferenceCounted::drop() for more information.
51IAnimatedMesh* CBSPMeshFileLoader::createMesh(io::IReadFile* file)
52{
53 s32 type = core::isFileExtension ( file->getFileName(), "bsp", "shader", "cfg" );
54 CQ3LevelMesh* q = 0;
55
56 switch ( type )
57 {
58 case 1:
59 q = new CQ3LevelMesh(FileSystem, SceneManager, LoadParam);
60
61 // determine real shaders in LoadParam
62 if ( 0 == LoadParam.loadAllShaders )
63 {
64 q->getShader("scripts/common.shader");
65 q->getShader("scripts/sfx.shader");
66 q->getShader("scripts/gfx.shader");
67 q->getShader("scripts/liquid.shader");
68 q->getShader("scripts/models.shader");
69 q->getShader("scripts/walls.shader");
70 //q->getShader("scripts/sky.shader");
71 }
72
73 if ( q->loadFile(file) )
74 return q;
75
76 q->drop();
77 break;
78
79 case 2:
80 q = new CQ3LevelMesh(FileSystem, SceneManager,LoadParam);
81 q->getShader( file );
82 return q;
83 break;
84
85 case 3:
86 // load quake 3 loading parameter
87 if ( file->getFileName() == "levelparameter.cfg" )
88 {
89 file->read ( &LoadParam, sizeof ( LoadParam ) );
90 }
91 else
92 {
93 q = new CQ3LevelMesh(FileSystem, SceneManager,LoadParam);
94 q->getConfiguration( file );
95 return q;
96 }
97 break;
98 }
99
100 return 0;
101}
102
103} // end namespace scene
104} // end namespace irr
105
106#endif // _IRR_COMPILE_WITH_BSP_LOADER_
107