-
Notifications
You must be signed in to change notification settings - Fork 2
/
Render.h
140 lines (108 loc) · 2.87 KB
/
Render.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef _RENDER_H_
#define _RENDER_H_
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include "Ogre.h"
#include "OgreConfigFile.h"
#include "CrowdObject.h"
#include "constants.h"
#include "Agent.h"
// Static plugins declaration section
// Note that every entry in here adds an extra header / library dependency
#ifdef OGRE_STATIC_LIB
# define OGRE_STATIC_GL
# if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
# define OGRE_STATIC_Direct3D9
// dx10 will only work on vista, so be careful about statically linking
# if OGRE_USE_D3D10
# define OGRE_STATIC_Direct3D10
# endif
# if OGRE_USE_D3D11
# define OGRE_STATIC_Direct3D11
# endif
# endif
# define OGRE_STATIC_BSPSceneManager
# define OGRE_STATIC_ParticleFX
# define OGRE_STATIC_CgProgramManager
# ifdef OGRE_USE_PCZ
# define OGRE_STATIC_PCZSceneManager
# define OGRE_STATIC_OctreeZone
# else
# define OGRE_STATIC_OctreeSceneManager
# endif
# if OGRE_PLATFORM == OGRE_PLATFORM_IPHONE
# undef OGRE_STATIC_CgProgramManager
# undef OGRE_STATIC_GL
# define OGRE_STATIC_GLES 1
# ifdef __OBJC__
# import <UIKit/UIKit.h>
# endif
# endif
# include "OgreStaticPluginLoader.h"
#endif
/* Render is a class that will take care of Rendering the world in our program
* It is a singleton.
*/
using namespace std;
class DrawObject {
protected:
//pointer to object to be rendered
Ogre::SceneNode * node;
Ogre::Entity * entity;
public:
DrawObject();
DrawObject( string m );
void createEntity(string meshname);
//possibly needs to be pure-virtual
virtual void update() = 0;
};
class DrawAgent : public DrawObject {
private:
Agent::Agent * a;
public:
DrawAgent();
DrawAgent(Agent::Agent * a, string meshname);
void update();
};
class DrawWall : public DrawObject {
private:
Wall::Wall * w;
public:
DrawWall();
DrawWall( Wall::Wall * wall, string meshname);
void update();
};
class Render {
private:
//Ogre objects
Ogre::Root * root;
Ogre::SceneManager * sceneMgr;
Ogre::Camera * cam;
//used to generate names
int namenum;
//singleton maintenance
static Render * instance;
Render();
~Render();
std::vector<DrawObject *> drawObjects;
bool initialized;
public:
//singleton maintenance
static Render * getInstance();
static Render * destroyInstance();
//creates a new Entity
Ogre::Entity * newEntity( string name, string model);
//attaches an entity to render. Returns the node to which the entity is attached
Ogre::SceneNode * attach(string nodename, Ogre::Entity * e);
//generates a unique name from the current render context
string generateName();
void drawThis( Agent::Agent * a, string meshname);
void drawThis( Wall::Wall * w, string meshname);
//updates i.e. renders to the screen
void update(float deltaTime);
bool isInitialized();
};
#endif