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 iSkeleton; 00049 struct iSkeletonAnimPacket; 00050 struct iSkeletonAnimPacketFactory; 00051 struct iSkeletonFactory; 00052 struct iSkeletonModel; 00053 00054 class AnimatedMeshState; 00055 00062 00063 typedef size_t BoneID; 00064 00066 static const BoneID InvalidBoneID = (BoneID)~0; 00067 00072 struct iSkeletonManager : public virtual iBase 00073 { 00074 SCF_INTERFACE(CS::Animation::iSkeletonManager, 1, 0, 0); 00075 00079 virtual iSkeletonFactory* CreateSkeletonFactory (const char* name) = 0; 00080 00084 virtual iSkeletonFactory* FindSkeletonFactory (const char* name) = 0; 00085 00089 virtual void ClearSkeletonFactories () = 0; 00090 00094 virtual iSkeletonAnimPacketFactory* CreateAnimPacketFactory (const char* name) = 0; 00095 00099 virtual iSkeletonAnimPacketFactory* FindAnimPacketFactory (const char* name) = 0; 00100 00104 virtual void ClearAnimPacketFactories () = 0; 00105 00109 virtual void ClearAll () = 0; 00110 }; 00111 00123 struct iSkeletonFactory : public virtual iBase 00124 { 00125 SCF_INTERFACE(CS::Animation::iSkeletonFactory, 1, 0, 5); 00126 00136 virtual BoneID CreateBone (BoneID parent = CS::Animation::InvalidBoneID) = 0; 00137 00142 virtual BoneID FindBone (const char *name) const = 0; 00143 00149 virtual void RemoveBone (BoneID bone) = 0; 00150 00157 virtual BoneID GetBoneParent (BoneID bone) const = 0; 00158 00162 virtual bool HasBone (BoneID bone) const = 0; 00163 00167 virtual void SetBoneName (BoneID bone, const char* name) = 0; 00168 00172 virtual const char* GetBoneName (BoneID bone) const = 0; 00173 00177 virtual BoneID GetTopBoneID () const = 0; 00178 00185 virtual void GetTransformBoneSpace (BoneID bone, csQuaternion& rot, 00186 csVector3& offset) const = 0; 00187 00194 virtual void SetTransformBoneSpace (BoneID bone, const csQuaternion& rot, 00195 const csVector3& offset) = 0; 00196 00203 virtual void GetTransformAbsSpace (BoneID bone, csQuaternion& rot, 00204 csVector3& offset) const = 0; 00205 00218 virtual void SetTransformAbsSpace (BoneID bone, const csQuaternion& rot, 00219 const csVector3& offset) = 0; 00220 00226 virtual csPtr<iSkeleton> CreateSkeleton () = 0; 00227 00231 virtual iSkeletonAnimPacketFactory* GetAnimationPacket () const = 0; 00232 00236 virtual void SetAnimationPacket (iSkeletonAnimPacketFactory* fact) = 0; 00237 00246 virtual void SetAutoStart (bool autostart) = 0; 00247 00252 virtual bool GetAutoStart () = 0; 00253 00257 virtual csString Description () const = 0; 00258 00263 virtual const csArray<CS::Animation::BoneID>& GetBoneOrderList () = 0; 00264 00268 virtual const char* GetName () const = 0; 00269 00276 virtual void SetSkeletonModel (CS::Animation::iSkeletonModel* model) = 0; 00277 00284 virtual CS::Animation::iSkeletonModel* GetSkeletonModel () const = 0; 00285 }; 00286 00299 struct iSkeleton : public virtual iBase 00300 { 00301 SCF_INTERFACE(CS::Animation::iSkeleton, 1, 0, 3); 00302 00306 virtual iSceneNode* GetSceneNode () = 0; 00307 00317 virtual void GetTransformBoneSpace (BoneID bone, csQuaternion& rot, 00318 csVector3& offset) const = 0; 00319 00326 virtual void SetTransformBoneSpace (BoneID bone, const csQuaternion& rot, 00327 const csVector3& offset) = 0; 00328 00335 virtual void GetTransformAbsSpace (BoneID bone, csQuaternion& rot, 00336 csVector3& offset) const = 0; 00337 00351 virtual void SetTransformAbsSpace (BoneID bone, const csQuaternion& rot, 00352 const csVector3& offset) = 0; 00353 00360 virtual void GetTransformBindSpace (BoneID bone, csQuaternion& rot, 00361 csVector3& offset) const = 0; 00362 00363 00377 virtual void SetTransformBindSpace (BoneID bone, const csQuaternion& rot, 00378 const csVector3& offset) = 0; 00379 00383 virtual csPtr<AnimatedMeshState> GetStateAbsSpace () = 0; 00384 00388 virtual csPtr<AnimatedMeshState> GetStateBoneSpace () = 0; 00389 00393 virtual csPtr<AnimatedMeshState> GetStateBindSpace () = 0; 00394 00400 virtual iSkeletonFactory* GetFactory () const = 0; 00401 00402 00406 virtual iSkeletonAnimPacket* GetAnimationPacket () const = 0; 00407 00411 virtual void SetAnimationPacket (iSkeletonAnimPacket* packet) = 0; 00412 00416 virtual void RecreateSkeleton () = 0; 00417 00421 virtual void RecreateAnimationTree () = 0; 00422 00428 virtual void UpdateSkeleton (float dt) = 0; 00429 00434 virtual unsigned int GetSkeletonStateVersion () const = 0; 00435 00439 virtual void SetAnimatedMesh (CS::Mesh::iAnimatedMesh* animesh) = 0; 00440 00444 virtual CS::Mesh::iAnimatedMesh* GetAnimatedMesh () = 0; 00445 00450 virtual void ResetSkeletonState () = 0; 00451 }; 00452 00458 class AnimatedMeshState : public csRefCount 00459 { 00460 public: 00461 00463 AnimatedMeshState () 00464 : boneVecs (0), boneQuats (0), numberOfBones (0) 00465 {} 00466 00468 virtual inline ~AnimatedMeshState () 00469 { 00470 delete[] boneVecs; 00471 delete[] boneQuats; 00472 } 00473 00478 inline const csVector3& GetVector (size_t i) const 00479 { 00480 return boneVecs[i]; 00481 } 00482 00487 inline csVector3& GetVector (size_t i) 00488 { 00489 return boneVecs[i]; 00490 } 00491 00492 00497 inline const csQuaternion& GetQuaternion (size_t i) const 00498 { 00499 return boneQuats[i]; 00500 } 00501 00506 inline csQuaternion& GetQuaternion (size_t i) 00507 { 00508 return boneQuats[i]; 00509 } 00510 00516 inline bool IsBoneUsed (BoneID bone) const 00517 { 00518 return bitSet.IsBitSet (bone); 00519 } 00520 00525 inline void SetBoneUsed (BoneID bone) 00526 { 00527 bitSet.SetBit (bone); 00528 } 00529 00533 inline size_t GetBoneCount () const 00534 { 00535 return numberOfBones; 00536 } 00537 00542 inline void Setup (size_t numBones) 00543 { 00544 delete[] boneVecs; 00545 delete[] boneQuats; 00546 00547 bitSet.SetSize (numBones); 00548 bitSet.Clear (); 00549 boneVecs = new csVector3 [numBones]; 00550 boneQuats = new csQuaternion [numBones]; 00551 numberOfBones = numBones; 00552 00553 for (size_t i = 0; i < numBones; ++i) 00554 boneVecs[i].Set (0,0,0); 00555 } 00556 00560 inline void Reset () 00561 { 00562 bitSet.Clear (); 00563 } 00564 00565 protected: 00566 csBitArray bitSet; 00567 csVector3* boneVecs; 00568 csQuaternion* boneQuats; 00569 size_t numberOfBones; 00570 }; 00571 00572 00573 } // namespace Animation 00574 } // namespace CS 00575 00576 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::AnimatedMeshState instead") 00577 typedef CS::Animation::AnimatedMeshState csSkeletalState2; 00578 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::iSkeleton instead") 00579 typedef CS::Animation::iSkeleton iSkeleton2; 00580 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::iSkeletonFactory instead") 00581 typedef CS::Animation::iSkeletonFactory iSkeletonFactory2; 00582 CS_DEPRECATED_METHOD_MSG("Use CS::Animation::iSkeletonManager instead") 00583 typedef CS::Animation::iSkeletonManager iSkeletonManager2; 00584 00590 #endif // __CS_IMESH_SKELETON2_H__ 00591
Generated for Crystal Space 2.1 by doxygen 1.6.1
