Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8490 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jun 15, 2006, 9:34:48 PM (18 years ago)
Author:
patrick
Message:

merged the bsp branche back to trunk

Location:
trunk/src/world_entities
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/WorldEntities.am

    r8271 r8490  
    1515                world_entities/test_entity.cc \
    1616                world_entities/planet.cc \
    17                 world_entities/bsp_entity.cc \
     17                world_entities/bsp_entity.cc \
    1818                \
    1919                world_entities/weapons/test_gun.cc \
     
    3939                world_entities/space_ships/hover.cc \
    4040                world_entities/space_ships/turbine_hover.cc \
     41                world_entities/space_ships/collision_probe.cc \
    4142                world_entities/creatures/md2_creature.cc \
    4243                world_entities/spectator.cc \
     
    7071                test_entity.h \
    7172                planet.h \
    72                 bsp_entity.h \
     73                bsp_entity.h \
    7374                \
    7475                weapons/test_gun.h \
     
    9495                space_ships/hover.h \
    9596                space_ships/turbine_hover.h \
     97                space_ships/collision_probe.cc \
    9698                creatures/md2_creature.h \
    9799                spectator.h \
  • trunk/src/world_entities/bsp_entity.cc

    r8186 r8490  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Claudio Botta
    1313   co-programmer: ...
    1414*/
     
    1717#include "util/loading/resource_manager.h"
    1818
    19 CREATE_FACTORY(BSPEntity, CL_BSP_ENTITY);
     19CREATE_FACTORY(BspEntity, CL_BSP_ENTITY);
    2020
    2121
    2222/**
    23  * constructs and loads a BSPEntity from a XML-element
     23 * constructs and loads a BspEntity from a XML-element
    2424 * @param root the XML-element to load from
    2525 */
    26 BSPEntity::BSPEntity(const TiXmlElement* root)
     26BspEntity::BspEntity(const TiXmlElement* root)
    2727{
    2828  this->init();
     29
    2930  if (root != NULL)
    3031    this->loadParams(root);
     
    3536 * standard deconstructor
    3637 */
    37 BSPEntity::~BSPEntity ()
     38BspEntity::~BspEntity ()
    3839{
    39 
     40  if( this->bspManager)
     41    delete this->bspManager;
    4042}
    4143
    42 void BSPEntity::setName(const std::string& name)
     44
     45/**
     46 * initializes the BspEntity
     47 * @todo change this to what you wish
     48 */
     49void BspEntity::init()
    4350{
    44   printf("+++++++++++ LOADING NAME %s\n", name.c_str());
     51  this->setClassID(CL_BSP_ENTITY, "BspEntity");
     52
     53  this->bspManager = new BspManager(this);
     54  this->toList(OM_ENVIRON);
     55
     56  /**
     57   * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition)
     58   */
     59}
     60
     61
     62void BspEntity::setName(const std::string& name)
     63{
     64  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
    4565
    4666  this->bspManager->load(name.c_str(), 0.1f);
     
    4868
    4969
    50 
    5170/**
    52  * initializes the BSPEntity
    53  * @todo change this to what you wish
    54  */
    55 void BSPEntity::init()
    56 {
    57   this->bspManager = new BspManager();
    58   this->setClassID(CL_BSP_ENTITY, "BSPEntity");
    59 
    60   this->toList(OM_ENVIRON);
    61 
    62   /**
    63    * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition)
    64    */
    65 
    66 }
    67 
    68 
    69 /**
    70  * loads a BSPEntity from a XML-element
     71 * loads a BspEntity from a XML-element
    7172 * @param root the XML-element to load from
    7273 * @todo make the class Loadable
    7374 */
    74 void BSPEntity::loadParams(const TiXmlElement* root)
     75void BspEntity::loadParams(const TiXmlElement* root)
    7576{
    7677  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
    7778 // WorldEntity::loadParam(root);
    7879
    79   LoadParam(root, "Name", this, BSPEntity, setName)
     80  LoadParam(root, "Name", this, BspEntity, setName)
    8081      .describe("Sets the of the BSP file.");
    8182
     
    9192
    9293/**
    93  * advances the BSPEntity about time seconds
     94 * advances the BspEntity about time seconds
    9495 * @param time the Time to step
    9596 */
    96 void BSPEntity::tick(float time)
     97void BspEntity::tick(float time)
    9798{
    98 
     99  this->bspManager->tick(time);
    99100}
    100101
     
    103104 * draws this worldEntity
    104105 */
    105 void BSPEntity::draw () const
     106void BspEntity::draw () const
    106107{
    107108  this->bspManager->draw();
     
    113114 *
    114115 */
    115 void BSPEntity::collidesWith (WorldEntity* entity, const Vector& location)
     116void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
    116117{
    117118
  • trunk/src/world_entities/bsp_entity.h

    r8186 r8490  
    1616
    1717//! A Class to ...
    18 class BSPEntity : public WorldEntity
     18class BspEntity : public WorldEntity
    1919{
    20  
     20
    2121 public:
    22   BSPEntity(const TiXmlElement* root = NULL);
    23   virtual ~BSPEntity();
     22  BspEntity(const TiXmlElement* root = NULL);
     23  virtual ~BspEntity();
    2424
    2525  virtual void loadParams(const TiXmlElement* root);
    26  
     26
    2727  void setName(const std::string& name);
    2828
     
    3333  virtual void collidesWith (WorldEntity* entity, const Vector& location);
    3434
     35  /** @returns the BspManager of this entity */
     36  inline BspManager* getBspManager() { return this->bspManager; }
     37
    3538 private:
    3639   BspManager* bspManager;
  • trunk/src/world_entities/creatures/md2_creature.cc

    r8362 r8490  
    2121
    2222#include "objModel.h"
    23 #include "md2Model.h"
     23#include "md2/md2Model.h"
    2424#include "util/loading/resource_manager.h"
    2525#include "state.h"
     
    256256  if( this->bJump && likely(this->getModel(0) != NULL))
    257257  {
    258     ((MD2Model*)this->getModel(0))->setAnim(JUMP);
     258    ((MD2Model*)this->getModel(0))->setAnimation(JUMP);
    259259  }
    260260  else if( this->bFire && likely(this->getModel(0) != NULL))
    261261  {
    262     if( ((MD2Model*)this->getModel(0))->getAnim() != ATTACK) ((MD2Model*)this->getModel(0))->setAnim(ATTACK);
     262    if( ((MD2Model*)this->getModel(0))->getAnim() != ATTACK) ((MD2Model*)this->getModel(0))->setAnimation(ATTACK);
    263263  }
    264264  else if( fabs(move.len()) > 0.0f && likely(this->getModel(0) != NULL))
    265265  {
    266     if( ((MD2Model*)this->getModel(0))->getAnim() != RUN) ((MD2Model*)this->getModel(0))->setAnim(RUN);
     266    if( ((MD2Model*)this->getModel(0))->getAnim() != RUN) ((MD2Model*)this->getModel(0))->setAnimation(RUN);
    267267  }
    268268  else if (likely(this->getModel(0) != NULL))
    269269  {
    270     if( ((MD2Model*)this->getModel(0))->getAnim() != STAND) ((MD2Model*)this->getModel(0))->setAnim(STAND);
     270    if( ((MD2Model*)this->getModel(0))->getAnim() != STAND) ((MD2Model*)this->getModel(0))->setAnimation(STAND);
    271271  }
    272272
  • trunk/src/world_entities/playable.cc

    r8316 r8490  
    6565
    6666  this->bDead = false;
     67
     68  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    6769
    6870  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
  • trunk/src/world_entities/space_ships/turbine_hover.h

    r7348 r8490  
    5959    float                 rotation;
    6060
    61     Vector                velocity;           //!< the velocity of the TurbineHover.
     61   // Vector                velocity;           //!< the velocity of the TurbineHover.
    6262    Quaternion            direction;          //!< the direction of the TurbineHover.
    6363    float                 travelSpeed;        //!< the current speed of the Hove (to make soft movement)
  • trunk/src/world_entities/test_entity.cc

    r8316 r8490  
    2626
    2727#include "test_entity.h"
    28 #include "stdincl.h"
    29 #include "model.h"
    30 #include "md2Model.h"
    31 #include "obb_tree.h"
     28
     29
     30#include "interactive_model.h"
     31#include "md2/md2Model.h"
     32
    3233#include "state.h"
    3334
     
    9091{
    9192  if( likely(this->getModel(0) != NULL))
    92     ((MD2Model*)this->getModel(0))->setAnim(animationIndex, animPlaybackMode);
     93    ((InteractiveModel*)this->getModel(0))->setAnimation(animationIndex, animPlaybackMode);
    9394}
    9495
     
    9798{
    9899  if( likely(this->getModel(0) != NULL))
    99     ((MD2Model*)this->getModel(0))->tick(time);
     100    ((InteractiveModel*)this->getModel(0))->tick(time);
    100101
    101102}
  • trunk/src/world_entities/world_entity.cc

    r8316 r8490  
    2121
    2222#include "model.h"
    23 #include "md2Model.h"
     23#include "md2/md2Model.h"
     24#include "md3/md3_model.h"
     25
    2426#include "util/loading/resource_manager.h"
    2527#include "util/loading/load_param.h"
     
    7779
    7880  // registering default reactions:
    79   this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);
    80   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND, CL_TERRAIN);
     81//   this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);
    8182
    8283  this->toList(OM_NULL);
     
    200201        this->buildObbTree(obbTreeDepth);
    201202    }
     203    else if(fileName.find(".md3") != std::string::npos)
     204    {
     205      PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str());
     206      Model* m = new md3::MD3Model(fileName, this->scaling);
     207      this->setModel(m, 0);
     208
     209//       if( m != NULL)
     210//         this->buildObbTree(obbTreeDepth);
     211    }
    202212  }
    203213  else
     
    411421 *  @param position it collides on the plane
    412422 */
    413 bool WorldEntity::registerCollision(WorldEntity* entity, Plane* plane, Vector position)
     423bool WorldEntity::registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)
    414424{
    415425  // is there any handler listening?
     
    420430  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
    421431  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
    422   c->collide(entity, plane, position);
     432  c->collide(entity, groundEntity, normal, position);
    423433
    424434  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
     
    501511
    502512  Vector v = this->getAbsDirX();
    503   v.x *= 10;
    504   v.y *= 10;
    505   v.z *= 10;
    506   Vector u = this->getAbsDirY();
    507 
    508   if(feet.x == (u.x+this->getAbsCoor().x) &&  feet.y == u.y +this->getAbsCoor().y && feet.z == this->getAbsCoor().z)
     513  v.x *= 10.1;
     514  v.y *= 10.1;
     515  v.z *= 10.1;
     516  Vector u = Vector(0.0,-20.0,0.0);
     517
     518
     519  if(!(this->getAbsCoor().x == ray_2.x && this->getAbsCoor().y == ray_2.y && this->getAbsCoor().z == ray_2.z) )
    509520  {
    510521
    511522  this->setAbsCoor(ray_2 - v);
    512   }
    513   else
     523
     524  }
     525    else
    514526  {
    515527    if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z)
     
    521533
    522534  }
     535
     536
    523537}
    524538
  • trunk/src/world_entities/world_entity.h

    r8190 r8490  
    2929class CollisionHandle;
    3030class Collision;
    31 class Plane;
    3231
    3332
     
    8685
    8786  bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
    88   bool registerCollision(WorldEntity* entity, Plane* plane, Vector position);
     87  bool registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position);
    8988  /** @return true if there is at least on collision reaction subscribed */
    9089  inline bool isReactive() const { return this->bReactive; }
     
    138137  inline float getMass() const { return this->physicsInterface.getMass(); }
    139138  inline float getTotalMass() const { return this->physicsInterface.getTotalMass(); }
     139  inline void setVelocity(const Vector& vel) { this->velocity = vel; }
    140140
    141141
     
    187187  PhysicsInterface        physicsInterface;                //!< the physics object of the WorldEntity
    188188
     189
     190  protected:
     191  Vector                  velocity;                        //!< speed of the entity
     192
    189193};
    190194
Note: See TracChangeset for help on using the changeset viewer.