Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

mount point connection

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