Josh's Graphics Library
JGL::J3D Namespace Reference

Drawing functions for primitive 3D Shapes. More...

Functions

void Init (const Vector2 &window_size, float fov, float far_plane)
 Initializes internals for 3D rendering. Probably will be rethought later. More...
 
void ChangeFOV (float fov)
 Helper function to conveniently change the Field-Of-View. More...
 
void ChangeFarPlane (float far_plane)
 Helper function to change the far-plane, which is the cutoff distance for rendering. More...
 
void Begin ()
 Open a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL). More...
 
void End ()
 Closes a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL). More...
 
void SetMatrix (const std::vector< GLfloat > &matrix, const Vector2 &window_size)
 
void DrawLine (const Color4 &color, const Vector3 &A, const Vector3 &B, float thickness=1.f)
 Draws a line in 3D space. More...
 
void DrawCubicBezierCurve (const Color4 &color, const Vector3 &controlA, const Vector3 &pointA, const Vector3 &pointB, const Vector3 &controlB, int subdivisions=10, float thickness=1)
 Draws a smooth, curved line segment between two control points, with the curve controlled by the two inner points. More...
 
void WireframeIcosahedron (const Color4 &color, const Vector3 &position, float radius, float thickness=1.f)
 Draws the outline of an Icosahedron in 3D space. More...
 
void FillIcosahedron (const Color4 &color, const Vector3 &position, float radius)
 Draws a solid Icosahedron in 3D space. More...
 
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. More...
 
void WireframeSphere (const Color4 &color, const Sphere &sphere, float thickness=1.f, uint sectors=10, uint stacks=10)
 Draws the outline of a Sphere in 3D space. More...
 
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. More...
 
void WireframeIcosphere (const Color4 &color, const Sphere &sphere, float thickness=1.f, unsigned int subdivisions=10)
 Draws the outline of an Icosphere in 3D space. More...
 
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. More...
 
void WireframeCubesphere (const Color4 &color, const Sphere &sphere, float thickness=1.f, unsigned int subdivisions=10)
 Draws the outline of a Cubesphere in 3D space. More...
 
void FillSphere (const Color4 &color, const Vector3 &position, float radius, uint sectors=10, uint stacks=10)
 Draws a solid Sphere in 3D space. More...
 
void FillSphere (const Color4 &color, const Sphere &sphere, uint sectors=10, uint stacks=10)
 Draws a solid Sphere in 3D space. More...
 
void FillIcosphere (const Color4 &color, const Vector3 &position, float radius, unsigned int subdivisions=10)
 Draws a solid Icosphere in 3D space. More...
 
void FillIcosphere (const Color4 &color, const Sphere &sphere, unsigned int subdivisions=10)
 Draws a solid Icosphere in 3D space. More...
 
void FillCubesphere (const Color4 &color, const Vector3 &position, float radius, unsigned int subdivisions=10)
 Draws a solid Cubesphere in 3D space. More...
 
void FillCubesphere (const Color4 &color, const Sphere &sphere, unsigned int subdivisions=10)
 Draws a solid Cubesphere in 3D space. More...
 
void WireframeAABB (const Color4 &color, const Vector3 &pos, const Vector3 &radii, float thickness=1.f)
 Draws an outline of an axis-aligned bounding box in 3D space. More...
 
void WireframeAABB (const Color4 &color, const AABB &aabb, float thickness=1.f)
 Draws an outline of an axis-aligned bounding box in 3D space. More...
 
void FillAABB (const Color4 &color, const Vector3 &pos, const Vector3 &radii)
 Draws a solid axis-aligned bounding box in 3D space. More...
 
void FillAABB (const Color4 &color, const AABB &aabb)
 Draws a solid axis-aligned bounding box in 3D space. More...
 
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. More...
 
void WireframeOBB (const Color4 &color, const OBB &obb, float thickness=1.f)
 Draws an outline of an oriented bounding box in 3D space. More...
 
void FillOBB (const Color4 &color, const Vector3 &position, const Vector3 &radii, const EulerAngle &orientation)
 Draws an outline of an oriented bounding box in 3D space. More...
 
void FillOBB (const Color4 &color, const OBB &obb)
 Draws an outline of an oriented bounding box in 3D space. More...
 
void WireframeCylinder ()
 
void FillCylinder ()
 
void WireframePrism ()
 
void FillPrism ()
 
void WireframePipe ()
 
void FillPipe ()
 
void WireframeCone ()
 
void FillCone ()
 
void WireframeTorus ()
 
void FillTorus ()
 
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)
 
void WireframeTriangleMesh (const Color3 &color, const TriangleMesh &mesh, float thickness=1.f)
 
void DrawString (const Color4 &color, const std::string &text, const Vector3 &pos, float scale, u32 size, const Font &font, const EulerAngle &angle={0, 0, 0}, bool draw_back_face=false)
 Draws a string of text in 3D space, with an arbitrary rotation. More...
 
void DrawBillboardString ()
 Draws a string of text in 3D space that is always facing the exact direction of the camera projection. More...
 
void DrawBillboardSprite ()
 Draws a texture sprite in 3D space that is always facing the exact direction of the camera projection. More...
 
void DrawSprite ()
 
void DrawMatrixGizmo (const Matrix3x3 &, const Vector3 &)
 
void DrawMatrixGizmo (const Matrix4x4 &)
 
void DrawAxisAngleGizmo (const AxisAngle &, const Vector3 &)
 
void DrawQuaternionGizmo (const Quaternion &, const Vector3 &)
 

Detailed Description

Drawing functions for primitive 3D Shapes.

Function Documentation

◆ Begin()

void JGL::J3D::Begin ( )

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.
Here is the call graph for this function:

◆ ChangeFarPlane()

void JGL::J3D::ChangeFarPlane ( float  far_plane)

Helper function to change the far-plane, which is the cutoff distance for rendering.

◆ ChangeFOV()

void JGL::J3D::ChangeFOV ( float  fov)

Helper function to conveniently change the Field-Of-View.

◆ DrawAxisAngleGizmo()

void JGL::J3D::DrawAxisAngleGizmo ( const AxisAngle &  ,
const Vector3 &   
)

◆ DrawBillboardSprite()

void JGL::J3D::DrawBillboardSprite ( )

Draws a texture sprite in 3D space that is always facing the exact direction of the camera projection.

◆ DrawBillboardString()

void JGL::J3D::DrawBillboardString ( )

Draws a string of text in 3D space that is always facing the exact direction of the camera projection.

◆ DrawCubicBezierCurve()

void JGL::J3D::DrawCubicBezierCurve ( const Color4 &  color,
const Vector3 &  controlA,
const Vector3 &  pointA,
const Vector3 &  pointB,
const Vector3 &  controlB,
int  subdivisions = 10,
float  thickness = 1 
)

Draws a smooth, curved line segment between two control points, with the curve controlled by the two inner points.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
controlAThe first control point, which can be considered the start of the line.
pointAThe first inner point, which controls the contour of the curve.
pointBThe second inner point, which controls the contour of the curve.
controlBThe second control point, which can be considered the end of the line.
subdivisionsThe accuracy of the approximation of the curve, measured in iteration steps taken.
thicknessThe line-width to draw the curve with.
See also
J3ML::Algorithm::Bezier
Here is the call graph for this function:

◆ DrawLine()

void JGL::J3D::DrawLine ( const Color4 &  color,
const Vector3 &  A,
const Vector3 &  B,
float  thickness = 1.f 
)

Draws a line in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
AThe start-point of the line segment.
BThe end-point of the line segment.
thicknessThe line-width to draw the line segment with.

◆ DrawMatrixGizmo() [1/2]

void JGL::J3D::DrawMatrixGizmo ( const Matrix3x3 &  ,
const Vector3 &   
)

◆ DrawMatrixGizmo() [2/2]

void JGL::J3D::DrawMatrixGizmo ( const Matrix4x4 &  )

◆ DrawQuaternionGizmo()

void JGL::J3D::DrawQuaternionGizmo ( const Quaternion &  ,
const Vector3 &   
)

◆ DrawSprite()

void JGL::J3D::DrawSprite ( )

◆ DrawString()

void JGL::J3D::DrawString ( const Color4 &  color,
const std::string &  text,
const Vector3 &  pos,
float  scale,
u32  size,
const Font font,
const EulerAngle &  angle = {0, 0, 0},
bool  draw_back_face = false 
)

Draws a string of text in 3D space, with an arbitrary rotation.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
textThe content to display on the screen.
posThe position in 3D space to display the text.
scaleThe scaling factor to render the text with, 1 being default. TODO: Vector2 scaling?
sizeThe pixel size to rasterize the font with.
fontThe font object to use when drawing.
angleThe orientation in 3D space.
draw_back_face
Here is the call graph for this function:

◆ End()

void JGL::J3D::End ( )

Closes a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL).

See also
Begin().

◆ FillAABB() [1/2]

void JGL::J3D::FillAABB ( const Color4 &  color,
const AABB &  aabb 
)

Draws a solid axis-aligned bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
aabbThe AABB object to visualize.
Here is the call graph for this function:

◆ FillAABB() [2/2]

void JGL::J3D::FillAABB ( const Color4 &  color,
const Vector3 &  pos,
const Vector3 &  radii 
)

Draws a solid axis-aligned bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe point in 3D space that is the center of the AABB.
radiiThe radii along x,y,z axes to size the bounding box.
Here is the caller graph for this function:

◆ FillCapsule()

void JGL::J3D::FillCapsule ( const Color3 &  color,
const Capsule &  capsule 
)

◆ FillCone()

void JGL::J3D::FillCone ( )

◆ FillCubesphere() [1/2]

void JGL::J3D::FillCubesphere ( 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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
sphereThe mathematically-defined sphere object to be rendered.
subdivisionsThe accuracy of the approximation of the Cubesphere, measured in iteration steps taken.

◆ FillCubesphere() [2/2]

void JGL::J3D::FillCubesphere ( const Color4 &  color,
const Vector3 &  position,
float  radius,
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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Sphere.
radiusThe size to draw the Sphere at.
subdivisionsThe accuracy of the approximation of the Cubesphere, measured in iteration steps taken.

◆ FillCylinder()

void JGL::J3D::FillCylinder ( )

◆ FillIcosahedron()

void JGL::J3D::FillIcosahedron ( const Color4 &  color,
const Vector3 &  position,
float  radius 
)

Draws a solid Icosahedron in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Icosahedron.
radiusThe size to draw the Icosahedron at.

◆ FillIcosphere() [1/2]

void JGL::J3D::FillIcosphere ( const Color4 &  color,
const Sphere &  sphere,
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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
sphereThe mathematically-defined sphere object to be rendered.
subdivisionsThe accuracy of the approximation of the Cubesphere, measured in iteration steps taken.

◆ FillIcosphere() [2/2]

void JGL::J3D::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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Sphere.
radiusThe size to draw the Sphere at.
subdivisionsThe accuracy of the approximation of the Cubesphere, measured in iteration steps taken.

◆ FillOBB() [1/2]

void JGL::J3D::FillOBB ( const Color4 &  color,
const OBB &  obb 
)

Draws an outline of an oriented bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
obbThe oriented-bounding-box object to visualize.

◆ FillOBB() [2/2]

void JGL::J3D::FillOBB ( const Color4 &  color,
const Vector3 &  position,
const Vector3 &  radii,
const EulerAngle &  orientation 
)

Draws an outline of an oriented bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe center-position of the oriented bounding box.
radiiThe radii along x,y,z axes to size the bounding box.
orientationThe rotation in 3D space of the OBB.

◆ FillPipe()

void JGL::J3D::FillPipe ( )

◆ FillPrism()

void JGL::J3D::FillPrism ( )

◆ FillSphere() [1/2]

void JGL::J3D::FillSphere ( const Color4 &  color,
const Sphere &  sphere,
uint  sectors = 10,
uint  stacks = 10 
)

Draws a solid Sphere in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
sphereThe mathematically-defined sphere object to be rendered.
sectorsThe amount of latitudinal subdivisions to perform when computing the sphere.
stacksThe amount of longitudinal subdivisions to perform when computing the sphere.

◆ FillSphere() [2/2]

void JGL::J3D::FillSphere ( const Color4 &  color,
const Vector3 &  position,
float  radius,
uint  sectors = 10,
uint  stacks = 10 
)

Draws a solid Sphere in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Sphere.
radiusThe size to draw the Sphere at.
sectorsThe amount of latitudinal subdivisions to perform when computing the sphere.
stacksThe amount of longitudinal subdivisions to perform when computing the sphere.

◆ FillTorus()

void JGL::J3D::FillTorus ( )

◆ FillTriangleMesh()

void JGL::J3D::FillTriangleMesh ( const Color3 &  color,
const TriangleMesh &  mesh 
)

◆ Init()

void JGL::J3D::Init ( const Vector2 &  window_size,
float  fov,
float  far_plane 
)

Initializes internals for 3D rendering. Probably will be rethought later.

◆ SetMatrix()

void JGL::J3D::SetMatrix ( const std::vector< GLfloat > &  matrix,
const Vector2 &  window_size 
)

◆ WireframeAABB() [1/2]

void JGL::J3D::WireframeAABB ( const Color4 &  color,
const AABB &  aabb,
float  thickness = 1.f 
)

Draws an outline of an axis-aligned bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
aabbThe AABB object to render.
Here is the call graph for this function:

◆ WireframeAABB() [2/2]

void JGL::J3D::WireframeAABB ( const Color4 &  color,
const Vector3 &  pos,
const Vector3 &  radii,
float  thickness = 1.f 
)

Draws an outline of an axis-aligned bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe point in 3D space that is the center of the AABB.
radiiThe radii along x,y,z axes to size the bounding box.
thicknessThe line-width to draw the Icosphere outline with.
Here is the caller graph for this function:

◆ WireframeCapsule()

void JGL::J3D::WireframeCapsule ( const Color3 &  color,
const Capsule &  cap,
float  thickness = 1.f 
)

◆ WireframeCone()

void JGL::J3D::WireframeCone ( )

◆ WireframeCubesphere() [1/2]

void JGL::J3D::WireframeCubesphere ( 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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
sphereThe mathematically-defined sphere object to be rendered.
thicknessThe line-width to draw the Cubesphere outline with.
subdivisionsThe accuracy of the approximation of the Cubesphere, measured in iteration steps taken.

◆ WireframeCubesphere() [2/2]

void JGL::J3D::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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Sphere.
radiusThe size to draw the Sphere at.
thicknessThe line-width to draw the Cubesphere outline with.
subdivisionsThe accuracy of the approximation of the Cubesphere, measured in iteration steps taken.

◆ WireframeCylinder()

void JGL::J3D::WireframeCylinder ( )

◆ WireframeIcosahedron()

void JGL::J3D::WireframeIcosahedron ( const Color4 &  color,
const Vector3 &  position,
float  radius,
float  thickness = 1.f 
)

Draws the outline of an Icosahedron in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Icosahedron.
radiusThe size to draw the Icosahedron at.
thicknessThe line-width to draw the Icosahedron outline with.

◆ WireframeIcosphere() [1/2]

void JGL::J3D::WireframeIcosphere ( const Color4 &  color,
const Sphere &  sphere,
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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
sphereThe mathematically-defined sphere object to be rendered.
thicknessThe line-width to draw the Icosphere outline with.
subdivisionsThe accuracy of the approximation of the Icosphere, measured in iteration steps taken.

◆ WireframeIcosphere() [2/2]

void JGL::J3D::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.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Sphere.
radiusThe size to draw the Sphere at.
thicknessThe line-width to draw the Icosahedron outline with.
subdivisionsThe accuracy of the approximation of the Icosphere, measured in iteration steps taken.

◆ WireframeOBB() [1/2]

void JGL::J3D::WireframeOBB ( const Color4 &  color,
const OBB &  obb,
float  thickness = 1.f 
)

Draws an outline of an oriented bounding box in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
obbThe OBB object to visualize.
thicknessThe line-width to draw the OBB outline with.

◆ WireframeOBB() [2/2]

void JGL::J3D::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.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space that is the center of the AABB.
radiiThe radii along x,y,z axes to size the bounding box.
orientationThe rotation in 3D space of the OBB.
thicknessThe line-width to draw the OBB outline with.

◆ WireframePipe()

void JGL::J3D::WireframePipe ( )

◆ WireframePrism()

void JGL::J3D::WireframePrism ( )

◆ WireframeSphere() [1/2]

void JGL::J3D::WireframeSphere ( const Color4 &  color,
const Sphere &  sphere,
float  thickness = 1.f,
uint  sectors = 10,
uint  stacks = 10 
)

Draws the outline of a Sphere in 3D space.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
sphereThe mathematically-defined sphere object to be rendered.
thicknessThe line-width to draw the Icosahedron outline with.
sectorsThe amount of latitudinal subdivisions to perform when computing the sphere.
stacksThe amount of longitudinal subdivisions to perform when computing the sphere.
Here is the call graph for this function:

◆ WireframeSphere() [2/2]

void JGL::J3D::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.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
positionThe point in 3D space at which to draw the Sphere.
radiusThe size to draw the Sphere at.
thicknessThe line-width to draw the Icosahedron outline with.
sectorsThe amount of latitudinal subdivisions to perform when computing the sphere.
stacksThe amount of longitudinal subdivisions to perform when computing the sphere.
Here is the caller graph for this function:

◆ WireframeTorus()

void JGL::J3D::WireframeTorus ( )

◆ WireframeTriangleMesh()

void JGL::J3D::WireframeTriangleMesh ( const Color3 &  color,
const TriangleMesh &  mesh,
float  thickness = 1.f 
)