/
phonex.h
190 lines (144 loc) · 5.74 KB
/
phonex.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
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
#pragma once
#include"Vector3.h"
#include"AABoundingBox.h"
#include"GameManager.h"
#include "Vector3.h"
#include "AABoundingBox.h"
#include "Bullet.h"
#include "gl/glut.h"
#include "Classes/Headers/texture.h"
#include "Classes/Headers/md2.h"
#include "Classes/Headers/pcx.h"
class phonex {
public:
Vector3 P , V;//Pposition of the buggy .. V is the velocity of the buggy
int teapotSize;
CMD2Model buggyBody; // MD2 object to load the buggy model
float animTimeSec;
float angle ;//current Angle of the model (used in rotation)
Vector3 Velo;
int MovesCounter ; //counter to keep track of buggy's moves to control it's moves
int yes ; //flag (takes values 0 or 1) if MovesCounter = 0 -> yes = 1 else yes = 0 (used in update function)
phonex(const Vector3 pos, int size , Vector3 V) {
yes=1 ;
MovesCounter=0 ;
Velo=V;
P = pos;
teapotSize = size;
animTimeSec = 0;
CTextureManager::GetInstance()->Initialize();
buggyBody.LoadModel("models/phoenix_ugv/phoenix_ugv.md2");
// buggyBody.LoadSkin("models/phoenix_ugv/buggy.bmp");
//plane.LoadSkin("C:\\Users\\Public\\Pictures\\Sample Pictures\\Penguins.bmp");
buggyBody.SetAnim(0);
/*
wings.LoadModel("models/airplane/wing.md2");
wings.LoadSkin("models/airplane/air3_b.pcx");
wings.SetAnim(0)*/;
}
AABoundingBox GetAABB() const {
Vector3 dims(3, 3, 3); // :@ msh radta tozbot
return AABoundingBox(P, 2*dims);
}
/*void Rotat(float angleDegrees)
{
Vector3 jDir(0, 0, 1);
P.RotateAround2(angleDegrees, jDir);
}*/
void Render() {
glPushMatrix();
glColor3f(0, 1, 0);
Vector3 saveP = P ;
glScalef(1, 0.7, 1);
glTranslatef(6*saveP.x, 4*saveP.y, 6*saveP.z);
glRotated ( 180 , 0 , 0 , 1 );
glRotated ( 90 , 1 , 0 , 0 );
glTranslatef (0,0,0);
glScalef(4, 4,4);
// glTranslatef(6*P.x, 4*P.y, 6*P.z);
//glutSolidTeapot(teapotSize);
glEnable(GL_TEXTURE_2D);
buggyBody.DrawModel(animTimeSec);
//wings.DrawModel(animTimeSec);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
Bullet ShootAt(const Vector3 &target) {
Vector3 bulDir = (target - P);
bulDir.Normalize();
Bullet bul(P, 40 * bulDir);
return bul;
}
void Update() {
if ( MovesCounter == 0 )
yes= 1 ;
else if (MovesCounter == 400 )
yes= 0 ;
if (yes )
{
P.z = P.z+0.05;
P.x = P.x+0.05;
MovesCounter++;
}
else
{
P.z = P.z-0.05;
P.x = P.x-0.05;
MovesCounter--;
}
}
void Update2() {
if ( MovesCounter == 0 )
yes= 1 ;
else if (MovesCounter == 400 )
yes= 0 ;
if ( yes)
{
P.z = P.z-0.05;
P.x = P.x+0.05;
MovesCounter++;
}
else
{
P.z = P.z+0.05;
P.x = P.x-0.05;
MovesCounter--;
}
}
void Update3() {
if ( MovesCounter == 0 )
yes= 1 ;
else if (MovesCounter == 400 )
yes= 0 ;
if ( yes )
{
P.z = P.z-0.05;
P.x = P.x-0.05;
MovesCounter++;
}
else
{
P.z = P.z+0.05;
P.x = P.x+0.05;
MovesCounter--;
}
}
void Update4() {
if ( MovesCounter == 0 )
yes= 1 ;
else if (MovesCounter == 400 )
yes= 0 ;
if ( yes )
{
P.z = P.z+0.05;
P.x = P.x-0.05;
MovesCounter++;
}
else
{
P.z = P.z-0.05;
P.x = P.x+0.05;
MovesCounter--;
}
}
};