/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: ... */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_NULL_PARENT #include "null_parent.h" #include "stdincl.h" #include "vector.h" #include "list.h" using namespace std; NullParent* NullParent::singletonRef = 0; NullParent* NullParent::getInstance () { if(!singletonRef) singletonRef = new NullParent (); return singletonRef; } /** \brief standard constructor \todo this constructor is not jet implemented - do it */ NullParent::NullParent () : PNode (Vector(0,0,0), NULL) { PRINTF(4)("NullParent::NullParent() - making new NullParent, there can only be one..\n"); this->parent = this; this->mode = PNODE_ALL; this->setName("NullParent"); } NullParent::NullParent (const Vector& absCoordinate) : PNode (Vector(0,0,0), NULL) { singletonRef = this; this->parent = this; this->mode = PNODE_ALL; this->absCoordinate = absCoordinate; this->setName("NullParent"); } /** \brief standard deconstructor \todo this deconstructor is not jet implemented - do it */ NullParent::~NullParent () { //delete singletonRef; singletonRef = NULL; } /** \brief updates the absCoordinate/absDirection this is used to go through the parent-tree to update all the absolute coordinates and directions. this update should be done by the engine, so you don't have to worry, normaly... */ void NullParent::update (float dt) { PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z); this->absCoordinate = this->relCoordinate; this->absDirection = parent->getAbsDir () * this->relDirection; tIterator* iterator = this->children->getIterator(); //PNode* pn = this->children->enumerate (); PNode* pn = iterator->nextElement(); while( pn != NULL) { /* if this node has changed, make sure, that all children are updated also */ if( this->bRelCoorChanged || this->bAbsCoorChanged) pn->parentCoorChanged (); if( this->bRelDirChanged || this->bAbsDirChanged) pn->parentDirChanged (); pn->update (dt); //pn = this->children->nextElement (); pn = iterator->nextElement(); } this->timeStamp = timeStamp; this->bRelCoorChanged = false; this->bAbsCoorChanged = false; this->bRelDirChanged = false; this->bAbsDirChanged = false; }