Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3542 was 3533, checked in by bensch, 20 years ago

orxonox/trunk: added some more files to the new destructor-type

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