imesh/skeleton.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

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

- File List
- File Members

imesh/skeleton.h

    00001 /*
    00002     Copyright (C) 2005 by Hristo Hristov
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library 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 GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public
    00015     License along with this library; if not, write to the Free
    00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00017 */
    00018
    00019 #ifndef __CS_ISKELETON_H__
    00020 #define __CS_ISKELETON_H__
    00021
    00022 #include "csutil/scf.h"
    00023 #include "csgeom/box.h"
    00024
    00025 struct iSkeleton;
    00026 struct iSkeletonGraveyard;
    00027 struct iSkeletonFactory;
    00028 struct iSkeletonBoneFactory;
    00029 struct iSkeletonBoneUpdateCallback;
    00030 struct iSkeletonSocket;
    00031 struct iSkeletonSocketFactory;
    00032 struct iSceneNode;
    00033 //struct iSkeletonBoneRagdollInfo;
    00034
    00035 /*
    00036 struct iODEGeom;
    00037 struct iODERigidBody;
    00038 struct iODEJoint;
    00039 struct iODEDynamicSystem;
    00040 */
    00041
    00042 enum csBoneTransformType
    00043 {
    00044   CS_BTT_NONE = 0,
    00045   CS_BTT_SCRIPT,
    00046   CS_BTT_RIGID_BODY
    00047 };
    00048
    00049 enum csBoneGeomType
    00050 {
    00051   CS_BGT_NONE = 0,
    00052   CS_BGT_BOX,
    00053   CS_BGT_SPHERE,
    00054   CS_BGT_CYLINDER
    00055 };
    00056
    00057 class csReversibleTransform;
    00058
    00062 struct iSkeletonBone : public virtual iBase
    00063 {
    00064   SCF_INTERFACE (iSkeletonBone, 1, 0, 1);
    00065
    00069   virtual const char* GetName () const = 0;
    00070
    00074   virtual void SetName (const char* name) = 0;
    00075
    00079   virtual csReversibleTransform &GetTransform () = 0;
    00080
    00084   virtual void SetTransform (const csReversibleTransform &transform) = 0;
    00085
    00089   virtual csReversibleTransform &GetFullTransform () = 0;
    00090
    00094   virtual void SetParent (iSkeletonBone *parent) = 0;
    00095
    00099   virtual iSkeletonBone *GetParent () = 0;
    00100
    00104   virtual size_t GetChildrenCount () = 0;
    00105
    00109   virtual iSkeletonBone *GetChild (size_t i) = 0;
    00110
    00114   virtual iSkeletonBone *FindChild (const char *name) = 0;
    00115
    00119   virtual size_t FindChildIndex (iSkeletonBone *child) = 0;
    00120
    00124   virtual void SetSkinBox (csBox3 &box) = 0;
    00125
    00129   virtual csBox3 &GetSkinBox () = 0;
    00130
    00135   virtual void SetUpdateCallback (iSkeletonBoneUpdateCallback *callback) = 0;
    00136
    00140   virtual iSkeletonBoneUpdateCallback *GetUpdateCallback () = 0;
    00141
    00145   virtual iSkeletonBoneFactory *GetFactory() = 0;
    00146
    00154   virtual void SetTransformMode(csBoneTransformType mode) = 0;
    00155
    00159   virtual csBoneTransformType GetTransformMode() = 0;
    00160
    00161   //virtual void SetRigidBody(iODERigidBody *rigid_body, const csReversibleTransform & offset_transform) = 0;
    00162   //virtual iODERigidBody *GetRigidBody() = 0;
    00163   //virtual void SetJoint(iODEJoint *joint) = 0;
    00164   //virtual iODEJoint *GetJoint() = 0;
    00165 };
    00166
    00170 struct iSkeletonBoneUpdateCallback : public virtual iBase
    00171 {
    00172   SCF_INTERFACE  (iSkeletonBoneUpdateCallback, 0, 0, 1);
    00173
    00174   virtual void UpdateTransform(iSkeletonBone *bone,
    00175       const csReversibleTransform & transform) = 0;
    00176 };
    00177
    00178 class csQuaternion;
    00179
    00184 struct iSkeletonAnimationKeyFrame : public virtual iBase
    00185 {
    00186   SCF_INTERFACE (iSkeletonAnimationKeyFrame, 1, 0, 0);
    00187
    00191   virtual const char* GetName () const = 0;
    00192
    00196   virtual void SetName (const char* name) = 0;
    00197
    00201   virtual csTicks GetDuration () = 0;
    00202
    00206   virtual void SetDuration (csTicks time) = 0;
    00207
    00211   virtual size_t GetTransformsCount() = 0;
    00212
    00216   virtual void AddTransform (iSkeletonBoneFactory *bone,
    00217     csReversibleTransform &transform, bool relative = false) = 0;
    00218
    00223   virtual bool GetTransform (iSkeletonBoneFactory *bone,
    00224       csReversibleTransform &dst_trans) = 0;
    00225
    00229   virtual void SetTransform(iSkeletonBoneFactory *bone,
    00230     csReversibleTransform &transform) = 0;
    00231
    00236   virtual bool GetKeyFrameData (iSkeletonBoneFactory *bone_fact,
    00237     csQuaternion & rot, csVector3 & pos, csQuaternion & tangent,
    00238     bool & relative) = 0;
    00239 };
    00240
    00244 struct iSkeletonAnimation : public virtual iBase
    00245 {
    00246   SCF_INTERFACE (iSkeletonAnimation, 1, 0, 0);
    00247
    00251   virtual const char* GetName () const = 0;
    00252
    00256   virtual void SetName (const char* name) = 0;
    00257
    00261   virtual csTicks GetTime () = 0;
    00262
    00266   virtual void SetTime (csTicks time) = 0;
    00267
    00271   virtual float GetSpeed () = 0;
    00272
    00276   virtual void SetSpeed (float speed) = 0;
    00277
    00281   virtual void SetFactor (float factor) = 0;
    00282
    00286   virtual float GetFactor () = 0;
    00287
    00291   virtual void SetLoop (bool loop) = 0;
    00292
    00296   virtual bool GetLoop () = 0;
    00297
    00301   virtual iSkeletonAnimationKeyFrame *CreateFrame (const char* name) = 0;
    00302
    00306   virtual size_t GetFramesCount () = 0;
    00307
    00311   virtual iSkeletonAnimationKeyFrame *GetFrame (size_t i) = 0;
    00312
    00316   virtual size_t FindFrameIndex (const char *name) = 0;
    00317
    00321   virtual void RemoveFrame (size_t i) = 0;
    00322
    00326   virtual void RemoveAllFrames () = 0;
    00327
    00333   virtual void RecalcSpline () = 0;
    00334 };
    00335
    00340 struct iSkeletonAnimationCallback : public virtual iBase
    00341 {
    00342   SCF_INTERFACE (iSkeletonAnimationCallback, 1, 0, 0);
    00343
    00347   virtual void Execute(iSkeletonAnimation *animation, size_t frame_idx) = 0;
    00348
    00352   virtual void OnFinish(iSkeletonAnimation *animation) = 0;
    00353 };
    00354
    00360 struct iSkeletonUpdateCallback : public virtual iBase
    00361 {
    00362   SCF_INTERFACE (iSkeletonUpdateCallback, 1, 0, 0);
    00363
    00367   virtual void Execute(iSkeleton *skeleton, const csTicks & current_ticks) = 0;
    00368 };
    00369
    00373 struct iSkeletonAnimationInstance : public virtual iBase
    00374 {
    00375   SCF_INTERFACE (iSkeletonAnimationInstance, 1, 0, 0);
    00376
    00380   virtual float GetSpeed () = 0;
    00381
    00385   virtual void SetSpeed (float speed) = 0;
    00386
    00390   virtual void SetFactor (float factor) = 0;
    00391
    00395   virtual float GetFactor () = 0;
    00396
    00400   virtual csTicks GetDuration () = 0;
    00401
    00405   virtual void SetDuration (csTicks time) = 0;
    00406 };
    00407
    00422 struct iSkeleton : public virtual iBase
    00423 {
    00424   SCF_INTERFACE (iSkeleton, 1, 0, 0);
    00425
    00429   virtual const char* GetName () const = 0;
    00430
    00434   virtual void SetName (const char* name) = 0;
    00435
    00439   virtual size_t GetBonesCount () = 0;
    00440
    00444   virtual iSkeletonBone *GetBone (size_t i) = 0;
    00445
    00449   virtual iSkeletonBone *FindBone (const char *name) = 0;
    00450
    00454   virtual size_t FindBoneIndex (const char *name) = 0;
    00455
    00459   virtual iSkeletonAnimation* Execute (const char *animation_name, float blend_factor = 0.0f) = 0;
    00460
    00466   virtual iSkeletonAnimation* Append (const char *animation_name) = 0;
    00467
    00471   virtual iSkeletonAnimationInstance *Play (const char *animation_name) = 0;
    00472
    00476   virtual void Stop (iSkeletonAnimationInstance *anim_instance) = 0;
    00477
    00481   virtual void ClearPendingAnimations () = 0;
    00482
    00486   virtual size_t GetAnimationsCount () = 0;
    00487
    00491   virtual iSkeletonAnimation* GetAnimation (size_t i) = 0;
    00492
    00496   virtual iSkeletonAnimation* FindAnimation (const char *animation_name) = 0;
    00497
    00501   virtual iSkeletonSocket* FindSocket (const char *socketname) = 0;
    00502
    00506   virtual void StopAll () = 0;
    00507
    00511   virtual void Stop (const char* animation_name) = 0;
    00512
    00516   virtual iSkeletonFactory *GetFactory () = 0;
    00517
    00521   virtual void SetAnimationCallback (iSkeletonAnimationCallback *cb) = 0;
    00522
    00523   //virtual void CreateRagdoll(iODEDynamicSystem *dyn_sys, csReversibleTransform & transform) = 0;
    00524   //virtual void DestroyRagdoll() = 0;
    00525
    00529   virtual size_t AddUpdateCallback (
    00530       iSkeletonUpdateCallback *update_callback) = 0;
    00531
    00535   virtual size_t GetUpdateCallbacksCount () = 0;
    00536
    00540   virtual iSkeletonUpdateCallback *GetUpdateCallback(size_t callback_idx) = 0;
    00541
    00545   virtual void RemoveUpdateCallback (size_t callback_idx) = 0;
    00546
    00551   virtual bool UpdateAnimation (csTicks current_time) = 0;
    00552
    00559   virtual void UpdateBones () = 0;
    00560 };
    00561
    00568 struct iSkeletonSocket : public virtual iBase
    00569 {
    00570   SCF_INTERFACE (iSkeletonSocket, 1, 0, 0);
    00571
    00575   virtual const char* GetName () const = 0;
    00576
    00580   virtual void SetName (const char* name) = 0;
    00581
    00585   virtual csReversibleTransform &GetTransform () = 0;
    00586
    00590   virtual void SetTransform (const csReversibleTransform &transform) = 0;
    00591
    00595   virtual csReversibleTransform &GetFullTransform () = 0;
    00596
    00600   virtual void SetBone (iSkeletonBone *bone) = 0;
    00601
    00605   virtual iSkeletonBone *GetBone () = 0;
    00606
    00610   virtual void SetSceneNode (iSceneNode *node) = 0;
    00611
    00615   virtual iSceneNode *GetSceneNode () = 0;
    00616
    00620   virtual iSkeletonSocketFactory *GetFactory () = 0;
    00621 };
    00622
    00623 struct iSkeletonBoneRagdollInfo : public virtual iBase
    00624 {
    00625   SCF_INTERFACE (iSkeletonBoneRagdollInfo, 1, 0, 0);
    00626
    00627   virtual void SetEnabled(bool enabled) = 0;
    00628   virtual bool GetEnabled() = 0;
    00629   virtual void SetAttachToParent(bool attach) = 0;
    00630   virtual bool GetAttachToParent() = 0;
    00631
    00632   virtual void SetGeomName(const char *name) = 0;
    00633   virtual const char *GetGeomName() = 0;
    00634   virtual void SetGeomType(int geom_type) = 0;
    00635   virtual int GetGeomType() = 0;
    00636   virtual void SetGeomDimensions(csVector3 &size) = 0;
    00637   virtual csVector3 &GetGeomDimensions() = 0;
    00638
    00639   virtual void SetFriction(float friction) = 0;
    00640   virtual float GetFriction() = 0;
    00641   virtual void SetElasticity(float elasticity) = 0;
    00642   virtual float GetElasticity() = 0;
    00643   virtual void SetSoftness(float softness) = 0;
    00644   virtual float GetSoftness() = 0;
    00645   virtual void SetSlip(float slip) = 0;
    00646   virtual float GetSlip() = 0;
    00647
    00648   virtual void SetBodyName(const char *name) = 0;
    00649   virtual const char *GetBodyName() = 0;
    00650   virtual void SetBodyMass(float mass) = 0;
    00651   virtual float GetBodyMass() = 0;
    00652   virtual void SetBodyGravmode(int gravmode) = 0;
    00653   virtual int GetBodyGravmode() = 0;
    00654
    00655   virtual void SetJointName(const char *name) = 0;
    00656   virtual const char *GetJointName() = 0;
    00657   virtual void SetJointMinRotContraints(csVector3 & constraints) = 0;
    00658   virtual csVector3 & GetJointMinRotContraints() = 0;
    00659   virtual void SetJointMaxRotContraints(csVector3 & constraints) = 0;
    00660   virtual csVector3 & GetJointMaxRotContraints() = 0;
    00661   virtual void SetJointMinTransContraints(csVector3 & constraints) = 0;
    00662   virtual csVector3 & GetJointMinTransContraints() = 0;
    00663   virtual void SetJointMaxTransContraints(csVector3 & constraints) = 0;
    00664   virtual csVector3 & GetJointMaxTransContraints() = 0;
    00665 };
    00666
    00671 struct iSkeletonBoneFactory : public virtual iBase
    00672 {
    00673   SCF_INTERFACE (iSkeletonBoneFactory, 1, 0, 0);
    00674
    00678   virtual const char* GetName () const = 0;
    00679
    00683   virtual void SetName (const char* name) = 0;
    00684
    00688   virtual csReversibleTransform &GetTransform () = 0;
    00689
    00693   virtual void SetTransform (const csReversibleTransform &transform) = 0;
    00694
    00698   virtual csReversibleTransform &GetFullTransform () = 0;
    00699
    00703   virtual  void SetParent (iSkeletonBoneFactory *parent) = 0;
    00704
    00708   virtual iSkeletonBoneFactory *GetParent () = 0;
    00709
    00713   virtual size_t GetChildrenCount () = 0;
    00714
    00718   virtual iSkeletonBoneFactory *GetChild (size_t i) = 0;
    00719
    00723   virtual iSkeletonBoneFactory *FindChild (const char *name) = 0;
    00724
    00728   virtual size_t FindChildIndex (iSkeletonBoneFactory *child) = 0;
    00729
    00733   virtual void SetSkinBox (csBox3 & box) = 0;
    00734
    00738   virtual csBox3 & GetSkinBox () = 0;
    00739
    00743   virtual iSkeletonBoneRagdollInfo *GetRagdollInfo() = 0;
    00744 };
    00745
    00750 struct iSkeletonSocketFactory : public virtual iBase
    00751 {
    00752   SCF_INTERFACE (iSkeletonSocketFactory, 1, 0, 0);
    00753
    00757   virtual const char* GetName () const = 0;
    00758
    00762   virtual void SetName (const char* name) = 0;
    00763
    00767   virtual csReversibleTransform &GetTransform () = 0;
    00768
    00772   virtual void SetTransform (const csReversibleTransform &transform) = 0;
    00773
    00777   virtual csReversibleTransform &GetFullTransform () = 0;
    00778
    00782   virtual void SetBone (iSkeletonBoneFactory *bone) = 0;
    00783
    00787   virtual iSkeletonBoneFactory *GetBone () = 0;
    00788 };
    00789
    00794 struct iSkeletonFactory : public virtual iBase
    00795 {
    00796   SCF_INTERFACE (iSkeletonFactory, 1, 0, 0);
    00797
    00801   virtual const char* GetName () const = 0;
    00802
    00806   virtual void SetName (const char* name) = 0;
    00807
    00811   virtual iSkeletonBoneFactory *CreateBone (const char *name) = 0;
    00812
    00816   virtual iSkeletonAnimation *CreateAnimation (const char *name) = 0;
    00817
    00821   virtual iSkeletonAnimation *FindAnimation (const char *name) = 0;
    00822
    00826   virtual size_t GetAnimationsCount () = 0;
    00827
    00831   virtual iSkeletonAnimation *GetAnimation (size_t idx) = 0;
    00832
    00836   virtual iSkeletonBoneFactory *FindBone (const char *name) = 0;
    00837
    00841   virtual size_t FindBoneIndex (const char *name) = 0;
    00842
    00846   virtual size_t GetBonesCount () const = 0;
    00847
    00851   virtual iSkeletonBoneFactory *GetBone(size_t i) = 0;
    00852
    00856   virtual iSkeletonGraveyard *GetGraveyard  () = 0;
    00857
    00861   virtual iSkeletonSocketFactory *CreateSocket(const char *name,
    00862       iSkeletonBoneFactory *bone) = 0;
    00863
    00867   virtual iSkeletonSocketFactory *FindSocket(const char *name) = 0;
    00868
    00872   virtual iSkeletonSocketFactory *GetSocket (int i) = 0;
    00873
    00877   virtual void RemoveSocket (int i) = 0;
    00878
    00882   virtual size_t GetSocketsCount() = 0;
    00883 };
    00884
    00885
    00891 struct iSkeletonGraveyard : public virtual iBase
    00892 {
    00893   SCF_INTERFACE (iSkeletonGraveyard, 1, 0, 0);
    00894
    00898   virtual size_t GetFactoriesCount() = 0;
    00899
    00903   virtual iSkeletonFactory *CreateFactory(const char *name) = 0;
    00904
    00908   virtual iSkeletonFactory *LoadFactory(const char *file_name) = 0;
    00909
    00913   virtual iSkeletonFactory *FindFactory(const char *name) = 0;
    00914
    00918   virtual iSkeleton *CreateSkeleton(iSkeletonFactory *fact,
    00919       const char *name = 0) = 0;
    00920
    00924   virtual void SetManualUpdates (bool man_updates) = 0;
    00925
    00929   virtual void Update (csTicks time) = 0;
    00930
    00934   virtual void AddSkeleton (iSkeleton *skeleton) = 0;
    00935
    00939   virtual void RemoveSkeleton (iSkeleton* skeleton) = 0;
    00940 };
    00941
    00942 #endif //__CS_ISKELETON_H__