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
|
class Airplane
{
private:
//attributes
double posX;
double posY;
double posZ;
double w;
double h;
double d;
float color1 = (rand() % 100) * .01;
float color2 = (rand() % 100) * .01;
float color3 = (rand() % 100) * .01;
float rotate = 0.0;
float propSpin;
float planeAngle;
public:
//constructor
Airplane(double px, double py, double pz, double _w, double _h, double _d)
{
posX = px;
posY = py;
posZ = pz;
w = _w;
h = _h;
d = _d;
propSpin = 0.0;
planeAngle = 15.0;
}
//methods
void drawAirplane()
{
glPushMatrix();
glRotatef(planeAngle, -1, 1, 0);
//body
glPushMatrix();
glRotatef(90.0, 0, 0, 1);
glRotatef(rotate, 1, 0, 0);
setColor(color1, color2, color3);
drawRectangle(posX, posY, posZ, w, h, d);
glPopMatrix();
//wings
glPushMatrix();
glRotatef(90.0, 1, 0, 0);
glRotatef(-rotate, 0, 0, 1);
setColor(color1, color2, color3);
drawRectangle(posX - 200, posY + 300, posZ - 500, w, h, d);
glPopMatrix();
//tail lat
enable3d();
glPushMatrix();
glRotatef(0.0, 0, 1, 0);
glRotatef(rotate, 0, 1, 0);
glScalef(1.0, 0.3, 0.75);
setColor(color1, color2, color3);
drawRectangle(posX - 250, posY + 700, posZ + 100, w, h, d);
glPopMatrix();
//tail lon
glPushMatrix();
glRotatef(90.0, 1, 0, 0);
glRotatef(-rotate, 0, 0, 1);
glScalef(1.0, 0.3, 0.5);
setColor(color1, color2, color3);
drawRectangle(posX - 250, posY + 1000, posZ - 750, w, h, d);
glPopMatrix();
//glPushMatrix();
//glRotatef(propSpin, 0, 1, 0);
//prop lat
glPushMatrix();
glRotatef(90.0, 0, 1, 0);
glRotatef(rotate, 0, 1, 0);
glScalef(0.5, 0.5, 0.5);
setColor(color1, color2, color3);
drawRectangle(posX - 800, posY + 400, posZ - 150, w, h, d);
glPopMatrix();
//prop long
glPushMatrix();
glRotatef(90.0, 0, 1, 0);
glRotatef(90.0, 0, 0, 1);
glRotatef(rotate, 1, 0, 0);
glScalef(0.4, 0.4, 0.4);
setColor(color1, color2, color3);
drawRectangle(posX + 300, posY + 750, posZ - 100, w, h, d);
glPopMatrix();
//glPopMatrix();
glPopMatrix();
rotate++;
propSpin++;
}
};
|