Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/coord/null_parent.cc @ 3595

Last change on this file since 3595 was 3591, checked in by bensch, 20 years ago

orxonox/trunk: debug.h some cleanup

File size: 2.4 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: ...
16*/
17
18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_NULL_PARENT
19
20#include "null_parent.h"
21
22
23using namespace std;
24
25NullParent* NullParent::singletonRef = 0;
26
27NullParent* NullParent::getInstance ()
28{
29  if(!singletonRef)
30    singletonRef = new NullParent ();
31  return singletonRef;
32}
33
34/**
35   \brief standard constructor
36
37   \todo this constructor is not jet implemented - do it
38*/
39NullParent::NullParent () : PNode (new Vector(0,0,0), NULL)
40{
41  PRINTF(4)("NullParent::NullParent() - making new NullParent, there can only be one..\n");
42  this->parent = this;
43  this->mode = PNODE_ALL;
44  this->setName("NullParent");
45}
46
47
48NullParent::NullParent (Vector* absCoordinate) : PNode (new Vector(0,0,0), NULL)
49{
50  singletonRef = this;
51  this->parent = this;
52  this->mode = PNODE_ALL;
53  this->absCoordinate = *absCoordinate;
54  this->setName("NullParent");
55}
56
57
58/**
59   \brief standard deconstructor
60
61   \todo this deconstructor is not jet implemented - do it
62*/
63NullParent::~NullParent () 
64{
65  //delete singletonRef;
66  singletonRef = NULL;
67}
68
69/**
70   \brief updates the absCoordinate/absDirection
71
72   this is used to go through the parent-tree to update all the absolute coordinates
73   and directions. this update should be done by the engine, so you don't have to
74   worry, normaly...
75*/
76void NullParent::update ()
77{
78
79  PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
80  this->absCoordinate = this->relCoordinate;
81  this->absDirection = parent->getAbsDir () * this->relDirection;
82 
83  PNode* pn = this->children->enumerate ();
84  while( pn != NULL) 
85    { 
86      /* if this node has changed, make sure, that all children are updated also */
87      if( this->bRelCoorChanged || this->bAbsCoorChanged)
88        pn->parentCoorChanged ();
89      if( this->bRelDirChanged || this->bAbsDirChanged)
90        pn->parentDirChanged ();
91      pn->update ();
92      pn = this->children->nextElement ();
93    }
94
95  this->timeStamp = timeStamp;
96  this->bRelCoorChanged = false;
97  this->bAbsCoorChanged = false;
98  this->bRelDirChanged = false;
99  this->bAbsDirChanged = false;
100}
Note: See TracBrowser for help on using the repository browser.