From a33337dc2b1ecc5b22462e7b9b65cd9d6b323017 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 17 Jan 2019 22:29:07 +0800 Subject: *graphics --- Build/Asura/Asura.vcxproj | 1 + Build/Asura/Asura.vcxproj.filters | 1 + Build/Runner/Runner.vcxproj.user | 4 ++ "Docs/~$\350\256\260\345\275\225.docx" | Bin 0 -> 162 bytes Docs/~WRL1631.tmp | Bin 0 -> 12544 bytes "Docs/\350\256\260\345\275\225.docx" | Bin 0 -> 12731 bytes Samples/Hello/entities/player.asr | 5 ++ Samples/Hello/gfx/icon.png | Bin 0 -> 4147 bytes Samples/Hello/gfx/icon.png.asr | 3 + Samples/Hello/gfx/particles/fire.asr | 4 ++ Samples/Hello/hello.asuraproject | 2 + Samples/Hello/scripts/components/fireball.lua | 28 ++++++++ Samples/Hello/scripts/components/fireball.lua.asr | 0 Samples/Hello/scripts/entities/bullet.lua | 0 Samples/Hello/scripts/entities/bullet.lua.asr | 3 + Samples/Hello/scripts/entities/spark.lua | 3 + Samples/Hello/scripts/entities/spark.lua.asr | 0 Samples/Hello/scripts/hello.lua | 0 Samples/Hello/scripts/hello.lua.asr | 3 + Samples/Hello/spr/spr_image.asr | 6 ++ Source/Asura/Component.h | 2 +- Source/Asura/GameObject.h | 6 ++ Source/Asura/Graphics/Animation.cpp | 21 ++++++ Source/Asura/Graphics/Animation.h | 78 +++++++++++++++++++++- Source/Asura/Graphics/Camera.h | 5 ++ Source/Asura/Graphics/Image.h | 33 ++++++++- Source/Asura/Graphics/Material.h | 6 ++ Source/Asura/Graphics/Shader.h | 6 ++ Source/Asura/Graphics/Sprite.h | 16 +++-- Source/Asura/Graphics/SpriteRenderer.h | 3 + Source/Asura/Manager.hpp | 14 ++++ Source/Asura/Scene.h | 11 +++ 32 files changed, 252 insertions(+), 12 deletions(-) create mode 100644 Build/Runner/Runner.vcxproj.user create mode 100644 "Docs/~$\350\256\260\345\275\225.docx" create mode 100644 Docs/~WRL1631.tmp create mode 100644 "Docs/\350\256\260\345\275\225.docx" create mode 100644 Samples/Hello/entities/player.asr create mode 100644 Samples/Hello/gfx/icon.png create mode 100644 Samples/Hello/gfx/icon.png.asr create mode 100644 Samples/Hello/gfx/particles/fire.asr create mode 100644 Samples/Hello/hello.asuraproject create mode 100644 Samples/Hello/scripts/components/fireball.lua create mode 100644 Samples/Hello/scripts/components/fireball.lua.asr create mode 100644 Samples/Hello/scripts/entities/bullet.lua create mode 100644 Samples/Hello/scripts/entities/bullet.lua.asr create mode 100644 Samples/Hello/scripts/entities/spark.lua create mode 100644 Samples/Hello/scripts/entities/spark.lua.asr create mode 100644 Samples/Hello/scripts/hello.lua create mode 100644 Samples/Hello/scripts/hello.lua.asr create mode 100644 Samples/Hello/spr/spr_image.asr create mode 100644 Source/Asura/Manager.hpp diff --git a/Build/Asura/Asura.vcxproj b/Build/Asura/Asura.vcxproj index 12968cb..30bd0b0 100644 --- a/Build/Asura/Asura.vcxproj +++ b/Build/Asura/Asura.vcxproj @@ -137,6 +137,7 @@ + diff --git a/Build/Asura/Asura.vcxproj.filters b/Build/Asura/Asura.vcxproj.filters index 153a4cc..c1743ee 100644 --- a/Build/Asura/Asura.vcxproj.filters +++ b/Build/Asura/Asura.vcxproj.filters @@ -187,6 +187,7 @@ Graphics + diff --git a/Build/Runner/Runner.vcxproj.user b/Build/Runner/Runner.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/Build/Runner/Runner.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git "a/Docs/~$\350\256\260\345\275\225.docx" "b/Docs/~$\350\256\260\345\275\225.docx" new file mode 100644 index 0000000..a03e1bd Binary files /dev/null and "b/Docs/~$\350\256\260\345\275\225.docx" differ diff --git a/Docs/~WRL1631.tmp b/Docs/~WRL1631.tmp new file mode 100644 index 0000000..036bd85 Binary files /dev/null and b/Docs/~WRL1631.tmp differ diff --git "a/Docs/\350\256\260\345\275\225.docx" "b/Docs/\350\256\260\345\275\225.docx" new file mode 100644 index 0000000..97654a7 Binary files /dev/null and "b/Docs/\350\256\260\345\275\225.docx" differ diff --git a/Samples/Hello/entities/player.asr b/Samples/Hello/entities/player.asr new file mode 100644 index 0000000..fa7550d --- /dev/null +++ b/Samples/Hello/entities/player.asr @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Samples/Hello/gfx/icon.png b/Samples/Hello/gfx/icon.png new file mode 100644 index 0000000..8074c4c Binary files /dev/null and b/Samples/Hello/gfx/icon.png differ diff --git a/Samples/Hello/gfx/icon.png.asr b/Samples/Hello/gfx/icon.png.asr new file mode 100644 index 0000000..93d6d58 --- /dev/null +++ b/Samples/Hello/gfx/icon.png.asr @@ -0,0 +1,3 @@ + + icon.png + \ No newline at end of file diff --git a/Samples/Hello/gfx/particles/fire.asr b/Samples/Hello/gfx/particles/fire.asr new file mode 100644 index 0000000..eae2506 --- /dev/null +++ b/Samples/Hello/gfx/particles/fire.asr @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Samples/Hello/hello.asuraproject b/Samples/Hello/hello.asuraproject new file mode 100644 index 0000000..fee1eb1 --- /dev/null +++ b/Samples/Hello/hello.asuraproject @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Samples/Hello/scripts/components/fireball.lua b/Samples/Hello/scripts/components/fireball.lua new file mode 100644 index 0000000..8b31228 --- /dev/null +++ b/Samples/Hello/scripts/components/fireball.lua @@ -0,0 +1,28 @@ +--´Ó³éÏóÀàcomponentÖÐÅÉÉú +--lua require²»»á¶à´ÎÔØÈ룬¼ûpackage.loadº¯Êý +local Spark = require("scripts/spark.lua") +local Fireball = AsuraEngine.Component.Extend("Fireball") +-- ×é¼þϵķǺ¯ÊýÀàÐÍ£¨ÆßÖÖ£©¶¼»áÏÔʾÔڱ༭Æ÷ÖУ¬ÒªÏÔʾÔڱ༭Æ÷ÖУ¬±ØÐë¸øÒ»¸ö³õʼֵ£¬ÒÔ +-- ÅжÏÀàÐÍ£¬Èç¹ûÊÇnil£¬´ú±í²»ÐèÒªÏÔʾÔڱ༭Æ÷ÖÐ +Fireball.name = "" +Fireball.position = 1 +Fireball.image = nil +Fireball.spark = Spark.New() + +function Fireball:OnEnable() + self.image = self.gameobject.GetComponent(AsuraEngine.Image) +end + +function Fireball:OnEvent(e) + +end + +function Fireball:OnUpdate(ms) + +end + +function Fireball:OnDraw() + +end + +return Fireball \ No newline at end of file diff --git a/Samples/Hello/scripts/components/fireball.lua.asr b/Samples/Hello/scripts/components/fireball.lua.asr new file mode 100644 index 0000000..e69de29 diff --git a/Samples/Hello/scripts/entities/bullet.lua b/Samples/Hello/scripts/entities/bullet.lua new file mode 100644 index 0000000..e69de29 diff --git a/Samples/Hello/scripts/entities/bullet.lua.asr b/Samples/Hello/scripts/entities/bullet.lua.asr new file mode 100644 index 0000000..bd43c00 --- /dev/null +++ b/Samples/Hello/scripts/entities/bullet.lua.asr @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Samples/Hello/scripts/entities/spark.lua b/Samples/Hello/scripts/entities/spark.lua new file mode 100644 index 0000000..c47be06 --- /dev/null +++ b/Samples/Hello/scripts/entities/spark.lua @@ -0,0 +1,3 @@ +local spark + +return spark \ No newline at end of file diff --git a/Samples/Hello/scripts/entities/spark.lua.asr b/Samples/Hello/scripts/entities/spark.lua.asr new file mode 100644 index 0000000..e69de29 diff --git a/Samples/Hello/scripts/hello.lua b/Samples/Hello/scripts/hello.lua new file mode 100644 index 0000000..e69de29 diff --git a/Samples/Hello/scripts/hello.lua.asr b/Samples/Hello/scripts/hello.lua.asr new file mode 100644 index 0000000..87e3c43 --- /dev/null +++ b/Samples/Hello/scripts/hello.lua.asr @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Samples/Hello/spr/spr_image.asr b/Samples/Hello/spr/spr_image.asr new file mode 100644 index 0000000..91be3a3 --- /dev/null +++ b/Samples/Hello/spr/spr_image.asr @@ -0,0 +1,6 @@ + + gfx/icon.png + spr_image + 12,32 + 10,10 + \ No newline at end of file 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 + 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(); + } + + 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 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: /// + /// Ó³ÉäIDµ½animation + /// + Containers::StringMap mAnimationIDs; + /// + /// Ó³Éäkeyµ½animation /// - Sprite* mSprite; + Containers::Map 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 mImages; + + /// + /// ËùÓеÄimage£¬Â·¾¶ºÍIDµÄÓ³Éä + /// + Containers::StringMap 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: @@ -45,11 +54,6 @@ namespace AsuraEngine /// Math::Vector2 size; - /// - /// Ïà¶ÔÓÚGameObjectµÄtransform¡£ - /// - Transform mTransform; - /// /// °ó¶¨µÄimage /// 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 mGameObjects; }; -- cgit v1.1-26-g67d0