Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3619 was 3608, checked in by patrick, 20 years ago

orxonox/trunk: now there is a real speedup in compiling time when dependencies are modified: just realy only includes, what is needed. Byside the speedup, there is more overview! never add an orxonox class to stdincl.h if it doesn't have to be

File size: 2.5 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#include "stdincl.h"
22#include "vector.h"
23#include "list.h"
24
25
26using namespace std;
27
28NullParent* NullParent::singletonRef = 0;
29
30NullParent* NullParent::getInstance ()
31{
32  if(!singletonRef)
33    singletonRef = new NullParent ();
34  return singletonRef;
35}
36
37/**
38   \brief standard constructor
39
40   \todo this constructor is not jet implemented - do it
41*/
42NullParent::NullParent () : PNode (new Vector(0,0,0), NULL)
43{
44  PRINTF(4)("NullParent::NullParent() - making new NullParent, there can only be one..\n");
45  this->parent = this;
46  this->mode = PNODE_ALL;
47  this->setName("NullParent");
48}
49
50
51NullParent::NullParent (Vector* absCoordinate) : PNode (new Vector(0,0,0), NULL)
52{
53  singletonRef = this;
54  this->parent = this;
55  this->mode = PNODE_ALL;
56  *this->absCoordinate = *absCoordinate;
57  this->setName("NullParent");
58}
59
60
61/**
62   \brief standard deconstructor
63
64   \todo this deconstructor is not jet implemented - do it
65*/
66NullParent::~NullParent () 
67{
68  //delete singletonRef;
69  singletonRef = NULL;
70}
71
72/**
73   \brief updates the absCoordinate/absDirection
74
75   this is used to go through the parent-tree to update all the absolute coordinates
76   and directions. this update should be done by the engine, so you don't have to
77   worry, normaly...
78*/
79void NullParent::update ()
80{
81
82  PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
83  *this->absCoordinate = *this->relCoordinate;
84  *this->absDirection = parent->getAbsDir () * *this->relDirection;
85 
86  PNode* pn = this->children->enumerate ();
87  while( pn != NULL) 
88    { 
89      /* if this node has changed, make sure, that all children are updated also */
90      if( this->bRelCoorChanged || this->bAbsCoorChanged)
91        pn->parentCoorChanged ();
92      if( this->bRelDirChanged || this->bAbsDirChanged)
93        pn->parentDirChanged ();
94      pn->update ();
95      pn = this->children->nextElement ();
96    }
97
98  this->timeStamp = timeStamp;
99  this->bRelCoorChanged = false;
100  this->bAbsCoorChanged = false;
101  this->bRelDirChanged = false;
102  this->bAbsDirChanged = false;
103}
Note: See TracBrowser for help on using the repository browser.