Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4682 in orxonox.OLD


Ignore:
Timestamp:
Jun 24, 2005, 12:50:34 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: now there is a possibility to render the bvtree through the world entities, the bvtree is a member of the worldentity

Location:
orxonox/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/obb_tree.cc

    r4671 r4682  
    3131OBBTree::OBBTree ()
    3232{
     33  this->init();
     34}
     35
     36OBBTree::OBBTree(int depth, sVec3D *verticesList, const int length)
     37{
     38  this->init();
     39  this->spawnBVTree(depth, verticesList, length);
     40}
     41
     42
     43
     44void OBBTree::init()
     45{
    3346  this->setClassID(CL_OBB_TREE, "OBBTree");
    3447
     
    6174  this->id = 0;
    6275}
    63 
    6476
    6577/**
  • orxonox/trunk/src/lib/collision_detection/obb_tree.h

    r4670 r4682  
    2020  public:
    2121    OBBTree();
     22    OBBTree(int depth, sVec3D *verticesList, const int length);
    2223    virtual ~OBBTree();
     24    void init();
    2325
    2426    virtual void spawnBVTree(int depth, sVec3D *verticesList, const int length);
  • orxonox/trunk/src/lib/graphics/importer/md2Model.cc

    r4488 r4682  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2525using namespace std;
    2626
    27 //! the model anorms 
     27//! the model anorms
    2828sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = {
    2929 #include "anorms.h"
     
    3838static float *shadeDots = MD2Model::anormsDots[0];
    3939
    40 //! the angle under which the model is viewd, used internaly 
     40//! the angle under which the model is viewd, used internaly
    4141float md2Angle = 0.0f;
    4242
     
    4545sAnim MD2Model::animationList[21] =
    4646  {
    47  // begin, end, fps 
     47 // begin, end, fps
    4848    {   0,  39,  9 },   //!< STAND
    4949    {  40,  45, 10 },   //!< RUN
     
    115115  for(int i = 0; i < this->data->numFrames; ++i)
    116116    {
    117       verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor;
    118       verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor;
    119       verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor;
     117      verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]));
     118      verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]));
     119      verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]));
    120120    }
    121121}
     
    138138  this->animationState.fps = animationList[type].fps;
    139139  this->animationState.type = type;
    140  
     140
    141141  this->animationState.interpolationState = 0.0;
    142142  this->animationState.localTime = 0.0;
     
    169169
    170170  glPopMatrix();
    171 } 
     171}
    172172
    173173
     
    185185  glEnable(GL_CULL_FACE);
    186186  glCullFace(GL_BACK);
    187      
     187
    188188  this->processLighting();
    189189  this->interpolate(verticesList);
     
    194194    {
    195195      if( i < 0)
    196         {
    197           glBegin(GL_TRIANGLE_FAN);
    198           i = -i;
    199         }
     196        {
     197          glBegin(GL_TRIANGLE_FAN);
     198          i = -i;
     199        }
    200200      else
    201         {
    202           glBegin(GL_TRIANGLE_STRIP);
    203         }
     201        {
     202          glBegin(GL_TRIANGLE_STRIP);
     203        }
    204204
    205205      for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
    206         {
    207           glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
    208           glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
    209           glVertex3fv(verticesList[pCommands[2]]);
    210         }
     206        {
     207          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
     208          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
     209          glVertex3fv(verticesList[pCommands[2]]);
     210        }
    211211      glEnd();
    212212    }
     
    227227      this->animationState.currentFrame = this->animationState.nextFrame;
    228228      this->animationState.nextFrame++;
    229      
     229
    230230      if( this->animationState.nextFrame > this->animationState.endFrame)
    231         this->animationState.nextFrame = this->animationState.startFrame;
     231        this->animationState.nextFrame = this->animationState.startFrame;
    232232      this->animationState.lastTime = this->animationState.localTime;
    233233    }
     
    238238    this->animationState.nextFrame = 0;
    239239
    240   this->animationState.interpolationState = this->animationState.fps * 
     240  this->animationState.interpolationState = this->animationState.fps *
    241241    (this->animationState.localTime - this->animationState.lastTime);
    242242}
     
    282282  this->pVertices = NULL;
    283283  this->pGLCommands = NULL;
    284   this->pLightNormals = NULL; 
     284  this->pLightNormals = NULL;
    285285
    286286  this->numFrames = 0;
    287287  this->numVertices = 0;
    288288  this->numGLCommands = 0;
    289  
    290   this->scaleFactor = 1.0f;
     289
     290  this->scaleFactor = 0.2f;
    291291
    292292  this->loadModel(modelFileName);
     
    328328
    329329  pFile = fopen(fileName, "rb");
    330   if( unlikely(!pFile)) 
     330  if( unlikely(!pFile))
    331331    {
    332332      PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
     
    364364  for(int i = 0; i < this->numFrames; ++i)
    365365    {
    366       frame = (sFrame*)(buffer + this->header->frameSize * i); 
     366      frame = (sFrame*)(buffer + this->header->frameSize * i);
    367367      pVertex = this->pVertices + this->numVertices  * i;
    368368      pNormals = this->pLightNormals + this->numVertices * i;
    369369
    370370      for(int j = 0; j < this->numVertices; ++j)
    371         {
    372           /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
    373           pVertex[j][0] = (frame->pVertices[j].v[0] * frame->scale[0]) + frame->translate[0];
    374           pVertex[j][1] = (frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2];
    375           pVertex[j][2] = -1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1]);
    376          
    377           pNormals[j] = frame->pVertices[j].lightNormalIndex;
    378         }
     371        {
     372          /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
     373          pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
     374          pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
     375          pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
     376
     377          pNormals[j] = frame->pVertices[j].lightNormalIndex;
     378        }
    379379    }
    380380
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4679 r4682  
    241241  {
    242242    entity->draw();
     243    entity->drawBVTree(depth, drawMode);
    243244    entity = iterator->nextElement();       /* give back the next element or NULL if last */
    244245  }
  • orxonox/trunk/src/world_entities/environment.cc

    r4679 r4682  
    2222#include "vector.h"
    2323#include "objModel.h"
     24#include "obb_tree.h"
    2425
    2526using namespace std;
     
    3334  this->setClassID(CL_ENVIRONMENT, "Environment");
    3435  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
     36
     37  this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    3538}
    3639
  • orxonox/trunk/src/world_entities/test_entity.cc

    r4679 r4682  
    2121#include "model.h"
    2222#include "md2Model.h"
     23#include "obb_tree.h"
    2324
    2425using namespace std;
     
    3132
    3233  this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
     34  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    3335  this->md2Model->debug();
    3436}
     
    7274  this->getAbsDir().matrix (matrix);
    7375  glMultMatrixf((float*)matrix);
    74   glScalef(0.2, 0.2, 0.2);
    7576  this->md2Model->draw();
    7677
  • orxonox/trunk/src/world_entities/world_entity.cc

    r4680 r4682  
    2121#include "list.h"
    2222#include "vector.h"
     23#include "obb_tree.h"
    2324
    2425using namespace std;
     
    3233
    3334  this->model = NULL;
     35  this->obbTree = NULL;
    3436
    3537  if (root)
  • orxonox/trunk/src/world_entities/world_entity.h

    r4680 r4682  
    1212#include "factory.h"
    1313#include "load_param.h"
     14#include "bv_tree.h"
    1415#include "model.h"
    1516
    16 //class CollisionCluster;
     17
     18
    1719class CharacterAttributes;
    1820class SoundEngine;
    1921class SoundBuffer;
    2022class SoundSource;
     23
    2124
    2225//! Basic class from which all interactive stuff in the world is derived from
     
    5255  void processDraw ();
    5356  virtual void draw ();
     57  inline void drawBVTree(int depth, int drawMode) { this->obbTree->drawBV(depth, drawMode); }
    5458  virtual void tick (float time);
    5559
    5660 protected:
    57   Model* model;                  //!< The model that should be loaded for this entity.
     61  Model* model;                       //!< The model that should be loaded for this entity.
    5862  CharacterAttributes* charAttr;      //!< the character attributes of a world_entity
     63  BVTree*             obbTree;       //!< this is the obb tree reference needed for collision detection
    5964
    6065 private:
Note: See TracChangeset for help on using the changeset viewer.