## Public API Reference

- Main Page
- Classes
- Files

# propclass/mechsys.h

    00001 /*
    00002     Crystal Space Entity Layer
    00003     Copyright (C) 2005 by Jorrit Tyberghein
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 #ifndef __CEL_PF_MECHANICS_SYSTEM__
    00021 #define __CEL_PF_MECHANICS_SYSTEM__
    00022
    00023 #include "cstypes.h"
    00024 #include "csutil/scf.h"
    00025
    00026 #include "propclass/mechcommon.h"
    00027
    00028 class csVector3;
    00029 class csBox3;
    00030 class csOrthoTransform;
    00031 class csPlane3;
    00032 struct iDynamicSystem;
    00033 struct iRigidBody;
    00034 struct iSector;
    00035 struct iPcMesh;
    00036 struct iPcLight;
    00037 struct iPcCamera;
    00038 struct iPcMechanicsObject;
    00039 struct iJoint;
    00040
    00056 struct iPcMechanicsSystem : public virtual iBase
    00057 {
    00058   SCF_INTERFACE (iPcMechanicsSystem, 0, 0, 1);
    00059
    00065   virtual void SetDynamicSystem (iDynamicSystem* dynsys) = 0;
    00066
    00072   virtual void SetDynamicSystem (const char *dynsysname) = 0;
    00073
    00074
    00078   virtual iDynamicSystem* GetDynamicSystem () = 0;
    00079
    00084   virtual void SetStepTime (float delta) = 0;
    00085
    00089   virtual float GetStepTime () const = 0;
    00090
    00096   virtual void SetSimulationSpeed (float simulationspeed) = 0;
    00097
    00101   virtual float GetSimulationSpeed () = 0;
    00102
    00107   virtual void SetGravity (const csVector3& grav) = 0;
    00108
    00112   virtual const csVector3 GetGravity () = 0;
    00113
    00126   virtual void AddForceDuration (iPcMechanicsObject* pcobject,
    00127         const csVector3& force, bool relative, const csVector3& position,
    00128         float seconds) = 0;
    00129
    00140   virtual void AddForceFrame (iPcMechanicsObject* pcobject,
    00141         const csVector3& force, bool relative, const csVector3& position) = 0;
    00142
    00155   virtual void AddForceTagged (iPcMechanicsObject* pcobject,
    00156         const csVector3& force, bool relative, const csVector3& position,
    00157         uint32 forceid) = 0;
    00158
    00166   virtual void RemoveForceTagged (iPcMechanicsObject* pcobject,
    00167         uint32 forceid) = 0;
    00168
    00175   virtual void ClearForces (iPcMechanicsObject* pcobject) = 0;
    00176
    00180   virtual void ClearAllForces () = 0;
    00181
    00185   virtual csPtr<iRigidBody> CreateBody () = 0;
    00186
    00191   virtual void RemoveBody (iRigidBody* body) = 0;
    00192
    00199   virtual void AddBodyToGroup (iRigidBody* body, const char* group) = 0;
    00200
    00206   virtual void RemoveBodyFromGroup (iRigidBody* body, const char* group) = 0;
    00207
    00211   virtual iJoint* CreateJoint (iRigidBody* body1, iRigidBody* body2) = 0;
    00212
    00216   virtual void RemoveJoint (iJoint* joint) = 0;
    00217
    00222   virtual void DisableStepFast () = 0;
    00227   virtual void EnableStepFast () = 0;
    00231   virtual void EnableQuickStep () = 0;
    00232 };
    00233
    00284 struct iPcMechanicsObject : public virtual iBase
    00285 {
    00286   SCF_INTERFACE (iPcMechanicsObject, 0, 0, 1);
    00287
    00294   virtual void SetMesh (iPcMesh* mesh) = 0;
    00295
    00299   virtual iPcMesh* GetMesh () = 0;
    00300
    00307   virtual void SetLight (iPcLight* light) = 0;
    00308
    00312   virtual iPcLight* GetLight () = 0;
    00313
    00320   virtual void SetCamera (iPcCamera* camera) = 0;
    00321
    00325   virtual iPcCamera* GetCamera () = 0;
    00326
    00333   virtual void SetMechanicsSystem (iPcMechanicsSystem* mechsys) = 0;
    00334
    00338   virtual iPcMechanicsSystem* GetMechanicsSystem () = 0;
    00339
    00343   virtual iRigidBody* GetBody () = 0;
    00344
    00345
    00347   //Object properties.
    00348
    00354   virtual void SetFriction (float friction) = 0;
    00355
    00361   virtual void SetMass (float mass) = 0;
    00362
    00368   virtual void SetElasticity (float elasticity) = 0;
    00369
    00375   virtual void SetDensity (float density) = 0;
    00376
    00382   virtual void SetSoftness (float softness) = 0;
    00383
    00389   virtual void SetLift (const csVector3& lift) = 0;
    00390
    00396   virtual void SetDrag (float drag) = 0;
    00397
    00402   virtual float GetFriction () = 0;
    00403
    00408   virtual float GetMass () = 0;
    00409
    00414   virtual float GetElasticity () = 0;
    00415
    00420   virtual float GetDensity () = 0;
    00421
    00426   virtual float GetSoftness () = 0;
    00427
    00432   virtual const csVector3& GetLift () = 0;
    00433
    00438   virtual float GetDrag () = 0;
    00439
    00440
    00442   //Initial velocities
    00443
    00448   virtual void SetLinearVelocity (const csVector3& vel) = 0;
    00449
    00454   virtual void SetAngularVelocity (const csVector3& vel) = 0;
    00455
    00456
    00458   //Reading velocities
    00459
    00463   virtual const csVector3 GetLinearVelocity () = 0;
    00464
    00468   virtual const csVector3 GetAngularVelocity () = 0;
    00469
    00470
    00472   //Static objects
    00473
    00479   virtual void MakeStatic (bool stat) = 0;
    00480
    00484   virtual bool IsStatic () const = 0;
    00485
    00486
    00488   //Colliders
    00489
    00493   virtual void AttachColliderBoundingSphere () = 0;
    00494
    00501   virtual void AttachColliderSphere (float radius, const csVector3& offset) = 0;
    00502
    00509   virtual void AttachColliderCylinder (float length, float radius,
    00510         const csOrthoTransform& trans) = 0;
    00511
    00515   virtual void AttachColliderBoundingBox () = 0;
    00516
    00522   virtual void AttachColliderBox (const csVector3& size,
    00523         const csOrthoTransform& trans) = 0;
    00524
    00529   virtual void AttachColliderPlane (const csPlane3& plane) = 0;
    00530
    00534   virtual void AttachColliderMesh () = 0;
    00535
    00536
    00538   //Forces
    00539
    00547   virtual void AddForceOnce (const csVector3& force, bool relative,
    00548         const csVector3& position) = 0;
    00549
    00558   virtual void AddForceDuration (const csVector3& force, bool relative,
    00559         const csVector3& position, float seconds) = 0;
    00560
    00568   virtual void AddForceFrame (const csVector3& force, bool relative,
    00569         const csVector3& position) = 0;
    00570
    00580   virtual uint32 AddForceTagged (const csVector3& force, bool relative,
    00581         const csVector3& position) = 0;
    00582
    00587   virtual void RemoveForceTagged (uint32 forceid) = 0;
    00588
    00592   virtual void ClearForces () = 0;
    00593
    00594
    00596   //Groups and Joints
    00597
    00603   virtual void AddToGroup (const char* group) = 0;
    00604
    00609   virtual void RemoveFromGroup (const char* group) = 0;
    00610
    00614   virtual iJoint* CreateJoint (iPcMechanicsObject* other) = 0;
    00615
    00619   virtual csVector3 LocalToWorld(csVector3 local) = 0;
    00623   virtual csVector3 WorldToLocal(csVector3 world) = 0;
    00624 };
    00625
    00641 struct iPcMechanicsJoint : public virtual iBase
    00642 {
    00643   SCF_INTERFACE (iPcMechanicsJoint, 0, 0, 1);
    00644
    00648   virtual iJoint* GetJoint () = 0;
    00649 };
    00650
    00651 #endif // __CEL_PF_MECHANICS_SYSTEM__
    00652