-
Notifications
You must be signed in to change notification settings - Fork 0
/
objs.h++
108 lines (80 loc) · 1.8 KB
/
objs.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "shared.h++"
#include <string.h>
#include <vector>
#include <cmath>
#include "file.h++"
#ifdef OBJ_DEBUG
#define _OBJ_DEBUG 1
#else
#define _OBJ_DEBUG 0
#endif
class objs_exception: public std::exception{
public:
explicit objs_exception(const char* message);
virtual ~objs_exception() noexcept;
virtual const char* what() const noexcept;
const char* msg;
};
class objs{
private:
struct f{
const objs* parent;
int *vertindexes;
int *verttexindexes;
int *vertnormindexes;
unsigned int size;
f(objs* p,int vi[],int vti[],int vni[],unsigned int size);
~f();
};
struct v{
const objs* parent;
float x,y,z,w;
v(objs* p,float x,float y,float z,float w);
float *data();
};
struct vt{
const objs* parent;
float u,v,w;
vt(objs* p,float u,float v,float w);
float *data();
};
struct vn{
const objs* parent;
float x,y,z;
vn(objs* p,float x,float y,float z);
float *data();
};
typedef f f;
typedef v v;
typedef vt vt;
typedef vn vn;
std::vector<f*> *faces;
std::vector<v*> *verts;
std::vector<vt*> *verttexs;
std::vector<vn*> *vertnorms;
std::vector<int> *facestartidxs;
void _loadstr(char *source);
public:
struct renderdata{
public:
int numberofshapes;
int *starts; // start index for each shape
int *lengths; // number of points in each shape
float *vs; // packed (stride 10) - vertex 4 floats + uv 3 floats + normal 3 floats
int totalsize;
private:
renderdata(int numberofshapes,int *starts, int *lengths, float *vs);
public:
~renderdata(){
free(vs);
}
int size();
friend objs;
};
objs();
void load(std::filesystem::path path);
void loadstr(const char *path);
void loadasset(const char *path);
renderdata makeRenderData();
~objs();
};