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