Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5257 in orxonox.OLD


Ignore:
Timestamp:
Sep 25, 2005, 7:04:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: bouncy effect with physically based animations… or something like it at least.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/physics/physics_connection.h

    r5039 r5257  
    11/*!
    22 * @file physics_connection.h
    3   *  Definition of The Physical Connection Class.
     3 *  Definition of The Physical Connection Class.
     4 * @todo
    45*/
    56
  • trunk/src/lib/physics/physics_interface.cc

    r5255 r5257  
    9999}
    100100
     101void PhysicsInterface::applyForce(const Vector& force)
     102{
     103  PNode* tmp = dynamic_cast<PNode*>((BaseObject*)this);
     104  this->forceSum += force;
     105  this->bForceApplied = true;
     106}
     107
    101108/**
    102109 *  ticks the PhysicsEffect
     
    107114  //  Vector acc = this->forceSum / ( this->massChildren + this->mass );
    108115  PNode* coorTick =  dynamic_cast<PNode*>((BaseObject*)this);
    109   if (this->bForceApplied && coorTick)
     116  if (coorTick != NULL )
     117    coorTick->shiftCoor((coorTick->getVelocity()+ this->forceSum/this->mass*dt)*dt);
     118
     119  if (this->bForceApplied)
    110120  {
    111     coorTick->shiftCoor((coorTick->getVelocity()+ this->forceSum/this->mass * dt)*dt);
    112 
    113121    this->bForceApplied = false;
     122    this->forceSum = Vector(0,0,0);
    114123  }
    115   this->forceSum = Vector(0,0,0);
    116124}
  • trunk/src/lib/physics/physics_interface.h

    r5143 r5257  
    3939  inline float getTotalMass( void ) const { return mass + massChildren; };
    4040
     41  virtual void applyForce(const Vector& force);
    4142  virtual void applyField(Field* field);
    4243  virtual void tickPhys( float dt );
  • trunk/src/world_entities/npc.cc

    r5087 r5257  
    4343  if (entity->isA(CL_PROJECTILE))
    4444    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    45   this->setVisibiliy(false);
    46   State::getWorldEntityList()->remove(this);
     45  this->applyForce(Vector(0,0,0)-location*1000);
     46//  this->setVisibiliy(false);
     47//  State::getWorldEntityList()->remove(this);
    4748}
    4849
     
    5051void NPC::tick(float dt)
    5152{
    52   Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());
     53//  Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());
    5354
    5455  //if (directin.len() < 100)
    55   this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
     56//  this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
    5657  this->shiftDir(Quaternion(dt, this->randomRotAxis));
    5758
  • trunk/src/world_entities/npc.h

    r5059 r5257  
    44
    55#include "world_entity.h"
     6#include "physics_interface.h"
    67
    78class AI;
    89
    9 class NPC : public WorldEntity {
     10class NPC : public WorldEntity, public PhysicsInterface {
    1011
    1112 public:
  • trunk/src/world_entities/player.h

    r5212 r5257  
    2323     the player.cc for debug also
    2424*/
    25 class Player : public WorldEntity, public PhysicsInterface, public EventListener
     25class Player : public WorldEntity, public EventListener
    2626{
    2727  friend class World;
  • trunk/src/world_entities/weapons/test_bullet.cc

    r5063 r5257  
    5959}
    6060
    61 
     61void TestBullet::collidesWith(WorldEntity* entity, const Vector& location)
     62{
     63  this->destroy();
     64}
    6265
    6366/**
     
    7982//      this->finalize();
    8083      GarbageCollector::getInstance()->collect(this);
    81       this->lifeCycle = 0.0;
    82 
     84      this->lifeCycle = 0.0; //! @todo should not be here
    8385    }
    8486}
     
    8890*/
    8991void TestBullet::destroy ()
    90 {}
     92{
     93
     94
     95}
    9196
    9297
  • trunk/src/world_entities/weapons/test_bullet.h

    r4932 r5257  
    1818  virtual ~TestBullet ();
    1919
     20  virtual void collidesWith(WorldEntity* entity, const Vector& location);
    2021  virtual void destroy ();
    2122
  • trunk/src/world_entities/world_entity.cc

    r5256 r5257  
    143143void WorldEntity::collidesWith(WorldEntity* entity, const Vector& location)
    144144{
    145   PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
     145//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    146146}
    147147
Note: See TracChangeset for help on using the changeset viewer.