-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathworld.cpp
More file actions
160 lines (125 loc) · 4.17 KB
/
Copy pathworld.cpp
File metadata and controls
160 lines (125 loc) · 4.17 KB
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
#include "world.h"
/**********************************************************************/
/** \file world.cpp
\brief The CWorld class implementation */
/**********************************************************************/
/** CWorld constructor
***********************************************************************/
CWorld::CWorld()
{
terrain = new CTerrain(256, 0.5);
}
/**********************************************************************/
/** CWorld destructor
***********************************************************************/
CWorld::~CWorld()
{
delete terrain;
delete audioSystem;
delete worldSound;
}
/**********************************************************************/
/** CWorld constructor
***********************************************************************/
CWorld::CWorld(CCamera *c)
{
camera = c;
terrain = new CTerrain(256, 0.6f);
enemy = new CEntity;
enemy2 = new CEntity;
enemy3 = new CEntity;
//nivel= new CNivel("models\\final3.bsp");
nivel= new CNivel("models\\final3.bsp");
msg=new CFont("Arial", 16);
frames_por_segundo=new CFont("Arial", 16);
temporizador=new CHiResTimer;
audioSystem = new CAudioSystem;
temporizador->Init();
enemy->AttachTo(terrain);
enemy2->AttachTo(terrain);
worldSound = audioSystem->Create("sounds\\musica.ogg", false);
audioSystem->Play(worldSound, true);
enemy->Load("models\\sodf8\\tris.md2", "models\\sodf8\\abarlith.pcx");
enemy->SetState(MODEL_RUN);
enemy->direction = 45.0;
enemy2->Load("models\\ogro\\tris.md2", "models\\ogro\\ogrobase.pcx");
enemy2->SetState(MODEL_RUN);
enemy2->direction = 225.0;
enemy2->position = CVector(200.0, 0.0, 200.0);
enemy3->Load("models\\ogro\\tris.md2", "models\\ogro\\ogrobase.pcx");
enemy3->position = CVector(0.0, 0.0, 0.0);
camera->position.y=100;
camera->position.x=0;
camera->position.z=00;
}
/**********************************************************************/
/** Animetes the camera and all objects in the scene
***********************************************************************/
void CWorld::Animate(float deltaTime)
{
CVector nueva_posicion;
// set camera height based on position on terrain
// camera->position.y = terrain->GetHeight(camera->position.x, camera->position.z) + 10.0f;
nueva_posicion=nivel->TrazaEsfera(camera->posicion_antigua,camera->position,15.0f);
//if(nivel->colision)
//camera->position=camera->posicion_antigua;
camera->position=nueva_posicion;
terrain->Animate(deltaTime);
}
/**********************************************************************/
/** Draw the scene
***********************************************************************/
void CWorld::Draw(CCamera *camera)
{
msg->SetPos3D(0.25,0.25,0);
frames_por_segundo->SetPos3D(0.15,0.35,0);
msg->SetRGB(0,1,0);
frames_por_segundo->SetRGB(0,1,0);
msg->Print("triangulos dibujados:%d",nivel->triangulos);
frames_por_segundo->Print("X:%f Y:%f Z:%f",camera->position.x,camera->position.y,camera->position.z);
//terrain->Draw(camera);
enemy3->Draw(camera);
//glTranslatef(100,158,100);
/* glPushMatrix();
glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
glDisable(GL_TEXTURE_2D);
glColor4f(1.0, 0.0, 0.0, 1.0);
glBegin(GL_QUADS);
glVertex3f(-5, -5, -3.0);
glVertex3f(5, -5, -3.0);
glVertex3f(5, 5, -3.0);
glVertex3f(-5, 5, -3.0);
glEnd();
glColor4f(1.0, 1.0, 1.0, 1.0);
glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glPopMatrix();*/
/* glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_DST_COLOR);*/
glPushMatrix();
glBegin(GL_LINE_LOOP);
glColor3ub(255,0,0);
glVertex3f(0,0,0);
glColor3ub(0,255,0);
glVertex3f(0,10,0);
glColor3ub(255,255,255);
glVertex3f(0,0,10);
glEnd();
glPopMatrix();
nivel->Draw(camera);
//glDisable(GL_BLEND);
}
/**********************************************************************/
/** Prepare all objects
***********************************************************************/
void CWorld::OnPrepare()
{
glClearColor(1.0, 1.0, 1.0, 1.0);
//nivel->ComprobarNodo(0,1
//camera->position.y=100;
//camera->position.x=1050;
//camera->position.z=1050;
//terrain->Prepare();
}