Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6713 was 6695, checked in by patrick, 19 years ago

merged the network branche to the trunk

File size: 36.4 KB
RevLine 
[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
[5419]13   co-programmer: Benjamin Grauer
[3246]14*/
15
[3590]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PNODE
[3246]17
18#include "p_node.h"
[4761]19
20#include "load_param.h"
21#include "class_list.h"
22
[6078]23#include <algorithm>
[3860]24#include "compiler.h"
[3608]25#include "debug.h"
26
[6054]27#include "glincl.h"
[5406]28#include "color.h"
[3246]29
[6341]30#include "synchronizeable.h"
31
[6424]32#include "shell_command.h"
33SHELL_COMMAND(debugNode, PNode, debugNodeSC);
34
[3246]35using namespace std;
36
37
38/**
[6048]39 * @brief standard constructor
[6078]40 * @param parent the Parent of this Node. __NULL__ if __No Parent__ requested, PNode::getNullParent(), if connected to NullParent directly (default)
[6299]41 * @param nodeFlags all flags to set. THIS_WILL_OVERWRITE Default_Values.
[5420]42 */
[6078]43PNode::PNode (PNode* parent, long nodeFlags)
[6695]44  : Synchronizeable(), BaseObject()
[3365]45{
[6074]46  this->setClassID(CL_PARENT_NODE, "PNode");
[3365]47
[6074]48  this->bRelCoorChanged = true;
49  this->bRelDirChanged = true;
50  this->parent = NULL;
[6078]51  this->parentMode = nodeFlags;
[6074]52  this->bActive = true;
[4993]53
[6074]54  // smooth-movers
55  this->toCoordinate = NULL;
56  this->toDirection = NULL;
57  this->bias = 1.0;
[6078]58
59  if (parent != NULL)
60    parent->addChild(this);
[3365]61}
62
[6074]63// NullParent Reference
64PNode* PNode::nullParent = NULL;
[6073]65
[3365]66/**
[6048]67 * @brief standard deconstructor
[5296]68 *
69 * There are two general ways to delete a PNode
70 * 1. delete instance;
71 *   -> result
72 *    delete this Node and all its children and children's children...
73 *    (danger if you still need the children's instance somewhere else!!)
74 *
[6073]75 * 2. instance->removeNode(); delete instance;
[5296]76 *   -> result:
77 *    moves its children to the NullParent
78 *    then deletes the Element.
79 */
[4570]80PNode::~PNode ()
[3365]81{
[6073]82  // remove the Node, delete it's children (if required).
83  std::list<PNode*>::iterator tmp = this->children.begin();
84  std::list<PNode*>::iterator deleteNode;
85  while(!this->children.empty())
86    while (tmp != this->children.end())
87    {
88      deleteNode = tmp;
[6142]89      tmp++;
[6078]90//      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
[6073]91      if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
92          ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
93      {
[6078]94        if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)
[6073]95          delete (*deleteNode);
96        else
97          (*deleteNode)->reparent();
98      }
99      else
100        delete (*deleteNode);
101    }
102
[6071]103  if (this->parent != NULL)
104   {
[6078]105     this->parent->eraseChild(this);
[6071]106     this->parent = NULL;
107   }
108
[5296]109  // remove all other allocated memory.
[5088]110  if (this->toCoordinate != NULL)
111    delete this->toCoordinate;
112  if (this->toDirection != NULL)
113    delete this->toDirection;
[6075]114
115  if (this == PNode::nullParent)
116    PNode::nullParent = NULL;
[3365]117}
[3246]118
[5296]119
[4448]120/**
[6048]121 * @brief loads parameters of the PNode
[4836]122 * @param root the XML-element to load the properties of
[5420]123 */
[4436]124void PNode::loadParams(const TiXmlElement* root)
125{
[6512]126  BaseObject::loadParams(root);
[4610]127
[5671]128  LoadParam(root, "rel-coor", this, PNode, setRelCoor)
[4771]129      .describe("Sets The relative position of the Node to its parent.");
130
[5671]131  LoadParam(root, "abs-coor", this, PNode, setAbsCoor)
[4610]132      .describe("Sets The absolute Position of the Node.");
133
[5671]134  LoadParam(root, "rel-dir", this, PNode, setRelDir)
[4771]135      .describe("Sets The relative rotation of the Node to its parent.");
[4761]136
[5671]137  LoadParam(root, "abs-dir", this, PNode, setAbsDir)
[4771]138      .describe("Sets The absolute rotation of the Node.");
139
[5671]140  LoadParam(root, "parent", this, PNode, setParent)
[4761]141      .describe("the Name of the Parent of this PNode");
[4765]142
[5671]143  LoadParam(root, "parent-mode", this, PNode, setParentMode)
[4765]144      .describe("the mode to connect this node to its parent ()");
145
146  // cycling properties
[4785]147  if (root != NULL)
[4765]148  {
[5654]149    LOAD_PARAM_START_CYCLE(root, element);
[4785]150    {
[6074]151      LoadParam_CYCLE(element, "child", this, PNode, addChild)
[4785]152          .describe("adds a new Child to the current Node.");
[4765]153
[4785]154    }
[5654]155    LOAD_PARAM_END_CYCLE(element);
[4765]156  }
[4436]157}
[3365]158
[6424]159
[3365]160/**
[6424]161 *  init the pnode to a well definied state
162 *
163 * this function actualy only updates the PNode tree
164 */
165void PNode::init()
166{
167  /* just update all aboslute positions via timestep 0.001ms */
168  this->updateNode(0.001f);
169  this->updateNode(0.001f);
170}
171
172
173/**
[6048]174 * @brief set relative coordinates
[4836]175 * @param relCoord relative coordinates to its parent
[5420]176 *
177 *
178 * it is very importand, that you use this function, if you want to update the
179 * relCoordinates. If you don't use this, the PNode won't recognize, that something
180 * has changed and won't update the children Nodes.
181 */
[3810]182void PNode::setRelCoor (const Vector& relCoord)
[3675]183{
[5113]184  if (this->toCoordinate!= NULL)
185  {
186    delete this->toCoordinate;
187    this->toCoordinate = NULL;
188  }
189
[4993]190  this->relCoordinate = relCoord;
[3675]191  this->bRelCoorChanged = true;
192}
193
194/**
[6048]195 * @brief set relative coordinates
[4836]196 * @param x x-relative coordinates to its parent
197 * @param y y-relative coordinates to its parent
198 * @param z z-relative coordinates to its parent
[4993]199 * @see  void PNode::setRelCoor (const Vector& relCoord)
[5420]200 */
[4610]201void PNode::setRelCoor (float x, float y, float z)
202{
203  this->setRelCoor(Vector(x, y, z));
204}
205
[4992]206/**
[6048]207 * @brief sets a new relative position smoothely
[4992]208 * @param relCoordSoft the new Position to iterate to
209 * @param bias how fast to iterate to this position
210 */
211void PNode::setRelCoorSoft(const Vector& relCoordSoft, float bias)
[4987]212{
[4993]213  if (likely(this->toCoordinate == NULL))
214    this->toCoordinate = new Vector();
[4987]215
[4993]216  *this->toCoordinate = relCoordSoft;
[6616]217  this->toStep = 0.0f;
[4992]218  this->bias = bias;
[4987]219}
220
[4990]221
[4610]222/**
[6048]223 * @brief set relative coordinates smoothely
[4990]224 * @param x x-relative coordinates to its parent
225 * @param y y-relative coordinates to its parent
226 * @param z z-relative coordinates to its parent
[4993]227 * @see  void PNode::setRelCoorSoft (const Vector&, float)
[4990]228 */
[4992]229void PNode::setRelCoorSoft (float x, float y, float z, float bias)
[4990]230{
[4992]231  this->setRelCoorSoft(Vector(x, y, z), bias);
[4990]232}
233
[5382]234
[4990]235/**
[4836]236 * @param absCoord set absolute coordinate
[5091]237 */
[3809]238void PNode::setAbsCoor (const Vector& absCoord)
[3675]239{
[5113]240  if (this->toCoordinate!= NULL)
241  {
242    delete this->toCoordinate;
243    this->toCoordinate = NULL;
244  }
245
[4993]246  if( likely(this->parentMode & PNODE_MOVEMENT))
247  {
248      /* if you have set the absolute coordinates this overrides all other changes */
249    if (likely(this->parent != NULL))
250      this->relCoordinate = absCoord - parent->getAbsCoor ();
251    else
252      this->relCoordinate = absCoord;
253  }
254  if( this->parentMode & PNODE_ROTATE_MOVEMENT)
255  {
256    if (likely(this->parent != NULL))
257      this->relCoordinate = absCoord - parent->getAbsCoor ();
258    else
259      this->relCoordinate = absCoord;
260  }
261
262  this->bRelCoorChanged = true;
263//  this->absCoordinate = absCoord;
[3675]264}
265
[5382]266
[3675]267/**
[4836]268 * @param x x-coordinate.
269 * @param y y-coordinate.
270 * @param z z-coordinate.
[4987]271 * @see void PNode::setAbsCoor (const Vector& absCoord)
[4610]272 */
273void PNode::setAbsCoor(float x, float y, float z)
274{
275  this->setAbsCoor(Vector(x, y, z));
276}
277
[6054]278
[4610]279/**
[5406]280 * @param absCoord set absolute coordinate
281 * @todo check off
282 */
283void PNode::setAbsCoorSoft (const Vector& absCoordSoft, float bias)
284{
285  if (this->toCoordinate == NULL)
286    this->toCoordinate = new Vector;
287
288  if( likely(this->parentMode & PNODE_MOVEMENT))
289  {
290      /* if you have set the absolute coordinates this overrides all other changes */
291    if (likely(this->parent != NULL))
292      *this->toCoordinate = absCoordSoft - parent->getAbsCoor ();
293    else
294      *this->toCoordinate = absCoordSoft;
295  }
296  if( this->parentMode & PNODE_ROTATE_MOVEMENT)
297  {
298    if (likely(this->parent != NULL))
299      *this->toCoordinate = absCoordSoft - parent->getAbsCoor ();
300    else
301      *this->toCoordinate = absCoordSoft;
302  }
[6616]303  this->toStep = 0.0f;
[5406]304}
305
306
307/**
[6048]308 * @brief shift coordinate relative
[4836]309 * @param shift shift vector
[4987]310 *
[5420]311 * this function shifts the current coordinates about the vector shift. this is
312 * usefull because from some place else you can:
313 * PNode* someNode = ...;
314 * Vector objectMovement = calculateShift();
315 * someNode->shiftCoor(objectMovement);
316 *
317 * this is the internal method of:
318 * PNode* someNode = ...;
319 * Vector objectMovement = calculateShift();
320 * Vector currentCoor = someNode->getRelCoor();
321 * Vector newCoor = currentCoor + objectMovement;
322 * someNode->setRelCoor(newCoor);
323 *
[5382]324 */
[3809]325void PNode::shiftCoor (const Vector& shift)
[3683]326{
[4993]327  this->relCoordinate += shift;
328  this->bRelCoorChanged = true;
[3683]329}
330
[6054]331
[3683]332/**
[6048]333 * @brief set relative direction
[4836]334 * @param relDir to its parent
[5091]335 */
[3810]336void PNode::setRelDir (const Quaternion& relDir)
[3675]337{
[5113]338  if (this->toDirection!= NULL)
339  {
340    delete this->toDirection;
341    this->toDirection = NULL;
342  }
[4993]343  this->relDirection = relDir;
[5819]344
[3675]345  this->bRelCoorChanged = true;
346}
347
[6054]348
[3365]349/**
[4771]350 * @see void PNode::setRelDir (const Quaternion& relDir)
351 * @param x the x direction
352 * @param y the y direction
353 * @param z the z direction
354 *
355 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
356 */
357void PNode::setRelDir (float x, float y, float z)
358{
359  this->setRelDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
360}
361
[4990]362
[4771]363/**
[6048]364 * @brief sets the Relative Direction of this node to its parent in a Smoothed way
[4990]365 * @param relDirSoft the direction to iterate to smoothely.
[4992]366 * @param bias how fast to iterate to the new Direction
[4990]367 */
[4992]368void PNode::setRelDirSoft(const Quaternion& relDirSoft, float bias)
[4990]369{
370  if (likely(this->toDirection == NULL))
371    this->toDirection = new Quaternion();
372
373  *this->toDirection = relDirSoft;
[4992]374  this->bias = bias;
[6616]375  this->toStep = 0.0f;
[5819]376  this->bRelDirChanged = true;
[4990]377}
378
[6054]379
[4990]380/**
381 * @see void PNode::setRelDirSoft (const Quaternion& relDir)
382 * @param x the x direction
383 * @param y the y direction
384 * @param z the z direction
385 *
386 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
387 */
[4992]388void PNode::setRelDirSoft(float x, float y, float z, float bias)
[4990]389{
[4992]390  this->setRelDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
[4990]391}
392
[6054]393
[4990]394/**
[6048]395 * @brief sets the absolute direction
[4836]396 * @param absDir absolute coordinates
[5091]397 */
[3810]398void PNode::setAbsDir (const Quaternion& absDir)
[3675]399{
[5113]400  if (this->toDirection!= NULL)
401  {
402    delete this->toDirection;
403    this->toDirection = NULL;
404  }
405
[5001]406  if (likely(this->parent != NULL))
407    this->relDirection = absDir / this->parent->getAbsDir();
[4996]408  else
[5001]409   this->relDirection = absDir;
[4993]410
411  this->bRelDirChanged = true;
[3675]412}
413
[6054]414
[3675]415/**
[4771]416 * @see void PNode::setAbsDir (const Quaternion& relDir)
417 * @param x the x direction
418 * @param y the y direction
419 * @param z the z direction
420 *
421 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
422 */
423void PNode::setAbsDir (float x, float y, float z)
424{
425  this->setAbsDir(Quaternion(Vector(x,y,z), Vector(0,1,0)));
426}
427
[6054]428
[4771]429/**
[6048]430 * @brief sets the absolute direction
[5414]431 * @param absDir absolute coordinates
[6048]432 * @param bias how fast to iterator to the new Position
[5414]433 */
434void PNode::setAbsDirSoft (const Quaternion& absDirSoft, float bias)
435{
436  if (this->toDirection == NULL)
437    this->toDirection = new Quaternion();
438
439  if (likely(this->parent != NULL))
440    *this->toDirection = absDirSoft / this->parent->getAbsDir();
441  else
442   *this->toDirection = absDirSoft;
443
444  this->bias = bias;
[6616]445  this->toStep = 0.0f;
[5915]446  this->bRelDirChanged = true;
[5414]447}
448
[6054]449
[5414]450/**
451 * @see void PNode::setAbsDir (const Quaternion& relDir)
452 * @param x the x direction
453 * @param y the y direction
454 * @param z the z direction
455 *
456 * main difference is, that here you give a directional vector, that will be translated into a Quaternion
457 */
458void PNode::setAbsDirSoft (float x, float y, float z, float bias)
459{
460  this->setAbsDirSoft(Quaternion(Vector(x,y,z), Vector(0,1,0)), bias);
461}
462
463
464/**
[6048]465 * @brief shift Direction
[5091]466 * @param shift the direction around which to shift.
467 */
[3802]468void PNode::shiftDir (const Quaternion& shift)
469{
[4993]470  this->relDirection = this->relDirection * shift;
[3802]471  this->bRelDirChanged = true;
472}
[3365]473
[6048]474
[3683]475/**
[6048]476 * @brief adds a child and makes this node to a parent
[5091]477 * @param child child reference
[4993]478 * use this to add a child to this node.
[5420]479 */
[5382]480void PNode::addChild (PNode* child)
[3365]481{
[4993]482  if( likely(child->parent != NULL))
[6078]483      child->parent->eraseChild(child);
[6075]484  if (this->checkIntegrity(child))
485  {
486    child->parent = this;
487    if (unlikely(this != NULL))
488      this->children.push_back(child);
489    child->parentCoorChanged();
[6695]490
491//     if(this->getUniqueID() == NET_UID_UNASSIGNED)
492//     {
493//       PRINTF(1)("Adding to an UNASSIGNED PNode - looking for next assigned Node\n");
494//       PNode* node = this->seekNextAssignedPNode(this);
495//       if( node == NULL)
496//         PRINTF(1)("    Got NULL - Is this the NULLParent - uid %i\n", this->getUniqueID());
497//       else
498//         PRINTF(1)("    Found next assigned node: %i\n", node->getUniqueID());
499//     }
[6075]500  }
501  else
502  {
503    PRINTF(1)("Tried to reparent to own child '%s::%s' to '%s::%s'.\n",
504              this->getClassName(), this->getName(), child->getClassName(), child->getName());
505    child->parent = NULL;
[6142]506    child->parentCoorChanged();
[6075]507  }
[3365]508}
509
[6048]510
[6695]511PNode* PNode::seekNextAssignedPNode(PNode* node) const
512{
513  PNode* tmpNode = node->parent;
514  printf("entering seek PNode loop for name: %s, uid: %i\n", node->getName(), node->getUniqueID());
515  if(tmpNode)
516    printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
517  while( tmpNode != NULL && tmpNode->getUniqueID() == NET_UID_UNASSIGNED)
518  {
519    printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
520    tmpNode = tmpNode->parent;
521  }
522  printf("leaving PNode loop\n\n");
523
524  return tmpNode;
525}
526
527
[3365]528/**
[5091]529 * @see PNode::addChild(PNode* child);
[4765]530 * @param childName the name of the child to add to this PNode
531 */
532void PNode::addChild (const char* childName)
533{
534  PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
[6634]535//  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
536//  assert( childNode != NULL );
[4765]537  if (childNode != NULL)
[6634]538  {
[4765]539    this->addChild(childNode);
[6634]540  }
[4765]541}
542
[6048]543
[4765]544/**
[6048]545 * @brief removes a child from the node
[5091]546 * @param child the child to remove from this pNode.
[4993]547 *
[6054]548 * Children from pNode will not be lost, they are Reparented by the rules of the ParentMode
[5420]549 */
[4993]550void PNode::removeChild (PNode* child)
[3365]551{
[5214]552  if (child != NULL)
[5769]553   child->removeNode();
[3365]554}
555
[6054]556
[3365]557/**
[6075]558 * !! PRIVATE FUNCTION
[6299]559 * @brief reparents a node (happens on Parents Node delete or remove and Flags are set.)
[6075]560 */
561void PNode::reparent()
562{
[6078]563  if (this->parentMode & PNODE_REPARENT_TO_NULL)
564    this->setParent((PNode*)NULL);
[6075]565  else if (this->parentMode & PNODE_REPARENT_TO_PARENTS_PARENT && this->parent != NULL)
566    this->setParent(this->parent->getParent());
[6078]567  else
568    this->setParent(PNode::getNullParent());
[6075]569}
570
[6299]571/**
572 * ereases child from the nodes children
573 * @param chuld the child to remove
574 */
[6078]575void PNode::eraseChild(PNode* child)
576{
577  std::list<PNode*>::iterator childRemover = std::find(this->children.begin(), this->children.end(), child);
578  if(childRemover != this->children.end())
579    this->children.erase(childRemover);
580}
[6075]581
[6078]582
[6075]583/**
[6048]584 * @brief remove this pnode from the tree and adds all following to NullParent
[5420]585 *
586 * this can be the case, if an entity in the world is being destroyed.
587 */
[5769]588void PNode::removeNode()
[3537]589{
[6078]590  list<PNode*>::iterator child = this->children.begin();
591  list<PNode*>::iterator reparenter;
592  while (child != this->children.end())
[6054]593  {
[6078]594    reparenter = child;
595    child++;
596    if (this->parentMode & PNODE_REPARENT_CHILDREN_ON_REMOVE ||
597        (*reparenter)->parentMode & PNODE_REPARENT_ON_PARENTS_REMOVE)
[6142]598    {
599      printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName());
[6054]600      (*reparenter)->reparent();
[6078]601      printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassName(),(*reparenter)->getParent()->getName());
[6054]602    }
603  }
[5214]604  if (this->parent != NULL)
[6142]605  {
[6078]606    this->parent->eraseChild(this);
[6142]607    this->parent = NULL;
608  }
[3537]609}
610
[3365]611
[4761]612/**
613 * @see PNode::setParent(PNode* parent);
614 * @param parentName the name of the Parent to set to this PNode
615 */
616void PNode::setParent (const char* parentName)
617{
618  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
619  if (parentNode != NULL)
620    parentNode->addChild(this);
[6075]621  else
622    PRINTF(2)("Not Found PNode's (%s::%s) new Parent by Name: %s\n",
623              this->getClassName(), this->getName(), parentName);
[4761]624}
625
[6054]626
[4990]627/**
[6048]628 * @brief does the reparenting in a very smooth way
[4990]629 * @param parentNode the new Node to connect this node to.
[4993]630 * @param bias the speed to iterate to this new Positions
[4990]631 */
[5382]632void PNode::setParentSoft(PNode* parentNode, float bias)
[4987]633{
[5382]634  // return if the new parent and the old one match
[6075]635  if (this->parent == parentNode )
[4992]636    return;
[6075]637  if (parentNode == NULL)
638    parentNode = PNode::getNullParent();
[4992]639
[5382]640  // store the Valures to iterate to.
[4993]641  if (likely(this->toCoordinate == NULL))
[4989]642  {
[4993]643    this->toCoordinate = new Vector();
644    *this->toCoordinate = this->getRelCoor();
[4989]645  }
[4990]646  if (likely(this->toDirection == NULL))
647  {
648    this->toDirection = new Quaternion();
649    *this->toDirection = this->getRelDir();
650  }
[4992]651  this->bias = bias;
[6616]652  this->toStep = 0.0f;
[4987]653
[4990]654  Vector tmpV = this->getAbsCoor();
655  Quaternion tmpQ = this->getAbsDir();
[4987]656
657  parentNode->addChild(this);
658
[5382]659 if (this->parentMode & PNODE_ROTATE_MOVEMENT && this->parent != NULL)
660   this->relCoordinate = this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor());
[5000]661 else
[5382]662   this->relCoordinate = tmpV - parentNode->getAbsCoor();
[4991]663
[5382]664 this->relDirection = tmpQ / parentNode->getAbsDir();
[4987]665}
666
[6054]667
[4993]668/**
[6048]669 * @brief does the reparenting in a very smooth way
[4993]670 * @param parentName the name of the Parent to reconnect to
671 * @param bias the speed to iterate to this new Positions
672 */
[5382]673void PNode::setParentSoft(const char* parentName, float bias)
[4987]674{
675  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
676  if (parentNode != NULL)
[5382]677    this->setParentSoft(parentNode, bias);
[4987]678}
679
[6054]680/**
681 * @param parentMode sets the parentingMode of this Node
682 */
683void PNode::setParentMode(PARENT_MODE parentMode)
684{
[6307]685  this->parentMode = ((this->parentMode & 0xfff0) | parentMode);
[6054]686}
[6048]687
[3365]688/**
[6048]689 * @brief sets the mode of this parent manually
[4765]690 * @param parentMode a String representing this parentingMode
691 */
692void PNode::setParentMode (const char* parentingMode)
693{
[4993]694  this->setParentMode(PNode::charToParentingMode(parentingMode));
[4765]695}
[3537]696
[3365]697/**
[6075]698 * @brief adds special mode Flags to this PNode
699 * @see PARENT_MODE
700 * @param nodeFlags a compsition of PARENT_MODE-flags, split by the '|' (or) operator.
[6054]701 */
[6078]702void PNode::addNodeFlags(unsigned short nodeFlags)
[6054]703{
704  this->parentMode |= nodeFlags;
705}
706
[6075]707/**
708 * @brief removes special mode Flags to this PNode
709 * @see PARENT_MODE
710 * @param nodeFlags a compsition of PARENT_MODE-flags, split by the '|' (or) operator.
711 */
[6078]712void PNode::removeNodeFlags(unsigned short nodeFlags)
[6054]713{
714  this->parentMode &= !nodeFlags;
715}
716
[6078]717/**
718 * @returns the NullParent (and if needed creates it)
719 */
720PNode* PNode::createNullParent()
721{
722  if (likely(PNode::nullParent == NULL))
723  {
724    PNode::nullParent = new PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL);
[6695]725    PNode::nullParent->setClassID(CL_NULL_PARENT, "NullParent");
[6078]726    PNode::nullParent->setName("NullParent");
[6695]727    PNode::nullParent->setSynchronized(true);
[6078]728  }
729  return PNode::nullParent;
730}
[6054]731
[6078]732
[6054]733/**
[6075]734 * !! PRIVATE FUNCTION
735 * @brief checks the upward integrity (e.g if PNode is somewhere up the Node tree.)
736 * @param checkParent the Parent to check.
737 * @returns true if the integrity-check succeeds, false otherwise.
738 *
739 * If there is a second occurence of checkParent before NULL, then a loop could get
740 * into the Tree, and we do not want this.
741 */
742bool PNode::checkIntegrity(const PNode* checkParent) const
743{
744  const PNode* parent = this;
745  while ( (parent = parent->getParent()) != NULL)
746    if (unlikely(parent == checkParent))
747      return false;
748  return true;
749}
750
751
752/**
[6048]753 * @brief updates the absCoordinate/absDirection
[4836]754 * @param dt The time passed since the last update
[5420]755 *
756 * this is used to go through the parent-tree to update all the absolute coordinates
757 * and directions. this update should be done by the engine, so you don't have to
758 * worry, normaly...
759 */
[5769]760void PNode::updateNode (float dt)
[3365]761{
[6075]762  if (!(this->parentMode & PNODE_STATIC_NODE))
763  {
764    if( likely(this->parent != NULL))
[4440]765    {
[6054]766        // movement for nodes with smoothMove enabled
767        if (unlikely(this->toCoordinate != NULL))
[4987]768        {
[6054]769          Vector moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;
770          if (likely(moveVect.len() >= PNODE_ITERATION_DELTA))
771          {
772            this->shiftCoor(moveVect);
773          }
774          else
775          {
776            delete this->toCoordinate;
777            this->toCoordinate = NULL;
778            PRINTF(5)("SmoothMove of %s finished\n", this->getName());
779          }
[4987]780        }
[6054]781        if (unlikely(this->toDirection != NULL))
[4987]782        {
[6616]783          this->toStep += fabs(dt) * bias;
[6624]784          //printf("%s::%s %f\n", this->getClassName(), this->getName(), this->toStep );
[6616]785          Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, toStep);
[6054]786          if (this->relDirection.distance(rotQuat) >PNODE_ITERATION_DELTA)
787          {
788            this->relDirection = rotQuat;
789            this->bRelDirChanged;
790          }
791          else
792          {
793            delete this->toDirection;
794            this->toDirection = NULL;
[6075]795            PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
[6054]796          }
[4987]797        }
[4990]798
[6054]799        // MAIN UPDATE /////////////////////////////////////
800        this->lastAbsCoordinate = this->absCoordinate;
[4145]801
[6075]802        PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClassName(), this->getName(),
803                      this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
[3800]804
[4570]805
[6307]806        if(this->bRelDirChanged && this->parentMode & PNODE_LOCAL_ROTATE )
[6054]807        {
808          /* update the current absDirection - remember * means rotation around sth.*/
809          this->prevRelCoordinate = this->relCoordinate;
[6253]810          this->absDirection = parent->getAbsDir() * this->relDirection;
[6054]811        }
[4570]812
[6307]813        if(likely(this->bRelCoorChanged && this->parentMode & PNODE_MOVEMENT))
[6054]814        {
[6075]815        /* update the current absCoordinate */
[6307]816          this->prevRelCoordinate = this->relCoordinate;
817          this->absCoordinate = this->parent->getAbsCoor() + this->relCoordinate;
[6054]818        }
819        else if( this->parentMode & PNODE_ROTATE_MOVEMENT && this->bRelCoorChanged)
820        {
821          /* update the current absCoordinate */
[6307]822          this->prevRelCoordinate = this->relCoordinate;
823          this->absCoordinate = this->parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);
[6054]824        }
825        /////////////////////////////////////////////////
[5007]826      }
[6075]827
828  else // Nodes without a Parent are handled faster :: MOST LIKELY THE NULLPARENT
[4440]829    {
[6075]830      PRINTF(4)("update ParentLess Node (%s::%s) - (%f, %f, %f)\n", this->getClassName(), this->getName(),
831                this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
[6054]832        if (this->bRelCoorChanged)
833        {
834          this->prevRelCoordinate = this->relCoordinate;
835          this->absCoordinate = this->relCoordinate;
836        }
837        if (this->bRelDirChanged)
838        {
839          this->prevRelDirection = this->relDirection;
840          this->absDirection = this->getAbsDir () * this->relDirection;
841        }
[5118]842      }
[4993]843    }
[3365]844
[6054]845    if(!this->children.empty() && (this->bActive || this->parentMode & PNODE_UPDATE_CHILDREN_IF_INACTIVE ))
[4993]846    {
[5770]847      list<PNode*>::iterator child;
848      for (child = this->children.begin(); child != this->children.end(); child ++)
[4574]849      {
850        /* if this node has changed, make sure, that all children are updated also */
[4993]851        if( likely(this->bRelCoorChanged))
[5770]852          (*child)->parentCoorChanged ();
[4993]853        if( likely(this->bRelDirChanged))
[5770]854          (*child)->parentDirChanged ();
[4993]855
[5770]856        (*child)->updateNode(dt);
[4993]857      }
[4440]858    }
[4993]859    this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
860    this->bRelCoorChanged = false;
861    this->bRelDirChanged = false;
[3365]862}
863
[5769]864
[6075]865
866
867
868/*************
869 * DEBUGGING *
870 *************/
[6048]871/**
872 * @brief counts total amount the children walking through the entire tree.
873 * @param nodes the counter
874 */
[5769]875void PNode::countChildNodes(int& nodes) const
876{
877  nodes++;
[5770]878  list<PNode*>::const_iterator child;
879  for (child = this->children.begin(); child != this->children.end(); child ++)
880    (*child)->countChildNodes(nodes);
[5769]881}
882
883
[3450]884/**
[6048]885 * @brief displays some information about this pNode
[4836]886 * @param depth The deph into which to debug the children of this PNode to.
[5383]887 * (0: all children will be debugged, 1: only this PNode, 2: this and direct children, ...)
888 * @param level !! INTERNAL !! The n-th level of the Node we draw (this is internal and only for nice output).
[5420]889 */
[5769]890void PNode::debugNode(unsigned int depth, unsigned int level) const
[3365]891{
[4574]892  for (unsigned int i = 0; i < level; i++)
[4575]893    PRINT(0)(" |");
[5770]894  if (this->children.size() > 0)
[4575]895    PRINT(0)(" +");
896  else
897    PRINT(0)(" -");
[5769]898
899  int childNodeCount = 0;
900  this->countChildNodes(childNodeCount);
901
902  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 - %d childs\n",
[4574]903           this->getClassName(),
904           this->getName(),
905           this->absCoordinate.x,
906           this->absCoordinate.y,
907           this->absCoordinate.z,
908           this->relCoordinate.x,
909           this->relCoordinate.y,
[4993]910           this->relCoordinate.z,
[4996]911           this->getAbsDirV().x,
912           this->getAbsDirV().y,
913           this->getAbsDirV().z,
[5769]914           this->parentingModeToChar(parentMode),
915           childNodeCount);
[4574]916  if (depth >= 2 || depth == 0)
917  {
[5770]918    list<PNode*>::const_iterator child;
919    for (child = this->children.begin(); child != this->children.end(); child ++)
[4574]920    {
921      if (depth == 0)
[5770]922        (*child)->debugNode(0, level + 1);
[4574]923      else
[5770]924        (*child)->debugNode(depth - 1, level +1);
[4574]925    }
926  }
[3365]927}
928
[4570]929/**
[6048]930 * @brief displays the PNode at its position with its rotation as a cube.
[5383]931 * @param  depth The deph into which to debug the children of this PNode to.
932 * (0: all children will be displayed, 1: only this PNode, 2: this and direct children, ...)
933 * @param size the Size of the Box to draw.
934 * @param color the color of the Box to display.
935 * @param level !! INTERNAL !! The n-th level of the Node we draw (this is internal and only for nice output).
936 */
937void PNode::debugDraw(unsigned int depth, float size, const Vector& color, unsigned int level) const
[4570]938{
[5432]939  // if this is the first Element we draw
[5383]940  if (level == 0)
941  {
[5432]942    glPushAttrib(GL_ENABLE_BIT); // save the Enable-attributes
943    glMatrixMode(GL_MODELVIEW);  // goto the ModelView Matrix
[5383]944
[5432]945    glDisable(GL_LIGHTING);      // disable lighting (we do not need them for just lighting)
946    glDisable(GL_BLEND);         // ''
947    glDisable(GL_TEXTURE_2D);    // ''
[5438]948    glDisable(GL_DEPTH_TEST);    // ''
[5383]949  }
950
[5432]951  glPushMatrix();                // repush the Matrix-stack
[4570]952  /* translate */
953  glTranslatef (this->getAbsCoor ().x,
954                this->getAbsCoor ().y,
955                this->getAbsCoor ().z);
[4998]956//  this->getAbsDir ().matrix (matrix);
957
[5432]958  /* rotate */
[4998]959  Vector tmpRot = this->getAbsDir().getSpacialAxis();
[5432]960  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
961  /* set the new Color */
[5008]962  glColor3f(color.x, color.y, color.z);
[5432]963  { /* draw a cube of size size */
[4570]964    glBegin(GL_LINE_STRIP);
[4995]965    glVertex3f(-.5*size, -.5*size,  -.5*size);
966    glVertex3f(+.5*size, -.5*size,  -.5*size);
967    glVertex3f(+.5*size, -.5*size,  +.5*size);
968    glVertex3f(-.5*size, -.5*size,  +.5*size);
969    glVertex3f(-.5*size, -.5*size,  -.5*size);
[4570]970    glEnd();
971    glBegin(GL_LINE_STRIP);
[4995]972    glVertex3f(-.5*size, +.5*size,  -.5*size);
973    glVertex3f(+.5*size, +.5*size,  -.5*size);
974    glVertex3f(+.5*size, +.5*size,  +.5*size);
975    glVertex3f(-.5*size, +.5*size,  +.5*size);
976    glVertex3f(-.5*size, +.5*size,  -.5*size);
[4570]977    glEnd();
[4995]978
[4570]979    glBegin(GL_LINES);
[4995]980    glVertex3f(-.5*size, -.5*size,  -.5*size);
981    glVertex3f(-.5*size, +.5*size,  -.5*size);
982    glVertex3f(+.5*size, -.5*size,  -.5*size);
983    glVertex3f(+.5*size, +.5*size,  -.5*size);
984    glVertex3f(+.5*size, -.5*size,  +.5*size);
985    glVertex3f(+.5*size, +.5*size,  +.5*size);
986    glVertex3f(-.5*size, -.5*size,  +.5*size);
987    glVertex3f(-.5*size, +.5*size,  +.5*size);
[4570]988    glEnd();
989  }
990
991  glPopMatrix();
[5007]992  if (depth >= 2 || depth == 0)
993  {
[5432]994    /* rotate the current color in HSV space around 20 degree */
[5115]995    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
[5770]996    list<PNode*>::const_iterator child;
997    for (child = this->children.begin(); child != this->children.end(); child ++)
[5007]998    {
[5394]999      // drawing the Dependency graph
[6074]1000     if (this != PNode::getNullParent())
[5394]1001      {
1002       glBegin(GL_LINES);
1003       glColor3f(color.x, color.y, color.z);
1004       glVertex3f(this->getAbsCoor ().x,
1005                  this->getAbsCoor ().y,
1006                  this->getAbsCoor ().z);
1007        glColor3f(childColor.x, childColor.y, childColor.z);
[5770]1008        glVertex3f((*child)->getAbsCoor ().x,
1009                   (*child)->getAbsCoor ().y,
1010                   (*child)->getAbsCoor ().z);
[5394]1011        glEnd();
1012      }
[5915]1013
[5432]1014      /* if we want to draw the children too */
1015      if (depth == 0) /* -> all of them */
[5770]1016        (*child)->debugDraw(0, size, childColor, level+1);
[5432]1017      else            /* -> only the Next one */
[5770]1018        (*child)->debugDraw(depth - 1, size, childColor, level +1);
[5007]1019    }
1020  }
[5383]1021  if (level == 0)
[5432]1022    glPopAttrib(); /* pop the saved attributes back out */
[4570]1023}
[4993]1024
1025
1026
1027/////////////////////
1028// HELPER_FUCTIONS //
1029/////////////////////
1030
1031/**
[6048]1032 * @brief converts a parentingMode into a string that is the name of it
[4993]1033 * @param parentingMode the ParentingMode to convert
1034 * @return the converted string
1035 */
1036const char* PNode::parentingModeToChar(int parentingMode)
1037{
1038  if (parentingMode == PNODE_LOCAL_ROTATE)
1039    return "local-rotate";
1040  else if (parentingMode == PNODE_ROTATE_MOVEMENT)
1041    return "rotate-movement";
1042  else if (parentingMode == PNODE_MOVEMENT)
1043    return "movement";
1044  else if (parentingMode == PNODE_ALL)
1045    return "all";
1046  else if (parentingMode == PNODE_ROTATE_AND_MOVE)
1047    return "rotate-and-move";
1048}
1049
1050/**
[6048]1051 * @brief converts a parenting-mode-string into a int
[4993]1052 * @param parentingMode the string naming the parentingMode
1053 * @return the int corresponding to the named parentingMode
1054 */
1055PARENT_MODE PNode::charToParentingMode(const char* parentingMode)
1056{
1057  if (!strcmp(parentingMode, "local-rotate"))
1058    return (PNODE_LOCAL_ROTATE);
1059  else  if (!strcmp(parentingMode, "rotate-movement"))
1060    return (PNODE_ROTATE_MOVEMENT);
1061  else  if (!strcmp(parentingMode, "movement"))
1062    return (PNODE_MOVEMENT);
1063  else  if (!strcmp(parentingMode, "all"))
1064    return (PNODE_ALL);
1065  else  if (!strcmp(parentingMode, "rotate-and-move"))
1066    return (PNODE_ROTATE_AND_MOVE);
1067}
[6341]1068
1069/**
1070 * Writes data from network containing information about the state
1071 * @param data pointer to data
1072 * @param length length of data
1073 * @param sender hostID of sender
1074 */
1075int PNode::writeState( const byte * data, int length, int sender )
1076{
1077  SYNCHELP_READ_BEGIN();
1078
1079  SYNCHELP_READ_FKT( BaseObject::writeState );
1080
[6695]1081//   char * parentName = NULL;
1082//   SYNCHELP_READ_STRINGM( parentName );
1083//
1084//   if ( strcmp(parentName, "")==0 )
1085//   {
1086//     setParent( (char*)NULL );
1087//   }
1088//   else
1089//   {
1090//     setParent( parentName );
1091//   }
1092//
1093//  delete[] parentName;
[6341]1094
1095  int parentMode;
1096  SYNCHELP_READ_INT( parentMode );
1097  this->setParentMode((PARENT_MODE)parentMode);
1098
1099  float f1, f2, f3, f4;
1100
1101  SYNCHELP_READ_FLOAT( f1 );
1102  SYNCHELP_READ_FLOAT( f2 );
1103  SYNCHELP_READ_FLOAT( f3 );
1104  this->setRelCoor( f1, f2, f3 );
1105
1106
1107  SYNCHELP_READ_FLOAT( f1 );
1108  SYNCHELP_READ_FLOAT( f2 );
1109  SYNCHELP_READ_FLOAT( f3 );
1110  SYNCHELP_READ_FLOAT( f4 );
1111  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
1112
[6695]1113//   int n;
1114//   char * childName;
1115//
1116//   PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
1117//   SYNCHELP_READ_INT( n );
1118//   PRINTF(0)("read %s:n=%d\n", this->getName(), n);
1119//
1120//   for (int i = 0; i<n; i++)
1121//   {
1122//     SYNCHELP_READ_STRINGM( childName );
1123//     PRINTF(0)("RCVD CHILD = %s\n", childName);
1124//     addChild( childName );
1125//     delete childName;
1126//     childName = NULL;
1127//   }
[6341]1128
1129  return SYNCHELP_READ_N;
1130}
1131
1132/**
1133 * data copied in data will bee sent to another host
1134 * @param data pointer to data
1135 * @param maxLength max length of data
1136 * @return the number of bytes writen
1137 */
1138int PNode::readState( byte * data, int maxLength )
1139{
1140  SYNCHELP_WRITE_BEGIN();
1141
1142  SYNCHELP_WRITE_FKT( BaseObject::readState );
1143
[6695]1144//   if ( this->parent )
1145//   {
1146//     SYNCHELP_WRITE_STRING( parent->getName() );
1147//   }
1148//   else
1149//   {
1150//     SYNCHELP_WRITE_STRING( "" );
1151//   }
[6341]1152
1153  SYNCHELP_WRITE_INT( this->parentMode );
1154
1155  SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
1156  SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
1157  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
1158
1159  SYNCHELP_WRITE_FLOAT( this->relDirection.w );
1160  SYNCHELP_WRITE_FLOAT( this->relDirection.v.x );
1161  SYNCHELP_WRITE_FLOAT( this->relDirection.v.y );
1162  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
1163
[6695]1164//   int n = children.size();
1165//   //check if camera is in children
1166//   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
1167//   {
1168//     if ( (*it)->isA(CL_CAMERA) )
1169//       n--;
1170//   }
1171//   PRINTF(0)("write %s:n=%d\n", this->getName(), n);
1172//   SYNCHELP_WRITE_INT( n );
1173//   PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
1174//
1175//
1176//   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
1177//   {
1178//     //dont add camera because there is only one camera attached to local player
1179//     if ( !(*it)->isA(CL_CAMERA) )
1180//     {
1181//       PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
1182//       SYNCHELP_WRITE_STRING( (*it)->getName() );
1183//     }
1184//   }
[6341]1185
1186  return SYNCHELP_WRITE_N;
1187}
[6634]1188
1189#define __FLAG_COOR 1
1190#define __FLAG_ROT  2
1191
1192#define __OFFSET_POS 1
1193#define __OFFSET_ROT 0.05
1194
1195/**
1196 * Writes data from network containing information about the state which has changed
1197 * @param data pointer to data
1198 * @param length length of data
1199 * @param sender hostID of sender
1200 */
1201int PNode::writeSync( const byte * data, int length, int sender )
1202{
1203  SYNCHELP_READ_BEGIN();
1204
1205  if ( this->getHostID()==this->getOwner() )
1206  {
1207    return SYNCHELP_READ_N;
1208  }
1209
1210  byte flags = 0;
1211  SYNCHELP_READ_BYTE( flags );
1212  //PRINTF(0)("%s::FLAGS = %d\n", this->getName(), flags);
1213
1214  float f1, f2, f3, f4;
1215
1216  if ( flags & __FLAG_COOR )
1217  {
1218    SYNCHELP_READ_FLOAT( f1 );
1219    SYNCHELP_READ_FLOAT( f2 );
1220    SYNCHELP_READ_FLOAT( f3 );
1221    PRINTF(0)("RCVD COOR: %f %f %f\n", f1, f2, f3);
1222    this->setRelCoor( f1, f2, f3 );
1223  }
1224
1225  if ( flags & __FLAG_ROT )
1226  {
1227    SYNCHELP_READ_FLOAT( f1 );
1228    SYNCHELP_READ_FLOAT( f2 );
1229    SYNCHELP_READ_FLOAT( f3 );
1230    SYNCHELP_READ_FLOAT( f4 );
1231    PRINTF(0)("RCVD QUAT: %f %f %f %f\n", f1, f2, f3, f4);
1232    //this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
1233    Quaternion q;
1234    q.w = f1;
1235    q.v.x = f2;
1236    q.v.y = f3;
1237    q.v.z = f4;
1238    this->setAbsDir( q );
1239  }
1240
1241  return SYNCHELP_READ_N;
1242}
1243
1244/**
1245 * data copied in data will bee sent to another host
1246 * @param data pointer to data
1247 * @param maxLength max length of data
1248 * @return the number of bytes writen
1249 */
1250int PNode::readSync( byte * data, int maxLength )
1251{
1252  SYNCHELP_WRITE_BEGIN();
1253
1254  if ( this->getHostID()!=this->getOwner() )
1255  {
1256    return SYNCHELP_WRITE_N;
1257  }
1258
1259  byte flags = 0;
1260  if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS ||
1261       fabs( coory - relCoordinate.y ) > __OFFSET_POS ||
1262       fabs( coorz - relCoordinate.z ) > __OFFSET_POS )
1263    flags |= __FLAG_COOR;
1264
1265  if ( fabs( rotw - absDirection.w ) > __OFFSET_ROT ||
1266       fabs( rotx - absDirection.v.x ) > __OFFSET_ROT ||
1267       fabs( roty - absDirection.v.y ) > __OFFSET_ROT ||
1268       fabs( rotz - absDirection.v.z ) > __OFFSET_ROT )
1269    flags |= __FLAG_ROT;
1270
1271
1272  SYNCHELP_WRITE_BYTE( flags );
1273  //PRINTF(0)("FLAGS = %d\n", flags);
1274
1275  if ( flags & __FLAG_COOR )
1276  {
1277
1278    PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z);
1279
1280    SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
1281    SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
1282    SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
1283
1284    coorx = relCoordinate.x;
1285    coory = relCoordinate.y;
1286    coorz = relCoordinate.z;
1287  }
1288
1289  if ( flags & __FLAG_ROT )
1290  {
1291
1292    PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z);
1293
1294    SYNCHELP_WRITE_FLOAT( this->absDirection.w );
1295    SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
1296    SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
1297    SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );
1298
1299    rotw = absDirection.w;
1300    rotx = absDirection.v.x;
1301    roty = absDirection.v.y;
1302    rotz = absDirection.v.z;
1303  }
1304
1305  return SYNCHELP_WRITE_N;
1306}
Note: See TracBrowser for help on using the repository browser.