-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.h
More file actions
66 lines (53 loc) · 1.38 KB
/
Model.h
File metadata and controls
66 lines (53 loc) · 1.38 KB
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
#ifndef ANDROIDGLINVESTIGATIONS_MODEL_H*
#define ANDROIDGLINVESTIGATIONS_MODEL_H
#include <vector>
#include "TextureAsset.h"
union Vector3 {
struct {
float x, y, z;
};
float idx[3];
};
union Vector2 {
struct {
float x, y;
};
struct {
float u, v;
};
float idx[2];
};
struct Vertex {
constexpr Vertex(const Vector3 &inPosition, const Vector2 &inUV) : position(inPosition),
uv(inUV) {}
Vector3 position;
Vector2 uv;
};
typedef uint16_t Index;
class Model {
public:
inline Model(
std::vector<Vertex> vertices,
std::vector<Index> indices,
std::shared_ptr<TextureAsset> spTexture)
: vertices_(std::move(vertices)),
indices_(std::move(indices)),
spTexture_(std::move(spTexture)) {}
inline const Vertex *getVertexData() const {
return vertices_.data();
}
inline const size_t getIndexCount() const {
return indices_.size();
}
inline const Index *getIndexData() const {
return indices_.data();
}
inline const TextureAsset &getTexture() const {
return *spTexture_;
}
private:
std::vector<Vertex> vertices_;
std::vector<Index> indices_;
std::shared_ptr<TextureAsset> spTexture_;
};
#endif //ANDROIDGLINVESTIGATIONS_MODEL_H