summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/mesh/mesh2d_data.h
blob: 024ba02094cd46354c39c4e42bf5941750858374 (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-utils/scripting/portable.hpp>
#include <asura-utils/math/vector2.hpp>
#include <asura-utils/io/decoded_data.h>

// module
#include "../graphics/color.h"
#include "../graphics/gpu_buffer.h"

namespace_begin(AsuraEngine)
namespace_begin(Mesh)

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

///
/// meshĶݺ
///
class Mesh2DData
	: AEIO::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(AEIO::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