CrystalSpace

Public API Reference

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, 0);
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 
00150   virtual void SetTransformMode(csBoneTransformType mode) = 0;
00151 
00155   virtual csBoneTransformType GetTransformMode() = 0;
00156 
00157   //virtual void SetRigidBody(iODERigidBody *rigid_body, const csReversibleTransform & offset_transform) = 0;
00158   //virtual iODERigidBody *GetRigidBody() = 0;
00159   //virtual void SetJoint(iODEJoint *joint) = 0;
00160   //virtual iODEJoint *GetJoint() = 0;
00161 };
00162 
00166 struct iSkeletonBoneUpdateCallback : public virtual iBase
00167 {
00168   SCF_INTERFACE  (iSkeletonBoneUpdateCallback, 0, 0, 1);
00169 
00170   virtual void UpdateTransform(iSkeletonBone *bone,
00171       const csReversibleTransform & transform) = 0;
00172 };
00173 
00174 class csQuaternion;
00175 
00180 struct iSkeletonAnimationKeyFrame : public virtual iBase
00181 {
00182   SCF_INTERFACE (iSkeletonAnimationKeyFrame, 1, 0, 0);
00183 
00187   virtual const char* GetName () const = 0;
00188 
00192   virtual void SetName (const char* name) = 0;
00193 
00197   virtual csTicks GetDuration () = 0;
00198 
00202   virtual void SetDuration (csTicks time) = 0;
00203 
00207   virtual size_t GetTransformsCount() = 0;
00208 
00212   virtual void AddTransform (iSkeletonBoneFactory *bone, 
00213     csReversibleTransform &transform, bool relative = false) = 0;
00214 
00220   CS_DEPRECATED_METHOD_MSG("GetTransform (iSkeletonBoneFactory *bone) is deprecated, use GetTransform"
00221     "(iSkeletonBoneFactory *bone, csReversibleTransform &dst_trans) instead")
00222   virtual csReversibleTransform & GetTransform (iSkeletonBoneFactory *bone) = 0;
00223 
00228   virtual bool GetTransform (iSkeletonBoneFactory *bone,
00229       csReversibleTransform &dst_trans) = 0;
00230 
00234   virtual void SetTransform(iSkeletonBoneFactory *bone, 
00235     csReversibleTransform &transform) = 0;
00236 
00241   virtual bool GetKeyFrameData (iSkeletonBoneFactory *bone_fact, 
00242     csQuaternion & rot, csVector3 & pos, csQuaternion & tangent,
00243     bool & relative) = 0;
00244 };
00245 
00246 CS_DEPRECATED_METHOD_MSG("iSkeletonScriptKeyFrame is deprecated, use iSkeletonAnimationKeyFrame instead")
00247 typedef iSkeletonAnimationKeyFrame iSkeletonScriptKeyFrame;
00248 
00252 struct iSkeletonAnimation : public virtual iBase
00253 {
00254   SCF_INTERFACE (iSkeletonAnimation, 1, 0, 0);
00255 
00259   virtual const char* GetName () const = 0;
00260 
00264   virtual void SetName (const char* name) = 0;
00265 
00269   virtual csTicks GetTime () = 0;
00270 
00274   virtual void SetTime (csTicks time) = 0;
00275 
00279   virtual float GetSpeed () = 0;
00280 
00284   virtual void SetSpeed (float speed) = 0;
00285 
00289   virtual void SetFactor (float factor) = 0;
00290 
00294   virtual float GetFactor () = 0;
00295 
00299   virtual void SetLoop (bool loop) = 0;
00300 
00304   virtual bool GetLoop () = 0;
00305 
00309   virtual iSkeletonAnimationKeyFrame *CreateFrame (const char* name) = 0;
00310 
00314   virtual size_t GetFramesCount () = 0;
00315 
00319   virtual iSkeletonAnimationKeyFrame *GetFrame (size_t i) = 0;
00320 
00324   virtual size_t FindFrameIndex (const char *name) = 0;
00325 
00329   virtual void RemoveFrame (size_t i) = 0;
00330 
00334   virtual void RemoveAllFrames () = 0;
00335 
00341   virtual void RecalcSpline () = 0;
00342 };
00343 
00344 CS_DEPRECATED_METHOD_MSG("iSkeletonScript is deprecated, use iSkeletonAnimation instead")
00345 typedef iSkeletonAnimation iSkeletonScript;
00346 
00351 struct iSkeletonAnimationCallback : public virtual iBase
00352 {
00353   SCF_INTERFACE (iSkeletonAnimationCallback, 1, 0, 0);
00354 
00358   virtual void Execute(iSkeletonAnimation *animation, size_t frame_idx) = 0;
00359 
00363   virtual void OnFinish(iSkeletonAnimation *animation) = 0;
00364 };
00365 
00366 CS_DEPRECATED_METHOD_MSG("iSkeletonScriptCallback is deprecated, use iSkeletonAnimationCallback instead")
00367 typedef iSkeletonAnimationCallback iSkeletonScriptCallback;
00368 
00374 struct iSkeletonUpdateCallback : public virtual iBase
00375 {
00376   SCF_INTERFACE (iSkeletonUpdateCallback, 1, 0, 0);
00377 
00381   virtual void Execute(iSkeleton *skeleton, const csTicks & current_ticks) = 0;
00382 };
00383 
00387 struct iSkeletonAnimationInstance : public virtual iBase
00388 {
00389   SCF_INTERFACE (iSkeletonAnimationInstance, 1, 0, 0);
00390 
00394   virtual float GetSpeed () = 0;
00395 
00399   virtual void SetSpeed (float speed) = 0;
00400 
00404   virtual void SetFactor (float factor) = 0;
00405 
00409   virtual float GetFactor () = 0;
00410 
00414   virtual csTicks GetDuration () = 0;
00415 
00419   virtual void SetDuration (csTicks time) = 0;
00420 };
00421 
00436 struct iSkeleton : public virtual iBase
00437 {
00438   SCF_INTERFACE (iSkeleton, 1, 0, 0);
00439 
00443   virtual const char* GetName () const = 0;
00444 
00448   virtual void SetName (const char* name) = 0;
00449 
00453   virtual size_t GetBonesCount () = 0;
00454 
00458   virtual iSkeletonBone *GetBone (size_t i) = 0;
00459 
00463   virtual iSkeletonBone *FindBone (const char *name) = 0;
00464 
00468   virtual size_t FindBoneIndex (const char *name) = 0;
00469 
00473   virtual iSkeletonAnimation* Execute (const char *animation_name) = 0;
00474 
00478   virtual iSkeletonAnimation* Append (const char *animation_name) = 0;
00479 
00483   virtual iSkeletonAnimationInstance *Play (const char *animation_name) = 0;
00484 
00488   virtual void Stop (iSkeletonAnimationInstance *anim_instance) = 0;
00489 
00493   virtual void ClearPendingAnimations () = 0;
00494 
00499   CS_DEPRECATED_METHOD_MSG("ClearPendingScripts is deprecated, use ClearPendingAnimations instead")
00500   virtual void ClearPendingScripts () = 0;
00501 
00505   virtual size_t GetAnimationsCount () = 0;
00506 
00511   CS_DEPRECATED_METHOD_MSG("GetScriptsCount is deprecated, use GetAnimationsCount instead")
00512   virtual size_t GetScriptsCount () = 0;
00513 
00517   virtual iSkeletonAnimation* GetAnimation (size_t i) = 0;
00518 
00523   CS_DEPRECATED_METHOD_MSG("GetScript is deprecated, use GetAnimation instead")
00524   virtual iSkeletonAnimation* GetScript (size_t i) = 0;
00525 
00529   virtual iSkeletonAnimation* FindAnimation (const char *animation_name) = 0;
00530 
00535   CS_DEPRECATED_METHOD_MSG("FindScript is deprecated, use FindAnimation instead")
00536   virtual iSkeletonAnimation* FindScript (const char *animation_name) = 0;
00537 
00541   virtual iSkeletonSocket* FindSocket (const char *socketname) = 0;
00542 
00546   virtual void StopAll () = 0;
00547 
00551   virtual void Stop (const char* animation_name) = 0;
00552 
00556   virtual iSkeletonFactory *GetFactory () = 0;
00557 
00561   virtual void SetScriptCallback (iSkeletonAnimationCallback *cb) = 0;
00562 
00568   CS_DEPRECATED_METHOD_MSG("SetScriptCallback is deprecated, use SetAnimationCallback instead")
00569   virtual void SetAnimationCallback (iSkeletonAnimationCallback *cb) = 0;
00570 
00571   //virtual void CreateRagdoll(iODEDynamicSystem *dyn_sys, csReversibleTransform & transform) = 0;
00572   //virtual void DestroyRagdoll() = 0;
00573 
00577   virtual size_t AddUpdateCallback (
00578       iSkeletonUpdateCallback *update_callback) = 0;
00579 
00583   virtual size_t GetUpdateCallbacksCount () = 0;
00584 
00588   virtual iSkeletonUpdateCallback *GetUpdateCallback(size_t callback_idx) = 0;
00589 
00593   virtual void RemoveUpdateCallback (size_t callback_idx) = 0;
00594 
00599   virtual bool UpdateAnimation (csTicks current_time) = 0;
00600 
00607   virtual void UpdateBones () = 0;
00608 };
00609 
00616 struct iSkeletonSocket : public virtual iBase
00617 {
00618   SCF_INTERFACE (iSkeletonSocket, 1, 0, 0);
00619 
00623   virtual const char* GetName () const = 0;
00624 
00628   virtual void SetName (const char* name) = 0;
00629 
00633   virtual csReversibleTransform &GetTransform () = 0;
00634 
00638   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00639 
00643   virtual csReversibleTransform &GetFullTransform () = 0;
00644 
00648   virtual void SetBone (iSkeletonBone *bone) = 0;
00649 
00653   virtual iSkeletonBone *GetBone () = 0;
00654 
00658   virtual void SetSceneNode (iSceneNode *node) = 0;
00659 
00663   virtual iSceneNode *GetSceneNode () = 0;
00664 
00668   virtual iSkeletonSocketFactory *GetFactory () = 0;
00669 };
00670 
00671 struct iSkeletonBoneRagdollInfo : public virtual iBase
00672 {
00673   SCF_INTERFACE (iSkeletonBoneRagdollInfo, 1, 0, 0);
00674 
00675   virtual void SetEnabled(bool enabled) = 0;
00676   virtual bool GetEnabled() = 0;
00677   virtual void SetAttachToParent(bool attach) = 0;
00678   virtual bool GetAttachToParent() = 0;
00679 
00680   virtual void SetGeomName(const char *name) = 0;
00681   virtual const char *GetGeomName() = 0;
00682   virtual void SetGeomType(int geom_type) = 0;
00683   virtual int GetGeomType() = 0;
00684   virtual void SetGeomDimensions(csVector3 &size) = 0;
00685   virtual csVector3 &GetGeomDimensions() = 0;
00686 
00687   virtual void SetFriction(float friction) = 0;
00688   virtual float GetFriction() = 0;
00689   virtual void SetElasticity(float elasticity) = 0;
00690   virtual float GetElasticity() = 0;
00691   virtual void SetSoftness(float softness) = 0;
00692   virtual float GetSoftness() = 0;
00693   virtual void SetSlip(float slip) = 0;
00694   virtual float GetSlip() = 0;
00695 
00696   virtual void SetBodyName(const char *name) = 0;
00697   virtual const char *GetBodyName() = 0;
00698   virtual void SetBodyMass(float mass) = 0;
00699   virtual float GetBodyMass() = 0;
00700   virtual void SetBodyGravmode(int gravmode) = 0;
00701   virtual int GetBodyGravmode() = 0;
00702 
00703   virtual void SetJointName(const char *name) = 0;
00704   virtual const char *GetJointName() = 0;
00705   virtual void SetJointMinRotContraints(csVector3 & constraints) = 0;
00706   virtual csVector3 & GetJointMinRotContraints() = 0;
00707   virtual void SetJointMaxRotContraints(csVector3 & constraints) = 0;
00708   virtual csVector3 & GetJointMaxRotContraints() = 0;
00709   virtual void SetJointMinTransContraints(csVector3 & constraints) = 0;
00710   virtual csVector3 & GetJointMinTransContraints() = 0;
00711   virtual void SetJointMaxTransContraints(csVector3 & constraints) = 0;
00712   virtual csVector3 & GetJointMaxTransContraints() = 0;
00713 };
00714 
00719 struct iSkeletonBoneFactory : public virtual iBase
00720 {
00721   SCF_INTERFACE (iSkeletonBoneFactory, 1, 0, 0);
00722 
00726   virtual const char* GetName () const = 0;
00727 
00731   virtual void SetName (const char* name) = 0;
00732 
00736   virtual csReversibleTransform &GetTransform () = 0;
00737 
00741   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00742 
00746   virtual csReversibleTransform &GetFullTransform () = 0;
00747 
00751   virtual  void SetParent (iSkeletonBoneFactory *parent) = 0;
00752 
00756   virtual iSkeletonBoneFactory *GetParent () = 0;
00757 
00761   virtual size_t GetChildrenCount () = 0;
00762 
00766   virtual iSkeletonBoneFactory *GetChild (size_t i) = 0;
00767 
00771   virtual iSkeletonBoneFactory *FindChild (const char *name) = 0;
00772 
00776   virtual size_t FindChildIndex (iSkeletonBoneFactory *child) = 0;
00777 
00781   virtual void SetSkinBox (csBox3 & box) = 0;
00782 
00786   virtual csBox3 & GetSkinBox () = 0;
00787 
00791   virtual iSkeletonBoneRagdollInfo *GetRagdollInfo() = 0;
00792 };
00793 
00798 struct iSkeletonSocketFactory : public virtual iBase
00799 {
00800   SCF_INTERFACE (iSkeletonSocketFactory, 1, 0, 0);
00801 
00805   virtual const char* GetName () const = 0;
00806 
00810   virtual void SetName (const char* name) = 0;
00811 
00815   virtual csReversibleTransform &GetTransform () = 0;
00816 
00820   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00821 
00825   virtual csReversibleTransform &GetFullTransform () = 0;
00826 
00830   virtual void SetBone (iSkeletonBoneFactory *bone) = 0;
00831 
00835   virtual iSkeletonBoneFactory *GetBone () = 0;
00836 };
00837 
00842 struct iSkeletonFactory : public virtual iBase
00843 {
00844   SCF_INTERFACE (iSkeletonFactory, 1, 0, 0);
00845 
00849   virtual const char* GetName () const = 0;
00850 
00854   virtual void SetName (const char* name) = 0;
00855 
00859   virtual iSkeletonBoneFactory *CreateBone (const char *name) = 0;
00860 
00864   virtual iSkeletonAnimation *CreateAnimation (const char *name) = 0;
00865 
00870   CS_DEPRECATED_METHOD_MSG("CreateScript is deprecated, use CreateAnimation instead")
00871   virtual iSkeletonAnimation *CreateScript(const char *name) = 0;
00872 
00876   virtual iSkeletonAnimation *FindAnimation (const char *name) = 0;
00877 
00881   virtual size_t GetAnimationsCount () = 0;
00882 
00886   virtual iSkeletonAnimation *GetAnimation (size_t idx) = 0;
00887 
00892   CS_DEPRECATED_METHOD_MSG("FindScript is deprecated, use FindAnimation instead")
00893   virtual iSkeletonAnimation *FindScript (const char *name) = 0;
00894 
00898   virtual iSkeletonBoneFactory *FindBone (const char *name) = 0;
00899 
00903   virtual size_t FindBoneIndex (const char *name) = 0;
00904 
00908   virtual size_t GetBonesCount () const = 0;
00909 
00913   virtual iSkeletonBoneFactory *GetBone(size_t i) = 0;
00914 
00918   virtual iSkeletonGraveyard *GetGraveyard  () = 0;
00919 
00923   virtual iSkeletonSocketFactory *CreateSocket(const char *name,
00924       iSkeletonBoneFactory *bone) = 0;
00925 
00929   virtual iSkeletonSocketFactory *FindSocket(const char *name) = 0;
00930 
00934   virtual iSkeletonSocketFactory *GetSocket (int i) = 0;
00935 
00939   virtual void RemoveSocket (int i) = 0;
00940 
00944   virtual size_t GetSocketsCount() = 0;
00945 };
00946 
00947 
00953 struct iSkeletonGraveyard : public virtual iBase
00954 {
00955   SCF_INTERFACE (iSkeletonGraveyard, 1, 0, 0);
00956 
00960   virtual size_t GetFactoriesCount() = 0;
00961 
00965   virtual iSkeletonFactory *CreateFactory(const char *name) = 0;
00966 
00970   virtual iSkeletonFactory *LoadFactory(const char *file_name) = 0;
00971 
00975   virtual iSkeletonFactory *FindFactory(const char *name) = 0;
00976 
00980   virtual iSkeleton *CreateSkeleton(iSkeletonFactory *fact,
00981       const char *name = 0) = 0;
00982 
00986   virtual void SetManualUpdates (bool man_updates) = 0;
00987 
00991   virtual void Update (csTicks time) = 0;
00992 
00996   virtual void AddSkeleton (iSkeleton *skeleton) = 0;
00997 
01001   virtual void RemoveSkeleton (iSkeleton* skeleton) = 0;
01002 };
01003 
01004 #endif //__CS_ISKELETON_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3