Work-in-progress documentation for J3D
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 3m55s

This commit is contained in:
2024-10-24 13:22:51 -04:00
parent 72c256f907
commit d29ea018c3
2 changed files with 100 additions and 9 deletions

View File

@@ -307,49 +307,140 @@ namespace JGL {
/// Drawing functions for primitive 3D Shapes.
namespace J3D {
/// Initializes internals for 3D rendering. Probably will be rethought later.
void Init(const Vector2 &window_size, float fov, float far_plane);
/// Helper function to conveniently change the Field-Of-View.
void ChangeFOV(float fov);
/// Helper function to change the far-plane, which is the cutoff distance for rendering.
void ChangeFarPlane(float far_plane);
/// Open a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL).
/// @note This call may not strictly be necessary on some setups, but is provided to keep the API constant.
/// It is recommended to always open a JGL 3D context to render your content, then close when completed.
/// This keeps our code from, say, clobbering the OpenGL rendering context driving 2D content in between our calls.
void Begin();
/// Closes a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL).
/// @see Begin().
void End();
void SetMatrix(const std::vector<GLfloat> &matrix, const Vector2 &window_size);
/// Draws a line in 3D space.
/// @param color
/// @param A
/// @param B
/// @param thickness
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param A The start-point of the line segment.
/// @param B The end-point of the line segment.
/// @param thickness The line-width to draw the line segment with.
void DrawLine(const Color4 &color, const Vector3 &A, const Vector3 &B, float thickness = 1.f);
/// Draws the outline of an Icosahedron in 3D space.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param position The point in 3D space at which to draw the Icosahedron.
/// @param radius The size to draw the Icosahedron at.
/// @param thickness The line-width to draw the Icosahedron outline with.
void WireframeIcosahedron(const Color4 &color, const Vector3 &position, float radius, float thickness = 1.f);
/// Draws the 'Wireframe' outline of a sphere in 3D space.
/// @param color
/// Draws the outline of a Sphere in 3D space.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param position The point in 3D space at which to draw the Sphere.
/// @param radius The size to draw the Sphere at.
/// @param thickness The line-width to draw the Icosahedron outline with.
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
void WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, uint sectors = 10, uint stacks = 10);
/// Draws the outline of a Sphere in 3D space.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param sphere The mathematically-defined sphere object to be rendered.
/// @param thickness The line-width to draw the Icosahedron outline with.
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
void WireframeSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, uint sectors = 10, uint stacks = 10);
/// Draws the outline of an Icosphere in 3D space.
/// @note An Icosphere is an approximation of a sphere that is generated by recursively subdividing an Icosahedron.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param position The point in 3D space at which to draw the Sphere.
/// @param radius The size to draw the Sphere at.
/// @param thickness The line-width to draw the Icosahedron outline with.
/// @param subdivisions The accuracy of the approximation of the Icosphere, measured in iteration steps taken.
void WireframeIcosphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int subdivisions = 10);
/// Draws the outline of an Icosphere in 3D space.
/// @note An Icosphere is an approximation of a sphere that is generated by recursively subdividing an Icosahedron.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param sphere The mathematically-defined sphere object to be rendered.
/// @param thickness The line-width to draw the Icosphere outline with.
/// @param subdivisions The accuracy of the approximation of the Icosphere, measured in iteration steps taken.
void WireframeIcosphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int subdivisions = 10);
/// Draws the outline of a Cubesphere in 3D space.
/// @note A Cubesphere is an approximation of a sphere that is generated by recursively subdividing a Cube.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param position The point in 3D space at which to draw the Sphere.
/// @param radius The size to draw the Sphere at.
/// @param thickness The line-width to draw the Cubesphere outline with.
/// @param subdivisions The accuracy of the approximation of the Cubesphere, measured in iteration steps taken.
void WireframeCubesphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int subdivisions = 10);
/// Draws the outline of a Cubesphere in 3D space.
/// @note A Cubesphere is an approximation of a sphere that is generated by recursively subdividing a Cube.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
/// @param sphere The mathematically-defined sphere object to be rendered.
/// @param thickness The line-width to draw the Cubesphere outline with.
/// @param subdivisions The accuracy of the approximation of the Cubesphere, measured in iteration steps taken.
void WireframeCubesphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int subdivisions = 10);
/// Draws a solid Sphere in 3D space.
void FillSphere(const Color4& color, const Vector3& position, float radius, uint sectors = 10, uint stacks = 10);
/// Draws a solid Sphere in 3D space.
void FillSphere(const Color4& color, const Sphere& sphere, uint sectors = 10, uint stacks = 10);
/// Draws a solid Icosphere in 3D space.
/// @note An Icosphere is an approximation of a sphere that is generated by recursively subdividing an Icosahedron.
void FillIcosphere(const Color4& color, const Vector3& position, float radius, unsigned int subdivisions = 10);
/// Draws a solid Icosphere in 3D space.
/// @note An Icosphere is an approximation of a sphere that is generated by recursively subdividing an Icosahedron.
void FillIcosphere(const Color4& color, const Sphere& sphere, unsigned int subdivisions = 10);
/// Draws a solid Cubesphere in 3D space.
/// @note A Cubesphere is an approximation of a sphere that is generated by recursively subdividing a Cube.
void FillCubesphere(const Color4& color, const Vector3& position, float radius, unsigned int subdivisions = 10);
/// Draws a solid Cubesphere in 3D space.
void FillCubesphere(const Color4& color, const Sphere& sphere, unsigned int subdivisions = 10);
/// Draws an outline of an axis-aligned bounding box in 3D space.
void WireframeAABB(const Color4& color, const AABB& aabb);
/// Draws an outline of an axis-aligned bounding box in 3D space.
void WireframeAABB(const Color4& color, const Vector3& pos, const Vector3& radii, float thickness = 1.f);
/// Draws a solid axis-aligned bounding box in 3D space.
void FillAABB(const Color4& color, const AABB& aabb);
/// Draws a solid axis-aligned bounding box in 3D space.
void FillAABB(const Color4& color, const Vector3& pos, const Vector3& radii);
/// Draws an outline of an oriented bounding box in 3D space.
void WireframeOBB(const Color4& color, const Vector3& position, const Vector3& radii, const EulerAngle& orientation, float thickness = 1.f);
/// Draws an outline of an oriented bounding box in 3D space.
void WireframeOBB(const Color4& color, const OBB& obb, float thickness = 1.f);
/// Draws an outline of an oriented bounding box in 3D space.
void FillOBB(const Color4&, const Vector3& position, const Vector3& radii, const EulerAngle& orientation);
/// Draws an outline of an oriented bounding box in 3D space.
void FillOBB(const Color4& color, const OBB& obb);
void WireframeCylinder();
void FillCylinder();
@@ -362,8 +453,7 @@ namespace JGL {
void WireframeTorus();
void FillTorus();
void FillOBB(const Color3& color, const OBB& obb);
void WireframeOBB(const Color3& color, const OBB& obb, float thickness = 1.f);
void FillCapsule(const Color3& color, const Capsule& capsule);
void WireframeCapsule(const Color3& color, const Capsule& cap, float thickness = 1.f);
void FillTriangleMesh(const Color3& color, const TriangleMesh& mesh);

View File

@@ -8,6 +8,7 @@
#include <JGL/logger/logger.h>
#include <J3ML/Geometry/AABB.hpp>
#include <J3ML/Geometry/Sphere.hpp>
#include <J3ML/Geometry/OBB.hpp>
#include "JGL/types/VRamList.h"
JGL::RenderTarget* render_target = nullptr;