Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/mount_points/src/world_entities/world_entity.cc @ 10058

Last change on this file since 10058 was 10058, checked in by patrick, 17 years ago

mount point interaction

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