Changeset 4333 in orxonox.OLD for orxonox/branches/physics/src/subprojects/particles/framework.cc
- Timestamp:
- May 27, 2005, 7:40:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/subprojects/particles/framework.cc
r4331 r4333 16 16 #include "framework.h" 17 17 18 #include "physics_engine.h" 19 #include "particle_engine.h" 20 21 #include "gui_gtk.h" 18 22 19 #include "p_node.h" 23 20 #include "null_parent.h" … … 32 29 int verbose; 33 30 34 int quitGui(GtkWidget* widget, void* data);35 36 37 void Framework::initModule()38 {39 // Creating a Test Particle System40 ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE);41 42 // Creating a Test Particle Emitter43 ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0));44 // Add the Flow from the Emitter into the System45 ParticleEngine::getInstance()->addConnection(emitter, system);46 }47 48 31 void* Framework::mainLoop(void* tmp) 49 32 { … … 60 43 float dt = framework->tick(); 61 44 45 NullParent::getInstance()->update(dt); 46 62 47 // Draw the scene 63 48 framework->draw(dt); … … 71 56 glLoadIdentity(); // Reset the view 72 57 73 ParticleEngine::getInstance()->draw(dt);74 58 this->moduleDraw(dt); 59 75 60 camera->apply(); 76 61 … … 85 70 lastFrame = currFrame; 86 71 87 ParticleEngine::getInstance()->tick(dt); 88 89 NullParent::getInstance()->update(dt); 72 this->moduleTick(dt); 73 90 74 return dt; 91 75 } … … 161 145 break; 162 146 case SDLK_i: 163 ParticleEngine::getInstance()->debug();147 // ParticleEngine::getInstance()->debug(); 164 148 break; 165 149 case SDLK_a: … … 231 215 232 216 233 initModule();217 moduleInit(); 234 218 235 219 camera = new Camera(); … … 238 222 239 223 camera->setAbsCoor(Vector(10, 10, 0)); 240 241 224 } 242 225 … … 254 237 PRINT(0)("========================\n"); 255 238 PRINT(0)("h - print thisHelp\n"); 256 PRINT(0)("i - state Information\n\n"); 257 PRINT(0)("\n"); 258 259 260 } 261 262 int emitterChange(GtkWidget* nonInterest, void* widget) 263 { 264 Option* option = (Option*) widget; 265 const char* name = option->getTitle(); 266 char* valueC = option->save(); 267 float value = atof(valueC); 268 269 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1); 270 if (tmpEmit) 271 { 272 if (!strcmp(name, "EmissionRate")) 273 { 274 tmpEmit->setEmissionRate(value); 275 PRINT(3)("EmissionRate set to %f\n", value); 276 } 277 else if (!strcmp(name, "Velocity")) 278 { 279 tmpEmit->setEmissionVelocity(value); 280 PRINT(3)("Velocity set to %f\n", value); 281 } 282 else if(!strcmp(name, "SpreadAngle")) 283 { 284 tmpEmit->setSpread(value); 285 PRINT(3)("SpreadAngle set to %f\n", value); 286 } 287 else if(!strcmp(name, "EmitterType")) 288 { 289 if (!strcmp(valueC, "EMITTER_DOT")) 290 tmpEmit->setType(EMITTER_DOT); 291 else if (!strcmp(valueC, "EMITTER_PLANE")) 292 tmpEmit->setType(EMITTER_PLANE); 293 else if (!strcmp(valueC, "EMITTER_CUBE")) 294 tmpEmit->setType(EMITTER_CUBE); 295 PRINT(3)("EmitterType set to %s\n", valueC); 296 } 297 else if(!strcmp(name, "EmitterSize")) 298 { 299 tmpEmit->setSize(value); 300 PRINT(3)("EmitterSize set to %f\n", value); 301 } 302 } 303 delete valueC; 304 } 305 306 307 int systemChange(GtkWidget* nonInterest, void* widget) 308 { 309 Option* option = (Option*) widget; 310 const char* name = option->getTitle(); 311 char* valueC = option->save(); 312 float value = atof(valueC); 313 314 ParticleSystem* tmpSys = ParticleEngine::getInstance()->getSystemByNumber(1); 315 if (tmpSys) 316 { 317 if (!strcmp(name, "StartRadius")) 318 { 319 tmpSys->setRadius(value, tmpSys->getEndRadius()); 320 PRINT(3)("ParticleStartRadius set to %f\n", value); 321 } 322 else if (!strcmp(name, "EndRadius")) 323 { 324 tmpSys->setRadius( tmpSys->getStartRadius(), value); 325 PRINT(3)("ParticleEndRadius set to %f\n", value); 326 } 327 328 else if (!strcmp(name, "LifeSpan")) 329 { 330 tmpSys->setLifeSpan(value); 331 PRINT(3)("ParticleLifeSpan set to %f\n", value); 332 } 333 334 else if (!strcmp(name, "ConserveFactor")) 335 { 336 tmpSys->setConserve(value); 337 PRINT(3)("ParticleConserveFactor set to %f\n", value); 338 } 339 340 else if (!strcmp(name, "ParticleType")) 341 { 342 if (!strcmp(valueC, "PARTICLE_DOT")) 343 tmpSys->setType(PARTICLE_DOT); 344 else if (!strcmp(valueC, "PARTICLE_SPARK")) 345 tmpSys->setType(PARTICLE_SPARK); 346 else if (!strcmp(valueC, "PARTICLE_SPRITE")) 347 tmpSys->setType(PARTICLE_SPRITE); 348 349 PRINT(3)("ParticleType set to %s\n", valueC); 350 } 351 352 else if (!strcmp(name, "InheritSpeed")) 353 { 354 tmpSys->setInheritSpeed(value); 355 PRINT(3)("ParticleInheritSpeed set to %f\n", value); 356 } 357 358 } 359 delete valueC; 360 } 361 239 240 this->moduleHelp(); 241 242 } 362 243 363 244 int quitGui(GtkWidget* widget, void* data) … … 370 251 } 371 252 372 void* Framework::initGui(void* argv)373 {374 Window* guiMainWindow = NULL;375 376 initGUI(0, NULL);377 378 guiMainWindow = new Window("ParticlesFUN");379 {380 Box* windowBox = new Box('v');381 {382 Frame* emitterFrame = new Frame("emitter-settings");383 {384 Box* emitterBox = new Box('v');385 {386 emitterBox->fill(new Label("EmissionRate"));387 Slider* EmissionRate = new Slider("EmissionRate", 0, 1000);388 EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange );389 emitterBox->fill(EmissionRate);390 391 emitterBox->fill(new Label("Velocity"));392 Slider* velocity = new Slider("Velocity", 0, 2);393 velocity->setExactness(3);394 velocity->connectSignal("value_changed", (void*)velocity, emitterChange );395 emitterBox->fill(velocity);396 397 emitterBox->fill(new Label("SpreadAngle"));398 Slider* SpreadAngle = new Slider("SpreadAngle", 0, M_PI);399 SpreadAngle->setExactness(3);400 SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange );401 emitterBox->fill(SpreadAngle);402 403 emitterBox->fill(new Label("EmitterType"));404 Menu* EmitterType = new Menu("EmitterType");405 EmitterType->addItem("EMITTER_DOT");406 EmitterType->addItem("EMITTER_PLANE");407 EmitterType->addItem("EMITTER_CUBE");408 EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange );409 emitterBox->fill(EmitterType);410 411 emitterBox->fill(new Label("EmitterSize"));412 Slider* EmitterSize = new Slider("EmitterSize", 0, 100);413 EmitterSize->setExactness(1);414 EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange );415 emitterBox->fill(EmitterSize);416 }417 emitterFrame->fill(emitterBox);418 }419 windowBox->fill(emitterFrame);420 421 Frame* systemFrame = new Frame("system-settings");422 {423 Box* systemBox = new Box('v');424 {425 systemBox->fill(new Label("StartRadius"));426 Slider* StartRadius = new Slider("StartRadius", 0, 10);427 StartRadius->setExactness(3);428 StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange );429 systemBox->fill(StartRadius);430 431 systemBox->fill(new Label("EndRadius"));432 Slider* EndRadius = new Slider("EndRadius", 0, 10);433 EndRadius->setExactness(3);434 EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange );435 systemBox->fill(EndRadius);436 437 systemBox->fill(new Label("LifeSpan"));438 Slider* LifeSpan = new Slider("LifeSpan", 0, 10);439 LifeSpan->setExactness(3);440 LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange );441 systemBox->fill(LifeSpan);442 443 systemBox->fill(new Label("ConserveFactor"));444 Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1);445 ConserveFactor->setExactness(3);446 ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange );447 systemBox->fill(ConserveFactor);448 449 systemBox->fill(new Label("ParticleType"));450 Menu* ParticleType = new Menu("ParticleType");451 ParticleType->addItem("PARTICLE_DOT");452 ParticleType->addItem("PARTICLE_SPARK");453 ParticleType->addItem("PARTICLE_SPRITE");454 ParticleType->connectSignal("changed", (void*)ParticleType, systemChange );455 systemBox->fill(ParticleType);456 457 systemBox->fill(new Label("InheritSpeed"));458 Slider* InheritSpeed = new Slider("InheritSpeed", 0, 1);459 InheritSpeed->setExactness(3);460 InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, systemChange );461 systemBox->fill(InheritSpeed);462 463 464 }465 systemFrame->fill(systemBox);466 }467 windowBox->fill(systemFrame);468 469 Button* quitButton = new Button("quit");470 471 quitButton->connectSignal("clicked", NULL, quitGui);472 // Window::mainWindow->connectSignal("remove", this, GuiExec::quitGui);473 Window::mainWindow->connectSignal("destroy", NULL, quitGui);474 475 windowBox->fill(quitButton);476 }477 guiMainWindow->fill(windowBox);478 }479 Window::mainWindow->showall();480 Window::mainWindow->setSize(300, 500);481 }482 483 void* Framework::mainloopGui(void* tmp)484 {485 mainloopGUI();486 }487 488 489 253 490 254 int main(int argc, char *argv[]) … … 494 258 Framework* framework = Framework::getInstance(); 495 259 496 framework-> initGui((void*)argv);260 framework->moduleInitGui(); 497 261 // framework->mainloopGui(NULL); 498 262 499 263 framework->mainLoop(NULL); 500 501 264 502 265 delete framework;
Note: See TracChangeset
for help on using the changeset viewer.