feat(renderer): added mesh-based outline

This commit is contained in:
maelstrom 2025-04-14 23:32:02 +02:00
parent 166c5c5ff8
commit d4a582f0a8
5 changed files with 478 additions and 48 deletions

View file

@ -1,11 +1,24 @@
#version 330 core #version 330 core
out vec4 FragColor; uniform vec3 scale;
uniform vec3 color; in vec3 vPos;
// Main out vec4 fColor;
void main() { void main() {
FragColor = vec4(color, 1); // float thickness = 0.2;
// vec3 distanceFromEdge = abs(scale * vPos) - scale / 2;
// vec3 vec = distanceFromEdge + vec3(thickness / 2);
// vec3 signs = max(sign(vec), 0);
// float negatives = signs.x + signs.y + signs.z;
// if (negatives >= 2)
// fColor = vec4(0.204, 0.584, 0.922, 1);
// else
// fColor = vec4(0);
fColor = vec4(0.204, 0.584, 0.922, 1);
} }

View file

@ -1,9 +1,9 @@
#version 330 core #version 330 core
layout (location = 0) in vec3 aPos; layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal; layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec3 vPos; out vec3 vPos;
out vec3 vNormal;
uniform mat4 model; uniform mat4 model;
uniform mat4 view; uniform mat4 view;
@ -12,4 +12,5 @@ uniform mat4 projection;
void main() void main()
{ {
gl_Position = projection * view * model * vec4(aPos, 1.0); gl_Position = projection * view * model * vec4(aPos, 1.0);
vPos = aPos;
} }

View file

@ -1151,14 +1151,454 @@ static float ARROW_VERTICES[] = {
}; };
static float OUTLINE_VERTICES[] = {
// positions // normals // texture coords
-0.5, 0.5, -0.25, -1.0, -0.0, -0.0, 0.625, 0.1875,
-0.5, 0.25, -0.5, -1.0, -0.0, -0.0, 0.5625, 0.25,
-0.5, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.1875,
0.25, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.4375,
0.5, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.5,
0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.4375,
0.5, 0.5, 0.25, 1.0, -0.0, -0.0, 0.625, 0.6875,
0.5, 0.25, 0.5, 1.0, -0.0, -0.0, 0.5625, 0.75,
0.5, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.6875,
-0.25, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.9375,
-0.5, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 1.0,
-0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.9375,
0.5, -0.5, 0.25, -0.0, -1.0, -0.0, 0.375, 0.6875,
0.25, -0.5, 0.5, -0.0, -1.0, -0.0, 0.3125, 0.75,
0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.3125, 0.6875,
-0.5, 0.5, 0.25, -0.0, 1.0, -0.0, 0.875, 0.6875,
-0.25, 0.5, 0.5, -0.0, 1.0, -0.0, 0.8125, 0.75,
-0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.8125, 0.6875,
-0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.8125, 0.6875,
0.25, 0.5, 0.5, -0.0, 1.0, -0.0, 0.6875, 0.75,
0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.6875, 0.6875,
-0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.1875, 0.6875,
-0.5, -0.5, 0.5, -0.0, -1.0, -0.0, 0.125, 0.75,
-0.5, -0.5, 0.25, -0.0, -1.0, -0.0, 0.125, 0.6875,
0.25, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.8125,
-0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.9375,
0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.8125,
-0.5, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.25,
-0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.3125,
-0.5, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.25,
0.5, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.75,
0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.8125,
0.5, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.75,
0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.6875, 0.6875,
0.5, 0.5, 0.5, -0.0, 1.0, -0.0, 0.625, 0.75,
0.5, 0.5, 0.25, -0.0, 1.0, -0.0, 0.625, 0.6875,
0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.3125, 0.6875,
-0.25, -0.5, 0.5, -0.0, -1.0, -0.0, 0.1875, 0.75,
-0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.1875, 0.6875,
-0.25, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.3125,
0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.4375,
-0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.3125,
0.25, -0.5, -0.5, -0.0, -1.0, -0.0, 0.3125, 0.5,
-0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.1875, 0.5625,
-0.25, -0.5, -0.5, -0.0, -1.0, -0.0, 0.1875, 0.5,
0.25, 0.5, -0.5, -0.0, 1.0, -0.0, 0.6875, 0.5,
0.5, 0.5, -0.25, -0.0, 1.0, -0.0, 0.625, 0.5625,
0.5, 0.5, -0.5, -0.0, 1.0, -0.0, 0.625, 0.5,
-0.25, -0.5, -0.5, -0.0, -1.0, -0.0, 0.1875, 0.5,
-0.5, -0.5, -0.25, -0.0, -1.0, -0.0, 0.125, 0.5625,
-0.5, -0.5, -0.5, -0.0, -1.0, -0.0, 0.125, 0.5,
-0.25, 0.5, -0.5, -0.0, 1.0, -0.0, 0.8125, 0.5,
0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.6875, 0.5625,
0.25, 0.5, -0.5, -0.0, 1.0, -0.0, 0.6875, 0.5,
-0.5, 0.5, -0.5, -0.0, 1.0, -0.0, 0.875, 0.5,
-0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.8125, 0.5625,
-0.25, 0.5, -0.5, -0.0, 1.0, -0.0, 0.8125, 0.5,
0.5, -0.5, -0.5, -0.0, -1.0, -0.0, 0.375, 0.5,
0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.3125, 0.5625,
0.25, -0.5, -0.5, -0.0, -1.0, -0.0, 0.3125, 0.5,
0.5, 0.5, -0.5, 1.0, -0.0, -0.0, 0.625, 0.5,
0.5, 0.25, -0.25, 1.0, -0.0, -0.0, 0.5625, 0.5625,
0.5, 0.25, -0.5, 1.0, -0.0, -0.0, 0.5625, 0.5,
-0.5, 0.5, 0.25, -1.0, -0.0, -0.0, 0.625, 0.0625,
-0.5, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.1875,
-0.5, 0.25, 0.25, -1.0, -0.0, -0.0, 0.5625, 0.0625,
-0.5, 0.5, 0.5, -1.0, -0.0, -0.0, 0.625, 0.0,
-0.5, 0.25, 0.25, -1.0, -0.0, -0.0, 0.5625, 0.0625,
-0.5, 0.25, 0.5, -1.0, -0.0, -0.0, 0.5625, 0.0,
-0.25, -0.5, 0.25, -0.0, -0.0, -1.0, 0.1875, 0.6875,
0.25, -0.25, 0.25, -0.0, -0.0, -1.0, 0.3125, 0.6875,
0.25, -0.5, 0.25, -0.0, -0.0, -1.0, 0.3125, 0.6875,
0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.6875, 0.5625,
0.5, 0.5, 0.25, -0.0, 1.0, -0.0, 0.625, 0.6875,
0.5, 0.5, -0.25, -0.0, 1.0, -0.0, 0.625, 0.5625,
-0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.1875, 0.5625,
-0.5, -0.5, 0.25, -0.0, -1.0, -0.0, 0.125, 0.6875,
-0.5, -0.5, -0.25, -0.0, -1.0, -0.0, 0.125, 0.5625,
-0.25, 0.5, 0.25, 1.0, -0.0, -0.0, 0.8125, 0.6875,
-0.25, 0.25, -0.25, 1.0, -0.0, -0.0, 0.8125, 0.5625,
-0.25, 0.5, -0.25, 1.0, -0.0, -0.0, 0.8125, 0.5625,
-0.5, 0.5, -0.25, -0.0, 1.0, -0.0, 0.875, 0.5625,
-0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.8125, 0.6875,
-0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.8125, 0.5625,
0.5, -0.5, -0.25, -0.0, -1.0, -0.0, 0.375, 0.5625,
0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.3125, 0.6875,
0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.3125, 0.5625,
0.5, 0.5, -0.25, 1.0, -0.0, -0.0, 0.625, 0.5625,
0.5, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.6875,
0.5, 0.25, -0.25, 1.0, -0.0, -0.0, 0.5625, 0.5625,
0.5, 0.25, -0.25, -0.0, -0.0, 1.0, 0.5625, 0.5625,
0.25, -0.25, -0.25, -0.0, -0.0, 1.0, 0.4375, 0.5625,
0.5, -0.25, -0.25, -0.0, -0.0, 1.0, 0.4375, 0.5625,
-0.5, 0.25, 0.5, -1.0, -0.0, -0.0, 0.5625, 0.0,
-0.5, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.0625,
-0.5, -0.25, 0.5, -1.0, -0.0, -0.0, 0.4375, 0.0,
-0.5, 0.25, 0.25, -0.0, -0.0, -1.0, 0.5625, 0.0625,
-0.25, -0.25, 0.25, -0.0, -0.0, -1.0, 0.4375, 0.0625,
-0.5, -0.25, 0.25, -0.0, -0.0, -1.0, 0.4375, 0.0625,
0.5, 0.25, -0.5, 1.0, -0.0, -0.0, 0.5625, 0.5,
0.5, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.5625,
0.5, -0.25, -0.5, 1.0, -0.0, -0.0, 0.4375, 0.5,
0.25, -0.25, -0.5, -1.0, -0.0, -0.0, 0.4375, 0.4375,
0.25, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.4375,
0.25, 0.25, -0.5, -1.0, -0.0, -0.0, 0.5625, 0.4375,
0.5, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.75,
0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.8125,
0.5, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.75,
-0.5, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.25,
-0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.3125,
-0.5, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.25,
0.25, 0.25, 0.5, -1.0, -0.0, -0.0, 0.5625, 0.8125,
0.25, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.8125,
0.25, -0.25, 0.5, -1.0, -0.0, -0.0, 0.4375, 0.8125,
-0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.9375,
-0.5, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 1.0,
-0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.9375,
0.5, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.6875,
0.5, -0.25, 0.5, 1.0, -0.0, -0.0, 0.4375, 0.75,
0.5, -0.25, 0.25, 1.0, -0.0, -0.0, 0.4375, 0.6875,
0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.4375,
0.5, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.5,
0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.4375,
-0.5, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.1875,
-0.5, -0.25, -0.5, -1.0, -0.0, -0.0, 0.4375, 0.25,
-0.5, -0.25, -0.25, -1.0, -0.0, -0.0, 0.4375, 0.1875,
-0.5, -0.25, -0.25, -1.0, -0.0, -0.0, 0.4375, 0.1875,
-0.5, -0.5, -0.5, -1.0, -0.0, -0.0, 0.375, 0.25,
-0.5, -0.5, -0.25, -1.0, -0.0, -0.0, 0.375, 0.1875,
0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.4375,
0.5, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.5,
0.25, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.4375,
0.5, -0.25, 0.25, 1.0, -0.0, -0.0, 0.4375, 0.6875,
0.5, -0.5, 0.5, 1.0, -0.0, -0.0, 0.375, 0.75,
0.5, -0.5, 0.25, 1.0, -0.0, -0.0, 0.375, 0.6875,
-0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.9375,
-0.5, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 1.0,
-0.25, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.9375,
0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.8125,
-0.25, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.9375,
0.25, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.8125,
-0.5, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.25,
-0.25, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.3125,
-0.5, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.25,
0.5, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.75,
0.25, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.8125,
0.5, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.75,
-0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.3125,
0.25, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.4375,
-0.25, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.3125,
0.5, -0.25, -0.5, 1.0, -0.0, -0.0, 0.4375, 0.5,
0.5, -0.5, -0.25, 1.0, -0.0, -0.0, 0.375, 0.5625,
0.5, -0.5, -0.5, 1.0, -0.0, -0.0, 0.375, 0.5,
-0.5, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.0625,
-0.5, -0.5, -0.25, -1.0, -0.0, -0.0, 0.375, 0.1875,
-0.5, -0.5, 0.25, -1.0, -0.0, -0.0, 0.375, 0.0625,
-0.5, -0.25, 0.5, -1.0, -0.0, -0.0, 0.4375, 0.0,
-0.5, -0.5, 0.25, -1.0, -0.0, -0.0, 0.375, 0.0625,
-0.5, -0.5, 0.5, -1.0, -0.0, -0.0, 0.375, 0.0,
0.5, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.5625,
0.5, -0.5, 0.25, 1.0, -0.0, -0.0, 0.375, 0.6875,
0.5, -0.5, -0.25, 1.0, -0.0, -0.0, 0.375, 0.5625,
0.25, -0.25, 0.5, -0.0, 1.0, -0.0, 0.4375, 0.8125,
-0.25, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.9375,
-0.25, -0.25, 0.5, -0.0, 1.0, -0.0, 0.4375, 0.9375,
-0.25, -0.25, 0.5, 1.0, -0.0, -0.0, 0.4375, 0.9375,
-0.25, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.9375,
-0.25, 0.25, 0.5, 1.0, -0.0, -0.0, 0.5625, 0.9375,
-0.25, 0.25, 0.5, -0.0, -1.0, -0.0, 0.5625, 0.9375,
0.25, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.8125,
0.25, 0.25, 0.5, -0.0, -1.0, -0.0, 0.5625, 0.8125,
0.5, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.5625,
0.25, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.6875,
0.5, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.6875,
0.5, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.6875,
0.25, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.5625,
0.5, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.5625,
0.5, -0.25, 0.25, -0.0, -0.0, -1.0, 0.4375, 0.6875,
0.25, 0.25, 0.25, -0.0, -0.0, -1.0, 0.5625, 0.6875,
0.5, 0.25, 0.25, -0.0, -0.0, -1.0, 0.5625, 0.6875,
-0.25, 0.25, -0.5, 1.0, -0.0, -0.0, 0.5625, 0.3125,
-0.25, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.3125,
-0.25, -0.25, -0.5, 1.0, -0.0, -0.0, 0.4375, 0.3125,
0.25, 0.25, -0.5, -0.0, -1.0, -0.0, 0.5625, 0.4375,
-0.25, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.3125,
-0.25, 0.25, -0.5, -0.0, -1.0, -0.0, 0.5625, 0.3125,
-0.25, -0.25, -0.5, -0.0, 1.0, -0.0, 0.4375, 0.3125,
0.25, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.4375,
0.25, -0.25, -0.5, -0.0, 1.0, -0.0, 0.4375, 0.4375,
0.25, 0.5, 0.25, -0.0, -0.0, -1.0, 0.6875, 0.6875,
-0.25, 0.25, 0.25, -0.0, -0.0, -1.0, 0.8125, 0.6875,
-0.25, 0.5, 0.25, -0.0, -0.0, -1.0, 0.8125, 0.6875,
-0.25, 0.5, -0.25, -0.0, -0.0, 1.0, 0.8125, 0.5625,
0.25, 0.25, -0.25, -0.0, -0.0, 1.0, 0.6875, 0.5625,
0.25, 0.5, -0.25, -0.0, -0.0, 1.0, 0.6875, 0.5625,
0.25, 0.5, -0.25, -1.0, -0.0, -0.0, 0.6875, 0.5625,
0.25, 0.25, 0.25, -1.0, -0.0, -0.0, 0.6875, 0.6875,
0.25, 0.5, 0.25, -1.0, -0.0, -0.0, 0.6875, 0.6875,
0.25, -0.5, 0.25, -1.0, -0.0, -0.0, 0.3125, 0.6875,
0.25, -0.25, -0.25, -1.0, -0.0, -0.0, 0.3125, 0.5625,
0.25, -0.5, -0.25, -1.0, -0.0, -0.0, 0.3125, 0.5625,
0.25, -0.5, -0.25, -0.0, -0.0, 1.0, 0.3125, 0.5625,
-0.25, -0.25, -0.25, -0.0, -0.0, 1.0, 0.1875, 0.5625,
-0.25, -0.5, -0.25, -0.0, -0.0, 1.0, 0.1875, 0.5625,
-0.25, -0.5, -0.25, 1.0, -0.0, -0.0, 0.1875, 0.5625,
-0.25, -0.25, 0.25, 1.0, -0.0, -0.0, 0.1875, 0.6875,
-0.25, -0.5, 0.25, 1.0, -0.0, -0.0, 0.1875, 0.6875,
-0.5, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.1875,
-0.25, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.0625,
-0.5, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.0625,
-0.5, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.0625,
-0.25, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.1875,
-0.5, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.1875,
-0.5, -0.25, -0.25, -0.0, -0.0, 1.0, 0.4375, 0.1875,
-0.25, 0.25, -0.25, -0.0, -0.0, 1.0, 0.5625, 0.1875,
-0.5, 0.25, -0.25, -0.0, -0.0, 1.0, 0.5625, 0.1875,
-0.5, 0.5, -0.25, -1.0, -0.0, -0.0, 0.625, 0.1875,
-0.5, 0.5, -0.5, -1.0, -0.0, -0.0, 0.625, 0.25,
-0.5, 0.25, -0.5, -1.0, -0.0, -0.0, 0.5625, 0.25,
0.25, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.4375,
0.5, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.5,
0.5, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.5,
0.5, 0.5, 0.25, 1.0, -0.0, -0.0, 0.625, 0.6875,
0.5, 0.5, 0.5, 1.0, -0.0, -0.0, 0.625, 0.75,
0.5, 0.25, 0.5, 1.0, -0.0, -0.0, 0.5625, 0.75,
-0.25, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.9375,
-0.5, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 1.0,
-0.5, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 1.0,
0.5, -0.5, 0.25, -0.0, -1.0, -0.0, 0.375, 0.6875,
0.5, -0.5, 0.5, -0.0, -1.0, -0.0, 0.375, 0.75,
0.25, -0.5, 0.5, -0.0, -1.0, -0.0, 0.3125, 0.75,
-0.5, 0.5, 0.25, -0.0, 1.0, -0.0, 0.875, 0.6875,
-0.5, 0.5, 0.5, -0.0, 1.0, -0.0, 0.875, 0.75,
-0.25, 0.5, 0.5, -0.0, 1.0, -0.0, 0.8125, 0.75,
-0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.8125, 0.6875,
-0.25, 0.5, 0.5, -0.0, 1.0, -0.0, 0.8125, 0.75,
0.25, 0.5, 0.5, -0.0, 1.0, -0.0, 0.6875, 0.75,
-0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.1875, 0.6875,
-0.25, -0.5, 0.5, -0.0, -1.0, -0.0, 0.1875, 0.75,
-0.5, -0.5, 0.5, -0.0, -1.0, -0.0, 0.125, 0.75,
0.25, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.8125,
-0.25, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.9375,
-0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.9375,
-0.5, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.25,
-0.25, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.3125,
-0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.3125,
0.5, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.75,
0.25, 0.5, 0.5, -0.0, -0.0, 1.0, 0.625, 0.8125,
0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.8125,
0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.6875, 0.6875,
0.25, 0.5, 0.5, -0.0, 1.0, -0.0, 0.6875, 0.75,
0.5, 0.5, 0.5, -0.0, 1.0, -0.0, 0.625, 0.75,
0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.3125, 0.6875,
0.25, -0.5, 0.5, -0.0, -1.0, -0.0, 0.3125, 0.75,
-0.25, -0.5, 0.5, -0.0, -1.0, -0.0, 0.1875, 0.75,
-0.25, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.3125,
0.25, 0.5, -0.5, -0.0, -0.0, -1.0, 0.625, 0.4375,
0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.4375,
0.25, -0.5, -0.5, -0.0, -1.0, -0.0, 0.3125, 0.5,
0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.3125, 0.5625,
-0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.1875, 0.5625,
0.25, 0.5, -0.5, -0.0, 1.0, -0.0, 0.6875, 0.5,
0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.6875, 0.5625,
0.5, 0.5, -0.25, -0.0, 1.0, -0.0, 0.625, 0.5625,
-0.25, -0.5, -0.5, -0.0, -1.0, -0.0, 0.1875, 0.5,
-0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.1875, 0.5625,
-0.5, -0.5, -0.25, -0.0, -1.0, -0.0, 0.125, 0.5625,
-0.25, 0.5, -0.5, -0.0, 1.0, -0.0, 0.8125, 0.5,
-0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.8125, 0.5625,
0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.6875, 0.5625,
-0.5, 0.5, -0.5, -0.0, 1.0, -0.0, 0.875, 0.5,
-0.5, 0.5, -0.25, -0.0, 1.0, -0.0, 0.875, 0.5625,
-0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.8125, 0.5625,
0.5, -0.5, -0.5, -0.0, -1.0, -0.0, 0.375, 0.5,
0.5, -0.5, -0.25, -0.0, -1.0, -0.0, 0.375, 0.5625,
0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.3125, 0.5625,
0.5, 0.5, -0.5, 1.0, -0.0, -0.0, 0.625, 0.5,
0.5, 0.5, -0.25, 1.0, -0.0, -0.0, 0.625, 0.5625,
0.5, 0.25, -0.25, 1.0, -0.0, -0.0, 0.5625, 0.5625,
-0.5, 0.5, 0.25, -1.0, -0.0, -0.0, 0.625, 0.0625,
-0.5, 0.5, -0.25, -1.0, -0.0, -0.0, 0.625, 0.1875,
-0.5, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.1875,
-0.5, 0.5, 0.5, -1.0, -0.0, -0.0, 0.625, 0.0,
-0.5, 0.5, 0.25, -1.0, -0.0, -0.0, 0.625, 0.0625,
-0.5, 0.25, 0.25, -1.0, -0.0, -0.0, 0.5625, 0.0625,
-0.25, -0.5, 0.25, -0.0, -0.0, -1.0, 0.1875, 0.6875,
-0.25, -0.25, 0.25, -0.0, -0.0, -1.0, 0.1875, 0.6875,
0.25, -0.25, 0.25, -0.0, -0.0, -1.0, 0.3125, 0.6875,
0.25, 0.5, -0.25, -0.0, 1.0, -0.0, 0.6875, 0.5625,
0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.6875, 0.6875,
0.5, 0.5, 0.25, -0.0, 1.0, -0.0, 0.625, 0.6875,
-0.25, -0.5, -0.25, -0.0, -1.0, -0.0, 0.1875, 0.5625,
-0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.1875, 0.6875,
-0.5, -0.5, 0.25, -0.0, -1.0, -0.0, 0.125, 0.6875,
-0.25, 0.5, 0.25, 1.0, -0.0, -0.0, 0.8125, 0.6875,
-0.25, 0.25, 0.25, 1.0, -0.0, -0.0, 0.8125, 0.6875,
-0.25, 0.25, -0.25, 1.0, -0.0, -0.0, 0.8125, 0.5625,
-0.5, 0.5, -0.25, -0.0, 1.0, -0.0, 0.875, 0.5625,
-0.5, 0.5, 0.25, -0.0, 1.0, -0.0, 0.875, 0.6875,
-0.25, 0.5, 0.25, -0.0, 1.0, -0.0, 0.8125, 0.6875,
0.5, -0.5, -0.25, -0.0, -1.0, -0.0, 0.375, 0.5625,
0.5, -0.5, 0.25, -0.0, -1.0, -0.0, 0.375, 0.6875,
0.25, -0.5, 0.25, -0.0, -1.0, -0.0, 0.3125, 0.6875,
0.5, 0.5, -0.25, 1.0, -0.0, -0.0, 0.625, 0.5625,
0.5, 0.5, 0.25, 1.0, -0.0, -0.0, 0.625, 0.6875,
0.5, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.6875,
0.5, 0.25, -0.25, -0.0, -0.0, 1.0, 0.5625, 0.5625,
0.25, 0.25, -0.25, -0.0, -0.0, 1.0, 0.5625, 0.5625,
0.25, -0.25, -0.25, -0.0, -0.0, 1.0, 0.4375, 0.5625,
-0.5, 0.25, 0.5, -1.0, -0.0, -0.0, 0.5625, 0.0,
-0.5, 0.25, 0.25, -1.0, -0.0, -0.0, 0.5625, 0.0625,
-0.5, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.0625,
-0.5, 0.25, 0.25, -0.0, -0.0, -1.0, 0.5625, 0.0625,
-0.25, 0.25, 0.25, -0.0, -0.0, -1.0, 0.5625, 0.0625,
-0.25, -0.25, 0.25, -0.0, -0.0, -1.0, 0.4375, 0.0625,
0.5, 0.25, -0.5, 1.0, -0.0, -0.0, 0.5625, 0.5,
0.5, 0.25, -0.25, 1.0, -0.0, -0.0, 0.5625, 0.5625,
0.5, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.5625,
0.25, -0.25, -0.5, -1.0, -0.0, -0.0, 0.4375, 0.4375,
0.25, -0.25, -0.25, -1.0, -0.0, -0.0, 0.4375, 0.4375,
0.25, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.4375,
0.5, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.75,
0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.8125,
0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.8125,
-0.5, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.25,
-0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.3125,
-0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.3125,
0.25, 0.25, 0.5, -1.0, -0.0, -0.0, 0.5625, 0.8125,
0.25, 0.25, 0.25, -1.0, -0.0, -0.0, 0.5625, 0.8125,
0.25, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.8125,
-0.25, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 0.9375,
-0.5, 0.25, 0.5, -0.0, -0.0, 1.0, 0.5625, 1.0,
-0.5, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 1.0,
0.5, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.6875,
0.5, 0.25, 0.5, 1.0, -0.0, -0.0, 0.5625, 0.75,
0.5, -0.25, 0.5, 1.0, -0.0, -0.0, 0.4375, 0.75,
0.25, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.4375,
0.5, 0.25, -0.5, -0.0, -0.0, -1.0, 0.5625, 0.5,
0.5, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.5,
-0.5, 0.25, -0.25, -1.0, -0.0, -0.0, 0.5625, 0.1875,
-0.5, 0.25, -0.5, -1.0, -0.0, -0.0, 0.5625, 0.25,
-0.5, -0.25, -0.5, -1.0, -0.0, -0.0, 0.4375, 0.25,
-0.5, -0.25, -0.25, -1.0, -0.0, -0.0, 0.4375, 0.1875,
-0.5, -0.25, -0.5, -1.0, -0.0, -0.0, 0.4375, 0.25,
-0.5, -0.5, -0.5, -1.0, -0.0, -0.0, 0.375, 0.25,
0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.4375,
0.5, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.5,
0.5, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.5,
0.5, -0.25, 0.25, 1.0, -0.0, -0.0, 0.4375, 0.6875,
0.5, -0.25, 0.5, 1.0, -0.0, -0.0, 0.4375, 0.75,
0.5, -0.5, 0.5, 1.0, -0.0, -0.0, 0.375, 0.75,
-0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.9375,
-0.5, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 1.0,
-0.5, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 1.0,
0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.8125,
-0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.9375,
-0.25, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.9375,
-0.5, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.25,
-0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.3125,
-0.25, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.3125,
0.5, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.75,
0.25, -0.25, 0.5, -0.0, -0.0, 1.0, 0.4375, 0.8125,
0.25, -0.5, 0.5, -0.0, -0.0, 1.0, 0.375, 0.8125,
-0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.3125,
0.25, -0.25, -0.5, -0.0, -0.0, -1.0, 0.4375, 0.4375,
0.25, -0.5, -0.5, -0.0, -0.0, -1.0, 0.375, 0.4375,
0.5, -0.25, -0.5, 1.0, -0.0, -0.0, 0.4375, 0.5,
0.5, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.5625,
0.5, -0.5, -0.25, 1.0, -0.0, -0.0, 0.375, 0.5625,
-0.5, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.0625,
-0.5, -0.25, -0.25, -1.0, -0.0, -0.0, 0.4375, 0.1875,
-0.5, -0.5, -0.25, -1.0, -0.0, -0.0, 0.375, 0.1875,
-0.5, -0.25, 0.5, -1.0, -0.0, -0.0, 0.4375, 0.0,
-0.5, -0.25, 0.25, -1.0, -0.0, -0.0, 0.4375, 0.0625,
-0.5, -0.5, 0.25, -1.0, -0.0, -0.0, 0.375, 0.0625,
0.5, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.5625,
0.5, -0.25, 0.25, 1.0, -0.0, -0.0, 0.4375, 0.6875,
0.5, -0.5, 0.25, 1.0, -0.0, -0.0, 0.375, 0.6875,
0.25, -0.25, 0.5, -0.0, 1.0, -0.0, 0.4375, 0.8125,
0.25, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.8125,
-0.25, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.9375,
-0.25, -0.25, 0.5, 1.0, -0.0, -0.0, 0.4375, 0.9375,
-0.25, -0.25, 0.25, 1.0, -0.0, -0.0, 0.4375, 0.9375,
-0.25, 0.25, 0.25, 1.0, -0.0, -0.0, 0.5625, 0.9375,
-0.25, 0.25, 0.5, -0.0, -1.0, -0.0, 0.5625, 0.9375,
-0.25, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.9375,
0.25, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.8125,
0.5, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.5625,
0.25, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.5625,
0.25, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.6875,
0.5, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.6875,
0.25, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.6875,
0.25, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.5625,
0.5, -0.25, 0.25, -0.0, -0.0, -1.0, 0.4375, 0.6875,
0.25, -0.25, 0.25, -0.0, -0.0, -1.0, 0.4375, 0.6875,
0.25, 0.25, 0.25, -0.0, -0.0, -1.0, 0.5625, 0.6875,
-0.25, 0.25, -0.5, 1.0, -0.0, -0.0, 0.5625, 0.3125,
-0.25, 0.25, -0.25, 1.0, -0.0, -0.0, 0.5625, 0.3125,
-0.25, -0.25, -0.25, 1.0, -0.0, -0.0, 0.4375, 0.3125,
0.25, 0.25, -0.5, -0.0, -1.0, -0.0, 0.5625, 0.4375,
0.25, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.4375,
-0.25, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.3125,
-0.25, -0.25, -0.5, -0.0, 1.0, -0.0, 0.4375, 0.3125,
-0.25, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.3125,
0.25, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.4375,
0.25, 0.5, 0.25, -0.0, -0.0, -1.0, 0.6875, 0.6875,
0.25, 0.25, 0.25, -0.0, -0.0, -1.0, 0.6875, 0.6875,
-0.25, 0.25, 0.25, -0.0, -0.0, -1.0, 0.8125, 0.6875,
-0.25, 0.5, -0.25, -0.0, -0.0, 1.0, 0.8125, 0.5625,
-0.25, 0.25, -0.25, -0.0, -0.0, 1.0, 0.8125, 0.5625,
0.25, 0.25, -0.25, -0.0, -0.0, 1.0, 0.6875, 0.5625,
0.25, 0.5, -0.25, -1.0, -0.0, -0.0, 0.6875, 0.5625,
0.25, 0.25, -0.25, -1.0, -0.0, -0.0, 0.6875, 0.5625,
0.25, 0.25, 0.25, -1.0, -0.0, -0.0, 0.6875, 0.6875,
0.25, -0.5, 0.25, -1.0, -0.0, -0.0, 0.3125, 0.6875,
0.25, -0.25, 0.25, -1.0, -0.0, -0.0, 0.3125, 0.6875,
0.25, -0.25, -0.25, -1.0, -0.0, -0.0, 0.3125, 0.5625,
0.25, -0.5, -0.25, -0.0, -0.0, 1.0, 0.3125, 0.5625,
0.25, -0.25, -0.25, -0.0, -0.0, 1.0, 0.3125, 0.5625,
-0.25, -0.25, -0.25, -0.0, -0.0, 1.0, 0.1875, 0.5625,
-0.25, -0.5, -0.25, 1.0, -0.0, -0.0, 0.1875, 0.5625,
-0.25, -0.25, -0.25, 1.0, -0.0, -0.0, 0.1875, 0.5625,
-0.25, -0.25, 0.25, 1.0, -0.0, -0.0, 0.1875, 0.6875,
-0.5, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.1875,
-0.25, 0.25, -0.25, -0.0, -1.0, -0.0, 0.5625, 0.1875,
-0.25, 0.25, 0.25, -0.0, -1.0, -0.0, 0.5625, 0.0625,
-0.5, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.0625,
-0.25, -0.25, 0.25, -0.0, 1.0, -0.0, 0.4375, 0.0625,
-0.25, -0.25, -0.25, -0.0, 1.0, -0.0, 0.4375, 0.1875,
-0.5, -0.25, -0.25, -0.0, -0.0, 1.0, 0.4375, 0.1875,
-0.25, -0.25, -0.25, -0.0, -0.0, 1.0, 0.4375, 0.1875,
-0.25, 0.25, -0.25, -0.0, -0.0, 1.0, 0.5625, 0.1875,
};
Mesh* CUBE_MESH; Mesh* CUBE_MESH;
Mesh* SPHERE_MESH; Mesh* SPHERE_MESH;
Mesh* ARROW_MESH; Mesh* ARROW_MESH;
Mesh* OUTLINE_MESH;
void initMeshes() { void initMeshes() {
CUBE_MESH = new Mesh(sizeof(CUBE_VERTICES) / sizeof(float) / 8, CUBE_VERTICES); CUBE_MESH = new Mesh(sizeof(CUBE_VERTICES) / sizeof(float) / 8, CUBE_VERTICES);
SPHERE_MESH = new Mesh(sizeof(SPHERE_VERTICES) / sizeof(float) / 8, SPHERE_VERTICES); SPHERE_MESH = new Mesh(sizeof(SPHERE_VERTICES) / sizeof(float) / 8, SPHERE_VERTICES);
ARROW_MESH = new Mesh(sizeof(ARROW_VERTICES) / sizeof(float) / 8, ARROW_VERTICES); ARROW_MESH = new Mesh(sizeof(ARROW_VERTICES) / sizeof(float) / 8, ARROW_VERTICES);
OUTLINE_MESH = new Mesh(sizeof(OUTLINE_VERTICES) / sizeof(float) / 8, OUTLINE_VERTICES);
} }
/* Python generator: /* Python generator:

View file

@ -4,5 +4,6 @@
extern Mesh* CUBE_MESH; extern Mesh* CUBE_MESH;
extern Mesh* SPHERE_MESH; extern Mesh* SPHERE_MESH;
extern Mesh* ARROW_MESH; extern Mesh* ARROW_MESH;
extern Mesh* OUTLINE_MESH;
void initMeshes(); void initMeshes();

View file

@ -187,6 +187,7 @@ void renderParts() {
void renderSkyBox() { void renderSkyBox() {
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glCullFace(GL_FRONT); glCullFace(GL_FRONT);
glFrontFace(GL_CW);
skyboxShader->use(); skyboxShader->use();
@ -354,69 +355,43 @@ void renderWireframe() {
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
} }
void renderOutline() { void renderOutlines() {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
glFrontFace(GL_CW); glFrontFace(GL_CCW);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glLineWidth(10.f);
// Use shader // Use shader
wireframeShader->use(); outlineShader->use();
// view/projection transformations // view/projection transformations
glm::mat4 projection = glm::perspective(glm::radians(45.f), (float)viewportWidth / (float)viewportHeight, 0.1f, 1000.0f); glm::mat4 projection = glm::perspective(glm::radians(45.f), (float)viewportWidth / (float)viewportHeight, 0.1f, 1000.0f);
glm::mat4 view = camera.getLookAt(); glm::mat4 view = camera.getLookAt();
wireframeShader->set("projection", projection); outlineShader->set("projection", projection);
wireframeShader->set("view", view); outlineShader->set("view", view);
// Pass in the camera position // Pass in the camera position
wireframeShader->set("viewPos", camera.cameraPos); outlineShader->set("viewPos", camera.cameraPos);
wireframeShader->set("transparency", 0.5f); // outlineShader->set("color", glm::vec3(1.f, 0.f, 0.f));
wireframeShader->set("color", glm::vec3(0.204, 0.584, 0.922));
// Sort by nearest // Sort by nearest
for (InstanceRef inst : gWorkspace()->GetChildren()) { for (auto it = gWorkspace()->GetDescendantsStart(); it != gWorkspace()->GetDescendantsEnd(); it++) {
if (inst->GetClass()->className != "Part") continue; InstanceRef inst = *it;
if (inst->GetClass() != &Part::TYPE) continue;
std::shared_ptr<Part> part = std::dynamic_pointer_cast<Part>(inst); std::shared_ptr<Part> part = std::dynamic_pointer_cast<Part>(inst);
if (!part->selected) continue; if (!part->selected) continue;
glm::mat4 model = part->cframe; glm::mat4 model = part->cframe;
model = glm::scale(model, (glm::vec3)part->size / glm::vec3(2) + glm::vec3(0.001)); model = glm::scale(model, (glm::vec3)part->size + glm::vec3(0.01));
wireframeShader->set("model", model); outlineShader->set("model", model);
glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model))); outlineShader->set("scale", part->size + glm::vec3(0.01));
wireframeShader->set("normalMatrix", normalMatrix);
// CUBE_MESH->bind(); OUTLINE_MESH->bind();
// glDrawArrays(GL_TRIANGLES, 0, CUBE_MESH->vertexCount); glDrawArrays(GL_TRIANGLES, 0, OUTLINE_MESH->vertexCount);
glBegin(GL_LINES);
// Upper face
glVertex3f(-1., 1., -1.); glVertex3f(1., 1., -1.);
glVertex3f(-1., 1., 1.); glVertex3f(1., 1., 1.);
glVertex3f(-1., 1., -1.); glVertex3f(-1., 1., 1.);
glVertex3f(1., 1., -1.); glVertex3f(1., 1., 1.);
// Lower face
glVertex3f(-1., -1., -1.); glVertex3f(1., -1., -1.);
glVertex3f(-1., -1., 1.); glVertex3f(1., -1., 1.);
glVertex3f(-1., -1., -1.); glVertex3f(-1., -1., 1.);
glVertex3f(1., -1., -1.); glVertex3f(1., -1., 1.);
// Connecting vertical lines
glVertex3f(-1., -1., -1.); glVertex3f(-1., 1., -1.);
glVertex3f(1., -1., -1.); glVertex3f(1., 1., -1.);
glVertex3f(-1., -1., 1.); glVertex3f(-1., 1., 1.);
glVertex3f(1., -1., 1.); glVertex3f(1., 1., 1.);
glEnd();
} }
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
} }
void render(GLFWwindow* window) { void render(GLFWwindow* window) {
@ -426,7 +401,7 @@ void render(GLFWwindow* window) {
renderSkyBox(); renderSkyBox();
renderHandles(); renderHandles();
renderParts(); renderParts();
renderOutline(); renderOutlines();
if (wireframeRendering) if (wireframeRendering)
renderWireframe(); renderWireframe();
// TODO: Make this a debug flag // TODO: Make this a debug flag