/
AseModel.h
77 lines (58 loc) · 1.92 KB
/
AseModel.h
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
#pragma once
#include <istream>
#include "math/Matrix4.h"
#include "../StaticModelSurface.h"
#include "parser/Tokeniser.h"
namespace model
{
class AseModel
{
private:
struct Material
{
Material();
std::string materialName; // *MATERIAL_NAME
std::string diffuseBitmap; // *BITMAP
float uOffset; // * UVW_U_OFFSET
float vOffset; // * UVW_V_OFFSET
float uTiling; // * UVW_U_TILING
float vTiling; // * UVW_V_TILING
float uvAngle; // * UVW_ANGLE
};
struct Face;
struct Mesh
{
std::vector<Vertex3f> vertices;
std::vector<Normal3f> normals;
std::vector<Face> faces;
std::vector<TexCoord2f> texcoords;
std::vector<Vector3> colours;
};
public:
struct Surface
{
std::string material;
std::vector<ArbitraryMeshVertex> vertices;
std::vector<unsigned int> indices;
};
private:
std::vector<Surface> _surfaces;
std::vector<Material> _materials;
public:
Surface& addSurface(const std::string& name);
Surface& ensureSurface(const std::string& name);
// Read/Write access
std::vector<Surface>& getSurfaces();
// Create a new ASE model from the given stream
// throws parser::ParseException on any failure
static std::shared_ptr<AseModel> CreateFromStream(std::istream& stream);
private:
void parseFromTokens(parser::StringTokeniser& tokeniser);
void parseMaterialList(parser::StringTokeniser& tokeniser);
void parseGeomObject(parser::StringTokeniser& tokeniser);
void parseFaceNormals(Mesh& mesh, parser::StringTokeniser& tokeniser);
void parseMesh(Mesh& mesh, parser::StringTokeniser& tokeniser);
void parseNodeMatrix(Matrix4& matrix, parser::StringTokeniser& tokeniser);
void finishSurface(Mesh& mesh, std::size_t materialIndex, const Matrix4& nodeMatrix);
};
}