/* 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: Benjamin Grauer co-programmer: ... */ #include "track_node.h" #include "null_parent.h" #include "track_manager.h" using namespace std; TrackNode* TrackNode::singletonRef = 0; TrackNode* TrackNode::getInstance () { if (singletonRef == NULL) singletonRef = new TrackNode (); return singletonRef; } /** \brief standard constructor \todo this constructor is not jet implemented - do it */ TrackNode::TrackNode () { this->setParent(NullParent::getInstance()); this->trackManager = TrackManager::getInstance(); this->mode = ALL; } TrackNode::TrackNode (Vector* absCoordinate) { this->parent = NullParent::getInstance(); this->trackManager = TrackManager::getInstance(); this->mode = ALL; this->absCoordinate = *absCoordinate; } /** \brief standard deconstructor \todo this deconstructor is not jet implemented - do it */ TrackNode::~TrackNode () { 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 TrackNode::update (float timeStamp) { this->absCoordinate = trackManager->calcPos(); this->absDirection = Quaternion(trackManager->calcDir(), Vector(0,1,0)); PNode* pn = this->children->enumerate (); 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 (timeStamp); pn = this->children->nextElement (); } this->timeStamp = timeStamp; this->bRelCoorChanged = false; this->bAbsCoorChanged = false; this->bRelDirChanged = false; this->bAbsDirChanged = false; }