## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# ivaria/ode.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2003 by Jorrit Tyberghein, Daniel Duhprey,
    00003     Leandro Motta Barros
    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., 675 Mass Ave, Cambridge, MA 02139, USA.
    00018 */
    00019
    00020 #ifndef __CS_IVARIA_ODE_H__
    00021 #define __CS_IVARIA_ODE_H__
    00022
    00027 #include "csutil/scf.h"
    00028
    00029 SCF_VERSION (iODEFrameUpdateCallback, 0, 0, 1);
    00030
    00035 struct iODEFrameUpdateCallback : public iBase
    00036 {
    00038   virtual void Execute (float stepsize) = 0;
    00039 };
    00040
    00041 SCF_VERSION (iODEDynamicState, 0, 0, 1);
    00042
    00047 struct iODEDynamicState : public iBase
    00048 {
    00049
    00051   virtual void SetGlobalERP (float erp) = 0;
    00052   virtual float GlobalERP () = 0;
    00053
    00055   virtual void SetGlobalCFM (float cfm) = 0;
    00056   virtual float GlobalCFM () = 0;
    00057
    00059   virtual void EnableStepFast (bool enable) = 0;
    00060   virtual bool StepFastEnabled () = 0;
    00061   virtual void SetStepFastIterations (int iter) = 0;
    00062   virtual int StepFastIterations () = 0;
    00063
    00064   virtual void EnableQuickStep (bool enable) = 0;
    00065   virtual bool QuickStepEnabled () = 0;
    00066   virtual void SetQuickStepIterations (int iter) = 0;
    00067   virtual int QuickStepIterations () = 0;
    00068
    00084   virtual void EnableFrameRate (bool enable) = 0;
    00085   virtual bool FrameRateEnabled () = 0;
    00086
    00087   virtual void SetFrameRate (float hz) = 0;
    00088   virtual float FrameRate () = 0;
    00089
    00090   virtual void SetFrameLimit (float hz) = 0;
    00091   virtual float FrameLimit () = 0;
    00092
    00093   virtual void AddFrameUpdateCallback (iODEFrameUpdateCallback *cb) = 0;
    00094   virtual void RemoveFrameUpdateCallback (iODEFrameUpdateCallback *cb) = 0;
    00095
    00101   virtual void EnableEventProcessing (bool enable) = 0;
    00102   virtual bool EventProcessingEnabled () = 0;
    00103
    00115   virtual void EnableFastObjects (bool enable) = 0;
    00116   virtual bool FastObjectsEnabled () = 0;
    00117
    00118 };
    00119
    00120 SCF_VERSION (iODEDynamicSystemState, 0, 0, 2);
    00121
    00122 struct iODEBallJoint;
    00123 struct iODEHingeJoint;
    00124 struct iODEHinge2Joint;
    00125 struct iODEAMotorJoint;
    00126 struct iODEUniversalJoint;
    00127 struct iODESliderJoint;
    00128
    00134 struct iODEDynamicSystemState : public iBase
    00135 {
    00141   virtual void SetERP (float erp) = 0;
    00142   virtual float ERP () = 0;
    00143
    00149   virtual void SetCFM (float cfm) = 0;
    00150   virtual float CFM () = 0;
    00151
    00157   virtual void EnableStepFast (bool enable) = 0;
    00158   virtual bool StepFastEnabled () = 0;
    00159   virtual void SetStepFastIterations (int iter) = 0;
    00160   virtual int StepFastIterations () = 0;
    00161
    00162   virtual void EnableQuickStep (bool enable) = 0;
    00163   virtual bool QuickStepEnabled () = 0;
    00164   virtual void SetQuickStepIterations (int iter) = 0;
    00165   virtual int QuickStepIterations () = 0;
    00166
    00172   virtual void EnableAutoDisable (bool enable) = 0;
    00173   virtual bool AutoDisableEnabled () =0;
    00183   virtual void SetAutoDisableParams (float linear, float angular, int steps,
    00184     float time)=0;
    00185
    00202   virtual void EnableFrameRate (bool enable) = 0;
    00203   virtual bool FrameRateEnabled () = 0;
    00204
    00205   virtual void SetFrameRate (float hz) = 0;
    00206   virtual float FrameRate () = 0;
    00207
    00208   virtual void SetFrameLimit (float hz) = 0;
    00209   virtual float FrameLimit () = 0;
    00210
    00211   virtual void AddFrameUpdateCallback (iODEFrameUpdateCallback *cb) = 0;
    00212   virtual void RemoveFrameUpdateCallback (iODEFrameUpdateCallback *cb) = 0;
    00213
    00227   virtual void EnableFastObjects (bool enable) = 0;
    00228   virtual bool FastObjectsEnabled () = 0;
    00229
    00231   virtual csPtr<iODEBallJoint> CreateBallJoint () = 0;
    00232
    00234   virtual csPtr<iODEHingeJoint> CreateHingeJoint () = 0;
    00235
    00237   virtual csPtr<iODEHinge2Joint> CreateHinge2Joint () = 0;
    00238
    00240   virtual csPtr<iODEAMotorJoint> CreateAMotorJoint () = 0;
    00241
    00243   virtual csPtr<iODEUniversalJoint> CreateUniversalJoint () = 0;
    00244
    00246   virtual csPtr<iODESliderJoint> CreateSliderJoint () = 0;
    00247
    00249   virtual void RemoveJoint (iODEBallJoint* joint) = 0;
    00250
    00252   virtual void RemoveJoint (iODEHingeJoint* joint) = 0;
    00253
    00255   virtual void RemoveJoint (iODEAMotorJoint* joint) = 0;
    00256
    00258   virtual void RemoveJoint (iODEUniversalJoint* joint) = 0;
    00259
    00261   virtual void RemoveJoint (iODESliderJoint* joint) = 0;
    00262
    00264   virtual void RemoveJoint (iODEHinge2Joint* joint) = 0;
    00265
    00273   virtual void SetContactMaxCorrectingVel (float v) = 0;
    00274
    00281   virtual float GetContactMaxCorrectingVel () = 0;
    00282
    00292   virtual void SetContactSurfaceLayer (float depth) = 0;
    00293
    00303   virtual float GetContactSurfaceLayer () = 0;
    00304 };
    00305
    00310 enum ODEJointType
    00311 {
    00312   CS_ODE_JOINT_TYPE_UNKNOWN = -1,
    00313   CS_ODE_JOINT_TYPE_BALL,
    00314   CS_ODE_JOINT_TYPE_HINGE,
    00315   CS_ODE_JOINT_TYPE_SLIDER,
    00316   CS_ODE_JOINT_TYPE_CONTACT,
    00317   CS_ODE_JOINT_TYPE_UNIVERSAL,
    00318   CS_ODE_JOINT_TYPE_HINGE2,
    00319   CS_ODE_JOINT_TYPE_FIXED,
    00320   CS_ODE_JOINT_TYPE_AMOTOR
    00321 };
    00322
    00323 SCF_VERSION (iODEJointState, 0, 0, 2);
    00324
    00328 struct iODEJointState : public iBase
    00329 {
    00330   virtual ODEJointType GetType() = 0;
    00331
    00332   // Baaad interface. Are those number axes? If so, perhaps pass it as
    00333   // parameter.
    00334   virtual void SetLoStop (float value) = 0;
    00335   virtual void SetHiStop (float value) = 0;
    00336   virtual void SetVel (float value) = 0;
    00337   virtual void SetFMax (float value) = 0;
    00338   virtual void SetFudgeFactor (float value) = 0;
    00339   virtual void SetBounce (float value) = 0;
    00340   virtual void SetCFM (float value) = 0;
    00341   virtual void SetStopERP (float value) = 0;
    00342   virtual void SetStopCFM (float value) = 0;
    00343   virtual void SetSuspensionERP (float value) = 0;
    00344   virtual void SetSuspensionCFM (float value) = 0;
    00345
    00346   virtual void SetLoStop2 (float value) = 0;
    00347   virtual void SetHiStop2 (float value) = 0;
    00348   virtual void SetVel2 (float value) = 0;
    00349   virtual void SetFMax2 (float value) = 0;
    00350   virtual void SetFudgeFactor2 (float value) = 0;
    00351   virtual void SetBounce2 (float value) = 0;
    00352   virtual void SetCFM2 (float value) = 0;
    00353   virtual void SetStopERP2 (float value) = 0;
    00354   virtual void SetStopCFM2 (float value) = 0;
    00355   virtual void SetSuspensionERP2 (float value) = 0;
    00356   virtual void SetSuspensionCFM2 (float value) = 0;
    00357
    00358   virtual void SetLoStop3 (float value) = 0;
    00359   virtual void SetHiStop3 (float value) = 0;
    00360   virtual void SetVel3 (float value) = 0;
    00361   virtual void SetFMax3 (float value) = 0;
    00362   virtual void SetFudgeFactor3 (float value) = 0;
    00363   virtual void SetBounce3 (float value) = 0;
    00364   virtual void SetCFM3 (float value) = 0;
    00365   virtual void SetStopERP3 (float value) = 0;
    00366   virtual void SetStopCFM3 (float value) = 0;
    00367   virtual void SetSuspensionERP3 (float value) = 0;
    00368   virtual void SetSuspensionCFM3 (float value) = 0;
    00369
    00370   virtual float GetLoStop () = 0;
    00371   virtual float GetHiStop () = 0;
    00372   virtual float GetVel () = 0;
    00373   virtual float GetFMax () = 0;
    00374   virtual float GetFudgeFactor () = 0;
    00375   virtual float GetBounce () = 0;
    00376   virtual float GetCFM () = 0;
    00377   virtual float GetStopERP () = 0;
    00378   virtual float GetStopCFM () = 0;
    00379   virtual float GetSuspensionERP () = 0;
    00380   virtual float GetSuspensionCFM () = 0;
    00381
    00382   virtual float GetLoStop2 () = 0;
    00383   virtual float GetHiStop2 () = 0;
    00384   virtual float GetVel2 () = 0;
    00385   virtual float GetFMax2 () = 0;
    00386   virtual float GetFudgeFactor2 () = 0;
    00387   virtual float GetBounce2 () = 0;
    00388   virtual float GetCFM2 () = 0;
    00389   virtual float GetStopERP2 () = 0;
    00390   virtual float GetStopCFM2 () = 0;
    00391   virtual float GetSuspensionERP2 () = 0;
    00392   virtual float GetSuspensionCFM2 () = 0;
    00393
    00394   virtual float GetLoStop3 () = 0;
    00395   virtual float GetHiStop3 () = 0;
    00396   virtual float GetVel3 () = 0;
    00397   virtual float GetFMax3 () = 0;
    00398   virtual float GetFudgeFactor3 () = 0;
    00399   virtual float GetBounce3 () = 0;
    00400   virtual float GetCFM3 () = 0;
    00401   virtual float GetStopERP3 () = 0;
    00402   virtual float GetStopCFM3 () = 0;
    00403   virtual float GetSuspensionERP3 () = 0;
    00404   virtual float GetSuspensionCFM3 () = 0;
    00405
    00406   // This is a very ugly hack quite specific to NmS
    00407   virtual void SetHinge2Axis1 (const csVector3& axis) = 0;
    00408   virtual void SetHinge2Axis2 (const csVector3& axis) = 0;
    00409   virtual void SetHinge2Anchor (const csVector3& point) = 0;
    00410 };
    00411
    00415 struct iODEGeneralJointState : public iBase
    00416 {
    00421   virtual void SetLoStop (float value, int axis) = 0;
    00422
    00428   virtual void SetHiStop (float value, int axis) = 0;
    00429
    00431   virtual void SetVel (float value, int axis) = 0;
    00432
    00438   virtual void SetFMax (float value, int axis) = 0;
    00439
    00450   virtual void SetFudgeFactor (float value, int axis) = 0;
    00451
    00457   virtual void SetBounce (float value, int axis) = 0;
    00458
    00463   virtual void SetCFM (float value, int axis) = 0;
    00464
    00466   virtual void SetStopERP (float value, int axis) = 0;
    00467
    00474   virtual void SetStopCFM (float value, int axis) = 0;
    00475
    00477   virtual void SetSuspensionERP (float value, int axis) = 0;
    00478
    00480   virtual void SetSuspensionCFM (float value, int axis) = 0;
    00481
    00483   virtual float GetLoStop (int axis) = 0;
    00484
    00486   virtual float GetHiStop (int axis) = 0;
    00487
    00489   virtual float GetVel (int axis) = 0;
    00490
    00495   virtual float GetFMax (int axis) = 0;
    00496
    00498   virtual float GetFudgeFactor (int axis) = 0;
    00499
    00501   virtual float GetBounce (int axis) = 0;
    00502
    00507   virtual float GetCFM (int axis) = 0;
    00508
    00510   virtual float GetStopERP (int axis) = 0;
    00511
    00513   virtual float GetStopCFM (int axis) = 0;
    00514
    00516   virtual float GetSuspensionERP (int axis) = 0;
    00517
    00519   virtual float GetSuspensionCFM (int axis) = 0;
    00520
    00528   virtual void Attach (iRigidBody *body1, iRigidBody *body2) = 0;
    00529
    00531   virtual csRef<iRigidBody> GetAttachedBody (int body) = 0;
    00532
    00534   virtual csVector3 GetFeedbackForce1 () = 0;
    00535
    00537   virtual csVector3 GetFeedbackTorque1 () = 0;
    00538
    00540   virtual csVector3 GetFeedbackForce2 () = 0;
    00541
    00543   virtual csVector3 GetFeedbackTorque2 () = 0;
    00544
    00545 };
    00546
    00547 SCF_VERSION (iODESliderJoint, 0, 0, 1);
    00548
    00549 struct iODESliderJoint : public iODEGeneralJointState
    00550 {
    00552   virtual void SetSliderAxis (float x, float y, float z) = 0;
    00553
    00555   virtual csVector3 GetSliderAxis () = 0;
    00556
    00562   virtual float GetSliderPosition () = 0;
    00563
    00565   virtual float GetSliderPositionRate () = 0;
    00566 };
    00567
    00568 SCF_VERSION (iODEUniversalJoint, 0, 0, 1);
    00576 struct iODEUniversalJoint : public iODEGeneralJointState
    00577 {
    00579   virtual void SetUniversalAnchor (float x, float y, float z) = 0;
    00580
    00582   virtual void SetUniversalAxis1 (float x, float y, float z) = 0;
    00583
    00585   virtual void SetUniversalAxis2 (float x, float y, float z) = 0;
    00586
    00592   virtual csVector3 GetUniversalAnchor1 () = 0;
    00593
    00599   virtual csVector3 GetUniversalAnchor2 () = 0;
    00600
    00602   virtual csVector3 GetUniversalAxis1 () = 0;
    00603
    00605   virtual csVector3 GetUniversalAxis2 () = 0;
    00606
    00607 };
    00608
    00609 enum ODEAMotorMode
    00610 {
    00611   CS_ODE_AMOTOR_MODE_UNKNOWN = -1,
    00612
    00613   CS_ODE_AMOTOR_MODE_USER = 0,
    00614   CS_ODE_AMOTOR_MODE_EULER,
    00615
    00616   CS_ODE_AMOTOR_MODE_LAST
    00617 };
    00618
    00619 SCF_VERSION (iODEAMotorJoint, 0, 0, 1);
    00620
    00632 struct iODEAMotorJoint : public iODEGeneralJointState
    00633 {
    00634
    00644   virtual void SetAMotorMode (ODEAMotorMode mode) = 0;
    00645
    00649   virtual ODEAMotorMode GetAMotorMode () = 0;
    00650
    00657   virtual void SetAMotorNumAxes (int axis_num) = 0;
    00658
    00663   virtual int GetAMotorNumAxes () = 0;
    00664
    00674   virtual void SetAMotorAxis (int axis_num, int rel_orient, float x, float y,
    00675         float z) = 0;
    00676
    00685   virtual void SetAMotorAxis (int axis_num, int rel_orient,
    00686         const csVector3 &axis) = 0;
    00687
    00691   virtual csVector3 GetAMotorAxis (int axis_num) = 0;
    00692
    00699   virtual int GetAMotorAxisRelOrientation (int axis_num) = 0;
    00700
    00708   virtual void SetAMotorAngle (int axis_num, float angle) = 0;
    00709
    00715   virtual float GetAMotorAngle (int axis_num) = 0;
    00716
    00722   virtual float GetAMotorAngleRate (int axis_num) = 0;
    00723 };
    00724
    00725 SCF_VERSION (iODEHinge2Joint, 0, 0, 1);
    00726
    00731 struct iODEHinge2Joint : public iODEGeneralJointState
    00732 {
    00737   virtual void SetHingeAnchor (const csVector3 &pos) = 0;
    00738
    00742   virtual void SetHingeAxis1 (const csVector3 &axis) = 0;
    00743
    00747   virtual void SetHingeAxis2 (const csVector3 &axis) = 0;
    00748
    00749
    00754   virtual csVector3 GetHingeAnchor1 () = 0;
    00755
    00760   virtual csVector3 GetHingeAnchor2 () = 0;
    00761
    00765   virtual csVector3 GetHingeAxis1 () = 0;
    00766
    00770   virtual csVector3 GetHingeAxis2 () = 0;
    00771
    00778   virtual float GetHingeAngle () = 0;
    00779
    00783   virtual float GetHingeAngleRate1 () = 0;
    00784
    00788   virtual float GetHingeAngleRate2 () = 0;
    00789
    00793   virtual csVector3 GetAnchorError () = 0;
    00794
    00795 };
    00796
    00797 SCF_VERSION (iODEHingeJoint, 0, 0, 1);
    00798
    00802 struct iODEHingeJoint : public iODEGeneralJointState
    00803 {
    00808   virtual void SetHingeAnchor (const csVector3 &pos) = 0;
    00809
    00813   virtual void SetHingeAxis (const csVector3 &axis) = 0;
    00814
    00819   virtual csVector3 GetHingeAnchor1 () = 0;
    00820
    00825   virtual csVector3 GetHingeAnchor2 () = 0;
    00826
    00830   virtual csVector3 GetHingeAxis () = 0;
    00831
    00838   virtual float GetHingeAngle () = 0;
    00839
    00843   virtual float GetHingeAngleRate () = 0;
    00844
    00848   virtual csVector3 GetAnchorError () = 0;
    00849
    00850 };
    00851
    00852 SCF_VERSION (iODEBallJoint, 0, 0, 1);
    00853
    00857 struct iODEBallJoint : public iBase
    00858 {
    00863   virtual void SetBallAnchor (const csVector3 &pos) = 0;
    00864
    00869   virtual csVector3 GetBallAnchor1 () = 0;
    00870
    00875   virtual csVector3 GetBallAnchor2 () = 0;
    00876
    00880   virtual csVector3 GetAnchorError () = 0;
    00881
    00889   virtual void Attach (iRigidBody *body1, iRigidBody *body2) = 0;
    00890
    00892   virtual csRef<iRigidBody> GetAttachedBody (int body) = 0;
    00893
    00895   virtual csVector3 GetFeedbackForce1 () = 0;
    00896
    00898   virtual csVector3 GetFeedbackTorque1 () = 0;
    00899
    00901   virtual csVector3 GetFeedbackForce2 () = 0;
    00902
    00904   virtual csVector3 GetFeedbackTorque2 () = 0;
    00905 };
    00906
    00907
    00908
    00909 #endif // __CS_IVARIA_ODE_H__