Implement line meshes
This commit is contained in:
parent
109c94a865
commit
1f4565c0a5
3 changed files with 47 additions and 7 deletions
|
@ -28,6 +28,7 @@ void model_colorBlue(Model *);
|
|||
void model_colorWhite(Model *);
|
||||
void model_colorBlack(Model *);
|
||||
Model *model_circle(int, GLfloat);
|
||||
Model *model_line(GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
9
src/cx.c
9
src/cx.c
|
@ -124,16 +124,17 @@ cx_glinit(GLFWwindow **window) {
|
|||
|
||||
int
|
||||
cx_glrun(GLFWwindow *window) {
|
||||
ModelRegistry *mr;
|
||||
Model *neural_network_model;
|
||||
GLuint VertexArrayID;
|
||||
GLuint programID;
|
||||
if (cx_loadShaders(&VertexArrayID, &programID)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Establish a model registry
|
||||
ModelRegistry *mr;
|
||||
mr = modelRegistry_new();
|
||||
|
||||
// Establish a model registry
|
||||
mr = modelRegistry_new();
|
||||
// Fill the model registry with mesh models
|
||||
for (int j = 0; j < 8; j++) {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
|
@ -147,7 +148,7 @@ cx_glrun(GLFWwindow *window) {
|
|||
translation_matrix[3] = (((GLfloat)-1*16/9)*.90)
|
||||
+ ((GLfloat)1/32 * i * (((GLfloat)16/9))*.90);
|
||||
|
||||
translation_matrix[7] = .90 + ((GLfloat)1/8 * j *.90);
|
||||
translation_matrix[7] = .90 - ((GLfloat)1/4 * j *.90);
|
||||
|
||||
model->transformations[0] = translation_matrix;
|
||||
model->transformations[1] = aspectRatio_matrix;
|
||||
|
|
44
src/model.c
44
src/model.c
|
@ -179,11 +179,49 @@ model_circle(int detail, GLfloat scale) {
|
|||
}
|
||||
|
||||
Model *
|
||||
model_line(Model *self, int detail) {
|
||||
model_line(float x1, float y1, float x2, float y2, float girth) {
|
||||
Model *self;
|
||||
float x_diff, y_diff, line_length;
|
||||
|
||||
x_diff = x2 - x1;
|
||||
y_diff = y2 - y1;
|
||||
line_length = sqrt((x_diff*x_diff) + (y_diff*y_diff));
|
||||
|
||||
printf("%f, ", girth);
|
||||
printf("%f,\n", -girth);
|
||||
float normal_x = (cos(M_PI/4) * x_diff
|
||||
+sin(M_PI/4) * y_diff)
|
||||
/ line_length * girth / 2;
|
||||
|
||||
float normal_y = (-sin(M_PI/4) * x_diff
|
||||
+cos(M_PI/4) * y_diff)
|
||||
/ line_length * girth / 2;
|
||||
|
||||
|
||||
self = model_new(6);
|
||||
|
||||
if (self == NULL) {
|
||||
self = model_new(6);
|
||||
return NULL;
|
||||
}
|
||||
return 0;
|
||||
|
||||
self->object[0] = x1 + normal_x;
|
||||
self->object[1] = y1 + normal_y;
|
||||
|
||||
self->object[4] = x1 - normal_x;
|
||||
self->object[5] = y1 - normal_y;
|
||||
|
||||
self->object[8] = x2 + normal_x;
|
||||
self->object[9] = y2 + normal_y;
|
||||
|
||||
self->object[12] = x1 - normal_x;
|
||||
self->object[13] = y1 - normal_y;
|
||||
|
||||
self->object[16] = x2 + normal_x;
|
||||
self->object[17] = y2 + normal_y;
|
||||
|
||||
self->object[20] = x2 - normal_x;
|
||||
self->object[21] = y2 - normal_y;
|
||||
return self;
|
||||
}
|
||||
|
||||
Model *
|
||||
|
|
Loading…
Reference in a new issue