Skip to content

Commit

Permalink
feat: add keys for reset and toggle axis
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJPinto committed Mar 6, 2024
1 parent 4b30802 commit ba21255
Show file tree
Hide file tree
Showing 10 changed files with 1,162 additions and 14 deletions.
42 changes: 28 additions & 14 deletions engine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

float cameraAngle = 0.0f;
float cameraAngleY = 0.0f;
int axis = 1;

Configuration c;
std::vector<std::vector<Point>> vectors;
Expand All @@ -35,20 +36,22 @@ void reshape(int w, int h) {
}

void drawAxis(void) {
glBegin(GL_LINES);
// x-axis (red)
glColor3f(50.0f, 0.0f, 0.0f);
glVertex3f(-500.0f, 0.0f, 0.0f);
glVertex3f(500.0f, 0.0f, 0.0f);
// y-axis (green)
glColor3f(0.0f, 50.0f, 0.0f);
glVertex3f(0.0f, -500.0f, 0.0f);
glVertex3f(0.0f, 500.0f, 0.0f);
// z-axis (blue)
glColor3f(0.0f, 0.0f, 50.0f);
glVertex3f(0.0f, 0.0f, -500.0f);
glVertex3f(0.0f, 0.0f, 500.0f);
glEnd();
if (axis) {
glBegin(GL_LINES);
// x-axis (red)
glColor3f(50.0f, 0.0f, 0.0f);
glVertex3f(-500.0f, 0.0f, 0.0f);
glVertex3f(500.0f, 0.0f, 0.0f);
// y-axis (green)
glColor3f(0.0f, 50.0f, 0.0f);
glVertex3f(0.0f, -500.0f, 0.0f);
glVertex3f(0.0f, 500.0f, 0.0f);
// z-axis (blue)
glColor3f(0.0f, 0.0f, 50.0f);
glVertex3f(0.0f, 0.0f, -500.0f);
glVertex3f(0.0f, 0.0f, 500.0f);
glEnd();
}
}

void renderScene(void) {
Expand Down Expand Up @@ -89,6 +92,17 @@ void processSpecialKeys(int key, int xx, int yy) {
case GLUT_KEY_DOWN:
cameraAngleY -= 1.0f;
break;
case GLUT_KEY_F2:
if (axis) {
axis = 0;
} else {
axis = 1;
}
break;
case GLUT_KEY_F1:
cameraAngle = 0;
cameraAngleY = 0;
break;
default:
break;
}
Expand Down
324 changes: 324 additions & 0 deletions models/box_2_3.3d
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
-1 -1 1
-0.333333 -1 1
-1 -0.333333 1
-1 -0.333333 1
-0.333333 -1 1
-0.333333 -0.333333 1
-1 -1 -1
-1 -0.333333 -1
-0.333333 -1 -1
-1 -0.333333 -1
-0.333333 -0.333333 -1
-0.333333 -1 -1
-1 -1 -1
-1 -1 -0.333333
-1 -0.333333 -1
-1 -1 -0.333333
-1 -0.333333 -0.333333
-1 -0.333333 -1
1 -1 -1
1 -0.333333 -1
1 -1 -0.333333
1 -1 -0.333333
1 -0.333333 -1
1 -0.333333 -0.333333
-1 1 -1
-1 1 -0.333333
-0.333333 1 -1
-1 1 -0.333333
-0.333333 1 -0.333333
-0.333333 1 -1
-1 -1 -1
-0.333333 -1 -1
-1 -1 -0.333333
-1 -1 -0.333333
-0.333333 -1 -1
-0.333333 -1 -0.333333
-1 -0.333333 1
-0.333333 -0.333333 1
-1 0.333333 1
-1 0.333333 1
-0.333333 -0.333333 1
-0.333333 0.333333 1
-1 -0.333333 -1
-1 0.333333 -1
-0.333333 -0.333333 -1
-1 0.333333 -1
-0.333333 0.333333 -1
-0.333333 -0.333333 -1
-1 -1 -0.333333
-1 -1 0.333333
-1 -0.333333 -0.333333
-1 -1 0.333333
-1 -0.333333 0.333333
-1 -0.333333 -0.333333
1 -1 -0.333333
1 -0.333333 -0.333333
1 -1 0.333333
1 -1 0.333333
1 -0.333333 -0.333333
1 -0.333333 0.333333
-1 1 -0.333333
-1 1 0.333333
-0.333333 1 -0.333333
-1 1 0.333333
-0.333333 1 0.333333
-0.333333 1 -0.333333
-1 -1 -0.333333
-0.333333 -1 -0.333333
-1 -1 0.333333
-1 -1 0.333333
-0.333333 -1 -0.333333
-0.333333 -1 0.333333
-1 0.333333 1
-0.333333 0.333333 1
-1 1 1
-1 1 1
-0.333333 0.333333 1
-0.333333 1 1
-1 0.333333 -1
-1 1 -1
-0.333333 0.333333 -1
-1 1 -1
-0.333333 1 -1
-0.333333 0.333333 -1
-1 -1 0.333333
-1 -1 1
-1 -0.333333 0.333333
-1 -1 1
-1 -0.333333 1
-1 -0.333333 0.333333
1 -1 0.333333
1 -0.333333 0.333333
1 -1 1
1 -1 1
1 -0.333333 0.333333
1 -0.333333 1
-1 1 0.333333
-1 1 1
-0.333333 1 0.333333
-1 1 1
-0.333333 1 1
-0.333333 1 0.333333
-1 -1 0.333333
-0.333333 -1 0.333333
-1 -1 1
-1 -1 1
-0.333333 -1 0.333333
-0.333333 -1 1
-0.333333 -1 1
0.333333 -1 1
-0.333333 -0.333333 1
-0.333333 -0.333333 1
0.333333 -1 1
0.333333 -0.333333 1
-0.333333 -1 -1
-0.333333 -0.333333 -1
0.333333 -1 -1
-0.333333 -0.333333 -1
0.333333 -0.333333 -1
0.333333 -1 -1
-1 -0.333333 -1
-1 -0.333333 -0.333333
-1 0.333333 -1
-1 -0.333333 -0.333333
-1 0.333333 -0.333333
-1 0.333333 -1
1 -0.333333 -1
1 0.333333 -1
1 -0.333333 -0.333333
1 -0.333333 -0.333333
1 0.333333 -1
1 0.333333 -0.333333
-0.333333 1 -1
-0.333333 1 -0.333333
0.333333 1 -1
-0.333333 1 -0.333333
0.333333 1 -0.333333
0.333333 1 -1
-0.333333 -1 -1
0.333333 -1 -1
-0.333333 -1 -0.333333
-0.333333 -1 -0.333333
0.333333 -1 -1
0.333333 -1 -0.333333
-0.333333 -0.333333 1
0.333333 -0.333333 1
-0.333333 0.333333 1
-0.333333 0.333333 1
0.333333 -0.333333 1
0.333333 0.333333 1
-0.333333 -0.333333 -1
-0.333333 0.333333 -1
0.333333 -0.333333 -1
-0.333333 0.333333 -1
0.333333 0.333333 -1
0.333333 -0.333333 -1
-1 -0.333333 -0.333333
-1 -0.333333 0.333333
-1 0.333333 -0.333333
-1 -0.333333 0.333333
-1 0.333333 0.333333
-1 0.333333 -0.333333
1 -0.333333 -0.333333
1 0.333333 -0.333333
1 -0.333333 0.333333
1 -0.333333 0.333333
1 0.333333 -0.333333
1 0.333333 0.333333
-0.333333 1 -0.333333
-0.333333 1 0.333333
0.333333 1 -0.333333
-0.333333 1 0.333333
0.333333 1 0.333333
0.333333 1 -0.333333
-0.333333 -1 -0.333333
0.333333 -1 -0.333333
-0.333333 -1 0.333333
-0.333333 -1 0.333333
0.333333 -1 -0.333333
0.333333 -1 0.333333
-0.333333 0.333333 1
0.333333 0.333333 1
-0.333333 1 1
-0.333333 1 1
0.333333 0.333333 1
0.333333 1 1
-0.333333 0.333333 -1
-0.333333 1 -1
0.333333 0.333333 -1
-0.333333 1 -1
0.333333 1 -1
0.333333 0.333333 -1
-1 -0.333333 0.333333
-1 -0.333333 1
-1 0.333333 0.333333
-1 -0.333333 1
-1 0.333333 1
-1 0.333333 0.333333
1 -0.333333 0.333333
1 0.333333 0.333333
1 -0.333333 1
1 -0.333333 1
1 0.333333 0.333333
1 0.333333 1
-0.333333 1 0.333333
-0.333333 1 1
0.333333 1 0.333333
-0.333333 1 1
0.333333 1 1
0.333333 1 0.333333
-0.333333 -1 0.333333
0.333333 -1 0.333333
-0.333333 -1 1
-0.333333 -1 1
0.333333 -1 0.333333
0.333333 -1 1
0.333333 -1 1
1 -1 1
0.333333 -0.333333 1
0.333333 -0.333333 1
1 -1 1
1 -0.333333 1
0.333333 -1 -1
0.333333 -0.333333 -1
1 -1 -1
0.333333 -0.333333 -1
1 -0.333333 -1
1 -1 -1
-1 0.333333 -1
-1 0.333333 -0.333333
-1 1 -1
-1 0.333333 -0.333333
-1 1 -0.333333
-1 1 -1
1 0.333333 -1
1 1 -1
1 0.333333 -0.333333
1 0.333333 -0.333333
1 1 -1
1 1 -0.333333
0.333333 1 -1
0.333333 1 -0.333333
1 1 -1
0.333333 1 -0.333333
1 1 -0.333333
1 1 -1
0.333333 -1 -1
1 -1 -1
0.333333 -1 -0.333333
0.333333 -1 -0.333333
1 -1 -1
1 -1 -0.333333
0.333333 -0.333333 1
1 -0.333333 1
0.333333 0.333333 1
0.333333 0.333333 1
1 -0.333333 1
1 0.333333 1
0.333333 -0.333333 -1
0.333333 0.333333 -1
1 -0.333333 -1
0.333333 0.333333 -1
1 0.333333 -1
1 -0.333333 -1
-1 0.333333 -0.333333
-1 0.333333 0.333333
-1 1 -0.333333
-1 0.333333 0.333333
-1 1 0.333333
-1 1 -0.333333
1 0.333333 -0.333333
1 1 -0.333333
1 0.333333 0.333333
1 0.333333 0.333333
1 1 -0.333333
1 1 0.333333
0.333333 1 -0.333333
0.333333 1 0.333333
1 1 -0.333333
0.333333 1 0.333333
1 1 0.333333
1 1 -0.333333
0.333333 -1 -0.333333
1 -1 -0.333333
0.333333 -1 0.333333
0.333333 -1 0.333333
1 -1 -0.333333
1 -1 0.333333
0.333333 0.333333 1
1 0.333333 1
0.333333 1 1
0.333333 1 1
1 0.333333 1
1 1 1
0.333333 0.333333 -1
0.333333 1 -1
1 0.333333 -1
0.333333 1 -1
1 1 -1
1 0.333333 -1
-1 0.333333 0.333333
-1 0.333333 1
-1 1 0.333333
-1 0.333333 1
-1 1 1
-1 1 0.333333
1 0.333333 0.333333
1 1 0.333333
1 0.333333 1
1 0.333333 1
1 1 0.333333
1 1 1
0.333333 1 0.333333
0.333333 1 1
1 1 0.333333
0.333333 1 1
1 1 1
1 1 0.333333
0.333333 -1 0.333333
1 -1 0.333333
0.333333 -1 1
0.333333 -1 1
1 -1 0.333333
1 -1 1
Loading

0 comments on commit ba21255

Please sign in to comment.