From 084623519e95f0ab0cf4bc328b5fa736d679c5bd Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 31 Jul 2019 21:35:12 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/modules/asura-core/mesh/am2_handler.cpp | 10 +-- source/modules/asura-core/mesh/am2_handler.h | 34 ++++---- source/modules/asura-core/mesh/mesh2d_data.h | 100 ++++++++++++------------ source/modules/asura-core/mesh/mesh2d_handler.h | 34 ++++---- 4 files changed, 85 insertions(+), 93 deletions(-) (limited to 'source/modules/asura-core/mesh') diff --git a/source/modules/asura-core/mesh/am2_handler.cpp b/source/modules/asura-core/mesh/am2_handler.cpp index 31bd51b..d0b9252 100644 --- a/source/modules/asura-core/mesh/am2_handler.cpp +++ b/source/modules/asura-core/mesh/am2_handler.cpp @@ -1,9 +1,7 @@ #include "am2_handler.h" -namespace AsuraEngine -{ - namespace Mesh - { +namespace_begin(AsuraEngine) +namespace_begin(Mesh) /* Asura定义的mesh2D格式称为.am2,具体格式如下。 开头11个字节表明这是一个AsuraMesh2D文件 @@ -32,5 +30,5 @@ f 0, 1, 2 - } -} +namespace_end +namespace_end diff --git a/source/modules/asura-core/mesh/am2_handler.h b/source/modules/asura-core/mesh/am2_handler.h index de93be9..4fa8ba5 100644 --- a/source/modules/asura-core/mesh/am2_handler.h +++ b/source/modules/asura-core/mesh/am2_handler.h @@ -3,30 +3,28 @@ #include "mesh2d_handler.h" -namespace AsuraEngine -{ - namespace Mesh - { +namespace_begin(AsuraEngine) +namespace_begin(Mesh) - /// - /// Asura Mesh Format handler。解析和构建Asura定义的.am2格式的mesh文件。 - /// - class AM2Handler ASURA_FINAL : public Mesh2DHandler - { - public: +/// +/// Asura Mesh Format handler。解析和构建Asura定义的.am2格式的mesh文件。 +/// +class AM2Handler ASURA_FINAL : public Mesh2DHandler +{ +public: - AM2Handler(); - ~AM2Handler(); + AM2Handler(); + ~AM2Handler(); - bool CanDecode(AEIO::DataBuffer& input) override; + bool CanDecode(AEIO::DataBuffer& input) override; - void Decode(AEIO::DataBuffer& input, Mesh2DData& target) override; + void Decode(AEIO::DataBuffer& input, Mesh2DData& target) override; - void Encode(Mesh2DData& input, AEIO::DataBuffer& target) override; + void Encode(Mesh2DData& input, AEIO::DataBuffer& target) override; - }; +}; - } -} +namespace_end +namespace_end #endif \ No newline at end of file diff --git a/source/modules/asura-core/mesh/mesh2d_data.h b/source/modules/asura-core/mesh/mesh2d_data.h index 2fea7ec..024ba02 100644 --- a/source/modules/asura-core/mesh/mesh2d_data.h +++ b/source/modules/asura-core/mesh/mesh2d_data.h @@ -13,67 +13,65 @@ #include "../graphics/color.h" #include "../graphics/gpu_buffer.h" -namespace AsuraEngine +namespace_begin(AsuraEngine) +namespace_begin(Mesh) + +/// +/// Mesh2D的顶点数据,和index数据配合使用。Asura 2D mesh支持4套UV运用在一个顶点上。 +/// +struct Vertex +{ + AEMath::Vector2f position; ///< 坐标 + AEGraphics::Color color; ///< 颜色 + AEMath::Vector2f texCoord[4]; ///< UVs +}; + +/// +/// mesh的顶点数据和索引数据 +/// +class Mesh2DData + : AEIO::DecodedData + , AEScripting::Portable { - namespace Mesh +public: + + enum Mesh2DComponent { + MESH2D_COMPONENT_POSITION, + MESH2D_COMPONENT_COLOR, + MESH2D_COMPONENT_TEXCOORD0, + MESH2D_COMPONENT_TEXCOORD1, + MESH2D_COMPONENT_TEXCOORD2, + MESH2D_COMPONENT_TEXCOORD3, + }; + + void Decode(AEIO::DataBuffer& buffer) override; + +private: - /// - /// Mesh2D的顶点数据,和index数据配合使用。Asura 2D mesh支持4套UV运用在一个顶点上。 - /// - struct Vertex - { - AEMath::Vector2f position; ///< 坐标 - AEGraphics::Color color; ///< 颜色 - AEMath::Vector2f texCoord[4]; ///< UVs - }; - - /// - /// mesh的顶点数据和索引数据 - /// - class Mesh2DData - : AEIO::DecodedData - , AEScripting::Portable - { - public: - - enum Mesh2DComponent - { - MESH2D_COMPONENT_POSITION, - MESH2D_COMPONENT_COLOR, - MESH2D_COMPONENT_TEXCOORD0, - MESH2D_COMPONENT_TEXCOORD1, - MESH2D_COMPONENT_TEXCOORD2, - MESH2D_COMPONENT_TEXCOORD3, - }; - - void Decode(AEIO::DataBuffer& buffer) override; - - private: - - LUAX_DECL_FACTORY(Mesh2DData); + LUAX_DECL_FACTORY(Mesh2DData); - LUAX_DECL_ENUM(Mesh2DComponent, 1); + LUAX_DECL_ENUM(Mesh2DComponent, 1); - LUAX_DECL_METHOD(_GetVertices); - LUAX_DECL_METHOD(_GetVertex); + LUAX_DECL_METHOD(_GetVertices); + LUAX_DECL_METHOD(_GetVertex); - /// - /// mesh的所有顶点。 - /// - std::vector m_Vertices; + /// + /// mesh的所有顶点。 + /// + std::vector m_Vertices; - /// - /// 索引,用来构建ebo。 - /// - std::vector m_Indices; + /// + /// 索引,用来构建ebo。 + /// + std::vector m_Indices; - int m_Components; + int m_Components; - }; +}; - } -} +namespace_end +namespace_end namespace AEMesh = AsuraEngine::Mesh; diff --git a/source/modules/asura-core/mesh/mesh2d_handler.h b/source/modules/asura-core/mesh/mesh2d_handler.h index 05e12f0..c8ae32e 100644 --- a/source/modules/asura-core/mesh/mesh2d_handler.h +++ b/source/modules/asura-core/mesh/mesh2d_handler.h @@ -6,29 +6,27 @@ #include "mesh2d_data.h" -namespace AsuraEngine -{ - namespace Mesh - { +namespace_begin(AsuraEngine) +namespace_begin(Mesh) - /// - /// 解析和保存mesh数据 - /// - ASURA_ABSTRACT class Mesh2DHandler - { - public: - Mesh2DHandler() {}; - virtual ~Mesh2DHandler() {}; +/// +/// 解析和保存mesh数据 +/// +ASURA_ABSTRACT class Mesh2DHandler +{ +public: + Mesh2DHandler() {}; + virtual ~Mesh2DHandler() {}; - virtual bool CanDecode(AEIO::DataBuffer& input) = 0; + virtual bool CanDecode(AEIO::DataBuffer& input) = 0; - virtual void Decode(AEIO::DataBuffer& input, Mesh2DData& target) = 0; + virtual void Decode(AEIO::DataBuffer& input, Mesh2DData& target) = 0; - virtual void Encode(Mesh2DData& input, AEIO::DataBuffer& target) = 0; + virtual void Encode(Mesh2DData& input, AEIO::DataBuffer& target) = 0; - }; +}; - } -} +namespace_end +namespace_end #endif \ No newline at end of file -- cgit v1.1-26-g67d0