-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScene.h
70 lines (54 loc) · 1.44 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
#ifndef __SCENE__
#define __SCENE__
#include "PreHeader.h"
#include "SkyBox.h"
#include "Input.h"
#include "Light.h"
#include "Geometry.h"
#include "Terrain.h"
class Camera;
class QTree;
class Scene
{
public:
Camera *camera; //通过照相机获得视图矩阵
XMFLOAT4X4 proj; //投影矩阵
protected:
typedef uint64_t Key;
typedef shared_ptr<RenderableThing> Val;
typedef unordered_map<Key, Val> RenderTable;
Input input;
RenderTable renderTable; //场景中所有可渲染的物件
vector<Val> visiableTable; //场景中可见物体
shared_ptr<SkyBox> skyBox; //天空盒
shared_ptr<Terrain> terrain; //地形
shared_ptr<Light> light;
QTree *qTree; //四叉树,用于可见性测试
public:
Scene();
virtual ~Scene();
void Init(const Rect &);
//添加一个场景中的物体
void AddRenderableThing(RenderableThing& );
//删除一个场景中的物体
void DeleteRenderableThing(RenderableThing& );
//添加天空盒子
void AddSky(SkyBox* );
//添加地形
void AddTerrain(Terrain *);
//跟新场景中的物体
virtual void Update(double time);
//处理输入信息
virtual void HandleInput(Input *);
//添加灯光
void AddLight(Light *);
//渲染场景中的物体
void Draw();
void Release();
private:
//能否被看见
void VisibleTest();
//展开物体和它的子节点
void UnfoldChildren(Val& );
};
#endif