Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9159 in orxonox.OLD for branches/presentation


Ignore:
Timestamp:
Jul 4, 2006, 5:38:24 PM (18 years ago)
Author:
bensch
Message:

added laser-cannon

Location:
branches/presentation/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/space_ships/spacecraft_2d.cc

    r9149 r9159  
    9191
    9292  //weapons:
    93   Weapon* wpRight = new TestGun(0);
     93  Weapon* wpRight = dynamic_cast<Weapon*>(Factory::fabricate(CL_LASER_CANNON));
    9494  wpRight->setName("testGun Right");
    95   Weapon* wpLeft = new TestGun(1);
     95  Weapon* wpLeft = dynamic_cast<Weapon*>(Factory::fabricate(CL_LASER_CANNON));
    9696  wpLeft->setName("testGun Left");
    9797  //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_HYPERBLASTER));
     
    123123  this->cameraLook = 0.0f;
    124124  this->rotation = 0.0f;
    125   this->acceleration = 10.0f;
     125  this->acceleration = 20.0f;
    126126  this->airFriction = 0.0f;
    127127
     
    136136  this->travelNode = new PNode();
    137137
     138  this->loadModel("models/ships/mantawing.obj", 5.0f);
    138139
    139140  // camera - issue
     
    180181  this->getWeaponManager().setSlotCount(5);
    181182
    182   this->getWeaponManager().setSlotPosition(0, Vector(-0.28, 1.186, -2.750));
     183  this->getWeaponManager().setSlotPosition(0, Vector(1.843, -0.335, 2.029) * 5.0);
    183184  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    184185
    185   this->getWeaponManager().setSlotPosition(1, Vector(-0.28, 1.186, 2.750));
     186  this->getWeaponManager().setSlotPosition(1, Vector(1.843, -0.335, -2.029) * 5.0);
    186187  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    187188
     
    207208  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
    208209  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
     210
     211
     212
    209213}
    210214
     
    454458        this->velocity += (accelerationDir - damping)* dt;
    455459
    456         if (this->getRelCoor().z > this->travelDistance.y && accel.z > 0.0)
     460        if (this->getRelCoor().z > this->travelDistance.y && velocity.z > 0.0)
    457461          this->velocity.z = 0.0f;
    458         if (this->getRelCoor().z < -this->travelDistance.y && accel.z < 0.0)
     462        if (this->getRelCoor().z < -this->travelDistance.y && velocity.z < 0.0)
    459463          this->velocity.z = 0.0f;
    460464
    461         if (this->getRelCoor().x > this->travelDistance.x && accel.x > 0.0)
     465        if (this->getRelCoor().x > this->travelDistance.x && velocity.x > 0.0)
    462466          this->velocity.x = 0.0f;
    463         if (this->getRelCoor().x < -this->travelDistance.x && accel.x < 0.0)
     467        if (this->getRelCoor().x < -this->travelDistance.x && velocity.x < 0.0)
    464468          this->velocity.x = 0.0f;
    465469
     
    467471        this->shiftCoor (this->velocity * dt);
    468472        if (accel.z == 0)
    469           this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 3.0f);
     473          this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 5.0f);
    470474        else
    471           this->setRelDirSoft(Quaternion(this->velocity.z * .01, Vector(1,0,0)), 2.0f);
     475          this->setRelDirSoft(Quaternion(this->velocity.z * .004, Vector(1,0,0)), 4.5f);
    472476      }
    473477      break;
  • branches/presentation/src/world_entities/weapons/laser_cannon.cc

    r9131 r9159  
    3333CREATE_FACTORY(LaserCannon, CL_LASER_CANNON);
    3434
    35 /**
    36  *  standard constructor
    37 
    38    creates a new weapon
    39 */
    40 LaserCannon::LaserCannon ( int leftRight)
    41   : Weapon()
    42 {
    43   this->init();
    44 
    45 
    46   this->leftRight = leftRight;
    47 
    48   this->objectComponent1 = new PNode();
    49   Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this->objectComponent1);
    50   Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
    51   Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
    52   //parent->addChild(this->objectComponent1, PNODE_ALL);
    53   this->addChild(this->objectComponent1);
    54 
    55   animation1->setInfinity(ANIM_INF_CONSTANT);
    56   animation2->setInfinity(ANIM_INF_CONSTANT);
    57   animation3->setInfinity(ANIM_INF_CONSTANT);
    58 
    59   if( this->leftRight == W_LEFT)
    60   {
    61     this->setEmissionPoint(1.0, -0.6, -0.2);
    62 
    63     animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    64     animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    65     animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
    66 
    67     animation2->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    68     animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    69 
    70     animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    71     animation3->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    72   }
    73   else if( this->leftRight == W_RIGHT)
    74   {
    75     this->setEmissionPoint(1.0, -0.6, 0.3);
    76 
    77     this->objectComponent1->setRelCoor(Vector(0,0,0.35));
    78     animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    79     animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    80     animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
    81 
    82     animation2->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    83     animation2->addKeyFrame(Vector(.0, .0, .0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    84 
    85     animation3->addKeyFrame(Vector(.0, .0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    86     animation3->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
    87   }
    88 }
    89 
    9035
    9136LaserCannon::LaserCannon(const TiXmlElement* root)
     
    11156//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);
    11257
    113   this->loadModel("models/guns/laser_cannon.obj");
     58  this->loadModel("models/guns/lasercannon.obj", 5.0f);
    11459
    11560  this->setStateDuration(WS_SHOOTING, .1);
     
    12974  this->setProjectileType(CL_LASER);
    13075  this->prepareProjectiles(100);
    131 
     76  this->setEmissionPoint(Vector(2.8,0,0) * 5.0);
    13277}
    13378
     
    184129  pj->activate();
    185130}
    186 
    187 
    188 
    189 /**
    190  *  this will draw the weapon
    191 */
    192 void LaserCannon::draw () const
    193 {
    194   /* draw gun body */
    195   glMatrixMode(GL_MODELVIEW);
    196   glPushMatrix();
    197   glTranslatef (this->getAbsCoor ().x,
    198                 this->getAbsCoor ().y,
    199                 this->getAbsCoor ().z);
    200 
    201   Vector tmpRot = this->getAbsDir().getSpacialAxis();
    202   glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    203 
    204   if( this->leftRight == W_RIGHT)
    205     glScalef(1.0, 1.0, -1.0);
    206   static_cast<StaticModel*>(this->getModel())->draw(1);
    207   glPopMatrix();
    208 
    209   /* draw objectComponent1: gun coil - animated stuff */
    210   glPushMatrix();
    211   glTranslatef (this->objectComponent1->getAbsCoor ().x,
    212                 this->objectComponent1->getAbsCoor ().y,
    213                 this->objectComponent1->getAbsCoor ().z);
    214   tmpRot = this->objectComponent1->getAbsDir().getSpacialAxis();
    215   glRotatef (this->objectComponent1->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    216   static_cast<StaticModel*>(this->getModel())->draw(0);
    217   glPopMatrix();
    218 }
    219 
  • branches/presentation/src/world_entities/weapons/laser_cannon.h

    r9131 r9159  
    2727
    2828
    29 //! a weapon can be left or right sided
    30 /**
    31  * @todo this will be reset with mirror X/Y/Z
    32  */
    33 #define    W_LEFT        0
    34 #define    W_RIGHT       1
    35 
    36 
    3729class LaserCannon : public Weapon
    3830  {
    3931  public:
    40     LaserCannon (int leftRight);
    41     LaserCannon (const TiXmlElement* root);
     32    LaserCannon (const TiXmlElement* root = NULL);
    4233    virtual ~LaserCannon ();
    4334
     
    5041    virtual void fire();
    5142
    52     virtual void draw() const;
    53 
    5443  private:
    5544    PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
     45  };
    5646
    57     int leftRight;   // this will become an enum
    58   };
    5947#endif /* _LASER_CANNON_H */
Note: See TracChangeset for help on using the changeset viewer.