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