From 91e589d1678a8187c307e09b98b67ec4133092ff Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 19 Jan 2019 01:44:05 +0800 Subject: =?UTF-8?q?*=E6=B8=B8=E6=88=8F=E6=A1=86=E6=9E=B6=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Asura.Engine/Graphics/Animation.h | 128 +++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 Source/Asura.Engine/Graphics/Animation.h (limited to 'Source/Asura.Engine/Graphics/Animation.h') diff --git a/Source/Asura.Engine/Graphics/Animation.h b/Source/Asura.Engine/Graphics/Animation.h new file mode 100644 index 0000000..391da22 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Animation.h @@ -0,0 +1,128 @@ +#ifndef __AE_ANIMATION_H__ +#define __AE_ANIMATION_H__ + +#include "Sprite.h" +#include "Component.h" +#include "Manager.hpp" +#include "SpriteRenderer.h" +#include "Containers/Map.h" +#include "Containers/Vector.hpp" +#include "Containers/StringMap.hpp" +#include "Filesystem/Asset.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// 关键帧 + /// + struct Frame + { + uint mask; // + float time; + Sprite* sprite; + }; + + /// + /// Sprite动画,可以改变的有sprite的大小、旋转、缩放、image。Animation通过animator修改。 + /// + class Animation final : public Filesystem::Asset + { + public: + + enum UpdateMask + { + Scale = 1, + Position = 1 << 1, + Rotation = 1 << 2, + Sprite = 1 << 3 + }; + + struct Definition + { + + }; + + /// + /// 根据时间获得一帧 + /// + Frame GetFrame(float t); + + /// + /// 获得关键帧数量 + /// + uint GetKeyFrameCount(); + + /// + /// 是否循环 + /// + uint GetLoop(); + + /// + /// 获取总时间 + /// + uint GetDuration(); + + private: + + /// + /// 关键帧 + /// + Containers::Vector mFrames; + + /// + /// 总时长 + /// + float mDuration; + + /// + /// 是否循环 + /// + bool mLoop; + + /// + /// ID + /// + uint mID; + + UpdateMask mUpdateMask; + + }; + + class AnimationManager : public Manager + { + public: + + Containers::String GetAnimationName(uint ID); + + uint GetAnimationID(const Containers::String& name); + + Animation* GetAnimation(uint ID); + + Animation* GetAnimation(const Containers::String& name); + + /// + /// 添加动画并返回ID + /// + uint AddAnimation(Animation* animation); + + private: + + /// + /// 映射ID到animation + /// + Containers::StringMap mAnimationIDs; + + /// + /// 映射key到animation + /// + Containers::Map mAnimations; + + }; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0