- Timestamp:
- May 27, 2005, 12:31:47 PM (20 years ago)
- Location:
- orxonox/branches/physics/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/lib/graphics/particles/particle_system.cc
r4293 r4330 115 115 this->particleType = particleType; 116 116 this->dialectCount = count; 117 if (glID != NULL) 118 delete glID; 119 120 glID = new GLuint[count]; 121 for (int i = 0; i< count; i++) 122 glID[i] = 0; 123 124 glID[0] = glGenLists(count); 125 126 material = new Material("transperencyMap"); 127 material->setDiffuseMap("pictures/radialTransparency.png"); 128 // material->setTransparency(.5); 129 130 glNewList(glID[0], GL_COMPILE); 131 glBegin(GL_TRIANGLE_STRIP); 132 glTexCoord2f(1, 1); 133 glVertex3f(0.0, .5, .5); 134 glTexCoord2f(1, 0); 135 glVertex3f(0.0, -.5, .5); 136 glTexCoord2f(0, 1); 137 glVertex3f(0.0, .5, -.5); 138 glTexCoord2f(0, 0); 139 glVertex3f(0.0, -.5, -.5); 140 glEnd(); 141 glEndList(); 117 // if (glID != NULL) 118 // delete glID; 119 120 // glID = new GLuint[count]; 121 // for (int i = 0; i< count; i++) 122 // glID[i] = 0; 123 124 // glID[0] = glGenLists(count); 125 if (material) 126 delete material; 127 material = NULL; 128 129 if (particleType == PARTICLE_SPRITE) 130 { 131 material = new Material("transperencyMap"); 132 material->setDiffuseMap("pictures/radialTransparency.png"); 133 // material->setTransparency(.5); 134 } 142 135 } 143 136 -
orxonox/branches/physics/src/subprojects/particles/Makefile.in
r4316 r4330 67 67 particles-null_parent.$(OBJEXT) particles-gui_gtk.$(OBJEXT) 68 68 particles_OBJECTS = $(am_particles_OBJECTS) 69 particles_DEPENDENCIES = $(MAINSRCDIR)/lib/physics/libORXphysics.a 69 am__DEPENDENCIES_1 = 70 particles_DEPENDENCIES = $(MAINSRCDIR)/lib/physics/libORXphysics.a \ 71 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) 70 72 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) 71 73 depcomp = $(SHELL) $(top_srcdir)/depcomp … … 213 215 MAINSRCDIR = ../.. 214 216 AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/coord -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/graphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/graphics/particles -I$(MAINSRCDIR)/lib/gui -I$(MAINSRCDIR)/lib/gui/gui -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/lib/physics -I$(MAINSRCDIR)/lib/physics/fields -I$(MAINSRCDIR)/lib/tinyxml -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai -I$(MAINSRCDIR)/util -I$(MAINSRCDIR)/util/animation -I$(MAINSRCDIR)/util/common -I$(MAINSRCDIR)/util/loading -I$(MAINSRCDIR)/util/track -I$(MAINSRCDIR)/subprojects 215 AM_LDFLAGS = $(MWINDOWS)\216 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)217 218 particles_LDADD = $(MAINSRCDIR)/lib/physics/libORXphysics.a 217 particles_LDADD = $(MAINSRCDIR)/lib/physics/libORXphysics.a \ 218 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \ 219 -lpthread 220 219 221 particles_CPPFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 220 222 particles_SOURCES = framework.cc \ -
orxonox/branches/physics/src/subprojects/particles/framework.cc
r4327 r4330 33 33 int verbose; 34 34 35 pthread_mutex_t mutex; 36 37 38 35 39 void Framework::initModule() 36 40 { … … 52 56 } 53 57 54 bool Framework::mainLoop() 55 { 58 void* Framework::mainLoop(void* tmp) 59 { 60 Framework* framework = Framework::getInstance(); 56 61 while(true) 57 62 { 58 63 // keyhandler returns false if sdl gets quit by some event 59 if (! this->keyHandler())60 return false;64 if (!framework->keyHandler()) 65 pthread_exit(NULL); 61 66 62 67 // tick the scene 63 float dt = this->tick();68 float dt = framework->tick(); 64 69 65 70 // Draw the scene 66 this->draw(dt); 71 pthread_mutex_lock (&mutex); 72 framework->draw(dt); 73 pthread_mutex_unlock (&mutex); 67 74 } 68 75 } … … 174 181 this->printHelp(); 175 182 break; 176 177 case SDLK_1:178 {179 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);180 if (tmpEmit)181 {182 tmpEmit->setEmissionRate(tmpEmit->getEmissionRate() +1.0);183 PRINT(3)("emissionRate set to %f\n", tmpEmit->getEmissionRate());184 }185 }186 break;187 case SDLK_2:188 {189 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);190 if (tmpEmit)191 {192 tmpEmit->setEmissionRate(tmpEmit->getEmissionRate() -1.0);193 PRINT(3)("emissionRate set to %f\n", tmpEmit->getEmissionRate());194 }195 }196 break;197 case SDLK_3:198 {199 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);200 if (tmpEmit)201 {202 tmpEmit->setEmissionVelocity(tmpEmit->getEmissionVelocity() -.01);203 PRINT(3)("emissionVelocity set to %f\n", tmpEmit->getEmissionVelocity());204 }205 }206 break;207 case SDLK_4:208 {209 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);210 if (tmpEmit)211 {212 tmpEmit->setEmissionVelocity(tmpEmit->getEmissionVelocity() + .01);213 PRINT(3)("emissionVelocity set to %f\n", tmpEmit->getEmissionVelocity());214 }215 }216 break;217 case SDLK_5:218 {219 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);220 if (tmpEmit)221 {222 tmpEmit->setSpread(tmpEmit->getSpread() +.1);223 PRINT(3)("emissionSpreadAngle set to %f\n", tmpEmit->getSpread());224 }225 }226 break;227 case SDLK_6:228 {229 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);230 if (tmpEmit)231 {232 tmpEmit->setSpread(tmpEmit->getSpread() -.1);233 PRINT(3)("emissionSpreadAngle set to %f\n", tmpEmit->getSpread());234 }235 }236 break;237 case SDLK_7:238 {239 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);240 if (tmpEmit)241 {242 tmpEmit->setSize(tmpEmit->getSize() - 1.0);243 PRINT(3)("EmitterSize set to %f\n", tmpEmit->getSize());244 }245 }246 break;247 case SDLK_8:248 {249 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);250 if (tmpEmit)251 {252 tmpEmit->setSize(tmpEmit->getSize() +1.0);253 PRINT(3)("EmitterSize set to %f\n", tmpEmit->getSize());254 }255 }256 break;257 case SDLK_9:258 {259 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);260 if (tmpEmit)261 {262 if (tmpEmit->getType() == EMITTER_DOT)263 tmpEmit->setType(EMITTER_PLANE);264 else if (tmpEmit->getType() == EMITTER_PLANE)265 tmpEmit->setType(EMITTER_CUBE);266 else if (tmpEmit->getType() == EMITTER_CUBE)267 tmpEmit->setType(EMITTER_DOT);268 PRINT(3)("EmitterType set to %d\n", tmpEmit->getType());269 }270 }271 break;272 273 183 } 274 184 break; … … 347 257 PRINT(0)("h - print thisHelp\n"); 348 258 PRINT(0)("i - state Information\n\n"); 349 PRINT(0)("Emitter Properties\n");350 PRINT(0)("1,2 - increase/decrease emissionRate\n");351 PRINT(0)("3,4 - increase/decrease emission velocity\n");352 PRINT(0)("5,6 - increase/decrease spread angle\n");353 PRINT(0)("7,8 - increase-decrease emitter-size\n");354 PRINT(0)("9 - swap emitterType\n");355 259 PRINT(0)("\n"); 356 260 … … 358 262 } 359 263 360 int changeOption(GtkWidget* nonInterest, void* widget)264 int emitterChange(GtkWidget* nonInterest, void* widget) 361 265 { 362 266 Option* option = (Option*) widget; … … 399 303 } 400 304 } 305 delete valueC; 306 } 307 308 309 int systemChange(GtkWidget* nonInterest, void* widget) 310 { 311 Option* option = (Option*) widget; 312 const char* name = option->getTitle(); 313 char* valueC = option->save(); 314 float value = atof(valueC); 401 315 402 316 ParticleSystem* tmpSys = ParticleEngine::getInstance()->getSystemByNumber(1); … … 435 349 tmpSys->setType(PARTICLE_SPRITE); 436 350 437 PRINT(3)("ParticleType set to % f\n", valueC);351 PRINT(3)("ParticleType set to %s\n", valueC); 438 352 } 439 353 … … 445 359 446 360 } 447 448 361 delete valueC; 449 362 } 450 363 364 365 int quitGui(GtkWidget* widget, void* data) 366 { 367 #ifdef HAVE_GTK2 368 gtk_main_quit(); 369 while(gtk_events_pending()) gtk_main_iteration(); 370 #endif /* HAVE_GTK2 */ 371 } 451 372 452 373 void* Framework::initGui(void* argv) … … 466 387 emitterBox->fill(new Label("EmissionRate")); 467 388 Slider* EmissionRate = new Slider("EmissionRate", 0, 1000); 468 EmissionRate->connectSignal("value_changed", (void*)EmissionRate, changeOption);389 EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange ); 469 390 emitterBox->fill(EmissionRate); 470 391 … … 472 393 Slider* velocity = new Slider("Velocity", 0, 2); 473 394 velocity->setExactness(3); 474 velocity->connectSignal("value_changed", (void*)velocity, changeOption);395 velocity->connectSignal("value_changed", (void*)velocity, emitterChange ); 475 396 emitterBox->fill(velocity); 476 397 … … 478 399 Slider* SpreadAngle = new Slider("SpreadAngle", 0, M_PI); 479 400 SpreadAngle->setExactness(3); 480 SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, changeOption);401 SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange ); 481 402 emitterBox->fill(SpreadAngle); 482 403 … … 486 407 EmitterType->addItem("EMITTER_PLANE"); 487 408 EmitterType->addItem("EMITTER_CUBE"); 488 EmitterType->connectSignal("changed", (void*)EmitterType, changeOption);409 EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange ); 489 410 emitterBox->fill(EmitterType); 490 411 … … 492 413 Slider* EmitterSize = new Slider("EmitterSize", 0, 100); 493 414 EmitterSize->setExactness(1); 494 EmitterSize->connectSignal("value_changed", (void*)EmitterSize, changeOption);415 EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange ); 495 416 emitterBox->fill(EmitterSize); 496 417 } … … 506 427 Slider* StartRadius = new Slider("StartRadius", 0, 10); 507 428 StartRadius->setExactness(3); 508 StartRadius->connectSignal("value_changed", (void*)StartRadius, changeOption);429 StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange ); 509 430 systemBox->fill(StartRadius); 510 431 … … 512 433 Slider* EndRadius = new Slider("EndRadius", 0, 10); 513 434 EndRadius->setExactness(3); 514 EndRadius->connectSignal("value_changed", (void*)EndRadius, changeOption);435 EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange ); 515 436 systemBox->fill(EndRadius); 516 437 … … 518 439 Slider* LifeSpan = new Slider("LifeSpan", 0, 10); 519 440 LifeSpan->setExactness(3); 520 LifeSpan->connectSignal("value_changed", (void*)LifeSpan, changeOption);441 LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange ); 521 442 systemBox->fill(LifeSpan); 522 443 … … 524 445 Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1); 525 446 ConserveFactor->setExactness(3); 526 ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, changeOption);447 ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange ); 527 448 systemBox->fill(ConserveFactor); 528 449 … … 532 453 ParticleType->addItem("PARTICLE_SPARK"); 533 454 ParticleType->addItem("PARTICLE_SPRITE"); 534 ParticleType->connectSignal("changed", (void*)ParticleType, changeOption);455 ParticleType->connectSignal("changed", (void*)ParticleType, systemChange ); 535 456 systemBox->fill(ParticleType); 536 457 … … 538 459 Slider* InheritSpeed = new Slider("InheritSpeed", 0, 1); 539 460 InheritSpeed->setExactness(3); 540 InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, changeOption);461 InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, systemChange ); 541 462 systemBox->fill(InheritSpeed); 542 463 … … 549 470 Button* quitButton = new Button("quit"); 550 471 472 quitButton->connectSignal("clicked", NULL, quitGui); 473 // Window::mainWindow->connectSignal("remove", this, GuiExec::quitGui); 474 Window::mainWindow->connectSignal("destroy", NULL, quitGui); 551 475 552 476 windowBox->fill(quitButton); … … 556 480 Window::mainWindow->showall(); 557 481 Window::mainWindow->setSize(300, 500); 482 } 483 484 void* Framework::mainloopGui(void* tmp) 485 { 558 486 mainloopGUI(); 559 487 } … … 565 493 verbose = 3; 566 494 pthread_t guiThread; 495 pthread_t openglThread; 496 pthread_attr_t attr; 497 int status; 498 499 pthread_mutex_init(&mutex, NULL); 500 501 /* Create threads to perform the dotproduct */ 502 pthread_attr_init(&attr); 503 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); 504 505 506 567 507 568 508 Framework* framework = Framework::getInstance(); 569 509 570 pthread_create(&guiThread, NULL, Framework::initGui,(void*) argv); 510 framework->initGui((void*)argv); 511 pthread_create(&guiThread, &attr, Framework::mainloopGui ,(void*) argv); 571 512 // framework->initGui(argv); 572 513 573 framework->mainLoop(); 514 pthread_create(&openglThread, &attr, Framework::mainLoop, NULL); 515 516 pthread_attr_destroy(&attr); 517 518 pthread_join( guiThread, (void **)&status); 519 pthread_join( openglThread, (void **)&status); 574 520 575 521 delete framework; -
orxonox/branches/physics/src/subprojects/particles/framework.h
r4317 r4330 33 33 34 34 void initModule(); 35 bool mainLoop();35 static void* mainLoop(void* tmp); 36 36 bool draw(float dt); 37 37 float tick(); 38 38 bool keyHandler(); 39 39 40 static void* initGui(void* argv); 40 void* initGui(void* argv); 41 static void* mainloopGui(void* tmp); 41 42 42 43 void printHelp(void) const; 43 44 }; 45 44 46 #endif /* _FRAMEWORK_H */
Note: See TracChangeset
for help on using the changeset viewer.