Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4378 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
May 29, 2005, 2:02:56 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: applying force works for particle-systems again

Location:
orxonox/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/particles/particle_system.cc

    r4377 r4378  
    5656  this->setType(type, 1);
    5757  this->setColor(1.0,1.0,1.0,1.0, .5,.5,.5,.5, .0,.0,.0,.0);
     58  this->setMass(1.0, 0.0);
    5859  ParticleEngine::getInstance()->addSystem(this);
    5960}
     
    182183
    183184/**
     185   \brief sets the initial mass of any particle
     186*/
     187void ParticleSystem::setMass(float mass, float randomMass)
     188{
     189  this->initialMass = mass;
     190  this->randomInitialMass = randomMass;
     191}
     192
     193/**
    184194   \brief sets the conserve Factor of newly created particles
    185195*/
     
    231241  while (likely(tickPart != NULL))
    232242    {
     243      // applying force to the System.
     244      tickPart->velocity += tickPart->extForce * tickPart->mass;
     245
     246      // rendering new position.
    233247      tickPart->position = tickPart->position + tickPart->velocity * dt;
    234248      tickPart->radius += tickPart->radiusIt * dt;
    235 
    236       // applying force to the System.
    237       tickPart->velocity += tickPart->extForce * tickPart->mass;
     249     
    238250      tickPart->extForce = Vector(0,0,0);
    239251
  • orxonox/trunk/src/lib/graphics/particles/particle_system.h

    r4377 r4378  
    7474                 float randomStartRadius = 0.0, float randomEndRadius = 0.0);
    7575  void setConserve(float conserve);
    76   void setMass(float mass, float randomMass);
     76  void setMass(float mass, float randomMass = 0.0);
    7777
    7878  void setColor(GLfloat br, GLfloat bg, GLfloat bb, GLfloat ba,
     
    9797  inline float getMass(void) const { return this->initialMass; };
    9898
    99   void applyField(Field* field, float dt);
     99  virtual void applyField(Field* field, float dt);
    100100
    101101  void tick(float dt);
  • orxonox/trunk/src/lib/physics/physics_connection.cc

    r4377 r4378  
    2626using namespace std;
    2727
    28 
    29 
    3028PhysicsConnection::PhysicsConnection(PhysicsInterface* subject, Field* field)
    3129{
     
    5351void PhysicsConnection::apply(const float& dt) const
    5452{
    55   switch(this->type)
    56     {
    57     case PCON_PhysIField:
    58      
    59       break;
    60 
    61     case PCON_PhysIPhysI:
     53  if (likely(this->type == PCON_PhysIField))
    6254      this->subject->applyField(this->field, dt);
    63       break;
    64     }
     55  else ;
    6556}
  • orxonox/trunk/src/lib/physics/physics_engine.cc

    r4338 r4378  
    100100  delete iterator;
    101101}
     102
     103
     104
     105/**
     106   \brief print out interesting debug information of this class
     107*/
     108void PhysicsEngine::debug(void) const
     109{
     110  PRINT(0)("====================================\n");
     111  PRINT(0)("= Physics-Engine debug information =\n");
     112  PRINT(0)("====================================\n");
     113  PRINT(0)(" reference: %p\n", this);
     114  PRINT(0)(" numbers of Connections: %d\n", this->connections->getSize());
     115
     116  PRINT(0)("==============================PHYS==\n");
     117}
  • orxonox/trunk/src/lib/physics/physics_engine.h

    r4375 r4378  
    2929  void tick(float dt);
    3030
     31  void debug(void) const;
     32
    3133 private:
    3234  PhysicsEngine(void);
     
    3436
    3537  tList<PhysicsConnection>* connections;
    36 
    37  
    3838};
    3939
  • orxonox/trunk/src/subprojects/particles/particle_fun.cc

    r4370 r4378  
    2020#include "physics_engine.h"
    2121#include "particle_engine.h"
     22#include "fields.h"
    2223
    2324#define PINIT_EMISSION_RATE          50
     
    3233#define PINIT_PARTICLE_TYPE          PARTICLE_SPRITE
    3334#define PINIT_INHERIT_SPEED          0.0
    34 
     35#define PINIT_PARTICLE_MASS          1.0
    3536
    3637void Framework::moduleInit(int argc, char** argv)
    3738{
    3839  verbose = 5;
     40  ParticleEngine::getInstance();
     41  PhysicsEngine::getInstance();
     42
    3943
    4044  // Creating a Test Particle System
     
    5357  // Add the Flow from the Emitter into the System
    5458  ParticleEngine::getInstance()->addConnection(emitter, system);
     59
     60
     61  Field* twirl = new Twirl();
     62  twirl->setMagnitude(.1);
     63  new PhysicsConnection(system, twirl);
    5564}
    5665
     
    7180void Framework::moduleTick(float dt)
    7281{
     82  PhysicsEngine::getInstance()->tick(dt);
    7383  ParticleEngine::getInstance()->tick(dt);
    7484}
     
    8595  PRINT(0)("i - Particle-state Information\n\n");
    8696  PRINT(0)("\n");
    87 
    8897}
    8998
Note: See TracChangeset for help on using the changeset viewer.