diff options
author | chai <chaifix@163.com> | 2019-01-17 22:29:07 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-17 22:29:07 +0800 |
commit | a33337dc2b1ecc5b22462e7b9b65cd9d6b323017 (patch) | |
tree | 71e75875e373f0fd24e5d17eda8dfe13c984db00 /Source | |
parent | fa4843386ff5a0ba0797006aa792372fa30ad0b1 (diff) |
*graphics
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Asura/Component.h | 2 | ||||
-rw-r--r-- | Source/Asura/GameObject.h | 6 | ||||
-rw-r--r-- | Source/Asura/Graphics/Animation.cpp | 21 | ||||
-rw-r--r-- | Source/Asura/Graphics/Animation.h | 78 | ||||
-rw-r--r-- | Source/Asura/Graphics/Camera.h | 5 | ||||
-rw-r--r-- | Source/Asura/Graphics/Image.h | 33 | ||||
-rw-r--r-- | Source/Asura/Graphics/Material.h | 6 | ||||
-rw-r--r-- | Source/Asura/Graphics/Shader.h | 6 | ||||
-rw-r--r-- | Source/Asura/Graphics/Sprite.h | 16 | ||||
-rw-r--r-- | Source/Asura/Graphics/SpriteRenderer.h | 3 | ||||
-rw-r--r-- | Source/Asura/Manager.hpp | 14 | ||||
-rw-r--r-- | Source/Asura/Scene.h | 11 |
12 files changed, 189 insertions, 12 deletions
diff --git a/Source/Asura/Component.h b/Source/Asura/Component.h index a602d50..5a9073d 100644 --- a/Source/Asura/Component.h +++ b/Source/Asura/Component.h @@ -1,7 +1,7 @@ #ifndef __AE_COMPONENT_H__ #define __AE_COMPONENT_H__ -#include "Object.h" +#include "GameObject.h" namespace AsuraEngine { diff --git a/Source/Asura/GameObject.h b/Source/Asura/GameObject.h index f4c4eb8..8e79b65 100644 --- a/Source/Asura/GameObject.h +++ b/Source/Asura/GameObject.h @@ -37,6 +37,12 @@ namespace AsuraEngine void SetScale(const Math::Vector2& scale); void SetRotation(const Math::Vector2& rotation); + template<typename T> + inline T GetComponent() + { + return NULL; + } + private: Transform mTransform; diff --git a/Source/Asura/Graphics/Animation.cpp b/Source/Asura/Graphics/Animation.cpp index e69de29..47643aa 100644 --- a/Source/Asura/Graphics/Animation.cpp +++ b/Source/Asura/Graphics/Animation.cpp @@ -0,0 +1,21 @@ +#include "Animation.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + void Animation::OnEnable() + { + mSpriteRenderer = mGameObject->GetComponent<SpriteRenderer*>(); + } + + void Animation::OnUpdate(uint32 milliseconds) + { + if (!mSpriteRenderer) + return; + mSpriteRenderer->SetSprite(NULL); + } + + } +} diff --git a/Source/Asura/Graphics/Animation.h b/Source/Asura/Graphics/Animation.h index e3d82b7..0e4bd5a 100644 --- a/Source/Asura/Graphics/Animation.h +++ b/Source/Asura/Graphics/Animation.h @@ -3,6 +3,11 @@ #include "Sprite.h" #include "Component.h" +#include "Manager.hpp" +#include "SpriteRenderer.h" +#include "Containers/Map.h" +#include "Containers/Vector.hpp" +#include "Containers/StringMap.hpp" namespace AsuraEngine { @@ -12,9 +17,10 @@ namespace AsuraEngine /// /// ؼ֡ /// - class AnimationKeyFrame + struct AnimationKeyFrame { - + float time; + Sprite* sprite; }; /// @@ -24,12 +30,78 @@ namespace AsuraEngine { public: + enum UpdateMask + { + Scale = 1, + Position = 1 << 1, + Rotation = 1 << 2, + Sprite = 1 << 3 + }; + + struct Definition + { + + }; + + void OnEnable() override; + void OnUpdate(uint32 milliseconds) override; + + void SetSpeed(float speed); + + private: + + Containers::Vector<AnimationKeyFrame> mFrames; + + float mTime; + + bool mLoop; + + /// + /// ٶȣĬΪ1 + /// + float mSpeed; + + /// + /// + /// + uint mKey; + + Containers::String mName; + + UpdateMask mUpdateMask; + + SpriteRenderer* mSpriteRenderer; + + }; + + 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: /// + /// ӳIDanimation + /// + Containers::StringMap<uint> mAnimationIDs; + /// + /// ӳkeyanimation /// - Sprite* mSprite; + Containers::Map<uint, Animation*> mAnimations; }; diff --git a/Source/Asura/Graphics/Camera.h b/Source/Asura/Graphics/Camera.h index 9da6ab0..699d342 100644 --- a/Source/Asura/Graphics/Camera.h +++ b/Source/Asura/Graphics/Camera.h @@ -29,6 +29,11 @@ namespace AsuraEngine /// bool mIsOnScreen; + /// + /// ü + /// + bool mIsCulling; + }; } diff --git a/Source/Asura/Graphics/Image.h b/Source/Asura/Graphics/Image.h index 198ad9e..34a83ce 100644 --- a/Source/Asura/Graphics/Image.h +++ b/Source/Asura/Graphics/Image.h @@ -2,6 +2,7 @@ #define __AE_IMAGE_H__ #include "Math/Vector2.h" +#include "Manager.hpp" #include "Object.h" namespace AsuraEngine @@ -10,8 +11,8 @@ namespace AsuraEngine { /// - /// ImageͼƬڴȡϷĽһImageڴ桢ԴֻᱣһݣҪ - /// imageêλãźתǶȣʹspriteһֻࡣ + /// ImageͼƬڴȡϷĽһImageڴ桢ԴֻᱣһݣҪ + /// imageêλãźתǶȣʹspriteһֻࡣ /// class Image final : public Object { @@ -30,6 +31,34 @@ namespace AsuraEngine }; + class ImageManager : public Manager + { + public: + + uint GetImagePath(uint ID); + + uint GetImageID(const Containers::String& path); + + Image* GetImage(const Containers::String& path); + + Image* GetImage(const Containers::String& id); + + uint AddImage(const Containers::String& path, Image* image); + + private: + + /// + /// еimage + /// + Containers::Map<uint, Image*> mImages; + + /// + /// еimage·IDӳ + /// + Containers::StringMap<uint> mImageIDs; + + }; + } } diff --git a/Source/Asura/Graphics/Material.h b/Source/Asura/Graphics/Material.h index 13c066a..56db3d9 100644 --- a/Source/Asura/Graphics/Material.h +++ b/Source/Asura/Graphics/Material.h @@ -11,6 +11,7 @@ #include "Shader.h" #include "Texture.h" +#include "Manager.hpp" namespace AsuraEngine { @@ -143,6 +144,11 @@ namespace AsuraEngine }; + class MaterialManager : public Manager + { + + }; + } } diff --git a/Source/Asura/Graphics/Shader.h b/Source/Asura/Graphics/Shader.h index ccd38af..b1e9c7a 100644 --- a/Source/Asura/Graphics/Shader.h +++ b/Source/Asura/Graphics/Shader.h @@ -7,6 +7,7 @@ #include "Containers/StringMap.hpp" #include "Object.h" #include "Color.h" +#include "Manager.hpp" namespace AsuraEngine { @@ -54,6 +55,11 @@ namespace AsuraEngine }; + class ShaderManager final : public Manager + { + + }; + } } diff --git a/Source/Asura/Graphics/Sprite.h b/Source/Asura/Graphics/Sprite.h index b573c45..581ee87 100644 --- a/Source/Asura/Graphics/Sprite.h +++ b/Source/Asura/Graphics/Sprite.h @@ -31,7 +31,16 @@ namespace AsuraEngine }; - void SetImage(Image* image); + struct SpriteDef + { + Image* image; + Align align; + Math::Vector2 anchor; + Math::Vector2 size; + }; + + Sprite(SpriteDef definition); + ~Sprite(); private: @@ -46,11 +55,6 @@ namespace AsuraEngine Math::Vector2 size; /// - /// GameObjecttransform - /// - Transform mTransform; - - /// /// image /// Image* mImage; diff --git a/Source/Asura/Graphics/SpriteRenderer.h b/Source/Asura/Graphics/SpriteRenderer.h index 4df932c..bd81509 100644 --- a/Source/Asura/Graphics/SpriteRenderer.h +++ b/Source/Asura/Graphics/SpriteRenderer.h @@ -12,6 +12,9 @@ namespace AsuraEngine class SpriteRenderer final : public Renderer { public: + + void SetSprite(Sprite* sprite); + void OnRender() override; private: diff --git a/Source/Asura/Manager.hpp b/Source/Asura/Manager.hpp new file mode 100644 index 0000000..5a94889 --- /dev/null +++ b/Source/Asura/Manager.hpp @@ -0,0 +1,14 @@ +#ifndef __AE_MANAGER_H__ +#define __AE_MANAGER_H__ + +namespace AsuraEngine +{ + + class Manager + { + + }; + +} + +#endif
\ No newline at end of file diff --git a/Source/Asura/Scene.h b/Source/Asura/Scene.h index 2fc4649..c873751 100644 --- a/Source/Asura/Scene.h +++ b/Source/Asura/Scene.h @@ -1,11 +1,22 @@ #ifndef __AE_SCENE_H__ #define __AE_SCENE_H__ +#include "Containers/Vector.hpp" +#include "GameObject.h" + namespace AsuraEngine { + /// + /// Ϸ + /// class Scene { + public: + + private: + + Containers::Vector<GameObject*> mGameObjects; }; |