Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7048 in orxonox.OLD for trunk/src/world_entities/environments


Ignore:
Timestamp:
Feb 6, 2006, 1:46:54 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: modelEntity should now also be able to load momentum and movement

Location:
trunk/src/world_entities/environments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/environments/model_entity.cc

    r6970 r7048  
    3434  this->toList(OM_ENVIRON_NOTICK);
    3535
     36  this->speed = NULL;
     37  this->momentum = NULL;
     38
    3639  if (root != NULL)
    3740    this->loadParams(root);
     
    4447ModelEntity::~ModelEntity()
    4548{
     49  if (this->speed != NULL)
     50    delete this->speed;
     51  if (this->momentum)
     52    delete this->momentum;
     53}
     54
     55void ModelEntity::loadParams(const TiXmlElement* root)
     56{
     57  WorldEntity::loadParams(root);
     58
     59  LoadParam(root, "speed", this, ModelEntity, setSpeed);
     60  LoadParam(root, "momentum", this, ModelEntity, setMomentum);
    4661}
    4762
    4863
     64void ModelEntity::setSpeed(float x, float y, float z)
     65{
     66  if (this->speed == NULL)
     67    this->speed = new Vector;
     68  *this->speed = Vector(x,y,z);
     69}
     70
     71void ModelEntity::setMomentum (float angle, float x, float y, float z)
     72{
     73  if (this->momentum == NULL)
     74    this->momentum = new Quaternion;
     75  *this->momentum = Quaternion(angle, Vector(x, y, z));
     76}
     77
     78void ModelEntity::tick(float dt)
     79{
     80  if (this->speed != NULL)
     81    this->shiftCoor(*this->speed * dt);
     82
     83  if (this->momentum != NULL)
     84    this->shiftDir(*this->momentum * dt);
     85}
  • trunk/src/world_entities/environments/model_entity.h

    r6988 r7048  
    2020  virtual ~ModelEntity();
    2121
     22  virtual void loadParams(const TiXmlElement* root);
     23
     24  void setSpeed(float x, float y, float z);
     25  void setMomentum (float angle, float x, float y, float z);
     26
     27  virtual void tick(float dt);
     28
     29  private:
     30    Vector*           speed;
     31    Quaternion*       momentum;
    2232};
    2333
Note: See TracChangeset for help on using the changeset viewer.