Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8217 in orxonox.OLD for branches/bsp_model/src/lib/graphics/importer


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/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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 */
Note: See TracChangeset for help on using the changeset viewer.