Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8217 in orxonox.OLD for branches/bsp_model


Ignore:
Timestamp:
Jun 7, 2006, 9:57:13 PM (18 years ago)
Author:
patrick
Message:

bsp: major restructure: going over bsp_entity for collision detection. adjusting interfaces

Location:
branches/bsp_model/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/collision_detection/cd_engine.cc

    r8215 r8217  
    3232
    3333#include "bsp_manager.h"
     34#include "bsp_entity.h"
    3435
    3536using namespace std;
     
    101102  std::list<BaseObject*>::const_iterator bspIterator;
    102103  std::list<WorldEntity*>::iterator entityIterator;
    103   const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_MODEL);
     104  const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_ENTITY);
    104105  if( bspList == NULL)
    105106    return;
     
    108109  for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++) {
    109110      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
    110         static_cast<BspManager*>(*bspIterator)->checkCollision(*entityIterator);
     111        (static_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator);
    111112  }
    112113}
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc

    r8216 r8217  
    3939#include "movie_player.h"
    4040
    41 #include "cd_engine.h"
    42 
    4341#include "world_entity.h"
    4442
     
    7775void BspManager::load(const char* fileName, float scale)
    7876{
    79   this->setClassID(CL_BSP_MODEL, "BspManager");
    8077  // open a BSP file
    8178  this->bspFile = new BspFile();
     
    8582  this->root  = this->bspFile->get_root();
    8683  this->alreadyVisible = new bool [this->bspFile->numFaces];
    87 
    88   CDEngine::getInstance()->setBSPModel(this);
    89 
    9084}
    9185/*
     
    872866  Vector out = dest;
    873867
    874 
    875 
    876   if(!worldEntity->isA(CL_PLAYABLE)) {
    877 
    878 
    879 
    880   }
    881   else {
    882 
    883     bool collision = false;
    884     Vector position1 = position + Vector(0.0,0.1,0.0);
    885     Vector position2 = position + Vector(0.0,0.2,0.0);
    886     Vector dest1 = position1 + forwardDir;
    887     Vector dest2 = position2 + forwardDir;
    888     dest = position - Vector(0.0, 20.0,0.0);
    889     Vector out1;
    890     Vector out2;
    891 
    892     this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
    893     if(this->outputFraction == 1.0f)  out1 = dest;
    894     else {
    895       collision = true;
    896       out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction;
    897       out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction;
    898       out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction;
    899 
    900     }
    901 
    902     this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    903     if(this->outputFraction == 1.0f) out2= dest;
    904     else {
    905       collision = true;
    906       out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction;
    907       out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction;
    908       out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction;
    909 
    910     }
    911 
    912     this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
    913     if(this->outputFraction == 1.0f) out = dest;
    914     else {
    915       collision = true;
    916       out.x = position.x + (dest.x -position.x) * this->outputFraction;
    917       out.y = position.y + (dest.y -position.y) * this->outputFraction;
    918       out.z = position.z + (dest.z -position.z) * this->outputFraction;
    919 
    920       Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z);
    921       this->out = out;
    922       this->out1 = out1;
    923       this->out2 = out2;
     868   bool collision = false;
     869
     870   Vector position1 = position + Vector(0.0,0.1,0.0);
     871   Vector position2 = position + Vector(0.0,0.2,0.0);
     872   Vector dest1 = position1 + forwardDir;
     873   Vector dest2 = position2 + forwardDir;
     874   dest = position - Vector(0.0, 20.0,0.0);
     875   Vector out1;
     876   Vector out2;
     877
     878   this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
     879   if(this->outputFraction == 1.0f)  out1 = dest;
     880   else {
     881     collision = true;
     882     out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction;
     883     out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction;
     884     out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction;
     885
     886   }
     887
     888   this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
     889   if(this->outputFraction == 1.0f) out2= dest;
     890   else {
     891     collision = true;
     892     out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction;
     893     out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction;
     894     out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction;
     895
     896   }
     897
     898   this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
     899   if(this->outputFraction == 1.0f) out = dest;
     900   else {
     901     collision = true;
     902     out.x = position.x + (dest.x -position.x) * this->outputFraction;
     903     out.y = position.y + (dest.y -position.y) * this->outputFraction;
     904     out.z = position.z + (dest.z -position.z) * this->outputFraction;
     905
     906     Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z);
     907     this->out = out;
     908     this->out1 = out1;
     909     this->out2 = out2;
    924910      //this->drawDebugCube(&out1);
    925911      //this->drawDebugCube(&out2);
     
    927913      //this->drawDebugCube(&out3);
    928914
    929     }
     915   }
    930916
    931917    // Return the normal here: Normal's stored in this->collPlane;
    932 
    933     if(collision)
    934       worldEntity->registerCollision(worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out);
    935 //       worldEntity->collidesWithGround(out,out1,out2);
    936   }
     918   if(collision)
     919     worldEntity->registerCollision(worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out);
     920
    937921}
    938922
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.h

    r8213 r8217  
    2020*/
    2121
     22#ifndef _BSP_MANAGER_H
     23#define _BSP_MANAGER_H
     24
     25
    2226#include <vector>
    2327#include <deque>
    2428
    25 #include "base_object.h"
     29
    2630
    2731// FORWARD DECLARATIONS
     
    4347};
    4448
    45 class BspManager : public BaseObject
     49class BspManager
    4650{
    4751public:
     
    106110};
    107111
     112#endif /* _BSP_MANAGER_H */
  • branches/bsp_model/src/world_entities/bsp_entity.h

    r8186 r8217  
    1818class BSPEntity : public WorldEntity
    1919{
    20  
     20
    2121 public:
    2222  BSPEntity(const TiXmlElement* root = NULL);
     
    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;
  • branches/bsp_model/src/world_entities/playable.cc

    r8147 r8217  
    6666  this->bDead = false;
    6767
     68  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_MODEL);
     69
    6870  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
    6971  registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER));
     
    7981  // this->setPlayer(NULL);
    8082  // IN ITS DESTRUCTOR.
    81  
     83
    8284  assert(this->currentPlayer == NULL);
    8385}
Note: See TracChangeset for help on using the changeset viewer.