Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/coord/p_node.cc @ 5089

Last change on this file since 5089 was 5089, checked in by bensch, 19 years ago

orxonox/trunk: rebuild Element2D. Now it is more like PNode

File size: 21.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer:
14
15   @todo Smooth-Parent: delay, speed
16*/
17
18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PNODE
19
20#include "p_node.h"
21#include "null_parent.h"
22
23#include "load_param.h"
24#include "class_list.h"
25
26#include "stdincl.h"
27#include "compiler.h"
28#include "error.h"
29#include "debug.h"
30#include "list.h"
31#include "vector.h"
32
33//#include "vector.h"
34//#include "quaternion.h"
35
36using namespace std;
37
38
39/**
40 *  standard constructor
41*/
42PNode::PNode ()
43{
44  init(NULL);
45
46  NullParent::getInstance()->addChild(this);
47}
48
49/**
50 * @param root the load-Element for the PNode
51*/
52PNode::PNode(const TiXmlElement* root)
53{
54  this->init(NULL);
55  this->loadParams(root);
56
57  NullParent::getInstance()->addChild(this);
58}
59
60/**
61 *  constructor with coodinates
62 * @param absCoordinate the Absolute coordinate of the Object
63 * @param parent The parent-node of this node.
64*/
65PNode::PNode (const Vector& absCoor, PNode* parent )
66{
67  this->init(parent);
68
69  if (likely(parent != NULL))
70    parent->addChild (this);
71
72  this->setAbsCoor(absCoor);
73}
74
75/**
76 *  standard deconstructor
77*/
78PNode::~PNode ()
79{
80  tIterator<PNode>* iterator = this->children->getIterator();
81  PNode* pn = iterator->nextElement();
82  while( pn != NULL)
83    {
84      delete pn;
85      pn = iterator->nextElement();
86    }
87  delete iterator;
88  /* this deletes all children in the list */
89  delete this->children;
90  if (this->parent)
91    this->parent->removeChild(this);
92
93  if (this->toCoordinate != NULL)
94    delete this->toCoordinate;
95  if (this->toDirection != NULL)
96    delete this->toDirection;
97}
98
99/**
100 *  initializes a PNode
101 * @param parent the parent for this PNode
102*/
103void PNode::init(PNode* parent)
104{
105  this->setClassID(CL_PARENT_NODE, "PNode");
106  this->children = new tList<PNode>();
107  this->bRelCoorChanged = true;
108  this->bRelDirChanged = true;
109  this->parent = parent;
110
111  // iterators
112  this->toCoordinate = NULL;
113  this->toDirection = NULL;
114  this->bias = 1.0;
115}
116
117/**
118 *  loads parameters of the PNode
119 * @param root the XML-element to load the properties of
120*/
121void PNode::loadParams(const TiXmlElement* root)
122{
123  static_cast<BaseObject*>(this)->loadParams(root);
124
125  LoadParam<PNode>(root, "rel-coor", this, &PNode::setRelCoor)
126      .describe("Sets The relative position of the Node to its parent.");
127
128  LoadParam<PNode>(root, "abs-coor", this, &PNode::setAbsCoor)
129      .describe("Sets The absolute Position of the Node.");
130
131  LoadParam<PNode>(root, "rel-dir", this, &PNode::setRelDir)
132      .describe("Sets The relative rotation of the Node to its parent.");
133
134  LoadParam<PNode>(root, "abs-dir", this, &PNode::setAbsDir)
135      .describe("Sets The absolute rotation of the Node.");
136
137  LoadParam<PNode>(root, "parent", this, &PNode::setParent)
138      .describe("the Name of the Parent of this PNode");
139
140  LoadParam<PNode>(root, "parent-mode", this, &PNode::setParentMode)
141      .describe("the mode to connect this node to its parent ()");
142
143  // cycling properties
144  if (root != NULL)
145  {
146    const TiXmlElement* element = root->FirstChildElement();
147    while (element != NULL)
148    {
149      LoadParam<PNode>(root, "parent", this, &PNode::addChild, true)
150          .describe("adds a new Child to the current Node.");
151
152      element = element->NextSiblingElement();
153    }
154  }
155}
156
157/**
158 *  set relative coordinates
159 * @param relCoord relative coordinates to its parent
160
161   it is very importand, that you use this function, if you want to update the
162   relCoordinates. If you don't use this, the PNode won't recognize, that something
163   has changed and won't update the children Nodes.
164*/
165void PNode::setRelCoor (const Vector& relCoord)
166{
167  this->relCoordinate = relCoord;
168  this->bRelCoorChanged = true;
169}
170
171/**
172 *  set relative coordinates
173 * @param x x-relative coordinates to its parent
174 * @param y y-relative coordinates to its parent
175 * @param z z-relative coordinates to its parent
176 * @see  void PNode::setRelCoor (const Vector& relCoord)
177*/
178void PNode::setRelCoor (float x, float y, float z)
179{
180  this->setRelCoor(Vector(x, y, z));
181}
182
183/**
184 * sets a new relative position smoothely
185 * @param relCoordSoft the new Position to iterate to
186 * @param bias how fast to iterate to this position
187 */
188void PNode::setRelCoorSoft(const Vector& relCoordSoft, float bias)
189{
190  if (likely(this->toCoordinate == NULL))
191    this->toCoordinate = new Vector();
192
193  *this->toCoordinate = relCoordSoft;
194  this->bias = bias;
195}
196
197
198/**
199 *  set relative coordinates smoothely
200 * @param x x-relative coordinates to its parent
201 * @param y y-relative coordinates to its parent
202 * @param z z-relative coordinates to its parent
203 * @see  void PNode::setRelCoorSoft (const Vector&, float)
204 */
205void PNode::setRelCoorSoft (float x, float y, float z, float bias)
206{
207  this->setRelCoorSoft(Vector(x, y, z), bias);
208}
209
210/**
211 * @param absCoord set absolute coordinate
212
213   it is very importand, that you use this function, if you want to update the
214   absCoordinates. If you don't use this, the PNode won't recognize, that something
215   has changed and won't update the children Nodes.
216
217@todo check if this does what it should
218*/
219void PNode::setAbsCoor (const Vector& absCoord)
220{
221  if( likely(this->parentMode & PNODE_MOVEMENT))
222  {
223      /* if you have set the absolute coordinates this overrides all other changes */
224    if (likely(this->parent != NULL))
225      this->relCoordinate = absCoord - parent->getAbsCoor ();
226    else
227      this->relCoordinate = absCoord;
228  }
229  if( this->parentMode & PNODE_ROTATE_MOVEMENT)
230  {
231    if (likely(this->parent != NULL))
232      this->relCoordinate = absCoord - parent->getAbsCoor ();
233    else
234      this->relCoordinate = absCoord;
235  }
236
237  this->bRelCoorChanged = true;
238//  this->absCoordinate = absCoord;
239}
240
241/**
242 * @param x x-coordinate.
243 * @param y y-coordinate.
244 * @param z z-coordinate.
245 * @see void PNode::setAbsCoor (const Vector& absCoord)
246 */
247void PNode::setAbsCoor(float x, float y, float z)
248{
249  this->setAbsCoor(Vector(x, y, z));
250}
251
252/**
253 *  shift coordinate (abs and rel)
254 * @param shift shift vector
255
256   this function shifts the current coordinates about the vector shift. this is
257   usefull because from some place else you can:
258   PNode* someNode = ...;
259   Vector objectMovement = calculateShift();
260   someNode->shiftCoor(objectMovement);
261
262   elsewhere you would have to:
263   PNode* someNode = ...;
264   Vector objectMovement = calculateShift();
265   Vector currentCoor = someNode->getRelCoor();
266   Vector newCoor = currentCoor + objectMovement;
267   someNode->setRelCoor(newCoor);
268
269   yea right... shorter...
270 *
271 * @todo this is ambiguous, from the outside one does not know it absCoor has been changed
272 * this might lead to strange artefacts !!
273
274*/
275void PNode::shiftCoor (const Vector& shift)
276{
277  this->relCoordinate += shift;
278  this->bRelCoorChanged = true;
279}
280
281/**
282 *  set relative direction
283 * @param relDir to its parent
284
285   it is very importand, that you use this function, if you want to update the
286   relDirection. If you don't use this, the PNode won't recognize, that something
287   has changed and won't update the children Nodes.
288*/
289void PNode::setRelDir (const Quaternion& relDir)
290{
291  this->relDirection = relDir;
292  this->bRelCoorChanged = true;
293}
294
295/**
296 * @see void PNode::setRelDir (const Quaternion& relDir)
297 * @param x the x direction
298 * @param y the y direction
299 * @param z the z direction
300 *
301 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
302 */
303void PNode::setRelDir (float x, float y, float z)
304{
305  this->setRelDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
306}
307
308
309/**
310 * sets the Relative Direction of this node to its parent in a Smoothed way
311 * @param relDirSoft the direction to iterate to smoothely.
312 * @param bias how fast to iterate to the new Direction
313 */
314void PNode::setRelDirSoft(const Quaternion& relDirSoft, float bias)
315{
316  if (likely(this->toDirection == NULL))
317    this->toDirection = new Quaternion();
318
319  *this->toDirection = relDirSoft;
320  this->bias = bias;
321}
322
323/**
324 * @see void PNode::setRelDirSoft (const Quaternion& relDir)
325 * @param x the x direction
326 * @param y the y direction
327 * @param z the z direction
328 *
329 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
330 */
331void PNode::setRelDirSoft(float x, float y, float z, float bias)
332{
333  this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
334}
335
336/**
337 *  sets the absolute direction (0,0,1)
338 * @param absDir absolute coordinates
339 *
340 * it is very importand, that you use this function, if you want to update the
341 * absDirection. If you don't use this, the PNode won't recognize, that something
342 * has changed and won't update the children Nodes.
343*/
344void PNode::setAbsDir (const Quaternion& absDir)
345{
346  if (likely(this->parent != NULL))
347    this->relDirection = absDir / this->parent->getAbsDir();
348  else
349   this->relDirection = absDir;
350
351  this->bRelDirChanged = true;
352}
353
354/**
355 * @see void PNode::setAbsDir (const Quaternion& relDir)
356 * @param x the x direction
357 * @param y the y direction
358 * @param z the z direction
359 *
360 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
361 */
362void PNode::setAbsDir (float x, float y, float z)
363{
364  this->setAbsDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
365}
366
367/**
368 *  shift coordinate (abs and rel)
369 * @param shift vector
370 * @todo implement this
371*/
372void PNode::shiftDir (const Quaternion& shift)
373{
374  this->relDirection = this->relDirection * shift;
375  this->bRelDirChanged = true;
376}
377
378/**
379 *  adds a child and makes this node to a parent
380 * @param pNode child reference
381 * @param parentMode on which changes the child should also change ist state
382 *
383 * use this to add a child to this node.
384*/
385void PNode::addChild (PNode* child, int parentMode)
386{
387  if( likely(child->parent != NULL))
388    {
389      PRINTF(4)("PNode::addChild() - reparenting node: removing it and adding it again\n");
390      child->parent->children->remove(child);
391    }
392  child->parentMode = parentMode;
393  child->parent = this;
394  this->children->add(child);
395  child->parentCoorChanged();
396}
397
398/**
399 * @see PNode::addChild(PNode* parent);
400 * @param childName the name of the child to add to this PNode
401 */
402void PNode::addChild (const char* childName)
403{
404  PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
405  if (childNode != NULL)
406    this->addChild(childNode);
407}
408
409/**
410 *  removes a child from the node
411 * @param pNode the child to remove from this pNode.
412 *
413 * Children from pNode will not be lost, they are referenced to NullPointer
414*/
415void PNode::removeChild (PNode* child)
416{
417  child->remove();
418  this->children->remove(child);
419  child->parent = NULL;
420}
421
422/**
423 *  remove this pnode from the tree and adds all following to NullParent
424
425   this can be the case, if an entity in the world is been destroyed.
426*/
427void PNode::remove()
428{
429  NullParent* nullParent = NullParent::getInstance();
430
431  tIterator<PNode>* iterator = this->children->getIterator();
432  PNode* pn = iterator->nextElement();
433
434  while( pn != NULL)
435    {
436      nullParent->addChild(pn, pn->getParentMode());
437      pn = iterator->nextElement();
438    }
439  delete iterator;
440  this->parent->children->remove(this);
441}
442
443/**
444 * sets the parent of this PNode
445 * @param parent the Parent to set
446*/
447void PNode::setParent (PNode* parent)
448{
449  parent->addChild(this);
450}
451
452/**
453 * @see PNode::setParent(PNode* parent);
454 * @param parentName the name of the Parent to set to this PNode
455 */
456void PNode::setParent (const char* parentName)
457{
458  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
459  if (parentNode != NULL)
460    parentNode->addChild(this);
461}
462
463/**
464 * does the reparenting in a very smooth way
465 * @param parentNode the new Node to connect this node to.
466 * @param bias the speed to iterate to this new Positions
467 */
468void PNode::softReparent(PNode* parentNode, float bias)
469{
470  if (this->parent == parentNode)
471    return;
472
473  if (likely(this->toCoordinate == NULL))
474  {
475    this->toCoordinate = new Vector();
476    *this->toCoordinate = this->getRelCoor();
477  }
478  if (likely(this->toDirection == NULL))
479  {
480    this->toDirection = new Quaternion();
481    *this->toDirection = this->getRelDir();
482  }
483  this->bias = bias;
484
485
486  Vector tmpV = this->getAbsCoor();
487  Quaternion tmpQ = this->getAbsDir();
488
489  parentNode->addChild(this);
490
491 if (this->parentMode & PNODE_ROTATE_MOVEMENT)
492   this->setRelCoor(this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor()));
493 else
494   this->setRelCoor(tmpV - parentNode->getAbsCoor());
495
496  this->setRelDir(tmpQ / parentNode->getAbsDir());
497}
498
499/**
500 * does the reparenting in a very smooth way
501 * @param parentName the name of the Parent to reconnect to
502 * @param bias the speed to iterate to this new Positions
503 */
504void PNode::softReparent(const char* parentName, float bias)
505{
506  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
507  if (parentNode != NULL)
508    this->softReparent(parentNode, bias);
509}
510
511/**
512 *  sets the mode of this parent manually
513 * @param parentMode a String representing this parentingMode
514 */
515void PNode::setParentMode (const char* parentingMode)
516{
517  this->setParentMode(PNode::charToParentingMode(parentingMode));
518}
519
520/**
521 *  updates the absCoordinate/absDirection
522 * @param dt The time passed since the last update
523
524   this is used to go through the parent-tree to update all the absolute coordinates
525   and directions. this update should be done by the engine, so you don't have to
526   worry, normaly...
527*/
528void PNode::update (float dt)
529{
530  if( likely(this->parent != NULL))
531    {
532      // movement for nodes with smoothMove enabled
533      if (unlikely(this->toCoordinate != NULL))
534      {
535        Vector moveVect = (*this->toCoordinate - this->getRelCoor()) *dt*bias;
536
537        if (likely(moveVect.len() >= PNODE_ITERATION_DELTA))
538        {
539          this->shiftCoor(moveVect);
540        }
541        else
542        {
543          delete this->toCoordinate;
544          this->toCoordinate = NULL;
545          PRINTF(5)("SmoothMove of %s finished\n", this->getName());
546        }
547      }
548      if (unlikely(this->toDirection != NULL))
549      {
550        Quaternion rotQuat = Quaternion::quatSlerp(Quaternion(), (*this->toDirection / this->relDirection), dt*this->bias);
551        if (likely(rotQuat.getSpacialAxisAngle() > PNODE_ITERATION_DELTA))
552        {
553          this->shiftDir(rotQuat);
554        }
555        else
556        {
557          delete this->toDirection;
558          this->toDirection = NULL;
559          PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
560        }
561      }
562
563      // MAIN UPDATE /////////////////////////////////////
564      this->lastAbsCoordinate = this->absCoordinate;
565
566      PRINTF(5)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
567
568
569      if( this->parentMode & PNODE_LOCAL_ROTATE && this->bRelDirChanged)
570      {
571        /* update the current absDirection - remember * means rotation around sth.*/
572        this->prevRelCoordinate = this->relCoordinate;
573        this->absDirection = this->relDirection * parent->getAbsDir();;
574      }
575
576      if(likely(this->parentMode & PNODE_MOVEMENT && this->bRelCoorChanged))
577      {
578        /* update the current absCoordinate */
579        this->prevRelCoordinate = this->relCoordinate;
580        this->absCoordinate = this->parent->getAbsCoor() + this->relCoordinate;
581      }
582      else if( this->parentMode & PNODE_ROTATE_MOVEMENT && this->bRelCoorChanged)
583      {
584        /* update the current absCoordinate */
585        this->prevRelCoordinate = this->relCoordinate;
586        this->absCoordinate = this->parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);
587      }
588      /////////////////////////////////////////////////
589   }
590  else
591    {
592      PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
593      if (this->bRelCoorChanged)
594        this->absCoordinate = this->relCoordinate;
595      if (this->bRelDirChanged)
596        this->absDirection = this->getAbsDir () * this->relDirection;
597    }
598
599    if(this->children->getSize() > 0)
600    {
601      tIterator<PNode>* iterator = this->children->getIterator();
602      PNode* pn = iterator->nextElement();
603      while( pn != NULL)
604      {
605        /* if this node has changed, make sure, that all children are updated also */
606        if( likely(this->bRelCoorChanged))
607          pn->parentCoorChanged ();
608        if( likely(this->bRelDirChanged))
609          pn->parentDirChanged ();
610
611        pn->update(dt);
612          //pn = this->children->nextElement();
613        pn = iterator->nextElement();
614      }
615      delete iterator;
616    }
617    this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
618    this->bRelCoorChanged = false;
619    this->bRelDirChanged = false;
620}
621
622/**
623 *  displays some information about this pNode
624 * @param depth The deph into which to debug the children of this PNode to.
625  (0: all children will be debugged, 1: only this PNode, 2: this and direct children...)
626 * @param level The n-th level of the Node we draw (this is internal and only for nice output)
627*/
628void PNode::debug(unsigned int depth, unsigned int level) const
629{
630  for (unsigned int i = 0; i < level; i++)
631    PRINT(0)(" |");
632  if (this->children->getSize() > 0)
633    PRINT(0)(" +");
634  else
635    PRINT(0)(" -");
636  PRINT(0)("PNode(%s::%s) - absCoord: (%0.2f, %0.2f, %0.2f), relCoord(%0.2f, %0.2f, %0.2f), direction(%0.2f, %0.2f, %0.2f) - %s\n",
637           this->getClassName(),
638           this->getName(),
639           this->absCoordinate.x,
640           this->absCoordinate.y,
641           this->absCoordinate.z,
642           this->relCoordinate.x,
643           this->relCoordinate.y,
644           this->relCoordinate.z,
645           this->getAbsDirV().x,
646           this->getAbsDirV().y,
647           this->getAbsDirV().z,
648           this->parentingModeToChar(parentMode));
649  if (depth >= 2 || depth == 0)
650  {
651    tIterator<PNode>* iterator = this->children->getIterator();
652      //PNode* pn = this->children->enumerate ();
653    PNode* pn = iterator->nextElement();
654    while( pn != NULL)
655    {
656      if (depth == 0)
657        pn->debug(0, level + 1);
658      else
659        pn->debug(depth - 1, level +1);
660      pn = iterator->nextElement();
661    }
662    delete iterator;
663  }
664}
665#include "color.h"
666
667/**
668   displays the PNode at its position with its rotation as a cube.
669*/
670void PNode::debugDraw(unsigned int depth, float size, Vector color) const
671{
672  glMatrixMode(GL_MODELVIEW);
673  glPushMatrix();
674  glDisable(GL_LIGHTING);
675
676  /* translate */
677  glTranslatef (this->getAbsCoor ().x,
678                this->getAbsCoor ().y,
679                this->getAbsCoor ().z);
680  /* rotate */
681//  this->getAbsDir ().matrix (matrix);
682//  glMultMatrixf((float*)matrix);
683
684  Vector tmpRot = this->getAbsDir().getSpacialAxis();
685  glColor3f(color.x, color.y, color.z);
686  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
687  {
688    glBegin(GL_LINE_STRIP);
689    glVertex3f(-.5*size, -.5*size,  -.5*size);
690    glVertex3f(+.5*size, -.5*size,  -.5*size);
691    glVertex3f(+.5*size, -.5*size,  +.5*size);
692    glVertex3f(-.5*size, -.5*size,  +.5*size);
693    glVertex3f(-.5*size, -.5*size,  -.5*size);
694    glEnd();
695    glBegin(GL_LINE_STRIP);
696    glVertex3f(-.5*size, +.5*size,  -.5*size);
697    glVertex3f(+.5*size, +.5*size,  -.5*size);
698    glVertex3f(+.5*size, +.5*size,  +.5*size);
699    glVertex3f(-.5*size, +.5*size,  +.5*size);
700    glVertex3f(-.5*size, +.5*size,  -.5*size);
701    glEnd();
702
703    glBegin(GL_LINES);
704    glVertex3f(-.5*size, -.5*size,  -.5*size);
705    glVertex3f(-.5*size, +.5*size,  -.5*size);
706    glVertex3f(+.5*size, -.5*size,  -.5*size);
707    glVertex3f(+.5*size, +.5*size,  -.5*size);
708    glVertex3f(+.5*size, -.5*size,  +.5*size);
709    glVertex3f(+.5*size, +.5*size,  +.5*size);
710    glVertex3f(-.5*size, -.5*size,  +.5*size);
711    glVertex3f(-.5*size, +.5*size,  +.5*size);
712    glEnd();
713  }
714
715  glPopMatrix();
716  glEnable(GL_LIGHTING);
717  if (depth >= 2 || depth == 0)
718  {
719    tIterator<PNode>* iterator = this->children->getIterator();
720      //PNode* pn = this->children->enumerate ();
721    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
722    PNode* pn = iterator->nextElement();
723    while( pn != NULL)
724    {
725      if (depth == 0)
726        pn->debugDraw(0, size, childColor);
727      else
728        pn->debugDraw(depth - 1, size, childColor);
729      pn = iterator->nextElement();
730    }
731    delete iterator;
732  }
733}
734
735
736
737/////////////////////
738// HELPER_FUCTIONS //
739/////////////////////
740
741/**
742 * converts a parentingMode into a string that is the name of it
743 * @param parentingMode the ParentingMode to convert
744 * @return the converted string
745 */
746const char* PNode::parentingModeToChar(int parentingMode)
747{
748  if (parentingMode == PNODE_LOCAL_ROTATE)
749    return "local-rotate";
750  else if (parentingMode == PNODE_ROTATE_MOVEMENT)
751    return "rotate-movement";
752  else if (parentingMode == PNODE_MOVEMENT)
753    return "movement";
754  else if (parentingMode == PNODE_ALL)
755    return "all";
756  else if (parentingMode == PNODE_ROTATE_AND_MOVE)
757    return "rotate-and-move";
758}
759
760/**
761 * converts a parenting-mode-string into a int
762 * @param parentingMode the string naming the parentingMode
763 * @return the int corresponding to the named parentingMode
764 */
765PARENT_MODE PNode::charToParentingMode(const char* parentingMode)
766{
767  if (!strcmp(parentingMode, "local-rotate"))
768    return (PNODE_LOCAL_ROTATE);
769  else  if (!strcmp(parentingMode, "rotate-movement"))
770    return (PNODE_ROTATE_MOVEMENT);
771  else  if (!strcmp(parentingMode, "movement"))
772    return (PNODE_MOVEMENT);
773  else  if (!strcmp(parentingMode, "all"))
774    return (PNODE_ALL);
775  else  if (!strcmp(parentingMode, "rotate-and-move"))
776    return (PNODE_ROTATE_AND_MOVE);
777}
Note: See TracBrowser for help on using the repository browser.