[3276] | 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 | |
---|
[3591] | 18 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_NULL_PARENT |
---|
[3276] | 19 | |
---|
| 20 | #include "null_parent.h" |
---|
[3607] | 21 | #include "stdincl.h" |
---|
[3608] | 22 | #include "vector.h" |
---|
| 23 | #include "list.h" |
---|
[3276] | 24 | |
---|
| 25 | |
---|
| 26 | using namespace std; |
---|
| 27 | |
---|
[3311] | 28 | NullParent* NullParent::singletonRef = 0; |
---|
[3276] | 29 | |
---|
[3311] | 30 | NullParent* NullParent::getInstance () |
---|
| 31 | { |
---|
[3543] | 32 | if(!singletonRef) |
---|
[3311] | 33 | singletonRef = new NullParent (); |
---|
| 34 | return singletonRef; |
---|
| 35 | } |
---|
| 36 | |
---|
[3276] | 37 | /** |
---|
| 38 | \brief standard constructor |
---|
| 39 | |
---|
| 40 | \todo this constructor is not jet implemented - do it |
---|
| 41 | */ |
---|
[3554] | 42 | NullParent::NullParent () : PNode (new Vector(0,0,0), NULL) |
---|
[3276] | 43 | { |
---|
[3591] | 44 | PRINTF(4)("NullParent::NullParent() - making new NullParent, there can only be one..\n"); |
---|
[3276] | 45 | this->parent = this; |
---|
[3565] | 46 | this->mode = PNODE_ALL; |
---|
[3529] | 47 | this->setName("NullParent"); |
---|
[3276] | 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
[3554] | 51 | NullParent::NullParent (Vector* absCoordinate) : PNode (new Vector(0,0,0), NULL) |
---|
[3276] | 52 | { |
---|
[3554] | 53 | singletonRef = this; |
---|
[3276] | 54 | this->parent = this; |
---|
[3565] | 55 | this->mode = PNODE_ALL; |
---|
[3607] | 56 | *this->absCoordinate = *absCoordinate; |
---|
[3529] | 57 | this->setName("NullParent"); |
---|
[3276] | 58 | } |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | \brief standard deconstructor |
---|
| 63 | |
---|
| 64 | \todo this deconstructor is not jet implemented - do it |
---|
| 65 | */ |
---|
[3311] | 66 | NullParent::~NullParent () |
---|
| 67 | { |
---|
[3529] | 68 | //delete singletonRef; |
---|
[3311] | 69 | singletonRef = NULL; |
---|
| 70 | } |
---|
[3276] | 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 | */ |
---|
[3551] | 79 | void NullParent::update () |
---|
[3276] | 80 | { |
---|
[3545] | 81 | |
---|
[3607] | 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; |
---|
[3276] | 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 (); |
---|
[3551] | 94 | pn->update (); |
---|
[3276] | 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 | } |
---|