-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriangle.hpp
executable file
·36 lines (29 loc) · 1.07 KB
/
Triangle.hpp
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
//
// Created by LEI XU on 4/11/19.
//
#ifndef RASTERIZER_TRIANGLE_H
#define RASTERIZER_TRIANGLE_H
#include <eigen3/Eigen/Eigen>
using namespace Eigen;
class Triangle
{
public:
Vector3f v[3]; /*the original coordinates of the triangle, v0, v1, v2 in
counter clockwise order*/
/*Per vertex values*/
Vector3f color[3]; // color at each vertex;
Vector2f tex_coords[3]; // texture u,v
Vector3f normal[3]; // normal vector for each vertex
// Texture *tex;
Triangle();
Eigen::Vector3f a() const { return v[0]; }
Eigen::Vector3f b() const { return v[1]; }
Eigen::Vector3f c() const { return v[2]; }
void setVertex(int ind, Vector3f ver); /*set i-th vertex coordinates */
void setNormal(int ind, Vector3f n); /*set i-th vertex normal vector*/
void setColor(int ind, float r, float g, float b); /*set i-th vertex color*/
void setTexCoord(int ind, float s,
float t); /*set i-th vertex texture coordinate*/
std::array<Vector4f, 3> toVector4() const;
};
#endif // RASTERIZER_TRIANGLE_H