From fa4843386ff5a0ba0797006aa792372fa30ad0b1 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 17 Jan 2019 09:00:56 +0800 Subject: =?UTF-8?q?*=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Asura/GameObject.h | 2 +- Source/Asura/Graphics/Animation.h | 39 +++++++++++++++++++ Source/Asura/Graphics/Camera.cpp | 0 Source/Asura/Graphics/Camera.h | 37 ++++++++++++++++++ Source/Asura/Graphics/Image.h | 37 +++++++++++++----- Source/Asura/Graphics/Material.h | 5 ++- Source/Asura/Graphics/Mesh2D.cpp | 0 Source/Asura/Graphics/Mesh2D.h | 20 ++++++++++ Source/Asura/Graphics/Mesh2DRenderer.cpp | 0 Source/Asura/Graphics/Mesh2DRenderer.h | 0 Source/Asura/Graphics/ParticleSystem.h | 2 +- Source/Asura/Graphics/RenderTarget.cpp | 0 Source/Asura/Graphics/RenderTarget.h | 22 +++++++++++ Source/Asura/Graphics/Renderer.h | 12 +++++- Source/Asura/Graphics/Shader.h | 2 +- Source/Asura/Graphics/ShapeRenderer.cpp | 0 Source/Asura/Graphics/ShapeRenderer.h | 0 Source/Asura/Graphics/Sprite.h | 67 ++++++++++++++++++++++++++++++++ Source/Asura/Graphics/SpriteRenderer.cpp | 0 Source/Asura/Graphics/SpriteRenderer.h | 29 ++++++++++++++ Source/Asura/Graphics/Texture.h | 7 +++- Source/Asura/Math/Curve.cpp | 0 Source/Asura/Math/Curve.h | 0 Source/Asura/Math/RangedValue.cpp | 0 Source/Asura/Math/RangedValue.h | 0 Source/Asura/Physics/World.h | 0 Source/Asura/Transform.h | 6 ++- 27 files changed, 270 insertions(+), 17 deletions(-) create mode 100644 Source/Asura/Graphics/Camera.cpp create mode 100644 Source/Asura/Graphics/Camera.h create mode 100644 Source/Asura/Graphics/Mesh2D.cpp create mode 100644 Source/Asura/Graphics/Mesh2D.h create mode 100644 Source/Asura/Graphics/Mesh2DRenderer.cpp create mode 100644 Source/Asura/Graphics/Mesh2DRenderer.h create mode 100644 Source/Asura/Graphics/RenderTarget.cpp create mode 100644 Source/Asura/Graphics/RenderTarget.h create mode 100644 Source/Asura/Graphics/ShapeRenderer.cpp create mode 100644 Source/Asura/Graphics/ShapeRenderer.h create mode 100644 Source/Asura/Graphics/SpriteRenderer.cpp create mode 100644 Source/Asura/Graphics/SpriteRenderer.h create mode 100644 Source/Asura/Math/Curve.cpp create mode 100644 Source/Asura/Math/Curve.h create mode 100644 Source/Asura/Math/RangedValue.cpp create mode 100644 Source/Asura/Math/RangedValue.h create mode 100644 Source/Asura/Physics/World.h (limited to 'Source') diff --git a/Source/Asura/GameObject.h b/Source/Asura/GameObject.h index fcef864..f4c4eb8 100644 --- a/Source/Asura/GameObject.h +++ b/Source/Asura/GameObject.h @@ -12,7 +12,7 @@ namespace AsuraEngine { /// - /// 游戏实体 + /// 游戏实体,由引擎管理。 /// class GameObject final : public Object { diff --git a/Source/Asura/Graphics/Animation.h b/Source/Asura/Graphics/Animation.h index e69de29..e3d82b7 100644 --- a/Source/Asura/Graphics/Animation.h +++ b/Source/Asura/Graphics/Animation.h @@ -0,0 +1,39 @@ +#ifndef __AE_ANIMATION_H__ +#define __AE_ANIMATION_H__ + +#include "Sprite.h" +#include "Component.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// 关键帧 + /// + class AnimationKeyFrame + { + + }; + + /// + /// Sprite动画,可以改变的有sprite的大小、旋转、缩放、image + /// + class Animation final : public Component + { + public: + + private: + + /// + /// + /// + Sprite* mSprite; + + }; + + } +} + +#endif \ No newline at end of file diff --git a/Source/Asura/Graphics/Camera.cpp b/Source/Asura/Graphics/Camera.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/Camera.h b/Source/Asura/Graphics/Camera.h new file mode 100644 index 0000000..9da6ab0 --- /dev/null +++ b/Source/Asura/Graphics/Camera.h @@ -0,0 +1,37 @@ +#ifndef __AE_CAMERA_H__ +#define __AE_CAMERA_H__ + +#include "RenderTarget.h" +#include "Component.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// Orthographic Camera. + /// + class Camera : public Component + { + public: + + + private: + + /// + /// 渲染的目标 + /// + RenderTarget* mRenderTarget; + + /// + /// 是否渲染到屏幕上 + /// + bool mIsOnScreen; + + }; + + } +} + +#endif diff --git a/Source/Asura/Graphics/Image.h b/Source/Asura/Graphics/Image.h index bd885eb..198ad9e 100644 --- a/Source/Asura/Graphics/Image.h +++ b/Source/Asura/Graphics/Image.h @@ -1,17 +1,36 @@ #ifndef __AE_IMAGE_H__ #define __AE_IMAGE_H__ -namespace AsuraEngine +#include "Math/Vector2.h" +#include "Object.h" + +namespace AsuraEngine { - namespace Graphics - { - - class Image - { - + namespace Graphics + { + + /// + /// Image是图片从内存中载入后,读取进游戏后保存的结果。一个Image在内存、显存中只会保存一份,不会产生副本。需要特 + /// 征化的区别image,如锚点位置,缩放和旋转角度,使用sprite。基本是一个只读类。 + /// + class Image final : public Object + { + public: + + Math::Vector2 GetSize(); + uint GetWidth(); + uint GetHeight(); + + private: + + /// + /// 大小(以像素为单位) + /// + uint mWidth, mHeight; + }; - - } + + } } #endif \ No newline at end of file diff --git a/Source/Asura/Graphics/Material.h b/Source/Asura/Graphics/Material.h index 16411a0..13c066a 100644 --- a/Source/Asura/Graphics/Material.h +++ b/Source/Asura/Graphics/Material.h @@ -22,7 +22,7 @@ namespace AsuraEngine /// 不同参数,通过数据文件(.mat)实现,而不是在代码里配置。所以在Asura中,Shader无法直接应用到渲染流程而必须和一个 /// 材质关联,由材质修改shader的uniforms,material充当了shader的代理。 /// - class Material : public Object + class Material final : public Object { public: @@ -116,6 +116,8 @@ namespace AsuraEngine LUAX_DECL_FACTORY( Material ); + LUAX_DECL_METHOD( l_Clone ); + LUAX_DECL_METHOD( l_SetShader ); LUAX_DECL_METHOD( l_SetTexture ); @@ -126,7 +128,6 @@ namespace AsuraEngine LUAX_DECL_METHOD( l_SetFloat ); LUAX_DECL_METHOD( l_SetInteger ); LUAX_DECL_METHOD( l_SetColor ); - LUAX_DECL_METHOD( l_SetVertexAttributes ); LUAX_DECL_METHOD( l_GetUniformInfo ); LUAX_DECL_METHOD( l_GetUniformInfof ); diff --git a/Source/Asura/Graphics/Mesh2D.cpp b/Source/Asura/Graphics/Mesh2D.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/Mesh2D.h b/Source/Asura/Graphics/Mesh2D.h new file mode 100644 index 0000000..a113f4c --- /dev/null +++ b/Source/Asura/Graphics/Mesh2D.h @@ -0,0 +1,20 @@ +#ifndef __AE_MESH2D_H__ +#define __AE_MESH2D_H__ + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// 2D mesh,用于做一些UV动画 + /// + class Mesh2D + { + + }; + + } +} + +#endif \ No newline at end of file diff --git a/Source/Asura/Graphics/Mesh2DRenderer.cpp b/Source/Asura/Graphics/Mesh2DRenderer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/Mesh2DRenderer.h b/Source/Asura/Graphics/Mesh2DRenderer.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/ParticleSystem.h b/Source/Asura/Graphics/ParticleSystem.h index 98aba49..2c22608 100644 --- a/Source/Asura/Graphics/ParticleSystem.h +++ b/Source/Asura/Graphics/ParticleSystem.h @@ -8,7 +8,7 @@ namespace AsuraEngine namespace Graphics { - class ParticleSystem : public Component + class ParticleSystem final : public Component { }; diff --git a/Source/Asura/Graphics/RenderTarget.cpp b/Source/Asura/Graphics/RenderTarget.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/RenderTarget.h b/Source/Asura/Graphics/RenderTarget.h new file mode 100644 index 0000000..b3f90cd --- /dev/null +++ b/Source/Asura/Graphics/RenderTarget.h @@ -0,0 +1,22 @@ +#ifndef __AE_RENDER_TARGET_H__ +#define __AE_RENDER_TARGET_H__ + +#include "Texture.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class RenderTarget : public Texture + { + public: + + + + }; + + } +} + +#endif \ No newline at end of file diff --git a/Source/Asura/Graphics/Renderer.h b/Source/Asura/Graphics/Renderer.h index 2efa391..c3677a7 100644 --- a/Source/Asura/Graphics/Renderer.h +++ b/Source/Asura/Graphics/Renderer.h @@ -9,16 +9,26 @@ namespace AsuraEngine namespace Graphics { + /// + /// 抽象基类,渲染由Renderer类处理,每个Renderer必须具备一个材质。 + /// class Renderer : public Component { public: + /// /// 一旦调用此方法,就会拷贝shared material,调用此方法意味着要对material的配置进行修改,如果此时使用的材质是 /// shared material,则需要拷贝一份,避免影响其他共享的renderer。 /// Material* GetMaterial(); - private: + /// + /// 渲染回调函数 + /// + virtual void OnRender() = 0; + + protected: + Material* mMaterial; }; diff --git a/Source/Asura/Graphics/Shader.h b/Source/Asura/Graphics/Shader.h index 7c09139..ccd38af 100644 --- a/Source/Asura/Graphics/Shader.h +++ b/Source/Asura/Graphics/Shader.h @@ -18,7 +18,7 @@ namespace AsuraEngine /// /// 一个shader是一个在材质间共享的程序。Shader本身不保存uniforms和顶点数据,只保存uniforms location。 /// - class Shader : public Object + class Shader final : public Object { public: diff --git a/Source/Asura/Graphics/ShapeRenderer.cpp b/Source/Asura/Graphics/ShapeRenderer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/ShapeRenderer.h b/Source/Asura/Graphics/ShapeRenderer.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/Sprite.h b/Source/Asura/Graphics/Sprite.h index e69de29..b573c45 100644 --- a/Source/Asura/Graphics/Sprite.h +++ b/Source/Asura/Graphics/Sprite.h @@ -0,0 +1,67 @@ +#ifndef __AE_SPRITE_H__ +#define __AE_SPRITE_H__ + +#include "Math/Vector2.h" +#include "Transform.h" +#include "Component.h" +#include "Image.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// Sprite是控制image的代理,image是在sprite间共享的数据,sprite可以区别化处理image的属性,如旋转,缩放等。 + /// + class Sprite final : public Object + { + public: + + enum Type + { + + }; + + /// + /// 对齐方式 + /// + enum Align + { + + }; + + void SetImage(Image* image); + + private: + + /// + /// 锚点坐标 + /// + Math::Vector2 mAnchor; + + /// + /// 大小 + /// + Math::Vector2 size; + + /// + /// 相对于GameObject的transform。 + /// + Transform mTransform; + + /// + /// 绑定的image + /// + Image* mImage; + + //---------------------------------------------------------------------------------------------------- + + + + }; + + } +} + +#endif \ No newline at end of file diff --git a/Source/Asura/Graphics/SpriteRenderer.cpp b/Source/Asura/Graphics/SpriteRenderer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Graphics/SpriteRenderer.h b/Source/Asura/Graphics/SpriteRenderer.h new file mode 100644 index 0000000..4df932c --- /dev/null +++ b/Source/Asura/Graphics/SpriteRenderer.h @@ -0,0 +1,29 @@ +#ifndef __AE_SPRITE_RENDERER_H__ +#define __AE_SPRITE_RENDERER_H__ + +#include "Renderer.h" +#include "Sprite.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class SpriteRenderer final : public Renderer + { + public: + void OnRender() override; + + private: + + /// + /// 用来渲染的sprite + /// + Sprite* mSprite; + + }; + + } +} + +#endif \ No newline at end of file diff --git a/Source/Asura/Graphics/Texture.h b/Source/Asura/Graphics/Texture.h index 0b9af4c..cc015ef 100644 --- a/Source/Asura/Graphics/Texture.h +++ b/Source/Asura/Graphics/Texture.h @@ -1,12 +1,17 @@ #ifndef __AE_TEXTURE_H__ #define __AE_TEXTURE_H__ +#include "Component.h" + namespace AsuraEngine { namespace Graphics { - class Texture + /// + /// 2D纹理(抽象类),在2d mesh和render target中被使用 + /// + class Texture : public Component { }; diff --git a/Source/Asura/Math/Curve.cpp b/Source/Asura/Math/Curve.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Math/Curve.h b/Source/Asura/Math/Curve.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Math/RangedValue.cpp b/Source/Asura/Math/RangedValue.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Math/RangedValue.h b/Source/Asura/Math/RangedValue.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Physics/World.h b/Source/Asura/Physics/World.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura/Transform.h b/Source/Asura/Transform.h index 98a0c77..cca7575 100644 --- a/Source/Asura/Transform.h +++ b/Source/Asura/Transform.h @@ -1,12 +1,16 @@ #ifndef __AE_TRANSFORM_H__ #define __AE_TRANSFORM_H__ +#include "Object.h" #include "Math/Vector2.h" namespace AsuraEngine { - class Transform + /// + /// Transform作为基本属性,不作为组件处理 + /// + class Transform final : public Object { private: Math::Vector2 position; -- cgit v1.1-26-g67d0