Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4397 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
May 30, 2005, 4:57:04 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: ok… forces now apply to the right objects, but i don't really like the way it works…. we will see….

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

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

    r4395 r4397  
    4040   \todo this constructor is not jet implemented - do it
    4141*/
    42 ParticleSystem::ParticleSystem (unsigned int maxCount, PARTICLE_TYPE type)
     42ParticleSystem::ParticleSystem (unsigned int maxCount, PARTICLE_TYPE type) : PhysicsInterface(this)
    4343{
    4444  this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem");
  • orxonox/trunk/src/lib/physics/physics_interface.cc

    r4396 r4397  
    3636   \brief standard constructor
    3737*/
    38 PhysicsInterface::PhysicsInterface ()
     38PhysicsInterface::PhysicsInterface (void* objectPointer)
    3939{
     40  this->objectPointer = objectPointer;
     41
    4042  //   this->setClassName ("PhysicsInterface");
    4143   this->mass = 1;
     
    9092void PhysicsInterface::applyField(Field* field)
    9193{
    92   this->forceSum += field->calcForce(dynamic_cast<PNode*>(this)->getAbsCoor());
     94  PNode* tmp = (PNode*) objectPointer;
     95  this->forceSum += field->calcForce(tmp->getAbsCoor()); 
    9396}
    9497
    9598void PhysicsInterface::tickPhys( float dt )
    9699{
    97   Vector acc = this->forceSum / ( this->massChildren + this->mass );
    98   PNode* coorTick =  (PNode*) this;
    99   coorTick->setRelCoor(coorTick->getRelCoor() + (this->forceSum / this->mass * dt));
    100 
     100  //  Vector acc = this->forceSum / ( this->massChildren + this->mass );
     101  PNode* coorTick =  (PNode*)(this->objectPointer);
     102  if (coorTick)
     103    coorTick->setRelCoor(coorTick->getRelCoor() + this->forceSum/this->mass * dt);
    101104  this->forceSum = Vector(0,0,0);
    102105  // todo: introduce kinematics
  • orxonox/trunk/src/lib/physics/physics_interface.h

    r4395 r4397  
    99#include "vector.h"
    1010#include "base_object.h"
     11
     12#ifndef NULL
     13#define NULL 0
     14#endif
    1115
    1216// Forward Declaration
     
    2630
    2731 public:
    28   PhysicsInterface();
     32  PhysicsInterface(void* objectPointer);
    2933  virtual ~PhysicsInterface();
    3034  /** \param mass the mass to set for this node. */
     
    4347 
    4448 private:
     49  void* objectPointer;
    4550  float mass;                   //!< Mass of this object
    4651  float massChildren;           //!< Sum of the masses of the children nodes
  • orxonox/trunk/src/story_entities/world.cc

    r4396 r4397  
    477477
    478478  Field* gravity = new Gravity();
    479   gravity->setMagnitude(1000);
     479  gravity->setMagnitude(10.0);
    480480  //  gravity->setParent(this->localCamera->getTarget());
    481481 
     
    484484
    485485  new PhysicsConnection(system, gravity);
    486     new PhysicsConnection(this->localPlayer, gravity);
    487  
    488 
    489   WorldEntity* testEntity = new TestEntity();
    490   //testEntity->setRelCoor(Vector(570, 10, -15));
    491   testEntity->setRelCoor(Vector(25, -10, -20));
     486  //    new PhysicsConnection(this->localPlayer, gravity);
     487 
     488
     489  TestEntity* testEntity = new TestEntity();
     490  testEntity->setRelCoor(Vector(570, 10, -15));
     491  //testEntity->setRelCoor(Vector(25, -10, -20));
    492492  testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));
    493493  this->spawn(testEntity);
    494   this->localPlayer->addChild(testEntity);
     494  //  this->localPlayer->addChild(testEntity);
     495
     496  new PhysicsConnection(testEntity, gravity);
    495497}
    496498
     
    585587        this->localPlayer->setName ("player");
    586588        this->spawn (this->localPlayer);
     589        this->localPlayer->setRelCoor(Vector(5,0,0));
    587590        /*monitor progress*/
    588591        this->glmis->step();
     592
     593        Field* testField = new Gravity();
     594        testField->setMagnitude(10);
     595        new PhysicsConnection(this->localPlayer, testField);
    589596
    590597        // bind camera
     
    10101017      this->localCamera->tick(this->dt);
    10111018      AnimationPlayer::getInstance()->tick(this->dtS);
    1012 
    10131019      PhysicsEngine::getInstance()->tick(this->dtS);
    10141020
  • orxonox/trunk/src/world_entities/player.cc

    r4389 r4397  
    3939   \param isFree if the player is free
    4040*/
    41 Player::Player() : WorldEntity()
     41Player::Player() : WorldEntity(), PhysicsInterface(this)
    4242{
    4343  /*
     
    4646     the player.cc for debug also
    4747  */
     48  this->setClassName("Player");
    4849  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    4950  travelSpeed = 15.0;
     
    8283   \todo add more parameters to load
    8384*/
    84 Player::Player(const TiXmlElement* root) : WorldEntity(root)
    85 {
     85Player::Player(const TiXmlElement* root) : WorldEntity(root), PhysicsInterface(this)
     86{
     87  this->setClassName("Player");
    8688  this->weapons = new tList<Weapon>();
    8789  this->activeWeapon = NULL;
     
    196198void Player::tick (float time)
    197199{
     200  printf("%p\n", this);
     201  this->getRelCoor().debug();
     202 
    198203  /* link tick to weapon */
    199204  //this->activeWeapon->tick(time);
  • orxonox/trunk/src/world_entities/test_entity.cc

    r4320 r4397  
    2626
    2727
    28 TestEntity::TestEntity () : WorldEntity()
     28TestEntity::TestEntity () : WorldEntity(), PhysicsInterface(this)
    2929
    3030  this->setClassID(CL_TEST_ENTITY, "TestEntity");
  • orxonox/trunk/src/world_entities/test_entity.h

    r4276 r4397  
    33
    44#include "world_entity.h"
     5#include "physics_interface.h"
    56
    67class MD2Loader;
     
    1011class Material;
    1112
    12 class TestEntity : public WorldEntity 
     13class TestEntity : public WorldEntity, PhysicsInterface
    1314{
    1415  friend class World;
Note: See TracChangeset for help on using the changeset viewer.