-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtdraw.h
77 lines (73 loc) · 3.28 KB
/
tdraw.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
#ifndef TDRAW_H
#define TDRAW_H
#include "timage.h"
#include "tmatrix4x4.h"
#include "tmodel.h"
#include "tshading.h"
#include "tvector4d.h"
#include <utility>
#include <vector>
class TDraw {
public:
TDraw();
void bresenhamLine(const TPoint &p1, const TPoint &p2,
std::vector<unsigned char> &img, const TPoint &resolution);
void bresenhamLine(const TVector4D &p1, const TVector4D &p2,
std::vector<unsigned char> &img, const TPoint &resolution);
void faceHiding(std::vector<unsigned char> &data, const TPoint &resolution,
TModel &model, TPoint &interpolated);
void zBuffer(std::vector<unsigned char> &data,
std::vector<float> &depthBuffer, const TPoint &resolution,
TModel &model, TPoint &interpolated);
void flatShading(std::vector<unsigned char> &data,
std::vector<float> &depthBuffer, const TPoint &resolution,
TModel &model, TPoint &interpolated);
void gourandShading(std::vector<unsigned char> &data,
std::vector<float> &depthBuffer, const TPoint &resolution,
TModel &model, TPoint &interpolated);
void phongShading(std::vector<unsigned char> &data,
std::vector<float> &depthBuffer, const TPoint &resolution,
TModel &model, TPoint &interpolated);
void bezierSurface(TImage &frame, std::vector<float> &depthBuffer,
const TPoint &resolution, TModel &model);
void bezierCurve(TImage &frame, std::vector<float> &depthBuffer,
const TPoint &resolution, TModel &model,
struct bezier_curve *curv);
void ambientLight(std::vector<unsigned char> &data,
std::vector<float> &depthBuffer, const TPoint &resolution,
TModel &model);
void explicitLine(const TPoint &p1, const TPoint &p2, int *img,
const TPoint &resolution);
void wireframe(std::vector<unsigned char> &data, const TPoint &resolution,
TModel &model, TPoint &interpolated);
void interpolateTriangle(std::vector<unsigned char> &data,
const TPoint &resolution, const TModel &model);
private:
int a, r, g, b, x, y;
enum class Octant {
first = 1,
second = 2,
third = 3,
fourth = 4,
fifth = 5,
sixth = 6,
seventh = 7,
eighth = 8
};
bool isInImage(const TPoint &p, const TPoint &resolution) const;
Octant toFirstOctant(TPoint &p1, TPoint &p2);
void fillTriangle(const TVector4D &p1, const TVector4D &p2,
const TVector4D &p3, std::vector<unsigned char> &img,
const TPoint &resolution);
void fillTriangle(const TVector4D &p1, const TVector4D &p2,
const TVector4D &p3, std::vector<unsigned char> &img,
std::vector<float> &depthBuffer, const TPoint &resolution,
const TPoint &interpolated);
void setAmbientLight(const TVector4D &p1, const TVector4D &p2,
const TVector4D &p3, std::vector<unsigned char> &img,
std::vector<float> &depthBuffer,
const TPoint &resolution);
float areaTriangle(const TVector4D &p1, const TVector4D &p2,
const TVector4D &p3);
};
#endif // DRAWLINE_H