Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/objects/ForceField.h @ 7674

Last change on this file since 7674 was 7674, checked in by dafrick, 13 years ago

Resolving some stupid bugs and some adding some minor improvements.

  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Aurelian Jaggi
24 *   Co-authors:
25 *      Damian 'Mozork' Frick
26 *
27 */
28
29/**
30    @file ForceField.h
31    @brief Definition of the ForceField class.
32    @ingroup Objects
33*/
34
35/**
36@file ForceField.h
37@brief Definition of the ForceField class.
38@inGroup Objects
39*/
40
41#ifndef _ForceField_H__
42#define _ForceField_H__
43
44#include "objects/ObjectsPrereqs.h"
45
46#include "tools/interfaces/Tickable.h"
47#include "worldentities/StaticEntity.h"
48
49namespace orxonox
50{
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    */
87    class _ObjectsExport ForceField : public StaticEntity, public Tickable
88    {
89        public:
90            ForceField(BaseObject* creator);
91            virtual ~ForceField();
92            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
93            virtual void tick(float dt);
94
95            inline void setVelocity(float vel)
96                { this->velocity_ = vel; }
97
98            inline float getVelocity()
99                { return this->velocity_; }
100
101            inline void setDiameter(float diam)
102                { this->diameter_ = diam; this->radius_ = diam/2; }
103
104            inline float getDiameter()
105                { return this->diameter_; }
106
107            inline void setLength(float l)
108                { this->length_ = l; this->halfLength_ = l/2; }
109
110            inline float getLength()
111                { return this->length_; }
112               
113            void setMode(const std::string& mode);
114               
115            inline const std::string& getMode(void);
116
117        private:
118            static const std::string modeTube_s;
119            static const std::string modeSphere_s;
120       
121            float velocity_;
122            float diameter_;
123            float radius_;
124            float length_;
125            float halfLength_;
126            forceFieldMode::Value mode_;
127  };
128}
129
130#endif
131
Note: See TracBrowser for help on using the repository browser.