Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4728 in orxonox.OLD for orxonox/trunk/src/lib/physics/fields


Ignore:
Timestamp:
Jun 28, 2005, 11:56:46 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: more loading (especially for physics)

Location:
orxonox/trunk/src/lib/physics/fields
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/physics/fields/field.cc

    r4394 r4728  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2020#include "physics_engine.h"
    2121
     22#include "factory.h"
     23#include "load_param.h"
    2224using namespace std;
    23 
    2425
    2526/**
    2627   \brief standard constructor
    27    \todo this constructor is not jet implemented - do it
    2828*/
    29 Field::Field () 
     29Field::Field ()
    3030{
    31    this->setClassName ("Field");
    32    this->setMagnitude(1);
    33    this->setAttenuation(0);
    34    
    35    PhysicsEngine::getInstance()->addField(this);
     31  this->init();
    3632}
    3733
     34/**
     35  \param root The XML-element to load settings from
     36 */
     37Field::Field(const TiXmlElement* root)
     38{
     39  this->init();
     40  this->loadParams(root);
     41}
    3842
    3943/**
     
    4145
    4246*/
    43 Field::~Field () 
     47Field::~Field ()
    4448{
    4549   PhysicsEngine::getInstance()->removeField(this);
    4650}
    4751
     52/**
     53  \brief initializes a Field
     54*/
     55void Field::init(void)
     56{
     57  this->setClassID(CL_FIELD, "Field");
     58  this->setMagnitude(1);
     59  this->setAttenuation(0);
     60
     61  PhysicsEngine::getInstance()->addField(this);
     62}
     63
     64/**
     65  \param root The XML-element to load settings from
     66 */
     67void Field::loadParams(const TiXmlElement* root)
     68{
     69  static_cast<PNode*>(this)->loadParams(root);
     70
     71  LoadParam<Field>(root, "magnitude", this, &Field::setMagnitude)
     72      .describe("sets the magnitude of this Field");
     73
     74  LoadParam<Field>(root, "attenuation", this, &Field::setAttenuation)
     75      .describe("sets the attenuation of this Field.");
     76
     77}
    4878
    4979/**
    5080   \param magnitude the magnitude of the Field.
    5181*/
    52 void Field::setMagnitude(const float& magnitude)
     82void Field::setMagnitude(float magnitude)
    5383{
    5484  this->magnitude = magnitude;
     
    5888   \param attenuation The attenuation of the Field (the bigger the smaller the region of influence)
    5989*/
    60 void Field::setAttenuation(const float& attenuation)
     90void Field::setAttenuation(float attenuation)
    6191{
    6292  this->attenuation = attenuation;
  • orxonox/trunk/src/lib/physics/fields/field.h

    r4481 r4728  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1414*/
    1515
    16 /*! 
     16/*!
    1717    \file field.h
    1818    \brief abstract definition of a Physical Field
    1919
    20     This is a totally abstract class, that only enables different Physical Fields to 
     20    This is a totally abstract class, that only enables different Physical Fields to
    2121    exist on a common Level.
    2222*/
     
    2828
    2929// FORWARD DEFINITION
    30 
     30class TiXmlElement;
    3131
    3232
    3333//! An abstract class that represents a Force.
    34 class Field : public PNode 
     34class Field : public PNode
    3535{
    3636 public:
    3737  Field();
     38  Field(const TiXmlElement* root);
    3839  virtual ~Field();
    3940
    40   /**
     41  void init(void);
     42  void loadParams(const TiXmlElement* root);
     43
     44  /**
    4145      \param data This is the data given to this force, to calculate the ForceVector
    4246      \returns The Force Vector
     
    4448  virtual Vector calcForce(const Vector& data) const = 0;
    4549
    46   void setMagnitude(const float& magnitude);
     50  void setMagnitude(float magnitude);
    4751  /** \returns The Magnitude of the Field */
    4852  inline const float& getMagnitude(void) const {return this->magnitude;}
    4953
    50   void setAttenuation(const float& attenuation);
     54  void setAttenuation(float attenuation);
    5155  /** \returns The Attenuation of the Fiels */
    5256  inline const float& getAttenuation(void) const {return this->attenuation;}
  • orxonox/trunk/src/lib/physics/fields/gravity.cc

    r4396 r4728  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1818#include "gravity.h"
    1919
     20#include "load_param.h"
     21#include "factory.h"
     22
    2023using namespace std;
    2124
     25CREATE_FACTORY(Gravity);
    2226
    2327/**
     
    2529   \todo this constructor is not jet implemented - do it
    2630*/
    27 Gravity::Gravity () 
     31Gravity::Gravity ()
    2832{
    29    this->setClassName ("Gravity");
     33   this->setClassName("Gravity");
    3034}
    3135
     36Gravity::Gravity(const TiXmlElement* root)
     37{
     38  this->setClassName("Gravity");
     39
     40  this->loadParams(root);
     41}
    3242
    3343/**
     
    3545
    3646*/
    37 Gravity::~Gravity () 
     47Gravity::~Gravity ()
    3848{
    3949  // delete what has to be deleted here
     50}
     51
     52void Gravity::loadParams(const TiXmlElement* root)
     53{
     54  static_cast<Field*>(this)->loadParams(root);
     55
    4056}
    4157
  • orxonox/trunk/src/lib/physics/fields/gravity.h

    r4395 r4728  
    1 /*! 
     1/*!
    22    \file gravity.h
    33    \brief Definition of ...
     
    1919 public:
    2020  Gravity();
     21  Gravity(const TiXmlElement* root);
    2122  virtual ~Gravity();
     23
     24  void loadParams(const TiXmlElement* root);
    2225
    2326  virtual Vector calcForce(const Vector& data) const;
Note: See TracChangeset for help on using the changeset viewer.