Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ODE/src/world_entities/space_ships/hover.cc @ 10359

Last change on this file since 10359 was 10359, checked in by bottac, 17 years ago
File size: 20.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14
15*/
16
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
19#include "hover.h"
20
21#include "weapons/weapon_manager.h"
22#include "weapons/test_gun.h"
23#include "weapons/turret.h"
24#include "weapons/cannon.h"
25
26#include "util/loading/factory.h"
27//#include "util/loading/resource_manager.h"
28
29#include "key_mapper.h"
30#include "state.h"
31
32#include "graphics_engine.h"
33
34#include "debug.h"
35
36
37ObjectListDefinition(Hover);
38CREATE_FACTORY(Hover);
39
40#include "script_class.h"
41CREATE_SCRIPTABLE_CLASS(Hover,
42                        addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer))
43                        //Coordinates
44                            ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
45                            ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
46                            ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
47                            ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
48                       );
49
50/**
51 *  destructs the hover, deletes alocated memory
52 */
53Hover::~Hover ()
54{
55  this->setPlayer(NULL);
56
57  //if (this->hoverBuffer != NULL)
58  //  ResourceManager::getInstance()->unload(this->hoverBuffer);
59}
60
61/**
62 * loads a Hover information from a specified file.
63 * @param fileName the name of the File to load the hover from (absolute path)
64 */
65Hover::Hover(const std::string& fileName)
66{
67  this->init();
68  TiXmlDocument doc(fileName);
69
70  if(!doc.LoadFile())
71  {
72    PRINTF(2)("Loading file %s failed for Hover.\n", fileName.c_str());
73    return;
74  }
75
76  this->loadParams(doc.RootElement());
77
78  //load sound
79  //if (this->hoverBuffer != NULL)
80  //  ResourceManager::getInstance()->unload(this->hoverBuffer);
81  //this->hoverBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/engine/hover.wav", WAV);
82
83}
84
85/**
86 *  creates a new Spaceship from Xml Data
87 * @param root the xml element containing spaceship data
88
89   @todo add more parameters to load
90*/
91Hover::Hover(const TiXmlElement* root)
92{
93  this->init();
94  if (root != NULL)
95    this->loadParams(root);
96
97  //weapons:
98  Weapon* wpRight = new TestGun(0);
99  wpRight->setName("testGun Right");
100  Weapon* wpLeft = new TestGun(1);
101  wpLeft->setName("testGun Left");
102  Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate("Hyperblaster"));
103
104  cannon->setName("BFG");
105
106  this->addWeapon(wpLeft, 1, 0);
107  this->addWeapon(wpRight,1 ,1);
108  this->addWeapon(cannon, 0, 2);
109
110  this->getWeaponManager().changeWeaponConfig(1);
111  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
112
113  this->loadModel("models/ships/hoverglider_mainbody.obj");
114}
115
116
117/**
118 * initializes a Hover
119 */
120void Hover::init()
121{
122
123  //this->hitEntity = NULL;
124  //this->hoverBuffer = NULL;
125
126  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
127  this->registerObject(this, Hover::_objectList);
128  this->toReflectionList();
129
130  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
131  this->loadModel("models/ships/hoverglider_rotor.obj", 1.0f, 4);
132  this->loadModel("models/ships/rotor.obj", .45f, 5);
133
134  bForward = bBackward = bLeft = bRight = bAscend = bDescend = false;
135  mouseSensitivity = 0.005;
136
137  this->rotorSpeed = 1000.0f;
138  this->rotorCycle = 0.0f;
139  this->cameraLook = 0.0f;
140  this->rotation = 0.0f;
141  this->acceleration = 15.0f;
142  this->airFriction = 3.0f;
143
144  // camera - issue
145  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
146  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
147  //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
148  this->cameraNode.setParent(this);
149
150  // rotors
151  this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT );
152  this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
153  this->wingNodeLeft.setParent(this);
154  this->wingNodeLeft.setRelCoor(-1.5, -.3, -1.0);
155  this->rotorNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
156  this->rotorNodeLeft.setParent(&this->wingNodeLeft);
157  this->rotorNodeLeft.setRelCoor(0, 1.0, -2.3);
158
159  this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
160  this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
161  this->wingNodeRight.setParent(this);
162  this->wingNodeRight.setRelCoor(-1.5, -0.3, 1.0);
163  this->rotorNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
164  this->rotorNodeRight.setParent(&this->wingNodeRight);
165  this->rotorNodeRight.setRelCoor(0, 1.0, 2.3);
166
167  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
168
169
170  //add events to the eventlist
171  registerEvent(KeyMapper::PEV_FORWARD);
172  registerEvent(KeyMapper::PEV_BACKWARD);
173  registerEvent(KeyMapper::PEV_LEFT);
174  registerEvent(KeyMapper::PEV_RIGHT);
175  registerEvent(KeyMapper::PEV_UP);
176  registerEvent(KeyMapper::PEV_DOWN);
177  registerEvent(KeyMapper::PEV_FIRE1);
178  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
179  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
180  registerEvent(EV_MOUSE_MOTION);
181
182
183  // WEAPON_MANAGER configuration
184  this->getWeaponManager().setSlotCount(5);
185
186  this->getWeaponManager().setSlotPosition(0, Vector(-0.28, 1.186, -2.750), &this->wingNodeLeft);
187  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
188
189  this->getWeaponManager().setSlotPosition(1, Vector(-0.28, 1.186, 2.750), &this->wingNodeRight);
190  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
191
192  this->getWeaponManager().setSlotPosition(2, Vector(-1.63, .809, -.003));
193  this->getWeaponManager().setSlotCapability(2, WTYPE_HEAVY);
194
195  /// TODO: THESE ARE TOO MUCH
196  this->getWeaponManager().setSlotPosition(3, Vector(-1.63, .678, -.652));
197  this->getWeaponManager().setSlotDirection(3, Quaternion(-24/180 * M_PI, Vector(1,0,0)));
198
199  this->getWeaponManager().setSlotPosition(4, Vector(-1.63, .678, .652));
200  this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
201
202  this->cameraNode.setRelCoor(1,5,0);
203  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
204  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
205
206  // NETWORK THINGS
207
208  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
209  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
210  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
211  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
212  registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
213  registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
214
215  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
216}
217
218/**
219 * loads the Settings of a Hover from an XML-element.
220 * @param root the XML-element to load the Spaceship's properties from
221 */
222void Hover::loadParams(const TiXmlElement* root)
223{
224  WorldEntity::loadParams(root);
225}
226
227
228void Hover::enter()
229{
230  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
231
232  State::getCameraNode()->setParentSoft(&this->cameraNode);
233  State::getCameraNode()->setRelCoorSoft(-10, 0,0);
234  State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
235
236  //this->soundSource.play(this->hoverBuffer, 0.3f, true);
237
238}
239
240void Hover::leave()
241{
242  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
243  this->detachCamera();
244
245}
246
247
248/**
249 *  effect that occurs after the Hover is spawned
250*/
251void Hover::postSpawn ()
252{
253  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
254}
255
256/**
257 *  the action occuring if the hover left the game
258*/
259void Hover::leftWorld ()
260{}
261
262/**
263 *  this function is called, when two entities collide
264 * @param entity: the world entity with whom it collides
265 *
266 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
267 */
268void Hover::collidesWith(WorldEntity* entity, const Vector& location)
269{
270  Playable::collidesWith(entity, location);
271}
272
273
274
275/**
276 *  the function called for each passing timeSnap
277 * @param time The timespan passed since last update
278*/
279void Hover::tick (float dt)
280{
281  Playable::tick(dt);
282
283  // spaceship controlled movement
284  this->movement(dt);
285  this->rotorCycle += this->rotorSpeed * dt;
286}
287
288/**
289 *  calculate the velocity
290 * @param time the timeslice since the last frame
291*/
292void Hover::movement (float dt)
293{
294  Vector accel(0.0, 0.0, 0.0);
295
296  if( this->bForward )
297  {
298    accel += Vector(this->acceleration, 0, 0);
299  }
300
301  if( this->bBackward )
302  {
303    accel -= Vector(this->acceleration, 0, 0);
304  }
305  if( this->bLeft)
306  {
307    accel -= Vector(0, 0, this->acceleration);
308  }
309
310  if( this->bRight)
311  {
312    accel += Vector(0, 0, this->acceleration);
313  }
314
315  if (this->bAscend )
316  {
317    accel += Vector(0, this->acceleration, 0);
318  }
319  if (this->bDescend )
320  {
321    accel -= Vector(0, this->acceleration, 0);
322  }
323
324  Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
325
326  // this is the air friction (necessary for a smooth control)
327  Vector damping = (this->velocity * this->airFriction);
328
329
330  this->velocity += (accelerationDir - damping)* dt;
331
332  this->shiftCoor (this->velocity * dt);
333
334  // limit the maximum rotation speed.
335  if (this->rotation != 0.0f)
336  {
337    float maxRot = 10.0 * dt;
338    if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
339    if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
340    this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
341    this->rotation = 0.0f;
342  }
343
344  this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
345
346  this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .03 +this->rotation, Vector(1,0,0)), 5);
347  this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .05+this->rotation + cameraLook, Vector(0,0,1)), 5);
348
349  this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .03 +this->rotation, Vector(1,0,0)), 5);
350  this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.05 -this->rotation + cameraLook, Vector(0,0,1)), 5);
351}
352
353
354void Hover::draw() const
355{
356  Vector tmpRot;
357  WorldEntity::draw();
358
359  glPushMatrix();
360  /// LEFT SIDE
361  glTranslatef (this->wingNodeLeft.getAbsCoor ().x,
362                this->wingNodeLeft.getAbsCoor ().y,
363                this->wingNodeLeft.getAbsCoor ().z);
364  tmpRot = this->wingNodeLeft.getAbsDir().getSpacialAxis();
365  glRotatef (this->wingNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
366  this->getModel(3)->draw();
367  glPopMatrix ();
368
369  glPushMatrix();
370  glTranslatef (this->rotorNodeLeft.getAbsCoor ().x,
371                this->rotorNodeLeft.getAbsCoor ().y,
372                this->rotorNodeLeft.getAbsCoor ().z);
373  tmpRot = this->rotorNodeLeft.getAbsDir().getSpacialAxis();
374  glRotatef (this->rotorNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
375  this->getModel(4)->draw();
376  glTranslatef(0,-1,0);
377  glRotatef(this->rotorCycle, 0,1,0);
378  this->getModel(5)->draw();
379  glPopMatrix ();
380
381  /// RIGHT SIDE
382  glPushMatrix();
383  glTranslatef (this->wingNodeRight.getAbsCoor ().x,
384                this->wingNodeRight.getAbsCoor ().y,
385                this->wingNodeRight.getAbsCoor ().z);
386  tmpRot = this->wingNodeRight.getAbsDir().getSpacialAxis();
387  glRotatef (this->wingNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
388  glScalef(1,1,-1);
389  this->getModel(3)->draw();
390  glPopMatrix ();
391
392  glPushMatrix();
393  glTranslatef (this->rotorNodeRight.getAbsCoor ().x,
394                this->rotorNodeRight.getAbsCoor ().y,
395                this->rotorNodeRight.getAbsCoor ().z);
396  tmpRot = this->rotorNodeRight.getAbsDir().getSpacialAxis();
397  glRotatef (this->rotorNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
398  glScalef(1,1,-1);
399  this->getModel(4)->draw();
400  glTranslatef(0,-1,0);
401  glRotatef(this->rotorCycle, 0,1,0);
402  this->getModel(5)->draw();
403  glPopMatrix ();
404  // ****************************************************************************************
405  // SHADOW
406  // ****************************************************************************************
407       
408glPushMatrix();
409
410        glTranslatef (this->getAbsCoor ().x,
411                  this->getAbsCoor ().y-2.0,
412                  this->getAbsCoor ().z);
413        Vector a = Vector(0.0,0.0,-10.0);
414
415        //drawDebugCube( &a);
416
417        glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );
418        glDepthMask(GL_FALSE);
419        glDepthFunc( GL_LEQUAL );
420
421        glEnable(GL_STENCIL_TEST);
422        glDisable(GL_LIGHTING);
423
424//PART ONE
425        glColorMask(0, 0, 0, 0);
426        glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
427
428        glEnable(GL_CULL_FACE);
429        glFrontFace( GL_CCW );
430        glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
431        drawDebugCube( &a);
432
433//PART TWO
434
435        glFrontFace( GL_CW );
436        glStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
437        drawDebugCube( &a);
438
439
440glPopMatrix();
441
442// RENDER THE WHOLE STUFF
443        glDisable(GL_TEXTURE_2D);
444        glFrontFace( GL_CCW );
445        glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
446        glColor4f( 0.0f, 0.1f, 0.0f, 0.4f );
447        glEnable( GL_BLEND );
448        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
449        glStencilFunc( GL_NOTEQUAL, 0, 0xffffffff );
450        glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
451        glPushMatrix();
452        glLoadIdentity();
453        glBegin( GL_TRIANGLE_STRIP );
454                glVertex3f( -1.1f,  1.1f, -.5f );
455                glVertex3f( -1.1f, -1.1f, -.5f );
456                glVertex3f(  1.1f,  1.1f, -.5f );
457                glVertex3f(  1.1f, -1.1f, -.5f );
458        glEnd();
459        glPopMatrix();
460
461        glDisable(GL_BLEND);
462        glEnable(GL_LIGHTING);
463        glDisable(GL_STENCIL_TEST);
464        glDisable(GL_CULL_FACE);
465        glDepthMask(GL_TRUE);
466
467}
468
469/**
470 * @todo switch statement ??
471 */
472void Hover::process(const Event &event)
473{
474  Playable::process(event);
475
476  if( event.type == KeyMapper::PEV_LEFT)
477    this->bLeft = event.bPressed;
478  else if( event.type == KeyMapper::PEV_RIGHT)
479    this->bRight = event.bPressed;
480  else if( event.type == KeyMapper::PEV_UP)
481    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
482  else if( event.type == KeyMapper::PEV_DOWN)
483    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
484  else if( event.type == KeyMapper::PEV_FORWARD)
485    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
486  else if( event.type == KeyMapper::PEV_BACKWARD)
487    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
488  else if( event.type == EV_MOUSE_MOTION)
489  {
490    float xMouse, yMouse;
491    xMouse = event.xRel*mouseSensitivity;
492    yMouse = event.yRel*mouseSensitivity;
493
494    // rotate the Player around the y-axis
495    this->rotation += xMouse;
496
497    this->cameraLook += yMouse;
498    // rotate the Camera around the z-axis
499    if (cameraLook > M_PI_4)
500      cameraLook = M_PI_4;
501    else if (cameraLook < -M_PI_4)
502      cameraLook = -M_PI_4;
503    //this->cameraNode.setRelDirSoft(this->direction,10);
504  }
505}
506
507 void drawDebugCube(const Vector* cam)
508{
509glBegin(GL_QUADS);
510 // Front Face
511                glNormal3f( 0.0f, 0.0f, 1.0f);                                  // Normal Pointing Towards Viewer
512                glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -10.0f,  1.0f);     // Point 1 (Front)
513                glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -10.0f,  1.0f);     // Point 2 (Front)
514                glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  10.0f,  1.0f);     // Point 3 (Front)
515                glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  10.0f,  1.0f);     // Point 4 (Front)
516                // Back Face
517                glNormal3f( 0.0f, 0.0f,-1.0f);                                  // Normal Pointing Away From Viewer
518                glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f, -1.0f);     // Point 1 (Back)
519                glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  10.0f, -1.0f);     // Point 2 (Back)
520                glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  10.0f, -1.0f);     // Point 3 (Back)
521                glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f, -1.0f);     // Point 4 (Back)
522                // Top Face
523                glNormal3f( 0.0f, 1.0f, 0.0f);                                  // Normal Pointing Up
524                glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  10.0f, -1.0f);     // Point 1 (Top)
525                glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  10.0f,  1.0f);     // Point 2 (Top)
526                glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  10.0f,  1.0f);     // Point 3 (Top)
527                glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  10.0f, -1.0f);     // Point 4 (Top)
528                // Bottom Face
529                glNormal3f( 0.0f,-1.0f, 0.0f);                                  // Normal Pointing Down
530                glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -10.0f, -1.0f);     // Point 1 (Bottom)
531                glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -10.0f, -1.0f);     // Point 2 (Bottom)
532                glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f,  1.0f);     // Point 3 (Bottom)
533                glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f,  1.0f);     // Point 4 (Bottom)
534                // Right face
535                glNormal3f( 1.0f, 0.0f, 0.0f);                                  // Normal Pointing Right
536                glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -10.0f, -1.0f);     // Point 1 (Right)
537                glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  10.0f, -1.0f);     // Point 2 (Right)
538                glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  10.0f,  1.0f);     // Point 3 (Right)
539                glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f,  1.0f);     // Point 4 (Right)
540                // Left Face
541                glNormal3f(-1.0f, 0.0f, 0.0f);                                  // Normal Pointing Left
542                glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -10.0f, -1.0f);     // Point 1 (Left)
543                glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f,  1.0f);     // Point 2 (Left)
544                glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  10.0f,  1.0f);     // Point 3 (Left)
545                glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  10.0f, -1.0f);     // Point 4 (Left)
546        glEnd();                                                                // Done Drawing Quads
547return;
548
549  glBegin(GL_QUADS);
550
551
552  // Bottom Face.  Red, 75% opaque, magnified texture
553
554  //glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting
555 // glColor4f(0.9,0.2,0.2,.75); // Basic polygon color
556
557  //glTexCoord2f(0.800f, 0.800f);
558glVertex3f(cam->x-5.0f, cam->y-100.0f,cam->z -5.0f);
559 // glTexCoord2f(0.200f, 0.800f);
560glVertex3f(cam->x+5.0f, cam->y-100.0f,cam->z -5.0f);
561  //glTexCoord2f(0.200f, 0.200f);
562glVertex3f(cam->x+ 5.0f,cam->y -100.0f,cam->z +  5.0f);
563  //glTexCoord2f(0.800f, 0.200f);
564glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z + 5.0f); //OK
565
566
567  // Top face; offset.  White, 50% opaque.
568
569 // glNormal3f( 0.0f, 5.0f, 0.0f);  glColor4f(0.5,0.5,0.5,.5);
570
571  //glTexCoord2f(0.005f, 5.995f);
572glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f);
573  //glTexCoord2f(0.005f, 0.005f);
574glVertex3f(cam->x-5.0f, cam->y+ 100.0f,  cam->z +5.0f);
575  //glTexCoord2f(5.995f, 0.005f);
576glVertex3f(cam->x+ 5.0f,  cam->y+100.0f,  cam->z +5.0f);
577  //glTexCoord2f(5.995f, 5.995f);
578glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z -5.0f); //OKQUAD_STRI
579
580
581  // Far face.  Green, 50% opaque, non-uniform texture cooridinates.
582
583  //glNormal3f( 0.0f, 0.0f,-5.0f);  glColor4f(0.2,0.9,0.2,.5);
584
585 // glTexCoord2f(0.995f, 0.005f);
586glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z -5.0f);
587 // glTexCoord2f(2.995f, 2.995f);
588glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f);
589 // glTexCoord2f(0.005f, 0.995f);
590glVertex3f(cam->x+ 5.0f,cam->y+  100.0f, cam->z -5.0f);
591  //glTexCoord2f(0.005f, 0.005f);
592glVertex3f( cam->x+5.0f,cam->y -100.0f, cam->z -5.0f);
593
594
595  // Right face.  Blue; 25% opaque
596
597 // glNormal3f( 5.0f, 0.0f, 0.0f);  glColor4f(0.2,0.2,0.9,.25);
598
599 // glTexCoord2f(0.995f, 0.005f);
600glVertex3f(cam->x+ 5.0f, cam->y -100.0f, cam->z -5.0f);
601 // glTexCoord2f(0.995f, 0.995f);
602glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z -5.0f);
603 // glTexCoord2f(0.005f, 0.995f);
604glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z + 5.0f);
605 // glTexCoord2f(0.005f, 0.005f);
606glVertex3f(cam->x+ 5.0f, cam->y-100.0f,  cam->z +5.0f);
607
608
609  // Front face; offset.  Multi-colored, 50% opaque.
610
611 // glNormal3f( 0.0f, 0.0f, 5.0f);
612
613//  glColor4f( 0.9f, 0.2f, 0.2f, 0.5f);
614//  glTexCoord2f( 0.005f, 0.005f);
615glVertex3f(cam->x-5.0f, cam->y-100.0f,  cam->z +5.0f);
616//  glColor4f( 0.2f, 0.9f, 0.2f, 0.5f);
617//  glTexCoord2f( 0.995f, 0.005f);
618glVertex3f(cam->x+ 5.0f, cam->y-100.0f,  cam->z +5.0f);
619 // glColor4f( 0.2f, 0.2f, 0.9f, 0.5f);
620//  glTexCoord2f( 0.995f, 0.995f);
621glVertex3f( cam->x+5.0f,  cam->y+100.0f,  cam->z +5.0f);
622//  glColor4f( 0.5f, 0.5f, 0.5f, 0.5f);
623//  glTexCoord2f( 0.005f, 0.995f); g
624glVertex3f(cam->x-5.0f, cam->y+ 100.0f,  cam->z +5.0f);
625
626
627  // Left Face; offset.  Yellow, varying levels of opaque.
628
629//  glNormal3f(-5.0f, 0.0f, 0.0f);
630
631//  glColor4f(0.9,0.9,0.2,0.0);
632 // glTexCoord2f(0.005f, 0.005f);
633glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z -5.0f);
634  //glColor4f(0.9,0.9,0.2,0.66);
635// glTexCoord2f(0.995f, 0.005f);
636glVertex3f(cam->x-5.0f,cam->y -100.0f,  cam->z +5.0f);
637//  glColor4f(0.9,0.9,0.2,5.0);
638//  glTexCoord2f(0.995f, 0.995f);
639glVertex3f(cam->x-5.0f, cam->y+ 100.0f,  cam->z +5.0f);
640//  glColor4f(0.9,0.9,0.2,0.33);
641//  glTexCoord2f(0.005f, 0.995f);
642glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f);
643
644  glEnd();
645}
646
Note: See TracBrowser for help on using the repository browser.