-
Notifications
You must be signed in to change notification settings - Fork 36
/
ThemeDefault.cpp
287 lines (219 loc) · 6.87 KB
/
ThemeDefault.cpp
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#include "ThemeDefault.h"
//#include <Windows.h>
//#include <gl/GL.h>
#include "GLee.h"
#include <gl/GLU.h>
#include <IL/il.h>
#include <IL/ilut.h>
#include "NeHeGL.h" // for g_window
ThemeDefault::ThemeDefault(void)
{
m_fTileOffsetGap = 2.2f;
m_sThemeName = "Default";
}
ThemeDefault::~ThemeDefault(void)
{
}
// setup any theme related resources
void ThemeDefault::SetupTheme(void)
{
// crate
m_CrateModel.LoadModel("crate1.3ds", (char *)GetFullAssetDirectory().c_str());
// wall
m_WallModel.LoadModel("5x5wall.3ds", (char *)GetFullAssetDirectory().c_str());
// floor
m_FloorModel.LoadModel("floor1.3ds", (char *)GetFullAssetDirectory().c_str());
// sky box
m_SkyboxModel.LoadModel("skysphere.3ds", (char *)GetFullAssetDirectory().c_str());
}
// un-setup any theme related resources
void ThemeDefault::DestroyTheme(void)
{
// crate
// glDeleteTextures(1, &m_CrateTextureID);
}
// Operations before the scene has been rendered
void ThemeDefault::PreRender(void)
{
//glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
}
// Operations after the scene has been rendered
void ThemeDefault::PostRender(void)
{
// DisplayAxis();
//glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
}
// Render the floor tile
void ThemeDefault::RenderTileFloor(float X, float Y)
{
X = (X + 1.0f) * m_fTileOffsetGap;
Y = (Y + 1.0f) * m_fTileOffsetGap;
float Z = 0.0f;
//glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glPushMatrix();
glTranslatef(X, Z, Y); //
glColor3f(1.0f,1.0f,1.0f); // white
//m_FloorModel.RenderModel();
glBegin(GL_QUADS); //
glVertex3f( 1.0f, 0.0f,-1.0f); // Bottom Right
glVertex3f(-1.0f, 0.0f,-1.0f); // Bottom Left
glVertex3f(-1.0f, 0.0f, 1.0f); // Top Left
glVertex3f( 1.0f, 0.0f, 1.0f); // Top Right
glEnd(); //
glPopMatrix();
}
// Render the wall tile
void ThemeDefault::RenderTileWall(float X, float Y)
{
X = (X + 1.0f) * m_fTileOffsetGap;
Y = (Y + 1.0f) * m_fTileOffsetGap;
float Z = 0.0f;
glEnable(GL_LIGHTING);
//glEnable(GL_TEXTURE_2D);
glPushMatrix();
glTranslatef(X, Z, Y); //
/*glColor3f(0.5f,0.5f,1.0f); // blue
glBegin(GL_QUADS); //
glVertex3f( 1.0f, 0.0f,-1.0f); // Bottom Right
glVertex3f(-1.0f, 0.0f,-1.0f); // Bottom Left
glVertex3f(-1.0f, 0.0f, 1.0f); // Top Left
glVertex3f( 1.0f, 0.0f, 1.0f); // Top Right*/
//glEnd(); //
//glScalef(m_fTileOffsetGap / 2.0f, 1.0f, m_fTileOffsetGap / 2.0f);
m_WallModel.RenderModel();
glPopMatrix();
//glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
}
// Render the void tile
void ThemeDefault::RenderTileVoid(float X, float Y)
{
X = (X + 1.0f) * m_fTileOffsetGap;
Y = (Y + 1.0f) * m_fTileOffsetGap;
float Z = 0.0f;
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(X, Z, Y); //
glColor3f(0.2f, 0.8f, 0.0f);
glBegin(GL_QUADS); //
glVertex3f( 1.0f, 0.0f,-1.0f); // Bottom Right
glVertex3f(-1.0f, 0.0f,-1.0f); // Bottom Left
glVertex3f(-1.0f, 0.0f, 1.0f); // Top Left
glVertex3f( 1.0f, 0.0f, 1.0f); // Top Right
glEnd(); //
glPopMatrix();
glDisable(GL_LIGHTING);
}
// Render the void tile
void ThemeDefault::RenderItemTarget(float X, float Y)
{
X = (X + 1.0f) * m_fTileOffsetGap;
Y = (Y + 1.0f) * m_fTileOffsetGap;
float Z = 0.0002f;
glPushMatrix();
glTranslatef(X, Z, Y); //
glColor3f(0.2f, 1.0f, 0.2f); // light green
glScalef(0.85f, 0.85f, 0.85f);
glBegin(GL_QUADS); //
glVertex3f( 1.0f, 0.0f,-1.0f); // Bottom Right
glVertex3f(-1.0f, 0.0f,-1.0f); // Bottom Left
glVertex3f(-1.0f, 0.0f, 1.0f); // Top Left
glVertex3f( 1.0f, 0.0f, 1.0f); // Top Right
glEnd(); //
glPopMatrix();
}
// Render the crate tile
void ThemeDefault::RenderItemCrate(float X, float Y)
{
X = (X + 1.0f) * m_fTileOffsetGap;
Y = (Y + 1.0f) * m_fTileOffsetGap;
//Z = 0.75f;
float Z=0.0f;
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(X, Z, Y); //
m_CrateModel.RenderModel();
glPopMatrix();
glDisable(GL_LIGHTING);
return;
/* glColor3f(1.0f,1.0f,0.0f); // yellow
glScalef(0.75f, 0.75f, 0.75f); // half size
glEnable(GL_TEXTURE_2D);
glColor3ub(255, 255, 255);
glBindTexture(GL_TEXTURE_2D, m_CrateTextureID);
glBegin(GL_QUADS);
// Front Face
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Back Face
glNormal3f( 0.0f, 0.0f,-1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// Top Face
glNormal3f( 0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Bottom Face
glNormal3f( 0.0f,-1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// Right face
glNormal3f( 1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// Left Face
glNormal3f(-1.0f, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);*/
}
// Render the void tile
void ThemeDefault::RenderItemPlayer(float X, float Y)
{
static GLUquadricObj* PlayerSphere = gluNewQuadric();
X = (X + 1.0f) * m_fTileOffsetGap;
Y = (Y + 1.0f) * m_fTileOffsetGap;
float Z = 0.5f;
glEnable(GL_LIGHTING);
glPushMatrix();
// draw body
glTranslatef(X, Z, Y); //
glColor3f(0.5f, 0.5f, 0.5f); // light grey
gluSphere(PlayerSphere, 0.85, 8, 8);
// draw head
glTranslatef(0.0f,1.0f,0.0f);
glColor3f(0.9f, 0.9f, 0.9f); // white
gluSphere(PlayerSphere, 0.50, 8, 8);
glPopMatrix();
glDisable(GL_LIGHTING);
}
// Render the surrounding scene
void ThemeDefault::RenderSurroundingScene(float X, float Y, float Z, float fLevelWidth)
{
glPushMatrix();
// glTranslatef(X+20, Y, Z+20);
CVector3 Pos;
Pos = g_camera->Position();
glTranslatef(Pos.x, Pos.y, Pos.z);
glScalef(5.0f, 5.0f, 5.0f);
m_SkyboxModel.RenderModel();
glPopMatrix();
}