-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLS_Circle.cpp
More file actions
143 lines (109 loc) · 2.98 KB
/
LS_Circle.cpp
File metadata and controls
143 lines (109 loc) · 2.98 KB
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
#include "LS_Circle.h"
#include <cmath>
#include "LS_VAO_Setup.h"
const double PI = 3.14152695;
GLuint CLS_Circle::circleTemplateVAO = 0;
void CLS_Circle::initCirc()
{
//Create the Points for the vetexes around the entire circle and store them in an array
GLfloat circleTemplateVBO[(36*2)];
for (int i=0; i<(36*2); i+=2) {
circleTemplateVBO[i] = float(cos(float(i*10*float(PI/180))));
circleTemplateVBO[i+1] = float(sin(float(i*10*float(PI/180))));
}
//For the Default colours
GLuint ColourTemplateVBO[36*3]; //Declare the temp array for the Circle
for (int i=0; i<(36*3); i+=3) {
ColourTemplateVBO[i] = 20;
ColourTemplateVBO[i+1] = 20;
ColourTemplateVBO[i+2] = 20;
}
//Point order of all the vertexes
GLuint PointOrder[36];
for (int i=0; i<(36); i+=1) {
PointOrder[i] = i;
}
//Using the Templated Class for creating a VAO create the VAO
GLfloat textureTemplateVBO[(36*2)];
for (int i=0; i<(36*2); i+=2) {
textureTemplateVBO[i] = circleTemplateVBO[i];
textureTemplateVBO[i+1] = circleTemplateVBO[i+1];
}
circleTemplateVAO = CLS_VAO_Setup::setupVAO(circleTemplateVBO,
ColourTemplateVBO,
textureTemplateVBO,
PointOrder);
}
CLS_Circle::CLS_Circle(void)
{
this->setType(CIRCLE);
this->setModelVAO(this->circleTemplateVAO);
this->setScale(20.0f);
this->setBounceFactor(0.1);
}
void CLS_Circle::setScale(float newScale)
{
CLS_Shapes::setScale(newScale);
//Width of the circle is -1.0f to 1.0f which is 2.0f. Wdht and height is the same
this->setCollisionBox(glm::vec3(2.0f * this->getScale(), 2.0f * this->getScale(), 2.0f * this->getScale()));
}
CLS_Circle::~CLS_Circle(void)
{
}
/*
void CLS_Circle::draw()
{
glBindVertexArray(this->getModelVAO());
glDrawElements(GL_TRIANGLE_FAN, this->getType(), GL_UNSIGNED_INT, (GLvoid*)0);
glBindVertexArray(0);
}*/
//void CLS_Circle::setColour(int r, int g, int b)
//{
// //Create the Points for the vetexes around the entire circle and store them in an array
// GLfloat circleTemplateVBO[(36*2)];
//
// for (int i=0; i<(36*2); i+=2) {
//
// circleTemplateVBO[i] = float(cos(float(i*10*float(PI/180))));
// circleTemplateVBO[i+1] = float(sin(float(i*10*float(PI/180))));
//
// }
//
// //For the Default colours
// GLuint ColourTemplateVBO[36*3]; //Declare the temp array for the Circle
//
// for (int i=0; i<(36*3); i+=3) {
//
// ColourTemplateVBO[i] = r;
// ColourTemplateVBO[i+1] = g;
// ColourTemplateVBO[i+2] = b;
// }
//
// //Point order of all the vertexes
//
// GLuint PointOrder[36];
//
// for (int i=0; i<(36); i+=1) {
//
// PointOrder[i] = i;
// }
//
//
// //Using the Templated Class for creating a VAO create the VAO
//
//
// GLfloat textureTemplateVBO[(36*2)];
//
// for (int i=0; i<(36*2); i+=2) {
//
// textureTemplateVBO[i] = circleTemplateVBO[i];
// textureTemplateVBO[i+1] = circleTemplateVBO[i+1];
//
// }
//
// this->setModelVAO(CLS_VAO_Setup::setupVAO(circleTemplateVBO,
// ColourTemplateVBO,
// textureTemplateVBO,
// PointOrder));
//
//}