~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CBSPMeshFileLoader.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 
 
5
#include "IrrCompileConfig.h"
 
6
#ifdef _IRR_COMPILE_WITH_BSP_LOADER_
 
7
 
 
8
#include "CBSPMeshFileLoader.h"
 
9
#include "CQ3LevelMesh.h"
 
10
 
 
11
namespace irr
 
12
{
 
13
namespace scene
 
14
{
 
15
 
 
16
//! Constructor
 
17
CBSPMeshFileLoader::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
 
32
CBSPMeshFileLoader::~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")
 
41
bool 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.
 
51
IAnimatedMesh* 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