Implement FillAABB
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 4m1s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 4m1s
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
/// @file JGL.h
|
||||
/// @desc All JGL usable functions are defined here. This is the public API.
|
||||
/// @edit 2024-07-16
|
||||
/// @edit 2024-10-24
|
||||
|
||||
|
||||
#pragma once
|
||||
|
5
main.cpp
5
main.cpp
@@ -167,7 +167,10 @@ public:
|
||||
J3D::DrawLine(Colors::Red, {-0.33,-0.125,1}, {-0.33,0.25,1});
|
||||
J3D::DrawString(Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f}, 1.f, 32, FreeSans, textAngle, true);
|
||||
J3D::WireframeSphere(Colors::Green, {0,0,0.5f}, 0.25f, 1.f, 10, 10);
|
||||
J3D::WireframeAABB(Colors::White, {0,0,0.25f}, {0.1f, 0.1f, 0.05f});
|
||||
|
||||
J3D::FillAABB(Colors::Whites::AliceBlue, {0,0,0.5f}, {0.1f, 0.05f, 0.1f});
|
||||
J3D::WireframeAABB(Colors::Gray, {0,0,0.5f}, {0.11f, 0.06f, 0.11f});
|
||||
|
||||
//J3D::WireframeIcosahedron(Colors::Green, {0,0,0.5f}, 0.125f, 1.f);
|
||||
J3D::End();
|
||||
|
||||
|
63
src/JGL.cpp
63
src/JGL.cpp
@@ -6,6 +6,7 @@
|
||||
#include <glad/glad.h>
|
||||
#include <J3ML/Algorithm/Bezier.hpp>
|
||||
#include <JGL/logger/logger.h>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include "JGL/types/VRamList.h"
|
||||
|
||||
JGL::RenderTarget* render_target = nullptr;
|
||||
@@ -1280,5 +1281,67 @@ namespace JGL {
|
||||
glColor4fv(baseColor);
|
||||
}
|
||||
|
||||
void J3D::FillAABB(const Color4 &color, const Vector3 &pos, const Vector3 &radii) {
|
||||
// Top of cube
|
||||
Vector3 top_right_top = pos + Vector3(radii.x, radii.y, -radii.z);
|
||||
Vector3 top_left_top = pos + Vector3(-radii.x, radii.y, -radii.z);
|
||||
Vector3 bottom_left_top = pos - radii;
|
||||
Vector3 bottom_right_top = pos + Vector3(radii.x, radii.y, radii.z);
|
||||
|
||||
// Bottom of cube
|
||||
Vector3 top_right_bottom = pos + Vector3(radii.x, -radii.y, radii.z);
|
||||
Vector3 top_left_bottom = pos + Vector3(-radii.x, -radii.y, radii.z);
|
||||
Vector3 bottom_left_bottom = pos - radii;
|
||||
Vector3 bottom_right_bottom = pos + Vector3(radii.x, -radii.y, -radii.z);
|
||||
|
||||
// front of cube
|
||||
Vector3 top_right_front = pos + radii;
|
||||
Vector3 top_left_front = pos + Vector3(-radii.x, radii.y, radii.z);
|
||||
Vector3 bottom_left_front = pos + Vector3(-radii.x, -radii.y, radii.z);
|
||||
Vector3 bottom_right_front = pos + Vector3(radii.x, -radii.y, radii.z);
|
||||
|
||||
// back of cube
|
||||
Vector3 top_right_back = pos + Vector3(radii.x, -radii.y, -radii.z);
|
||||
Vector3 top_left_back = pos - radii;
|
||||
Vector3 bottom_left_back = pos + Vector3(-radii.x, radii.y, -radii.z);
|
||||
Vector3 bottom_right_back = pos + Vector3(radii.x, radii.y, -radii.z);
|
||||
|
||||
// left of cube
|
||||
Vector3 top_right_left = pos + Vector3(-radii.x, radii.y, radii.z);
|
||||
Vector3 top_left_left = pos + Vector3(-radii.x, radii.y, -radii.z);
|
||||
Vector3 bottom_left_left = pos - radii;
|
||||
Vector3 bottom_right_left = pos + Vector3(-radii.x, -radii.y, radii.z);
|
||||
|
||||
// right of cube
|
||||
Vector3 top_right_right = pos + Vector3(radii.x, radii.y, -radii.z);
|
||||
Vector3 top_left_right = pos + radii;
|
||||
Vector3 bottom_left_right = pos + Vector3(radii.x, -radii.y, radii.z);
|
||||
Vector3 bottom_right_right = pos + Vector3(radii.x, -radii.y, -radii.z);
|
||||
|
||||
std::vector<Vector3> vertices
|
||||
{
|
||||
top_right_top, top_left_top, bottom_left_top, bottom_right_top,
|
||||
top_right_bottom, top_left_bottom, bottom_left_bottom, bottom_right_bottom,
|
||||
top_right_front, top_left_front, bottom_left_front, bottom_right_front,
|
||||
top_right_back, top_left_back, bottom_left_back, bottom_right_back,
|
||||
top_right_left, top_left_left, bottom_left_left, bottom_right_left,
|
||||
top_right_right, top_left_right, bottom_left_right, bottom_right_right
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glColor4ubv(color.ptr());
|
||||
//glBindBuffer(GL_ARRAY_BUFFER, vertices.size());
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vector3), vertices.data());
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, vertices.size());
|
||||
glColor4fv(baseColor);
|
||||
}
|
||||
|
||||
void J3D::FillAABB(const Color4 &color, const AABB &aabb) {
|
||||
FillAABB(color, aabb.Centroid(), aabb.Size());
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
}
|
||||
|
Reference in New Issue
Block a user