Debug render
This module provides functionality for rendering debug primitives. It includes data structures for representing the primitives, as well as functions for drawing them.
Note
The primitives are similar to those in module wireframe_render. Debug primitives only work in the editor (either in scene view or both in scene view and game view) and are not visible in the actual game; by default they are visible only in the scene view, but you can make them appear in the game view as well by enabling the corresponding option in editor Preferences.
To use this module, include the following line in your project file:
require engine.render.debug_render // or require engine.core
Functions
- draw_debug_line(begin: float3; end: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe line visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_line(float3(0), float3(1, 0, 0), float4(1, 0, 0, 1)) // Draws a red line visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_line(nodeId, float3(0), float3(1, 0, 0), float4(1, 0, 0, 1)) // Draws a red line visible only in editor, aligned with the node
- draw_debug_ray(ray: Ray; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe ray visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_ray(Ray(float3(0), float3(1, 0, 0)), 2., float4(1, 0, 0, 1)) // Draws a red ray visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_ray(nodeId, Ray(float3(0), float3(1, 0, 0)), 2., float4(1, 0, 0, 1)) // Draws a red ray visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_ray(float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_ray(nodeId, float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_sphere(float3(0), 1., float4(1, 0, 0, 1)) // Draws a red wireframe sphere visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_sphere(nodeId, float3(0), 1., float4(1, 0, 0, 1)) // Draws a red wireframe sphere visible only in editor
- draw_debug_sphere(sphere: BSphere3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe sphere visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_sphere(BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red wireframe sphere visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_sphere(nodeId, BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red wireframe sphere visible only in editor
- draw_debug_box(min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe box visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box visible only in editor
- draw_debug_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 visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(nodeId, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box visible only in editor
- draw_debug_box(box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe box visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(BBox3D(float3(0), float3(1))) // Draws a wireframe box visible only in editor
- draw_debug_box(nodeId: NodeId; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe box visible only in the editor (not in game).
- 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(nodeId, BBox3D(float3(0), float3(1))) // Draws a wireframe box visible only in editor
- draw_debug_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 visible only in the editor (not in game), 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(nodeId.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box visible only in editor
- draw_debug_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 visible only in the editor (not in game), 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(node1, node2.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red wireframe box visible only in editor
- draw_debug_box(tm: float3x4; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: WireframeDrawFlags = bitfield(0x0))
Draws a wireframe box visible only in the editor (not in game), 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(nodeId.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red wireframe box visible only in editor
- draw_debug_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 visible only in the editor (not in game), 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
WireframeDrawFlagsdescription
Usage example:
draw_debug_box(node1, node2.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red wireframe box visible only in editor
- draw_debug_text(text: string; position: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 10; font_size: float = 16f)
Draws text in 3D space visible only in the editor (not in game).
..note :: Unlike other debug drawing functions, text drawn with this function is always visible in editor’s game view, editing editor preferences won’t affect its visibility. However, it won’t be visible in actual game, just like other debug drawing functions.
- Arguments:
text : string - the text to draw
position : float3 - the position of the text
color : float4 - the color of the text
frames : int - the number of frames to render the text
font_size : float - the font size of the text
Usage example:
draw_debug_text("Hello, World!", float3(0), float4(1, 0, 0, 1)) // Draws "Hello, World!" in red at (0, 0, 0) visible only in editor