Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: softDir/softCoor is now overwritten(deleted) if one sets the relCoor/relDir/absDir/absCoor
shell is also in smooth-mode now :)

File size: 21.1 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>(element, "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  if (this->toCoordinate!= NULL)
168  {
169    delete this->toCoordinate;
170    this->toCoordinate = NULL;
171  }
172
173  this->relCoordinate = relCoord;
174  this->bRelCoorChanged = true;
175}
176
177/**
178 *  set relative coordinates
179 * @param x x-relative coordinates to its parent
180 * @param y y-relative coordinates to its parent
181 * @param z z-relative coordinates to its parent
182 * @see  void PNode::setRelCoor (const Vector& relCoord)
183*/
184void PNode::setRelCoor (float x, float y, float z)
185{
186  this->setRelCoor(Vector(x, y, z));
187}
188
189/**
190 * sets a new relative position smoothely
191 * @param relCoordSoft the new Position to iterate to
192 * @param bias how fast to iterate to this position
193 */
194void PNode::setRelCoorSoft(const Vector& relCoordSoft, float bias)
195{
196  if (likely(this->toCoordinate == NULL))
197    this->toCoordinate = new Vector();
198
199  *this->toCoordinate = relCoordSoft;
200  this->bias = bias;
201}
202
203
204/**
205 *  set relative coordinates smoothely
206 * @param x x-relative coordinates to its parent
207 * @param y y-relative coordinates to its parent
208 * @param z z-relative coordinates to its parent
209 * @see  void PNode::setRelCoorSoft (const Vector&, float)
210 */
211void PNode::setRelCoorSoft (float x, float y, float z, float bias)
212{
213  this->setRelCoorSoft(Vector(x, y, z), bias);
214}
215
216/**
217 * @param absCoord set absolute coordinate
218 */
219void PNode::setAbsCoor (const Vector& absCoord)
220{
221  if (this->toCoordinate!= NULL)
222  {
223    delete this->toCoordinate;
224    this->toCoordinate = NULL;
225  }
226
227  if( likely(this->parentMode & PNODE_MOVEMENT))
228  {
229      /* if you have set the absolute coordinates this overrides all other changes */
230    if (likely(this->parent != NULL))
231      this->relCoordinate = absCoord - parent->getAbsCoor ();
232    else
233      this->relCoordinate = absCoord;
234  }
235  if( this->parentMode & PNODE_ROTATE_MOVEMENT)
236  {
237    if (likely(this->parent != NULL))
238      this->relCoordinate = absCoord - parent->getAbsCoor ();
239    else
240      this->relCoordinate = absCoord;
241  }
242
243  this->bRelCoorChanged = true;
244//  this->absCoordinate = absCoord;
245}
246
247/**
248 * @param x x-coordinate.
249 * @param y y-coordinate.
250 * @param z z-coordinate.
251 * @see void PNode::setAbsCoor (const Vector& absCoord)
252 */
253void PNode::setAbsCoor(float x, float y, float z)
254{
255  this->setAbsCoor(Vector(x, y, z));
256}
257
258/**
259 *  shift coordinate relative
260 * @param shift shift vector
261
262   this function shifts the current coordinates about the vector shift. this is
263   usefull because from some place else you can:
264   PNode* someNode = ...;
265   Vector objectMovement = calculateShift();
266   someNode->shiftCoor(objectMovement);
267
268   elsewhere you would have to:
269   PNode* someNode = ...;
270   Vector objectMovement = calculateShift();
271   Vector currentCoor = someNode->getRelCoor();
272   Vector newCoor = currentCoor + objectMovement;
273   someNode->setRelCoor(newCoor);
274
275   yea right... shorter...
276 *
277*/
278void PNode::shiftCoor (const Vector& shift)
279{
280  this->relCoordinate += shift;
281  this->bRelCoorChanged = true;
282}
283
284/**
285 *  set relative direction
286 * @param relDir to its parent
287 */
288void PNode::setRelDir (const Quaternion& relDir)
289{
290  if (this->toDirection!= NULL)
291  {
292    delete this->toDirection;
293    this->toDirection = NULL;
294  }
295  this->relDirection = relDir;
296  this->bRelCoorChanged = true;
297}
298
299/**
300 * @see void PNode::setRelDir (const Quaternion& relDir)
301 * @param x the x direction
302 * @param y the y direction
303 * @param z the z direction
304 *
305 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
306 */
307void PNode::setRelDir (float x, float y, float z)
308{
309  this->setRelDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
310}
311
312
313/**
314 * sets the Relative Direction of this node to its parent in a Smoothed way
315 * @param relDirSoft the direction to iterate to smoothely.
316 * @param bias how fast to iterate to the new Direction
317 */
318void PNode::setRelDirSoft(const Quaternion& relDirSoft, float bias)
319{
320  if (likely(this->toDirection == NULL))
321    this->toDirection = new Quaternion();
322
323  *this->toDirection = relDirSoft;
324  this->bias = bias;
325}
326
327/**
328 * @see void PNode::setRelDirSoft (const Quaternion& relDir)
329 * @param x the x direction
330 * @param y the y direction
331 * @param z the z direction
332 *
333 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
334 */
335void PNode::setRelDirSoft(float x, float y, float z, float bias)
336{
337  this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
338}
339
340/**
341 *  sets the absolute direction
342 * @param absDir absolute coordinates
343 */
344void PNode::setAbsDir (const Quaternion& absDir)
345{
346  if (this->toDirection!= NULL)
347  {
348    delete this->toDirection;
349    this->toDirection = NULL;
350  }
351
352  if (likely(this->parent != NULL))
353    this->relDirection = absDir / this->parent->getAbsDir();
354  else
355   this->relDirection = absDir;
356
357  this->bRelDirChanged = true;
358}
359
360/**
361 * @see void PNode::setAbsDir (const Quaternion& relDir)
362 * @param x the x direction
363 * @param y the y direction
364 * @param z the z direction
365 *
366 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
367 */
368void PNode::setAbsDir (float x, float y, float z)
369{
370  this->setAbsDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
371}
372
373/**
374 * shift Direction
375 * @param shift the direction around which to shift.
376 */
377void PNode::shiftDir (const Quaternion& shift)
378{
379  this->relDirection = this->relDirection * shift;
380  this->bRelDirChanged = true;
381}
382
383/**
384 *  adds a child and makes this node to a parent
385 * @param child child reference
386 * @param parentMode on which changes the child should also change ist state
387 *
388 * use this to add a child to this node.
389*/
390void PNode::addChild (PNode* child, int parentMode)
391{
392  if( likely(child->parent != NULL))
393    {
394      PRINTF(4)("PNode::addChild() - reparenting node: removing it and adding it again\n");
395      child->parent->children->remove(child);
396    }
397  child->parentMode = parentMode;
398  child->parent = this;
399  this->children->add(child);
400  child->parentCoorChanged();
401}
402
403/**
404 * @see PNode::addChild(PNode* child);
405 * @param childName the name of the child to add to this PNode
406 */
407void PNode::addChild (const char* childName)
408{
409  PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
410  if (childNode != NULL)
411    this->addChild(childNode);
412}
413
414/**
415 *  removes a child from the node
416 * @param child the child to remove from this pNode.
417 *
418 * Children from pNode will not be lost, they are referenced to NullPointer
419*/
420void PNode::removeChild (PNode* child)
421{
422  child->remove();
423  this->children->remove(child);
424  child->parent = NULL;
425}
426
427/**
428 *  remove this pnode from the tree and adds all following to NullParent
429
430   this can be the case, if an entity in the world is being destroyed.
431*/
432void PNode::remove()
433{
434  NullParent* nullParent = NullParent::getInstance();
435
436  tIterator<PNode>* iterator = this->children->getIterator();
437  PNode* pn = iterator->nextElement();
438
439  while( pn != NULL)
440    {
441      nullParent->addChild(pn, pn->getParentMode());
442      pn = iterator->nextElement();
443    }
444  delete iterator;
445  this->parent->children->remove(this);
446}
447
448/**
449 * sets the parent of this PNode
450 * @param parent the Parent to set
451*/
452void PNode::setParent (PNode* parent)
453{
454  parent->addChild(this);
455}
456
457/**
458 * @see PNode::setParent(PNode* parent);
459 * @param parentName the name of the Parent to set to this PNode
460 */
461void PNode::setParent (const char* parentName)
462{
463  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
464  if (parentNode != NULL)
465    parentNode->addChild(this);
466}
467
468/**
469 * does the reparenting in a very smooth way
470 * @param parentNode the new Node to connect this node to.
471 * @param bias the speed to iterate to this new Positions
472 */
473void PNode::softReparent(PNode* parentNode, float bias)
474{
475  if (this->parent == parentNode)
476    return;
477
478  if (likely(this->toCoordinate == NULL))
479  {
480    this->toCoordinate = new Vector();
481    *this->toCoordinate = this->getRelCoor();
482  }
483  if (likely(this->toDirection == NULL))
484  {
485    this->toDirection = new Quaternion();
486    *this->toDirection = this->getRelDir();
487  }
488  this->bias = bias;
489
490
491  Vector tmpV = this->getAbsCoor();
492  Quaternion tmpQ = this->getAbsDir();
493
494  parentNode->addChild(this);
495
496 if (this->parentMode & PNODE_ROTATE_MOVEMENT)
497   this->setRelCoor(this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor()));
498 else
499   this->setRelCoor(tmpV - parentNode->getAbsCoor());
500
501  this->setRelDir(tmpQ / parentNode->getAbsDir());
502}
503
504/**
505 * does the reparenting in a very smooth way
506 * @param parentName the name of the Parent to reconnect to
507 * @param bias the speed to iterate to this new Positions
508 */
509void PNode::softReparent(const char* parentName, float bias)
510{
511  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
512  if (parentNode != NULL)
513    this->softReparent(parentNode, bias);
514}
515
516/**
517 *  sets the mode of this parent manually
518 * @param parentMode a String representing this parentingMode
519 */
520void PNode::setParentMode (const char* parentingMode)
521{
522  this->setParentMode(PNode::charToParentingMode(parentingMode));
523}
524
525/**
526 *  updates the absCoordinate/absDirection
527 * @param dt The time passed since the last update
528
529   this is used to go through the parent-tree to update all the absolute coordinates
530   and directions. this update should be done by the engine, so you don't have to
531   worry, normaly...
532*/
533void PNode::update (float dt)
534{
535  if( likely(this->parent != NULL))
536    {
537      // movement for nodes with smoothMove enabled
538      if (unlikely(this->toCoordinate != NULL))
539      {
540        Vector moveVect = (*this->toCoordinate - this->getRelCoor()) *dt*bias;
541
542        if (likely(moveVect.len() >= PNODE_ITERATION_DELTA))
543        {
544          this->shiftCoor(moveVect);
545        }
546        else
547        {
548          delete this->toCoordinate;
549          this->toCoordinate = NULL;
550          PRINTF(5)("SmoothMove of %s finished\n", this->getName());
551        }
552      }
553      if (unlikely(this->toDirection != NULL))
554      {
555        Quaternion rotQuat = Quaternion::quatSlerp(Quaternion(), (*this->toDirection / this->relDirection), dt*this->bias);
556        if (likely(rotQuat.getSpacialAxisAngle() > PNODE_ITERATION_DELTA))
557        {
558          this->shiftDir(rotQuat);
559        }
560        else
561        {
562          delete this->toDirection;
563          this->toDirection = NULL;
564          PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
565        }
566      }
567
568      // MAIN UPDATE /////////////////////////////////////
569      this->lastAbsCoordinate = this->absCoordinate;
570
571      PRINTF(5)("PNode::update - %s - (%f, %f, %f)\n", this->getName(), this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
572
573
574      if( this->parentMode & PNODE_LOCAL_ROTATE && this->bRelDirChanged)
575      {
576        /* update the current absDirection - remember * means rotation around sth.*/
577        this->prevRelCoordinate = this->relCoordinate;
578        this->absDirection = this->relDirection * parent->getAbsDir();;
579      }
580
581      if(likely(this->parentMode & PNODE_MOVEMENT && this->bRelCoorChanged))
582      {
583        /* update the current absCoordinate */
584        this->prevRelCoordinate = this->relCoordinate;
585        this->absCoordinate = this->parent->getAbsCoor() + this->relCoordinate;
586      }
587      else if( this->parentMode & PNODE_ROTATE_MOVEMENT && this->bRelCoorChanged)
588      {
589        /* update the current absCoordinate */
590        this->prevRelCoordinate = this->relCoordinate;
591        this->absCoordinate = this->parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);
592      }
593      /////////////////////////////////////////////////
594   }
595  else
596    {
597      PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
598      if (this->bRelCoorChanged)
599        this->absCoordinate = this->relCoordinate;
600      if (this->bRelDirChanged)
601        this->absDirection = this->getAbsDir () * this->relDirection;
602    }
603
604    if(this->children->getSize() > 0)
605    {
606      tIterator<PNode>* iterator = this->children->getIterator();
607      PNode* pn = iterator->nextElement();
608      while( pn != NULL)
609      {
610        /* if this node has changed, make sure, that all children are updated also */
611        if( likely(this->bRelCoorChanged))
612          pn->parentCoorChanged ();
613        if( likely(this->bRelDirChanged))
614          pn->parentDirChanged ();
615
616        pn->update(dt);
617          //pn = this->children->nextElement();
618        pn = iterator->nextElement();
619      }
620      delete iterator;
621    }
622    this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
623    this->bRelCoorChanged = false;
624    this->bRelDirChanged = false;
625}
626
627/**
628 *  displays some information about this pNode
629 * @param depth The deph into which to debug the children of this PNode to.
630 * (0: all children will be debugged, 1: only this PNode, 2: this and direct children...)
631 * @param level The n-th level of the Node we draw (this is internal and only for nice output)
632*/
633void PNode::debug(unsigned int depth, unsigned int level) const
634{
635  for (unsigned int i = 0; i < level; i++)
636    PRINT(0)(" |");
637  if (this->children->getSize() > 0)
638    PRINT(0)(" +");
639  else
640    PRINT(0)(" -");
641  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",
642           this->getClassName(),
643           this->getName(),
644           this->absCoordinate.x,
645           this->absCoordinate.y,
646           this->absCoordinate.z,
647           this->relCoordinate.x,
648           this->relCoordinate.y,
649           this->relCoordinate.z,
650           this->getAbsDirV().x,
651           this->getAbsDirV().y,
652           this->getAbsDirV().z,
653           this->parentingModeToChar(parentMode));
654  if (depth >= 2 || depth == 0)
655  {
656    tIterator<PNode>* iterator = this->children->getIterator();
657      //PNode* pn = this->children->enumerate ();
658    PNode* pn = iterator->nextElement();
659    while( pn != NULL)
660    {
661      if (depth == 0)
662        pn->debug(0, level + 1);
663      else
664        pn->debug(depth - 1, level +1);
665      pn = iterator->nextElement();
666    }
667    delete iterator;
668  }
669}
670#include "color.h"
671
672/**
673   displays the PNode at its position with its rotation as a cube.
674*/
675void PNode::debugDraw(unsigned int depth, float size, Vector color) const
676{
677  glMatrixMode(GL_MODELVIEW);
678  glPushMatrix();
679  glDisable(GL_LIGHTING);
680
681  /* translate */
682  glTranslatef (this->getAbsCoor ().x,
683                this->getAbsCoor ().y,
684                this->getAbsCoor ().z);
685  /* rotate */
686//  this->getAbsDir ().matrix (matrix);
687//  glMultMatrixf((float*)matrix);
688
689  Vector tmpRot = this->getAbsDir().getSpacialAxis();
690  glColor3f(color.x, color.y, color.z);
691  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
692  {
693    glBegin(GL_LINE_STRIP);
694    glVertex3f(-.5*size, -.5*size,  -.5*size);
695    glVertex3f(+.5*size, -.5*size,  -.5*size);
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    glEnd();
700    glBegin(GL_LINE_STRIP);
701    glVertex3f(-.5*size, +.5*size,  -.5*size);
702    glVertex3f(+.5*size, +.5*size,  -.5*size);
703    glVertex3f(+.5*size, +.5*size,  +.5*size);
704    glVertex3f(-.5*size, +.5*size,  +.5*size);
705    glVertex3f(-.5*size, +.5*size,  -.5*size);
706    glEnd();
707
708    glBegin(GL_LINES);
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    glVertex3f(+.5*size, +.5*size,  -.5*size);
713    glVertex3f(+.5*size, -.5*size,  +.5*size);
714    glVertex3f(+.5*size, +.5*size,  +.5*size);
715    glVertex3f(-.5*size, -.5*size,  +.5*size);
716    glVertex3f(-.5*size, +.5*size,  +.5*size);
717    glEnd();
718  }
719
720  glPopMatrix();
721  glEnable(GL_LIGHTING);
722  if (depth >= 2 || depth == 0)
723  {
724    tIterator<PNode>* iterator = this->children->getIterator();
725      //PNode* pn = this->children->enumerate ();
726    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
727    PNode* pn = iterator->nextElement();
728    while( pn != NULL)
729    {
730      if (depth == 0)
731        pn->debugDraw(0, size, childColor);
732      else
733        pn->debugDraw(depth - 1, size, childColor);
734      pn = iterator->nextElement();
735    }
736    delete iterator;
737  }
738}
739
740
741
742/////////////////////
743// HELPER_FUCTIONS //
744/////////////////////
745
746/**
747 * converts a parentingMode into a string that is the name of it
748 * @param parentingMode the ParentingMode to convert
749 * @return the converted string
750 */
751const char* PNode::parentingModeToChar(int parentingMode)
752{
753  if (parentingMode == PNODE_LOCAL_ROTATE)
754    return "local-rotate";
755  else if (parentingMode == PNODE_ROTATE_MOVEMENT)
756    return "rotate-movement";
757  else if (parentingMode == PNODE_MOVEMENT)
758    return "movement";
759  else if (parentingMode == PNODE_ALL)
760    return "all";
761  else if (parentingMode == PNODE_ROTATE_AND_MOVE)
762    return "rotate-and-move";
763}
764
765/**
766 * converts a parenting-mode-string into a int
767 * @param parentingMode the string naming the parentingMode
768 * @return the int corresponding to the named parentingMode
769 */
770PARENT_MODE PNode::charToParentingMode(const char* parentingMode)
771{
772  if (!strcmp(parentingMode, "local-rotate"))
773    return (PNODE_LOCAL_ROTATE);
774  else  if (!strcmp(parentingMode, "rotate-movement"))
775    return (PNODE_ROTATE_MOVEMENT);
776  else  if (!strcmp(parentingMode, "movement"))
777    return (PNODE_MOVEMENT);
778  else  if (!strcmp(parentingMode, "all"))
779    return (PNODE_ALL);
780  else  if (!strcmp(parentingMode, "rotate-and-move"))
781    return (PNODE_ROTATE_AND_MOVE);
782}
Note: See TracBrowser for help on using the repository browser.