imesh/skeleton2anim.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_SKELETON2ANIM_H__ 00020 #define __CS_IMESH_SKELETON2ANIM_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/dualquaternion.h" 00027 #include "imesh/skeleton2.h" 00028 00029 class csQuaternion; 00030 class csVector3; 00031 00036 struct iSkeleton2; 00037 00038 struct iSkeletonAnimPacketFactory2; 00039 struct iSkeletonAnimPacket2; 00040 00041 struct iSkeletonAnimation2; 00042 00043 struct iSkeletonAnimNodeFactory2; 00044 struct iSkeletonAnimNode2; 00045 00046 struct iSkeletonAnimationNodeFactory2; 00047 struct iSkeletonAnimationNode2; 00048 00049 struct iSkeletonBlendNodeFactory2; 00050 struct iSkeletonBlendNode2; 00051 00052 struct iSkeletonPriorityNodeFactory2; 00053 struct iSkeletonPriorityNode2; 00054 00055 struct iSkeletonRandomNodeFactory2; 00056 struct iSkeletonRandomNode2; 00057 00058 struct iSkeletonFSMNodeFactory2; 00059 struct iSkeletonFSMNode2; 00060 00061 class csSkeletalState2; 00062 00063 00070 namespace CS 00071 { 00072 namespace Animation 00073 { 00075 typedef unsigned int ChannelID; 00076 00078 typedef unsigned int KeyFrameID; 00079 00081 typedef unsigned int StateID; 00082 00084 static const ChannelID InvalidChannelID = (ChannelID)~0; 00085 00087 static const KeyFrameID InvalidKeyframeID = (KeyFrameID)~0; 00088 00090 static const StateID InvalidStateID = (CS::Animation::StateID)~0; 00091 00093 enum SynchronizationMode 00094 { 00096 SYNC_NONE, 00098 SYNC_FIRSTFRAME 00099 }; 00100 } 00101 } 00102 00108 struct iSkeletonAnimPacketFactory2 : public virtual iBase 00109 { 00110 SCF_INTERFACE(iSkeletonAnimPacketFactory2, 2, 0, 0); 00111 00115 virtual csPtr<iSkeletonAnimPacket2> CreateInstance (iSkeleton2* skeleton) = 0; 00116 00120 virtual iSkeletonAnimation2* CreateAnimation (const char* name) = 0; 00121 00125 virtual iSkeletonAnimation2* FindAnimation (const char* name) = 0; 00126 00130 virtual void ClearAnimations () = 0; 00131 00135 virtual iSkeletonAnimation2* GetAnimation (size_t index) = 0; 00136 00140 virtual size_t GetAnimationCount () const = 0; 00141 00145 virtual void SetAnimationRoot (iSkeletonAnimNodeFactory2* root) = 0; 00146 00150 virtual iSkeletonAnimNodeFactory2* GetAnimationRoot () const = 0; 00151 00155 virtual csPtr<iSkeletonAnimationNodeFactory2> CreateAnimationNode (const char* name) = 0; 00156 00160 virtual csPtr<iSkeletonBlendNodeFactory2> CreateBlendNode (const char* name) = 0; 00161 00165 virtual csPtr<iSkeletonPriorityNodeFactory2> CreatePriorityNode (const char* name) = 0; 00166 00170 virtual csPtr<iSkeletonRandomNodeFactory2> CreateRandomNode (const char* name) = 0; 00171 00175 virtual csPtr<iSkeletonFSMNodeFactory2> CreateFSMNode (const char* name) = 0; 00176 }; 00177 00181 struct iSkeletonAnimPacket2 : public virtual iBase 00182 { 00183 SCF_INTERFACE(iSkeletonAnimPacket2, 2, 0, 0); 00184 00188 virtual iSkeletonAnimPacketFactory2* GetFactory () const = 0; 00189 00193 virtual iSkeletonAnimNode2* GetAnimationRoot () const = 0; 00194 }; 00195 00202 struct iSkeletonAnimation2 : public virtual iBase 00203 { 00204 SCF_INTERFACE(iSkeletonAnimation2, 2, 0, 0); 00205 00209 virtual const char* GetName () const = 0; 00210 00216 virtual CS::Animation::ChannelID AddChannel (BoneID bone) = 0; 00217 00221 virtual CS::Animation::ChannelID FindChannel (BoneID bone) const = 0; 00222 00229 virtual void AddKeyFrame (CS::Animation::ChannelID channel, float time, 00230 const csQuaternion& rotation, const csVector3& offset) = 0; 00231 00236 virtual size_t GetKeyFrameCount (CS::Animation::ChannelID channel) const = 0; 00237 00246 virtual void GetKeyFrame (CS::Animation::ChannelID channel, 00247 CS::Animation::KeyFrameID keyframe, BoneID& bone, 00248 float& time, csQuaternion& rotation, csVector3& offset) = 0; 00249 00260 virtual void GetTwoKeyFrames (CS::Animation::ChannelID channel, float time, BoneID& bone, 00261 float& timeBefore, csQuaternion& beforeRot, csVector3& beforeOffset, 00262 float& timeAfter, csQuaternion& afterRot, csVector3& afterOffset) = 0; 00263 00272 virtual void BlendState (csSkeletalState2* state, 00273 float baseWeight, float playbackTime, bool isPlayingCyclic) const = 0; 00274 00278 virtual float GetDuration () const = 0; 00279 }; 00280 00281 00286 struct iSkeletonAnimCallback2 : public virtual iBase 00287 { 00292 virtual void AnimationFinished (iSkeletonAnimNode2* node) = 0; 00293 00297 virtual void AnimationCycled (iSkeletonAnimNode2* node) = 0; 00298 00302 virtual void PlayStateChanged (iSkeletonAnimNode2* node, bool isPlaying) = 0; 00303 00307 virtual void DurationChanged (iSkeletonAnimNode2* node) = 0; 00308 }; 00309 00310 00314 struct iSkeletonAnimNodeFactory2 : public virtual iBase 00315 { 00316 SCF_INTERFACE(iSkeletonAnimNodeFactory2, 1, 0, 0); 00317 00321 virtual csPtr<iSkeletonAnimNode2> CreateInstance ( 00322 iSkeletonAnimPacket2* packet, iSkeleton2* skeleton) = 0; 00323 00327 virtual const char* GetNodeName () const = 0; 00328 00332 virtual iSkeletonAnimNodeFactory2* FindNode (const char* name) = 0; 00333 }; 00334 00339 struct iSkeletonAnimNode2 : public virtual iBase 00340 { 00341 SCF_INTERFACE(iSkeletonAnimNode2, 1, 0, 0); 00342 00347 virtual void Play () = 0; 00348 00352 virtual void Stop () = 0; 00353 00358 virtual void SetPlaybackPosition (float time) = 0; 00359 00363 virtual float GetPlaybackPosition () const = 0; 00364 00368 virtual float GetDuration () const = 0; 00369 00373 virtual void SetPlaybackSpeed (float speed) = 0; 00374 00378 virtual float GetPlaybackSpeed () const = 0; 00379 00386 virtual void BlendState (csSkeletalState2* state, float baseWeight = 1.0f) = 0; 00387 00392 virtual void TickAnimation (float dt) = 0; 00393 00397 virtual bool IsActive () const = 0; 00398 00402 virtual iSkeletonAnimNodeFactory2* GetFactory () const = 0; 00403 00407 virtual iSkeletonAnimNode2* FindNode (const char* name) = 0; 00408 00413 virtual void AddAnimationCallback (iSkeletonAnimCallback2* callback) = 0; 00414 00419 virtual void RemoveAnimationCallback (iSkeletonAnimCallback2* callback) = 0; 00420 }; 00421 00425 struct iSkeletonAnimationNodeFactory2 : public iSkeletonAnimNodeFactory2 00426 { 00427 SCF_INTERFACE(iSkeletonAnimationNodeFactory2, 1, 0, 0); 00428 00432 virtual void SetAnimation (iSkeletonAnimation2* animation) = 0; 00433 00437 virtual iSkeletonAnimation2* GetAnimation () const = 0; 00438 00442 virtual void SetCyclic (bool cyclic) = 0; 00443 00447 virtual bool IsCyclic () const = 0; 00448 00452 virtual void SetPlaybackSpeed (float speed) = 0; 00453 00457 virtual float GetPlaybackSpeed () const = 0; 00458 00463 virtual void SetAutomaticReset (bool reset) = 0; 00464 00469 virtual bool GetAutomaticReset () const = 0; 00470 00474 virtual void SetAutomaticStop (bool enabed) = 0; 00475 00479 virtual bool GetAutomaticStop () const = 0; 00480 00481 }; 00482 00487 struct iSkeletonAnimationNode2 : public iSkeletonAnimNode2 00488 { 00489 SCF_INTERFACE(iSkeletonAnimationNode2, 1, 0, 0); 00490 }; 00491 00495 struct iSkeletonBlendNodeFactory2 : public iSkeletonAnimNodeFactory2 00496 { 00497 SCF_INTERFACE(iSkeletonBlendNodeFactory2, 1, 0, 0); 00498 00504 virtual void AddNode (iSkeletonAnimNodeFactory2* node, float weight) = 0; 00505 00509 virtual void SetNodeWeight (uint node, float weight) = 0; 00510 00514 virtual void NormalizeWeights () = 0; 00515 00520 virtual iSkeletonAnimNodeFactory2* GetNode (uint node) = 0; 00521 00525 virtual uint GetNodeCount () const = 0; 00526 00530 virtual void ClearNodes () = 0; 00531 00535 virtual void SetSynchronizationMode (CS::Animation::SynchronizationMode mode) = 0; 00536 00540 virtual CS::Animation::SynchronizationMode GetSynchronizationMode () const = 0; 00541 }; 00542 00543 00549 struct iSkeletonBlendNode2 : public iSkeletonAnimNode2 00550 { 00551 SCF_INTERFACE(iSkeletonBlendNode2, 1, 0, 0); 00552 00556 virtual void SetNodeWeight (uint node, float weight) = 0; 00557 00561 virtual void NormalizeWeights () = 0; 00562 }; 00563 00564 00568 struct iSkeletonPriorityNodeFactory2 : public iSkeletonAnimNodeFactory2 00569 { 00570 SCF_INTERFACE(iSkeletonPriorityNodeFactory2, 1, 0, 0); 00571 00577 virtual void AddNode (iSkeletonAnimNodeFactory2* node, unsigned int priority) = 0; 00578 00582 virtual void SetNodePriority (uint node, unsigned int priority) = 0; 00583 00588 virtual iSkeletonAnimNodeFactory2* GetNode (uint node) = 0; 00589 00593 virtual uint GetNodeCount () const = 0; 00594 00598 virtual void ClearNodes () = 0; 00599 }; 00600 00608 struct iSkeletonPriorityNode2 : public iSkeletonAnimNode2 00609 { 00610 SCF_INTERFACE(iSkeletonPriorityNode2, 1, 0, 0); 00611 00615 virtual void SetNodePriority (uint node, unsigned int priority) = 0; 00616 }; 00617 00621 struct iSkeletonRandomNodeFactory2 : public iSkeletonAnimNodeFactory2 00622 { 00623 SCF_INTERFACE(iSkeletonRandomNodeFactory2, 1, 0, 0); 00624 00631 virtual void AddNode (iSkeletonAnimNodeFactory2* node, float probability) = 0; 00632 00636 virtual void SetNodeProbability (uint node, float weight) = 0; 00637 00642 virtual void SetAutomaticSwitch (bool automatic) = 0; 00643 00648 virtual iSkeletonAnimNodeFactory2* GetNode (uint node) = 0; 00649 00653 virtual uint GetNodeCount () const = 0; 00654 00658 virtual void ClearNodes () = 0; 00659 }; 00660 00661 00665 struct iSkeletonRandomNode2 : public iSkeletonAnimNode2 00666 { 00667 SCF_INTERFACE(iSkeletonRandomNode2, 1, 0, 0); 00668 00672 virtual void Switch () = 0; 00673 00677 virtual iSkeletonAnimNode2* GetCurrentNode () const = 0; 00678 }; 00679 00680 00681 00685 struct iSkeletonFSMNodeFactory2 : public iSkeletonAnimNodeFactory2 00686 { 00687 SCF_INTERFACE(iSkeletonFSMNodeFactory2, 1, 0, 0); 00688 00692 virtual CS::Animation::StateID AddState () = 0; 00693 00698 virtual void SetStateNode (CS::Animation::StateID id, iSkeletonAnimNodeFactory2* nodeFact) = 0; 00699 00704 virtual iSkeletonAnimNodeFactory2* GetStateNode (CS::Animation::StateID id) const = 0; 00705 00709 virtual void SetStateName (CS::Animation::StateID id, const char* name) = 0; 00710 00714 virtual const char* GetStateName (CS::Animation::StateID id) const = 0; 00715 00719 virtual CS::Animation::StateID FindState (const char* name) const = 0; 00720 00725 virtual void SetStartState (CS::Animation::StateID id) = 0; 00726 00731 virtual CS::Animation::StateID GetStartState () const = 0; 00732 00736 virtual uint GetStateCount () const = 0; 00737 00741 virtual void ClearStates () = 0; 00742 00751 virtual void SetStateTransition (CS::Animation::StateID fromState, 00752 CS::Animation::StateID toState, iSkeletonAnimNodeFactory2* fact) = 0; 00753 00763 virtual void SetTransitionCrossfade (CS::Animation::StateID fromState, 00764 CS::Animation::StateID toState, float time1, float time2) = 0; 00765 }; 00766 00767 00771 struct iSkeletonFSMNode2 : public iSkeletonAnimNode2 00772 { 00773 SCF_INTERFACE(iSkeletonFSMNode2, 1, 0, 0); 00774 00778 virtual void SwitchToState (CS::Animation::StateID newState) = 0; 00779 00783 virtual CS::Animation::StateID GetCurrentState () const = 0; 00784 }; 00785 00791 #endif // __CS_IMESH_SKELETON2ANIM_H__
Generated for Crystal Space 1.4.1 by doxygen 1.7.1