Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4396 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 30, 2005, 3:27:36 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now Objects should be affected by the PhysicsEngine too

Location:
orxonox/trunk/src
Files:
6 edited

Legend:

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

    r4395 r4396  
    9999
    100100  virtual void applyField(Field* field);
     101  virtual void tickPhys(float dt) {};
    101102
    102103  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
  • orxonox/trunk/src/lib/physics/fields/gravity.cc

    r4395 r4396  
    4747Vector Gravity::calcForce(const Vector& data) const
    4848{
    49   return /*(this->getAbsDir().apply(Vector(0,1,0)))*/ Vector(0,-1,0) * this->getMagnitude();
     49  return Vector(0,-1,0) * this->getMagnitude();
    5050}
    5151
  • orxonox/trunk/src/lib/physics/physics_engine.cc

    r4395 r4396  
    140140void PhysicsEngine::tick(float dt)
    141141{
    142   tIterator<PhysicsConnection>* iterator = this->connections->getIterator();
    143   PhysicsConnection* enumConn = iterator->nextElement();
    144   while (enumConn)
     142  tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
     143  PhysicsConnection* enumPC = itPC->nextElement();
     144  while (enumPC)
    145145    {
    146       enumConn->apply();
    147       enumConn = iterator->nextElement();
     146      enumPC->apply();
     147      enumPC = itPC->nextElement();
    148148    }
    149   delete iterator;
     149  delete itPC;
     150
     151
     152  tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
     153  PhysicsInterface* enumPI = itPI->nextElement();
     154  while (enumPI)
     155    {
     156      enumPI->tickPhys(dt);
     157      enumPI = itPI->nextElement();
     158    }
     159  delete itPI;
    150160}
    151161
  • orxonox/trunk/src/lib/physics/physics_interface.cc

    r4395 r4396  
    3939{
    4040  //   this->setClassName ("PhysicsInterface");
    41    this->mass = 0;
     41   this->mass = 1;
    4242   this->massChildren = 0;
    4343   this->forceSum = Vector(0, 0, 0);
     
    9090void PhysicsInterface::applyField(Field* field)
    9191{
    92   //  this->forceSum += force;
     92  this->forceSum += field->calcForce(dynamic_cast<PNode*>(this)->getAbsCoor());
    9393}
    9494
     
    9696{
    9797  Vector acc = this->forceSum / ( this->massChildren + this->mass );
     98  PNode* coorTick =  (PNode*) this;
     99  coorTick->setRelCoor(coorTick->getRelCoor() + (this->forceSum / this->mass * dt));
     100
     101  this->forceSum = Vector(0,0,0);
    98102  // todo: introduce kinematics
    99103}
  • orxonox/trunk/src/story_entities/world.cc

    r4382 r4396  
    4848#include "graphics_engine.h"
    4949#include "physics_engine.h"
     50#include "fields.h"
    5051
    5152#include "command_node.h"
     
    181182  TextEngine::getInstance()->flush();
    182183  delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence.
     184  delete PhysicsEngine::getInstance();
    183185  //delete garbagecollecor
    184186  //delete animator
     
    473475  emitter->setParent(this->localPlayer);
    474476  emitter->setRelCoor(Vector(-3,0,0));
     477
     478  Field* gravity = new Gravity();
     479  gravity->setMagnitude(1000);
     480  //  gravity->setParent(this->localCamera->getTarget());
    475481 
    476482  // Add the Flow from the Emitter into the System
    477483  particleEngine->addConnection(emitter, system);
    478484
     485  new PhysicsConnection(system, gravity);
     486    new PhysicsConnection(this->localPlayer, gravity);
     487 
    479488
    480489  WorldEntity* testEntity = new TestEntity();
     
    10021011      AnimationPlayer::getInstance()->tick(this->dtS);
    10031012
     1013      PhysicsEngine::getInstance()->tick(this->dtS);
     1014
     1015
    10041016      particleEngine->tick(this->dtS);
    10051017      this->garbageCollector->tick(this->dtS);
  • orxonox/trunk/src/story_entities/world.h

    r4338 r4396  
    1616class TrackManager;
    1717class Camera;
     18class Player;
    1819class PNode;
    1920class GLMenuImageScreen;
     
    123124  GLuint objectList;                  //!< temporary: \todo this will be ereased soon
    124125  tList<WorldEntity>* entities;       //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them.
    125   WorldEntity* localPlayer;           //!< The Player, you fly through the level.
     126  Player* localPlayer;                //!< The Player, you fly through the level.
    126127  PilotNode* pilotNode;               //!< THe pilot node to fly with the mouse
    127128
Note: See TracChangeset for help on using the changeset viewer.