Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/space_ship.cc

    r9656 r9869  
    2626#include "weapons/cannon.h"
    2727
    28 #include "dot_emitter.h"
    29 #include "sprite_particles.h"
     28#include "particles/dot_emitter.h"
     29#include "particles/sprite_particles.h"
    3030
    3131#include "util/loading/factory.h"
     
    5353
    5454
    55 
    56 CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP);
     55#include "class_id_DEPRECATED.h"
     56ObjectListDefinitionID(SpaceShip, CL_SPACE_SHIP);
     57CREATE_FACTORY(SpaceShip);
     58
    5759#include "script_class.h"
    58 CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,
    59                         addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
    60                         ->addMethod("fire", ExecutorLua1<Playable, bool>(&Playable::fire))
    61                         ->addMethod("loadModel", ExecutorLua2<WorldEntity,const std::string& ,float>(&WorldEntity::loadModel2))
    62                         ->addMethod("setName", ExecutorLua1<BaseObject,const std::string&>(&BaseObject::setName))
    63                         ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
    64                         ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
    65                        //Coordinates
    66                         ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    67                         ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    68                         ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    69                         ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     60CREATE_SCRIPTABLE_CLASS(SpaceShip,
     61                        addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer))
     62                        ->addMethod("fire", Executor1<Playable, lua_State*, bool>(&Playable::fire))
     63                        ->addMethod("loadModel", Executor2<WorldEntity, lua_State*,const std::string& ,float>(&WorldEntity::loadModel2))
     64                        ->addMethod("setName", Executor1<BaseObject, lua_State*,const std::string&>(&BaseObject::setName))
     65                        ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide))
     66                        ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide))
     67                        //Coordinates
     68                        ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
     69                        ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
     70                        ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
     71                        ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
    7072                       );
    7173
     
    116118void SpaceShip::init()
    117119{
    118 //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    119   this->setClassID(CL_SPACE_SHIP, "SpaceShip");
     120  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
     121  this->registerObject(this, SpaceShip::_objectList);
    120122
    121123  PRINTF(4)("SPACESHIP INIT\n");
     
    145147  controlVelocityY = 150;
    146148  shipInertia = 1.5;
    147 //  cycle = 0.0;
     149  //  cycle = 0.0;
    148150
    149151  this->setHealthMax(100);
     
    156158  this->pitchDir = this->getAbsDir();
    157159
    158 //   GLGuiButton* button = new GLGuiPushButton();
    159 //    button->show();
    160 //    button->setLabel("orxonox");
    161 //    button->setBindNode(this);
    162 //     GLGuiBar* bar = new GLGuiBar();
    163 //     bar->show();
    164 //     bar->setValue(7.0);
    165 //     bar->setMaximum(10);
    166 //     bar->setSize2D( 20, 100);
    167 //     bar->setAbsCoor2D( 10, 200);
     160  //   GLGuiButton* button = new GLGuiPushButton();
     161  //    button->show();
     162  //    button->setLabel("orxonox");
     163  //    button->setBindNode(this);
     164  //     GLGuiBar* bar = new GLGuiBar();
     165  //     bar->show();
     166  //     bar->setValue(7.0);
     167  //     bar->setMaximum(10);
     168  //     bar->setSize2D( 20, 100);
     169  //     bar->setAbsCoor2D( 10, 200);
    168170
    169171  //add events to the eventlist
     
    200202  this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
    201203  this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    202 //
    203    this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
    204    this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    205    //
    206 //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
    207 //   this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
    208 //
    209 //   this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    210 //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
     204  //
     205  this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
     206  this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     207  //
     208  //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
     209  //   this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
     210  //
     211  //   this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
     212  //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    211213
    212214  this->getWeaponManager().getFixedTarget()->setParent(this);
     
    310312void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
    311313{
    312 
    313314}
    314315
     
    332333
    333334  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
    334    {
     335  {
    335336    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
    336337    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     
    342343    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
    343344    xMouse = yMouse = 0;
    344    }
    345 
    346 
    347 //   if( this != State::getPlayer()->getControllable())
    348 //     return;
     345  }
     346
     347
     348  //   if( this != State::getPlayer()->getControllable())
     349  //     return;
    349350
    350351  // spaceship controlled movement fire(bool bF){ this->bFire = bF;}
    351352  //if (this->getOwner() == this->getHostID())
    352     this->calculateVelocity(time);
     353  this->calculateVelocity(time);
    353354
    354355
     
    363364
    364365  //orient the spaceship in direction of the mouse
    365    rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
    366    if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
     366  rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
     367  if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
    367368    this->setAbsDir( rotQuat);
    368    //this->setAbsDirSoft(mouseDir,5);
     369  //this->setAbsDirSoft(mouseDir,5);
    369370
    370371  // this is the air friction (necessary for a smooth control)
     
    388389  this->shiftCoor(move);
    389390
    390 //   PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());
     391  //   PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());
    391392
    392393}
     
    409410
    410411  if( this->bUp )
    411    {
    412      //this->shiftCoor(this->getAbsDirX());
    413       //accel += (this->getAbsDirX())*2;
    414       accel += (this->getAbsDirX())*acceleration;
    415 
    416    }
     412  {
     413    //this->shiftCoor(this->getAbsDirX());
     414    //accel += (this->getAbsDirX())*2;
     415    accel += (this->getAbsDirX())*acceleration;
     416
     417  }
    417418
    418419  if( this->bDown )
    419    {
    420      //this->shiftCoor((this->getAbsDirX())*-1);
    421      //accel -= (this->getAbsDirX())*2;
     420  {
     421    //this->shiftCoor((this->getAbsDirX())*-1);
     422    //accel -= (this->getAbsDirX())*2;
    422423    //if(velocity.len() > 50)
    423      accel -= (this->getAbsDirX())*0.5*acceleration;
    424 
    425 
    426 
    427    }
     424    accel -= (this->getAbsDirX())*0.5*acceleration;
     425
     426
     427
     428  }
    428429
    429430  if( this->bLeft/* > -this->getRelCoor().z*2*/)
    430431  {
    431432    this->shiftDir(Quaternion(time, Vector(0,1,0)));
    432 //    accel -= rightDirection;
     433    //    accel -= rightDirection;
    433434    //velocityDir.normalize();
    434435    //rot +=Vector(1,0,0);
     
    449450  {
    450451    mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    451 //    accel -= rightDirection;
     452    //    accel -= rightDirection;
    452453    //velocityDir.normalize();
    453454    //rot +=Vector(1,0,0);
     
    467468    this->shiftDir(Quaternion(time, Vector(0,0,1)));
    468469
    469 //    accel += upDirection;
     470    //    accel += upDirection;
    470471    //velocityDir.normalize();
    471472    //rot += Vector(0,0,1);
     
    495496
    496497  if( event.type == KeyMapper::PEV_LEFT)
    497       this->bRollL = event.bPressed;
     498    this->bRollL = event.bPressed;
    498499  else if( event.type == KeyMapper::PEV_RIGHT)
    499       this->bRollR = event.bPressed;
     500    this->bRollR = event.bPressed;
    500501  else if( event.type == KeyMapper::PEV_FORWARD)
    501502    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
Note: See TracChangeset for help on using the changeset viewer.