Wireframe render

This module provides functionality for rendering wireframe primitives. It includes data structures for representing the primitives, as well as functions for drawing them.

To use this module, include the following line in your project file:

require engine.render.wireframe_render // or require engine.core

Type aliases

bitfield WireframeDrawFlags
Fields:
  • ZTest (0x1) - Enable z-test, so debug lines will be occluded by opaque geometry

Functions

draw_line(begin: float3; end: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe line.

Arguments:
  • begin : float3 - the starting point of the line

  • end : float3 - the ending point of the line

  • color : float4 - the color of the line

  • frames : int - the number of frames to render the line

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_line(float3(0), float3(1, 0, 0), float4(1, 0, 0, 1)) // Draws a red line from (0, 0, 0) to (1, 0, 0)
draw_line(nodeId: NodeId; begin: float3; end: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe line.

Arguments:
  • nodeId : NodeId - the id of the node against which the line transformation matrix is calculated

  • begin : float3 - the starting point of the line

  • end : float3 - the ending point of the line

  • color : float4 - the color of the line

  • frames : int - the number of frames to render the line

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_line(nodeId, float3(0), float3(1, 0, 0), float4(1, 0, 0, 1)) // Draws a red line from (0, 0, 0) to (1, 0, 0) aligned with the transformation matrix of the node
draw_ray(ray: Ray; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe ray.

Arguments:
  • ray : Ray - the ray to draw

  • length : float - the length of the ray

  • color : float4 - the color of the ray

  • frames : int - the number of frames to render the ray

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_ray(float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2
draw_ray(nodeId: NodeId; ray: Ray; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe ray.

Arguments:
  • nodeId : NodeId - the id of the node against which the ray transformation matrix is calculated

  • ray : Ray - the ray to draw

  • length : float - the length of the ray

  • color : float4 - the color of the ray

  • frames : int - the number of frames to render the ray

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_ray(nodeId, float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2 aligned with the transformation matrix of the node
draw_ray(origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe ray.

Arguments:
  • origin : float3 - the origin of the ray

  • direction : float3 - the direction of the ray

  • length : float - the length of the ray

  • color : float4 - the color of the ray

  • frames : int - the number of frames to render the ray

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_ray(float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2
draw_ray(nodeId: NodeId; origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe ray.

Arguments:
  • nodeId : NodeId - the id of the node against which the ray transformation matrix is calculated

  • origin : float3 - the origin of the ray

  • direction : float3 - the direction of the ray

  • length : float - the length of the ray

  • color : float4 - the color of the ray

  • frames : int - the number of frames to render the ray

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_ray(nodeId, float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2 aligned with the transformation matrix of the node
draw_sphere(center: float3; radius: float; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe sphere.

Arguments:
  • center : float3 - the center position of the sphere

  • radius : float - the radius of the sphere

  • color : float4 - the color of the sphere

  • frames : int - the number of frames to render the sphere

  • segments : int - the number of segments to render the sphere

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_sphere(float3(0), 1., float4(1, 0, 0, 1)) // Draws a red wireframe sphere at (0, 0, 0) with radius 1
draw_sphere(nodeId: NodeId; center: float3; radius: float; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe sphere.

Arguments:
  • nodeId : NodeId - the id of the node against which the sphere transformation matrix is calculated

  • center : float3 - the center position of the sphere

  • radius : float - the radius of the sphere

  • color : float4 - the color of the sphere

  • frames : int - the number of frames to render the sphere

  • segments : int - the number of segments to render the sphere

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_sphere(nodeId, float3(0), 1., float4(1, 0, 0, 1)) // Draws a red wireframe sphere at (0, 0, 0) with radius 1 aligned with the transformation matrix of the node
draw_sphere(sphere: BSphere3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe sphere.

Arguments:
  • sphere : BSphere3D - the bounding sphere to draw

  • color : float4 - the color of the sphere

  • frames : int - the number of frames to render the sphere

  • segments : int - the number of segments to render the sphere

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_sphere(BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red wireframe sphere at (0, 0, 0) with radius 1
draw_sphere(nodeId: NodeId; sphere: BSphere3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe sphere.

Arguments:
  • nodeId : NodeId - the id of the node against which the sphere transformation matrix is calculated

  • sphere : BSphere3D - the bounding sphere to draw

  • color : float4 - the color of the sphere

  • frames : int - the number of frames to render the sphere

  • segments : int - the number of segments to render the sphere

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_sphere(nodeId, BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red wireframe sphere at (0, 0, 0) with radius 1 aligned with the transformation matrix of the node
draw_box(min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box.

Arguments:
  • min : float3 - the minimum point of the box

  • max : float3 - the maximum point of the box

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box from (0, 0, 0) to (1, 1, 1)
draw_box(nodeId: NodeId; min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box.

Arguments:
  • nodeId : NodeId - the id of the node against which the box transformation matrix is calculated

  • min : float3 - the minimum point of the box

  • max : float3 - the maximum point of the box

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(nodeId, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box from (0, 0, 0) to (1, 1, 1) aligned with the transformation matrix of the node
draw_box(box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box.

Arguments:
  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(BBox3D(float3(0), float3(1))) // Draws a wireframe box from (0, 0, 0) to (1, 1, 1)
draw_box(nodeId: NodeId; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box.

Arguments:
  • nodeId : NodeId - the id of the node against which the box transformation matrix is calculated

  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(nodeId, BBox3D(float3(0), float3(1))) // Draws a wireframe box from (0, 0, 0) to (1, 1, 1) aligned with the transformation matrix of the node
draw_box(tm: float3x4; min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box aligned with the given transformation matrix.

Arguments:
  • tm : float3x4 - the transformation matrix of the box

  • min : float3 - the minimum point of the box

  • max : float3 - the maximum point of the box

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(nodeId.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node
draw_box(nodeId: NodeId; tm: float3x4; min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box aligned with the given transformation matrix.

Arguments:
  • nodeId : NodeId - the id of the node against which the box transformation matrix is calculated

  • tm : float3x4 - the transformation matrix of the box

  • min : float3 - the minimum point of the box

  • max : float3 - the maximum point of the box

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(node1, node2.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node2 and aligned with the transformation matrix of the node1 (the matrices are multiplied)
draw_box(tm: float3x4; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box aligned with the given transformation matrix.

Arguments:
  • tm : float3x4 - the transformation matrix of the box

  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(nodeId.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red wireframe box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node
draw_box(nodeId: NodeId; tm: float3x4; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))

Draws a wireframe box aligned with the given transformation matrix.

Arguments:
  • nodeId : NodeId - the id of the node against which the box transformation matrix is calculated

  • tm : float3x4 - the transformation matrix of the box

  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the box

  • frames : int - the number of frames to render the box

  • flags : WireframeDrawFlags - rendering flags, see WireframeDrawFlags description

Usage example:

draw_box(node1, node2.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red wireframe box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node2 and aligned with the transformation matrix of the node1 (the matrices are multiplied)