00001 /* 00002 Sheep - A Rigid Body Dynamics Engine 00003 Copyright (C) 2001-2004 Francois Beaune 00004 Contact: http://toxicengine.sourceforge.net/ 00005 00006 This file is part of Sheep. 00007 00008 Sheep is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 Sheep is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Sheep; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #ifndef SHEEP_DYNAMICS_FORCETORQUE_H 00024 #define SHEEP_DYNAMICS_FORCETORQUE_H 00025 00026 #include "common/math/real.h" 00027 #include "common/math/vector3.h" 00028 #include "rigidbody.h" 00029 00030 namespace sheep { 00031 00032 //!\todo Make the Evaluate() methods throw a "unimplemented feature" 00033 //! like exception by default, while still keeping this class abstract 00034 //! by making the destructor pure-virtual or something. This will make 00035 //! things simpler when new type of actor (soft bodies and so on) will 00036 //! be handled by the engine. 00037 00038 class IForce { // abstract class 00039 public: 00040 inline IForce(const Vector3 &p); 00041 00042 inline const Vector3 &GetPoint() const; 00043 00044 virtual Vector3 Evaluate(Real t, const RigidBody *b) const = 0; 00045 00046 protected: 00047 Vector3 m_point; 00048 }; 00049 00050 class ITorque { // abstract class 00051 public: 00052 virtual Vector3 Evaluate(Real t, const RigidBody *b) const = 0; 00053 }; 00054 00055 // Some classical forces and torques. 00056 00057 class ConstantForce : public IForce { 00058 public: 00059 inline ConstantForce(const Vector3 &p, const Vector3 &f); 00060 00061 inline virtual Vector3 Evaluate(Real t, const RigidBody *b) const; 00062 00063 protected: 00064 Vector3 m_force; 00065 }; 00066 00067 class ConstantTorque : public ITorque { 00068 public: 00069 inline ConstantTorque(const Vector3 &t); 00070 00071 inline virtual Vector3 Evaluate(Real t, const RigidBody *b) const; 00072 00073 protected: 00074 Vector3 m_torque; 00075 }; 00076 00077 class LinearDampingForce : public IForce { 00078 public: 00079 inline LinearDampingForce(Real k); 00080 00081 inline virtual Vector3 Evaluate(Real t, const RigidBody *b) const; 00082 00083 protected: 00084 Real m_k; 00085 }; 00086 00087 class LinearDampingTorque : public ITorque { 00088 public: 00089 inline LinearDampingTorque(Real k); 00090 00091 inline virtual Vector3 Evaluate(Real t, const RigidBody *b) const; 00092 00093 protected: 00094 Real m_k; 00095 }; 00096 00097 #include "forcetorque.inl" 00098 00099 } 00100 00101 #endif // !SHEEP_DYNAMICS_FORCETORQUE_H
1.3.6