[3246] | 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 "p_node.h" |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | using namespace std; |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | \brief standard constructor |
---|
| 27 | |
---|
| 28 | \todo this constructor is not jet implemented - do it |
---|
| 29 | */ |
---|
[3248] | 30 | PNode::PNode () |
---|
| 31 | { |
---|
| 32 | this->children = new tList<PNode>(); |
---|
| 33 | } |
---|
[3246] | 34 | |
---|
| 35 | |
---|
| 36 | /** |
---|
| 37 | \brief standard deconstructor |
---|
| 38 | |
---|
| 39 | \todo this deconstructor is not jet implemented - do it |
---|
| 40 | */ |
---|
[3248] | 41 | PNode::~PNode () |
---|
| 42 | { |
---|
| 43 | this->children->destroy(); |
---|
| 44 | delete this->children; |
---|
| 45 | } |
---|
[3246] | 46 | |
---|
[3247] | 47 | |
---|
| 48 | /** |
---|
| 49 | \brief get relative coordinates |
---|
| 50 | \returns relative coordinates to its parent |
---|
| 51 | */ |
---|
| 52 | Vector PNode::getRelCoor () |
---|
[3248] | 53 | { |
---|
| 54 | Vector r = this->relCoordinate; /* return a copy, so it can't be modified */ |
---|
| 55 | return r; |
---|
| 56 | } |
---|
[3247] | 57 | |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | \brief set relative coordinates |
---|
| 61 | \param relative coordinates to its parent |
---|
| 62 | |
---|
| 63 | it is very importand, that you use this function, if you want to update the |
---|
| 64 | relCoordinates. If you don't use this, the PNode won't recognize, that something |
---|
| 65 | has changed and won't update the children Nodes. |
---|
| 66 | */ |
---|
| 67 | void PNode::setRelCoor (Vector relCoord) |
---|
| 68 | {} |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | \brief get absolute coordinates |
---|
| 73 | \returns absolute coordinates from (0,0,0) |
---|
| 74 | */ |
---|
| 75 | Vector PNode::getAbsCoor () |
---|
| 76 | {} |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /** |
---|
| 80 | \brief get relative coordinates |
---|
| 81 | \returns relative coordinates to its parent |
---|
| 82 | |
---|
| 83 | it is very importand, that you use this function, if you want to update the |
---|
| 84 | absCoordinates. If you don't use this, the PNode won't recognize, that something |
---|
| 85 | has changed and won't update the children Nodes. |
---|
| 86 | */ |
---|
| 87 | void PNode::setAbsCoor (Vector absCoord) |
---|
| 88 | {} |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | /** |
---|
[3248] | 92 | \brief shift coordinate (abs and rel) |
---|
| 93 | \param shift vector |
---|
| 94 | |
---|
| 95 | this function shifts the current coordinates about the vector shift. this is |
---|
| 96 | usefull because from some place else you can: |
---|
| 97 | PNode* someNode = ...; |
---|
| 98 | Vector objectMovement = calculateShift(); |
---|
| 99 | someNode->shiftCoor(objectMovement); |
---|
| 100 | |
---|
| 101 | elsewhere you would have to: |
---|
| 102 | PNode* someNode = ...; |
---|
| 103 | Vector objectMovement = calculateShift(); |
---|
| 104 | Vector currentCoor = someNode->getRelCoor(); |
---|
| 105 | Vector newCoor = currentCoor + objectMovement; |
---|
| 106 | someNode->setRelCoor(newCoor); |
---|
| 107 | |
---|
| 108 | yea right... shorter... |
---|
| 109 | |
---|
| 110 | */ |
---|
| 111 | void PNode::shiftCoor (Vector shift) |
---|
| 112 | {} |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | /** |
---|
[3247] | 117 | \brief get relative direction |
---|
| 118 | \returns relative direction to its parent |
---|
| 119 | */ |
---|
| 120 | Quaternion PNode::getRelDir () |
---|
| 121 | {} |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | /** |
---|
| 125 | \brief set relative direction |
---|
| 126 | \param relative direction to its parent |
---|
| 127 | |
---|
| 128 | it is very importand, that you use this function, if you want to update the |
---|
| 129 | relDirection. If you don't use this, the PNode won't recognize, that something |
---|
| 130 | has changed and won't update the children Nodes. |
---|
| 131 | */ |
---|
| 132 | void PNode::setRelDir (Quaternion relDir) |
---|
| 133 | {} |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | \brief gets the absolute direction (0,0,1) |
---|
| 138 | \returns absolute coordinates |
---|
| 139 | */ |
---|
| 140 | Quaternion PNode::getAbsDir () |
---|
| 141 | {} |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | /** |
---|
| 145 | \brief sets the absolute direction (0,0,1) |
---|
| 146 | \param absolute coordinates |
---|
| 147 | |
---|
| 148 | it is very importand, that you use this function, if you want to update the |
---|
| 149 | absDirection. If you don't use this, the PNode won't recognize, that something |
---|
| 150 | has changed and won't update the children Nodes. |
---|
| 151 | */ |
---|
| 152 | void PNode::setAbsDir (Quaternion absDir) |
---|
| 153 | {} |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | /** |
---|
[3248] | 157 | \brief shift coordinate (abs and rel) |
---|
| 158 | \param shift vector |
---|
| 159 | |
---|
| 160 | this function shifts the current coordinates about the vector shift. this is |
---|
| 161 | usefull because from some place else you can: |
---|
| 162 | PNode* someNode = ...; |
---|
| 163 | Quaternion objectMovement = calculateShift(); |
---|
| 164 | someNode->shiftCoor(objectMovement); |
---|
| 165 | |
---|
| 166 | elsewhere you would have to: |
---|
| 167 | PNode* someNode = ...; |
---|
| 168 | Quaternion objectMovement = calculateShift(); |
---|
| 169 | Quaternion currentCoor = someNode->getRelCoor(); |
---|
| 170 | Quaternion newCoor = currentCoor + objectMovement; |
---|
| 171 | someNode->setRelCoor(newCoor); |
---|
| 172 | |
---|
| 173 | yea right... shorter... |
---|
| 174 | |
---|
| 175 | */ |
---|
| 176 | void PNode::shiftDir (Quaternion shift) |
---|
| 177 | {} |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | /** |
---|
[3247] | 182 | \brief adds a child and makes this node to a parent |
---|
| 183 | \param child reference |
---|
| 184 | |
---|
| 185 | use this to add a child to this node. |
---|
| 186 | */ |
---|
| 187 | void PNode::addChild (PNode* pNode) |
---|
[3248] | 188 | { |
---|
| 189 | this->addChild(pNode, DEFAULT_MODE); |
---|
| 190 | } |
---|
[3247] | 191 | |
---|
| 192 | |
---|
[3248] | 193 | /** |
---|
| 194 | \brief adds a child and makes this node to a parent |
---|
| 195 | \param child reference |
---|
| 196 | \param on which changes the child should also change ist state |
---|
| 197 | |
---|
| 198 | use this to add a child to this node. |
---|
| 199 | */ |
---|
| 200 | void PNode::addChild (PNode* pNode, parentingMode mode) |
---|
| 201 | { |
---|
| 202 | pNode->mode = mode; |
---|
| 203 | this->children->add (pNode); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | /** |
---|
| 208 | /brief removes a child from the node |
---|
| 209 | */ |
---|
[3247] | 210 | void PNode::removeChild (PNode* pNode) |
---|
[3248] | 211 | { |
---|
| 212 | this->children->remove (pNode); |
---|
| 213 | } |
---|
[3247] | 214 | |
---|
| 215 | |
---|
[3248] | 216 | /** |
---|
| 217 | \brief sets the parent of this PNode |
---|
| 218 | */ |
---|
[3247] | 219 | void PNode::setParent (PNode* parent) |
---|
[3248] | 220 | { |
---|
| 221 | this->parent = parent; |
---|
| 222 | } |
---|
[3247] | 223 | |
---|
[3248] | 224 | |
---|
| 225 | /** |
---|
| 226 | \brief updates the absCoordinate/absDirection |
---|
| 227 | |
---|
| 228 | this is used to go through the parent-tree to update all the absolute coordinates |
---|
| 229 | and directions. this update should be done by the engine, so you don't have to |
---|
| 230 | worry, normaly... |
---|
| 231 | */ |
---|
| 232 | void PNode::update() |
---|
| 233 | { |
---|
| 234 | |
---|
| 235 | } |
---|
| 236 | |
---|