Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 7, 2005, 3:54:49 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/levelloader: Merged trunk into branch… still not working though…

Location:
orxonox/branches/levelloader/src/world_entities
Files:
2 deleted
12 edited
4 copied

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelloader/src/world_entities/environment.cc

    r3605 r3746  
    3030Environment::Environment () : WorldEntity()
    3131{
    32   this->model = new OBJModel("../data/models/fighter.obj");
     32  this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);
     33  //  this->model = new OBJModel("../data/models/fighter.obj");
    3334}
    3435
     
    5455        string = grabParameter( root, "model");
    5556        if( string != NULL)
    56                 this->model = new OBJModel( string);
     57        this->model = (Model*) ResourceManager::getInstance()->load( string, RP_LEVEL);
    5758        else
    5859        {
    5960                PRINTF0("Environment is missing a proper 'model'\n");
    60                 this->model = new OBJModel( "../data/models/reaplow.obj");
     61        this->model = (Model*) ResourceManager::getInstance()->load( "cube", RP_LEVEL);
    6162        }
    6263        if( this->model == NULL)
  • orxonox/branches/levelloader/src/world_entities/player.cc

    r3605 r3746  
    2020#include "player.h"
    2121
     22#include "track_manager.h"
     23#include "objModel.h"
     24#include "resource_manager.h"
     25#include "weapon.h"
     26#include "test_gun.h"
     27#include "world.h"
     28
     29#include "list.h"
    2230#include "stdincl.h"
    23 //#include "collision.h"
    24 #include "objModel.h"
    25 #include "list.h"
    26 #include "weapon.h"
    27 #include "track_manager.h"
    2831
    2932using namespace std;
     
    3538   \param isFree if the player is free
    3639*/
    37 Player::Player(bool isFree) : WorldEntity(isFree)
    38 {
    39   this->model = new OBJModel("../data/models/reaplow.obj");
     40Player::Player() : WorldEntity()
     41{
    4042  this->weapons = new tList<Weapon>();
    4143  this->activeWeapon = NULL;
    42 
     44  /*
     45    this is the debug player - actualy we would have to make a new
     46     class derivated from Player for each player. for now, we just use
     47     the player.cc for debug also
     48  */
     49  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    4350  travelSpeed = 15.0;
    44   velocity = Vector();
     51  velocity = new Vector();
    4552  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    4653  bFire = false;
    4754  acceleration = 10.0;
     55  //weapons:
     56  Weapon* wp = new TestGun(this, new Vector(-1.1, 0.0, 2.6), new Quaternion());
     57  this->weapons->add(wp);
     58  this->activeWeapon = wp; 
    4859}
    4960
     
    5364Player::~Player ()
    5465{
    55   Weapon* w = this->weapons->enumerate();
    56   while( w != NULL)
    57     {
    58       delete w;
    59       w = this->weapons->nextElement();
    60     }
     66  /* do not delete the weapons, they are contained in the pnode tree
     67     and will be deleted there.
     68     this only frees the memory allocated to save the list.
     69  */
    6170  delete this->weapons;
    62  
    63   //delete this->velocity;
    6471}
    6572
     
    94101        string = grabParameter( root, "model");
    95102        if( string != NULL)
    96                 this->model = new OBJModel( string);
     103        this->model = (Model*)ResourceManager::getInstance()->load(string, OBJ, RP_CAMPAIGN);
    97104        else
    98105        {
    99106                PRINTF0("Player is missing a proper 'model'\n");
    100                 this->model = new OBJModel( "../data/models/reaplow.obj");
     107        this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    101108        }
    102109        if( this->model == NULL)
     
    104111                PRINTF0("Player model '%s' could not be loaded\n", string);
    105112        }
     113       
     114        this->weapons = new tList<Weapon>();
     115  this->activeWeapon = NULL;
     116  /*
     117    this is the debug player - actualy we would have to make a new
     118     class derivated from Player for each player. for now, we just use
     119     the player.cc for debug also
     120  */
     121  travelSpeed = 15.0;
     122  velocity = new Vector();
     123  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     124  bFire = false;
     125  acceleration = 10.0;
     126  //weapons:
     127  Weapon* wp = new TestGun(this, new Vector(-1.1, 0.0, 2.6), new Quaternion());
     128  this->weapons->add(wp);
     129  this->activeWeapon = wp;
    106130}
    107131
     
    192216void Player::tick (float time)
    193217{
     218  /* link tick to weapon */
     219  this->activeWeapon->tick(time);
    194220  // player controlled movement
    195   this->move (time);
     221  this->move(time);
    196222  // weapon system manipulation
    197   this->fire();
     223  this->weapon();
    198224}
    199225
     
    214240  //orthDirection = orthDirection.cross (direction);
    215241
    216   if( this->bUp && this->getRelCoor().x < 20)
     242  if( this->bUp && this->getRelCoor()->x < 20)
    217243    accel = accel+(direction*acceleration);
    218   if( this->bDown && this->getRelCoor().x > -5)
     244  if( this->bDown && this->getRelCoor()->x > -5)
    219245    accel = accel-(direction*acceleration);
    220   if( this->bLeft &&  TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)
     246  if( this->bLeft &&  TrackManager::getInstance()->getWidth() > -this->getRelCoor()->z*2)
    221247    accel = accel - (orthDirection*acceleration);
    222   if( this->bRight &&  TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
     248  if( this->bRight &&  TrackManager::getInstance()->getWidth() > this->getRelCoor()->z*2)
    223249    accel = accel + (orthDirection*acceleration);
    224250  if( this->bAscend )
     
    233259   \brief weapon manipulation by the player
    234260*/
    235 void Player::fire()
    236 {
    237   if(this->bFire)
     261void Player::weapon()
     262{
     263  if( this->bFire)
    238264    {
    239265      if(this->activeWeapon != NULL)
    240266        this->activeWeapon->fire();
    241267    }
    242   if(this->bWeaponChange)
     268  if( this->bWeaponChange && this->weapons->getSize() > 1)
    243269    {
    244       Weapon* w = this->weapons->enumerate();
     270      PRINTF(1)("changing the weapon of the player: deactivate old, activate new\n");
     271      this->activeWeapon->deactivate();
     272      //this->weapons->enumerate();  FIX: strang weapon change...
    245273      this->activeWeapon = this->weapons->nextElement(this->activeWeapon);
     274      this->activeWeapon->activate();
    246275    }
    247276}
  • orxonox/branches/levelloader/src/world_entities/player.h

    r3605 r3746  
    1010
    1111template<class T> class tList;
    12 class OBJModel;
    1312class Weapon;
     13class Vector;
     14class World;
    1415
    1516//! Basic controllable WorldEntity
     
    1920 
    2021 public:
    21   Player(bool isFree = false);
     22  Player();
    2223  Player(TiXmlElement* root);
    2324  virtual ~Player();
     
    4849  tList<Weapon>* weapons;//!< a list of weapon
    4950  Weapon* activeWeapon;  //!< the weapon that is currenty activated
     51  World* myWorld;        //!< reference to the world object
    5052
    51   Vector velocity;       //!< the velocity of the player.
     53  Vector* velocity;       //!< the velocity of the player.
    5254  float travelSpeed;     //!< the current speed of the player (to make soft movement)
    5355  float acceleration;    //!< the acceleration of the player.
    5456 
    5557  void move(float time);
    56   void fire(void);
     58  void weapon(void);
    5759 
    5860};
  • orxonox/branches/levelloader/src/world_entities/projectile.cc

    r3605 r3746  
    1818
    1919#include "projectile.h"
    20 #include "stdincl.h"
     20
    2121#include "world_entity.h"
     22#include "weapon.h"
     23#include "null_parent.h"
     24#include "model.h"
    2225#include "vector.h"
    23 #include "objModel.h"
    2426
    2527using namespace std;
     
    2931   \brief standard constructor
    3032*/
    31 Projectile::Projectile () : WorldEntity()
     33Projectile::Projectile (Weapon* weapon) : WorldEntity()
    3234{
    33   this->model = new OBJModel("");
     35  this->model = (Model*)ResourceManager::getInstance()->load("sphere", PRIM, RP_LEVEL);
     36  this->weapon = weapon;
     37  this->flightDirection = NULL;
     38  this->currentLifeTime = 0.0f;
     39  this->ttl = 0.75f; /* sec */
     40  this->speed = 2.0f;
    3441}
    3542
     
    4047Projectile::~Projectile ()
    4148{
    42 
     49  /*
     50     do not delete the test projectModel, since it is pnode
     51     and will be cleaned out by world
     52  */
     53  //delete this->projectileModel;
    4354}
    4455
     56
     57/**
     58   \brief this sets the flight direction of the projectile
     59   \param directin in which to flight
     60
     61   this function will calculate a vector out of this to be used in the
     62   tick function
     63*/
     64void Projectile::setFlightDirection(Quaternion flightDirection)
     65{
     66  if( this->flightDirection == NULL)
     67    this->flightDirection = new Vector();
     68  Vector v(1, 0, 0);
     69  *this->flightDirection = flightDirection.apply(v);
     70  this->flightDirection->normalize();
     71}
     72
     73
     74/**
     75   \brief this sets the time to life of the projectile
     76   \param ttl in second
     77
     78   after this life time, the projectile will garbage collect itself
     79*/
     80void Projectile::setTTL(float ttl)
     81{
     82  this->ttl = ttl;
     83}
     84
     85
     86/**
     87   \brief sets the speed of the projectile
     88*/
     89void Projectile::setSpeed(float speed)
     90{
     91  this->speed = speed * 3; /* fix speed settings */
     92  PRINTF(4)("Projectile::setting speed to: %f\n", this->speed);
     93}
    4594
    4695/**
     
    4998*/
    5099void Projectile::tick (float time)
    51 {}
     100{
     101  Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.7);
     102  this->shiftCoor(v);
     103
     104  this->currentLifeTime += time;
     105  if( this->ttl < this->currentLifeTime)
     106    {
     107      PRINTF(5)("FINALIZE==========================\n");
     108      PRINTF(5)("current life time is: %f/%f\n", this->currentLifeTime, this->ttl);
     109      PRINTF(5)("FINALIZE===========================\n");
     110      this->finalize();
     111      this->currentLifeTime = 0.0f;
     112    }
     113}
    52114
    53115/**
  • orxonox/branches/levelloader/src/world_entities/projectile.h

    r3605 r3746  
    22    \projectile.h
    33    \brief a projectile, that is been shooted by a weapon
     4
     5    You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the
     6    shooting funcions work, use the Projectile class. But if you want to implement your own shoots its
     7    different:<br>
     8    Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions
     9    - void tick()
     10    - void draw()
     11    - void hit() (only if you have working collision detection)
     12    When you have implemented these functions you have just to add the projectiles to your weapon. You ll want
     13    to make this by looking into the function
     14    - Weapon::fire()
     15    there you just change the line:
     16    Projectile* pj = new Projectile();    TO     Projectile* pj = new MyOwnProjectileClass();
     17    and schwups it works... :)
    418*/
    519
     
    923#include "world_entity.h"
    1024
     25class Vector;
     26class Weapon;
    1127
    1228class Projectile : public WorldEntity
     
    1531
    1632 public:
    17   Projectile ();
     33  Projectile (Weapon* weapon);
    1834  virtual ~Projectile ();
     35
     36  void setFlightDirection(Quaternion flightDirection);
     37  void setSpeed(float speed);
     38  void setTTL(float ttl);
    1939
    2040  virtual void hit (WorldEntity* weapon, Vector* loc);
     
    2444  virtual void draw ();
    2545
    26  private:
     46 protected:
    2747  //physical attriutes like: force, speed, acceleration etc.
    28 
     48  float speed;                         //!< this is the speed of the projectile
     49  float currentLifeTime;               //!< this is the time, the projectile exists in this world (incremented by tick)
     50  float ttl;                           //!< time to life, after this time, the projectile will garbage collect itself
     51  Vector* flightDirection;             //!< direction in which the shoot flights
     52  Weapon* weapon;                      //!< weapon the shoot belongs to
     53 
    2954};
    3055
  • orxonox/branches/levelloader/src/world_entities/skysphere.cc

    r3605 r3746  
    2626#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
    2727
    28 #include "material.h"
     28
    2929#include "skysphere.h"
    3030#include "stdincl.h"
     31
     32#include "material.h"
    3133#include "vector.h"
    32 #include "world_entity.h"
     34//#include "world_entity.h"
     35
    3336
    3437using namespace std;
     
    100103  glPushMatrix();
    101104  glMatrixMode(GL_MODELVIEW);
    102   glTranslatef(this->absCoordinate.x,
    103                this->absCoordinate.y,
    104                this->absCoordinate.z);
     105  Vector r = this->getAbsCoor();
     106  glTranslatef(r.x, r.y, r.z);
    105107
    106108  //glRotatef(-30, 1, 0, 0);
  • orxonox/branches/levelloader/src/world_entities/skysphere.h

    r3605 r3746  
    1414
    1515/* INCLUDES */
    16 #include "p_node.h"
    1716#include "world_entity.h"
    1817
  • orxonox/branches/levelloader/src/world_entities/terrain.cc

    r3605 r3746  
    1616
    1717#include "terrain.h"
    18 
     18#include "stdincl.h"
     19#include "model.h"
     20#include "vector.h"
    1921#include "glincl.h"
    2022
     
    4345  if (strstr(fileName, ".obj") || strstr(fileName, ".OBJ"))
    4446    {
    45       this->model = (OBJModel*)new OBJModel(fileName);
     47      this->model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_LEVEL);
    4648    }
    4749  else
  • orxonox/branches/levelloader/src/world_entities/weapon.cc

    r3605 r3746  
    2121#include "world_entity.h"
    2222#include "vector.h"
    23 #include "objModel.h"
     23#include "model.h"
    2424#include "projectile.h"
     25#include "list.h"
     26#include "world.h"
    2527
    2628using namespace std;
     
    3234   creates a new weapon
    3335*/
    34 Weapon::Weapon () : WorldEntity()
    35 {}
     36Weapon::Weapon (PNode* parent, Vector* coordinate, Quaternion* direction)
     37  : WorldEntity()
     38{
     39  parent->addChild(this, PNODE_ROTATE_AND_MOVE);
     40  this->setRelCoor(coordinate);
     41  this->setRelDir(direction);
     42  WorldInterface* wi = WorldInterface::getInstance();
     43  this->worldEntities = wi->getEntityList();
     44}
    3645
    3746
     
    145154*/
    146155void Weapon::setWeaponIdleTime(float time)
    147 {}
     156{
     157  this->idleTime = time;
     158}
    148159
    149160/**
     
    155166*/
    156167float Weapon::getWeaponIdleTime(void)
    157 {}
     168{
     169  return this->idleTime;
     170}
    158171
    159172/**
     
    165178*/
    166179bool Weapon::hasWeaponIdleTimeElapsed(void)
    167 {}
     180{
     181  return (this->localTime>this->idleTime)?true:false;
     182}
    168183
    169184
  • orxonox/branches/levelloader/src/world_entities/weapon.h

    r3605 r3746  
    4343
    4444 public:
    45   Weapon ();
     45  Weapon (PNode* parent, Vector* coordinate, Quaternion* direction);
    4646  virtual ~Weapon ();
    4747 
     
    5757  bool isActive(void);
    5858
    59   virtual void setWeaponIdleTime(float time);
    60   virtual float getWeaponIdleTime(void);
    61   virtual bool hasWeaponIdleTimeElapsed(void);
     59  void setWeaponIdleTime(float time);
     60  float getWeaponIdleTime(void);
     61  bool hasWeaponIdleTimeElapsed(void);
    6262
    63   virtual void fire(void);
     63  virtual void fire(void) = 0;
    6464  virtual void hit (WorldEntity* weapon, Vector* loc);
    6565  virtual void destroy(void);
     
    6969  virtual void draw(void);
    7070
     71 protected:
     72  tList<WorldEntity>* worldEntities;
     73  float localTime;
     74  float idleTime;
     75  float slowDownFactor;
    7176
    7277 private:
    7378  bool enabled;
    74   float localTime;
    75   float slowDownFactor;
    7679  Projectile* projectile;
    7780  //WeaponSound sound;
    78 
    7981};
    8082
  • orxonox/branches/levelloader/src/world_entities/world_entity.cc

    r3605 r3746  
    1919
    2020#include "world_entity.h"
    21 #include "stdincl.h"
     21#include "objModel.h"
     22#include "list.h"
     23
     24//#include "stdincl.h"
    2225//#include "collision.h"
    2326
     
    4851{
    4952  // if( collisioncluster != NULL) delete collisioncluster;
    50   delete this->model;
     53  if (this->model)
     54    ResourceManager::getInstance()->unload(this->model);
    5155}
    5256
     
    167171   Handle all stuff that should update with time inside this method (movement, animation, etc.)
    168172*/
    169 void WorldEntity::tick(float time)
     173inline void WorldEntity::tick(float time)
    170174{
    171175}
     
    177181   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    178182*/
    179 void WorldEntity::draw()
     183inline void WorldEntity::draw()
    180184{}
    181185
  • orxonox/branches/levelloader/src/world_entities/world_entity.h

    r3605 r3746  
    77#define _WORLD_ENTITY_H
    88
    9 #include "stdincl.h"
    109#include "p_node.h"
    11 #include "objModel.h"
     10#include "comincl.h"
     11#include "resource_manager.h"
     12
    1213
    1314//class CollisionCluster;
    1415class CharacterAttributes;
     16class Model;
    1517
    1618
     
    4850 
    4951 protected:
    50   OBJModel* model;                  //!< The model that should be loaded for this entity.
     52  Model* model;                  //!< The model that should be loaded for this entity.
    5153  CharacterAttributes* charAttr;      //!< the character attributes of a world_entity
    5254 
Note: See TracChangeset for help on using the changeset viewer.