Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4183 in orxonox.OLD


Ignore:
Timestamp:
May 14, 2005, 2:50:25 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/physics: physicsEngine works for particles

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

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/story_entities/world.cc

    r4178 r4183  
    4848
    4949#include "animation3d.h"
     50#include "physics_engine.h"
     51#include "gravity.h"
    5052
    5153#include "substring.h"
     
    207209  TextEngine::getInstance()->flush();
    208210
     211  delete PhysicsEngine::getInstance();
    209212  delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence.
    210213  //delete garbagecollecor
     
    255258
    256259  AnimationPlayer::getInstance(); // initializes the animationPlayer
     260  PhysicsEngine::getInstance();
    257261
    258262  this->localCamera = new Camera();
     
    496500  emitter->setParent(this->localPlayer);
    497501 
     502  Gravity* gravity = new Gravity();
     503  gravity->setMagnitude(0.001);
     504  new PhysicsConnection(system, gravity);
     505
    498506  particleEngine->addConnection(emitter, system);
    499507}
     
    11451153
    11461154      AnimationPlayer::getInstance()->tick(this->dtS);
     1155      PhysicsEngine::getInstance()->tick(this->dtS);
     1156
    11471157      particleEngine->tick(this->dtS);
    11481158    }
  • orxonox/branches/physics/src/util/physics/physics_connection.cc

    r4182 r4183  
    1717
    1818#include "physics_connection.h"
    19 #include "field.h"
    20 #include "particle_system.h"
     19
     20#include "physics_engine.h"
    2121
    2222using namespace std;
     
    2929  this->particleSystem = particleSystem;
    3030  this->field = field;
     31
     32  PhysicsEngine::getInstance()->addConnection(this);
    3133}
    3234
     
    3840PhysicsConnection::~PhysicsConnection ()
    3941{
    40 
     42  PhysicsEngine::getInstance()->removeConnection(this);
    4143}
    4244
  • orxonox/branches/physics/src/util/physics/physics_connection.h

    r4182 r4183  
    77#define _PHYSICS_CONNECTION_H
    88
     9#include "field.h"
     10#include "particle_system.h"
     11#include "i_physics.h"
     12
    913//! An enumerator for different ConnectionTypes
    1014typedef enum PCON_Type { PCON_IPhysIPhys = 0,
     
    1418
    1519// Forward Declaration
    16 class Field;
    17 class IPhysics;
    18 class ParticleSystem;
    1920
    2021//! A class that Handles Physical Connection between subjects
  • orxonox/branches/physics/src/util/physics/physics_engine.cc

    r4121 r4183  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1614*/
    1715
    18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
    1917
    2018#include "physics_engine.h"
    2119
    22 #include "stdincl.h" // maybe
     20#include "list.h"
    2321
    2422using namespace std;
     
    2725/**
    2826   \brief standard constructor
    29    \todo this constructor is not jet implemented - do it
    3027*/
    31 PhysicsEngine::PhysicsEngine ()
     28PhysicsEngine::PhysicsEngine()
    3229{
    3330   this->setClassName ("PhysicsEngine");
     31
     32   this->connections = new tList<PhysicsConnection>;
    3433}
    3534
     35/**
     36   \brief the singleton reference to this class
     37*/
     38PhysicsEngine* PhysicsEngine::singletonRef = NULL;
     39
     40/**
     41   \returns a Pointer to this Class
     42*/
     43PhysicsEngine* PhysicsEngine::getInstance(void)
     44{
     45  if (!PhysicsEngine::singletonRef)
     46    PhysicsEngine::singletonRef = new PhysicsEngine();
     47  return PhysicsEngine::singletonRef;
     48}
    3649
    3750/**
     
    4154PhysicsEngine::~PhysicsEngine ()
    4255{
    43   // delete what has to be deleted here
     56  PhysicsEngine::singletonRef = NULL;
    4457}
    4558
    4659/**
    47    \brief nonsense - delete this method
    48    \param realy nothing to give
    49    \returns true or false - probably nothing?
     60   \brief adds A Physical Connection to the List of Connections
     61   \param connection the Connection to add
     62   
     63   Usually this is done through the constructor of PhysicshConnections
     64*/
     65void PhysicsEngine::addConnection(PhysicsConnection* connection)
     66{
     67  this->connections->add(connection);
     68}
    5069
    51    this is just to show the doxygen abilities (this for example is an extension for a long comment)
     70/**
     71   \brief removes A Physical Connection from the List of Connections
     72   \param connection the Connection to remove
     73   
     74   Usually this is done through the destructor of PhysicsConnections
    5275*/
    53 bool PhysicsEngine::doNonSense (int nothing) {}
     76void PhysicsEngine::removeConnection(PhysicsConnection* connection)
     77{
     78  this->connections->remove(connection);
     79}
     80
     81
     82
     83
     84
     85/**
     86   \brief Steps through all the Connections and Ticks them
     87   \param dt The time Passed in Seconds
     88
     89   This function brings a flow into the whole animation
     90*/
     91void PhysicsEngine::tick(float dt)
     92{
     93  tIterator<PhysicsConnection>* iterator = this->connections->getIterator();
     94  PhysicsConnection* enumConn = iterator->nextElement();
     95  while (enumConn)
     96    {
     97      enumConn->apply();
     98      enumConn = iterator->nextElement();
     99    }
     100  delete iterator;
     101}
  • orxonox/branches/physics/src/util/physics/physics_engine.h

    r4121 r4183  
    11/*!
    22    \file physics_engine.h
    3     \brief Definition of the proto class template, used quickly start work
    4     \todo Example: this shows how to use simply add a Marker that here has to be done something.
    5 
    6     The PhysicsEngine exists, to help you quikly getting the run for how to develop in orxonox.
    7     It is an example for the CODING-CONVENTION, and a starting-point for every class.
     3    \brief Definition of the ... singleton Class
     4   
    85*/
    96
     
    129
    1310#include "base_object.h"
     11#include "physics_connection.h"
     12#include "field.h"
    1413
    15 // FORWARD DEFINITION \\
    16 class someClassWeNeed;
     14// Forward Declaration
     15template<class T> class tList;
    1716
    1817
    19 /*class Test;*/ /* forward definition of class Test (without including it here!)*/
    20 
    21 //! A default class that aids you to start creating a new class
    22 /**
    23    here can be some longer description of this class
    24 */
     18//! A default singleton class.
    2519class PhysicsEngine : public BaseObject {
    2620
    2721 public:
    28   PhysicsEngine();
    29   virtual ~PhysicsEngine();
     22  static PhysicsEngine* getInstance(void);
     23  virtual ~PhysicsEngine(void);
    3024
    31   bool doNonSense (int nothing);
     25  void addConnection(PhysicsConnection* connection);
     26  void removeConnection(PhysicsConnection* connection);
     27
     28  void tick(float dt);
    3229
    3330 private:
    34   int nonSense;  //!< doxygen tag here like this for all the variables - delete this variable if you use this
     31  PhysicsEngine(void);
     32  static PhysicsEngine* singletonRef;
    3533
     34  tList<PhysicsConnection>* connections;
     35
     36 
    3637};
    3738
     39
     40
    3841#endif /* _PHYSICS_ENGINE_H */
Note: See TracChangeset for help on using the changeset viewer.