From d4a582f0a87f8de298cc740691943bc0eb6ad944 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Mon, 14 Apr 2025 23:32:02 +0200 Subject: [PATCH] feat(renderer): added mesh-based outline --- assets/shaders/outline.fs | 21 +- assets/shaders/outline.vs | 3 +- core/src/rendering/defaultmeshes.cpp | 440 +++++++++++++++++++++++++++ core/src/rendering/defaultmeshes.h | 1 + core/src/rendering/renderer.cpp | 61 ++-- 5 files changed, 478 insertions(+), 48 deletions(-) diff --git a/assets/shaders/outline.fs b/assets/shaders/outline.fs index 53ee504..744406a 100644 --- a/assets/shaders/outline.fs +++ b/assets/shaders/outline.fs @@ -1,11 +1,24 @@ #version 330 core -out vec4 FragColor; +uniform vec3 scale; -uniform vec3 color; +in vec3 vPos; -// Main +out vec4 fColor; 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); } \ No newline at end of file diff --git a/assets/shaders/outline.vs b/assets/shaders/outline.vs index 52ee47b..6dcb3ff 100644 --- a/assets/shaders/outline.vs +++ b/assets/shaders/outline.vs @@ -1,9 +1,9 @@ #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec3 aNormal; +layout (location = 2) in vec2 aTexCoords; out vec3 vPos; -out vec3 vNormal; uniform mat4 model; uniform mat4 view; @@ -12,4 +12,5 @@ uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0); + vPos = aPos; } diff --git a/core/src/rendering/defaultmeshes.cpp b/core/src/rendering/defaultmeshes.cpp index 703cd7c..d8e4580 100644 --- a/core/src/rendering/defaultmeshes.cpp +++ b/core/src/rendering/defaultmeshes.cpp @@ -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* SPHERE_MESH; Mesh* ARROW_MESH; +Mesh* OUTLINE_MESH; void initMeshes() { CUBE_MESH = new Mesh(sizeof(CUBE_VERTICES) / sizeof(float) / 8, CUBE_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); + OUTLINE_MESH = new Mesh(sizeof(OUTLINE_VERTICES) / sizeof(float) / 8, OUTLINE_VERTICES); } /* Python generator: diff --git a/core/src/rendering/defaultmeshes.h b/core/src/rendering/defaultmeshes.h index 37f0839..f5332ab 100644 --- a/core/src/rendering/defaultmeshes.h +++ b/core/src/rendering/defaultmeshes.h @@ -4,5 +4,6 @@ extern Mesh* CUBE_MESH; extern Mesh* SPHERE_MESH; extern Mesh* ARROW_MESH; +extern Mesh* OUTLINE_MESH; void initMeshes(); \ No newline at end of file diff --git a/core/src/rendering/renderer.cpp b/core/src/rendering/renderer.cpp index eac9bf4..26121a2 100644 --- a/core/src/rendering/renderer.cpp +++ b/core/src/rendering/renderer.cpp @@ -187,6 +187,7 @@ void renderParts() { void renderSkyBox() { glDepthMask(GL_FALSE); glCullFace(GL_FRONT); + glFrontFace(GL_CW); skyboxShader->use(); @@ -354,69 +355,43 @@ void renderWireframe() { glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } -void renderOutline() { +void renderOutlines() { glDepthMask(GL_TRUE); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); - glFrontFace(GL_CW); + glFrontFace(GL_CCW); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - glLineWidth(10.f); // Use shader - wireframeShader->use(); + outlineShader->use(); // view/projection transformations glm::mat4 projection = glm::perspective(glm::radians(45.f), (float)viewportWidth / (float)viewportHeight, 0.1f, 1000.0f); glm::mat4 view = camera.getLookAt(); - wireframeShader->set("projection", projection); - wireframeShader->set("view", view); + outlineShader->set("projection", projection); + outlineShader->set("view", view); // Pass in the camera position - wireframeShader->set("viewPos", camera.cameraPos); + outlineShader->set("viewPos", camera.cameraPos); - wireframeShader->set("transparency", 0.5f); - wireframeShader->set("color", glm::vec3(0.204, 0.584, 0.922)); + // outlineShader->set("color", glm::vec3(1.f, 0.f, 0.f)); // Sort by nearest - for (InstanceRef inst : gWorkspace()->GetChildren()) { - if (inst->GetClass()->className != "Part") continue; + for (auto it = gWorkspace()->GetDescendantsStart(); it != gWorkspace()->GetDescendantsEnd(); it++) { + InstanceRef inst = *it; + if (inst->GetClass() != &Part::TYPE) continue; std::shared_ptr part = std::dynamic_pointer_cast(inst); if (!part->selected) continue; + glm::mat4 model = part->cframe; - model = glm::scale(model, (glm::vec3)part->size / glm::vec3(2) + glm::vec3(0.001)); - wireframeShader->set("model", model); - glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model))); - wireframeShader->set("normalMatrix", normalMatrix); + model = glm::scale(model, (glm::vec3)part->size + glm::vec3(0.01)); + outlineShader->set("model", model); + outlineShader->set("scale", part->size + glm::vec3(0.01)); - // CUBE_MESH->bind(); - // glDrawArrays(GL_TRIANGLES, 0, CUBE_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(); + OUTLINE_MESH->bind(); + glDrawArrays(GL_TRIANGLES, 0, OUTLINE_MESH->vertexCount); } - - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } void render(GLFWwindow* window) { @@ -426,7 +401,7 @@ void render(GLFWwindow* window) { renderSkyBox(); renderHandles(); renderParts(); - renderOutline(); + renderOutlines(); if (wireframeRendering) renderWireframe(); // TODO: Make this a debug flag