Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/single_player_map/src/world_entities/world_entity.cc @ 8940

Last change on this file since 8940 was 8940, checked in by patrick, 18 years ago

falling down fps player

File size: 21.5 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: Christian Meyer
16*/
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
19#include "world_entity.h"
20#include "shell_command.h"
21
22#include "model.h"
23#include "md2/md2Model.h"
24#include "md3/md3_model.h"
25
26#include "aabb_tree_node.h"
27
28#include "util/loading/resource_manager.h"
29#include "util/loading/load_param.h"
30#include "vector.h"
31#include "obb_tree.h"
32
33#include "glgui_bar.h"
34
35#include "state.h"
36#include "camera.h"
37
38#include "collision_handle.h"
39#include "collision_event.h"
40#include "game_rules.h"
41#include "kill.h"
42
43#include <stdarg.h>
44
45
46using namespace std;
47
48SHELL_COMMAND(model, WorldEntity, loadModel)
49->describe("sets the Model of the WorldEntity")
50->defaultValues("models/ships/fighter.obj", 1.0f);
51
52SHELL_COMMAND(debugEntity, WorldEntity, debugWE);
53
54/**
55 *  Loads the WordEntity-specific Part of any derived Class
56 *
57 * @param root: Normally NULL, as the Derived Entities define a loadParams Function themeselves,
58 *              that can calls WorldEntities loadParams for itself.
59 */
60WorldEntity::WorldEntity()
61    : Synchronizeable()
62{
63  this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
64
65  this->obbTree = NULL;
66  this->aabbNode = NULL;
67  this->healthWidget = NULL;
68  this->healthMax = 1.0f;
69  this->health = 1.0f;
70  this->damage = 0.0f; // no damage dealt by a default entity
71  this->scaling = 1.0f;
72
73  /* OSOLETE */
74  this->bVisible = true;
75  this->bCollide = true;
76
77  this->objectListNumber = OM_INIT;
78  this->objectListIterator = NULL;
79
80  // reset all collision handles to NULL == unsubscribed state
81  for(int i = 0; i < CREngine::CR_NUMBER; ++i)
82    this->collisionHandles[i] = NULL;
83  this->bReactive = false;
84  this->bOnGround = false;
85
86  // registering default reactions:
87  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);
88
89  this->toList(OM_NULL);
90
91  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
92  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
93}
94
95/**
96 *  standard destructor
97*/
98WorldEntity::~WorldEntity ()
99{
100  State::getObjectManager()->toList(this, OM_INIT);
101
102  // Delete the model (unregister it with the ResourceManager)
103  for (unsigned int i = 0; i < this->models.size(); i++)
104    this->setModel(NULL, i);
105
106  // Delete the obbTree
107  if( this->obbTree != NULL)
108    delete this->obbTree;
109
110  if (this->healthWidget != NULL)
111    delete this->healthWidget;
112
113  this->unsubscribeReaction();
114}
115
116/**
117 * loads the WorldEntity Specific Parameters.
118 * @param root: the XML-Element to load the Data From
119 */
120void WorldEntity::loadParams(const TiXmlElement* root)
121{
122  // Do the PNode loading stuff
123  PNode::loadParams(root);
124
125  LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture)
126  .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)")
127  .defaultValues("");
128
129  // Model Loading
130  LoadParam(root, "model", this, WorldEntity, loadModel)
131  .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
132  .defaultValues("", 1.0f, 0);
133
134  LoadParam(root, "maxHealth", this, WorldEntity, setHealthMax)
135  .describe("The Maximum health that can be loaded onto this entity")
136  .defaultValues(1.0f);
137
138  LoadParam(root, "health", this, WorldEntity, setHealth)
139  .describe("The Health the WorldEntity has at this moment")
140  .defaultValues(1.0f);
141}
142
143
144/**
145 * loads a Model onto a WorldEntity
146 * @param fileName the name of the model to load
147 * @param scaling the Scaling of the model
148 *
149 * FIXME
150 * @todo: separate the obb tree generation from the model
151 */
152void WorldEntity::loadModel(const std::string& fileName, float scaling, unsigned int modelNumber, unsigned int obbTreeDepth)
153{
154  this->modelLODName = fileName;
155  this->scaling = scaling;
156
157  std::string name = fileName;
158
159  if (  name.find( ResourceManager::getInstance()->getDataDir() ) == 0 )
160  {
161    name.erase(ResourceManager::getInstance()->getDataDir().size());
162  }
163
164  this->modelFileName = name;
165
166  if (!fileName.empty())
167  {
168    // search for the special character # in the LoadParam
169    if (fileName.find('#') != std::string::npos)
170    {
171      PRINTF(4)("Found # in %s... searching for LOD's\n", fileName.c_str());
172      std::string lodFile = fileName;
173      unsigned int offset = lodFile.find('#');
174      for (unsigned int i = 0; i < 3; i++)
175      {
176        lodFile[offset] = 48+(int)i;
177        if (ResourceManager::isInDataDir(lodFile))
178          this->loadModel(lodFile, scaling, i);
179      }
180      return;
181    }
182    if (this->scaling <= 0.0)
183    {
184      PRINTF(1)("YOU GAVE ME A CRAPY SCALE resetting to 1.0\n");
185      this->scaling = 1.0;
186    }
187    if(fileName.find(".obj") != std::string::npos)
188    {
189      PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str());
190      BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling);
191      if (loadedModel != NULL)
192        this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber);
193      else
194        PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str());
195
196      if( modelNumber == 0 && !this->isA(CL_WEAPON))
197        this->buildObbTree(obbTreeDepth);
198    }
199    else if(fileName.find(".md2") != std::string::npos)
200    {
201      PRINTF(4)("fetching MD2 file: %s\n", fileName.c_str());
202      Model* m = new MD2Model(fileName, this->md2TextureFileName, this->scaling);
203      //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
204      this->setModel(m, 0);
205
206      if( m != NULL)
207        this->buildObbTree(obbTreeDepth);
208    }
209    else /*if(fileName.find(".md3") != std::string::npos)*/
210    {
211      PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str());
212      Model* m = new md3::MD3Model(fileName, this->scaling);
213      this->setModel(m, 0);
214
215//       if( m != NULL)
216//         this->buildObbTree(obbTreeDepth);
217    }
218  }
219  else
220  {
221    this->setModel(NULL);
222  }
223}
224
225/**
226 * sets a specific Model for the Object.
227 * @param model The Model to set
228 * @param modelNumber the n'th model in the List to get.
229 */
230void WorldEntity::setModel(Model* model, unsigned int modelNumber)
231{
232  if (this->models.size() <= modelNumber)
233    this->models.resize(modelNumber+1, NULL);
234
235  if (this->models[modelNumber] != NULL)
236  {
237    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(dynamic_cast<BaseObject*>(this->models[modelNumber]));
238    if (resource != NULL)
239      ResourceManager::getInstance()->unload(resource, RP_LEVEL);
240    else
241    {
242      PRINTF(4)("Forcing model deletion\n");
243      delete this->models[modelNumber];
244    }
245  }
246
247  this->models[modelNumber] = model;
248}
249
250
251/**
252 * builds the obb-tree
253 * @param depth the depth to calculate
254 */
255bool WorldEntity::buildObbTree(int depth)
256{
257  if (this->obbTree)
258    delete this->obbTree;
259
260  if (this->models[0] != NULL)
261    this->obbTree = new OBBTree(depth, models[0]->getModelInfo(), this);
262  else
263  {
264    PRINTF(1)("could not create obb-tree, because no model was loaded yet\n");
265    this->obbTree = NULL;
266    return false;
267  }
268
269
270  // create the axis aligned bounding box
271  if( this->aabbNode != NULL)
272  {
273    delete this->aabbNode;
274    this->aabbNode = NULL;
275  }
276
277  if( this->models[0] != NULL) {
278    this->aabbNode = new AABBTreeNode();
279    this->aabbNode->spawnBVTree(this->models[0]);
280  }
281  return true;
282}
283
284
285/**
286 * subscribes this world entity to a collision reaction
287 *  @param type the type of reaction to subscribe to
288 *  @param target1 a filter target (classID)
289 */
290void WorldEntity::subscribeReaction(CREngine::CRType type, long target1)
291{
292  this->subscribeReaction(type);
293
294  // add the target filter
295  this->collisionHandles[type]->addTarget(target1);
296}
297
298
299/**
300 * subscribes this world entity to a collision reaction
301 *  @param type the type of reaction to subscribe to
302 *  @param target1 a filter target (classID)
303 */
304void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2)
305{
306  this->subscribeReaction(type);
307
308  // add the target filter
309  this->collisionHandles[type]->addTarget(target1);
310  this->collisionHandles[type]->addTarget(target2);
311}
312
313
314/**
315 * subscribes this world entity to a collision reaction
316 *  @param type the type of reaction to subscribe to
317 *  @param target1 a filter target (classID)
318 */
319void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3)
320{
321  this->subscribeReaction(type);
322
323  // add the target filter
324  this->collisionHandles[type]->addTarget(target1);
325  this->collisionHandles[type]->addTarget(target2);
326  this->collisionHandles[type]->addTarget(target3);
327}
328
329
330/**
331 * subscribes this world entity to a collision reaction
332 *  @param type the type of reaction to subscribe to
333 *  @param target1 a filter target (classID)
334 */
335void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, long target4)
336{
337  this->subscribeReaction(type);
338
339  // add the target filter
340  this->collisionHandles[type]->addTarget(target1);
341  this->collisionHandles[type]->addTarget(target2);
342  this->collisionHandles[type]->addTarget(target3);
343  this->collisionHandles[type]->addTarget(target4);
344}
345
346
347/**
348 * subscribes this world entity to a collision reaction
349 *  @param type the type of reaction to subscribe to
350 *  @param nrOfTargets number of target filters
351 *  @param ... the targets as classIDs
352 */
353void WorldEntity::subscribeReaction(CREngine::CRType type)
354{
355  if( this->collisionHandles[type] != NULL)  {
356    PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n");
357    return;
358  }
359
360  this->collisionHandles[type] = CREngine::getInstance()->subscribeReaction(this, type);
361
362  // now there is at least one collision reaction subscribed
363  this->bReactive = true;
364}
365
366
367/**
368 * unsubscribes a specific reaction from the worldentity
369 *  @param type the reaction to unsubscribe
370 */
371void WorldEntity::unsubscribeReaction(CREngine::CRType type)
372{
373  if( this->collisionHandles[type] == NULL)
374    return;
375
376  CREngine::getInstance()->unsubscribeReaction(this->collisionHandles[type]);
377  this->collisionHandles[type] = NULL;
378
379  // check if there is still any handler registered
380  for(int i = 0; i < CREngine::CR_NUMBER; ++i)
381  {
382    if( this->collisionHandles[i] != NULL)
383    {
384      this->bReactive = true;
385      return;
386    }
387  }
388  this->bReactive = false;
389}
390
391
392/**
393 * unsubscribes all collision reactions
394 */
395void WorldEntity::unsubscribeReaction()
396{
397  for( int i = 0; i < CREngine::CR_NUMBER; i++)
398    this->unsubscribeReaction((CREngine::CRType)i);
399
400  // there are no reactions subscribed from now on
401  this->bReactive = false;
402}
403
404
405/**
406 * registers a new collision event to this world entity
407 *  @param entityA entity of the collision
408 *  @param entityB entity of the collision
409 *  @param bvA colliding bounding volume of entityA
410 *  @param bvB colliding bounding volume of entityA
411 */
412bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
413{
414  // is there any handler listening?
415  if( !this->bReactive)
416    return false;
417
418  // get a collision event
419  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
420  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
421  c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
422
423  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
424    if( this->collisionHandles[i] != NULL)
425      this->collisionHandles[i]->registerCollisionEvent(c);
426  return true;
427}
428
429
430/**
431 * registers a new collision event to this woeld entity
432 *  @param entity the entity that collides
433 *  @param plane it stands on
434 *  @param position it collides on the plane
435 */
436bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
437{
438  // is there any handler listening?
439  if( !this->bReactive)
440    return false;
441
442  // get a collision event
443  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
444  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
445  c->collide(type, entity, groundEntity, normal, position, bInWall);
446
447  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
448    if( this->collisionHandles[i] != NULL)
449      this->collisionHandles[i]->registerCollisionEvent(c);
450  return true;
451}
452
453
454/**
455 * @brief moves this entity to the List OM_List
456 * @param list the list to set this Entity to.
457 *
458 * this is the same as a call to State::getObjectManager()->toList(entity , list);
459 * directly, but with an easier interface.
460 *
461 * @todo inline this (peut etre)
462 */
463void WorldEntity::toList(OM_LIST list)
464{
465  State::getObjectManager()->toList(this, list);
466}
467
468void WorldEntity::toReflectionList()
469{
470  State::getObjectManager()->toReflectionList( this );
471}
472
473void removeFromReflectionList()
474{
475/// TODO
476///  State::getObject
477}
478
479/**
480 * sets the character attributes of a worldentity
481 * @param character attributes
482 *
483 * these attributes don't have to be set, only use them, if you need them
484*/
485//void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
486//{}
487
488
489/**
490 *  this function is called, when two entities collide
491 * @param entity: the world entity with whom it collides
492 *
493 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
494 */
495void WorldEntity::collidesWith(WorldEntity* entity, const Vector& location)
496{
497  /**
498   * THIS IS A DEFAULT COLLISION-Effect.
499   * IF YOU WANT TO CREATE A SPECIFIC COLLISION ON EACH OBJECT
500   * USE::
501   * if (entity->isA(CL_WHAT_YOU_ARE_LOOKING_FOR)) { printf "dothings"; };
502   *
503   * You can always define a default Action.... don't be affraid just test it :)
504   */
505  //  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
506}
507
508
509/**
510 *  this function is called, when two entities collide
511 * @param entity: the world entity with whom it collides
512 *
513 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
514 */
515void WorldEntity::collidesWithGround(const Vector& location)
516{
517  PRINTF(0)("BSP_GROUND: %s collides \n", this->getClassName() );
518}
519
520void WorldEntity::collidesWithGround(const Vector& feet, const Vector& ray_1, const Vector& ray_2)
521{
522
523  // PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() );
524
525  Vector v = this->getAbsDirX();
526  v.x *= 10.1;
527  v.y *= 10.1;
528  v.z *= 10.1;
529  Vector u = Vector(0.0,-20.0,0.0);
530
531
532  if(!(this->getAbsCoor().x == ray_2.x && this->getAbsCoor().y == ray_2.y && this->getAbsCoor().z == ray_2.z) )
533  {
534
535  this->setAbsCoor(ray_2 - v);
536
537  }
538    else
539  {
540    if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z)
541    {
542      this->setAbsCoor(feet -u );
543    }
544
545    this->setAbsCoor(ray_2 - v);
546
547  }
548
549
550}
551
552/**
553 *  this is called immediately after the Entity has been constructed, initialized and then Spawned into the World
554 *
555 */
556void WorldEntity::postSpawn ()
557{}
558
559
560/**
561 *  this method is called by the world if the WorldEntity leaves the game
562 */
563void WorldEntity::leaveWorld ()
564{}
565
566
567/**
568 * resets the WorldEntity to its initial values. eg. used for multiplayer games: respawning
569 */
570void WorldEntity::reset()
571{}
572
573/**
574 *  this method is called every frame
575 * @param time: the time in seconds that has passed since the last tick
576 *
577 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
578*/
579void WorldEntity::tick(float time)
580{}
581
582
583/**
584 *  the entity is drawn onto the screen with this function
585 *
586 * This is a central function of an entity: call it to let the entity painted to the screen.
587 * Just override this function with whatever you want to be drawn.
588*/
589void WorldEntity::draw() const
590{
591  //PRINTF(0)("(%s::%s)\n", this->getClassName(), this->getName());
592  //  assert(!unlikely(this->models.empty()));
593  {
594    glMatrixMode(GL_MODELVIEW);
595    glPushMatrix();
596
597    /* translate */
598    glTranslatef (this->getAbsCoor ().x,
599                  this->getAbsCoor ().y,
600                  this->getAbsCoor ().z);
601    Vector tmpRot = this->getAbsDir().getSpacialAxis();
602    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
603
604
605    // This Draws the LOD's
606    float cameraDistance = State::getCamera()->distance(this);
607    if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
608    {
609      this->models[2]->draw();
610    }
611    else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
612    {
613      this->models[1]->draw();
614    }
615    else if (this->models.size() >= 1 && this->models[0] != NULL)
616    {
617      this->models[0]->draw();
618    }
619
620//     if( this->aabbNode != NULL)
621//       this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);
622
623    glPopMatrix();
624  }
625}
626
627/**
628 * @param health the Health to add.
629 * @returns the health left (this->healthMax - health+this->health)
630 */
631float WorldEntity::increaseHealth(float health)
632{
633  this->health += health;
634  if (this->health > this->healthMax)
635  {
636    float retHealth = this->healthMax - this->health;
637    this->health = this->healthMax;
638    this->updateHealthWidget();
639    return retHealth;
640  }
641  this->updateHealthWidget();
642  return 0.0;
643}
644
645/**
646 * @param health the Health to be removed
647 * @returns 0.0 or the rest, that was not substracted (bellow 0.0)
648 */
649float WorldEntity::decreaseHealth(float health)
650{
651  this->health -= health;
652
653  if (this->health < 0)
654  {
655    float retHealth = -this->health;
656    this->health = 0.0f;
657    this->updateHealthWidget();
658    return retHealth;
659  }
660  this->updateHealthWidget();
661  return 0.0;
662
663}
664
665/**
666 * @param maxHealth the maximal health that can be loaded onto the entity.
667 */
668void WorldEntity::setHealthMax(float healthMax)
669{
670  this->healthMax = healthMax;
671  if (this->health > this->healthMax)
672  {
673    PRINTF(3)("new maxHealth is bigger as the old health. Did you really intend to do this for (%s::%s)\n", this->getClassName(), this->getName());
674    this->health = this->healthMax;
675  }
676  this->updateHealthWidget();
677}
678
679/**
680 * @brief creates the HealthWidget
681 *
682 * since not all entities need an HealthWidget, it is only created on request.
683 */
684void WorldEntity::createHealthWidget()
685{
686  if (this->healthWidget == NULL)
687  {
688    this->healthWidget = new OrxGui::GLGuiBar();
689    this->healthWidget->setSize2D(30,400);
690    this->healthWidget->setAbsCoor2D(10,100);
691
692    this->updateHealthWidget();
693  }
694  else
695    PRINTF(3)("Allready created the HealthWidget for %s::%s\n", this->getClassName(), this->getName());
696}
697
698void WorldEntity::increaseHealthMax(float increaseHealth)
699{
700  this->healthMax += increaseHealth;
701  this->updateHealthWidget();
702}
703
704
705OrxGui::GLGuiWidget* WorldEntity::getHealthWidget()
706{
707  this->createHealthWidget();
708  return this->healthWidget;
709}
710
711/**
712 * @param visibility shows or hides the health-bar
713 * (creates the widget if needed)
714 */
715void WorldEntity::setHealthWidgetVisibilit(bool visibility)
716{
717  if (visibility)
718  {
719    if (this->healthWidget != NULL)
720      this->healthWidget->show();
721    else
722    {
723      this->createHealthWidget();
724      this->updateHealthWidget();
725      this->healthWidget->show();
726    }
727  }
728  else if (this->healthWidget != NULL)
729    this->healthWidget->hide();
730}
731
732
733/**
734 * hit the world entity with
735 *  @param damage damage to be dealt
736 */
737void WorldEntity::hit(float damage)
738{
739  this->decreaseHealth(damage);
740
741  PRINTF(5)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());
742
743  if( this->getHealth() > 0)
744  {
745    // any small explosion animaitions
746  }
747  else
748  {
749    this->destroy();
750
751    if( State::getGameRules() != NULL)
752      State::getGameRules()->registerKill(Kill(NULL, this));
753  }
754}
755
756
757/**
758 * destoys the world entity
759 */
760void WorldEntity::destroy()
761{
762  this->toList(OM_DEAD);
763}
764
765
766/**
767 * @brief updates the HealthWidget
768 */
769void WorldEntity::updateHealthWidget()
770{
771  if (this->healthWidget != NULL)
772  {
773    this->healthWidget->setMaximum(this->healthMax);
774    this->healthWidget->setValue(this->health);
775  }
776}
777
778
779/**
780 * DEBUG-DRAW OF THE BV-Tree.
781 * @param depth What depth to draw
782 * @param drawMode the mode to draw this entity under
783 */
784void WorldEntity::drawBVTree(int depth, int drawMode) const
785{
786  glMatrixMode(GL_MODELVIEW);
787  glPushMatrix();
788  /* translate */
789  glTranslatef (this->getAbsCoor ().x,
790                this->getAbsCoor ().y,
791                this->getAbsCoor ().z);
792  /* rotate */
793  Vector tmpRot = this->getAbsDir().getSpacialAxis();
794  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
795
796
797  if (this->obbTree)
798    this->obbTree->drawBV(depth, drawMode);
799
800
801  glPopMatrix();
802}
803
804
805/**
806 * Debug the WorldEntity
807 */
808void WorldEntity::debugEntity() const
809{
810  PRINT(0)("WorldEntity %s::%s  (DEBUG)\n", this->getClassName(), this->getName());
811  this->debugNode();
812  PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber) , this->models.size());
813  for (unsigned int i = 0; i < this->models.size(); i++)
814  {
815    if (models[i] != NULL)
816      PRINT(0)(" : %d:%s", i, this->models[i]->getName());
817  }
818  PRINT(0)("\n");
819
820}
821
822
823/**
824 * handler for changes on registred vars
825 * @param id id's which changed
826 */
827void WorldEntity::varChangeHandler( std::list< int > & id )
828{
829  if ( std::find( id.begin(), id.end(), modelFileName_handle ) != id.end() ||
830       std::find( id.begin(), id.end(), scaling_handle ) != id.end()
831     )
832  {
833    loadModel( modelFileName, scaling );
834  }
835
836  PNode::varChangeHandler( id );
837}
838
Note: See TracBrowser for help on using the repository browser.