CEL: Crystal Entity Layer: propclass/mechsys.h Source File (CEL: Crystal Entity Layer Public API Reference)

| ## 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
    00095   virtual void SetGravity (const csVector3& grav) = 0;
    00096
    00100   virtual const csVector3 GetGravity () = 0;
    00101
    00114   virtual void AddForceDuration (iPcMechanicsObject* pcobject,
    00115         const csVector3& force, bool relative, const csVector3& position,
    00116         float seconds) = 0;
    00117
    00128   virtual void AddForceFrame (iPcMechanicsObject* pcobject,
    00129         const csVector3& force, bool relative, const csVector3& position) = 0;
    00130
    00143   virtual void AddForceTagged (iPcMechanicsObject* pcobject,
    00144         const csVector3& force, bool relative, const csVector3& position,
    00145         uint32 forceid) = 0;
    00146
    00154   virtual void RemoveForceTagged (iPcMechanicsObject* pcobject,
    00155         uint32 forceid) = 0;
    00156
    00163   virtual void ClearForces (iPcMechanicsObject* pcobject) = 0;
    00164
    00168   virtual void ClearAllForces () = 0;
    00169
    00173   virtual csPtr<iRigidBody> CreateBody () = 0;
    00174
    00179   virtual void RemoveBody (iRigidBody* body) = 0;
    00180
    00187   virtual void AddBodyToGroup (iRigidBody* body, const char* group) = 0;
    00188
    00194   virtual void RemoveBodyFromGroup (iRigidBody* body, const char* group) = 0;
    00195
    00199   virtual iJoint* CreateJoint (iRigidBody* body1, iRigidBody* body2) = 0;
    00200
    00204   virtual void RemoveJoint (iJoint* joint) = 0;
    00205
    00210   virtual void DisableStepFast () = 0;
    00215   virtual void EnableStepFast () = 0;
    00219   virtual void EnableQuickStep () = 0;
    00220 };
    00221
    00272 struct iPcMechanicsObject : public virtual iBase
    00273 {
    00274   SCF_INTERFACE (iPcMechanicsObject, 0, 0, 1);
    00275
    00282   virtual void SetMesh (iPcMesh* mesh) = 0;
    00283
    00287   virtual iPcMesh* GetMesh () = 0;
    00288
    00295   virtual void SetLight (iPcLight* light) = 0;
    00296
    00300   virtual iPcLight* GetLight () = 0;
    00301
    00308   virtual void SetCamera (iPcCamera* camera) = 0;
    00309
    00313   virtual iPcCamera* GetCamera () = 0;
    00314
    00321   virtual void SetMechanicsSystem (iPcMechanicsSystem* mechsys) = 0;
    00322
    00326   virtual iPcMechanicsSystem* GetMechanicsSystem () = 0;
    00327
    00331   virtual iRigidBody* GetBody () = 0;
    00332
    00333
    00335   //Object properties.
    00336
    00342   virtual void SetFriction (float friction) = 0;
    00343
    00349   virtual void SetMass (float mass) = 0;
    00350
    00356   virtual void SetElasticity (float elasticity) = 0;
    00357
    00363   virtual void SetDensity (float density) = 0;
    00364
    00370   virtual void SetSoftness (float softness) = 0;
    00371
    00377   virtual void SetLift (const csVector3& lift) = 0;
    00378
    00384   virtual void SetDrag (float drag) = 0;
    00385
    00390   virtual float GetFriction () = 0;
    00391
    00396   virtual float GetMass () = 0;
    00397
    00402   virtual float GetElasticity () = 0;
    00403
    00408   virtual float GetDensity () = 0;
    00409
    00414   virtual float GetSoftness () = 0;
    00415
    00420   virtual const csVector3& GetLift () = 0;
    00421
    00426   virtual float GetDrag () = 0;
    00427
    00428
    00430   //Initial velocities
    00431
    00436   virtual void SetLinearVelocity (const csVector3& vel) = 0;
    00437
    00442   virtual void SetAngularVelocity (const csVector3& vel) = 0;
    00443
    00444
    00446   //Reading velocities
    00447
    00451   virtual const csVector3 GetLinearVelocity () = 0;
    00452
    00456   virtual const csVector3 GetAngularVelocity () = 0;
    00457
    00458
    00460   //Static objects
    00461
    00467   virtual void MakeStatic (bool stat) = 0;
    00468
    00472   virtual bool IsStatic () const = 0;
    00473
    00474
    00476   //Colliders
    00477
    00484   virtual void AttachColliderSphere (float radius, const csVector3& offset) = 0;
    00485
    00492   virtual void AttachColliderCylinder (float length, float radius,
    00493         const csOrthoTransform& trans) = 0;
    00494
    00500   virtual void AttachColliderBox (const csVector3& size,
    00501         const csOrthoTransform& trans) = 0;
    00502
    00507   virtual void AttachColliderPlane (const csPlane3& plane) = 0;
    00508
    00512   virtual void AttachColliderMesh () = 0;
    00513
    00514
    00516   //Forces
    00517
    00525   virtual void AddForceOnce (const csVector3& force, bool relative,
    00526         const csVector3& position) = 0;
    00527
    00536   virtual void AddForceDuration (const csVector3& force, bool relative,
    00537         const csVector3& position, float seconds) = 0;
    00538
    00546   virtual void AddForceFrame (const csVector3& force, bool relative,
    00547         const csVector3& position) = 0;
    00548
    00558   virtual uint32 AddForceTagged (const csVector3& force, bool relative,
    00559         const csVector3& position) = 0;
    00560
    00565   virtual void RemoveForceTagged (uint32 forceid) = 0;
    00566
    00570   virtual void ClearForces () = 0;
    00571
    00572
    00574   //Groups and Joints
    00575
    00581   virtual void AddToGroup (const char* group) = 0;
    00582
    00587   virtual void RemoveFromGroup (const char* group) = 0;
    00588
    00592   virtual iJoint* CreateJoint (iPcMechanicsObject* other) = 0;
    00593
    00597   virtual csVector3 LocalToWorld(csVector3 local) = 0;
    00601   virtual csVector3 WorldToLocal(csVector3 world) = 0;
    00602 };
    00603
    00619 struct iPcMechanicsJoint : public virtual iBase
    00620 {
    00621   SCF_INTERFACE (iPcMechanicsJoint, 0, 0, 1);
    00622
    00626   virtual iJoint* GetJoint () = 0;
    00627 };
    00628
    00629 #endif // __CEL_PF_MECHANICS_SYSTEM__
    00630