Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6234 in orxonox.OLD for branches/spaceshipcontrol


Ignore:
Timestamp:
Dec 21, 2005, 3:14:00 PM (19 years ago)
Author:
snellen
Message:

playable.cc and space_ship.cc updated

Location:
branches/spaceshipcontrol/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/story_entities/world.cc

    r6222 r6234  
    341341  }
    342342
    343   // bind camera
    344   playable->addChild (this->localCamera);
    345343
    346344//   //localCamera->setParent(TrackNode::getInstance());
  • branches/spaceshipcontrol/src/world_entities/playable.cc

    r6142 r6234  
    2020#include "event_handler.h"
    2121#include "player.h"
     22#include "state.h"
    2223
    2324
     
    7273    for (ev = this->events.begin(); ev != events.end(); ev++)
    7374      evh->subscribe(player, ES_GAME, (*ev));
    74 
     75    this->enter();
    7576    return true;
    7677  }
     
    9798      evh->unsubscribe( ES_GAME, (*ev));
    9899
     100    this->leave();
    99101    this->currentPlayer = NULL;
    100102    return true;
     
    127129
    128130
     131void  Playable::attachCamera()
     132{
     133       State::getCamera()->setParentSoft(this);
     134       State::getCameraTarget()->setParentSoft(this);
     135
     136}
     137
     138
     139void  Playable::detachCamera()
     140{
     141
     142
     143}
  • branches/spaceshipcontrol/src/world_entities/playable.h

    r6222 r6234  
    2525    virtual ~Playable();
    2626
    27     virtual void enter() {};
    28     virtual void leave() {};
     27    virtual void enter()=0;
     28    virtual void leave()=0;
    2929
    3030    virtual void addWeapon(Weapon* weapon )  {}//= 0;
     
    3434    bool subscribePlayer(Player* player);
    3535    bool unsubscribePlayer(Player* player);
     36
     37    void attachCamera();
     38    void detachCamera();
    3639
    3740    virtual void process(const Event &event) = 0;
  • branches/spaceshipcontrol/src/world_entities/player.cc

    r6222 r6234  
    9595         if (this->controllable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->controllable->getAbsCoor()).len() < 10.0)
    9696       {
    97          this->controllable->leave();
     97 
    9898         this->disconnectControllable();
    9999         this->setControllable(dynamic_cast<Playable*>(*node));
    100          this->controllable->enter();
    101          State::getCamera()->setParentSoft(this->controllable);
    102          State::getCameraTarget()->setParentSoft(this->controllable);
    103100
    104101         break;
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc

    r6222 r6234  
    112112  PRINTF(4)("SPACESHIP INIT\n");
    113113
    114 //   EventHandler::getInstance()->grabEvents(true);
     114  EventHandler::getInstance()->grabEvents(true);
    115115
    116116  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     
    193193{
    194194  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
     195  this->attachCamera();
    195196
    196197
     
    200201{
    201202  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
     203  this->detachCamera();
    202204
    203205
     
    284286
    285287  //orient the spaceship in direction of the mouse
    286    rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
    287    if (this->getAbsDir().distance(rotQuat) > 0.001)
     288   rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, fabsf(time)*3.0);
     289   if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
    288290    this->setAbsDir( rotQuat);
    289291   //this->setAbsDirSoft(mouseDir,5);
     
    440442    this->yMouse = event.yRel;
    441443    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    442     if( xMouse*xMouse + yMouse*yMouse < 0.9)
    443      this->setAbsDir(mouseDir);
     444   // if( xMouse*xMouse + yMouse*yMouse < 0.9)
     445     //this->setAbsDir(mouseDir);
    444446  }
    445447}
  • branches/spaceshipcontrol/src/world_entities/weapons/guided_missile.cc

    r6222 r6234  
    146146{
    147147
    148   if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
     148 
     149if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
    149150   {
    150151    speed = velocity.len();
     
    152153
    153154    if(velocity.dot(diffVector) != 0)
    154     {
     155     {
    155156     correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
    156157
     
    159160      else if (velocity.dot(diffVector) < 0)
    160161        velocity -= correctionVector;
    161     }
     162     }
    162163    else
    163164      velocity += diffVector * agility;
Note: See TracChangeset for help on using the changeset viewer.