- Timestamp:
- Nov 6, 2007, 1:40:00 AM (17 years ago)
- Location:
- code/branches/objecthierarchie/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchie/src/BaseObject.h
r162 r172 15 15 inline bool isA(Identifier* identifier) 16 16 { this->getIdentifier()->isA(identifier); } 17 inline bool isDirect A(Identifier* identifier)18 { this->getIdentifier()->isDirect A(identifier); }17 inline bool isDirectlyA(Identifier* identifier) 18 { this->getIdentifier()->isDirectlyA(identifier); } 19 19 inline bool isChildOf(Identifier* identifier) 20 20 { this->getIdentifier()->isChildOf(identifier); } -
code/branches/objecthierarchie/src/ClassHierarchy.cc
r162 r172 1 1 #include "ClassHierarchy.h" 2 #include "OrxonoxClass.h" 2 3 3 4 namespace orxonox … … 27 28 this->allChildren_ = new IdentifierList(); 28 29 this->objects_ = new ObjectList(); 30 } 31 32 Identifier::~Identifier() 33 { 34 delete this->directParents_; 35 delete this->allParents_; 36 delete this->directChildren_; 37 delete this->allChildren_; 38 delete this->objects_; 39 delete &this->name_; 29 40 } 30 41 … … 94 105 } 95 106 96 bool Identifier::isDirect A(Identifier* identifier)107 bool Identifier::isDirectlyA(Identifier* identifier) 97 108 { 98 109 return (identifier == this); … … 190 201 } 191 202 203 std::string IdentifierList::toString() 204 { 205 IdentifierListElement* temp = this->first_; 206 std::string output = ""; 207 208 while (temp) 209 { 210 output += temp->identifier_->getName(); 211 output += " "; 212 213 temp = temp->next_; 214 } 215 216 return output; 217 } 218 192 219 193 220 // ############################### … … 199 226 this->next_ = NULL; 200 227 this->bDirect_ = true; 228 } 229 230 IdentifierListElement::~IdentifierListElement() 231 { 201 232 } 202 233 … … 268 299 } 269 300 301 ObjectListElement::~ObjectListElement() 302 { 303 } 304 270 305 271 306 // ############################### … … 284 319 ClassHierarchy::ClassHierarchy() 285 320 { 286 this->bCreatingHierarchy_ = false; 321 this->hierarchyCreatingCounter_ = 0; 322 } 323 324 ClassHierarchy::~ClassHierarchy() 325 { 326 this->pointer_ = NULL; 287 327 } 288 328 } -
code/branches/objecthierarchie/src/ClassHierarchy.h
r162 r172 4 4 #include <string> 5 5 #include <iostream> 6 7 // DONE: 6 #include <assert.h> 7 8 // DONE AND TESTED: 8 9 // - klassenhierarchie aufbauen 10 // - isA u.a. vergleiche 9 11 // - in listen einfügen 12 13 // IN WORK: 10 14 // - factory 11 15 // - klassen-identifier 12 // - isA u.ä. vergleiche 13 14 // TODO: 16 17 // TO DO: 15 18 // - durch listen iterieren 16 19 // - searchtree für classname-strings … … 20 23 { 21 24 // ##### ClassHierarchy ##### 25 template <class T> 26 class ClassIdentifier; 27 22 28 class ClassHierarchy 23 29 { 30 template <class T> 31 friend class ClassIdentifier; 32 24 33 public: 25 34 static ClassHierarchy* getSingleton(); 26 bool isCreatingHierarchy() { return this->bCreatingHierarchy_; } 27 void createHierarchy(bool bCreatingHierarchy) { this->bCreatingHierarchy_ = bCreatingHierarchy; std::cout << "*** Switched Hierarchy-Creating-Mode to" << bCreatingHierarchy << "\n"; } 35 bool isCreatingHierarchy() { return (this->hierarchyCreatingCounter_ > 0); } 28 36 29 37 private: 30 38 ClassHierarchy(); 39 ~ClassHierarchy(); 40 void startCreatingHierarchy() { this->hierarchyCreatingCounter_++; std::cout << "*** Increased Hierarchy-Creating-Counter to " << this->hierarchyCreatingCounter_ << "\n"; } 41 void stopCreatingHierarchy() { this->hierarchyCreatingCounter_--; std::cout << "*** Decreased Hierarchy-Creating-Counter to " << this->hierarchyCreatingCounter_ << "\n"; } 31 42 32 43 static ClassHierarchy* pointer_; 33 bool bCreatingHierarchy_;44 int hierarchyCreatingCounter_; 34 45 }; 35 46 … … 38 49 class ObjectList; 39 50 class OrxonoxClass; 40 template <class T>41 class ClassIdentifier;42 51 43 52 class Identifier … … 46 55 friend class ClassIdentifier; 47 56 48 public: 57 template <class T> 58 friend class BaseIdentifier; 59 60 public: 61 Identifier(Identifier* identifier) {}; 62 ~Identifier(); 49 63 void addObject(OrxonoxClass* object); 50 64 void removeObject(OrxonoxClass* object); 51 65 52 66 bool isA(Identifier* identifier); 53 bool isDirect A(Identifier* identifier);67 bool isDirectlyA(Identifier* identifier); 54 68 bool isChildOf(Identifier* identifier); 55 69 bool isDirectChildOf(Identifier* identifier); … … 57 71 bool isDirectParentOf(Identifier* identifier); 58 72 73 std::string getName() { return this->name_; } 74 IdentifierList* getDirectParents() { return this->directParents_; } 75 IdentifierList* getAllParents() { return this->allParents_; } 76 IdentifierList* getDirectChildren() { return this->directChildren_; } 77 IdentifierList* getAllChildren() { return this->allChildren_; } 78 59 79 private: 60 80 Identifier(); … … 72 92 }; 73 93 94 95 // ##### ClassIdentifier ##### 96 class A1; 97 74 98 template <class T> 75 99 class ClassIdentifier : public Identifier … … 82 106 private: 83 107 ClassIdentifier(); 108 ~ClassIdentifier(); 84 109 85 110 static ClassIdentifier<T>* pointer_; … … 93 118 ClassIdentifier<T>::ClassIdentifier() 94 119 { 120 } 121 122 template <class T> 123 ClassIdentifier<T>::~ClassIdentifier() 124 { 125 this->pointer_ = NULL; 95 126 } 96 127 … … 120 151 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 121 152 { 122 std::cout << "*** Get Identifier.\n";153 // std::cout << "*** Get Identifier.\n"; 123 154 if (!pointer_) 124 155 { 125 156 std::cout << "*** Get Identifier -> Create Class\n"; 126 ClassHierarchy::getSingleton()-> createHierarchy(true);157 ClassHierarchy::getSingleton()->startCreatingHierarchy(); 127 158 T* temp = new T(); 128 ClassHierarchy::getSingleton()-> createHierarchy(false);159 ClassHierarchy::getSingleton()->stopCreatingHierarchy(); 129 160 delete temp; 130 161 } … … 138 169 return new T(); 139 170 } 171 140 172 141 173 // ##### Identifier List ##### … … 150 182 void remove(Identifier* identifier); 151 183 bool isInList(Identifier* identifier); 184 std::string toString(); 152 185 153 186 IdentifierListElement* first_; … … 158 191 public: 159 192 IdentifierListElement(Identifier* identifier); 193 ~IdentifierListElement(); 160 194 161 195 Identifier* identifier_; … … 183 217 public: 184 218 ObjectListElement(OrxonoxClass* object); 219 ~ObjectListElement(); 185 220 186 221 OrxonoxClass* object_; -
code/branches/objecthierarchie/src/orxonox.cc
r162 r172 61 61 #endif 62 62 63 namespace orxonox 64 { 65 class OrxExitListener : public Ogre::FrameListener 66 { 67 public: 68 OrxExitListener(OIS::Keyboard *keyboard) 69 : mKeyboard(keyboard) 70 { 71 } 72 73 bool frameStarted(const Ogre::FrameEvent& evt) 74 { 75 mKeyboard->capture(); 76 return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); 77 } 78 79 private: 80 OIS::Keyboard *mKeyboard; 81 }; 82 83 class OrxApplication 84 { 85 public: 86 void go() 87 { 88 /* 89 createRoot(); 90 defineResources(); 91 setupRenderSystem(); 92 createRenderWindow(); 93 initializeResourceGroups(); 94 setupScene(); 95 setupInputSystem(); 96 setupCEGUI(); 97 createFrameListener(); 98 startRenderLoop(); 99 */ 100 /* 101 std::cout << "Test 1\n"; 102 BaseObject* test1; 103 test1 = new BaseObject(); 104 test1 = new BaseObject(); 105 test1 = new BaseObject(); 106 107 std::cout << "Test 2\n"; 108 A1* test2; 109 test2 = new A1(); 110 test2 = new A1(); 111 test2 = new A1(); 112 113 std::cout << "Test 3\n"; 114 BaseObject* test3; 115 test3 = new BaseObject(); 116 test3 = new BaseObject(); 117 test3 = new BaseObject(); 118 119 std::cout << "Test 4\n"; 120 A3* test4; 121 test4 = new A3(); 122 test4 = new A3(); 123 test4 = new A3(); 124 */ 125 /* 126 std::cout << "Test 5\n"; 127 A1* test5_01 = new A1(); 128 A2* test5_02 = new A2(); 129 A3* test5_03 = new A3(); 130 A1B1* test5_04 = new A1B1(); 131 A1B2* test5_05 = new A1B2(); 132 A2B1* test5_06 = new A2B1(); 133 A2B2* test5_07 = new A2B2(); 134 A3B1* test5_08 = new A3B1(); 135 A3B2* test5_09 = new A3B2(); 136 A1B1C1* test5_10 = new A1B1C1(); 137 A1B1C2* test5_11 = new A1B1C2(); 138 A1B2C1* test5_12 = new A1B2C1(); 139 A2B1C1* test5_13 = new A2B1C1(); 140 A2B2C1* test5_14 = new A2B2C1(); 141 A3B1C1* test5_15 = new A3B1C1(); 142 A3B1C2* test5_16 = new A3B1C2(); 143 A3B2C1* test5_17 = new A3B2C1(); 144 A3B2C2* test5_18 = new A3B2C2(); 145 146 OrxonoxClass* test5; 147 for (int i = 0; i <= 18; i++) 148 { 149 if (i == 0) test5 = test1; 150 if (i == 1) test5 = test5_01; 151 if (i == 2) test5 = test5_02; 152 if (i == 3) test5 = test5_03; 153 if (i == 4) test5 = test5_04; 154 if (i == 5) test5 = test5_05; 155 if (i == 6) test5 = test5_06; 156 if (i == 7) test5 = test5_07; 157 if (i == 8) test5 = test5_08; 158 if (i == 9) test5 = test5_09; 159 if (i == 10) test5 = test5_10; 160 if (i == 11) test5 = test5_11; 161 if (i == 12) test5 = test5_12; 162 if (i == 13) test5 = test5_13; 163 if (i == 14) test5 = test5_14; 164 if (i == 15) test5 = test5_15; 165 if (i == 16) test5 = test5_16; 166 if (i == 17) test5 = test5_17; 167 if (i == 18) test5 = test5_18; 168 169 std::cout << "\n"; 170 std::cout << test5->getIdentifier()->getName() << ": directParents: " << test5->getIdentifier()->getDirectParents()->toString() << "\n"; 171 std::cout << test5->getIdentifier()->getName() << ": allParents: " << test5->getIdentifier()->getAllParents()->toString() << "\n"; 172 std::cout << test5->getIdentifier()->getName() << ": directChildren: " << test5->getIdentifier()->getDirectChildren()->toString() << "\n"; 173 std::cout << test5->getIdentifier()->getName() << ": allChildren: " << test5->getIdentifier()->getAllChildren()->toString() << "\n"; 174 } 175 */ 176 /* 177 #define testandcout(code) \ 178 std::cout << #code << " " << code << "\n" 179 180 181 std::cout << "\n"; 182 std::cout << "isA(XYZ)-Test:\n"; 183 std::cout << "test5_01 = A1, Erwartet: 1 0 0 1 0\n"; 184 testandcout(test5_01->isA(Class(A1))); 185 testandcout(test5_01->isA(Class(A2))); 186 testandcout(test5_01->isA(Class(A1B1))); 187 testandcout(test5_01->isA(Class(BaseObject))); 188 testandcout(test5_01->isA(Class(Interface1))); 189 190 std::cout << "\n"; 191 std::cout << "test5_02 = A2, Erwartet: 0 1 0 1 0\n"; 192 testandcout(test5_02->isA(Class(A1))); 193 testandcout(test5_02->isA(Class(A2))); 194 testandcout(test5_02->isA(Class(A1B1))); 195 testandcout(test5_02->isA(Class(BaseObject))); 196 testandcout(test5_02->isA(Class(Interface1))); 197 198 std::cout << "\n"; 199 std::cout << "test5_01 = A3, Erwartet: 0 0 0 1 1\n"; 200 testandcout(test5_03->isA(Class(A1))); 201 testandcout(test5_03->isA(Class(A2))); 202 testandcout(test5_03->isA(Class(A1B1))); 203 testandcout(test5_03->isA(Class(BaseObject))); 204 testandcout(test5_03->isA(Class(Interface1))); 205 206 207 std::cout << "\n"; 208 std::cout << "isDirectA(XYZ)-Test:\n"; 209 std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n"; 210 testandcout(test5_01->isDirectlyA(Class(A1))); 211 testandcout(test5_01->isDirectlyA(Class(A2))); 212 testandcout(test5_01->isDirectlyA(Class(A1B1))); 213 testandcout(test5_01->isDirectlyA(Class(BaseObject))); 214 testandcout(test5_01->isDirectlyA(Class(Interface1))); 215 216 std::cout << "\n"; 217 std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n"; 218 testandcout(test5_02->isDirectlyA(Class(A1))); 219 testandcout(test5_02->isDirectlyA(Class(A2))); 220 testandcout(test5_02->isDirectlyA(Class(A1B1))); 221 testandcout(test5_02->isDirectlyA(Class(BaseObject))); 222 testandcout(test5_02->isDirectlyA(Class(Interface1))); 223 224 std::cout << "\n"; 225 std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n"; 226 testandcout(test5_03->isDirectlyA(Class(A1))); 227 testandcout(test5_03->isDirectlyA(Class(A2))); 228 testandcout(test5_03->isDirectlyA(Class(A1B1))); 229 testandcout(test5_03->isDirectlyA(Class(BaseObject))); 230 testandcout(test5_03->isDirectlyA(Class(Interface1))); 231 232 std::cout << "\n"; 233 std::cout << "isChildOf(XYZ)-Test:\n"; 234 std::cout << "test5_04 = A1B1, Erwartet: 1 0 1 0 0 0 0\n"; 235 testandcout(test5_04->isChildOf(Class(A1))); 236 testandcout(test5_04->isChildOf(Class(A2))); 237 testandcout(test5_04->isChildOf(Class(BaseObject))); 238 testandcout(test5_04->isChildOf(Class(Interface1))); 239 testandcout(test5_04->isChildOf(Class(Interface2))); 240 testandcout(test5_04->isChildOf(Class(A1B1C2))); 241 testandcout(test5_04->isChildOf(Class(A1B1))); 242 243 std::cout << "\n"; 244 std::cout << "test5_06 = A2B1, Erwartet: 0 1 1 0 0 0 0\n"; 245 testandcout(test5_06->isChildOf(Class(A1))); 246 testandcout(test5_06->isChildOf(Class(A2))); 247 testandcout(test5_06->isChildOf(Class(BaseObject))); 248 testandcout(test5_06->isChildOf(Class(Interface1))); 249 testandcout(test5_06->isChildOf(Class(Interface2))); 250 testandcout(test5_06->isChildOf(Class(A1B1C2))); 251 testandcout(test5_06->isChildOf(Class(A1B1))); 252 253 std::cout << "\n"; 254 std::cout << "test5_07 = A2B2, Erwartet: 0 1 1 1 0 0\n"; 255 testandcout(test5_07->isChildOf(Class(A1))); 256 testandcout(test5_07->isChildOf(Class(A2))); 257 testandcout(test5_07->isChildOf(Class(BaseObject))); 258 testandcout(test5_07->isChildOf(Class(Interface1))); 259 testandcout(test5_07->isChildOf(Class(Interface2))); 260 testandcout(test5_07->isChildOf(Class(A1B1C2))); 261 262 std::cout << "\n"; 263 std::cout << "test5_08 = A3B1, Erwartet: 0 0 1 1 0 0\n"; 264 testandcout(test5_08->isChildOf(Class(A1))); 265 testandcout(test5_08->isChildOf(Class(A2))); 266 testandcout(test5_08->isChildOf(Class(BaseObject))); 267 testandcout(test5_08->isChildOf(Class(Interface1))); 268 testandcout(test5_08->isChildOf(Class(Interface2))); 269 testandcout(test5_08->isChildOf(Class(A1B1C2))); 270 271 std::cout << "\n"; 272 std::cout << "test5_09 = A3B2, Erwartet: 0 0 1 1 1 0\n"; 273 testandcout(test5_09->isChildOf(Class(A1))); 274 testandcout(test5_09->isChildOf(Class(A2))); 275 testandcout(test5_09->isChildOf(Class(BaseObject))); 276 testandcout(test5_09->isChildOf(Class(Interface1))); 277 testandcout(test5_09->isChildOf(Class(Interface2))); 278 testandcout(test5_09->isChildOf(Class(A1B1C2))); 279 280 std::cout << "\n"; 281 std::cout << "isDirectChildOf(XYZ)-Test:\n"; 282 std::cout << "test5_04 = A1B1, Erwartet: 1 0 0 0 0 0 0\n"; 283 testandcout(test5_04->isDirectChildOf(Class(A1))); 284 testandcout(test5_04->isDirectChildOf(Class(A2))); 285 testandcout(test5_04->isDirectChildOf(Class(BaseObject))); 286 testandcout(test5_04->isDirectChildOf(Class(Interface1))); 287 testandcout(test5_04->isDirectChildOf(Class(Interface2))); 288 testandcout(test5_04->isDirectChildOf(Class(A1B1C2))); 289 testandcout(test5_04->isDirectChildOf(Class(A1B1))); 290 291 std::cout << "\n"; 292 std::cout << "test5_06 = A2B1, Erwartet: 0 1 0 0 0 0 0\n"; 293 testandcout(test5_06->isDirectChildOf(Class(A1))); 294 testandcout(test5_06->isDirectChildOf(Class(A2))); 295 testandcout(test5_06->isDirectChildOf(Class(BaseObject))); 296 testandcout(test5_06->isDirectChildOf(Class(Interface1))); 297 testandcout(test5_06->isDirectChildOf(Class(Interface2))); 298 testandcout(test5_06->isDirectChildOf(Class(A1B1C2))); 299 testandcout(test5_06->isDirectChildOf(Class(A1B1))); 300 301 std::cout << "\n"; 302 std::cout << "test5_07 = A2B2, Erwartet: 0 1 0 1 0 0\n"; 303 testandcout(test5_07->isDirectChildOf(Class(A1))); 304 testandcout(test5_07->isDirectChildOf(Class(A2))); 305 testandcout(test5_07->isDirectChildOf(Class(BaseObject))); 306 testandcout(test5_07->isDirectChildOf(Class(Interface1))); 307 testandcout(test5_07->isDirectChildOf(Class(Interface2))); 308 testandcout(test5_07->isDirectChildOf(Class(A1B1C2))); 309 310 std::cout << "\n"; 311 std::cout << "test5_08 = A3B1, Erwartet: 0 0 0 0 0 0\n"; 312 testandcout(test5_08->isDirectChildOf(Class(A1))); 313 testandcout(test5_08->isDirectChildOf(Class(A2))); 314 testandcout(test5_08->isDirectChildOf(Class(BaseObject))); 315 testandcout(test5_08->isDirectChildOf(Class(Interface1))); 316 testandcout(test5_08->isDirectChildOf(Class(Interface2))); 317 testandcout(test5_08->isDirectChildOf(Class(A1B1C2))); 318 319 std::cout << "\n"; 320 std::cout << "test5_09 = A3B2, Erwartet: 0 0 0 0 1 0\n"; 321 testandcout(test5_09->isDirectChildOf(Class(A1))); 322 testandcout(test5_09->isDirectChildOf(Class(A2))); 323 testandcout(test5_09->isDirectChildOf(Class(BaseObject))); 324 testandcout(test5_09->isDirectChildOf(Class(Interface1))); 325 testandcout(test5_09->isDirectChildOf(Class(Interface2))); 326 testandcout(test5_09->isDirectChildOf(Class(A1B1C2))); 327 328 std::cout << "\n"; 329 std::cout << "isParentOf(XYZ)-Test:\n"; 330 std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n"; 331 testandcout(test1->isParentOf(Class(BaseObject))); 332 testandcout(test1->isParentOf(Class(Interface1))); 333 testandcout(test1->isParentOf(Class(A1))); 334 testandcout(test1->isParentOf(Class(A2))); 335 testandcout(test1->isParentOf(Class(A1B1))); 336 testandcout(test1->isParentOf(Class(A2B2))); 337 testandcout(test1->isParentOf(Class(A3B1C2))); 338 339 std::cout << "\n"; 340 std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n"; 341 testandcout(test5_01->isParentOf(Class(BaseObject))); 342 testandcout(test5_01->isParentOf(Class(Interface1))); 343 testandcout(test5_01->isParentOf(Class(A1))); 344 testandcout(test5_01->isParentOf(Class(A2))); 345 testandcout(test5_01->isParentOf(Class(A1B1))); 346 testandcout(test5_01->isParentOf(Class(A2B2))); 347 testandcout(test5_01->isParentOf(Class(A3B1C2))); 348 349 std::cout << "\n"; 350 std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 1\n"; 351 testandcout(Class(Interface1)->isParentOf(Class(BaseObject))); 352 testandcout(Class(Interface1)->isParentOf(Class(Interface1))); 353 testandcout(Class(Interface1)->isParentOf(Class(A1))); 354 testandcout(Class(Interface1)->isParentOf(Class(A2))); 355 testandcout(Class(Interface1)->isParentOf(Class(A1B1))); 356 testandcout(Class(Interface1)->isParentOf(Class(A2B2))); 357 testandcout(Class(Interface1)->isParentOf(Class(A3B1C2))); 358 359 std::cout << "\n"; 360 std::cout << "isDirectParentOf(XYZ)-Test:\n"; 361 std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 0 0 0\n"; 362 testandcout(test1->isDirectParentOf(Class(BaseObject))); 363 testandcout(test1->isDirectParentOf(Class(Interface1))); 364 testandcout(test1->isDirectParentOf(Class(A1))); 365 testandcout(test1->isDirectParentOf(Class(A2))); 366 testandcout(test1->isDirectParentOf(Class(A1B1))); 367 testandcout(test1->isDirectParentOf(Class(A2B2))); 368 testandcout(test1->isDirectParentOf(Class(A3B1C2))); 369 370 std::cout << "\n"; 371 std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n"; 372 testandcout(test5_01->isDirectParentOf(Class(BaseObject))); 373 testandcout(test5_01->isDirectParentOf(Class(Interface1))); 374 testandcout(test5_01->isDirectParentOf(Class(A1))); 375 testandcout(test5_01->isDirectParentOf(Class(A2))); 376 testandcout(test5_01->isDirectParentOf(Class(A1B1))); 377 testandcout(test5_01->isDirectParentOf(Class(A2B2))); 378 testandcout(test5_01->isDirectParentOf(Class(A3B1C2))); 379 380 std::cout << "\n"; 381 std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 0\n"; 382 testandcout(Class(Interface1)->isDirectParentOf(Class(BaseObject))); 383 testandcout(Class(Interface1)->isDirectParentOf(Class(Interface1))); 384 testandcout(Class(Interface1)->isDirectParentOf(Class(A1))); 385 testandcout(Class(Interface1)->isDirectParentOf(Class(A2))); 386 testandcout(Class(Interface1)->isDirectParentOf(Class(A1B1))); 387 testandcout(Class(Interface1)->isDirectParentOf(Class(A2B2))); 388 testandcout(Class(Interface1)->isDirectParentOf(Class(A3B1C2))); 389 */ 390 /* 391 std::cout << "Test 6\n"; 392 std::cout << "1:\n"; 393 Identifier* test6_01 = Class(A1B1); 394 std::cout << "2:\n"; 395 Identifier* test6_02 = Class(A1B1); 396 std::cout << "3:\n"; 397 Identifier* test6_03 = Class(A1); 398 std::cout << "4:\n"; 399 Identifier* test6_04 = Class(A1B1C1); 400 std::cout << "5:\n"; 401 Identifier* test6_05 = Class(A1B1); 402 std::cout << "6:\n"; 403 Identifier* test6_06 = Class(A1B1C1); 404 */ 405 /* 406 std::cout << "\n"; 407 std::cout << "BaseObject: directParents: " << Class(BaseObject)->getDirectParents()->toString() << "\n"; 408 std::cout << "BaseObject: allParents: " << Class(BaseObject)->getAllParents()->toString() << "\n"; 409 std::cout << "BaseObject: directChildren: " << Class(BaseObject)->getDirectChildren()->toString() << "\n"; 410 std::cout << "BaseObject: allChildren: " << Class(BaseObject)->getAllChildren()->toString() << "\n"; 411 412 std::cout << "\n"; 413 std::cout << "A1: directParents: " << Class(A1)->getDirectParents()->toString() << "\n"; 414 std::cout << "A1: allParents: " << Class(A1)->getAllParents()->toString() << "\n"; 415 std::cout << "A1: directChildren: " << Class(A1)->getDirectChildren()->toString() << "\n"; 416 std::cout << "A1: allChildren: " << Class(A1)->getAllChildren()->toString() << "\n"; 417 418 std::cout << "\n"; 419 std::cout << "A1B1: directParents: " << Class(A1B1)->getDirectParents()->toString() << "\n"; 420 std::cout << "A1B1: allParents: " << Class(A1B1)->getAllParents()->toString() << "\n"; 421 std::cout << "A1B1: directChildren: " << Class(A1B1)->getDirectChildren()->toString() << "\n"; 422 std::cout << "A1B1: allChildren: " << Class(A1B1)->getAllChildren()->toString() << "\n"; 423 424 std::cout << "\n"; 425 std::cout << "A1B1C1: directParents: " << Class(A1B1C1)->getDirectParents()->toString() << "\n"; 426 std::cout << "A1B1C1: allParents: " << Class(A1B1C1)->getAllParents()->toString() << "\n"; 427 std::cout << "A1B1C1: directChildren: " << Class(A1B1C1)->getDirectChildren()->toString() << "\n"; 428 std::cout << "A1B1C1: allChildren: " << Class(A1B1C1)->getAllChildren()->toString() << "\n"; 429 430 std::cout << "\n"; 431 std::cout << "A3B1C1 child of A3: " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n"; 432 std::cout << "\n"; 433 std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n"; 434 */ 435 436 } 437 438 ~OrxApplication() 439 { 440 mInputManager->destroyInputObject(mKeyboard); 441 OIS::InputManager::destroyInputSystem(mInputManager); 442 443 delete mRenderer; 444 delete mSystem; 445 446 delete mListener; 447 delete mRoot; 448 } 449 450 private: 451 Ogre::Root *mRoot; 452 OIS::Keyboard *mKeyboard; 453 OIS::Mouse *mMouse; 454 OIS::InputManager *mInputManager; 455 CEGUI::OgreCEGUIRenderer *mRenderer; 456 CEGUI::System *mSystem; 457 OrxExitListener *mListener; 458 459 void createRoot() 460 { 461 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 462 mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg"); 463 #else 464 mRoot = new Ogre::Root(); 465 #endif 466 } 467 468 void defineResources() 469 { 470 Ogre::String secName, typeName, archName; 471 Ogre::ConfigFile cf; 472 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 473 cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); 474 #else 475 cf.load("resources.cfg"); 476 #endif 477 478 Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); 479 while (seci.hasMoreElements()) 480 { 481 secName = seci.peekNextKey(); 482 Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); 483 Ogre::ConfigFile::SettingsMultiMap::iterator i; 484 for (i = settings->begin(); i != settings->end(); ++i) 485 { 486 typeName = i->first; 487 archName = i->second; 488 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 489 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); 490 #else 491 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); 492 #endif 493 } 494 } 495 } 496 497 void setupRenderSystem() 498 { 499 if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) 500 throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); 501 } 502 503 void createRenderWindow() 504 { 505 mRoot->initialise(true, "Ogre Render Window"); 506 } 507 508 void initializeResourceGroups() 509 { 510 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); 511 Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 512 } 513 514 void setupScene() 515 { 516 Ogre::SceneManager *mgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager"); 517 Ogre::Camera *cam = mgr->createCamera("Camera"); 518 Ogre::Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam); 519 } 520 521 void setupInputSystem() 522 { 523 size_t windowHnd = 0; 524 std::ostringstream windowHndStr; 525 OIS::ParamList pl; 526 Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); 527 528 win->getCustomAttribute("WINDOW", &windowHnd); 529 windowHndStr << windowHnd; 530 pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 531 mInputManager = OIS::InputManager::createInputSystem(pl); 532 533 try 534 { 535 mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false)); 536 mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false)); 537 } 538 catch (const OIS::Exception &e) 539 { 540 throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem"); 541 } 542 } 543 544 void setupCEGUI() 545 { 546 Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); 547 Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); 548 549 // CEGUI setup 550 mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr); 551 mSystem = new CEGUI::System(mRenderer); 552 553 // Other CEGUI setup here. 554 } 555 556 void createFrameListener() 557 { 558 mListener = new OrxExitListener(mKeyboard); 559 mRoot->addFrameListener(mListener); 560 } 561 562 void startRenderLoop() 563 { 564 mRoot->startRendering(); 565 } 566 }; 567 } 568 63 569 using namespace Ogre; 64 65 class OrxExitListener : public FrameListener66 {67 public:68 OrxExitListener(OIS::Keyboard *keyboard)69 : mKeyboard(keyboard)70 {71 }72 73 bool frameStarted(const FrameEvent& evt)74 {75 mKeyboard->capture();76 return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);77 }78 79 private:80 OIS::Keyboard *mKeyboard;81 };82 83 class OrxApplication84 {85 public:86 void go()87 {88 /* createRoot();89 defineResources();90 setupRenderSystem();91 createRenderWindow();92 initializeResourceGroups();93 setupScene();94 setupInputSystem();95 setupCEGUI();96 createFrameListener();97 startRenderLoop();98 */99 std::cout << "Test 1\n";100 orxonox::BaseObject* test1;101 test1 = new orxonox::BaseObject();102 test1 = new orxonox::BaseObject();103 test1 = new orxonox::BaseObject();104 105 std::cout << "Test 2\n";106 orxonox::A1* test2;107 test2 = new orxonox::A1();108 test2 = new orxonox::A1();109 test2 = new orxonox::A1();110 111 std::cout << "Test 3\n";112 orxonox::BaseObject* test3;113 test3 = new orxonox::BaseObject();114 test3 = new orxonox::BaseObject();115 test3 = new orxonox::BaseObject();116 117 std::cout << "Test 4\n";118 orxonox::A3* test4;119 test4 = new orxonox::A3();120 test4 = new orxonox::A3();121 test4 = new orxonox::A3();122 123 }124 125 ~OrxApplication()126 {127 mInputManager->destroyInputObject(mKeyboard);128 OIS::InputManager::destroyInputSystem(mInputManager);129 130 delete mRenderer;131 delete mSystem;132 133 delete mListener;134 delete mRoot;135 }136 137 private:138 Root *mRoot;139 OIS::Keyboard *mKeyboard;140 OIS::Mouse *mMouse;141 OIS::InputManager *mInputManager;142 CEGUI::OgreCEGUIRenderer *mRenderer;143 CEGUI::System *mSystem;144 OrxExitListener *mListener;145 146 void createRoot()147 {148 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE149 mRoot = new Root(macBundlePath() + "/Contents/Resources/plugins.cfg");150 #else151 mRoot = new Root();152 #endif153 }154 155 void defineResources()156 {157 String secName, typeName, archName;158 ConfigFile cf;159 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE160 cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");161 #else162 cf.load("resources.cfg");163 #endif164 165 ConfigFile::SectionIterator seci = cf.getSectionIterator();166 while (seci.hasMoreElements())167 {168 secName = seci.peekNextKey();169 ConfigFile::SettingsMultiMap *settings = seci.getNext();170 ConfigFile::SettingsMultiMap::iterator i;171 for (i = settings->begin(); i != settings->end(); ++i)172 {173 typeName = i->first;174 archName = i->second;175 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE176 ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName);177 #else178 ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);179 #endif180 }181 }182 }183 184 void setupRenderSystem()185 {186 if (!mRoot->restoreConfig() && !mRoot->showConfigDialog())187 throw Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()");188 }189 190 void createRenderWindow()191 {192 mRoot->initialise(true, "Ogre Render Window");193 }194 195 void initializeResourceGroups()196 {197 TextureManager::getSingleton().setDefaultNumMipmaps(5);198 ResourceGroupManager::getSingleton().initialiseAllResourceGroups();199 }200 201 void setupScene()202 {203 SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");204 Camera *cam = mgr->createCamera("Camera");205 Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);206 }207 208 void setupInputSystem()209 {210 size_t windowHnd = 0;211 std::ostringstream windowHndStr;212 OIS::ParamList pl;213 RenderWindow *win = mRoot->getAutoCreatedWindow();214 215 win->getCustomAttribute("WINDOW", &windowHnd);216 windowHndStr << windowHnd;217 pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));218 mInputManager = OIS::InputManager::createInputSystem(pl);219 220 try221 {222 mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));223 mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false));224 }225 catch (const OIS::Exception &e)226 {227 throw new Exception(42, e.eText, "OrxApplication::setupInputSystem");228 }229 }230 231 void setupCEGUI()232 {233 SceneManager *mgr = mRoot->getSceneManager("Default SceneManager");234 RenderWindow *win = mRoot->getAutoCreatedWindow();235 236 // CEGUI setup237 mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr);238 mSystem = new CEGUI::System(mRenderer);239 240 // Other CEGUI setup here.241 }242 243 void createFrameListener()244 {245 mListener = new OrxExitListener(mKeyboard);246 mRoot->addFrameListener(mListener);247 }248 249 void startRenderLoop()250 {251 mRoot->startRendering();252 }253 };254 570 255 571 #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 … … 264 580 try 265 581 { 266 OrxApplication orxonox;582 orxonox::OrxApplication orxonox; 267 583 orxonox.go(); 268 584 } … … 279 595 return 0; 280 596 } 281
Note: See TracChangeset
for help on using the changeset viewer.