[74] | 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 | |
---|
[116] | 28 | #include <Ogre.h> |
---|
| 29 | #include <OIS/OIS.h> |
---|
[112] | 30 | #include <CEGUI/CEGUI.h> |
---|
[162] | 31 | #include <OgreCEGUIRenderer.h> |
---|
| 32 | |
---|
[218] | 33 | #include "IdentifierIncludes.h" |
---|
[162] | 34 | #include "BaseObject.h" |
---|
| 35 | #include "Test.h" |
---|
[197] | 36 | #include "test1.h" |
---|
| 37 | #include "test2.h" |
---|
| 38 | #include "test3.h" |
---|
[74] | 39 | |
---|
[116] | 40 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
[172] | 41 | #include <CoreFoundation/CoreFoundation.h> |
---|
| 42 | |
---|
[116] | 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() |
---|
[74] | 47 | { |
---|
[116] | 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 | |
---|
[172] | 67 | namespace orxonox |
---|
| 68 | { |
---|
| 69 | class OrxExitListener : public Ogre::FrameListener |
---|
| 70 | { |
---|
| 71 | public: |
---|
| 72 | OrxExitListener(OIS::Keyboard *keyboard) |
---|
| 73 | : mKeyboard(keyboard) |
---|
| 74 | { |
---|
| 75 | } |
---|
[116] | 76 | |
---|
[172] | 77 | bool frameStarted(const Ogre::FrameEvent& evt) |
---|
| 78 | { |
---|
| 79 | mKeyboard->capture(); |
---|
| 80 | return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); |
---|
| 81 | } |
---|
[74] | 82 | |
---|
[172] | 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(); |
---|
[162] | 103 | */ |
---|
[244] | 104 | |
---|
| 105 | #define testandcout(code) \ |
---|
| 106 | std::cout << #code << " " << code << "\n" |
---|
| 107 | |
---|
[172] | 108 | /* |
---|
| 109 | std::cout << "Test 1\n"; |
---|
| 110 | BaseObject* test1; |
---|
| 111 | test1 = new BaseObject(); |
---|
| 112 | test1 = new BaseObject(); |
---|
| 113 | test1 = new BaseObject(); |
---|
[162] | 114 | |
---|
[172] | 115 | std::cout << "Test 2\n"; |
---|
| 116 | A1* test2; |
---|
| 117 | test2 = new A1(); |
---|
| 118 | test2 = new A1(); |
---|
| 119 | test2 = new A1(); |
---|
[162] | 120 | |
---|
[172] | 121 | std::cout << "Test 3\n"; |
---|
| 122 | BaseObject* test3; |
---|
| 123 | test3 = new BaseObject(); |
---|
| 124 | test3 = new BaseObject(); |
---|
| 125 | test3 = new BaseObject(); |
---|
[162] | 126 | |
---|
[172] | 127 | std::cout << "Test 4\n"; |
---|
| 128 | A3* test4; |
---|
| 129 | test4 = new A3(); |
---|
| 130 | test4 = new A3(); |
---|
| 131 | test4 = new A3(); |
---|
| 132 | */ |
---|
[197] | 133 | /* |
---|
[172] | 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(); |
---|
[243] | 153 | |
---|
[172] | 154 | OrxonoxClass* test5; |
---|
| 155 | for (int i = 0; i <= 18; i++) |
---|
| 156 | { |
---|
[243] | 157 | if (i == 0) test5 = new BaseObject; |
---|
[172] | 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"; |
---|
[243] | 178 | std::cout << test5->getIdentifier()->getName() << ": parents: " << test5->getIdentifier()->getParents().toString() << "\n"; |
---|
| 179 | std::cout << test5->getIdentifier()->getName() << ": children: " << test5->getIdentifier()->getChildren().toString() << "\n"; |
---|
[172] | 180 | } |
---|
| 181 | */ |
---|
[197] | 182 | /* |
---|
[172] | 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); |
---|
[243] | 326 | |
---|
[172] | 327 | std::cout << "\n"; |
---|
[243] | 328 | std::cout << "BaseObject: parents: " << Class(BaseObject)->getParents().toString() << "\n"; |
---|
| 329 | std::cout << "BaseObject: children: " << Class(BaseObject)->getChildren().toString() << "\n"; |
---|
[172] | 330 | |
---|
| 331 | std::cout << "\n"; |
---|
[243] | 332 | std::cout << "A1: parents: " << Class(A1)->getParents().toString() << "\n"; |
---|
| 333 | std::cout << "A1: children: " << Class(A1)->getChildren().toString() << "\n"; |
---|
[172] | 334 | |
---|
| 335 | std::cout << "\n"; |
---|
[243] | 336 | std::cout << "A1B1: parents: " << Class(A1B1)->getParents().toString() << "\n"; |
---|
| 337 | std::cout << "A1B1: children: " << Class(A1B1)->getChildren().toString() << "\n"; |
---|
[172] | 338 | |
---|
| 339 | std::cout << "\n"; |
---|
[243] | 340 | std::cout << "A1B1C1: parents: " << Class(A1B1C1)->getParents().toString() << "\n"; |
---|
| 341 | std::cout << "A1B1C1: children: " << Class(A1B1C1)->getChildren().toString() << "\n"; |
---|
[172] | 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"; |
---|
[244] | 347 | */ |
---|
| 348 | /* |
---|
[176] | 349 | std::cout << "Test 7\n"; |
---|
| 350 | std::cout << "1\n"; |
---|
[242] | 351 | SubclassIdentifier<A1B1> test7_01; |
---|
[176] | 352 | test7_01 = Class(A1B1C1); |
---|
| 353 | |
---|
[242] | 354 | SubclassIdentifier<A1B1> test7_02; |
---|
[176] | 355 | test7_02 = Class(A1B1); |
---|
| 356 | |
---|
[218] | 357 | std::cout << test7_01->getName() << "\n"; |
---|
| 358 | std::cout << test7_02->getName() << "\n"; |
---|
[197] | 359 | */ |
---|
| 360 | /* |
---|
| 361 | std::cout << "2\n"; |
---|
[176] | 362 | |
---|
[242] | 363 | SubclassIdentifier<A1B1> test7_03; |
---|
[176] | 364 | test7_03 = Class(A1); |
---|
| 365 | |
---|
[242] | 366 | SubclassIdentifier<A1B1> test7_04; |
---|
[176] | 367 | test7_04 = Class(A1B2); |
---|
| 368 | |
---|
[242] | 369 | SubclassIdentifier<A1B1> test7_05; |
---|
[176] | 370 | test7_05 = Class(A2); |
---|
| 371 | */ |
---|
[218] | 372 | /* |
---|
[197] | 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 | |
---|
[176] | 380 | std::cout << "2\n"; |
---|
[197] | 381 | Test2* test8_02 = new Test2; |
---|
| 382 | test8_03->usefullClassesIsATest(test8_02); |
---|
[176] | 383 | |
---|
[197] | 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()); |
---|
[176] | 390 | |
---|
[197] | 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; |
---|
[246] | 409 | |
---|
| 410 | |
---|
[218] | 411 | std::cout << "Test 9\n"; |
---|
| 412 | std::cout << "1\n"; |
---|
| 413 | Identifier* test9_01 = Class(A3); |
---|
[219] | 414 | BaseObject* test9_02 = test9_01->fabricate(); |
---|
[218] | 415 | std::cout << test9_02->getIdentifier()->getName() << "\n"; |
---|
[197] | 416 | |
---|
[218] | 417 | std::cout << "\n2\n"; |
---|
[219] | 418 | BaseObject* test9_03 = Class(A1B2)->fabricate(); |
---|
[218] | 419 | std::cout << test9_03->getIdentifier()->getName() << "\n"; |
---|
| 420 | |
---|
| 421 | std::cout << "\n3\n"; |
---|
[242] | 422 | SubclassIdentifier<A1> test9_04; |
---|
[218] | 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"; |
---|
[244] | 428 | BaseObject* test9_06 = ID("A2B2")->fabricate(); |
---|
[218] | 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; |
---|
[221] | 436 | */ |
---|
[248] | 437 | |
---|
[221] | 438 | std::cout << "Test 10\n"; |
---|
[224] | 439 | Identifier* test10_01 = Class(A1B2); |
---|
| 440 | Identifier* test10_02 = Class(A2); |
---|
| 441 | Identifier* test10_03 = Class(A3B1C1); |
---|
[218] | 442 | |
---|
[224] | 443 | BaseObject* test10_04 = test10_01->fabricate(); |
---|
| 444 | BaseObject* test10_05 = test10_02->fabricate(); |
---|
| 445 | BaseObject* test10_06 = test10_03->fabricate(); |
---|
[221] | 446 | |
---|
[224] | 447 | BaseObject* test10_07; |
---|
[221] | 448 | for (int i = 0; i < 10; i++) |
---|
[244] | 449 | test10_07 = ID("A1B1C1")->fabricate(); |
---|
[221] | 450 | |
---|
| 451 | std::cout << "1\n"; |
---|
[246] | 452 | int count; |
---|
[248] | 453 | |
---|
| 454 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } |
---|
[221] | 455 | std::cout << "Anzahl BaseObjects: " << count << "\n"; |
---|
[248] | 456 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } |
---|
[221] | 457 | std::cout << "Anzahl A1: " << count << "\n"; |
---|
[248] | 458 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } |
---|
[221] | 459 | std::cout << "Anzahl A1B1: " << count << "\n"; |
---|
[248] | 460 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } |
---|
[221] | 461 | std::cout << "Anzahl A1B1C1: " << count << "\n"; |
---|
[248] | 462 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } |
---|
[221] | 463 | std::cout << "Anzahl A2: " << count << "\n"; |
---|
| 464 | |
---|
| 465 | std::cout << "2\n"; |
---|
[224] | 466 | BaseObject* test10_08; |
---|
| 467 | BaseObject* test10_09; |
---|
| 468 | BaseObject* test10_10; |
---|
[221] | 469 | for (int i = 0; i < 10; i++) |
---|
| 470 | { |
---|
[244] | 471 | test10_08 = ID("A2B1C1")->fabricate(); |
---|
[224] | 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; |
---|
[221] | 480 | } |
---|
| 481 | |
---|
[248] | 482 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } |
---|
[246] | 483 | std::cout << "Anzahl BaseObjects: " << count << "\n"; |
---|
[248] | 484 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } |
---|
[246] | 485 | std::cout << "Anzahl A1: " << count << "\n"; |
---|
[248] | 486 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } |
---|
[246] | 487 | std::cout << "Anzahl A1B1: " << count << "\n"; |
---|
[248] | 488 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } |
---|
[246] | 489 | std::cout << "Anzahl A1B1C1: " << count << "\n"; |
---|
[248] | 490 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } |
---|
[246] | 491 | std::cout << "Anzahl A2: " << count << "\n"; |
---|
| 492 | |
---|
[248] | 493 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) |
---|
[221] | 494 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 495 | |
---|
| 496 | std::cout << "3\n"; |
---|
[248] | 497 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) |
---|
[221] | 498 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 499 | |
---|
| 500 | std::cout << "4\n"; |
---|
[224] | 501 | delete test10_08; |
---|
[221] | 502 | |
---|
[248] | 503 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } |
---|
[246] | 504 | std::cout << "Anzahl BaseObjects: " << count << "\n"; |
---|
[248] | 505 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } |
---|
[246] | 506 | std::cout << "Anzahl A1: " << count << "\n"; |
---|
[248] | 507 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } |
---|
[246] | 508 | std::cout << "Anzahl A1B1: " << count << "\n"; |
---|
[248] | 509 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } |
---|
[246] | 510 | std::cout << "Anzahl A1B1C1: " << count << "\n"; |
---|
[248] | 511 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } |
---|
[246] | 512 | std::cout << "Anzahl A2: " << count << "\n"; |
---|
| 513 | |
---|
[224] | 514 | std::cout << "5\n"; |
---|
[248] | 515 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) |
---|
[224] | 516 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 517 | |
---|
| 518 | std::cout << "6\n"; |
---|
[248] | 519 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) |
---|
[224] | 520 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 521 | |
---|
| 522 | std::cout << "7\n"; |
---|
| 523 | delete test10_09; |
---|
| 524 | |
---|
[248] | 525 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::end(); it != 0; --it) { count++; } |
---|
[246] | 526 | std::cout << "Anzahl BaseObjects: " << count << "\n"; |
---|
[248] | 527 | count = 0; for (Iterator<A1> it = ObjectList<A1>::end(); it != 0; --it) { count++; } |
---|
[246] | 528 | std::cout << "Anzahl A1: " << count << "\n"; |
---|
[248] | 529 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::end(); it; --it) { count++; } |
---|
[246] | 530 | std::cout << "Anzahl A1B1: " << count << "\n"; |
---|
[248] | 531 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::end(); it; --it) { count++; } |
---|
[246] | 532 | std::cout << "Anzahl A1B1C1: " << count << "\n"; |
---|
[248] | 533 | count = 0; for (Iterator<A2> it = ObjectList<A2>::end(); it; --it) { count++; } |
---|
[246] | 534 | std::cout << "Anzahl A2: " << count << "\n"; |
---|
| 535 | |
---|
[224] | 536 | std::cout << "8\n"; |
---|
[248] | 537 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) |
---|
[224] | 538 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 539 | |
---|
| 540 | std::cout << "9\n"; |
---|
[248] | 541 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) |
---|
[224] | 542 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 543 | |
---|
| 544 | std::cout << "10\n"; |
---|
| 545 | delete test10_10; |
---|
| 546 | |
---|
[248] | 547 | count = 0; for (Iterator<BaseObject> it = ObjectList<BaseObject>::start(); it != 0; ++it) { count++; } |
---|
[246] | 548 | std::cout << "Anzahl BaseObjects: " << count << "\n"; |
---|
[248] | 549 | count = 0; for (Iterator<A1> it = ObjectList<A1>::start(); it != 0; ++it) { count++; } |
---|
[246] | 550 | std::cout << "Anzahl A1: " << count << "\n"; |
---|
[248] | 551 | count = 0; for (Iterator<A1B1> it = ObjectList<A1B1>::start(); it; ++it) { count++; } |
---|
[246] | 552 | std::cout << "Anzahl A1B1: " << count << "\n"; |
---|
[248] | 553 | count = 0; for (Iterator<A1B1C1> it = ObjectList<A1B1C1>::start(); it; ++it) { count++; } |
---|
[246] | 554 | std::cout << "Anzahl A1B1C1: " << count << "\n"; |
---|
[248] | 555 | count = 0; for (Iterator<A2> it = ObjectList<A2>::start(); it; ++it) { count++; } |
---|
[246] | 556 | std::cout << "Anzahl A2: " << count << "\n"; |
---|
| 557 | |
---|
[224] | 558 | std::cout << "11\n"; |
---|
[248] | 559 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it) |
---|
[224] | 560 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 561 | |
---|
| 562 | std::cout << "12\n"; |
---|
[248] | 563 | for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it) |
---|
[224] | 564 | std::cout << "Name: " << it->name_ << "\n"; |
---|
| 565 | |
---|
[248] | 566 | |
---|
[172] | 567 | } |
---|
[74] | 568 | |
---|
[172] | 569 | ~OrxApplication() |
---|
| 570 | { |
---|
| 571 | mInputManager->destroyInputObject(mKeyboard); |
---|
| 572 | OIS::InputManager::destroyInputSystem(mInputManager); |
---|
[116] | 573 | |
---|
[172] | 574 | delete mRenderer; |
---|
| 575 | delete mSystem; |
---|
[116] | 576 | |
---|
[172] | 577 | delete mListener; |
---|
| 578 | delete mRoot; |
---|
| 579 | } |
---|
[116] | 580 | |
---|
[172] | 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; |
---|
[116] | 589 | |
---|
[172] | 590 | void createRoot() |
---|
| 591 | { |
---|
[116] | 592 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
[172] | 593 | mRoot = new Ogre::Root(macBundlePath() + "/Contents/Resources/plugins.cfg"); |
---|
[116] | 594 | #else |
---|
[172] | 595 | mRoot = new Ogre::Root(); |
---|
[116] | 596 | #endif |
---|
[172] | 597 | } |
---|
[74] | 598 | |
---|
[172] | 599 | void defineResources() |
---|
| 600 | { |
---|
| 601 | Ogre::String secName, typeName, archName; |
---|
| 602 | Ogre::ConfigFile cf; |
---|
[116] | 603 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
[172] | 604 | cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); |
---|
[116] | 605 | #else |
---|
[172] | 606 | cf.load("resources.cfg"); |
---|
[116] | 607 | #endif |
---|
[74] | 608 | |
---|
[172] | 609 | Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); |
---|
| 610 | while (seci.hasMoreElements()) |
---|
[116] | 611 | { |
---|
[172] | 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; |
---|
[116] | 619 | #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE |
---|
[172] | 620 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); |
---|
[116] | 621 | #else |
---|
[172] | 622 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); |
---|
[116] | 623 | #endif |
---|
[172] | 624 | } |
---|
[116] | 625 | } |
---|
| 626 | } |
---|
[74] | 627 | |
---|
[172] | 628 | void setupRenderSystem() |
---|
| 629 | { |
---|
| 630 | if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) |
---|
| 631 | throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); |
---|
| 632 | } |
---|
[74] | 633 | |
---|
[172] | 634 | void createRenderWindow() |
---|
| 635 | { |
---|
| 636 | mRoot->initialise(true, "Ogre Render Window"); |
---|
| 637 | } |
---|
[74] | 638 | |
---|
[172] | 639 | void initializeResourceGroups() |
---|
| 640 | { |
---|
| 641 | Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); |
---|
| 642 | Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); |
---|
| 643 | } |
---|
[74] | 644 | |
---|
[172] | 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 | } |
---|
[74] | 651 | |
---|
[172] | 652 | void setupInputSystem() |
---|
| 653 | { |
---|
| 654 | size_t windowHnd = 0; |
---|
| 655 | std::ostringstream windowHndStr; |
---|
| 656 | OIS::ParamList pl; |
---|
| 657 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); |
---|
[74] | 658 | |
---|
[172] | 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); |
---|
[74] | 663 | |
---|
[172] | 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 | } |
---|
[116] | 673 | } |
---|
[172] | 674 | |
---|
| 675 | void setupCEGUI() |
---|
[116] | 676 | { |
---|
[172] | 677 | Ogre::SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); |
---|
| 678 | Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow(); |
---|
[74] | 679 | |
---|
[172] | 680 | // CEGUI setup |
---|
| 681 | mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr); |
---|
| 682 | mSystem = new CEGUI::System(mRenderer); |
---|
[116] | 683 | |
---|
[172] | 684 | // Other CEGUI setup here. |
---|
| 685 | } |
---|
[116] | 686 | |
---|
[172] | 687 | void createFrameListener() |
---|
| 688 | { |
---|
| 689 | mListener = new OrxExitListener(mKeyboard); |
---|
| 690 | mRoot->addFrameListener(mListener); |
---|
| 691 | } |
---|
[116] | 692 | |
---|
[172] | 693 | void startRenderLoop() |
---|
| 694 | { |
---|
| 695 | mRoot->startRendering(); |
---|
| 696 | } |
---|
| 697 | }; |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | using namespace Ogre; |
---|
| 701 | |
---|
[116] | 702 | #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
[74] | 703 | #define WIN32_LEAN_AND_MEAN |
---|
| 704 | #include "windows.h" |
---|
| 705 | |
---|
[116] | 706 | INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) |
---|
[74] | 707 | #else |
---|
[116] | 708 | int main(int argc, char **argv) |
---|
[74] | 709 | #endif |
---|
| 710 | { |
---|
[116] | 711 | try |
---|
| 712 | { |
---|
[172] | 713 | orxonox::OrxApplication orxonox; |
---|
[74] | 714 | orxonox.go(); |
---|
[116] | 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); |
---|
[74] | 720 | #else |
---|
| 721 | fprintf(stderr, "An exception has occurred: %s\n", |
---|
| 722 | e.getFullDescription().c_str()); |
---|
| 723 | #endif |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | return 0; |
---|
| 727 | } |
---|