Move.hpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #ifndef sim_custom_Move_hpp
00023 #define sim_custom_Move_hpp
00024 
00025 #include "util/config/util_config.hpp"
00026 
00027 #ifdef SE_OWN_MOVE
00028 
00029 #include "config/CustomMove.hpp"
00030 
00031 #else
00032 
00033 #include "../stat/sim_stat.hpp"
00034 #include "util/vecmath/Quat4.hpp"
00035 #include "util/vecmath/Euler3.hpp"
00036 #include "util/vecmath/Point3.hpp"
00037 #include "util/vecmath/Vector3.hpp"
00038 #include "util/vecmath/ViewPoint.hpp"
00039 
00040 
00041 namespace se_core {
00042 
00043     class _SeCoreExport Move {
00044     public:
00045         //
00046         Vector3 velocity_; // Velocity - the speed and direction at which the position changes
00047         Euler3 angularVelocity_; // Angular Velocity - the rate at which the orientation changes
00048 
00049         // Usually stable values
00050         scale_t mass_; // The mass of the body
00051         Point3 centerOfMass_; // The pivot point of the center of mass - relative to the position
00052         //Matrix3 inertia_; // How the mass is distributed around the center of mass
00053 
00054         // The sum of forces working on this body.
00055         Vector3 force_; // Forces applied (acceleration)
00056         Euler3 torque_; // Torque - forces changing rotation
00057 
00058         scale_t linearFriction_;
00059         scale_t linearFrictionR_;
00060         scale_t angularFriction_;
00061         bool didBounce_;
00062         scale_t bounceMaintain_;
00063         scale_t floorBounce_;
00064         int affectCode_;
00065 
00066         // The physics object is free to interpret these values as they like
00067         struct WorkVars {
00068             coor_t speed_;
00069             ViewPoint vp_;
00070         } work_;
00071 
00072     public:
00073         Move();
00074         void setMove(const Move& original);
00075 
00076         coor_t workSpeed() const { return work_.speed_; }
00077         bray_t workYaw() const { return work_.vp_.face_.yaw_; }
00078 
00084         const inline Vector3& velocity() const { return velocity_; }
00085 
00089         inline void resetSpeed() { work_.speed_ = 0; velocity_.reset(); }
00090 
00091         void changeYaw(bray_t yaw);
00092         void changeSpeed(coor_t speed);
00093 
00101         void changeMovement(bray_t yaw, coor_t speed);
00102 
00108         inline bool isMoving() const { return (velocity_.isZero() || !force_.isZero()); }
00109 
00116         void resetForces();
00117 
00118 
00124         const Vector3& resultantForce() const { return force_; }
00125 
00129         void clearForces() { force_.reset(); }
00130 
00136         void addForce(const Vector3& force) { 
00137             force_.add(force); 
00138             Assert(!force_.isNan());
00139         }
00140         void addForce(scale_t s, const Vector3& force) { force_.scaleAdd(s, force, force_); }
00141 
00147         void subtractForce(const Vector3& force) { force_.sub(force); }
00148 
00149     };
00150 
00151 
00152 
00153 }
00154 #endif // SE_OWN_MOVE
00155 
00156 #endif

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:11 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo