imesh/skeleton2.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/skeleton2.h
Go to the documentation of this file.

    00001 /*
    00002   Copyright (C) 2008 by Marten Svanfeldt
    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_IMESH_SKELETON2_H__
    00020 #define __CS_IMESH_SKELETON2_H__
    00021
    00022 #include "csutil/scf_interface.h"
    00023 #include "csutil/ref.h"
    00024 #include "csutil/refcount.h"
    00025 #include "csutil/bitarray.h"
    00026 #include "csgeom/quaternion.h"
    00027 #include "csgeom/vector3.h"
    00028
    00029 class csDualQuaternion;
    00030
    00035 struct iSceneNode;
    00036
    00037 namespace CS {
    00038 namespace Mesh {
    00039
    00040 struct iAnimatedMesh;
    00041
    00042 } // namespace Mesh
    00043 } // namespace CS
    00044
    00045 namespace CS {
    00046 namespace Animation {
    00047
    00048 struct iSkeletonFactory;
    00049 struct iSkeleton;
    00050
    00051 class AnimatedMeshState;
    00052
    00053 struct iSkeletonAnimPacketFactory;
    00054 struct iSkeletonAnimPacket;
    00055
    00063
    00064 typedef size_t BoneID;
    00065
    00067 static const BoneID InvalidBoneID = (BoneID)~0;
    00068
    00073 struct iSkeletonManager : public virtual iBase
    00074 {
    00075   SCF_INTERFACE(CS::Animation::iSkeletonManager, 1, 0, 0);
    00076
    00080   virtual iSkeletonFactory* CreateSkeletonFactory (const char* name) = 0;
    00081
    00085   virtual iSkeletonFactory* FindSkeletonFactory (const char* name) = 0;
    00086
    00090   virtual void ClearSkeletonFactories () = 0;
    00091
    00095   virtual iSkeletonAnimPacketFactory* CreateAnimPacketFactory (const char* name) = 0;
    00096
    00100   virtual iSkeletonAnimPacketFactory* FindAnimPacketFactory (const char* name) = 0;
    00101
    00105   virtual void ClearAnimPacketFactories () = 0;
    00106
    00110   virtual void ClearAll () = 0;
    00111 };
    00112
    00124 struct iSkeletonFactory : public virtual iBase
    00125 {
    00126   SCF_INTERFACE(CS::Animation::iSkeletonFactory, 1, 0, 4);
    00127
    00137   virtual BoneID CreateBone (BoneID parent = CS::Animation::InvalidBoneID) = 0;
    00138
    00143   virtual BoneID FindBone (const char *name) const = 0;
    00144
    00150   virtual void RemoveBone (BoneID bone) = 0;
    00151
    00158   virtual BoneID GetBoneParent (BoneID bone) const = 0;
    00159
    00163   virtual bool HasBone (BoneID bone) const = 0;
    00164
    00168   virtual void SetBoneName (BoneID bone, const char* name) = 0;
    00169
    00173   virtual const char* GetBoneName (BoneID bone) const = 0;
    00174
    00178   virtual BoneID GetTopBoneID () const = 0;
    00179
    00186   virtual void GetTransformBoneSpace (BoneID bone, csQuaternion& rot,
    00187     csVector3& offset) const = 0;
    00188
    00195   virtual void SetTransformBoneSpace (BoneID bone, const csQuaternion& rot,
    00196     const csVector3& offset) = 0;
    00197
    00204   virtual void GetTransformAbsSpace (BoneID bone, csQuaternion& rot,
    00205     csVector3& offset) const = 0;
    00206
    00219   virtual void SetTransformAbsSpace (BoneID bone, const csQuaternion& rot,
    00220     const csVector3& offset) = 0;
    00221
    00227   virtual csPtr<iSkeleton> CreateSkeleton () = 0;
    00228
    00232   virtual iSkeletonAnimPacketFactory* GetAnimationPacket () const = 0;
    00233
    00237   virtual void SetAnimationPacket (iSkeletonAnimPacketFactory* fact) = 0;
    00238
    00247   virtual void SetAutoStart (bool autostart) = 0;
    00248
    00253   virtual bool GetAutoStart () = 0;
    00254
    00258   virtual csString Description () const = 0;
    00259
    00264   virtual const csArray<CS::Animation::BoneID>& GetBoneOrderList () = 0;
    00265
    00269   virtual const char* GetName () const = 0;
    00270 };
    00271
    00284 struct iSkeleton : public virtual iBase
    00285 {
    00286   SCF_INTERFACE(CS::Animation::iSkeleton, 1, 0, 2);
    00287
    00291   virtual iSceneNode* GetSceneNode () = 0;
    00292
    00302   virtual void GetTransformBoneSpace (BoneID bone, csQuaternion& rot,
    00303     csVector3& offset) const = 0;
    00304
    00311   virtual void SetTransformBoneSpace (BoneID bone, const csQuaternion& rot,
    00312     const csVector3& offset) = 0;
    00313
    00320   virtual void GetTransformAbsSpace (BoneID bone, csQuaternion& rot,
    00321     csVector3& offset) const = 0;
    00322
    00336   virtual void SetTransformAbsSpace (BoneID bone, const csQuaternion& rot,
    00337     const csVector3& offset) = 0;
    00338
    00345   virtual void GetTransformBindSpace (BoneID bone, csQuaternion& rot,
    00346     csVector3& offset) const = 0;
    00347
    00348
    00362   virtual void SetTransformBindSpace (BoneID bone, const csQuaternion& rot,
    00363     const csVector3& offset) = 0;
    00364
    00368   virtual csPtr<AnimatedMeshState> GetStateAbsSpace () = 0;
    00369
    00373   virtual csPtr<AnimatedMeshState> GetStateBoneSpace () = 0;
    00374
    00378   virtual csPtr<AnimatedMeshState> GetStateBindSpace () = 0;
    00379
    00385   virtual iSkeletonFactory* GetFactory () const = 0;
    00386
    00387
    00391   virtual iSkeletonAnimPacket* GetAnimationPacket () const = 0;
    00392
    00396   virtual void SetAnimationPacket (iSkeletonAnimPacket* packet) = 0;
    00397
    00401   virtual void RecreateSkeleton () = 0;
    00402
    00408   virtual void UpdateSkeleton (float dt) = 0;
    00409
    00414   virtual unsigned int GetSkeletonStateVersion () const = 0;
    00415
    00419   virtual void SetAnimatedMesh (CS::Mesh::iAnimatedMesh* animesh) = 0;
    00420
    00424   virtual CS::Mesh::iAnimatedMesh* GetAnimatedMesh () = 0;
    00425
    00430   virtual void ResetSkeletonState () = 0;
    00431 };
    00432
    00438 class AnimatedMeshState : public csRefCount
    00439 {
    00440 public:
    00441
    00443   AnimatedMeshState ()
    00444     : boneVecs (0), boneQuats (0), numberOfBones (0)
    00445   {}
    00446
    00448   virtual inline ~AnimatedMeshState ()
    00449   {
    00450     delete[] boneVecs;
    00451     delete[] boneQuats;
    00452   }
    00453
    00458   inline const csVector3& GetVector (size_t i) const
    00459   {
    00460     return boneVecs[i];
    00461   }
    00462
    00467   inline csVector3& GetVector (size_t i)
    00468   {
    00469     return boneVecs[i];
    00470   }
    00471
    00472
    00477   inline const csQuaternion& GetQuaternion (size_t i) const
    00478   {
    00479     return boneQuats[i];
    00480   }
    00481
    00486   inline csQuaternion& GetQuaternion (size_t i)
    00487   {
    00488     return boneQuats[i];
    00489   }
    00490
    00496   inline bool IsBoneUsed (BoneID bone) const
    00497   {
    00498     return bitSet.IsBitSet (bone);
    00499   }
    00500
    00505   inline void SetBoneUsed (BoneID bone)
    00506   {
    00507     bitSet.SetBit (bone);
    00508   }
    00509
    00513   inline size_t GetBoneCount () const
    00514   {
    00515     return numberOfBones;
    00516   }
    00517
    00522   inline void Setup (size_t numBones)
    00523   {
    00524     delete[] boneVecs;
    00525     delete[] boneQuats;
    00526
    00527     bitSet.SetSize (numBones);
    00528     bitSet.Clear ();
    00529     boneVecs = new csVector3 [numBones];
    00530     boneQuats = new csQuaternion [numBones];
    00531     numberOfBones = numBones;
    00532
    00533     for (size_t i = 0; i < numBones; ++i)
    00534       boneVecs[i].Set (0,0,0);
    00535   }
    00536
    00540   inline void Reset ()
    00541   {
    00542     bitSet.Clear ();
    00543   }
    00544
    00545 protected:
    00546   csBitArray bitSet;
    00547   csVector3* boneVecs;
    00548   csQuaternion* boneQuats;
    00549   size_t numberOfBones;
    00550 };
    00551
    00552
    00553 } // namespace Animation
    00554 } // namespace CS
    00555
    00556 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::AnimatedMeshState instead")
    00557 typedef CS::Animation::AnimatedMeshState csSkeletalState2;
    00558 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::iSkeleton instead")
    00559 typedef CS::Animation::iSkeleton iSkeleton2;
    00560 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::iSkeletonFactory instead")
    00561 typedef CS::Animation::iSkeletonFactory iSkeletonFactory2;
    00562 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::iSkeletonManager instead")
    00563 typedef CS::Animation::iSkeletonManager iSkeletonManager2;
    00564
    00570 #endif // __CS_IMESH_SKELETON2_H__
    00571