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: Benjamin Grauer |
---|
15 | co-programmer: ... |
---|
16 | */ |
---|
17 | |
---|
18 | |
---|
19 | #include "track_node.h" |
---|
20 | |
---|
21 | #include "null_parent.h" |
---|
22 | |
---|
23 | #include "track_manager.h" |
---|
24 | |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | TrackNode* TrackNode::singletonRef = 0; |
---|
28 | |
---|
29 | TrackNode* TrackNode::getInstance () |
---|
30 | { |
---|
31 | if (singletonRef == NULL) |
---|
32 | singletonRef = new TrackNode (); |
---|
33 | return singletonRef; |
---|
34 | } |
---|
35 | |
---|
36 | /** |
---|
37 | \brief standard constructor |
---|
38 | |
---|
39 | \todo this constructor is not jet implemented - do it |
---|
40 | */ |
---|
41 | TrackNode::TrackNode () |
---|
42 | { |
---|
43 | this->setParent(NullParent::getInstance()); |
---|
44 | this->trackManager = TrackManager::getInstance(); |
---|
45 | this->mode = ALL; |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | TrackNode::TrackNode (Vector* absCoordinate) |
---|
50 | { |
---|
51 | this->parent = NullParent::getInstance(); |
---|
52 | this->trackManager = TrackManager::getInstance(); |
---|
53 | this->mode = ALL; |
---|
54 | this->absCoordinate = *absCoordinate; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | /** |
---|
59 | \brief standard deconstructor |
---|
60 | |
---|
61 | \todo this deconstructor is not jet implemented - do it |
---|
62 | */ |
---|
63 | TrackNode::~TrackNode () |
---|
64 | { |
---|
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 TrackNode::update (float timeStamp) |
---|
76 | { |
---|
77 | this->absCoordinate = trackManager->calcPos(); |
---|
78 | this->absDirection = Quaternion(trackManager->calcDir(), Vector(0,1,0)); |
---|
79 | |
---|
80 | PNode* pn = this->children->enumerate (); |
---|
81 | while( pn != NULL) |
---|
82 | { |
---|
83 | /* if this node has changed, make sure, that all children are updated also */ |
---|
84 | if( this->bRelCoorChanged || this->bAbsCoorChanged) |
---|
85 | pn->parentCoorChanged (); |
---|
86 | if( this->bRelDirChanged || this->bAbsDirChanged) |
---|
87 | pn->parentDirChanged (); |
---|
88 | pn->update (timeStamp); |
---|
89 | pn = this->children->nextElement (); |
---|
90 | } |
---|
91 | |
---|
92 | this->timeStamp = timeStamp; |
---|
93 | this->bRelCoorChanged = false; |
---|
94 | this->bAbsCoorChanged = false; |
---|
95 | this->bRelDirChanged = false; |
---|
96 | this->bAbsDirChanged = false; |
---|
97 | } |
---|