-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolygon3d.h
94 lines (79 loc) · 2.96 KB
/
polygon3d.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
#ifndef glop102_polygon3d
#define glop102_polygon3d
#include <stdio.h>
#include <vector>
#include <GL/glut.h>
#include "vector_basics.h"
//===================================================================
// POLYGON CLASS
//===================================================================
// This does all the basics that a drawn polygon should care about
// NOTE!!!
// When specifying points, the first and last point must be the same
// We are wanting to make sure that when you draw lines the polygon is closed
// MAKE SURE THE FIRST AND LAST POINT ARE THE SAME
//===================================================================
// This draws polygons using the draw function in a realative manner
// so if GL has the matrix moved for the world before calling the draw
// function, then polygon will be drawn relative to the moved location
//===================================================================
class Polygon3d{
protected: // we let our children get to this but not the world
Point center;
Vector rotation;
double scale;
Vector velocity;
Vector rotationSpeed;
std::vector<Point> vertexList;
bool drawTesselate;
GLubyte color[4]; //RGBA - 1 byte a piece
double maxRadius; // special little optimization for collision checking
GLuint texture;
bool hasTex;
std::vector<Point> vertexTextureList;
Vector normal;
public:
Polygon3d();
Polygon3d(double,double,double); // specifies the center
Polygon3d(std::vector<Point>&);
Polygon3d(Point pnt, std::vector<Point>& points);
Polygon3d(Triangle &);
Polygon3d(const Polygon3d&);
void setRotation(Vector&);
Vector getRotation();
void setScale(double);
double getScale();
void setCenter(Point);
Point getCenter();
void setColor(GLubyte red,GLubyte green, GLubyte blue);
void setColor(GLubyte red,GLubyte green, GLubyte blue, GLubyte alpha);
GLubyte getColor(int channel);
void setTesselation(bool tes);
bool getTesselation();
void setVelocity(double x, double y, double z);
void setVelocity(Vector& x);
Vector getVelocity();
void setRotationSpeed(Vector&);
Vector getRotationSpeed();
double getMaxRadius();
Vector getNormal();
void setTexture(GLuint tex);
GLuint getTexture();
std::vector<Point>& getTexturePoints();
Point& getTexturePos(int index);
bool hasTexture();
void removeTexture();
int numPoints()const;
std::vector<Point>& getPoints(); // get the list of points for you to affect the shape with
Point& operator[](int); // get point number x back
Polygon3d& operator=(Polygon3d);
Polygon3d getTransform(); // get the transform of the points of the polygon to where they should be
void recenter(); // moves the center of the polygon to be at the centroid of the shape but does not change its position
Polygon3d getWorldPoints();
void draw();
void drawLines(); // draw the border of the polygon an do not fill it in
void draw_static(); // does not rotate or translate the world before drawing
static void __secretVertexDrawingFunction(void *data, void *polygon);
void update();
};
#endif