Changeset 4554 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jun 8, 2005, 1:36:16 PM (19 years ago)
- Location:
- orxonox/trunk/src/subprojects
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/subprojects/benchmark.cc
r4166 r4554 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 16 16 You should have received a copy of the GNU General Public License 17 17 along with this program; if not, write to the Free Software Foundation, 18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 19 20 20 … … 26 26 27 27 28 #if defined __linux__ 28 #if defined __linux__ 29 29 30 30 #include "list.h" … … 59 59 dt = end - ini; 60 60 61 int type = -1; 62 /* type -1 == all 61 int type = -1; 62 /* type -1 == all 63 63 type 0 == framework 64 64 type 1 == vector … … 69 69 { 70 70 /* framework test*/ 71 71 72 72 printf("Generating Objects:\t\t\t\t\t%i\n", ITERATIONS); 73 73 /* ************WorldEntity class test************** */ … … 75 75 int i = 0; 76 76 unsigned long mittel = 0; 77 78 for(i = 0; i < ITERATIONS; ++i) 79 80 81 82 83 84 85 86 87 77 78 for(i = 0; i < ITERATIONS; ++i) 79 { 80 rdtscl(ini); 81 82 WorldEntity* w = new WorldEntity(); 83 84 rdtscl(end); 85 delete w; 86 mittel += (end - ini - dt); 87 } 88 88 float mi = mittel / (float)ITERATIONS; 89 89 printf(" Generate a WorldEntity object:\t\t%11.2f\n", mi); 90 90 91 91 /* 92 93 94 95 96 97 98 99 100 101 102 103 104 92 mittel = 0; 93 for(i = 0; i < ITERATIONS; ++i) 94 { 95 rdtscl(ini); 96 97 WorldEntity* w = new Primitive(P_SPHERE); 98 99 rdtscl(end); 100 delete w; 101 mittel += (end - ini - dt); 102 } 103 mi = mittel / (float)ITERATIONS; 104 printf(" Generate a Primitive object:\t\t%11.2f\n", mi); 105 105 */ 106 106 107 107 mittel = 0; 108 108 for(i = 0; i < ITERATIONS; ++i) 109 110 111 112 113 114 115 116 117 109 { 110 rdtscl(ini); 111 112 Vector* v = new Vector(); 113 114 rdtscl(end); 115 delete v; 116 mittel += (end - ini - dt); 117 } 118 118 mi = mittel / (float)ITERATIONS; 119 119 printf(" Generate a Vector object:\t\t%11.2f\n", mi); … … 122 122 mittel = 0; 123 123 for(i = 0; i < ITERATIONS; ++i) 124 125 126 127 128 129 130 131 132 124 { 125 rdtscl(ini); 126 127 Quaternion* q = new Quaternion(); 128 129 rdtscl(end); 130 delete q; 131 mittel += (end - ini - dt); 132 } 133 133 mi = mittel / (float)ITERATIONS; 134 134 printf(" Generate a Quaternion object:\t\t%11.2f\n", mi); … … 141 141 w = new WorldEntity(); 142 142 for(i = 0; i < ITERATIONS; ++i) 143 144 145 146 147 148 149 150 143 { 144 rdtscl(ini); 145 146 w->tick(0.0f); 147 148 rdtscl(end); 149 mittel += (end - ini - dt); 150 } 151 151 //delete w; 152 152 mi = mittel / (float)ITERATIONS; … … 157 157 WorldEntity wo; 158 158 for(i = 0; i < ITERATIONS; ++i) 159 160 161 162 163 164 165 166 159 { 160 rdtscl(ini); 161 162 wo.tick(0.0f); 163 164 rdtscl(end); 165 mittel += (end - ini - dt); 166 } 167 167 //delete w; 168 168 mi = mittel / (float)ITERATIONS; 169 169 printf(" Inl virt funct tick() of WE v2: \t%11.2f\n", mi); 170 170 171 171 172 172 mittel = 0; 173 173 BaseObject* bo = new BaseObject(); 174 174 for(i = 0; i < ITERATIONS; ++i) 175 176 177 178 179 180 181 182 175 { 176 rdtscl(ini); 177 178 bo->isFinalized(); 179 180 rdtscl(end); 181 mittel += (end - ini - dt); 182 } 183 183 //delete w; 184 184 mi = mittel / (float)ITERATIONS; 185 185 printf(" Inl funct BaseObject::isFinazlized(): \t%11.2f\n", mi); 186 186 187 187 188 188 tList<WorldEntity>* list = new tList<WorldEntity>(); 189 189 190 190 191 191 /* ************Primitvie class test************** */ 192 192 list = new tList<WorldEntity>(); 193 194 193 194 195 195 /* 196 197 198 199 200 201 202 203 204 205 206 207 208 196 mittel = 0; 197 w = new Primitive(P_SPHERE); 198 for(i = 0; i < ITERATIONS; ++i) 199 { 200 rdtscl(ini); 201 202 w->tick(0.0f); 203 204 rdtscl(end); 205 mittel += (end - ini - dt); 206 } 207 mi = mittel / (float)ITERATIONS; 208 printf(" Call function tick() of Prim:\t\t%11.2f\n", mi); 209 209 */ 210 210 211 211 } 212 212 213 213 if(type == 1 || type == -1) 214 214 { … … 218 218 Vector* b = new Vector(0.4, 2.5, 6.2); 219 219 Vector* c = new Vector(); 220 220 221 221 unsigned long mittel, ini, end; 222 222 float mi; … … 225 225 mittel = 0; 226 226 for(i = 0; i < VECTOR_MAX; ++i) 227 228 229 230 231 232 233 234 227 { 228 rdtscl(ini); 229 230 *c = *a + *b; 231 232 rdtscl(end); 233 mittel += (end - ini - dt); 234 } 235 235 mi = mittel / (float)VECTOR_MAX; 236 236 printf(" Addition of two vectors:\t\t%11.2f\n", mi); 237 237 238 238 // multiplikation 239 239 240 240 mittel = 0; 241 241 for(i = 0; i < VECTOR_MAX; ++i) 242 243 244 245 246 247 248 249 242 { 243 rdtscl(ini); 244 245 *c = a->cross( *b); 246 247 rdtscl(end); 248 mittel += (end - ini - dt); 249 } 250 250 mi = mittel / (float)VECTOR_MAX; 251 251 printf(" CrossMult of two vectors:\t\t%11.2f\n", mi); … … 260 260 Quaternion* b = new Quaternion(); 261 261 Quaternion* c = new Quaternion(); 262 262 263 263 unsigned long mittel, ini, end; 264 264 float mi; … … 269 269 Vector* qb = new Vector(3.5, 6.1, 4.3); 270 270 for(i = 0; i < VECTOR_MAX; ++i) 271 272 273 274 275 276 277 278 279 271 { 272 rdtscl(ini); 273 274 Quaternion* qu = new Quaternion(*qa, *qb); 275 276 rdtscl(end); 277 delete qu; 278 mittel += (end - ini - dt); 279 } 280 280 delete a; 281 281 delete b; 282 282 mi = mittel / (float)VECTOR_MAX; 283 283 printf(" Gen. quatern. betw. two vectors:\t%11.2f\n", mi); 284 285 284 285 286 286 // multiplication 287 287 mittel = 0; 288 288 for(i = 0; i < VECTOR_MAX; ++i) 289 290 291 292 293 294 295 296 289 { 290 rdtscl(ini); 291 292 *c = *a * *b; 293 294 rdtscl(end); 295 mittel += (end - ini - dt); 296 } 297 297 mi = mittel / (float)VECTOR_MAX; 298 298 printf(" Multiplying two quat.(=rot): a * b\t%11.2f\n", mi); 299 300 301 299 300 301 302 302 // rotating a vector by a quaternion 303 303 mittel = 0; 304 304 for(i = 0; i < VECTOR_MAX; ++i) 305 306 307 308 309 310 311 312 305 { 306 rdtscl(ini); 307 308 *qa = a->apply(*qb); 309 310 rdtscl(end); 311 mittel += (end - ini - dt); 312 } 313 313 mi = mittel / (float)VECTOR_MAX; 314 314 printf(" Rot a vec by a quat: q->apply(v)\t%11.2f\n", mi); 315 316 317 315 316 317 318 318 // generate rotation matrix 319 319 mittel = 0; 320 320 float matrix[4][4]; 321 321 for(i = 0; i < VECTOR_MAX; ++i) 322 323 324 325 326 327 328 329 322 { 323 rdtscl(ini); 324 325 a->matrix(matrix); 326 327 rdtscl(end); 328 mittel += (end - ini - dt); 329 } 330 330 mi = mittel / (float)VECTOR_MAX; 331 331 printf(" Generate rot matrix: q->matrix(m)\t%11.2f\n", mi); … … 337 337 tList<char>* list = new tList<char>(); 338 338 char* name; 339 339 340 340 printf(" Adding[1..10] elements to list, found:\n"); 341 341 list->add("1"); … … 349 349 list->add("9"); 350 350 list->add("10"); 351 351 352 352 /*give list out */ 353 353 tIterator<char>* iterator = list->getIterator(); … … 355 355 printf(" List Elements: \t\t"); 356 356 while( name != NULL) 357 358 359 360 357 { 358 printf("%s,", name); 359 name = iterator->nextElement(); 360 } 361 361 delete iterator; 362 362 printf("\n"); 363 364 363 364 365 365 /*removing some elements from the list*/ 366 366 printf(" Removing elements [2,3,6,8,10], adding [11] now found:\n"); … … 376 376 printf(" List Elements: \t\t"); 377 377 while( name != NULL) 378 379 380 381 378 { 379 printf("%s,", name); 380 name = iterator->nextElement(); 381 } 382 382 delete iterator; 383 383 printf("\n"); 384 384 385 385 delete list; 386 386 printf("\nChecking list performance:\t\t\t\t%i\n", LIST_MAX); 387 387 388 388 tList<int>* plist = new tList<int>(); 389 389 unsigned long mittel, ini, end; … … 392 392 mittel = 0; 393 393 for(i = 0; i < LIST_MAX; ++i) 394 395 396 397 398 399 400 401 394 { 395 rdtscl(ini); 396 397 plist->add(&i); 398 399 rdtscl(end); 400 mittel += (end - ini - dt); 401 } 402 402 mi = mittel / (float)LIST_MAX; 403 403 printf(" Adding reference to list:\t\t%11.2f\n", mi); 404 404 405 405 mittel = 0; 406 406 for(i = 0; i < LIST_MAX; ++i) 407 408 409 410 411 412 413 414 407 { 408 rdtscl(ini); 409 410 plist->remove(&i); 411 412 rdtscl(end); 413 mittel += (end - ini - dt); 414 } 415 415 mi = mittel / (float)LIST_MAX; 416 416 printf(" Removing 1st reference from list:\t%11.2f\n", mi); 417 417 418 418 419 419 printf("\nList operations tests: \t\t\t\t\t%i\n", LIST_MAX); … … 430 430 list->add("9"); 431 431 list->add("10"); 432 432 433 433 /*give list out */ 434 434 iterator = list->getIterator(); … … 436 436 printf(" List Elements: \t\t"); 437 437 while( name != NULL) 438 439 440 441 438 { 439 printf("%s,", name); 440 name = iterator->nextElement(); 441 } 442 442 delete iterator; 443 443 printf("\n"); 444 445 444 445 446 446 int c = 0; 447 447 printf(" Going trough list with nextElement(el) func: "); 448 448 name = list->firstElement(); 449 449 while(c < 20) 450 451 452 453 454 450 { 451 printf("%s,", name); 452 name = list->nextElement(name); 453 c++; 454 } 455 455 printf("\n"); 456 457 458 456 457 458 459 459 } 460 460 461 461 } 462 462 -
orxonox/trunk/src/subprojects/benchmark.h
r4131 r4554 1 /*! 1 /*! 2 2 \file benchmark.h 3 3 \brief benchmark functions 4 */ 4 */ 5 5 6 6 -
orxonox/trunk/src/subprojects/framework.cc
r4519 r4554 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 36 36 #ifdef GUI_MODULE 37 37 while(gtk_events_pending()) 38 38 gtk_main_iteration(); 39 39 #endif 40 40 // keyhandler returns false if sdl gets quit by some event … … 56 56 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 57 57 glLoadIdentity(); // Reset the view 58 58 59 59 this->moduleDraw(); 60 60 61 61 camera->apply(); 62 62 63 63 SDL_GL_SwapBuffers(); // Swap the buffers 64 64 } … … 89 89 switch (event.type) { 90 90 case SDL_MOUSEMOTION: 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 91 { 92 Vector view = camera->getTarget()->getAbsCoor() - camera->getAbsCoor(); 93 Vector up = Vector(0, 1, 0); 94 up = camera->getAbsDir().apply(up); 95 Vector h = up.cross(view); 96 Vector v = h.cross(view); 97 h.normalize(); 98 v.normalize(); 99 float distance = view.len(); 100 101 Vector newCameraPos = camera->getAbsCoor(); 102 Vector newTargetPos = camera->getTarget()->getAbsCoor(); 103 int changed = 0; 104 105 if (mouseDown[1]) 106 { 107 newCameraPos = camera->getRelCoor()+ (h * event.motion.xrel - v * event.motion.yrel) * .005 * distance; 108 changed += 1; 109 } 110 if (mouseDown[3]) 111 { 112 newTargetPos = camera->getTarget()->getRelCoor() + (h * event.motion.xrel - v * event.motion.yrel) * .005 * distance; 113 changed += 2; 114 } 115 116 Vector newView = newTargetPos - newCameraPos; 117 118 if (changed == 1) 119 camera->setRelCoor(newCameraPos + newView * (1- distance/newView.len())); 120 else if (changed == 2) 121 camera->getTarget()->setRelCoor(newTargetPos - newView * (1-distance/newView.len())); 122 else if (changed == 3) 123 { 124 camera->setRelCoor(newCameraPos); 125 camera->getTarget()->setRelCoor(newTargetPos); 126 } 127 128 } 129 break; 130 130 case SDL_MOUSEBUTTONDOWN: 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 131 switch (event.button.button) 132 { 133 case 4: 134 PRINTF(4)("MouseWheel up\n"); 135 camera->setRelCoor(camera->getRelCoor() + (camera->getTarget()->getAbsCoor() - camera->getAbsCoor())*.1); 136 break; 137 case 5: 138 PRINTF(4)("MouseWheel down\n"); 139 camera->setRelCoor(camera->getRelCoor() - (camera->getTarget()->getAbsCoor() - camera->getAbsCoor())*.1); 140 break; 141 case 1: 142 case 2: 143 case 3: 144 mouseDown[event.button.button] = true; 145 break; 146 } 147 148 break; 149 149 case SDL_MOUSEBUTTONUP: 150 151 152 153 154 155 156 157 158 150 switch (event.button.button) 151 { 152 case 1: 153 case 2: 154 case 3: 155 mouseDown[event.button.button] = false; 156 break; 157 } 158 break; 159 159 case SDL_VIDEORESIZE: 160 161 160 GraphicsEngine::getInstance()->resolutionChanged(&event.resize); 161 break; 162 162 case SDL_KEYDOWN: 163 164 165 166 167 #ifdef GUI_MODULE 168 163 switch (event.key.keysym.sym) 164 { 165 case SDLK_q: 166 case SDLK_ESCAPE: 167 #ifdef GUI_MODULE 168 quitGui(NULL, NULL); 169 169 #else 170 171 #endif 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 170 this->quit(); 171 #endif 172 break; 173 case SDLK_a: 174 camera->setRelCoor(camera->getRelCoor() + (camera->getTarget()->getAbsCoor() - camera->getAbsCoor())*.1); 175 break; 176 case SDLK_z: 177 camera->setRelCoor(camera->getRelCoor() - (camera->getTarget()->getAbsCoor() - camera->getAbsCoor())*.1); 178 break; 179 case SDLK_r: 180 camera->setAbsCoor(Vector(10, 10, 10)); 181 camera->getTarget()->setAbsCoor(Vector()); 182 break; 183 case SDLK_h: 184 this->printHelp(); 185 break; 186 case SDLK_2: 187 for (int i = 0; i < 3; i++) 188 { 189 backgroundColor[i] += .1; 190 if (backgroundColor[i] > 1.0) 191 backgroundColor[i] = 1.0; 192 GraphicsEngine::setBackgroundColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], backgroundColor[3]); 193 } 194 break; 195 case SDLK_1: 196 for (int i = 0; i < 3; i++) 197 { 198 backgroundColor[i] -= .1; 199 if (backgroundColor[i] < 0.0) 200 backgroundColor[i] = 0.0; 201 GraphicsEngine::setBackgroundColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], backgroundColor[3]); 202 } 203 break; 204 } 205 break; 206 207 207 // If a quit event was recieved 208 208 case SDL_QUIT: 209 210 #ifdef GUI_MODULE 211 209 // then we're done and we'll end this program 210 #ifdef GUI_MODULE 211 quitGui(NULL, NULL); 212 212 #else 213 214 #endif 215 213 this->quit(); 214 #endif 215 break; 216 216 default: 217 217 break; 218 218 } 219 219 … … 258 258 259 259 ResourceManager::getInstance()->setDataDir(DATA_DIRECTORY); 260 260 261 261 camera = new Camera(); 262 262 … … 292 292 PRINT(0)("mouse right button - rotate the camera's target around the camera\n"); 293 293 PRINT(0)("mouse left-and-right button - move the camera and the target\n"); 294 294 295 295 this->moduleHelp(); 296 296 … … 310 310 { 311 311 verbose = 3; 312 312 313 313 Framework* framework = Framework::getInstance(); 314 314 -
orxonox/trunk/src/subprojects/framework.h
r4546 r4554 1 1 #ifndef _FRAMEWORK_H 2 2 #define _FRAMEWORK_H 3 3 4 4 #include "vector.h" 5 5 #include "glincl.h" … … 9 9 #ifdef GUI_MODULE 10 10 #include "gui_gtk.h" 11 #endif 11 #endif 12 12 13 13 #define DATA_DIRECTORY "~/orxonox/repos/trunk/data/" … … 20 20 Framework(); 21 21 static Framework* singletonRef; 22 22 23 23 Camera* camera; 24 24 25 25 bool isFinished; 26 26 … … 30 30 Uint32 lastFrame; 31 31 Uint32 currFrame; 32 32 33 33 Uint8* keys; // This variable will be used in the keyboard routine 34 34 bool mouseDown[MOUSE_BUTTON_COUNT]; 35 35 36 36 public: 37 ~Framework(); 38 37 ~Framework(); 38 39 39 /** \returns a Pointer to the only object of this Class */ 40 40 inline static Framework* getInstance(void) { if (!singletonRef) singletonRef = new Framework(); return singletonRef; }; … … 48 48 void moduleTick(float dt); 49 49 void moduleDraw(void) const; 50 50 51 51 void moduleHelp(void) const; 52 52 -
orxonox/trunk/src/subprojects/gui/gui_main.cc
r4266 r4554 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 16 16 You should have received a copy of the GNU General Public License 17 17 along with this program; if not, write to the Free Software Foundation, 18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 19 20 20 -
orxonox/trunk/src/subprojects/importer/importer.cc
r4492 r4554 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 33 33 else if (argc>=2) 34 34 obj = new OBJModel(argv[1]); 35 else 35 else 36 36 obj = new PrimitiveModel(PRIM_CYLINDER); 37 37 … … 56 56 case SDL_KEYDOWN: 57 57 switch (event->key.keysym.sym) 58 59 60 61 58 { 59 case SDLK_i: 60 break; 61 } 62 62 } 63 63 } … … 65 65 void Framework::moduleTick(float dt) 66 66 { 67 67 68 68 } 69 69 … … 78 78 void Framework::moduleHelp(void) const 79 79 { 80 80 81 81 } -
orxonox/trunk/src/subprojects/particles/particle_fun.cc
r4392 r4554 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 84 84 case SDL_KEYDOWN: 85 85 switch (event->key.keysym.sym) 86 87 88 89 90 91 86 { 87 case SDLK_i: 88 ParticleEngine::getInstance()->debug(); 89 PhysicsEngine::getInstance()->debug(); 90 break; 91 } 92 92 } 93 93 } … … 122 122 { 123 123 if (!strcmp(name, "EmissionRate")) 124 125 126 127 124 { 125 tmpEmit->setEmissionRate(atof(value)); 126 PRINT(4)("EmissionRate set to %f\n", atof(value)); 127 } 128 128 else if (!strcmp(name, "Velocity")) 129 130 131 132 129 { 130 tmpEmit->setEmissionVelocity(atof(value)); 131 PRINT(4)("Velocity set to %f\n", atof(value)); 132 } 133 133 else if(!strcmp(name, "SpreadAngle")) 134 135 136 137 134 { 135 tmpEmit->setSpread(atof(value), 0); 136 PRINT(4)("SpreadAngle set to %f\n", atof(value)); 137 } 138 138 else if(!strcmp(name, "EmitterType")) 139 140 141 142 143 144 145 146 147 139 { 140 if (!strcmp(value, "EMITTER_DOT")) 141 tmpEmit->setType(EMITTER_DOT); 142 else if (!strcmp(value, "EMITTER_PLANE")) 143 tmpEmit->setType(EMITTER_PLANE); 144 else if (!strcmp(value, "EMITTER_CUBE")) 145 tmpEmit->setType(EMITTER_CUBE); 146 PRINT(4)("EmitterType set to %s\n", value); 147 } 148 148 else if(!strcmp(name, "EmitterSize")) 149 150 151 152 149 { 150 tmpEmit->setSize(atof(value)); 151 PRINT(4)("EmitterSize set to %f\n", atof(value)); 152 } 153 153 } 154 154 delete value; … … 166 166 { 167 167 if (!strcmp(name, "StartRadius")) 168 169 170 171 168 { 169 tmpSys->setRadius(atof(value), tmpSys->getEndRadius()); 170 PRINT(4)("ParticleStartRadius set to %f\n", atof(value)); 171 } 172 172 else if (!strcmp(name, "EndRadius")) 173 174 175 176 173 { 174 tmpSys->setRadius( tmpSys->getStartRadius(), atof(value)); 175 PRINT(4)("ParticleEndRadius set to %f\n", atof(value)); 176 } 177 177 178 178 else if (!strcmp(name, "LifeSpan")) 179 180 181 182 179 { 180 tmpSys->setLifeSpan(atof(value)); 181 PRINT(4)("ParticleLifeSpan set to %f\n", atof(value)); 182 } 183 183 184 184 else if (!strcmp(name, "Mass")) 185 186 187 188 185 { 186 tmpSys->setMass(atof(value)); 187 PRINT(4)("ParticleMass set to %f\n", atof(value)); 188 } 189 189 190 190 else if (!strcmp(name, "ConserveFactor")) 191 192 193 194 191 { 192 tmpSys->setConserve(atof(value)); 193 PRINT(4)("ParticleConserveFactor set to %f\n", atof(value)); 194 } 195 195 196 196 else if (!strcmp(name, "ParticleType")) 197 198 199 200 201 202 203 204 205 206 197 { 198 if (!strcmp(value, "PARTICLE_DOT")) 199 tmpSys->setType(PARTICLE_DOT); 200 else if (!strcmp(value, "PARTICLE_SPARK")) 201 tmpSys->setType(PARTICLE_SPARK); 202 else if (!strcmp(value, "PARTICLE_SPRITE")) 203 tmpSys->setType(PARTICLE_SPRITE); 204 205 PRINT(4)("ParticleType set to %s\n", value); 206 } 207 207 208 208 else if (!strcmp(name, "InheritSpeed")) 209 210 211 212 209 { 210 tmpSys->setInheritSpeed(atof(value)); 211 PRINT(4)("ParticleInheritSpeed set to %f\n", atof(value)); 212 } 213 213 else if (!strcmp(name, "RandomColor")) 214 215 tmpSys->setColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 1, 216 (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, .5, 217 218 214 { 215 tmpSys->setColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 1, 216 (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, .5, 217 (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 0); 218 } 219 219 } 220 220 delete value; … … 248 248 { 249 249 Window* guiMainWindow = NULL; 250 250 251 251 initGUI(0, NULL); 252 252 253 253 guiMainWindow = new Window("ParticlesFUN"); 254 254 { … … 257 257 Frame* emitterFrame = new Frame("emitter-settings"); 258 258 { 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 259 Box* emitterBox = new Box('v'); 260 { 261 emitterBox->fill(new Label("EmissionRate")); 262 Slider* EmissionRate = new Slider("EmissionRate", 0, 1000); 263 EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange ); 264 EmissionRate->setValue(PINIT_EMISSION_RATE); 265 EmissionRate->redraw(); 266 emitterBox->fill(EmissionRate); 267 268 emitterBox->fill(new Label("Velocity")); 269 Slider* velocity = new Slider("Velocity", 0, 20); 270 velocity->setExactness(2); 271 velocity->connectSignal("value_changed", (void*)velocity, emitterChange ); 272 velocity->setValue(PINIT_EMISSION_VELOCITY); 273 velocity->redraw(); 274 emitterBox->fill(velocity); 275 276 emitterBox->fill(new Label("SpreadAngle")); 277 Slider* SpreadAngle = new Slider("SpreadAngle", 0, M_PI); 278 SpreadAngle->setExactness(3); 279 SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange ); 280 SpreadAngle->setValue(PINIT_SPREAD_ANGLE); 281 SpreadAngle->redraw(); 282 emitterBox->fill(SpreadAngle); 283 284 emitterBox->fill(new Label("EmitterType")); 285 Menu* EmitterType = new Menu("EmitterType"); 286 EmitterType->addItem("EMITTER_DOT"); 287 EmitterType->addItem("EMITTER_PLANE"); 288 EmitterType->addItem("EMITTER_CUBE"); 289 EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange ); 290 EmitterType->load("EMITTER_DOT"); 291 emitterBox->fill(EmitterType); 292 293 emitterBox->fill(new Label("EmitterSize")); 294 Slider* EmitterSize = new Slider("EmitterSize", 0, 100); 295 EmitterSize->setExactness(1); 296 EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange ); 297 EmitterSize->setValue(PINIT_EMITTER_SIZE); 298 EmitterSize->redraw(); 299 emitterBox->fill(EmitterSize); 300 } 301 emitterFrame->fill(emitterBox); 302 302 } 303 303 windowBox->fill(emitterFrame); 304 304 305 305 Frame* systemFrame = new Frame("system-settings"); 306 306 { 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 ParticleType->connectSignal("changed", (void*)ParticleType, systemChange ); 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 307 Box* systemBox = new Box('v'); 308 { 309 systemBox->fill(new Label("StartRadius")); 310 Slider* StartRadius = new Slider("StartRadius", 0, 10); 311 StartRadius->setExactness(3); 312 StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange ); 313 StartRadius->setValue(PINIT_START_RADIUS); 314 StartRadius->redraw(); 315 systemBox->fill(StartRadius); 316 317 systemBox->fill(new Label("EndRadius")); 318 Slider* EndRadius = new Slider("EndRadius", 0, 10); 319 EndRadius->setExactness(3); 320 EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange ); 321 EndRadius->setValue(PINIT_END_RADIUS); 322 EndRadius->redraw(); 323 systemBox->fill(EndRadius); 324 325 systemBox->fill(new Label("ParticleMass")); 326 Slider* Mass = new Slider("Mass", 0, 10); 327 Mass->setExactness(2); 328 Mass->connectSignal("value_changed", (void*)Mass, systemChange ); 329 Mass->setValue(PINIT_PARTICLE_MASS); 330 Mass->redraw(); 331 systemBox->fill(Mass); 332 333 334 systemBox->fill(new Label("LifeSpan")); 335 Slider* LifeSpan = new Slider("LifeSpan", 0, 10); 336 LifeSpan->setExactness(3); 337 LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange ); 338 LifeSpan->setValue(PINIT_LIFESPAN); 339 LifeSpan->redraw(); 340 systemBox->fill(LifeSpan); 341 342 systemBox->fill(new Label("ConserveFactor")); 343 Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1); 344 ConserveFactor->setExactness(3); 345 ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange ); 346 ConserveFactor->setValue(PINIT_CONSERVE_FACTOR); 347 ConserveFactor->redraw(); 348 systemBox->fill(ConserveFactor); 349 350 systemBox->fill(new Label("ParticleType")); 351 Menu* ParticleType = new Menu("ParticleType"); 352 ParticleType->addItem("PARTICLE_DOT"); 353 ParticleType->addItem("PARTICLE_SPARK"); 354 ParticleType->addItem("PARTICLE_SPRITE"); 355 ParticleType->connectSignal("changed", (void*)ParticleType, systemChange ); 356 ParticleType->load("PARTICLE_SPRITE"); 357 systemBox->fill(ParticleType); 358 359 systemBox->fill(new Label("InheritSpeed")); 360 Slider* InheritSpeed = new Slider("InheritSpeed", 0, 1); 361 InheritSpeed->setExactness(3); 362 InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, systemChange ); 363 systemBox->fill(InheritSpeed); 364 365 Button* RandomColor = new Button("RandomColor"); 366 RandomColor->connectSignal("released", (void*)RandomColor, systemChange); 367 systemBox->fill(RandomColor); 368 369 } 370 systemFrame->fill(systemBox); 371 371 } 372 372 windowBox->fill(systemFrame); … … 374 374 Frame* fieldsFrame = new Frame("Field-Settings"); 375 375 { 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 376 Box* fieldsBox = new Box('v'); 377 { 378 fieldsBox->fill(new Label("Gravity")); 379 Slider* Gravity = new Slider("Gravity", 0, 10); 380 Gravity->setExactness(1); 381 Gravity->connectSignal("value_changed", (void*)Gravity, fieldsChange ); 382 Gravity->setValue(0); 383 Gravity->redraw(); 384 fieldsBox->fill(Gravity); 385 386 387 fieldsBox->fill(new Label("Twirl")); 388 Slider* Twirl = new Slider("Twirl", 0, 10); 389 Twirl->setExactness(1); 390 Twirl->connectSignal("value_changed", (void*)Twirl, fieldsChange ); 391 Twirl->setValue(0); 392 Twirl->redraw(); 393 fieldsBox->fill(Twirl); 394 395 396 fieldsBox->fill(new Label("PointGravity")); 397 Slider* PointGravity = new Slider("PointGravity", 0, 10); 398 PointGravity->setExactness(1); 399 PointGravity->connectSignal("value_changed", (void*)PointGravity, fieldsChange ); 400 PointGravity->setValue(0); 401 PointGravity->redraw(); 402 fieldsBox->fill(PointGravity); 403 404 } 405 fieldsFrame->fill(fieldsBox); 406 406 } 407 407 windowBox->fill(fieldsFrame); 408 408 409 409 Button* quitButton = new Button("quit"); 410 410 411 411 quitButton->connectSignal("clicked", NULL, quitGui); 412 412 // Window::mainWindow->connectSignal("remove", this, GuiExec::quitGui); 413 413 Window::mainWindow->connectSignal("destroy", NULL, quitGui); 414 414 windowBox->fill(quitButton); 415 415 416 416 } 417 417 guiMainWindow->fill(windowBox);
Note: See TracChangeset
for help on using the changeset viewer.