[2954] | 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: |
---|
[7673] | 25 | * Damian 'Mozork' Frick |
---|
[2954] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[7601] | 29 | /** |
---|
| 30 | @file ForceField.h |
---|
| 31 | @brief Definition of the ForceField class. |
---|
| 32 | @ingroup Objects |
---|
| 33 | */ |
---|
[2954] | 34 | |
---|
[7673] | 35 | /** |
---|
| 36 | @file ForceField.h |
---|
| 37 | @brief Definition of the ForceField class. |
---|
| 38 | @inGroup Objects |
---|
| 39 | */ |
---|
| 40 | |
---|
[2954] | 41 | #ifndef _ForceField_H__ |
---|
| 42 | #define _ForceField_H__ |
---|
| 43 | |
---|
[5730] | 44 | #include "objects/ObjectsPrereqs.h" |
---|
[3196] | 45 | |
---|
[5693] | 46 | #include "tools/interfaces/Tickable.h" |
---|
[5735] | 47 | #include "worldentities/StaticEntity.h" |
---|
[2954] | 48 | |
---|
| 49 | namespace orxonox |
---|
| 50 | { |
---|
[7673] | 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 | */ |
---|
[5730] | 87 | class _ObjectsExport ForceField : public StaticEntity, public Tickable |
---|
[3064] | 88 | { |
---|
[7673] | 89 | public: |
---|
| 90 | ForceField(BaseObject* creator); |
---|
| 91 | virtual ~ForceField(); |
---|
| 92 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 93 | virtual void tick(float dt); |
---|
[2954] | 94 | |
---|
[7673] | 95 | inline void setVelocity(float vel) |
---|
| 96 | { this->velocity_ = vel; } |
---|
[5693] | 97 | |
---|
[7673] | 98 | inline float getVelocity() |
---|
| 99 | { return this->velocity_; } |
---|
[5693] | 100 | |
---|
[7673] | 101 | inline void setDiameter(float diam) |
---|
| 102 | { this->diameter_ = diam; this->radius_ = diam/2; } |
---|
[2954] | 103 | |
---|
[7673] | 104 | inline float getDiameter() |
---|
| 105 | { return this->diameter_; } |
---|
[5693] | 106 | |
---|
[7673] | 107 | inline void setLength(float l) |
---|
| 108 | { this->length_ = l; this->halfLength_ = l/2; } |
---|
[2954] | 109 | |
---|
[7673] | 110 | inline float getLength() |
---|
| 111 | { return this->length_; } |
---|
| 112 | |
---|
| 113 | void setMode(const std::string& mode); |
---|
| 114 | |
---|
| 115 | inline const std::string& getMode(void); |
---|
[2954] | 116 | |
---|
[7673] | 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_; |
---|
[2954] | 127 | }; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | #endif |
---|
| 131 | |
---|