Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

orxonox/trunk: put together a little scene in the collision detection subproject. obbs not yet calculated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4678 r4679  
    2828#include "model.h"
    2929#include "test_entity.h"
     30#include "environment.h"
    3031
    3132#include "graphics_engine.h"
     
    3940tList<WorldEntity>* entityList;
    4041
     42int lastFrame, currentFrame, dt;
     43
    4144void Framework::moduleInit(int argc, char** argv)
    4245{
     
    4447
    4548  CDEngine::getInstance();
     49
     50  /* Simple Test */
    4651  //CDEngine::getInstance()->debug();
    4752
     53  /* MD2 Model Test */
    4854//   model = new MD2Model("models/tris.md2", "models/tris.pcx");
    4955//   model->tick(0.1f);
    5056//   CDEngine::getInstance()->debugSpawnTree(9, model->data->pVertices, model->data->numVertices);
    5157
     58  /* OBJ - Model Test */
     59//   mod = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
     60//   CDEngine::getInstance()->debugSpawnTree(9, (sVec3D*)mod->getVertexArray(), mod->getVertexArrayCount());
     61
     62
     63
    5264  entityList = new tList<WorldEntity>();
    5365
    5466  TestEntity* a = new TestEntity();
     67  Environment* b = new Environment();
     68  b->setRelCoor(0.0, 0.0, -10.0);
    5569
    5670  entityList->add(a);
    57 
    58 
    59   mod = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    60   CDEngine::getInstance()->debugSpawnTree(9, (sVec3D*)mod->getVertexArray(), mod->getVertexCount());
    61 
    62   /* ligths */
     71  entityList->add(b);
     72
     73
    6374  LightManager* lightMan = LightManager::getInstance();
    6475  lightMan->setAmbientColor(.1,.1,.1);
     
    7182  drawMode = DRAW_MODEL;
    7283  depth = 0;
     84  dt = lastFrame = currentFrame = 0;
     85
    7386
    7487  moduleHelp();
     
    184197void Framework::moduleTick(float dt)
    185198{
     199
     200  currentFrame = SDL_GetTicks();
     201  dt = currentFrame - lastFrame;
     202
     203  if( dt > 55)
     204  {
     205    float fps = 1000/dt;
     206
     207          // temporary, only for showing how fast the text-engine is
     208    char tmpChar[20];
     209    sprintf(tmpChar, "fps: %4.0f", fps);
     210  }
     211  else
     212  {
     213          /* the frame-rate is limited to 100 frames per second, all other things are for nothing.
     214          */
     215    SDL_Delay((unsigned int)(50-dt));
     216    dt = 55;
     217  }
     218
     219
    186220  tIterator<WorldEntity>* iterator = entityList->getIterator(); /* get the iterator - JAVA style */
    187221  WorldEntity* entity = iterator->nextElement();   /* this returns the FIRST element */
    188222  while( entity != NULL)                        /* nextElement() will return NULL at the end */
    189223  {
    190     entity->tick(0.2);
     224    entity->tick(0.1);
    191225    entity = iterator->nextElement();       /* give back the next element or NULL if last */
    192226  }
    193227  delete iterator;
    194228
     229  lastFrame = currentFrame;
    195230}
    196231
     
    198233void Framework::moduleDraw() const
    199234{
    200   CDEngine::getInstance()->drawBV(depth, drawMode);
    201 
     235  //CDEngine::getInstance()->drawBV(depth, drawMode);
    202236  LightManager::getInstance()->draw();
    203237
    204 //   tIterator<WorldEntity>* iterator = entityList->getIterator(); /* get the iterator - JAVA style */
    205 //   WorldEntity* entity = iterator->nextElement();   /* this returns the FIRST element */
    206 //   while( entity != NULL)                        /* nextElement() will return NULL at the end */
    207 //   {
    208 //     entity->draw();
    209 //     entity = iterator->nextElement();       /* give back the next element or NULL if last */
    210 //   }
    211 //   delete iterator;
     238  tIterator<WorldEntity>* iterator = entityList->getIterator(); /* get the iterator - JAVA style */
     239  WorldEntity* entity = iterator->nextElement();   /* this returns the FIRST element */
     240  while( entity != NULL)                        /* nextElement() will return NULL at the end */
     241  {
     242    entity->draw();
     243    entity = iterator->nextElement();       /* give back the next element or NULL if last */
     244  }
     245  delete iterator;
    212246  //model->draw();
    213247}
Note: See TracChangeset for help on using the changeset viewer.