-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scene.cpp
86 lines (70 loc) · 1.75 KB
/
Scene.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
#include "Scene.h"
#include "Objects.h"
#include <time.h>
#include <fstream>
#include <iostream>
#include <sstream>
using namespace std;
// Active global color
float r,g,b;
// Main drawing function
void renderScene(void)
{
// Compute position if we move forward or left or right
if (deltaMove || lstrafe || rstrafe)
computePos(deltaMove);
// Clear color and set background to blue sky
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0.3, 1.0f);
// Sets up viewing
// Eye is at recorded position x, y, z
// We are looking in the direction vx, vy, vz
// The up vector is in y direction
glLoadIdentity();
gluLookAt( x, y, z,
x+vx, y+vy, z+vz,
0.0f, 1.0f, 0.0f );
// Roll the camera as required by roll amount
glTranslatef(x,y,z);
glRotatef(rollamount, vx, vy, vz);
glTranslatef(-x, -y, -z);
// Draw green grass
glColor3f(0.0f, 0.65f, 0.15f);
glBegin(GL_QUADS);
glVertex3f(-100.0f, -0.01f, -100.0f);
glVertex3f(-100.0f, -0.01f, 100.0f);
glVertex3f( 100.0f, -0.01f, 100.0f);
glVertex3f( 100.0f, -0.01f, -100.0f);
glEnd();
//All drawing routines
drawHouseBoundary();
drawHouseWalls();
drawTiles();
furnishBathroom();
furnishBedroom();
furnishKitchen();
furnishLivingRoom();
drawCeiling();
if(parachutejump)
{
printf("%f\n",y);
y -= 0.5;
if(y<=3)
parachutejump = 0;
}
glutSwapBuffers();
//Switch off interact toggle after drawing all objects
interact = 0;
}
int main(int argc, char **argv)
{
// Initialize graphics and plant a random seed
initGraphics(argc, argv);
srand(time(NULL));
// renderScene will be our main drawing routine invoked everytime
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);
// Start the scene
glutMainLoop();
return 0;
}