summaryrefslogtreecommitdiff
path: root/Source/modules/asura-core/Mesh/Mesh2DData.h
blob: f041e05c5c6fa30763001f44030e9ea69e06ef99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef _ASURA_MESH2D_DATA_H__
#define _ASURA_MESH2D_DATA_H__

// cpp
#include <vector>

// asura modules
#include <asura-base/Scripting/Scripting.h>
#include <asura-base/Math/Vector2.hpp>
#include <asura-base/FileSystem/DecodedData.h>

// module
#include "../Graphics/Color.h"
#include "../Graphics/GPUBuffer.h"

namespace_begin(AsuraEngine)
namespace_begin(Mesh)

///
/// Mesh2DĶݣindexʹáAsura 2D mesh֧4UVһϡ
///
struct Vertex
{
	Vector2f  position;    ///< 
	AEGraphics::Color color;       ///< ɫ
	Vector2f  texCoord[4]; ///< UVs
};

///
/// meshĶݺ
///
class Mesh2DData
	: AEFileSystem::DecodedData
	, AEScripting::Portable<Mesh2DData>
{
public:

	enum Mesh2DComponent
	{
		MESH2D_COMPONENT_POSITION,
		MESH2D_COMPONENT_COLOR,
		MESH2D_COMPONENT_TEXCOORD0,
		MESH2D_COMPONENT_TEXCOORD1,
		MESH2D_COMPONENT_TEXCOORD2,
		MESH2D_COMPONENT_TEXCOORD3,
	};

	void Decode(AEFileSystem::DataBuffer& buffer) override;

private:

	LUAX_DECL_FACTORY(Mesh2DData);
			
	LUAX_DECL_ENUM(Mesh2DComponent, 1);

	LUAX_DECL_METHOD(_GetVertices);
	LUAX_DECL_METHOD(_GetVertex);

	///
	/// meshж㡣
	///
	std::vector<Vertex*> m_Vertices;

	///
	/// ebo
	///
	std::vector<int> m_Indices;

	int m_Components;

};

namespace_end
namespace_end

namespace AEMesh = AsuraEngine::Mesh;

#endif