Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 16, 2006, 3:34:04 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: does not run anymore with scripts, but i think, it is on track

lua_State is now handled over the Global Executor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/world_entities/space_ships/space_ship.cc

    r9716 r9746  
    5959#include "script_class.h"
    6060CREATE_SCRIPTABLE_CLASS(SpaceShip, SpaceShip::classID(),
    61                         addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
    62                         ->addMethod("fire", ExecutorLua1<Playable, bool>(&Playable::fire))
    63                         ->addMethod("loadModel", ExecutorLua2<WorldEntity,const std::string& ,float>(&WorldEntity::loadModel2))
    64                         ->addMethod("setName", ExecutorLua1<BaseObject,const std::string&>(&BaseObject::setName))
    65                         ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
    66                         ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
    67                        //Coordinates
    68                         ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    69                         ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    70                         ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    71                         ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     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))
    7272                       );
    7373
     
    118118void SpaceShip::init()
    119119{
    120 //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
     120  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    121121  this->registerObject(this, SpaceShip::_objectList);
    122122
     
    147147  controlVelocityY = 150;
    148148  shipInertia = 1.5;
    149 //  cycle = 0.0;
     149  //  cycle = 0.0;
    150150
    151151  this->setHealthMax(100);
     
    158158  this->pitchDir = this->getAbsDir();
    159159
    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);
     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);
    170170
    171171  //add events to the eventlist
     
    202202  this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
    203203  this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-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)));:
     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)));:
    213213
    214214  this->getWeaponManager().getFixedTarget()->setParent(this);
     
    312312void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
    313313{
    314 
    315314}
    316315
     
    334333
    335334  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
    336    {
     335  {
    337336    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
    338337    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     
    344343    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
    345344    xMouse = yMouse = 0;
    346    }
    347 
    348 
    349 //   if( this != State::getPlayer()->getControllable())
    350 //     return;
     345  }
     346
     347
     348  //   if( this != State::getPlayer()->getControllable())
     349  //     return;
    351350
    352351  // spaceship controlled movement fire(bool bF){ this->bFire = bF;}
    353352  //if (this->getOwner() == this->getHostID())
    354     this->calculateVelocity(time);
     353  this->calculateVelocity(time);
    355354
    356355
     
    365364
    366365  //orient the spaceship in direction of the mouse
    367    rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
    368    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)
    369368    this->setAbsDir( rotQuat);
    370    //this->setAbsDirSoft(mouseDir,5);
     369  //this->setAbsDirSoft(mouseDir,5);
    371370
    372371  // this is the air friction (necessary for a smooth control)
     
    390389  this->shiftCoor(move);
    391390
    392 //   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());
    393392
    394393}
     
    411410
    412411  if( this->bUp )
    413    {
    414      //this->shiftCoor(this->getAbsDirX());
    415       //accel += (this->getAbsDirX())*2;
    416       accel += (this->getAbsDirX())*acceleration;
    417 
    418    }
     412  {
     413    //this->shiftCoor(this->getAbsDirX());
     414    //accel += (this->getAbsDirX())*2;
     415    accel += (this->getAbsDirX())*acceleration;
     416
     417  }
    419418
    420419  if( this->bDown )
    421    {
    422      //this->shiftCoor((this->getAbsDirX())*-1);
    423      //accel -= (this->getAbsDirX())*2;
     420  {
     421    //this->shiftCoor((this->getAbsDirX())*-1);
     422    //accel -= (this->getAbsDirX())*2;
    424423    //if(velocity.len() > 50)
    425      accel -= (this->getAbsDirX())*0.5*acceleration;
    426 
    427 
    428 
    429    }
     424    accel -= (this->getAbsDirX())*0.5*acceleration;
     425
     426
     427
     428  }
    430429
    431430  if( this->bLeft/* > -this->getRelCoor().z*2*/)
    432431  {
    433432    this->shiftDir(Quaternion(time, Vector(0,1,0)));
    434 //    accel -= rightDirection;
     433    //    accel -= rightDirection;
    435434    //velocityDir.normalize();
    436435    //rot +=Vector(1,0,0);
     
    451450  {
    452451    mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    453 //    accel -= rightDirection;
     452    //    accel -= rightDirection;
    454453    //velocityDir.normalize();
    455454    //rot +=Vector(1,0,0);
     
    469468    this->shiftDir(Quaternion(time, Vector(0,0,1)));
    470469
    471 //    accel += upDirection;
     470    //    accel += upDirection;
    472471    //velocityDir.normalize();
    473472    //rot += Vector(0,0,1);
     
    497496
    498497  if( event.type == KeyMapper::PEV_LEFT)
    499       this->bRollL = event.bPressed;
     498    this->bRollL = event.bPressed;
    500499  else if( event.type == KeyMapper::PEV_RIGHT)
    501       this->bRollR = event.bPressed;
     500    this->bRollR = event.bPressed;
    502501  else if( event.type == KeyMapper::PEV_FORWARD)
    503502    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
Note: See TracChangeset for help on using the changeset viewer.