Merge branch 'master' of https://git.redacted.cc/Josh/JGL
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m41s

This commit is contained in:
2024-10-22 22:32:27 -04:00
3 changed files with 28 additions and 27 deletions

View File

@@ -322,20 +322,19 @@ namespace JGL {
void DrawLine(const Color4& color, const Vector3& A, const Vector3& B, float thickness = 1.f);
/// Render a wireframe sphere.
void WireframeSphere(const Color4& color, const Vector3& position, float radius, unsigned int lats, unsigned int longs, float thickness = 1.f);
void WireframeSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f);
void WireframeIcosphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f);
void WireframeIcosphere(const Color4& color, const Sphere& sphere, float thickness = 1.f);
void WireframeCubesphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f);
void WireframeCubesphere(const Color4& color, const Sphere& sphere, float thickness = 1.f);
void WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int subdivisions = 10);
void WireframeSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int subdivisions = 10);
void WireframeIcosphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int subdivisions = 10);
void WireframeIcosphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int subdivisions = 10);
void WireframeCubesphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int subdivisions = 10);
void WireframeCubesphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int subdivisions = 10);
void FillSphere(const Color4& color, const Vector3& position, float radius);
void FillSphere(const Color4& color, const Sphere& sphere);
void FillIcosphere(const Color4& color, const Vector3& position, float radius);
void FillIcosphere(const Color4& color, const Sphere& sphere);
void FillCubesphere(const Color4& color, const Vector3& position, float radius);
void FillCubesphere(const Color4& color, const Sphere& sphere);
void FillSphere(const Color4& color, const Vector3& position, float radius, unsigned int subdivisions = 10);
void FillSphere(const Color4& color, const Sphere& sphere, unsigned int subdivisions = 10);
void FillIcosphere(const Color4& color, const Vector3& position, float radius, unsigned int subdivisions = 10);
void FillIcosphere(const Color4& color, const Sphere& sphere, unsigned int subdivisions = 10);
void FillCubesphere(const Color4& color, const Vector3& position, float radius, unsigned int subdivisions = 10);
void FillCubesphere(const Color4& color, const Sphere& sphere, unsigned int subdivisions = 10);
void WireframeAABB(const Color4& color, const AABB& aabb);
void WireframeAABB(const Color4& color, const Vector3& pos, const Vector3& radii, float thickness = 1.f);

View File

@@ -150,6 +150,7 @@ public:
fov_increasing = false;
else if (fov <= 75)
fov_increasing = true;
J3D::ChangeFOV(fov);
sprite_radians += 0.005;
textAngle.y += .05f;
@@ -165,7 +166,7 @@ public:
J3D::DrawLine(Colors::Red, {-0.33,-0.125,1}, {-1,-0.125,1});
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,1.f}, 0.25f, 25, 25, 1.f);
J3D::WireframeSphere(Colors::Green, {0,0,1.f}, 0.25f, 25, 1.f);
J3D::End();
J2D::Begin(j2d_render_target, true);
@@ -219,18 +220,6 @@ public:
}
void OnRefresh(float elapsed) override {
if (isKeyDown(Keys::RightArrow))
camera->angle.y += 45.f * elapsed;
if (isKeyDown(Keys::LeftArrow))
camera->angle.y -= 45.f * elapsed;
if (isKeyDown(Keys::UpArrow))
camera->angle.x -= 45.f * elapsed;
if (isKeyDown(Keys::DownArrow))
camera->angle.x += 45.f * elapsed;
if (isKeyDown(Keys::Space))
camera->position.y += 1.f * elapsed;
if (isKeyDown(Keys::LeftShift))
camera->position.y -= 1.f * elapsed;
auto mouse = GetMouseCoordinates();
a.Update(mouse);
b.Update(mouse);

View File

@@ -1061,13 +1061,16 @@ namespace JGL {
glColor4fv(baseColor);
}
void J3D::WireframeSphere(const Color4& color, const Vector3& position, float radius, unsigned int lats, unsigned int longs, float thickness) {
void J3D::WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness, unsigned int subdivisions) {
if (!inJ3D)
Logger::Error("Drawing J3D element before J3D begin.");
glLineWidth(thickness);
glColor4ubv(color.ptr());
unsigned int lats = subdivisions;
unsigned int longs = subdivisions;
float r = radius;
std::vector<Vector3> vertices((lats + 1) * (longs + 1));
@@ -1099,6 +1102,16 @@ namespace JGL {
glVertexPointer(3, GL_FLOAT, sizeof(Vector3), vertices.data());
glDrawArrays(GL_LINE_LOOP, 0, vertices.size());
glColor4fv(baseColor);
}
void J3D::WireframeIcosphere(const Color4 &color, const Vector3& position, float radius, float thickness,
unsigned int subdivisions) {
const float h_angle = Math::Pi / 180 * 72; // 72 degree = 360 / 5;
const float v_angle = Math::Atan(1.f / 2.f);
std::vector<float> vertices(12*3);
}
#pragma endregion