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 
00060 struct iSkeletonBone : public virtual iBase
00061 {
00062   SCF_INTERFACE (iSkeletonBone, 1, 0, 0);
00063 
00067   virtual const char* GetName () const = 0;
00068 
00072   virtual void SetName (const char* name) = 0;
00073 
00077   virtual csReversibleTransform &GetTransform () = 0;
00078 
00082   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00083 
00087   virtual csReversibleTransform &GetFullTransform () = 0;
00088 
00092   virtual  void SetParent (iSkeletonBone *parent) = 0;
00093 
00097   virtual iSkeletonBone *GetParent () = 0;
00098 
00102   virtual int GetChildrenCount () = 0;
00103 
00107   virtual iSkeletonBone *GetChild (size_t i) = 0;
00108 
00112   virtual iSkeletonBone *FindChild (const char *name) = 0;
00113 
00117   virtual size_t FindChildIndex (iSkeletonBone *child) = 0;
00118 
00122   virtual void SetSkinBox (csBox3 & box) = 0;
00123 
00127   virtual csBox3 & GetSkinBox () = 0;
00128 
00133   virtual void SetUpdateCallback (iSkeletonBoneUpdateCallback *callback) = 0;
00134 
00138   virtual iSkeletonBoneUpdateCallback *GetUpdateCallback () = 0;
00139 
00143   virtual iSkeletonBoneFactory *GetFactory() = 0;
00144 
00148   virtual void SetTransformMode(csBoneTransformType mode) = 0;
00149 
00153   virtual csBoneTransformType GetTransformMode() = 0;
00154 
00155   //virtual void SetRigidBody(iODERigidBody *rigid_body, const csReversibleTransform & offset_transform) = 0;
00156   //virtual iODERigidBody *GetRigidBody() = 0;
00157   //virtual void SetJoint(iODEJoint *joint) = 0;
00158   //virtual iODEJoint *GetJoint() = 0;
00159 };
00160 
00161 SCF_VERSION  (iSkeletonBoneUpdateCallback, 0, 0, 1);
00162 
00166 struct iSkeletonBoneUpdateCallback : public virtual iBase
00167 {
00168         virtual void UpdateTransform(iSkeletonBone *bone, const csReversibleTransform & transform) = 0;
00169 };
00170 
00175 struct iSkeletonScriptKeyFrame : public virtual iBase
00176 {
00177   SCF_INTERFACE (iSkeletonScriptKeyFrame, 1, 0, 0);
00178 
00182   virtual const char* GetName () const = 0;
00183 
00187   virtual void SetName (const char* name) = 0;
00188 
00192   virtual csTicks GetDuration () = 0;
00193 
00197   virtual void SetDuration (csTicks time) = 0;
00198 
00202   virtual size_t GetTransformsCount() = 0;
00203 
00207   virtual void AddTransform(iSkeletonBoneFactory *bone, 
00208           csReversibleTransform &transform, bool relative = false) = 0;
00209 
00213   virtual csReversibleTransform & GetTransform(iSkeletonBoneFactory *bone) = 0;
00214 
00218   virtual void SetTransform(iSkeletonBoneFactory *bone, 
00219           csReversibleTransform &transform) = 0;
00220 
00224   virtual void GetKeyFrameData(iSkeletonBoneFactory *bone_fact, 
00225           csQuaternion & rot, csVector3 & pos, csQuaternion & tangent,
00226        bool & relative) = 0;
00227 };
00228 
00232 struct iSkeletonScript : public virtual iBase
00233 {
00234   SCF_INTERFACE (iSkeletonScript, 1, 0, 0);
00235 
00239   virtual const char* GetName () const = 0;
00240 
00244   virtual void SetName (const char* name) = 0;
00245 
00249   virtual csTicks GetTime () = 0;
00250 
00254   virtual void SetTime (csTicks time) = 0;
00255 
00259   virtual float GetSpeed () = 0;
00260 
00264   virtual void SetSpeed (float speed) = 0;
00265 
00269   virtual void SetFactor (float factor) = 0;
00270 
00274   virtual float GetFactor () = 0;
00275 
00279   virtual void SetLoop (bool loop) = 0;
00280 
00284   virtual bool GetLoop () = 0;
00285 
00289   virtual iSkeletonScriptKeyFrame *CreateFrame(const char* name) = 0;
00290 
00294   virtual size_t GetFramesCount() = 0;
00295 
00299   virtual iSkeletonScriptKeyFrame *GetFrame(size_t i) = 0;
00300 
00304   virtual size_t FindFrameIndex(const char *name) = 0;
00305 
00309   virtual void RemoveFrame(size_t i) = 0;
00310 
00316   virtual void RecalcSpline () = 0;
00317 };
00318 
00323 struct iSkeletonScriptCallback : public virtual iBase
00324 {
00325     SCF_INTERFACE (iSkeletonScriptCallback, 1, 0, 0);
00326 
00330         virtual void Execute(iSkeletonScript *script, size_t frame_idx) = 0;
00331 
00335         virtual void OnFinish(iSkeletonScript *script) = 0;
00336 };
00337 
00343 struct iSkeletonUpdateCallback : public virtual iBase
00344 {
00345     SCF_INTERFACE (iSkeletonUpdateCallback, 1, 0, 0);
00346 
00350         virtual void Execute(iSkeleton *skeleton, const csTicks & current_ticks) = 0;
00351 };
00352 
00367 struct iSkeleton : public virtual iBase
00368 {
00369   SCF_INTERFACE (iSkeleton, 1, 0, 0);
00370 
00374   virtual const char* GetName () const = 0;
00375 
00379   virtual void SetName (const char* name) = 0;
00380 
00384   virtual size_t GetBonesCount () = 0;
00385 
00389   virtual iSkeletonBone *GetBone (size_t i) = 0;
00390 
00394   virtual iSkeletonBone *FindBone (const char *name) = 0;
00395 
00399   virtual size_t FindBoneIndex (const char *name) = 0;
00400 
00404   virtual iSkeletonScript* Execute (const char *scriptname) = 0;
00405 
00409   virtual iSkeletonScript* Append (const char *scriptname) = 0;
00410 
00414   virtual void ClearPendingScripts () = 0;
00415 
00419   virtual size_t GetScriptsCount () = 0;
00420 
00424   virtual iSkeletonScript* GetScript (size_t i) = 0;
00425 
00429   virtual iSkeletonScript* FindScript (const char *scriptname) = 0;
00430 
00434   virtual iSkeletonSocket* FindSocket (const char *socketname) = 0;
00435 
00439   virtual void StopAll () = 0;
00440 
00444   virtual void Stop (const char* scriptname) = 0;
00445 
00449   virtual iSkeletonFactory *GetFactory() = 0;
00450 
00454   virtual void SetScriptCallback(iSkeletonScriptCallback *cb) = 0;
00455 
00456   //virtual void CreateRagdoll(iODEDynamicSystem *dyn_sys, csReversibleTransform & transform) = 0;
00457   //virtual void DestroyRagdoll() = 0;
00458 
00462   virtual size_t AddUpdateCallback(iSkeletonUpdateCallback *update_callback) = 0;
00463 
00467   virtual size_t GetUpdateCallbacksCount() = 0;
00468 
00472   virtual iSkeletonUpdateCallback *GetUpdateCallback(size_t callback_idx) = 0;
00473 
00477   virtual void RemoveUpdateCallback(size_t callback_idx) = 0;
00478 };
00479 
00486 struct iSkeletonSocket : public virtual iBase
00487 {
00488   SCF_INTERFACE (iSkeletonSocket, 1, 0, 0);
00489 
00493   virtual const char* GetName () const = 0;
00494 
00498   virtual void SetName (const char* name) = 0;
00499 
00503   virtual csReversibleTransform &GetTransform () = 0;
00504 
00508   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00509 
00513   virtual csReversibleTransform &GetFullTransform () = 0;
00514 
00518   virtual void SetBone (iSkeletonBone *bone) = 0;
00519 
00523   virtual iSkeletonBone *GetBone () = 0;
00524 
00528   virtual void SetSceneNode (iSceneNode *node) = 0;
00529 
00533   virtual iSceneNode *GetSceneNode () = 0;
00534 
00538   virtual iSkeletonSocketFactory *GetFactory () = 0;
00539 };
00540 
00541 struct iSkeletonBoneRagdollInfo : public virtual iBase
00542 {
00543   SCF_INTERFACE (iSkeletonBoneRagdollInfo, 1, 0, 0);
00544 
00545   virtual void SetEnabled(bool enabled) = 0;
00546   virtual bool GetEnabled() = 0;
00547   virtual void SetAttachToParent(bool attach) = 0;
00548   virtual bool GetAttachToParent() = 0;
00549 
00550   virtual void SetGeomName(const char *name) = 0;
00551   virtual const char *GetGeomName() = 0;
00552   virtual void SetGeomType(int geom_type) = 0;
00553   virtual int GetGeomType() = 0;
00554   virtual void SetGeomDimensions(csVector3 &size) = 0;
00555   virtual csVector3 &GetGeomDimensions() = 0;
00556 
00557   virtual void SetFriction(float friction) = 0;
00558   virtual float GetFriction() = 0;
00559   virtual void SetElasticity(float elasticity) = 0;
00560   virtual float GetElasticity() = 0;
00561   virtual void SetSoftness(float softness) = 0;
00562   virtual float GetSoftness() = 0;
00563   virtual void SetSlip(float slip) = 0;
00564   virtual float GetSlip() = 0;
00565 
00566   virtual void SetBodyName(const char *name) = 0;
00567   virtual const char *GetBodyName() = 0;
00568   virtual void SetBodyMass(float mass) = 0;
00569   virtual float GetBodyMass() = 0;
00570   virtual void SetBodyGravmode(int gravmode) = 0;
00571   virtual int GetBodyGravmode() = 0;
00572 
00573   virtual void SetJointName(const char *name) = 0;
00574   virtual const char *GetJointName() = 0;
00575   virtual void SetJointMinRotContraints(csVector3 & constraints) = 0;
00576   virtual csVector3 & GetJointMinRotContraints() = 0;
00577   virtual void SetJointMaxRotContraints(csVector3 & constraints) = 0;
00578   virtual csVector3 & GetJointMaxRotContraints() = 0;
00579   virtual void SetJointMinTransContraints(csVector3 & constraints) = 0;
00580   virtual csVector3 & GetJointMinTransContraints() = 0;
00581   virtual void SetJointMaxTransContraints(csVector3 & constraints) = 0;
00582   virtual csVector3 & GetJointMaxTransContraints() = 0;
00583 };
00584 
00589 struct iSkeletonBoneFactory : public virtual iBase
00590 {
00591   SCF_INTERFACE (iSkeletonBoneFactory, 1, 0, 0);
00592 
00596   virtual const char* GetName () const = 0;
00597 
00601   virtual void SetName (const char* name) = 0;
00602 
00606   virtual csReversibleTransform &GetTransform () = 0;
00607 
00611   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00612 
00616   virtual csReversibleTransform &GetFullTransform () = 0;
00617 
00621   virtual  void SetParent (iSkeletonBoneFactory *parent) = 0;
00622 
00626   virtual iSkeletonBoneFactory *GetParent () = 0;
00627 
00631   virtual int GetChildrenCount () = 0;
00632 
00636   virtual iSkeletonBoneFactory *GetChild (size_t i) = 0;
00637 
00641   virtual iSkeletonBoneFactory *FindChild (const char *name) = 0;
00642 
00646   virtual size_t FindChildIndex (iSkeletonBoneFactory *child) = 0;
00647 
00651   virtual void SetSkinBox (csBox3 & box) = 0;
00652 
00656   virtual csBox3 & GetSkinBox () = 0;
00657 
00661   virtual iSkeletonBoneRagdollInfo *GetRagdollInfo() = 0;
00662 };
00663 
00668 struct iSkeletonSocketFactory : public virtual iBase
00669 {
00670   SCF_INTERFACE (iSkeletonSocketFactory, 1, 0, 0);
00671 
00675   virtual const char* GetName () const = 0;
00676 
00680   virtual void SetName (const char* name) = 0;
00681 
00685   virtual csReversibleTransform &GetTransform () = 0;
00686 
00690   virtual void SetTransform (const csReversibleTransform &transform) = 0;
00691 
00695   virtual csReversibleTransform &GetFullTransform () = 0;
00696 
00700   virtual void SetBone (iSkeletonBoneFactory *bone) = 0;
00701 
00705   virtual iSkeletonBoneFactory *GetBone () = 0;
00706 };
00707 
00712 struct iSkeletonFactory : public virtual iBase
00713 {
00714   SCF_INTERFACE (iSkeletonFactory, 1, 0, 0);
00715 
00719   virtual const char* GetName () const = 0;
00720 
00724   virtual void SetName (const char* name) = 0;
00725 
00729   virtual iSkeletonBoneFactory *CreateBone(const char *name) = 0;
00730 
00734   virtual iSkeletonScript *CreateScript(const char *name) = 0;
00735 
00739   virtual iSkeletonScript *FindScript(const char *name) = 0;
00740 
00744   virtual iSkeletonBoneFactory *FindBone (const char *name) = 0;
00745 
00749   virtual size_t FindBoneIndex (const char *name) = 0;
00750 
00754   virtual size_t GetBonesCount () const = 0;
00755 
00759   virtual iSkeletonBoneFactory *GetBone(size_t i) = 0;
00760 
00764   virtual iSkeletonGraveyard *GetGraveyard  () = 0;
00765 
00769   virtual iSkeletonSocketFactory *CreateSocket(const char *name, iSkeletonBoneFactory *bone) = 0;
00770 
00774   virtual iSkeletonSocketFactory *FindSocket(const char *name) = 0;
00775 
00779   virtual iSkeletonSocketFactory *GetSocket (int i) = 0;
00780 
00784   virtual void RemoveSocket (int i) = 0;
00785 
00789   virtual size_t GetSocketsCount() = 0;
00790 };
00791 
00792 
00798 struct iSkeletonGraveyard : public virtual iBase
00799 {
00800   SCF_INTERFACE (iSkeletonGraveyard, 1, 0, 0);
00801 
00805   virtual size_t GetFactoriesCount() = 0;
00806 
00810   virtual iSkeletonFactory *CreateFactory(const char *name) = 0;
00811 
00815   virtual iSkeletonFactory *LoadFactory(const char *file_name) = 0;
00816 
00820   virtual iSkeletonFactory *FindFactory(const char *name) = 0;
00821 
00825   virtual iSkeleton *CreateSkeleton(iSkeletonFactory *fact, const char *name = 0) = 0;
00826 };
00827 
00828 #endif //__CS_ISKELETON_H__

Generated for Crystal Space 1.0.2 by doxygen 1.4.7