Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4186 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 14, 2005, 10:57:14 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/physics: forces now time dependant

Location:
orxonox/branches/physics/src
Files:
13 edited

Legend:

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

    r4182 r4186  
    249249    \brief applies some force to a Particle.
    250250 */
    251 void ParticleSystem::applyField(Field* field)
     251void ParticleSystem::applyField(float dt, Field* field)
    252252{
    253253  Particle* tickPart = particles;
    254254  while (tickPart)
    255255    {
    256       tickPart->extForce += field->calcForce(tickPart->position);
     256      tickPart->extForce += field->calcForce(dt, tickPart->position);
    257257      tickPart = tickPart->next;
    258258    }
  • orxonox/branches/physics/src/lib/graphics/particles/particle_system.h

    r4182 r4186  
    7070  void setMass(float mass, float randomMass);
    7171
    72   void applyField(Field* field);
     72  void applyField(float dt, Field* field);
    7373
    7474  void tick(float dt);
  • orxonox/branches/physics/src/story_entities/world.cc

    r4184 r4186  
    492492
    493493
    494   ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPARK);
     494  ParticleSystem* system = new ParticleSystem(10000, PARTICLE_SPARK);
    495495  system->setLifeSpan(5);
    496496  system->setConserve(.9);
    497497  system->setRadius(2, 0, 2, 0);
    498498
    499   ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_2, 5000, 1);
     499  ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 1000, 0);
    500500  emitter->setParent(this->localPlayer);
    501501 
    502502  Field* twirl = new Twirl();
    503   twirl->setMagnitude(.0001);
     503  twirl->setMagnitude(-.1);
    504504  Field* gravity = new PointGravity();
    505   gravity->setMagnitude(0.0001);
     505  gravity->setMagnitude(0);
    506506  new PhysicsConnection(system, twirl);
    507   new PhysicsConnection(system, gravity);
    508   twirl->setParent(this->localPlayer);
     507  //  new PhysicsConnection(system, gravity);
     508  twirl->setParent(this->localCamera->getTarget());
    509509  gravity->setParent(this->localCamera->getTarget());
    510510  particleEngine->addConnection(emitter, system);
  • orxonox/branches/physics/src/util/physics/fields/field.h

    r4180 r4186  
    3939
    4040  /**
     41      \param dt The time over which to apply the force
    4142      \param data This is the data given to this force, to calculate the ForceVector
    4243      \returns The Force Vector
    4344  */
    44   virtual Vector calcForce(const Vector& data) const = 0;
     45  virtual Vector calcForce(float dt, const Vector& data) const = 0;
    4546
    4647  void setMagnitude(const float& magnitude);
  • orxonox/branches/physics/src/util/physics/fields/gravity.cc

    r4180 r4186  
    4545   \returns The force.
    4646*/
    47 Vector Gravity::calcForce(const Vector& data) const
     47Vector Gravity::calcForce(float dt, const Vector& data) const
    4848{
    49   return /*(this->getAbsDir().apply(Vector(0,1,0)))*/ Vector(0,-1,0) * this->getMagnitude();
     49  return /*(this->getAbsDir().apply(Vector(0,1,0)))*/ Vector(0,-1,0) * this->getMagnitude() * dt;
    5050}
    5151
  • orxonox/branches/physics/src/util/physics/fields/gravity.h

    r4180 r4186  
    2121  virtual ~Gravity();
    2222
    23   virtual Vector calcForce(const Vector& data) const;
     23  virtual Vector calcForce(float dt, const Vector& data) const;
    2424
    2525 private:
  • orxonox/branches/physics/src/util/physics/fields/point_gravity.cc

    r4184 r4186  
    4545   \returns The force.
    4646*/
    47 Vector PointGravity::calcForce(const Vector& data) const
     47Vector PointGravity::calcForce(float dt, const Vector& data) const
    4848{
    49   return (this->getAbsCoor() - data) * this->getMagnitude();
     49  return (this->getAbsCoor() - data) * this->getMagnitude() * dt;
    5050}
    5151
  • orxonox/branches/physics/src/util/physics/fields/point_gravity.h

    r4184 r4186  
    2121  virtual ~PointGravity();
    2222
    23   virtual Vector calcForce(const Vector& data) const;
     23  virtual Vector calcForce(float dt, const Vector& data) const;
    2424
    2525 private:
  • orxonox/branches/physics/src/util/physics/fields/twirl.cc

    r4184 r4186  
    4545   \returns The force.
    4646*/
    47 Vector Twirl::calcForce(const Vector& data) const
     47Vector Twirl::calcForce(float dt, const Vector& data) const
    4848{
    4949  return /*this->getAbsDir()*/ Vector(0,1,0).cross(this->getAbsCoor() - data)
    50     * this->getMagnitude();
     50    * this->getMagnitude() * dt;
    5151}
    5252
  • orxonox/branches/physics/src/util/physics/fields/twirl.h

    r4184 r4186  
    2121  virtual ~Twirl();
    2222
    23   virtual Vector calcForce(const Vector& data) const;
     23  virtual Vector calcForce(float dt, const Vector& data) const;
    2424
    2525 private:
  • orxonox/branches/physics/src/util/physics/physics_connection.cc

    r4183 r4186  
    4545/**
    4646    \brief applies the Force to some Object.
     47    \param dt The time to apply in Seconds
    4748*/
    48 void PhysicsConnection::apply(void) const
     49void PhysicsConnection::apply(const float& dt) const
    4950{
    5051  switch(this->type)
     
    5556
    5657    case PCON_ParticlesField:
    57       this->particleSystem->applyField(this->field);
     58      this->particleSystem->applyField(dt, this->field);
    5859
    5960      break;
  • orxonox/branches/physics/src/util/physics/physics_connection.h

    r4183 r4186  
    2929  virtual ~PhysicsConnection();
    3030
    31   void apply(void) const;
     31  void apply(const float& dt) const;
    3232
    3333 private:
  • orxonox/branches/physics/src/util/physics/physics_engine.cc

    r4183 r4186  
    9595  while (enumConn)
    9696    {
    97       enumConn->apply();
     97      enumConn->apply(dt);
    9898      enumConn = iterator->nextElement();
    9999    }
Note: See TracChangeset for help on using the changeset viewer.