Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9172 in orxonox.OLD


Ignore:
Timestamp:
Jul 4, 2006, 9:45:39 PM (18 years ago)
Author:
patrick
Message:

less debug more boxes creation obb

Location:
branches/presentation/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/lib/collision_detection/obb_tree.cc

    r8316 r9172  
    4141
    4242
     43/**
     44 *  standard constructor
     45 */
     46OBBTree::OBBTree()
     47  : BVTree()
     48{}
     49
    4350
    4451void OBBTree::init()
     
    7885
    7986  this->rootNode->spawnBVTree(modelInf, triangleIndexes, modelInf.numTriangles);
     87}
     88
     89
     90void OBBTree::createBox(Vector start, Vector end)
     91{
     92  this->rootNode = new OBBTreeNode(*this, NULL, 11);
     93
     94  this->rootNode->createBox(start, end);
    8095}
    8196
  • branches/presentation/src/lib/collision_detection/obb_tree.h

    r7711 r9172  
    2323  public:
    2424    OBBTree(int depth, const modelInfo* modInfo, WorldEntity* entity);
     25    OBBTree();
    2526    virtual ~OBBTree();
    2627    void init();
     
    2829    virtual void spawnBVTree(const modelInfo& modelInf);
    2930    virtual void flushTree();
     31
     32    void createBox(Vector start, Vector end);
    3033
    3134    virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2);
  • branches/presentation/src/lib/collision_detection/obb_tree_node.cc

    r9008 r9172  
    9090    delete this->bvElement;
    9191}
     92
     93
     94
     95void OBBTreeNode::createBox(Vector start, Vector end)
     96{
     97
     98  this->bvElement = new OBB();
     99  this->nodeLeft = NULL;
     100  this->nodeRight = NULL;
     101
     102  this->bvElement->center = (end - start) * 0.5f;
     103  this->bvElement->halfLength[0] = (end.x - start.x) * 0.5f;
     104  this->bvElement->halfLength[1] = (end.y - start.y) * 0.5f;
     105  this->bvElement->halfLength[2] = (end.z - start.z) * 0.5f;
     106}
     107
    92108
    93109
     
    682698    if( depth == 0/*!(drawMode & DRAW_SINGLE && depth != 0)*/)
    683699    {
    684       if( 1 /*drawMode & DRAW_POINTS*/)
     700      if( 0 /*drawMode & DRAW_POINTS*/)
    685701      {
    686702        glBegin(GL_POINTS);
  • branches/presentation/src/lib/collision_detection/obb_tree_node.h

    r7732 r9172  
    3131
    3232    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
     33    void createBox(Vector start, Vector end);
    3334
    3435    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
  • branches/presentation/src/world_entities/creatures/fps_player.cc

    r9168 r9172  
    243243      this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * f, 0.0));
    244244
    245       this->aimingSystem->toList(/*OM_LIST(this->getOMListNumber() + 1)*/ OM_GROUP_00);
     245      this->aimingSystem->toList(/*OM_LIST(this->getOMListNumber() + 1)*/ OM_COMMON);
    246246    }
    247247  }
     
    399399
    400400  this->setOnGround(false);
    401 
     401  this->aimingSystem->flushList();
    402402}
    403403
  • branches/presentation/src/world_entities/weapons/aiming_system.cc

    r9168 r9172  
    1 /*
     1  /*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3636AimingSystem::AimingSystem (WorldEntity* entity)
    3737{
     38  this->owner = entity;
     39
    3840  this->init();
    3941}
     
    5557  this->setName("AimingSystem");
    5658
    57   this->loadModel("models/guns/targeting_system_body.obj");
     59  //this->loadModel("models/guns/targeting_system_body2.obj");
     60//   this->loadModel("models/ships/fighter.obj");
    5861
    5962  // registering default reactions:
    6063  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);
     64
     65  this->range = 1000.0f;
     66  this->sideLength = 10.0f;
     67
     68  // new obb tree
     69  this->obbTree = new OBBTree();
     70  this->obbTree->createBox(Vector(0.0f, 0.0f, 0.0f), Vector(this->range, this->sideLength, this->sideLength));
    6171}
    6272
     
    6979WorldEntity* AimingSystem::getNearestTarget()
    7080{
     81
     82//   PRINTF(0)("size: %i\n", this->selectionList.size());
     83
     84
    7185  if( this->selectionList.size() == 0)
    7286    return NULL;
    73   else if( this->selectionList.size() == 1)
    74     return this->selectionList.back();
     87
    7588
    7689  WorldEntity* nearestEntity     = NULL;
     
    91104  if( nearestEntity != this->owner)
    92105    return nearestEntity;
    93   else return NULL;
     106  else
     107    return NULL;
    94108}
    95109
     
    123137void AimingSystem::draw() const
    124138{
    125   WorldEntity::draw();
     139//   WorldEntity::draw();
    126140
    127   if( this->getOBBTree () != NULL)
    128     this->getOBBTree()->drawBV(0, 1);
     141  glMatrixMode(GL_MODELVIEW);
     142  glPushMatrix();
     143
     144  /* translate */
     145  glTranslatef (this->getAbsCoor ().x,
     146                this->getAbsCoor ().y,
     147                this->getAbsCoor ().z);
     148  Vector tmpRot = this->getAbsDir().getSpacialAxis();
     149  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     150
     151  this->obbTree->drawBV(1, 1);
     152
     153  glPopMatrix();
     154
    129155}
  • branches/presentation/src/world_entities/weapons/aiming_system.h

    r9168 r9172  
    1616class BVTree;
    1717class Model;
     18class OBBTree;
    1819
    1920
     
    2829
    2930  WorldEntity* getNearestTarget();
     31  void flushList() { this->selectionList.clear(); }
    3032
    3133  void setRange(float range){this->range = range;};
     
    3941 private:
    4042   float                       range;                //!<
     43   float                       sideLength;
    4144   std::vector<WorldEntity*>   selectionList;        //!< the selections
    4245
    4346   WorldEntity*                owner;                //!< the owner of the targeting system
    4447
     48   OBBTree*                    obbTree;
     49
    4550};
    4651
Note: See TracChangeset for help on using the changeset viewer.