Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/parenting/src/null_parent.cc @ 3347

Last change on this file since 3347 was 3311, checked in by patrick, 20 years ago

oroxnox/branches/parenting: implemented helperParent and made some tests with the opengl nurbs lib

File size: 2.0 KB
Line 
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
19#include "null_parent.h"
20
21
22using namespace std;
23
24NullParent* NullParent::singletonRef = 0;
25
26NullParent* NullParent::getInstance ()
27{
28  if( singletonRef == NULL)
29    singletonRef = new NullParent ();
30  return singletonRef;
31}
32
33/**
34   \brief standard constructor
35
36   \todo this constructor is not jet implemented - do it
37*/
38NullParent::NullParent () 
39{
40  this->parent = this;
41  this->mode = ALL;
42}
43
44
45NullParent::NullParent (Vector* absCoordinate)
46{
47  this->parent = this;
48  this->mode = ALL;
49  this->absCoordinate = *absCoordinate;
50}
51
52
53/**
54   \brief standard deconstructor
55
56   \todo this deconstructor is not jet implemented - do it
57*/
58NullParent::~NullParent () 
59{
60  delete singletonRef;
61  singletonRef = NULL;
62}
63
64
65
66
67/**
68   \brief updates the absCoordinate/absDirection
69
70   this is used to go through the parent-tree to update all the absolute coordinates
71   and directions. this update should be done by the engine, so you don't have to
72   worry, normaly...
73*/
74void NullParent::update (float timeStamp)
75{
76  this->absCoordinate = this->relCoordinate;
77  this->absDirection = parent->getAbsDir () * this->relDirection;
78 
79  PNode* pn = this->children->enumerate ();
80  while( pn != NULL) 
81    { 
82      /* if this node has changed, make sure, that all children are updated also */
83      if( this->bRelCoorChanged || this->bAbsCoorChanged)
84        pn->parentCoorChanged ();
85      if( this->bRelDirChanged || this->bAbsDirChanged)
86        pn->parentDirChanged ();
87      pn->update (timeStamp);
88      pn = this->children->nextElement ();
89    }
90
91  this->timeStamp = timeStamp;
92  this->bRelCoorChanged = false;
93  this->bAbsCoorChanged = false;
94  this->bRelDirChanged = false;
95  this->bAbsDirChanged = false;
96}
Note: See TracBrowser for help on using the repository browser.