Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6162 in orxonox.OLD for trunk


Ignore:
Timestamp:
Dec 19, 2005, 4:52:01 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the spaceshipcontroll branche into the trunk
merged with command
svn merge -r6036:HEAD spaceshipcontrol/ ../trunk/
no conflicts

Location:
trunk/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r6139 r6162  
    9292  CL_TEXTURE                    =    0x00c01000,
    9393  CL_MODEL                      =    0x00c02000,
     94  CL_STATIC_MODEL               =    0x00c04000,
     95  CL_VERTEX_ARRAY_MODEL         =    0x00c08000,
    9496
    9597
     
    202204  CL_MATERIAL                   =    0x00000804,
    203205  CL_TEXTURE_SEQUENCE           =    0x00c04805,
    204   CL_VERTEX_ARRAY_MODEL         =    0x00000806,
    205   CL_OBJMODEL                   =    0x00000807,
     206  CL_OBJ_MODEL                  =    0x00000807,
    206207  CL_PROMITIVE_MODEL            =    0x00000808,
    207208  CL_MD2Model                   =    0x00000809,
  • trunk/src/lib/graphics/graphics_engine.cc

    r6142 r6162  
    3838 #include "class_list.h"
    3939 #include "list.h"
    40  #include "model.h"
     40 #include "static_model.h"
    4141#endif
    4242using namespace std;
     
    285285  }
    286286  PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
    287 
    288 }
     287}
     288
    289289
    290290/**
     
    322322    }
    323323    // REBUILDING MODELS
    324     const std::list<BaseObject*>* modelList = ClassList::getList(CL_MODEL);
     324    const std::list<BaseObject*>* modelList = ClassList::getList(CL_STATIC_MODEL);
    325325    if (texList != NULL)
    326326    {
    327327      std::list<BaseObject*>::const_iterator reModel;
    328328      for (reModel = modelList->begin(); reModel != modelList->end(); reModel++)
    329         dynamic_cast<Model*>(*reModel)->rebuild();
     329        dynamic_cast<StaticModel*>(*reModel)->rebuild();
    330330    }
    331331#endif /* __WIN32__ */
  • trunk/src/lib/graphics/importer/model.cc

    r6073 r6162  
    2828Model::Model()
    2929{
    30 //   this->setClassID(CL_PROTO_ID, "ProtoClass");
     30  this->setClassID(CL_MODEL, "Model");
    3131  this->pModelInfo.numVertices = 0;
    3232  this->pModelInfo.numTriangles = 0;
     
    5555  const GLfloat* pVertices = NULL;
    5656  const GLfloat* pNorm = NULL;
    57  
     57
    5858  glBegin(GL_TRIANGLES);
    5959  for( int i = 0; i < this->pModelInfo.numTriangles; ++i)
     
    6464      glNormal3f(pNorm[0], pNorm[1], pNorm[2]);
    6565      glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
    66      
     66
    6767      pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[1]];
    6868      pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[1]];
    6969      glNormal3f(pNorm[0], pNorm[1], pNorm[2]);
    7070      glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
    71      
     71
    7272      pNorm = &this->pModelInfo.pNormals[this->pModelInfo.pTriangles[i].indexToNormals[2]];
    7373      pVertices = &this->pModelInfo.pVertices[this->pModelInfo.pTriangles[i].indexToVertices[2]];
    7474      glNormal3f(pNorm[0], pNorm[1], pNorm[2]);
    7575      glVertex3f(pVertices[0], pVertices[1], pVertices[2]);
    76      
     76
    7777    }
    7878  glEnd();
  • trunk/src/lib/graphics/importer/objModel.cc

    r6022 r6162  
    3434OBJModel::OBJModel(const char* fileName, float scaling) : StaticModel(fileName)
    3535{
     36  this->setClassID(CL_OBJ_MODEL, "OBJModel");
     37
    3638  this->objPath = "./";
    3739
  • trunk/src/lib/graphics/importer/static_model.cc

    r6072 r6162  
    144144StaticModel::StaticModel(const char* modelName)
    145145{
    146   this->setClassID(CL_MODEL, "Model");
     146  this->setClassID(CL_STATIC_MODEL, "StaticModel");
    147147  PRINTF(4)("new 3D-Model is being created\n");
    148148  this->setName(modelName);
     
    550550      this->currentGroup->currentFace->vertexCount++;
    551551    }
    552  
     552
    553553  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
    554554  this->faceCount += this->currentGroup->currentFace->vertexCount -2;
  • trunk/src/world_entities/playable.h

    r5915 r6162  
    3434
    3535    virtual void process(const Event &event) = 0;
     36   
    3637
    3738
  • trunk/src/world_entities/space_ships/helicopter.cc

    r6005 r6162  
    9999
    100100/**
    101  * initializes a Spaceship
     101 * initializes a Helicopter
    102102 */
    103103void Helicopter::init()
     
    240240void Helicopter::tick (float time)
    241241{
    242      cycle += time;
    243242  // spaceship controlled movement
    244243  this->calculateVelocity(time);
     
    246245  Vector move = (velocity)*time;
    247246
    248   //orient the spaceship model in the direction of movement.
    249 
    250247  // this is the air friction (necessary for a smooth control)
    251   if(velocity.len() != 0) velocity -= velocity*0.01;
    252 
     248  if(velocity.len() != 0) velocity -= velocity*0.1;
     249
     250
     251  //hoover effect
     252  cycle += time;
    253253  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     254
     255  //readjust
     256 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
     257  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    254258
    255259  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
     
    269273{
    270274  Vector accel(0.0, 0.0, 0.0);
    271   //Vector rot(0.0, 0.0, 0.0);
    272   //float rotVal = 0.0;
     275  Vector rot(0.0, 0.0, 0.0);
     276  float rotVal = 0.0;
    273277  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    274278  /* calculate the direction in which the craft is heading  */
     
    277281   {
    278282     //this->shiftCoor(this->getAbsDirX());
    279       accel += (this->getAbsDirX())*2;
     283
     284     accel += Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2;
     285     if((this->getAbsDirX()).y > -.2)
     286     {
     287       rot += Vector (0,0,1);
     288       rotVal -= time/5;
     289     }
     290   }
     291   else
     292   {
     293       if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/5, Vector(0,0,1)));
    280294   }
    281295
     
    283297   {
    284298     //this->shiftCoor((this->getAbsDirX())*-1);
    285      accel -= (this->getAbsDirX())*2;
     299     accel -= Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2;
     300     if((this->getAbsDirX()).y < .2)
     301     {
     302       rot += Vector (0,0,1);
     303       rotVal += time/5;
     304     }
     305   }
     306   else
     307   {
     308         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(-time/5, Vector(0,0,1)));
    286309   }
    287310
    288311  if( this->bLeft /* > -this->getRelCoor().z*2*/)
    289312  {
    290     this->shiftDir(Quaternion(time, Vector(0,1,0)));
    291 //    accel -= rightDirection;
     313    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
     314    accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     315    //velocityDir.normalize();
     316    if((this->getAbsDirZ()).y < .2)
     317    {
     318      rot +=Vector(1,0,0);
     319      rotVal -= time/5;
     320    }
     321  }
     322  else
     323   {
     324         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0)));
     325   }
     326   
     327  if( this->bRight /* > this->getRelCoor().z*2*/)
     328  {
     329    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
     330
     331    accel += Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     332    //velocityDir.normalize();
     333    if((this->getAbsDirZ()).y > -.2)
     334    {
     335      rot += Vector(1,0,0);
     336      rotVal += time/5;
     337    }
     338  }
     339  else
     340   {
     341         if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time/5, Vector(1,0,0)));
     342   }
     343
     344  if( this->bRollL /* > -this->getRelCoor().z*2*/)
     345  {
     346    this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     347    //accel -= rightDirection;
    292348    //velocityDir.normalize();
    293349    //rot +=Vector(1,0,0);
    294350    //rotVal -= .4;
    295351  }
    296   if( this->bRight /* > this->getRelCoor().z*2*/)
    297   {
    298     this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    299 
    300     //    accel += rightDirection;
     352  if( this->bRollR /* > this->getRelCoor().z*2*/)
     353  {
     354    this->shiftDir(Quaternion(time, Vector(1,0,0)));
     355
     356    //accel += rightDirection;
    301357    //velocityDir.normalize();
    302358    //rot += Vector(1,0,0);
    303359    //rotVal += .4;
    304360  }
    305 
    306   if( this->bRollL /* > -this->getRelCoor().z*2*/)
    307   {
    308     this->shiftDir(Quaternion(-time, Vector(1,0,0)));
    309 //    accel -= rightDirection;
    310     //velocityDir.normalize();
    311     //rot +=Vector(1,0,0);
    312     //rotVal -= .4;
    313   }
    314   if( this->bRollR /* > this->getRelCoor().z*2*/)
    315   {
    316     this->shiftDir(Quaternion(time, Vector(1,0,0)));
    317 
    318     //    accel += rightDirection;
    319     //velocityDir.normalize();
    320     //rot += Vector(1,0,0);
    321     //rotVal += .4;
    322   }
    323361  if (this->bAscend )
    324362  {
    325     this->shiftDir(Quaternion(time, Vector(0,0,1)));
    326 
    327 //    accel += upDirection;
     363    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
     364
     365    accel += (this->getAbsDirY())*2;
    328366    //velocityDir.normalize();
    329367    //rot += Vector(0,0,1);
     
    332370  if (this->bDescend )
    333371  {
    334     this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    335 
    336     //    accel -= upDirection;
     372    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
     373
     374    accel -= (this->getAbsDirY())*2;
    337375    //velocityDir.normalize();
    338376    //rot += Vector(0,0,1);
     
    341379
    342380  velocity += accel;
    343   //rot.normalize();
    344   //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     381  rot.normalize();
     382  this->shiftDir(Quaternion(rotVal, rot));
    345383}
    346384
     
    373411
    374412  if( event.type == SDLK_a)
    375       this->bRollL = event.bPressed;
     413      this->bLeft = event.bPressed;
    376414  else if( event.type == SDLK_d)
    377       this->bRollR = event.bPressed;
     415      this->bRight = event.bPressed;
    378416  else if( event.type == KeyMapper::PEV_FIRE1)
    379417      this->bFire = event.bPressed;
     
    382420  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
    383421    this->getWeaponManager()->previousWeaponConfig();
    384 
     422  else if( event.type == SDLK_e)
     423    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
     424  else if( event.type == SDLK_c)
     425    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
    385426  else if( event.type == SDLK_w)
    386427    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     
    391432    this->xMouse = event.xRel;
    392433    this->yMouse = event.yRel;
     434    if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0;
    393435    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    394436  }
  • trunk/src/world_entities/space_ships/helicopter.h

    r6005 r6162  
    6565    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6666    float                 acceleration;       //!< the acceleration of the player.
     67   
     68    float                 airViscosity;
    6769
    6870};
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6078 r6162  
    119119  mouseSensitivity = 0.001;
    120120  airViscosity = 1.0;
    121 
    122121  cycle = 0.0;
    123122
     
    125124  travelSpeed = 15.0;
    126125  this->velocity = Vector(0.0,0.0,0.0);
    127   this->velocityDir = Vector(1.0,0.0,0.0);
     126  this->mouseDir = this->getAbsDir();
    128127
    129128//   GLGuiButton* button = new GLGuiPushButton();
     
    175174//   this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    176175
     176  this->getWeaponManager()->getFixedTarget()->setParent(this);
     177  this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0);
     178
    177179}
    178180
     
    265267  velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    266268  velocity = (velocity.getNormalized())*travelSpeed;
    267 
     269 
     270  //orient the spaceship in direction of the mouse
     271   rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
     272   if (this->getAbsDir().distance(rotQuat) > 0.001) 
     273    this->setAbsDir( rotQuat);
     274   //this->setAbsDirSoft(mouseDir,5);
     275   
    268276  // this is the air friction (necessary for a smooth control)
    269277  if(velocity.len() != 0) velocity -= velocity*0.01;
     
    293301{
    294302  Vector accel(0.0, 0.0, 0.0);
    295   //Vector rot(0.0, 0.0, 0.0);
     303  /*
     304  Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter
     305  */
    296306  //float rotVal = 0.0;
    297307  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
     
    302312     //this->shiftCoor(this->getAbsDirX());
    303313      accel += (this->getAbsDirX())*2;
     314     
     315      /* Heli-Steuerung
     316         accel += (this->getAbsDirX()*2;
     317         if(
     318      */
    304319   }
    305320
     
    331346  if( this->bRollL /* > -this->getRelCoor().z*2*/)
    332347  {
    333     this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     348    mouseDir *= Quaternion(-time, Vector(1,0,0));
    334349//    accel -= rightDirection;
    335350    //velocityDir.normalize();
     
    339354  if( this->bRollR /* > this->getRelCoor().z*2*/)
    340355  {
    341     this->shiftDir(Quaternion(time, Vector(1,0,0)));
     356    mouseDir *= Quaternion(time, Vector(1,0,0));
    342357
    343358    //    accel += rightDirection;
     
    407422    this->xMouse = event.xRel;
    408423    this->yMouse = event.yRel;
    409     this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     424    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     425    if( xMouse*xMouse + yMouse*yMouse < 0.9)
     426     this->setAbsDir(mouseDir);
    410427  }
    411428}
  • trunk/src/world_entities/space_ships/space_ship.h

    r6034 r6162  
    88
    99#include "playable.h"
     10
    1011
    1112template<class T> class tList;
     
    6465
    6566    Vector                velocity;           //!< the velocity of the player.
    66     Vector                velocityDir;        //!< the direction of the velocity of the spaceship
     67    Quaternion            mouseDir;           //!< the direction where the player wants to fly
     68    Quaternion rotQuat;
    6769    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6870    float                 acceleration;       //!< the acceleration of the player.
  • trunk/src/world_entities/weapons/crosshair.cc

    r5978 r6162  
    6767  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
    6868
    69 //  this->setBindNode(this);
     69  this->setBindNode(this);
    7070  this->material = new Material;
    7171
     
    166166{
    167167  glPushMatrix();
    168   glTranslatef(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2, 0);
     168  glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
    169169
    170170  glRotatef(this->getAbsDir2D(), 0,0,1);
  • trunk/src/world_entities/weapons/guided_missile.cc

    r6142 r6162  
    4545  this->energyMin = 1;
    4646  this->energyMax = 10;
    47   this->lifeSpan = 5.0;
    48   this->agility = 5.0;
    49   this->maxVelocity = 100;
     47  this->lifeSpan = 10.0;
     48  this->agility = 4;
     49  this->maxVelocity = 75;
    5050
    5151  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     
    147147void GuidedMissile::tick (float time)
    148148{
    149   //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
     149
    150150  if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
    151151   {
    152      velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
    153      float speed = velocity.len();
    154      if (speed > this->maxVelocity)
    155        velocity *= maxVelocity/speed;
     152    speed = velocity.len();
     153    diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized());
     154
     155    if(velocity.dot(diffVector) != 0)
     156    {
     157     correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
     158
     159      if(velocity.dot(diffVector) > 0)
     160        velocity += correctionVector;
     161      else if (velocity.dot(diffVector) < 0)
     162        velocity -= correctionVector;
     163    }
     164    else
     165      velocity += diffVector * agility;
    156166
    157167     this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
    158168   }
     169
     170  velocity *= maxVelocity/velocity.len();
    159171  Vector v = this->velocity * (time);
    160172  this->shiftCoor(v);
  • trunk/src/world_entities/weapons/guided_missile.h

    r6054 r6162  
    4040    float                             agility;
    4141    float                             maxVelocity;
     42    float                             speed;
     43    Vector                            diffVector ;
     44    Vector                            correctionVector;
    4245
    4346    WorldEntity* hitEntity; // FIXME TEMPORARY
  • trunk/src/world_entities/weapons/laser.cc

    r6142 r6162  
    4545  this->energyMin = 1;
    4646  this->energyMax = 10;
    47   this->lifeSpan = 1.0;
     47  this->lifeSpan = 5.0;
    4848
    4949  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
  • trunk/src/world_entities/weapons/test_gun.cc

    r6074 r6162  
    184184  pj->setParent(PNode::getNullParent());
    185185
    186   pj->setVelocity(this->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*50+VECTOR_RAND(5));
     186  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
    187187
    188188  pj->setAbsCoor(this->getEmissionPoint());
Note: See TracChangeset for help on using the changeset viewer.