Changeset 4343 in orxonox.OLD for orxonox/trunk/src/subprojects/importer/importer.cc
- Timestamp:
- May 27, 2005, 10:17:18 PM (20 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/subprojects/importer/importer.cc
r4342 r4343 18 18 #include "framework.h" 19 19 20 #include "physics_engine.h" 21 #include "particle_engine.h" 20 #include "light.h" 21 22 #include "objModel.h" 23 #include "primitive_model.h" 24 #include <stdlib.h> 22 25 23 26 24 void Framework::moduleInit() 27 Model* obj; 28 29 void Framework::moduleInit(int argc, char** argv) 25 30 { 26 // Creating a Test Particle System 27 ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE); 28 system->setRadius(0,0,0,0); 29 system->setLifeSpan(0); 30 system->setConserve(1.0); 31 if (argc>=3) 32 obj = new OBJModel (argv[1], atof(argv[2])); 33 else if (argc>=2) 34 obj = new OBJModel(argv[1]); 35 else 36 obj = new PrimitiveModel(CYLINDER); 31 37 32 // Creating a Test Particle Emitter 33 ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0)); 34 emitter->setEmissionRate(0); 35 emitter->setEmissionVelocity(0,0); 36 emitter->setSpread(0,0); 37 emitter->setType(EMITTER_DOT); 38 emitter->setSize(0); 39 // Add the Flow from the Emitter into the System 40 ParticleEngine::getInstance()->addConnection(emitter, system); 38 LightManager* lightMan = LightManager::getInstance(); 39 lightMan->setAmbientColor(.1,.1,.1); 40 lightMan->addLight(); 41 // lightMan->setAttenuation(1.0, .01, 0.0); 42 // lightMan->setDiffuseColor(1,1,1); 43 // lightMan->addLight(1); 44 // lightMan->setPosition(20, 10, -20); 45 // lightMan->setDiffuseColor(0,0,0); 46 // lightMan->debug(); 47 lightMan->setPosition(5.0, 10.0, 40.0); 48 lightMan->addLight(); 49 lightMan->setPosition(-10, -20, -100); 41 50 } 42 51 … … 49 58 { 50 59 case SDLK_i: 51 ParticleEngine::getInstance()->debug();52 60 break; 53 61 } … … 57 65 void Framework::moduleTick(float dt) 58 66 { 59 ParticleEngine::getInstance()->tick(dt);67 60 68 } 61 69 62 70 void Framework::moduleDraw(float dt) 63 71 { 64 ParticleEngine::getInstance()->draw(dt); 72 obj->draw(); 73 74 LightManager::getInstance()->draw(); 65 75 } 66 76 … … 69 79 { 70 80 PRINT(0)("\n"); 71 PRINT(0)("i - Particle-state Information\n\n");81 PRINT(0)("i "); 72 82 PRINT(0)("\n"); 73 83 74 84 } 75 76 int emitterChange(GtkWidget* nonInterest, void* widget)77 {78 Option* option = (Option*) widget;79 const char* name = option->getTitle();80 char* value = option->save();81 82 ParticleEmitter* tmpEmit = ParticleEngine::getInstance()->getEmitterByNumber(1);83 if (tmpEmit)84 {85 if (!strcmp(name, "EmissionRate"))86 {87 tmpEmit->setEmissionRate(atof(value));88 PRINT(3)("EmissionRate set to %f\n", atof(value));89 }90 else if (!strcmp(name, "Velocity"))91 {92 tmpEmit->setEmissionVelocity(atof(value));93 PRINT(3)("Velocity set to %f\n", atof(value));94 }95 else if(!strcmp(name, "SpreadAngle"))96 {97 tmpEmit->setSpread(atof(value));98 PRINT(3)("SpreadAngle set to %f\n", atof(value));99 }100 else if(!strcmp(name, "EmitterType"))101 {102 if (!strcmp(value, "EMITTER_DOT"))103 tmpEmit->setType(EMITTER_DOT);104 else if (!strcmp(value, "EMITTER_PLANE"))105 tmpEmit->setType(EMITTER_PLANE);106 else if (!strcmp(value, "EMITTER_CUBE"))107 tmpEmit->setType(EMITTER_CUBE);108 PRINT(3)("EmitterType set to %s\n", value);109 }110 else if(!strcmp(name, "EmitterSize"))111 {112 tmpEmit->setSize(atof(value));113 PRINT(3)("EmitterSize set to %f\n", atof(value));114 }115 }116 delete value;117 }118 119 120 int systemChange(GtkWidget* nonInterest, void* widget)121 {122 Option* option = (Option*) widget;123 const char* name = option->getTitle();124 char* value = option->save();125 printf("%s\n", value);126 127 ParticleSystem* tmpSys = ParticleEngine::getInstance()->getSystemByNumber(1);128 if (tmpSys)129 {130 if (!strcmp(name, "StartRadius"))131 {132 tmpSys->setRadius(atof(value), tmpSys->getEndRadius());133 PRINT(3)("ParticleStartRadius set to %f\n", atof(value));134 }135 else if (!strcmp(name, "EndRadius"))136 {137 tmpSys->setRadius( tmpSys->getStartRadius(), atof(value));138 PRINT(3)("ParticleEndRadius set to %f\n", atof(value));139 }140 141 else if (!strcmp(name, "LifeSpan"))142 {143 tmpSys->setLifeSpan(atof(value));144 PRINT(3)("ParticleLifeSpan set to %f\n", atof(value));145 }146 147 else if (!strcmp(name, "ConserveFactor"))148 {149 tmpSys->setConserve(atof(value));150 PRINT(3)("ParticleConserveFactor set to %f\n", atof(value));151 }152 153 else if (!strcmp(name, "ParticleType"))154 {155 if (!strcmp(value, "PARTICLE_DOT"))156 tmpSys->setType(PARTICLE_DOT);157 else if (!strcmp(value, "PARTICLE_SPARK"))158 tmpSys->setType(PARTICLE_SPARK);159 else if (!strcmp(value, "PARTICLE_SPRITE"))160 tmpSys->setType(PARTICLE_SPRITE);161 162 PRINT(3)("ParticleType set to %s\n", value);163 }164 165 else if (!strcmp(name, "InheritSpeed"))166 {167 tmpSys->setInheritSpeed(atof(value));168 PRINT(3)("ParticleInheritSpeed set to %f\n", atof(value));169 }170 171 }172 delete value;173 }174 175 176 void Framework::moduleInitGui(void)177 {178 Window* guiMainWindow = NULL;179 180 initGUI(0, NULL);181 182 guiMainWindow = new Window("ParticlesFUN");183 {184 Box* windowBox = new Box('v');185 {186 Frame* emitterFrame = new Frame("emitter-settings");187 {188 Box* emitterBox = new Box('v');189 {190 emitterBox->fill(new Label("EmissionRate"));191 Slider* EmissionRate = new Slider("EmissionRate", 0, 1000);192 EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange );193 emitterBox->fill(EmissionRate);194 195 emitterBox->fill(new Label("Velocity"));196 Slider* velocity = new Slider("Velocity", 0, 2);197 velocity->setExactness(3);198 velocity->connectSignal("value_changed", (void*)velocity, emitterChange );199 emitterBox->fill(velocity);200 201 emitterBox->fill(new Label("SpreadAngle"));202 Slider* SpreadAngle = new Slider("SpreadAngle", 0, M_PI);203 SpreadAngle->setExactness(3);204 SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange );205 emitterBox->fill(SpreadAngle);206 207 emitterBox->fill(new Label("EmitterType"));208 Menu* EmitterType = new Menu("EmitterType");209 EmitterType->addItem("EMITTER_DOT");210 EmitterType->addItem("EMITTER_PLANE");211 EmitterType->addItem("EMITTER_CUBE");212 EmitterType->load("EMITTER_DOT");213 EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange );214 emitterBox->fill(EmitterType);215 216 emitterBox->fill(new Label("EmitterSize"));217 Slider* EmitterSize = new Slider("EmitterSize", 0, 100);218 EmitterSize->setExactness(1);219 EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange );220 emitterBox->fill(EmitterSize);221 }222 emitterFrame->fill(emitterBox);223 }224 windowBox->fill(emitterFrame);225 226 Frame* systemFrame = new Frame("system-settings");227 {228 Box* systemBox = new Box('v');229 {230 systemBox->fill(new Label("StartRadius"));231 Slider* StartRadius = new Slider("StartRadius", 0, 10);232 StartRadius->setExactness(3);233 StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange );234 systemBox->fill(StartRadius);235 236 systemBox->fill(new Label("EndRadius"));237 Slider* EndRadius = new Slider("EndRadius", 0, 10);238 EndRadius->setExactness(3);239 EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange );240 systemBox->fill(EndRadius);241 242 systemBox->fill(new Label("LifeSpan"));243 Slider* LifeSpan = new Slider("LifeSpan", 0, 10);244 LifeSpan->setExactness(3);245 LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange );246 systemBox->fill(LifeSpan);247 248 systemBox->fill(new Label("ConserveFactor"));249 Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1);250 ConserveFactor->setExactness(3);251 ConserveFactor->load("1.0");252 ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange );253 systemBox->fill(ConserveFactor);254 255 systemBox->fill(new Label("ParticleType"));256 Menu* ParticleType = new Menu("ParticleType");257 ParticleType->addItem("PARTICLE_DOT");258 ParticleType->addItem("PARTICLE_SPARK");259 ParticleType->addItem("PARTICLE_SPRITE");260 ParticleType->load("PARTICLE_SPRITE");261 ParticleType->connectSignal("changed", (void*)ParticleType, systemChange );262 systemBox->fill(ParticleType);263 264 systemBox->fill(new Label("InheritSpeed"));265 Slider* InheritSpeed = new Slider("InheritSpeed", 0, 1);266 InheritSpeed->setExactness(3);267 InheritSpeed->connectSignal("value_changed", (void*)InheritSpeed, systemChange );268 systemBox->fill(InheritSpeed);269 270 271 }272 systemFrame->fill(systemBox);273 }274 windowBox->fill(systemFrame);275 276 Button* quitButton = new Button("quit");277 278 quitButton->connectSignal("clicked", NULL, quitGui);279 // Window::mainWindow->connectSignal("remove", this, GuiExec::quitGui);280 Window::mainWindow->connectSignal("destroy", NULL, quitGui);281 282 windowBox->fill(quitButton);283 }284 guiMainWindow->fill(windowBox);285 }286 Window::mainWindow->showall();287 Window::mainWindow->setSize(300, 500);288 }
Note: See TracChangeset
for help on using the changeset viewer.