| 1 | /* | 
|---|
| 2 | *   ORXONOX - the hottest 3D action shooter ever to exist | 
|---|
| 3 | * | 
|---|
| 4 | * | 
|---|
| 5 | *   License notice: | 
|---|
| 6 | * | 
|---|
| 7 | *   This program is free software: you can redistribute it and/or modify | 
|---|
| 8 | *   it under the terms of the GNU General Public License as published by | 
|---|
| 9 | *   the Free Software Foundation, either version 3 of the License, or | 
|---|
| 10 | *   (at your option) any later version. | 
|---|
| 11 | * | 
|---|
| 12 | *   This program is distributed in the hope that it will be useful, | 
|---|
| 13 | *   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 14 | *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 15 | *   GNU General Public License for more details. | 
|---|
| 16 | * | 
|---|
| 17 | *   You should have received a copy of the GNU General Public License | 
|---|
| 18 | *   along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| 19 | * | 
|---|
| 20 | * | 
|---|
| 21 | *   Author: | 
|---|
| 22 | *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 | 
|---|
| 23 | *   Co-authors: | 
|---|
| 24 | *      ... | 
|---|
| 25 | * | 
|---|
| 26 | */ | 
|---|
| 27 |  | 
|---|
| 28 | #include <Ogre.h> | 
|---|
| 29 | #include <OIS/OIS.h> | 
|---|
| 30 | #include <CEGUI/CEGUI.h> | 
|---|
| 31 | #include <OgreCEGUIRenderer.h> | 
|---|
| 32 |  | 
|---|
| 33 | #include "IdentifierIncludes.h" | 
|---|
| 34 | #include "BaseObject.h" | 
|---|
| 35 | #include "Test.h" | 
|---|
| 36 | #include "test1.h" | 
|---|
| 37 | #include "test2.h" | 
|---|
| 38 | #include "test3.h" | 
|---|
| 39 |  | 
|---|
| 40 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
| 41 | #include <CoreFoundation/CoreFoundation.h> | 
|---|
| 42 |  | 
|---|
| 43 | // This function will locate the path to our application on OS X, | 
|---|
| 44 | // unlike windows you can not rely on the curent working directory | 
|---|
| 45 | // for locating your configuration files and resources. | 
|---|
| 46 | std::string macBundlePath() | 
|---|
| 47 | { | 
|---|
| 48 | char path[1024]; | 
|---|
| 49 | CFBundleRef mainBundle = CFBundleGetMainBundle(); | 
|---|
| 50 | assert(mainBundle); | 
|---|
| 51 |  | 
|---|
| 52 | CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); | 
|---|
| 53 | assert(mainBundleURL); | 
|---|
| 54 |  | 
|---|
| 55 | CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); | 
|---|
| 56 | assert(cfStringRef); | 
|---|
| 57 |  | 
|---|
| 58 | CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); | 
|---|
| 59 |  | 
|---|
| 60 | CFRelease(mainBundleURL); | 
|---|
| 61 | CFRelease(cfStringRef); | 
|---|
| 62 |  | 
|---|
| 63 | return std::string(path); | 
|---|
| 64 | } | 
|---|
| 65 | #endif | 
|---|
| 66 |  | 
|---|
| 67 | namespace orxonox | 
|---|
| 68 | { | 
|---|
| 69 | class OrxExitListener : public Ogre::FrameListener | 
|---|
| 70 | { | 
|---|
| 71 | public: | 
|---|
| 72 | OrxExitListener(OIS::Keyboard *keyboard) | 
|---|
| 73 | : mKeyboard(keyboard) | 
|---|
| 74 | { | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | bool frameStarted(const Ogre::FrameEvent& evt) | 
|---|
| 78 | { | 
|---|
| 79 | mKeyboard->capture(); | 
|---|
| 80 | return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | private: | 
|---|
| 84 | OIS::Keyboard *mKeyboard; | 
|---|
| 85 | }; | 
|---|
| 86 |  | 
|---|
| 87 | class OrxApplication | 
|---|
| 88 | { | 
|---|
| 89 | public: | 
|---|
| 90 | void go() | 
|---|
| 91 | { | 
|---|
| 92 | /* | 
|---|
| 93 | createRoot(); | 
|---|
| 94 | defineResources(); | 
|---|
| 95 | setupRenderSystem(); | 
|---|
| 96 | createRenderWindow(); | 
|---|
| 97 | initializeResourceGroups(); | 
|---|
| 98 | setupScene(); | 
|---|
| 99 | setupInputSystem(); | 
|---|
| 100 | setupCEGUI(); | 
|---|
| 101 | createFrameListener(); | 
|---|
| 102 | startRenderLoop(); | 
|---|
| 103 | */ | 
|---|
| 104 |  | 
|---|
| 105 | #define testandcout(code) \ | 
|---|
| 106 | std::cout << #code << " " << code << "\n" | 
|---|
| 107 |  | 
|---|
| 108 | /* | 
|---|
| 109 | std::cout << "Test 1\n"; | 
|---|
| 110 | BaseObject* test1; | 
|---|
| 111 | test1 = new BaseObject(); | 
|---|
| 112 | test1 = new BaseObject(); | 
|---|
| 113 | test1 = new BaseObject(); | 
|---|
| 114 |  | 
|---|
| 115 | std::cout << "Test 2\n"; | 
|---|
| 116 | A1* test2; | 
|---|
| 117 | test2 = new A1(); | 
|---|
| 118 | test2 = new A1(); | 
|---|
| 119 | test2 = new A1(); | 
|---|
| 120 |  | 
|---|
| 121 | std::cout << "Test 3\n"; | 
|---|
| 122 | BaseObject* test3; | 
|---|
| 123 | test3 = new BaseObject(); | 
|---|
| 124 | test3 = new BaseObject(); | 
|---|
| 125 | test3 = new BaseObject(); | 
|---|
| 126 |  | 
|---|
| 127 | std::cout << "Test 4\n"; | 
|---|
| 128 | A3* test4; | 
|---|
| 129 | test4 = new A3(); | 
|---|
| 130 | test4 = new A3(); | 
|---|
| 131 | test4 = new A3(); | 
|---|
| 132 | */ | 
|---|
| 133 | /* | 
|---|
| 134 | std::cout << "Test 5\n"; | 
|---|
| 135 | A1* test5_01 = new A1(); | 
|---|
| 136 | A2* test5_02 = new A2(); | 
|---|
| 137 | A3* test5_03 = new A3(); | 
|---|
| 138 | A1B1* test5_04 = new A1B1(); | 
|---|
| 139 | A1B2* test5_05 = new A1B2(); | 
|---|
| 140 | A2B1* test5_06 = new A2B1(); | 
|---|
| 141 | A2B2* test5_07 = new A2B2(); | 
|---|
| 142 | A3B1* test5_08 = new A3B1(); | 
|---|
| 143 | A3B2* test5_09 = new A3B2(); | 
|---|
| 144 | A1B1C1* test5_10 = new A1B1C1(); | 
|---|
| 145 | A1B1C2* test5_11 = new A1B1C2(); | 
|---|
| 146 | A1B2C1* test5_12 = new A1B2C1(); | 
|---|
| 147 | A2B1C1* test5_13 = new A2B1C1(); | 
|---|
| 148 | A2B2C1* test5_14 = new A2B2C1(); | 
|---|
| 149 | A3B1C1* test5_15 = new A3B1C1(); | 
|---|
| 150 | A3B1C2* test5_16 = new A3B1C2(); | 
|---|
| 151 | A3B2C1* test5_17 = new A3B2C1(); | 
|---|
| 152 | A3B2C2* test5_18 = new A3B2C2(); | 
|---|
| 153 |  | 
|---|
| 154 | OrxonoxClass* test5; | 
|---|
| 155 | for (int i = 0; i <= 18; i++) | 
|---|
| 156 | { | 
|---|
| 157 | if (i == 0) test5 = new BaseObject; | 
|---|
| 158 | if (i == 1) test5 = test5_01; | 
|---|
| 159 | if (i == 2) test5 = test5_02; | 
|---|
| 160 | if (i == 3) test5 = test5_03; | 
|---|
| 161 | if (i == 4) test5 = test5_04; | 
|---|
| 162 | if (i == 5) test5 = test5_05; | 
|---|
| 163 | if (i == 6) test5 = test5_06; | 
|---|
| 164 | if (i == 7) test5 = test5_07; | 
|---|
| 165 | if (i == 8) test5 = test5_08; | 
|---|
| 166 | if (i == 9) test5 = test5_09; | 
|---|
| 167 | if (i == 10) test5 = test5_10; | 
|---|
| 168 | if (i == 11) test5 = test5_11; | 
|---|
| 169 | if (i == 12) test5 = test5_12; | 
|---|
| 170 | if (i == 13) test5 = test5_13; | 
|---|
| 171 | if (i == 14) test5 = test5_14; | 
|---|
| 172 | if (i == 15) test5 = test5_15; | 
|---|
| 173 | if (i == 16) test5 = test5_16; | 
|---|
| 174 | if (i == 17) test5 = test5_17; | 
|---|
| 175 | if (i == 18) test5 = test5_18; | 
|---|
| 176 |  | 
|---|
| 177 | std::cout << "\n"; | 
|---|
| 178 | std::cout << test5->getIdentifier()->getName() << ": parents:     " << test5->getIdentifier()->getParents().toString() << "\n"; | 
|---|
| 179 | std::cout << test5->getIdentifier()->getName() << ": children:    " << test5->getIdentifier()->getChildren().toString() << "\n"; | 
|---|
| 180 | } | 
|---|
| 181 | */ | 
|---|
| 182 | /* | 
|---|
| 183 | std::cout << "\n"; | 
|---|
| 184 | std::cout << "isA(XYZ)-Test:\n"; | 
|---|
| 185 | std::cout << "test5_01 = A1, Erwartet: 1 0 0 1 0\n"; | 
|---|
| 186 | testandcout(test5_01->isA(Class(A1))); | 
|---|
| 187 | testandcout(test5_01->isA(Class(A2))); | 
|---|
| 188 | testandcout(test5_01->isA(Class(A1B1))); | 
|---|
| 189 | testandcout(test5_01->isA(Class(BaseObject))); | 
|---|
| 190 | testandcout(test5_01->isA(Class(Interface1))); | 
|---|
| 191 |  | 
|---|
| 192 | std::cout << "\n"; | 
|---|
| 193 | std::cout << "test5_02 = A2, Erwartet: 0 1 0 1 0\n"; | 
|---|
| 194 | testandcout(test5_02->isA(Class(A1))); | 
|---|
| 195 | testandcout(test5_02->isA(Class(A2))); | 
|---|
| 196 | testandcout(test5_02->isA(Class(A1B1))); | 
|---|
| 197 | testandcout(test5_02->isA(Class(BaseObject))); | 
|---|
| 198 | testandcout(test5_02->isA(Class(Interface1))); | 
|---|
| 199 |  | 
|---|
| 200 | std::cout << "\n"; | 
|---|
| 201 | std::cout << "test5_01 = A3, Erwartet: 0 0 0 1 1\n"; | 
|---|
| 202 | testandcout(test5_03->isA(Class(A1))); | 
|---|
| 203 | testandcout(test5_03->isA(Class(A2))); | 
|---|
| 204 | testandcout(test5_03->isA(Class(A1B1))); | 
|---|
| 205 | testandcout(test5_03->isA(Class(BaseObject))); | 
|---|
| 206 | testandcout(test5_03->isA(Class(Interface1))); | 
|---|
| 207 |  | 
|---|
| 208 | std::cout << "\n"; | 
|---|
| 209 | std::cout << "isDirectA(XYZ)-Test:\n"; | 
|---|
| 210 | std::cout << "test5_01 = A1, Erwartet: 1 0 0 0 0\n"; | 
|---|
| 211 | testandcout(test5_01->isDirectlyA(Class(A1))); | 
|---|
| 212 | testandcout(test5_01->isDirectlyA(Class(A2))); | 
|---|
| 213 | testandcout(test5_01->isDirectlyA(Class(A1B1))); | 
|---|
| 214 | testandcout(test5_01->isDirectlyA(Class(BaseObject))); | 
|---|
| 215 | testandcout(test5_01->isDirectlyA(Class(Interface1))); | 
|---|
| 216 |  | 
|---|
| 217 | std::cout << "\n"; | 
|---|
| 218 | std::cout << "test5_02 = A2, Erwartet: 0 1 0 0 0\n"; | 
|---|
| 219 | testandcout(test5_02->isDirectlyA(Class(A1))); | 
|---|
| 220 | testandcout(test5_02->isDirectlyA(Class(A2))); | 
|---|
| 221 | testandcout(test5_02->isDirectlyA(Class(A1B1))); | 
|---|
| 222 | testandcout(test5_02->isDirectlyA(Class(BaseObject))); | 
|---|
| 223 | testandcout(test5_02->isDirectlyA(Class(Interface1))); | 
|---|
| 224 |  | 
|---|
| 225 | std::cout << "\n"; | 
|---|
| 226 | std::cout << "test5_03 = A3, Erwartet: 0 0 0 0 0\n"; | 
|---|
| 227 | testandcout(test5_03->isDirectlyA(Class(A1))); | 
|---|
| 228 | testandcout(test5_03->isDirectlyA(Class(A2))); | 
|---|
| 229 | testandcout(test5_03->isDirectlyA(Class(A1B1))); | 
|---|
| 230 | testandcout(test5_03->isDirectlyA(Class(BaseObject))); | 
|---|
| 231 | testandcout(test5_03->isDirectlyA(Class(Interface1))); | 
|---|
| 232 |  | 
|---|
| 233 | std::cout << "\n"; | 
|---|
| 234 | std::cout << "isChildOf(XYZ)-Test:\n"; | 
|---|
| 235 | std::cout << "test5_04 = A1B1, Erwartet: 1 0 1 0 0 0 0\n"; | 
|---|
| 236 | testandcout(test5_04->isChildOf(Class(A1))); | 
|---|
| 237 | testandcout(test5_04->isChildOf(Class(A2))); | 
|---|
| 238 | testandcout(test5_04->isChildOf(Class(BaseObject))); | 
|---|
| 239 | testandcout(test5_04->isChildOf(Class(Interface1))); | 
|---|
| 240 | testandcout(test5_04->isChildOf(Class(Interface2))); | 
|---|
| 241 | testandcout(test5_04->isChildOf(Class(A1B1C2))); | 
|---|
| 242 | testandcout(test5_04->isChildOf(Class(A1B1))); | 
|---|
| 243 |  | 
|---|
| 244 | std::cout << "\n"; | 
|---|
| 245 | std::cout << "test5_06 = A2B1, Erwartet: 0 1 1 0 0 0 0\n"; | 
|---|
| 246 | testandcout(test5_06->isChildOf(Class(A1))); | 
|---|
| 247 | testandcout(test5_06->isChildOf(Class(A2))); | 
|---|
| 248 | testandcout(test5_06->isChildOf(Class(BaseObject))); | 
|---|
| 249 | testandcout(test5_06->isChildOf(Class(Interface1))); | 
|---|
| 250 | testandcout(test5_06->isChildOf(Class(Interface2))); | 
|---|
| 251 | testandcout(test5_06->isChildOf(Class(A1B1C2))); | 
|---|
| 252 | testandcout(test5_06->isChildOf(Class(A1B1))); | 
|---|
| 253 |  | 
|---|
| 254 | std::cout << "\n"; | 
|---|
| 255 | std::cout << "test5_07 = A2B2, Erwartet: 0 1 1 1 0 0\n"; | 
|---|
| 256 | testandcout(test5_07->isChildOf(Class(A1))); | 
|---|
| 257 | testandcout(test5_07->isChildOf(Class(A2))); | 
|---|
| 258 | testandcout(test5_07->isChildOf(Class(BaseObject))); | 
|---|
| 259 | testandcout(test5_07->isChildOf(Class(Interface1))); | 
|---|
| 260 | testandcout(test5_07->isChildOf(Class(Interface2))); | 
|---|
| 261 | testandcout(test5_07->isChildOf(Class(A1B1C2))); | 
|---|
| 262 |  | 
|---|
| 263 | std::cout << "\n"; | 
|---|
| 264 | std::cout << "test5_08 = A3B1, Erwartet: 0 0 1 1 0 0\n"; | 
|---|
| 265 | testandcout(test5_08->isChildOf(Class(A1))); | 
|---|
| 266 | testandcout(test5_08->isChildOf(Class(A2))); | 
|---|
| 267 | testandcout(test5_08->isChildOf(Class(BaseObject))); | 
|---|
| 268 | testandcout(test5_08->isChildOf(Class(Interface1))); | 
|---|
| 269 | testandcout(test5_08->isChildOf(Class(Interface2))); | 
|---|
| 270 | testandcout(test5_08->isChildOf(Class(A1B1C2))); | 
|---|
| 271 |  | 
|---|
| 272 | std::cout << "\n"; | 
|---|
| 273 | std::cout << "test5_09 = A3B2, Erwartet: 0 0 1 1 1 0\n"; | 
|---|
| 274 | testandcout(test5_09->isChildOf(Class(A1))); | 
|---|
| 275 | testandcout(test5_09->isChildOf(Class(A2))); | 
|---|
| 276 | testandcout(test5_09->isChildOf(Class(BaseObject))); | 
|---|
| 277 | testandcout(test5_09->isChildOf(Class(Interface1))); | 
|---|
| 278 | testandcout(test5_09->isChildOf(Class(Interface2))); | 
|---|
| 279 | testandcout(test5_09->isChildOf(Class(A1B1C2))); | 
|---|
| 280 |  | 
|---|
| 281 | std::cout << "\n"; | 
|---|
| 282 | std::cout << "isParentOf(XYZ)-Test:\n"; | 
|---|
| 283 | std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n"; | 
|---|
| 284 | testandcout(test1->isParentOf(Class(BaseObject))); | 
|---|
| 285 | testandcout(test1->isParentOf(Class(Interface1))); | 
|---|
| 286 | testandcout(test1->isParentOf(Class(A1))); | 
|---|
| 287 | testandcout(test1->isParentOf(Class(A2))); | 
|---|
| 288 | testandcout(test1->isParentOf(Class(A1B1))); | 
|---|
| 289 | testandcout(test1->isParentOf(Class(A2B2))); | 
|---|
| 290 | testandcout(test1->isParentOf(Class(A3B1C2))); | 
|---|
| 291 |  | 
|---|
| 292 | std::cout << "\n"; | 
|---|
| 293 | std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n"; | 
|---|
| 294 | testandcout(test5_01->isParentOf(Class(BaseObject))); | 
|---|
| 295 | testandcout(test5_01->isParentOf(Class(Interface1))); | 
|---|
| 296 | testandcout(test5_01->isParentOf(Class(A1))); | 
|---|
| 297 | testandcout(test5_01->isParentOf(Class(A2))); | 
|---|
| 298 | testandcout(test5_01->isParentOf(Class(A1B1))); | 
|---|
| 299 | testandcout(test5_01->isParentOf(Class(A2B2))); | 
|---|
| 300 | testandcout(test5_01->isParentOf(Class(A3B1C2))); | 
|---|
| 301 |  | 
|---|
| 302 | std::cout << "\n"; | 
|---|
| 303 | std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 1\n"; | 
|---|
| 304 | testandcout(Class(Interface1)->isParentOf(Class(BaseObject))); | 
|---|
| 305 | testandcout(Class(Interface1)->isParentOf(Class(Interface1))); | 
|---|
| 306 | testandcout(Class(Interface1)->isParentOf(Class(A1))); | 
|---|
| 307 | testandcout(Class(Interface1)->isParentOf(Class(A2))); | 
|---|
| 308 | testandcout(Class(Interface1)->isParentOf(Class(A1B1))); | 
|---|
| 309 | testandcout(Class(Interface1)->isParentOf(Class(A2B2))); | 
|---|
| 310 | testandcout(Class(Interface1)->isParentOf(Class(A3B1C2))); | 
|---|
| 311 | */ | 
|---|
| 312 | /* | 
|---|
| 313 | std::cout << "Test 6\n"; | 
|---|
| 314 | std::cout << "1:\n"; | 
|---|
| 315 | Identifier* test6_01 = Class(A1B1); | 
|---|
| 316 | std::cout << "2:\n"; | 
|---|
| 317 | Identifier* test6_02 = Class(A1B1); | 
|---|
| 318 | std::cout << "3:\n"; | 
|---|
| 319 | Identifier* test6_03 = Class(A1); | 
|---|
| 320 | std::cout << "4:\n"; | 
|---|
| 321 | Identifier* test6_04 = Class(A1B1C1); | 
|---|
| 322 | std::cout << "5:\n"; | 
|---|
| 323 | Identifier* test6_05 = Class(A1B1); | 
|---|
| 324 | std::cout << "6:\n"; | 
|---|
| 325 | Identifier* test6_06 = Class(A1B1C1); | 
|---|
| 326 |  | 
|---|
| 327 | std::cout << "\n"; | 
|---|
| 328 | std::cout << "BaseObject: parents:     " << Class(BaseObject)->getParents().toString() << "\n"; | 
|---|
| 329 | std::cout << "BaseObject: children:    " << Class(BaseObject)->getChildren().toString() << "\n"; | 
|---|
| 330 |  | 
|---|
| 331 | std::cout << "\n"; | 
|---|
| 332 | std::cout << "A1: parents:     " << Class(A1)->getParents().toString() << "\n"; | 
|---|
| 333 | std::cout << "A1: children:    " << Class(A1)->getChildren().toString() << "\n"; | 
|---|
| 334 |  | 
|---|
| 335 | std::cout << "\n"; | 
|---|
| 336 | std::cout << "A1B1: parents:     " << Class(A1B1)->getParents().toString() << "\n"; | 
|---|
| 337 | std::cout << "A1B1: children:    " << Class(A1B1)->getChildren().toString() << "\n"; | 
|---|
| 338 |  | 
|---|
| 339 | std::cout << "\n"; | 
|---|
| 340 | std::cout << "A1B1C1: parents:     " << Class(A1B1C1)->getParents().toString() << "\n"; | 
|---|
| 341 | std::cout << "A1B1C1: children:    " << Class(A1B1C1)->getChildren().toString() << "\n"; | 
|---|
| 342 |  | 
|---|
| 343 | std::cout << "\n"; | 
|---|
| 344 | std::cout << "A3B1C1 child of A3:  " << Class(A3B1C1)->isChildOf(Class(A3)) << "\n"; | 
|---|
| 345 | std::cout << "\n"; | 
|---|
| 346 | std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n"; | 
|---|
| 347 | */ | 
|---|
| 348 | /* | 
|---|
| 349 | std::cout << "Test 7\n"; | 
|---|
| 350 | std::cout << "1\n"; | 
|---|
| 351 | SubclassIdentifier<A1B1> test7_01; | 
|---|
| 352 | test7_01 = Class(A1B1C1); | 
|---|
| 353 |  | 
|---|
| 354 | SubclassIdentifier<A1B1> test7_02; | 
|---|
| 355 | test7_02 = Class(A1B1); | 
|---|
| 356 |  | 
|---|
| 357 | std::cout << test7_01->getName() << "\n"; | 
|---|
| 358 | std::cout << test7_02->getName() << "\n"; | 
|---|
| 359 | */ | 
|---|
| 360 | /* | 
|---|
| 361 | std::cout << "2\n"; | 
|---|
| 362 |  | 
|---|
| 363 | SubclassIdentifier<A1B1> test7_03; | 
|---|
| 364 | test7_03 = Class(A1); | 
|---|
| 365 |  | 
|---|
| 366 | SubclassIdentifier<A1B1> test7_04; | 
|---|
| 367 | test7_04 = Class(A1B2); | 
|---|
| 368 |  | 
|---|
| 369 | SubclassIdentifier<A1B1> test7_05; | 
|---|
| 370 | test7_05 = Class(A2); | 
|---|
| 371 | */ | 
|---|
| 372 | /* | 
|---|
| 373 | std::cout << "Test 8\n"; | 
|---|
| 374 |  | 
|---|
| 375 | std::cout << "1\n"; | 
|---|
| 376 | Test1* test8_01 = new Test1; | 
|---|
| 377 | Test3* test8_03 = new Test3; | 
|---|
| 378 | test8_03->usefullClassesIsATest(test8_01); | 
|---|
| 379 |  | 
|---|
| 380 | std::cout << "2\n"; | 
|---|
| 381 | Test2* test8_02 = new Test2; | 
|---|
| 382 | test8_03->usefullClassesIsATest(test8_02); | 
|---|
| 383 |  | 
|---|
| 384 | std::cout << "3\n"; | 
|---|
| 385 | test8_01->setUsefullClass1(Class(Test1)); | 
|---|
| 386 | test8_01->setUsefullClass1(test8_02->getIdentifier()); | 
|---|
| 387 | test8_01->setUsefullClass2(Class(Test2)); | 
|---|
| 388 | test8_01->setUsefullClassOfTypeTest3(Class(Test3)); | 
|---|
| 389 | test8_01->setUsefullClassOfTypeTest3(test8_03->getIdentifier()); | 
|---|
| 390 |  | 
|---|
| 391 |  | 
|---|
| 392 | testandcout(test8_01->isA(Class(Test1))); | 
|---|
| 393 | testandcout(test8_01->isA(Class(Test2))); | 
|---|
| 394 | testandcout(test8_01->isA(Class(Test3))); | 
|---|
| 395 |  | 
|---|
| 396 | Test2* test8_04 = new Test2; | 
|---|
| 397 | testandcout(test8_02->isA(Class(Test1))); | 
|---|
| 398 | testandcout(test8_02->isA(Class(Test2))); | 
|---|
| 399 | testandcout(test8_02->isA(Class(Test3))); | 
|---|
| 400 |  | 
|---|
| 401 | Test3* test8_05 = new Test3; | 
|---|
| 402 | testandcout(test8_03->isA(Class(Test1))); | 
|---|
| 403 | testandcout(test8_03->isA(Class(Test2))); | 
|---|
| 404 | testandcout(test8_03->isA(Class(Test3))); | 
|---|
| 405 |  | 
|---|
| 406 | delete test8_01; | 
|---|
| 407 | delete test8_02; | 
|---|
| 408 | delete test8_03; | 
|---|
| 409 |  | 
|---|
| 410 |  | 
|---|
| 411 | std::cout << "Test 9\n"; | 
|---|
| 412 | std::cout << "1\n"; | 
|---|
| 413 | Identifier* test9_01 = Class(A3); | 
|---|
| 414 | BaseObject* test9_02 = test9_01->fabricate(); | 
|---|
| 415 | std::cout << test9_02->getIdentifier()->getName() << "\n"; | 
|---|
| 416 |  | 
|---|
| 417 | std::cout << "\n2\n"; | 
|---|
| 418 | BaseObject* test9_03 = Class(A1B2)->fabricate(); | 
|---|
| 419 | std::cout << test9_03->getIdentifier()->getName() << "\n"; | 
|---|
| 420 |  | 
|---|
| 421 | std::cout << "\n3\n"; | 
|---|
| 422 | SubclassIdentifier<A1> test9_04; | 
|---|
| 423 | test9_04 = Class(A1B1C1); | 
|---|
| 424 | A1* test9_05 = test9_04.fabricate(); | 
|---|
| 425 | std::cout << test9_05->getIdentifier()->getName() << "\n"; | 
|---|
| 426 |  | 
|---|
| 427 | std::cout << "\n4\n"; | 
|---|
| 428 | BaseObject* test9_06 = ID("A2B2")->fabricate(); | 
|---|
| 429 | std::cout << test9_06->getIdentifier()->getName() << "\n"; | 
|---|
| 430 |  | 
|---|
| 431 | std::cout << "\n5\n"; | 
|---|
| 432 | delete test9_02; | 
|---|
| 433 | delete test9_03; | 
|---|
| 434 | delete test9_05; | 
|---|
| 435 | delete test9_06; | 
|---|
| 436 | */ | 
|---|
| 437 |  | 
|---|
| 438 | std::cout << "Test 10\n"; | 
|---|
| 439 | Identifier* test10_01 = Class(A1B2); | 
|---|
| 440 | Identifier* test10_02 = Class(A2); | 
|---|
| 441 | Identifier* test10_03 = Class(A3B1C1); | 
|---|
| 442 |  | 
|---|
| 443 | BaseObject* test10_04 = test10_01->fabricate(); | 
|---|
| 444 | BaseObject* test10_05 = test10_02->fabricate(); | 
|---|
| 445 | BaseObject* test10_06 = test10_03->fabricate(); | 
|---|
| 446 |  | 
|---|
| 447 | BaseObject* test10_07; | 
|---|
| 448 | for (int i = 0; i < 10; i++) | 
|---|
| 449 | test10_07 = ID("A1B1C1")->fabricate(); | 
|---|
| 450 |  | 
|---|
| 451 | std::cout << "1\n"; | 
|---|
| 452 | int count; | 
|---|
| 453 |  | 
|---|
| 454 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } | 
|---|
| 455 | std::cout << "Anzahl BaseObjects: " << count << "\n"; | 
|---|
| 456 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } | 
|---|
| 457 | std::cout << "Anzahl A1: " << count << "\n"; | 
|---|
| 458 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } | 
|---|
| 459 | std::cout << "Anzahl A1B1: " << count << "\n"; | 
|---|
| 460 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } | 
|---|
| 461 | std::cout << "Anzahl A1B1C1: " << count << "\n"; | 
|---|
| 462 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } | 
|---|
| 463 | std::cout << "Anzahl A2: " << count << "\n"; | 
|---|
| 464 |  | 
|---|
| 465 | std::cout << "2\n"; | 
|---|
| 466 | BaseObject* test10_08; | 
|---|
| 467 | BaseObject* test10_09; | 
|---|
| 468 | BaseObject* test10_10; | 
|---|
| 469 | for (int i = 0; i < 10; i++) | 
|---|
| 470 | { | 
|---|
| 471 | test10_08 = ID("A2B1C1")->fabricate(); | 
|---|
| 472 | test10_08->name_ = "A2B1C1#"; | 
|---|
| 473 | test10_08->name_ += ('0' + i); | 
|---|
| 474 |  | 
|---|
| 475 | if (i == 0) | 
|---|
| 476 | test10_09 = test10_08; | 
|---|
| 477 |  | 
|---|
| 478 | if (i == 5) | 
|---|
| 479 | test10_10 = test10_08; | 
|---|
| 480 | } | 
|---|
| 481 |  | 
|---|
| 482 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } | 
|---|
| 483 | std::cout << "Anzahl BaseObjects: " << count << "\n"; | 
|---|
| 484 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } | 
|---|
| 485 | std::cout << "Anzahl A1: " << count << "\n"; | 
|---|
| 486 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } | 
|---|
| 487 | std::cout << "Anzahl A1B1: " << count << "\n"; | 
|---|
| 488 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } | 
|---|
| 489 | std::cout << "Anzahl A1B1C1: " << count << "\n"; | 
|---|
| 490 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } | 
|---|
| 491 | std::cout << "Anzahl A2: " << count << "\n"; | 
|---|
| 492 |  | 
|---|
| 493 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) | 
|---|
| 494 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 495 |  | 
|---|
| 496 | std::cout << "3\n"; | 
|---|
| 497 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) | 
|---|
| 498 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 499 |  | 
|---|
| 500 | std::cout << "4\n"; | 
|---|
| 501 | delete test10_08; | 
|---|
| 502 |  | 
|---|
| 503 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } | 
|---|
| 504 | std::cout << "Anzahl BaseObjects: " << count << "\n"; | 
|---|
| 505 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } | 
|---|
| 506 | std::cout << "Anzahl A1: " << count << "\n"; | 
|---|
| 507 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } | 
|---|
| 508 | std::cout << "Anzahl A1B1: " << count << "\n"; | 
|---|
| 509 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } | 
|---|
| 510 | std::cout << "Anzahl A1B1C1: " << count << "\n"; | 
|---|
| 511 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } | 
|---|
| 512 | std::cout << "Anzahl A2: " << count << "\n"; | 
|---|
| 513 |  | 
|---|
| 514 | std::cout << "5\n"; | 
|---|
| 515 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) | 
|---|
| 516 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 517 |  | 
|---|
| 518 | std::cout << "6\n"; | 
|---|
| 519 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) | 
|---|
| 520 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 521 |  | 
|---|
| 522 | std::cout << "7\n"; | 
|---|
| 523 | delete test10_09; | 
|---|
| 524 |  | 
|---|
| 525 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it != 0; --it) { count++; } | 
|---|
| 526 | std::cout << "Anzahl BaseObjects: " << count << "\n"; | 
|---|
| 527 | count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it != 0; --it) { count++; } | 
|---|
| 528 | std::cout << "Anzahl A1: " << count << "\n"; | 
|---|
| 529 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::end(); it; --it) { count++; } | 
|---|
| 530 | std::cout << "Anzahl A1B1: " << count << "\n"; | 
|---|
| 531 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::end(); it; --it) { count++; } | 
|---|
| 532 | std::cout << "Anzahl A1B1C1: " << count << "\n"; | 
|---|
| 533 | count = 0; for (Iterator<A2> it = ObjectList<A2>::end(); it; --it) { count++; } | 
|---|
| 534 | std::cout << "Anzahl A2: " << count << "\n"; | 
|---|
| 535 |  | 
|---|
| 536 | std::cout << "8\n"; | 
|---|
| 537 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) | 
|---|
| 538 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 539 |  | 
|---|
| 540 | std::cout << "9\n"; | 
|---|
| 541 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) | 
|---|
| 542 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 543 |  | 
|---|
| 544 | std::cout << "10\n"; | 
|---|
| 545 | delete test10_10; | 
|---|
| 546 |  | 
|---|
| 547 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } | 
|---|
| 548 | std::cout << "Anzahl BaseObjects: " << count << "\n"; | 
|---|
| 549 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } | 
|---|
| 550 | std::cout << "Anzahl A1: " << count << "\n"; | 
|---|
| 551 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } | 
|---|
| 552 | std::cout << "Anzahl A1B1: " << count << "\n"; | 
|---|
| 553 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } | 
|---|
| 554 | std::cout << "Anzahl A1B1C1: " << count << "\n"; | 
|---|
| 555 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } | 
|---|
| 556 | std::cout << "Anzahl A2: " << count << "\n"; | 
|---|
| 557 |  | 
|---|
| 558 | std::cout << "11\n"; | 
|---|
| 559 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) | 
|---|
| 560 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 561 |  | 
|---|
| 562 | std::cout << "12\n"; | 
|---|
| 563 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) | 
|---|
| 564 | std::cout << "Name: " << it->name_ << "\n"; | 
|---|
| 565 |  | 
|---|
| 566 |  | 
|---|
| 567 | } | 
|---|
| 568 |  | 
|---|
| 569 | ~OrxApplication() | 
|---|
| 570 | { | 
|---|
| 571 | mInputManager->destroyInputObject(mKeyboard); | 
|---|
| 572 | OIS::InputManager::destroyInputSystem(mInputManager); | 
|---|
| 573 |  | 
|---|
| 574 | delete mRenderer; | 
|---|
| 575 | delete mSystem; | 
|---|
| 576 |  | 
|---|
| 577 | delete mListener; | 
|---|
| 578 | delete mRoot; | 
|---|
| 579 | } | 
|---|
| 580 |  | 
|---|
| 581 | private: | 
|---|
| 582 | Ogre::Root *mRoot; | 
|---|
| 583 | OIS::Keyboard *mKeyboard; | 
|---|
| 584 | OIS::Mouse *mMouse; | 
|---|
| 585 | OIS::InputManager *mInputManager; | 
|---|
| 586 | CEGUI::OgreCEGUIRenderer *mRenderer; | 
|---|
| 587 | CEGUI::System *mSystem; | 
|---|
| 588 | OrxExitListener *mListener; | 
|---|
| 589 |  | 
|---|
| 590 | void createRoot() | 
|---|
| 591 | { | 
|---|
| 592 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
| 593 | mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg"); | 
|---|
| 594 | #else | 
|---|
| 595 | mRoot = new Ogre::Root(); | 
|---|
| 596 | #endif | 
|---|
| 597 | } | 
|---|
| 598 |  | 
|---|
| 599 | void defineResources() | 
|---|
| 600 | { | 
|---|
| 601 | Ogre::String secName, typeName, archName; | 
|---|
| 602 | Ogre::ConfigFile cf; | 
|---|
| 603 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
| 604 | cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); | 
|---|
| 605 | #else | 
|---|
| 606 | cf.load("resources.cfg"); | 
|---|
| 607 | #endif | 
|---|
| 608 |  | 
|---|
| 609 | Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); | 
|---|
| 610 | while (seci.hasMoreElements()) | 
|---|
| 611 | { | 
|---|
| 612 | secName = seci.peekNextKey(); | 
|---|
| 613 | Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); | 
|---|
| 614 | Ogre::ConfigFile::SettingsMultiMap::iterator i; | 
|---|
| 615 | for (i = settings->begin(); i != settings->end(); ++i) | 
|---|
| 616 | { | 
|---|
| 617 | typeName = i->first; | 
|---|
| 618 | archName = i->second; | 
|---|
| 619 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE | 
|---|
| 620 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); | 
|---|
| 621 | #else | 
|---|
| 622 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); | 
|---|
| 623 | #endif | 
|---|
| 624 | } | 
|---|
| 625 | } | 
|---|
| 626 | } | 
|---|
| 627 |  | 
|---|
| 628 | void setupRenderSystem() | 
|---|
| 629 | { | 
|---|
| 630 | if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) | 
|---|
| 631 | throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); | 
|---|
| 632 | } | 
|---|
| 633 |  | 
|---|
| 634 | void createRenderWindow() | 
|---|
| 635 | { | 
|---|
| 636 | mRoot->initialise(true, "Ogre Render Window"); | 
|---|
| 637 | } | 
|---|
| 638 |  | 
|---|
| 639 | void initializeResourceGroups() | 
|---|
| 640 | { | 
|---|
| 641 | Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); | 
|---|
| 642 | Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); | 
|---|
| 643 | } | 
|---|
| 644 |  | 
|---|
| 645 | void setupScene() | 
|---|
| 646 | { | 
|---|
| 647 | Ogre::SceneManager *mgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager"); | 
|---|
| 648 | Ogre::Camera *cam = mgr->createCamera("Camera"); | 
|---|
| 649 | Ogre::Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam); | 
|---|
| 650 | } | 
|---|
| 651 |  | 
|---|
| 652 | void setupInputSystem() | 
|---|
| 653 | { | 
|---|
| 654 | size_t windowHnd = 0; | 
|---|
| 655 | std::ostringstream windowHndStr; | 
|---|
| 656 | OIS::ParamList pl; | 
|---|
| 657 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); | 
|---|
| 658 |  | 
|---|
| 659 | win->getCustomAttribute("WINDOW", &windowHnd); | 
|---|
| 660 | windowHndStr << windowHnd; | 
|---|
| 661 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); | 
|---|
| 662 | mInputManager = OIS::InputManager::createInputSystem(pl); | 
|---|
| 663 |  | 
|---|
| 664 | try | 
|---|
| 665 | { | 
|---|
| 666 | mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false)); | 
|---|
| 667 | mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false)); | 
|---|
| 668 | } | 
|---|
| 669 | catch (const OIS::Exception &e) | 
|---|
| 670 | { | 
|---|
| 671 | throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem"); | 
|---|
| 672 | } | 
|---|
| 673 | } | 
|---|
| 674 |  | 
|---|
| 675 | void setupCEGUI() | 
|---|
| 676 | { | 
|---|
| 677 | Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); | 
|---|
| 678 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); | 
|---|
| 679 |  | 
|---|
| 680 | // CEGUI setup | 
|---|
| 681 | mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr); | 
|---|
| 682 | mSystem = new CEGUI::System(mRenderer); | 
|---|
| 683 |  | 
|---|
| 684 | // Other CEGUI setup here. | 
|---|
| 685 | } | 
|---|
| 686 |  | 
|---|
| 687 | void createFrameListener() | 
|---|
| 688 | { | 
|---|
| 689 | mListener = new OrxExitListener(mKeyboard); | 
|---|
| 690 | mRoot->addFrameListener(mListener); | 
|---|
| 691 | } | 
|---|
| 692 |  | 
|---|
| 693 | void startRenderLoop() | 
|---|
| 694 | { | 
|---|
| 695 | mRoot->startRendering(); | 
|---|
| 696 | } | 
|---|
| 697 | }; | 
|---|
| 698 | } | 
|---|
| 699 |  | 
|---|
| 700 | using namespace Ogre; | 
|---|
| 701 |  | 
|---|
| 702 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 | 
|---|
| 703 | #define WIN32_LEAN_AND_MEAN | 
|---|
| 704 | #include "windows.h" | 
|---|
| 705 |  | 
|---|
| 706 | INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) | 
|---|
| 707 | #else | 
|---|
| 708 | int main(int argc, char **argv) | 
|---|
| 709 | #endif | 
|---|
| 710 | { | 
|---|
| 711 | try | 
|---|
| 712 | { | 
|---|
| 713 | orxonox::OrxApplication orxonox; | 
|---|
| 714 | orxonox.go(); | 
|---|
| 715 | } | 
|---|
| 716 | catch(Exception& e) | 
|---|
| 717 | { | 
|---|
| 718 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 | 
|---|
| 719 | MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); | 
|---|
| 720 | #else | 
|---|
| 721 | fprintf(stderr, "An exception has occurred: %s\n", | 
|---|
| 722 | e.getFullDescription().c_str()); | 
|---|
| 723 | #endif | 
|---|
| 724 | } | 
|---|
| 725 |  | 
|---|
| 726 | return 0; | 
|---|
| 727 | } | 
|---|