-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscene.h
108 lines (85 loc) · 2.16 KB
/
scene.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/********************************************************************
created: 2010/04/13
file name: scene.h
author: maxint [email protected]
*********************************************************************/
#ifndef _RT_SCENE_H_
#define _RT_SCENE_H_
#include "common.h"
#include <vector>
#include <list>
namespace trimeshVec{
class CAccessObj;
}
namespace RayTracer {
class Primitive;
class Vertex;
class Light;
// ------------------------------------------------------------------------------
// Scene class definition
// ------------------------------------------------------------------------------
class Scene
{
public:
Scene();
~Scene();
/** Initialization
Create some primitives
*/
void initScene();
int getNumOfPrimitives() const
{
return static_cast<int>(mPrimitives.size());
}
int getNumOfLights() const
{
return static_cast<int>(mLights.size());
}
const AABB& getExtends() const
{
return mExtends;
}
/** Load obj model file
*/
void loadObjModel(const trimeshVec::CAccessObj* accessObj);
friend class Engine;
private:
void setupMaterials();
/** Destroy the primitives and release the resources.
*/
void destroy();
/** Setup lights
*/
void setupLights();
/** Destroy lights
*/
void destroyLights();
/** Find extends of the primitives
*/
void updateExtends();
/** Build the grid of the primitives
*/
void buildGrid();
void removeGrid();
private:
typedef std::list<Primitive*> PrimitiveList;
typedef PrimitiveList::iterator PrimListItor;
typedef std::list<Primitive*> ObjectList;
typedef ObjectList::iterator ObjectItor;
typedef std::vector<ObjectList*> GridMap;
typedef GridMap::iterator GridMapItor;
typedef std::list<Vertex*> VertexList;
typedef VertexList::iterator VertexItor;
typedef std::list<Light*> LightList;
typedef LightList::iterator LightItor;
private:
PrimitiveList mPrimitives;
LightList mLights;
GridMap mGird;
AABB mExtends;
/// obj model loader
const trimeshVec::CAccessObj* mObjLoader;
VertexList mVerticesPool;
};
}; // namespace RayTracer
#endif // _RT_SCENE_H_