Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4333 in orxonox.OLD


Ignore:
Timestamp:
May 27, 2005, 7:40:46 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/physics: made the framework more modular

Location:
orxonox/branches/physics/src/subprojects/particles
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/subprojects/particles/Makefile.am

    r4328 r4333  
    3939
    4040particles_SOURCES= framework.cc \
     41                   particle_fun.cc \
    4142                  $(MAINSRCDIR)/lib/graphics/particles/particle_engine.cc \
    4243                  $(MAINSRCDIR)/lib/graphics/particles/particle_system.cc \
  • orxonox/branches/physics/src/subprojects/particles/Makefile.in

    r4330 r4333  
    5454PROGRAMS = $(bin_PROGRAMS)
    5555am_particles_OBJECTS = particles-framework.$(OBJEXT) \
     56        particles-particle_fun.$(OBJEXT) \
    5657        particles-particle_engine.$(OBJEXT) \
    5758        particles-particle_system.$(OBJEXT) \
     
    8788@AMDEP_TRUE@    ./$(DEPDIR)/particles-particle_emitter.Po \
    8889@AMDEP_TRUE@    ./$(DEPDIR)/particles-particle_engine.Po \
     90@AMDEP_TRUE@    ./$(DEPDIR)/particles-particle_fun.Po \
    8991@AMDEP_TRUE@    ./$(DEPDIR)/particles-particle_system.Po \
    9092@AMDEP_TRUE@    ./$(DEPDIR)/particles-primitive_model.Po \
     
    221223particles_CPPFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
    222224particles_SOURCES = framework.cc \
     225                   particle_fun.cc \
    223226                  $(MAINSRCDIR)/lib/graphics/particles/particle_engine.cc \
    224227                  $(MAINSRCDIR)/lib/graphics/particles/particle_system.cc \
     
    323326@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/particles-particle_emitter.Po@am__quote@
    324327@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/particles-particle_engine.Po@am__quote@
     328@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/particles-particle_fun.Po@am__quote@
    325329@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/particles-particle_system.Po@am__quote@
    326330@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/particles-primitive_model.Po@am__quote@
     
    362366@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    363367@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(particles_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o particles-framework.obj `if test -f 'framework.cc'; then $(CYGPATH_W) 'framework.cc'; else $(CYGPATH_W) '$(srcdir)/framework.cc'; fi`
     368
     369particles-particle_fun.o: particle_fun.cc
     370@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(particles_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT particles-particle_fun.o -MD -MP -MF "$(DEPDIR)/particles-particle_fun.Tpo" -c -o particles-particle_fun.o `test -f 'particle_fun.cc' || echo '$(srcdir)/'`particle_fun.cc; \
     371@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/particles-particle_fun.Tpo" "$(DEPDIR)/particles-particle_fun.Po"; else rm -f "$(DEPDIR)/particles-particle_fun.Tpo"; exit 1; fi
     372@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='particle_fun.cc' object='particles-particle_fun.o' libtool=no @AMDEPBACKSLASH@
     373@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/particles-particle_fun.Po' tmpdepfile='$(DEPDIR)/particles-particle_fun.TPo' @AMDEPBACKSLASH@
     374@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     375@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(particles_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o particles-particle_fun.o `test -f 'particle_fun.cc' || echo '$(srcdir)/'`particle_fun.cc
     376
     377particles-particle_fun.obj: particle_fun.cc
     378@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(particles_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT particles-particle_fun.obj -MD -MP -MF "$(DEPDIR)/particles-particle_fun.Tpo" -c -o particles-particle_fun.obj `if test -f 'particle_fun.cc'; then $(CYGPATH_W) 'particle_fun.cc'; else $(CYGPATH_W) '$(srcdir)/particle_fun.cc'; fi`; \
     379@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/particles-particle_fun.Tpo" "$(DEPDIR)/particles-particle_fun.Po"; else rm -f "$(DEPDIR)/particles-particle_fun.Tpo"; exit 1; fi
     380@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='particle_fun.cc' object='particles-particle_fun.obj' libtool=no @AMDEPBACKSLASH@
     381@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/particles-particle_fun.Po' tmpdepfile='$(DEPDIR)/particles-particle_fun.TPo' @AMDEPBACKSLASH@
     382@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     383@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(particles_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o particles-particle_fun.obj `if test -f 'particle_fun.cc'; then $(CYGPATH_W) 'particle_fun.cc'; else $(CYGPATH_W) '$(srcdir)/particle_fun.cc'; fi`
    364384
    365385particles-particle_engine.o: $(MAINSRCDIR)/lib/graphics/particles/particle_engine.cc
  • orxonox/branches/physics/src/subprojects/particles/framework.cc

    r4331 r4333  
    1616#include "framework.h"
    1717
    18 #include "physics_engine.h"
    19 #include "particle_engine.h"
    20 
    21 #include "gui_gtk.h"
     18
    2219#include "p_node.h"
    2320#include "null_parent.h"
     
    3229int verbose;
    3330
    34 int quitGui(GtkWidget* widget, void* data);
    35 
    36 
    37 void Framework::initModule()
    38 {
    39   // Creating a Test Particle System
    40   ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE);
    41 
    42   // Creating a Test Particle Emitter
    43   ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0));
    44   // Add the Flow from the Emitter into the System
    45   ParticleEngine::getInstance()->addConnection(emitter, system);
    46 }
    47 
    4831void* Framework::mainLoop(void* tmp)
    4932{
     
    6043      float dt = framework->tick();
    6144
     45      NullParent::getInstance()->update(dt);
     46
    6247      // Draw the scene
    6348      framework->draw(dt);
     
    7156  glLoadIdentity(); // Reset the view
    7257 
    73   ParticleEngine::getInstance()->draw(dt);
    74 
     58  this->moduleDraw(dt);
     59 
    7560  camera->apply();
    7661 
     
    8570  lastFrame = currFrame;
    8671
    87   ParticleEngine::getInstance()->tick(dt);
    88 
    89   NullParent::getInstance()->update(dt);
     72  this->moduleTick(dt);
     73
    9074  return dt;
    9175}
     
    161145            break;
    162146          case SDLK_i:
    163             ParticleEngine::getInstance()->debug();
     147            //      ParticleEngine::getInstance()->debug();
    164148            break;
    165149          case SDLK_a:
     
    231215 
    232216
    233   initModule();
     217  moduleInit();
    234218
    235219  camera = new Camera();
     
    238222
    239223  camera->setAbsCoor(Vector(10, 10, 0));
    240 
    241224}
    242225
     
    254237  PRINT(0)("========================\n");
    255238  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}
    362243
    363244int quitGui(GtkWidget* widget, void* data)
     
    370251}
    371252
    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 
    489253
    490254int main(int argc, char *argv[])
     
    494258  Framework* framework = Framework::getInstance();
    495259
    496   framework->initGui((void*)argv);
     260  framework->moduleInitGui();
    497261  //  framework->mainloopGui(NULL);
    498262
    499263  framework->mainLoop(NULL);
    500 
    501264
    502265  delete framework;
  • orxonox/branches/physics/src/subprojects/particles/framework.h

    r4331 r4333  
    44#include "vector.h"
    55#include "glincl.h"
     6
     7#include "gui_gtk.h"
    68
    79
     
    2527  Uint32 currFrame;
    2628   
    27   Uint8* keys; // This variable will be used in the keyboard routine
     29  Uint8* keys;        // This variable will be used in the keyboard routine
    2830  bool mouseDown[MOUSE_BUTTON_COUNT];
    2931
    3032 public:
    31   ~Framework();
     33  ~Framework(); 
    3234 
    3335  static Framework* getInstance(void);
    3436
    3537
    36   void initModule();
     38  void moduleInit();
     39  void* moduleInitGui(void);
     40
     41  void moduleDraw(float dt);
     42  void moduleTick(float dt);
     43 
     44  void moduleHelp(void) const;
     45
     46
     47
    3748  static void* mainLoop(void* tmp);
    3849  bool draw(float dt);
     
    4152  void quit();
    4253
    43   void* initGui(void* argv);
    4454  static void* mainloopGui(void* tmp);
    4555
     
    4757};
    4858
     59int quitGui(GtkWidget* widget, void* data);
     60
     61
    4962#endif /* _FRAMEWORK_H */
Note: See TracChangeset for help on using the changeset viewer.