Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreRefAppApplicationObject.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of the OGRE Reference Application, a layer built
00004 on top of OGRE(Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __REFAPP_APPLICATIONOBJECT_H__
00026 #define __REFAPP_APPLICATIONOBJECT_H__
00027 
00028 #include "OgreRefAppPrerequisites.h"
00029 
00030 namespace OgreRefApp {
00031 
00042     class _OgreRefAppExport ApplicationObject : public UserDefinedObject
00043     {
00044     protected:
00045         // Visual component
00046         SceneNode* mSceneNode;
00047         Entity* mEntity;
00048 
00050         dBody* mOdeBody;
00052         dMass mMass;
00053 
00054 
00056         typedef std::list<dGeom*> CollisionProxyList;
00057         CollisionProxyList mCollisionProxies;
00058 
00059 
00060         bool mDynamicsEnabled;
00061         bool mReenableIfInteractedWith;
00062         bool mCollisionEnabled;
00063 
00064         Real mBounceCoeffRestitution;
00065         Real mBounceVelocityThreshold;
00066         Real mSoftness;
00067         Real mFriction;
00068         Real mLinearVelDisableThreshold;
00069         Real mAngularVelDisableThreshold;
00070         Real mDisableTime;
00071         Real mDisableTimeEnd;
00072 
00073         // Set up method, must override
00074         virtual void setUp(const String& name) = 0;
00076         virtual void updateCollisionProxies(void);
00077 
00079         virtual bool testCollidePlaneBounds(SceneQuery::WorldFragment* wf);
00080 
00082         virtual void setEntityQueryFlags(void);
00083 
00084     public:
00085         ApplicationObject(const String& name);
00086         virtual ~ApplicationObject();
00087 
00089         virtual void setPosition(const Vector3& vec);
00091         virtual void setPosition(Real x, Real y, Real z);
00093         virtual void setOrientation(const Quaternion& orientation);
00095         virtual const Vector3& getPosition(void);
00097         virtual const Quaternion& getOrientation(void);
00098 
00100         virtual void _updateFromDynamics(void);
00101 
00103         virtual bool isCollisionEnabled(void);
00109         virtual bool isDynamicsEnabled(void);
00135         virtual void setDynamicsDisableThreshold(Real linearSq, Real angularSq, Real overTime);
00136 
00137         virtual void setCollisionEnabled(bool enabled);
00151         virtual void setDynamicsEnabled(bool enabled, bool reEnableOnInteraction = false);
00152 
00165         virtual void setBounceParameters(Real restitutionValue, Real velocityThreshold);
00167         virtual Real getBounceRestitutionValue(void);
00169         virtual Real getBounceVelocityThreshold(void);
00170 
00178         virtual void setSoftness(Real softness);
00180         virtual Real getSoftness(void);
00181 
00190         virtual void setFriction(Real friction);
00192         virtual Real getFriction(void);
00199         virtual void addForce(const Vector3& direction, const Vector3& atPosition = Vector3::ZERO);
00206         virtual void addForce(Real dir_x, Real dir_y, Real dir_z, 
00207             Real pos_x = 0, Real pos_y = 0, Real pos_z = 0);
00214         virtual void addForceWorldSpace(const Vector3& direction, const Vector3& atPosition = Vector3::ZERO);
00221         virtual void addForceWorldSpace(Real dir_x, Real dir_y, Real dir_z, 
00222         Real pos_x, Real pos_y, Real pos_z);
00227         virtual void addTorque(const Vector3& direction);
00232         virtual void addTorque(Real x, Real y, Real z);
00237         virtual void addTorqueWorldSpace(const Vector3& direction);
00242         virtual void addTorqueWorldSpace(Real x, Real y, Real z);
00243 
00251         virtual bool testCollide(ApplicationObject* otherObj);
00252 
00260         virtual bool testCollide(SceneQuery::WorldFragment* wf);
00261 
00263         struct CollisionInfo
00264         {
00266             Vector3 position;
00268             Vector3 normal;
00270             Real penetrationDepth;
00271         };
00274         virtual void _notifyCollided(ApplicationObject* otherObj, const CollisionInfo& info);
00277         virtual void _notifyCollided(SceneQuery::WorldFragment* wf, const CollisionInfo& info);
00280         SceneNode* getSceneNode(void);
00282         Entity* getEntity(void);
00284         dBody* getOdeBody(void);
00285 
00294         void setMassSphere(Real density, Real radius);
00295 
00304         void setMassBox(Real density, const Vector3& dimensions, 
00305             const Quaternion& orientation = Quaternion::IDENTITY);
00306 
00317         void setMassCappedCylinder(Real density, Real length, Real width, 
00318             const Quaternion& orientation = Quaternion::IDENTITY);
00319 
00325         void setMassExpert(Real mass, const Vector3 center, const Matrix3 inertia);
00326 
00328         const dMass* getOdeMass(void);
00329 
00336         void setLinearVelocity(const Vector3& vel);
00343         void setLinearVelocity(Real x, Real y, Real z);
00349         const Vector3& getLinearVelocity(void);
00350 
00356         const Vector3& getAngularVelocity(void);
00357 
00364         void setAngularVelocity(const Vector3& vel);
00371         void setAngularVelocity(Real x, Real y, Real z);
00372 
00380         virtual void translate(const Vector3& d);
00387         virtual void translate(Real x, Real y, Real z);
00388 
00396         virtual void translateWorldSpace(const Vector3& d);
00403         virtual void translateWorldSpace(Real x, Real y, Real z);
00404 
00407         virtual void roll(const Radian& angle);
00408 #ifndef OGRE_FORCE_ANGLE_TYPES
00409         inline void roll(Real angleunits) {
00410             roll ( Angle(angleunits) );
00411         }
00412 #endif//OGRE_FORCE_ANGLE_TYPES
00413 
00416         virtual void pitch(const Radian& angle);
00417 #ifndef OGRE_FORCE_ANGLE_TYPES
00418         inline void pitch(Real angleunits) {
00419             pitch ( Angle(angleunits) );
00420         }
00421 #endif//OGRE_FORCE_ANGLE_TYPES
00422 
00425         virtual void yaw(const Radian& angle);
00426 #ifndef OGRE_FORCE_ANGLE_TYPES
00427         inline void yaw(Real angleunits) {
00428             yaw ( Angle(angleunits) );
00429         }
00430 #endif//OGRE_FORCE_ANGLE_TYPES
00431 
00434         virtual void rotate(const Vector3& axis, const Radian& angle);
00435 #ifndef OGRE_FORCE_ANGLE_TYPES
00436         inline void rotate(const Vector3& axis, Real angleunits) {
00437             rotate ( axis, Angle(angleunits) );
00438         }
00439 #endif//OGRE_FORCE_ANGLE_TYPES
00440 
00443         virtual void rotate(const Quaternion& q);
00444 
00445 
00446     };
00447 
00448 
00449 } // namespace
00450 
00451 #endif
00452 
00453 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:47 2006