Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2010, 11:24:50 PM (13 years ago)
Author:
dafrick
Message:

Documenting and extending ForceField.
A little cleaning up in The Time Machine level.
Adding a Bond villain…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/ForceField.h

    r7601 r7673  
    2323 *      Aurelian Jaggi
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     
    3131    @brief Definition of the ForceField class.
    3232    @ingroup Objects
     33*/
     34
     35/**
     36@file ForceField.h
     37@brief Definition of the ForceField class.
     38@inGroup Objects
    3339*/
    3440
     
    4349namespace orxonox
    4450{
     51
     52    /**
     53    @brief
     54        The mode of the ForceField.
     55   
     56    @inGroup Objects
     57    */
     58    namespace ForceFieldMode
     59    {
     60        enum Value {
     61            tube, //!< The ForceField has a tube shape.
     62            sphere //!< The ForceField has a spherical shape.
     63           
     64        };
     65    }
     66
     67    /**
     68    @brief
     69        Implements a force field, that applies a force to any @ref orxonox::MoblieEnity "MobileEntity" that enters its range.
     70       
     71        The following parameters can be set to specify the behavior of the ForceField.
     72        - @b velocity The amount of force the ForceField excerts.
     73        - @b diameter The diameter of the ForceField.
     74        - @b length The length of the ForceField.
     75        - @b mode The mode the ForceField is in. For mode:
     76        -- <em>tube</em> A ForceField which exerts force only in the direction it is oriented. The force is only exerted on objects that are in a tube of length <em>length</em> and diameter <em>diameter</em>. The magintude of the force is proportional to the <em><velocity/em>, being highest when an object is in the middle of the tube (radius-wise), linearly decreasing with greater radii and finally reaching zero, when the object is <code>diameter/2</code> away from the orientation vector.
     77        -- <em>sphere</em> A Force Field which exerts force radially away from itself, with the greatest magnitude (proportional to <em>velocity</em>) being in the origin of the ForceField, linearly decreasing with respect to the distance to the origin and finally reaching zero at distance <code>diameter/2</code>.
     78       
     79    @author
     80        Aurelian Jaggi
     81       
     82    @author
     83        Damian 'Mozork' Frick
     84       
     85    @inGroup Objects
     86    */
    4587    class _ObjectsExport ForceField : public StaticEntity, public Tickable
    4688    {
    47     public:
    48         ForceField(BaseObject* creator);
    49         virtual ~ForceField();
    50         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    51         virtual void tick(float dt);
     89        public:
     90            ForceField(BaseObject* creator);
     91            virtual ~ForceField();
     92            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     93            virtual void tick(float dt);
    5294
    53         inline void setVelocity(float vel)
    54             { this->velocity_ = vel; }
     95            inline void setVelocity(float vel)
     96                { this->velocity_ = vel; }
    5597
    56         inline float getVelocity()
    57             { return velocity_; }
     98            inline float getVelocity()
     99                { return this->velocity_; }
    58100
    59         inline void setDiameter(float diam)
    60             { this->diameter_ = diam; }
     101            inline void setDiameter(float diam)
     102                { this->diameter_ = diam; this->radius_ = diam/2; }
    61103
    62         inline float getDiameter()
    63             { return diameter_; }
     104            inline float getDiameter()
     105                { return this->diameter_; }
    64106
    65         inline void setLength(float l)
    66             { this->length_ = l; }
     107            inline void setLength(float l)
     108                { this->length_ = l; this->halfLength_ = l/2; }
    67109
    68         inline float getLength()
    69             { return length_; }
     110            inline float getLength()
     111                { return this->length_; }
     112               
     113            void setMode(const std::string& mode);
     114               
     115            inline const std::string& getMode(void);
    70116
    71     private:
    72         float velocity_;
    73         float diameter_;
    74         float length_;
     117        private:
     118            static const std::string modeStringTube_s;
     119            static const std::string modeStringSphere_s;
     120       
     121            float velocity_;
     122            float diameter_;
     123            float radius_;
     124            float length_;
     125            float halfLength_;
     126            ForceFieldMode::Value mode_;
    75127  };
    76128}
Note: See TracChangeset for help on using the changeset viewer.