Blender V2.61 - r43446

PHY_IPhysicsController.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef PHY_IPHYSICSCONTROLLER_H
00033 #define PHY_IPHYSICSCONTROLLER_H
00034 
00035 #include "PHY_IController.h"
00036 
00037 class PHY_IMotionState;
00038 class PHY_IPhysicsEnvironment;
00039 
00044 class PHY_IPhysicsController : public PHY_IController
00045 {
00046 
00047     public:
00048         virtual ~PHY_IPhysicsController();
00052         virtual bool        SynchronizeMotionStates(float time)=0;
00057         virtual void        WriteMotionStateToDynamics(bool nondynaonly)=0;
00058         virtual void        WriteDynamicsToMotionState()=0;
00059         virtual class PHY_IMotionState* GetMotionState() = 0;
00060         // controller replication
00061         virtual void        PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0;
00062 
00063         // kinematic methods
00064         virtual void        RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)=0;
00065         virtual void        RelativeRotate(const float drot[12],bool local)=0;
00066         virtual void        getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)=0;
00067         virtual void        setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)=0;
00068         virtual void        setPosition(float posX,float posY,float posZ)=0;
00069         virtual void        getPosition(PHY__Vector3&   pos) const=0;
00070         virtual void        setScaling(float scaleX,float scaleY,float scaleZ)=0;
00071         
00072         // physics methods
00073         virtual void        ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)=0;
00074         virtual void        ApplyForce(float forceX,float forceY,float forceZ,bool local)=0;
00075         virtual void        SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)=0;
00076         virtual void        SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)=0;
00077         virtual void        resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
00078 
00079         virtual void        applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)=0;
00080         virtual void        SetActive(bool active)=0;
00081 
00082         // reading out information from physics
00083         virtual void        GetLinearVelocity(float& linvX,float& linvY,float& linvZ)=0;
00084         virtual void        GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)=0; 
00085         virtual void        getReactionForce(float& forceX,float& forceY,float& forceZ)=0;
00086 
00087         // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
00088         virtual void        setRigidBody(bool rigid)=0;
00089 
00090         virtual PHY_IPhysicsController* GetReplica() {return 0;}
00091 
00092         virtual void    calcXform() =0;
00093         virtual void SetMargin(float margin) =0;
00094         virtual float GetMargin() const=0;
00095         virtual float GetRadius() const=0;
00096         virtual void  SetRadius(float margin) = 0;
00097 
00098         virtual float GetLinVelocityMin() const=0;
00099         virtual void  SetLinVelocityMin(float val) = 0;
00100         virtual float GetLinVelocityMax() const=0;
00101         virtual void  SetLinVelocityMax(float val) = 0;
00102         
00103         PHY__Vector3    GetWorldPosition(PHY__Vector3& localpos);
00104 
00105 #ifdef WITH_CXX_GUARDEDALLOC
00106 public:
00107     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IPhysicsController"); }
00108     void operator delete( void *mem ) { MEM_freeN(mem); }
00109 #endif
00110 };
00111 
00112 #endif //PHY_IPHYSICSCONTROLLER_H
00113