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 | |
---|
26 | using namespace std; |
---|
27 | |
---|
28 | NullParent* NullParent::singletonRef = 0; |
---|
29 | |
---|
30 | NullParent* 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 | */ |
---|
42 | NullParent::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 | |
---|
51 | NullParent::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 | */ |
---|
66 | NullParent::~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 | */ |
---|
79 | void NullParent::update (float dt) |
---|
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 | tIterator<PNode>* iterator = this->children->getIterator(); |
---|
87 | //PNode* pn = this->children->enumerate (); |
---|
88 | PNode* pn = iterator->nextElement(); |
---|
89 | while( pn != NULL) |
---|
90 | { |
---|
91 | /* if this node has changed, make sure, that all children are updated also */ |
---|
92 | if( this->bRelCoorChanged || this->bAbsCoorChanged) |
---|
93 | pn->parentCoorChanged (); |
---|
94 | if( this->bRelDirChanged || this->bAbsDirChanged) |
---|
95 | pn->parentDirChanged (); |
---|
96 | pn->update (dt); |
---|
97 | //pn = this->children->nextElement (); |
---|
98 | pn = iterator->nextElement(); |
---|
99 | } |
---|
100 | |
---|
101 | this->timeStamp = timeStamp; |
---|
102 | this->bRelCoorChanged = false; |
---|
103 | this->bAbsCoorChanged = false; |
---|
104 | this->bRelDirChanged = false; |
---|
105 | this->bAbsDirChanged = false; |
---|
106 | } |
---|