Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the network-branche back to the trunk

merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r6500:HEAD
minor conflicts in texture and one Makefile resolved to the trunk

also made a small patch to texture, so it Modulates with GL_REPEAT

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