-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmodel.h
148 lines (130 loc) · 2.88 KB
/
tmodel.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef TMODEL_H
#define TMODEL_H
#include "tmatrix4x4.h"
#include "tvector4d.h"
#include <string>
#include <vector>
typedef struct bezier_curve {
TVector3D p0;
TVector3D p1;
TVector3D p2;
TVector3D p3;
} bezier_curve;
typedef struct hermite_curve {
TVector3D p0;
TVector3D p1;
} hermite_curve;
typedef struct bezier_surface {
struct bezier_curve c0;
struct bezier_curve c1;
struct bezier_curve c2;
struct bezier_curve c3;
TVector4D u;
TVector4D v;
} bezier_surface;
typedef struct hermite_surface {
struct hermite_curve c0;
struct hermite_curve c1;
struct hermite_curve c2;
struct hermite_curve c3;
} hermite_surface;
typedef struct line_segment {
TPoint p0;
TPoint p1;
} line_segment;
typedef struct camera {
// perspectiva
float angleOfView;
float aspectRatio;
// frustrum
float bottom;
float top;
float left;
float right;
float near;
float far;
TVector3D pos;
} camera;
class TModel {
public:
struct face {
int n_faces;
int v1;
int v2;
int v3;
int v4;
};
struct light {
TVector3D pos;
TVector3D color;
};
struct Phong {
struct light light_dir;
float Ka;
float Kd;
float Ks;
int shin;
};
struct lights {
struct light ambient;
struct light diffuse;
struct light gourand;
struct Phong phong;
struct light flatShading;
};
struct input {
bool wireframe;
bool faceHiding;
bool flatShading;
bool zBuffer;
bool atime;
bool curvaDeBezier;
int tiempo;
bool lightAmbient;
bool lightDiffuse;
bool lightSpecular;
bool phong;
bool gourand;
bool bezierCurve;
bool hermiteCurve;
bool bezierSurface;
bool hermiteSurface;
// Rotación
float angleX;
float angleY;
float angleZ;
struct line_segment line;
struct bezier_curve cbezier;
struct hermite_curve chermite;
struct bezier_surface bsurface;
struct hermite_surface hsurface;
struct lights luces;
struct camera cam;
TPoint resolution;
};
TModel();
struct input info;
void rotate(const TVector3D &vector);
void rotate(const TVector3D &vector, TVector3D &vertex);
void scale(const TVector3D &vector);
void translate(const TVector3D &vector);
void setPerspective();
void getInfo(const std::string &name);
void setFrustum(TMatrix4x4 &MProj);
private:
friend class TDraw;
std::string name;
std::vector<TVector4D> list_vertexes;
std::vector<TVector3D> list_textures;
std::vector<TVector3D> list_normals;
std::vector<TVector3D> space_vertexes;
std::vector<struct face> faces_for_vertexes;
std::vector<struct face> faces_for_textures;
std::vector<struct face> faces_for_normals;
void getVertex(std::string &line);
void getFace(std::string &line);
void getNormal(std::string &line);
void readObjFile(const std::string &filename);
void readRawFile(const std::string &filename);
};
#endif // TMODEL_H