[4554] | 1 | /* |
---|
[4333] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
| 14 | |
---|
| 15 | this file extends the framework file, so it renders what i want. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #include "framework.h" |
---|
| 19 | |
---|
| 20 | #include "physics_engine.h" |
---|
| 21 | #include "particle_engine.h" |
---|
[4378] | 22 | #include "fields.h" |
---|
[4381] | 23 | #include "stdlibincl.h" |
---|
[4649] | 24 | #include "graphics_engine.h" |
---|
[4667] | 25 | #include "light.h" |
---|
[7193] | 26 | #include "util/loading/resource_manager.h" |
---|
[4333] | 27 | |
---|
[4666] | 28 | #include <dirent.h> |
---|
| 29 | |
---|
[4351] | 30 | #define PINIT_EMISSION_RATE 50 |
---|
| 31 | #define PINIT_EMISSION_VELOCITY 5.0 |
---|
[4692] | 32 | #define PINIT_EMISSION_MOMENTUM 1.0 |
---|
[4351] | 33 | #define PINIT_SPREAD_ANGLE 0.1 |
---|
| 34 | #define PINIT_EMITTER_TYPE EMITTER_DOT |
---|
| 35 | #define PINIT_EMITTER_SIZE 1.0 |
---|
| 36 | #define PINIT_START_RADIUS 5.0 |
---|
| 37 | #define PINIT_END_RADIUS 0.0 |
---|
| 38 | #define PINIT_LIFESPAN 1.0 |
---|
| 39 | #define PINIT_CONSERVE_FACTOR 1.0 |
---|
| 40 | #define PINIT_PARTICLE_TYPE PARTICLE_SPRITE |
---|
| 41 | #define PINIT_INHERIT_SPEED 0.0 |
---|
[4378] | 42 | #define PINIT_PARTICLE_MASS 1.0 |
---|
[4666] | 43 | #define PINIT_MODEL_DIRECTORY "models/" |
---|
[4333] | 44 | |
---|
[4379] | 45 | |
---|
| 46 | Field* twirl; |
---|
| 47 | Field* gravity; |
---|
| 48 | Field* pointGravity; |
---|
| 49 | |
---|
[4343] | 50 | void Framework::moduleInit(int argc, char** argv) |
---|
[4333] | 51 | { |
---|
[4649] | 52 | GraphicsEngine::getInstance()->setWindowName("ParticlesFun", "particles"); |
---|
| 53 | |
---|
[4356] | 54 | verbose = 5; |
---|
[4378] | 55 | ParticleEngine::getInstance(); |
---|
| 56 | PhysicsEngine::getInstance(); |
---|
[4356] | 57 | |
---|
[4378] | 58 | |
---|
[4333] | 59 | // Creating a Test Particle System |
---|
[4639] | 60 | |
---|
[4351] | 61 | ParticleSystem* system = new ParticleSystem(100000, PINIT_PARTICLE_TYPE); |
---|
[4637] | 62 | system->setRadius(0, PINIT_START_RADIUS, 0 ); |
---|
| 63 | system->setRadius(1, PINIT_END_RADIUS, 0 ); |
---|
[4351] | 64 | system->setLifeSpan(PINIT_LIFESPAN); |
---|
[4555] | 65 | |
---|
[4351] | 66 | system->setConserve(PINIT_CONSERVE_FACTOR); |
---|
[4639] | 67 | //system->setMass(5,3,6); |
---|
[4333] | 68 | |
---|
| 69 | // Creating a Test Particle Emitter |
---|
| 70 | ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0)); |
---|
[4351] | 71 | emitter->setEmissionRate(PINIT_EMISSION_RATE); |
---|
| 72 | emitter->setEmissionVelocity(PINIT_EMISSION_VELOCITY ,0); |
---|
| 73 | emitter->setSpread(PINIT_SPREAD_ANGLE ,0); |
---|
| 74 | emitter->setType(PINIT_EMITTER_TYPE); |
---|
| 75 | emitter->setSize(PINIT_EMITTER_SIZE); |
---|
[4379] | 76 | emitter->setAbsCoor(Vector(3,0,0)); |
---|
[4333] | 77 | // Add the Flow from the Emitter into the System |
---|
| 78 | ParticleEngine::getInstance()->addConnection(emitter, system); |
---|
[4378] | 79 | |
---|
| 80 | |
---|
[4379] | 81 | twirl = new Twirl(); |
---|
[4383] | 82 | twirl->setMagnitude(0); |
---|
[4379] | 83 | gravity = new Gravity(); |
---|
[4383] | 84 | gravity->setMagnitude(0); |
---|
[4379] | 85 | pointGravity = new PointGravity(); |
---|
[4383] | 86 | pointGravity->setMagnitude(0); |
---|
| 87 | |
---|
| 88 | new PhysicsConnection(system, gravity); |
---|
| 89 | new PhysicsConnection(system, twirl); |
---|
| 90 | new PhysicsConnection(system, pointGravity); |
---|
[4667] | 91 | |
---|
[4741] | 92 | (new Light)->setAbsCoor(10, 10, 10); |
---|
[4667] | 93 | |
---|
[4333] | 94 | } |
---|
| 95 | |
---|
[4334] | 96 | void Framework::moduleEventHandler(SDL_Event* event) |
---|
| 97 | { |
---|
| 98 | switch (event->type) |
---|
| 99 | { |
---|
| 100 | case SDL_KEYDOWN: |
---|
| 101 | switch (event->key.keysym.sym) |
---|
[4554] | 102 | { |
---|
| 103 | case SDLK_i: |
---|
| 104 | ParticleEngine::getInstance()->debug(); |
---|
| 105 | PhysicsEngine::getInstance()->debug(); |
---|
| 106 | break; |
---|
| 107 | } |
---|
[4334] | 108 | } |
---|
[4333] | 109 | } |
---|
| 110 | |
---|
| 111 | void Framework::moduleTick(float dt) |
---|
| 112 | { |
---|
[4378] | 113 | PhysicsEngine::getInstance()->tick(dt); |
---|
[4333] | 114 | ParticleEngine::getInstance()->tick(dt); |
---|
| 115 | } |
---|
| 116 | |
---|
[4349] | 117 | void Framework::moduleDraw() const |
---|
[4334] | 118 | { |
---|
[4349] | 119 | ParticleEngine::getInstance()->draw(); |
---|
[4334] | 120 | } |
---|
[4333] | 121 | |
---|
[4334] | 122 | |
---|
[4333] | 123 | void Framework::moduleHelp(void) const |
---|
| 124 | { |
---|
| 125 | PRINT(0)("\n"); |
---|
[4336] | 126 | PRINT(0)("i - Particle-state Information\n\n"); |
---|
| 127 | PRINT(0)("\n"); |
---|
[4333] | 128 | } |
---|
| 129 | |
---|
| 130 | int emitterChange(GtkWidget* nonInterest, void* widget) |
---|
| 131 | { |
---|
| 132 | Option* option = (Option*) widget; |
---|
| 133 | const char* name = option->getTitle(); |
---|
[4336] | 134 | char* value = option->save(); |
---|
[4333] | 135 | |
---|
| 136 | ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1); |
---|
| 137 | if (tmpEmit) |
---|
| 138 | { |
---|
| 139 | if (!strcmp(name, "EmissionRate")) |
---|
[4554] | 140 | { |
---|
| 141 | tmpEmit->setEmissionRate(atof(value)); |
---|
| 142 | PRINT(4)("EmissionRate set to %f\n", atof(value)); |
---|
| 143 | } |
---|
[4333] | 144 | else if (!strcmp(name, "Velocity")) |
---|
[4554] | 145 | { |
---|
| 146 | tmpEmit->setEmissionVelocity(atof(value)); |
---|
| 147 | PRINT(4)("Velocity set to %f\n", atof(value)); |
---|
| 148 | } |
---|
[4692] | 149 | else if (!strcmp(name, "Momentum")) |
---|
| 150 | { |
---|
| 151 | tmpEmit->setEmissionMomentum(atof(value)); |
---|
| 152 | PRINT(4)("Momentum set to %f\n", atof(value)); |
---|
| 153 | } |
---|
[4333] | 154 | else if(!strcmp(name, "SpreadAngle")) |
---|
[4554] | 155 | { |
---|
| 156 | tmpEmit->setSpread(atof(value), 0); |
---|
| 157 | PRINT(4)("SpreadAngle set to %f\n", atof(value)); |
---|
| 158 | } |
---|
[4333] | 159 | else if(!strcmp(name, "EmitterType")) |
---|
[4554] | 160 | { |
---|
| 161 | if (!strcmp(value, "EMITTER_DOT")) |
---|
| 162 | tmpEmit->setType(EMITTER_DOT); |
---|
| 163 | else if (!strcmp(value, "EMITTER_PLANE")) |
---|
| 164 | tmpEmit->setType(EMITTER_PLANE); |
---|
| 165 | else if (!strcmp(value, "EMITTER_CUBE")) |
---|
| 166 | tmpEmit->setType(EMITTER_CUBE); |
---|
| 167 | PRINT(4)("EmitterType set to %s\n", value); |
---|
| 168 | } |
---|
[4333] | 169 | else if(!strcmp(name, "EmitterSize")) |
---|
[4554] | 170 | { |
---|
| 171 | tmpEmit->setSize(atof(value)); |
---|
| 172 | PRINT(4)("EmitterSize set to %f\n", atof(value)); |
---|
| 173 | } |
---|
[4637] | 174 | else if (!strcmp(name, "InheritSpeed")) |
---|
| 175 | { |
---|
| 176 | tmpEmit->setInheritSpeed(atof(value)); |
---|
| 177 | PRINT(4)("ParticleInheritSpeed set to %f\n", atof(value)); |
---|
| 178 | } |
---|
[4333] | 179 | } |
---|
[4336] | 180 | delete value; |
---|
[4333] | 181 | } |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | int systemChange(GtkWidget* nonInterest, void* widget) |
---|
| 185 | { |
---|
| 186 | Option* option = (Option*) widget; |
---|
| 187 | const char* name = option->getTitle(); |
---|
[4336] | 188 | char* value = option->save(); |
---|
[4333] | 189 | |
---|
| 190 | ParticleSystem* tmpSys = ParticleEngine::getInstance()->getSystemByNumber(1); |
---|
| 191 | if (tmpSys) |
---|
| 192 | { |
---|
| 193 | if (!strcmp(name, "StartRadius")) |
---|
[4554] | 194 | { |
---|
[4637] | 195 | tmpSys->setRadius(0, atof(value)); |
---|
[4554] | 196 | PRINT(4)("ParticleStartRadius set to %f\n", atof(value)); |
---|
| 197 | } |
---|
[4333] | 198 | else if (!strcmp(name, "EndRadius")) |
---|
[4554] | 199 | { |
---|
[4637] | 200 | tmpSys->setRadius( 1, atof(value)); |
---|
[4554] | 201 | PRINT(4)("ParticleEndRadius set to %f\n", atof(value)); |
---|
| 202 | } |
---|
[4333] | 203 | |
---|
| 204 | else if (!strcmp(name, "LifeSpan")) |
---|
[4554] | 205 | { |
---|
| 206 | tmpSys->setLifeSpan(atof(value)); |
---|
| 207 | PRINT(4)("ParticleLifeSpan set to %f\n", atof(value)); |
---|
| 208 | } |
---|
[4333] | 209 | |
---|
[4383] | 210 | else if (!strcmp(name, "Mass")) |
---|
[4554] | 211 | { |
---|
[4637] | 212 | tmpSys->setMass(0, atof(value)); |
---|
[4554] | 213 | PRINT(4)("ParticleMass set to %f\n", atof(value)); |
---|
| 214 | } |
---|
[4383] | 215 | |
---|
[4333] | 216 | else if (!strcmp(name, "ConserveFactor")) |
---|
[4554] | 217 | { |
---|
| 218 | tmpSys->setConserve(atof(value)); |
---|
| 219 | PRINT(4)("ParticleConserveFactor set to %f\n", atof(value)); |
---|
| 220 | } |
---|
[4333] | 221 | |
---|
| 222 | else if (!strcmp(name, "ParticleType")) |
---|
[4554] | 223 | { |
---|
| 224 | if (!strcmp(value, "PARTICLE_DOT")) |
---|
| 225 | tmpSys->setType(PARTICLE_DOT); |
---|
| 226 | else if (!strcmp(value, "PARTICLE_SPARK")) |
---|
| 227 | tmpSys->setType(PARTICLE_SPARK); |
---|
| 228 | else if (!strcmp(value, "PARTICLE_SPRITE")) |
---|
| 229 | tmpSys->setType(PARTICLE_SPRITE); |
---|
[4333] | 230 | |
---|
[4554] | 231 | PRINT(4)("ParticleType set to %s\n", value); |
---|
| 232 | } |
---|
[4666] | 233 | else if(!strcmp(name, "ParticleModel")) |
---|
| 234 | { |
---|
| 235 | char* modelName = new char[strlen(PINIT_MODEL_DIRECTORY) + strlen(value)+1]; |
---|
| 236 | sprintf(modelName, "%s%s", PINIT_MODEL_DIRECTORY, value); |
---|
[4726] | 237 | tmpSys->loadModel(modelName); |
---|
[4666] | 238 | delete modelName; |
---|
| 239 | } |
---|
[4351] | 240 | else if (!strcmp(name, "RandomColor")) |
---|
[4554] | 241 | { |
---|
[4637] | 242 | tmpSys->setColor(0, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 1); |
---|
| 243 | tmpSys->setColor(.5, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, .5); |
---|
| 244 | tmpSys->setColor(.5, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 0); |
---|
[4554] | 245 | } |
---|
[4333] | 246 | } |
---|
[4336] | 247 | delete value; |
---|
[4333] | 248 | } |
---|
| 249 | |
---|
[4379] | 250 | int fieldsChange(GtkWidget* nonInterest, void* widget) |
---|
| 251 | { |
---|
| 252 | Option* option = (Option*) widget; |
---|
| 253 | const char* name = option->getTitle(); |
---|
| 254 | char* value = option->save(); |
---|
[4333] | 255 | |
---|
[4379] | 256 | |
---|
[4383] | 257 | if (!strcmp(name, "Gravity")) |
---|
[4379] | 258 | { |
---|
[4383] | 259 | gravity->setMagnitude(atof(value)); |
---|
[4379] | 260 | } |
---|
| 261 | |
---|
[4383] | 262 | else if (!strcmp(name, "Twirl")) |
---|
| 263 | { |
---|
| 264 | twirl->setMagnitude(atof(value)); |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | else if (!strcmp(name, "PointGravity")) |
---|
| 268 | { |
---|
| 269 | pointGravity->setMagnitude(atof(value)); |
---|
| 270 | } |
---|
| 271 | |
---|
[4379] | 272 | } |
---|
| 273 | |
---|
[4343] | 274 | void Framework::moduleInitGui(int argc, char** argv) |
---|
[4333] | 275 | { |
---|
| 276 | Window* guiMainWindow = NULL; |
---|
[4554] | 277 | |
---|
[4333] | 278 | initGUI(0, NULL); |
---|
[4554] | 279 | |
---|
[4333] | 280 | guiMainWindow = new Window("ParticlesFUN"); |
---|
| 281 | { |
---|
[4379] | 282 | Box* windowBox = new Box('h'); |
---|
[4333] | 283 | { |
---|
| 284 | Frame* emitterFrame = new Frame("emitter-settings"); |
---|
| 285 | { |
---|
[4554] | 286 | Box* emitterBox = new Box('v'); |
---|
| 287 | { |
---|
| 288 | emitterBox->fill(new Label("EmissionRate")); |
---|
| 289 | Slider* EmissionRate = new Slider("EmissionRate", 0, 1000); |
---|
| 290 | EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange ); |
---|
| 291 | EmissionRate->setValue(PINIT_EMISSION_RATE); |
---|
| 292 | EmissionRate->redraw(); |
---|
| 293 | emitterBox->fill(EmissionRate); |
---|
[4333] | 294 | |
---|
[4554] | 295 | emitterBox->fill(new Label("Velocity")); |
---|
| 296 | Slider* velocity = new Slider("Velocity", 0, 20); |
---|
| 297 | velocity->setExactness(2); |
---|
| 298 | velocity->connectSignal("value_changed", (void*)velocity, emitterChange ); |
---|
| 299 | velocity->setValue(PINIT_EMISSION_VELOCITY); |
---|
| 300 | velocity->redraw(); |
---|
| 301 | emitterBox->fill(velocity); |
---|
[4333] | 302 | |
---|
[4692] | 303 | emitterBox->fill(new Label("Momentum")); |
---|
| 304 | Slider* Momentum = new Slider("Momentum", 0, 20); |
---|
| 305 | Momentum->setExactness(2); |
---|
| 306 | Momentum->connectSignal("value_changed", (void*)Momentum, emitterChange ); |
---|
| 307 | Momentum->setValue(PINIT_EMISSION_MOMENTUM); |
---|
| 308 | Momentum->redraw(); |
---|
| 309 | emitterBox->fill(Momentum); |
---|
| 310 | |
---|
[4554] | 311 | emitterBox->fill(new Label("SpreadAngle")); |
---|
| 312 | Slider* SpreadAngle = new Slider("SpreadAngle", 0, M_PI); |
---|
| 313 | SpreadAngle->setExactness(3); |
---|
| 314 | SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange ); |
---|
| 315 | SpreadAngle->setValue(PINIT_SPREAD_ANGLE); |
---|
| 316 | SpreadAngle->redraw(); |
---|
| 317 | emitterBox->fill(SpreadAngle); |
---|
| 318 | |
---|
| 319 | emitterBox->fill(new Label("EmitterType")); |
---|
| 320 | Menu* EmitterType = new Menu("EmitterType"); |
---|
| 321 | EmitterType->addItem("EMITTER_DOT"); |
---|
| 322 | EmitterType->addItem("EMITTER_PLANE"); |
---|
| 323 | EmitterType->addItem("EMITTER_CUBE"); |
---|
| 324 | EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange ); |
---|
| 325 | EmitterType->load("EMITTER_DOT"); |
---|
| 326 | emitterBox->fill(EmitterType); |
---|
| 327 | |
---|
| 328 | emitterBox->fill(new Label("EmitterSize")); |
---|
| 329 | Slider* EmitterSize = new Slider("EmitterSize", 0, 100); |
---|
| 330 | EmitterSize->setExactness(1); |
---|
| 331 | EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange ); |
---|
| 332 | EmitterSize->setValue(PINIT_EMITTER_SIZE); |
---|
| 333 | EmitterSize->redraw(); |
---|
| 334 | emitterBox->fill(EmitterSize); |
---|
[4637] | 335 | |
---|
| 336 | emitterBox->fill(new Label("InheritSpeed")); |
---|
| 337 | Slider* InheritSpeed = new Slider("InheritSpeed", 0, 1); |
---|
| 338 | InheritSpeed->setExactness(3); |
---|
| 339 | InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, emitterChange ); |
---|
| 340 | emitterBox->fill(InheritSpeed); |
---|
[4554] | 341 | } |
---|
| 342 | emitterFrame->fill(emitterBox); |
---|
[4333] | 343 | } |
---|
| 344 | windowBox->fill(emitterFrame); |
---|
[4554] | 345 | |
---|
[4333] | 346 | Frame* systemFrame = new Frame("system-settings"); |
---|
| 347 | { |
---|
[4554] | 348 | Box* systemBox = new Box('v'); |
---|
| 349 | { |
---|
| 350 | systemBox->fill(new Label("StartRadius")); |
---|
| 351 | Slider* StartRadius = new Slider("StartRadius", 0, 10); |
---|
| 352 | StartRadius->setExactness(3); |
---|
| 353 | StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange ); |
---|
| 354 | StartRadius->setValue(PINIT_START_RADIUS); |
---|
| 355 | StartRadius->redraw(); |
---|
| 356 | systemBox->fill(StartRadius); |
---|
[4333] | 357 | |
---|
[4554] | 358 | systemBox->fill(new Label("EndRadius")); |
---|
| 359 | Slider* EndRadius = new Slider("EndRadius", 0, 10); |
---|
| 360 | EndRadius->setExactness(3); |
---|
| 361 | EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange ); |
---|
| 362 | EndRadius->setValue(PINIT_END_RADIUS); |
---|
| 363 | EndRadius->redraw(); |
---|
| 364 | systemBox->fill(EndRadius); |
---|
[4333] | 365 | |
---|
[4554] | 366 | systemBox->fill(new Label("ParticleMass")); |
---|
| 367 | Slider* Mass = new Slider("Mass", 0, 10); |
---|
| 368 | Mass->setExactness(2); |
---|
| 369 | Mass->connectSignal("value_changed", (void*)Mass, systemChange ); |
---|
| 370 | Mass->setValue(PINIT_PARTICLE_MASS); |
---|
| 371 | Mass->redraw(); |
---|
| 372 | systemBox->fill(Mass); |
---|
[4383] | 373 | |
---|
[4333] | 374 | |
---|
[4554] | 375 | systemBox->fill(new Label("LifeSpan")); |
---|
| 376 | Slider* LifeSpan = new Slider("LifeSpan", 0, 10); |
---|
| 377 | LifeSpan->setExactness(3); |
---|
| 378 | LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange ); |
---|
| 379 | LifeSpan->setValue(PINIT_LIFESPAN); |
---|
| 380 | LifeSpan->redraw(); |
---|
| 381 | systemBox->fill(LifeSpan); |
---|
[4333] | 382 | |
---|
[4554] | 383 | systemBox->fill(new Label("ConserveFactor")); |
---|
| 384 | Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1); |
---|
| 385 | ConserveFactor->setExactness(3); |
---|
| 386 | ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange ); |
---|
| 387 | ConserveFactor->setValue(PINIT_CONSERVE_FACTOR); |
---|
| 388 | ConserveFactor->redraw(); |
---|
| 389 | systemBox->fill(ConserveFactor); |
---|
[4333] | 390 | |
---|
[4554] | 391 | systemBox->fill(new Label("ParticleType")); |
---|
| 392 | Menu* ParticleType = new Menu("ParticleType"); |
---|
| 393 | ParticleType->addItem("PARTICLE_DOT"); |
---|
| 394 | ParticleType->addItem("PARTICLE_SPARK"); |
---|
| 395 | ParticleType->addItem("PARTICLE_SPRITE"); |
---|
| 396 | ParticleType->connectSignal("changed", (void*)ParticleType, systemChange ); |
---|
| 397 | ParticleType->load("PARTICLE_SPRITE"); |
---|
| 398 | systemBox->fill(ParticleType); |
---|
| 399 | |
---|
[4666] | 400 | systemBox->fill(new Label("ParticleModel")); |
---|
| 401 | Menu* ParticleModel = new Menu("ParticleModel"); |
---|
| 402 | { |
---|
| 403 | DIR* directory; |
---|
| 404 | directory = opendir(ResourceManager::getFullName(PINIT_MODEL_DIRECTORY)); |
---|
| 405 | dirent* file; |
---|
| 406 | while(file = readdir(directory)) |
---|
| 407 | if(strstr(file->d_name, ".obj")) |
---|
| 408 | ParticleModel->addItem(file->d_name); |
---|
| 409 | } |
---|
| 410 | ParticleModel->connectSignal("changed", (void*)ParticleModel, systemChange ); |
---|
| 411 | systemBox->fill(ParticleModel); |
---|
| 412 | |
---|
| 413 | |
---|
[4554] | 414 | Button* RandomColor = new Button("RandomColor"); |
---|
| 415 | RandomColor->connectSignal("released", (void*)RandomColor, systemChange); |
---|
| 416 | systemBox->fill(RandomColor); |
---|
| 417 | |
---|
| 418 | } |
---|
| 419 | systemFrame->fill(systemBox); |
---|
[4333] | 420 | } |
---|
| 421 | windowBox->fill(systemFrame); |
---|
[4379] | 422 | |
---|
| 423 | Frame* fieldsFrame = new Frame("Field-Settings"); |
---|
| 424 | { |
---|
[4554] | 425 | Box* fieldsBox = new Box('v'); |
---|
| 426 | { |
---|
| 427 | fieldsBox->fill(new Label("Gravity")); |
---|
| 428 | Slider* Gravity = new Slider("Gravity", 0, 10); |
---|
| 429 | Gravity->setExactness(1); |
---|
| 430 | Gravity->connectSignal("value_changed", (void*)Gravity, fieldsChange ); |
---|
| 431 | Gravity->setValue(0); |
---|
| 432 | Gravity->redraw(); |
---|
| 433 | fieldsBox->fill(Gravity); |
---|
[4383] | 434 | |
---|
| 435 | |
---|
[4554] | 436 | fieldsBox->fill(new Label("Twirl")); |
---|
| 437 | Slider* Twirl = new Slider("Twirl", 0, 10); |
---|
| 438 | Twirl->setExactness(1); |
---|
| 439 | Twirl->connectSignal("value_changed", (void*)Twirl, fieldsChange ); |
---|
| 440 | Twirl->setValue(0); |
---|
| 441 | Twirl->redraw(); |
---|
| 442 | fieldsBox->fill(Twirl); |
---|
[4383] | 443 | |
---|
| 444 | |
---|
[4554] | 445 | fieldsBox->fill(new Label("PointGravity")); |
---|
| 446 | Slider* PointGravity = new Slider("PointGravity", 0, 10); |
---|
| 447 | PointGravity->setExactness(1); |
---|
| 448 | PointGravity->connectSignal("value_changed", (void*)PointGravity, fieldsChange ); |
---|
| 449 | PointGravity->setValue(0); |
---|
| 450 | PointGravity->redraw(); |
---|
| 451 | fieldsBox->fill(PointGravity); |
---|
[4383] | 452 | |
---|
[4554] | 453 | } |
---|
| 454 | fieldsFrame->fill(fieldsBox); |
---|
[4379] | 455 | } |
---|
| 456 | windowBox->fill(fieldsFrame); |
---|
[4554] | 457 | |
---|
[4333] | 458 | Button* quitButton = new Button("quit"); |
---|
[4554] | 459 | |
---|
[4333] | 460 | quitButton->connectSignal("clicked", NULL, quitGui); |
---|
| 461 | // Window::mainWindow->connectSignal("remove", this, GuiExec::quitGui); |
---|
| 462 | Window::mainWindow->connectSignal("destroy", NULL, quitGui); |
---|
[4385] | 463 | windowBox->fill(quitButton); |
---|
[4554] | 464 | |
---|
[4333] | 465 | } |
---|
| 466 | guiMainWindow->fill(windowBox); |
---|
| 467 | } |
---|
| 468 | Window::mainWindow->showall(); |
---|
| 469 | Window::mainWindow->setSize(300, 500); |
---|
| 470 | } |
---|