Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5435 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Oct 25, 2005, 5:31:54 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: power-ups implemented (simple-mode)

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/abstract_model.h

    r5430 r5435  
    1616/*!
    1717 * @file abstract_model.h
    18   *  Definition of an abstract model. containing all needed for other model
    19 */
     18 *  Definition of an abstract model. containing all needed for other model
     19 */
    2020
    2121#ifndef _ABSTRACT_MODEL_H
  • trunk/src/lib/math/vector.h

    r5420 r5435  
    187187  inline Vector getSpacialAxis() const { return this->v / sin(acos(w));/*sqrt(v.x*v.x + v.y*v.y + v.z+v.z);*/ };
    188188  /** @returns the rotational angle of this Quaternion around getSpacialAxis()  !! IN DEGREE !! */
    189   inline float getSpacialAxisAngle() const { return 360.0 / M_PI * acos(this->w); };
     189  inline float getSpacialAxisAngle() const { return 360.0 / M_PI * acos( this->w ); };
    190190
    191191  static Quaternion quatSlerp(const Quaternion& from, const Quaternion& to, float t);
  • trunk/src/world_entities/player.cc

    r5420 r5435  
    9292  wpLeft->setName("testGun Left");
    9393
    94   Weapon* turret1 = new Turret(this->weaponMan);
    95   turret1->setName("Turret1");
    96   turret1->setStateDuration(WS_SHOOTING, .2);
    97   Weapon* turret2 = new Turret(this->weaponMan);
    98   turret2->setName("Turret2");
    99   turret2->setStateDuration(WS_SHOOTING, .3);
    100   Weapon* turret3 = new Turret(this->weaponMan);
    101   turret3->setName("Turret3");
    102   turret3->setStateDuration(WS_SHOOTING, .17);
    103 
    104   Weapon* turret4 = new Turret(this->weaponMan);
    105   turret4->setName("Turret4");
    106   turret4->setStateDuration(WS_SHOOTING, .3);
    107 
    108 
    10994  this->weaponMan->addWeapon(wpLeft, 1, 0);
    11095  this->weaponMan->addWeapon(wpRight,1 ,1);
    111   this->weaponMan->addWeapon(turret1, 2, 2);
    112   this->weaponMan->addWeapon(turret2, 2, 3);
    113   this->weaponMan->addWeapon(turret3, 2, 4);
    114   this->weaponMan->addWeapon(turret4, 2, 5);
    115 
    11696  //this->weaponMan->addWeapon(turret, 3, 0);
    11797
    118   this->weaponMan->changeWeaponConfig(0);
     98  this->weaponMan->changeWeaponConfig(1);
    11999}
    120100
     
    153133
    154134  this->weaponMan = new WeaponManager(this);
    155   this->weaponMan->setSlotCount(6);
     135  this->weaponMan->setSlotCount(10);
    156136
    157137  this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0));
     
    171151  this->weaponMan->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    172152
     153  this->weaponMan->setSlotPosition(6, Vector(-2.0, 0.1, -2.0));
     154  this->weaponMan->setSlotPosition(7, Vector(-2.0, 0.1, 2.0));
     155
     156  this->weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
     157  this->weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
     158
     159  this->weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
     160  this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));
     161
    173162}
    174163
     
    222211
    223212
    224 
    225 /**
    226  *  if the player is hit, call this function
    227  * @param weapon hit by this weapon
    228  * @param loc ??
    229 */
    230 void Player::hit (WorldEntity* weapon, Vector* loc)
    231 {
    232 }
    233 
    234 
    235 /**
    236   *  Collision with another Entity has this effect
    237   * @param other the other colider
    238   * @param ownhitflags ??
    239   * @param otherhitflags ??
    240 */
    241 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags)
    242 {
    243 }
    244 
     213WorldEntity* ref = NULL;
     214/**
     215 *  this function is called, when two entities collide
     216 * @param entity: the world entity with whom it collides
     217 *
     218 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
     219 */
     220void Player::collidesWith(WorldEntity* entity, const Vector& location)
     221{
     222  if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)
     223  {
     224    this->ADDWEAPON();
     225    ref = entity;
     226    }
     227//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
     228}
    245229
    246230/**
     
    343327    this->weaponMan->previousWeaponConfig();
    344328}
     329
     330// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
     331int slot = 2;
     332void Player::ADDWEAPON()
     333{
     334  Weapon* turret1 = new Turret(this->weaponMan);
     335  turret1->setName("Turret");
     336  turret1->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
     337
     338  this->weaponMan->addWeapon(turret1, 2, slot++);
     339
     340  this->weaponMan->changeWeaponConfig(2);
     341}
  • trunk/src/world_entities/player.h

    r5257 r5435  
    4141    virtual void postSpawn();
    4242    virtual void leftWorld();
    43     virtual void hit(WorldEntity* weapon, Vector* loc);
    44     virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags);
    4543
     44    virtual void collidesWith(WorldEntity* entity, const Vector& location);
    4645    virtual void tick(float time);
    4746    virtual void draw();
     
    5453    void weaponAction();
    5554
     55    // !! temporary !!
     56    void ADDWEAPON();
    5657
    5758  private:
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r5434 r5435  
    1717#include "turret_power_up.h"
    1818#include "factory.h"
     19#include "state.h"
     20#include "list.h"
    1921
    2022using namespace std;
    2123
    2224CREATE_FACTORY(TurretPowerUp);
     25
     26GLUquadricObj* TurretPowerUp_sphereObj = NULL;
     27Material*      TurretPowerUp_sphereMat = NULL;
    2328
    2429
     
    3641
    3742
    38 TurretPowerUp::~TurretPowerUp () {}
     43TurretPowerUp::~TurretPowerUp () {
     44
     45}
    3946
    4047
     
    4249{
    4350  this->setClassID(CL_TURRET_POWER_UP, "TurretPowerUp");
    44   this->loadModel("models/guns/turret1.obj");
     51  this->loadModelWithScale("models/guns/turret1.obj", 2.0);
     52
     53  if (TurretPowerUp_sphereObj == NULL)
     54    TurretPowerUp_sphereObj = gluNewQuadric();
     55  if(TurretPowerUp_sphereMat == NULL)
     56  {
     57    TurretPowerUp_sphereMat = new Material("TurretPowerUp_Sphere");
     58    TurretPowerUp_sphereMat->setTransparency(.1);
     59  }
     60  this->rotation = Vector(0,1,0);
     61  this->cycle    = 0;
    4562}
    4663
     
    5168
    5269}
     70
     71
     72/**
     73 * this function is called, when two entities collide
     74 * @param entity: the world entity with whom it collides
     75 *
     76 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
     77 */
     78void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location)
     79{
     80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
     81 if (entity->isA(CL_PLAYER))
     82  State::getWorldEntityList()->remove(this);
     83}
     84
     85/**
     86 *  this method is called every frame
     87 * @param time: the time in seconds that has passed since the last tick
     88 *
     89 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
     90*/
     91void TurretPowerUp::tick(float dt)
     92{
     93  this->shiftDir(Quaternion(dt, this->rotation));
     94  this->cycle+=dt;
     95
     96}
     97
     98/**
     99 *  the entity is drawn onto the screen with this function
     100 *
     101 * This is a central function of an entity: call it to let the entity painted to the screen.
     102 * Just override this function with whatever you want to be drawn.
     103*/
     104void TurretPowerUp::draw()
     105{  glMatrixMode(GL_MODELVIEW);
     106  glPushMatrix();
     107  /* translate */
     108  glTranslatef (this->getAbsCoor ().x,
     109                this->getAbsCoor ().y + cos(this->cycle*3.0)*2.0,
     110                this->getAbsCoor ().z);
     111  /* rotate */
     112  Vector tmpRot = this->getAbsDir().getSpacialAxis();
     113  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     114  TurretPowerUp_sphereMat->select();
     115//  gluSphere(TurretPowerUp_sphereObj, 3, 5, 5);
     116  this->model->draw();
     117  glPopMatrix();
     118
     119}
     120
  • trunk/src/world_entities/power_ups/turret_power_up.h

    r5434 r5435  
    1616  virtual ~TurretPowerUp ();
    1717
     18  virtual void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location);
     19  virtual void tick(float dt);
     20  virtual void draw();
     21
    1822  private:
    1923   void init();
    2024   void loadParams(const TiXmlElement* root);
     25
     26  private:
     27   Vector              rotation;
     28   float               cycle;
    2129};
    2230
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5208 r5435  
    152152 * this is used, to identify to which ship/man/whatever this WeaponManager is connected.
    153153 * also all the Slots will be subconnected to this parent.
     154 *
     155 * The reason this function exists is that the WeaponManager is neither a WorldEntity nor
     156 * a PNode.
    154157 */
    155158void WeaponManager::setParent(PNode* parent)
  • trunk/src/world_entities/weapons/weapon_manager.h

    r4972 r5435  
    2020
    2121
    22 #define    WM_MAX_SLOTS            8              //!< How many slots the WeaponManager has at its max
     22#define    WM_MAX_SLOTS            10             //!< How many slots the WeaponManager has at its max
    2323#define    WM_MAX_CONFIGS          4              //!< The maximum number of predefined Configurations
    2424#define    WM_MAX_LOADED_WEAPONS   20             //!< The
  • trunk/src/world_entities/world_entity.cc

    r5431 r5435  
    203203                this->getAbsCoor ().y,
    204204                this->getAbsCoor ().z);
    205   /* rotate */
     205  /* rotate */ // FIXME: devise a new Way to rotate this
    206206  this->getAbsDir ().matrix (matrix);
    207207  glMultMatrixf((float*)matrix);
Note: See TracChangeset for help on using the changeset viewer.