.. _stdlib_debug_render: ============ Debug render ============ This module provides functionality for rendering debug primitives. It includes data structures for representing debug primitives, as well as functions for drawing them. To use this module, include the following line in your project file:: require engine.render.debug_render // or require engine.core ++++++++++++ Type aliases ++++++++++++ .. _alias-DebugDrawFlags: .. das:attribute:: bitfield DebugDrawFlags :Fields: * **ZTest** (0x1) - Enable z-test, so debug lines will be occluded by opaque geometry * **HideInGame** (0x2) - Hide debug lines game view. They're always visible in scene view +++++++++ Functions +++++++++ * :ref:`draw_line (begin: float3; end: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_line (nodeId: NodeId; begin: float3; end: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_ray (ray: Ray; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_ray (nodeId: NodeId; ray: Ray; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_ray (origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_ray (nodeId: NodeId; origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_sphere (center: float3; radius: float; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_sphere (nodeId: NodeId; center: float3; radius: float; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_sphere (sphere: BSphere3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_sphere (nodeId: NodeId; sphere: BSphere3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (nodeId: NodeId; min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (nodeId: NodeId; box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (tm: float3x4; min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (nodeId: NodeId; tm: float3x4; min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (tm: float3x4; box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_box (nodeId: NodeId; tm: float3x4; box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) ` * :ref:`draw_text (text: string; position: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 10; font_size: float = 16f) ` .. _function-debug_render_draw_line_float3_float3_float4_int_DebugDrawFlags: .. das:function:: draw_line(begin: float3; end: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug line. :Arguments: * **begin** : float3 - the starting point of the debug line * **end** : float3 - the ending point of the debug line * **color** : float4 - the color of the debug line * **frames** : int - the number of frames to render the debug line * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` 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) .. _function-debug_render_draw_line_NodeId_float3_float3_float4_int_DebugDrawFlags: .. das:function:: draw_line(nodeId: NodeId; begin: float3; end: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug line. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug line transformation matrix is calculated * **begin** : float3 - the starting point of the debug line * **end** : float3 - the ending point of the debug line * **color** : float4 - the color of the debug line * **frames** : int - the number of frames to render the debug line * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` 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 .. _function-debug_render_draw_ray_Ray_float_float4_int_DebugDrawFlags: .. das:function:: draw_ray(ray: Ray; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug ray. :Arguments: * **ray** : :ref:`Ray ` - the ray to draw * **length** : float - the length of the debug ray * **color** : float4 - the color of the debug ray * **frames** : int - the number of frames to render the debug ray * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` 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 .. _function-debug_render_draw_ray_NodeId_Ray_float_float4_int_DebugDrawFlags: .. das:function:: draw_ray(nodeId: NodeId; ray: Ray; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug ray. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug ray transformation matrix is calculated * **ray** : :ref:`Ray ` - the ray to draw * **length** : float - the length of the debug ray * **color** : float4 - the color of the debug ray * **frames** : int - the number of frames to render the debug ray * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` 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 .. _function-debug_render_draw_ray_float3_float3_float_float4_int_DebugDrawFlags: .. das:function:: draw_ray(origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug ray. :Arguments: * **origin** : float3 - the origin of the debug ray * **direction** : float3 - the direction of the debug ray * **length** : float - the length of the debug ray * **color** : float4 - the color of the debug ray * **frames** : int - the number of frames to render the debug ray * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` 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 .. _function-debug_render_draw_ray_NodeId_float3_float3_float_float4_int_DebugDrawFlags: .. das:function:: draw_ray(nodeId: NodeId; origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug ray. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug ray transformation matrix is calculated * **origin** : float3 - the origin of the debug ray * **direction** : float3 - the direction of the debug ray * **length** : float - the length of the debug ray * **color** : float4 - the color of the debug ray * **frames** : int - the number of frames to render the debug ray * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` 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 .. _function-debug_render_draw_sphere_float3_float_float4_int_int_DebugDrawFlags: .. das:function:: draw_sphere(center: float3; radius: float; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug sphere. :Arguments: * **center** : float3 - the center position of the debug sphere * **radius** : float - the radius of the debug sphere * **color** : float4 - the color of the debug sphere * **frames** : int - the number of frames to render the debug sphere * **segments** : int - the number of segments to render the debug sphere * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_sphere(float3(0), 1., float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1 .. _function-debug_render_draw_sphere_NodeId_float3_float_float4_int_int_DebugDrawFlags: .. das:function:: draw_sphere(nodeId: NodeId; center: float3; radius: float; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug sphere. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug sphere transformation matrix is calculated * **center** : float3 - the center position of the debug sphere * **radius** : float - the radius of the debug sphere * **color** : float4 - the color of the debug sphere * **frames** : int - the number of frames to render the debug sphere * **segments** : int - the number of segments to render the debug sphere * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_sphere(nodeId, float3(0), 1., float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1 aligned with the transformation matrix of the node .. _function-debug_render_draw_sphere_BSphere3D_float4_int_int_DebugDrawFlags: .. das:function:: draw_sphere(sphere: BSphere3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug sphere. :Arguments: * **sphere** : :ref:`BSphere3D ` - the bounding sphere to draw * **color** : float4 - the color of the debug sphere * **frames** : int - the number of frames to render the debug sphere * **segments** : int - the number of segments to render the debug sphere * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_sphere(BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1 .. _function-debug_render_draw_sphere_NodeId_BSphere3D_float4_int_int_DebugDrawFlags: .. das:function:: draw_sphere(nodeId: NodeId; sphere: BSphere3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug sphere. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug sphere transformation matrix is calculated * **sphere** : :ref:`BSphere3D ` - the bounding sphere to draw * **color** : float4 - the color of the debug sphere * **frames** : int - the number of frames to render the debug sphere * **segments** : int - the number of segments to render the debug sphere * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_sphere(nodeId, BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1 aligned with the transformation matrix of the node .. _function-debug_render_draw_box_float3_float3_float4_int_DebugDrawFlags: .. das:function:: draw_box(min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box. :Arguments: * **min** : float3 - the minimum point of the debug box * **max** : float3 - the maximum point of the debug box * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) .. _function-debug_render_draw_box_NodeId_float3_float3_float4_int_DebugDrawFlags: .. das:function:: draw_box(nodeId: NodeId; min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug box transformation matrix is calculated * **min** : float3 - the minimum point of the debug box * **max** : float3 - the maximum point of the debug box * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(nodeId, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) aligned with the transformation matrix of the node .. _function-debug_render_draw_box_BBox3D_float4_int_DebugDrawFlags: .. das:function:: draw_box(box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box. :Arguments: * **box** : :ref:`BBox3D ` - the bounding box to draw * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(BBox3D(float3(0), float3(1))) // Draws a red box from (0, 0, 0) to (1, 1, 1) .. _function-debug_render_draw_box_NodeId_BBox3D_float4_int_DebugDrawFlags: .. das:function:: draw_box(nodeId: NodeId; box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug box transformation matrix is calculated * **box** : :ref:`BBox3D ` - the bounding box to draw * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(nodeId, BBox3D(float3(0), float3(1))) // Draws a red box from (0, 0, 0) to (1, 1, 1) aligned with the transformation matrix of the node .. _function-debug_render_draw_box_float3x4_float3_float3_float4_int_DebugDrawFlags: .. das:function:: draw_box(tm: float3x4; min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box aligned with the given transformation matrix. :Arguments: * **tm** : :ref:`float3x4 ` - the transformation matrix of the debug box * **min** : float3 - the minimum point of the debug box * **max** : float3 - the maximum point of the debug box * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(nodeId.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node .. _function-debug_render_draw_box_NodeId_float3x4_float3_float3_float4_int_DebugDrawFlags: .. das:function:: draw_box(nodeId: NodeId; tm: float3x4; min: float3; max: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box aligned with the given transformation matrix. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug box transformation matrix is calculated * **tm** : :ref:`float3x4 ` - the transformation matrix of the debug box * **min** : float3 - the minimum point of the debug box * **max** : float3 - the maximum point of the debug box * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(node1, node2.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red 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) .. _function-debug_render_draw_box_float3x4_BBox3D_float4_int_DebugDrawFlags: .. das:function:: draw_box(tm: float3x4; box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box aligned with the given transformation matrix. :Arguments: * **tm** : :ref:`float3x4 ` - the transformation matrix of the debug box * **box** : :ref:`BBox3D ` - the bounding box to draw * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(nodeId.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node .. _function-debug_render_draw_box_NodeId_float3x4_BBox3D_float4_int_DebugDrawFlags: .. das:function:: draw_box(nodeId: NodeId; tm: float3x4; box: BBox3D; color: float4 = float4(1f,1f,1f,1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0)) Draws a debug box aligned with the given transformation matrix. :Arguments: * **nodeId** : :ref:`NodeId ` - the id of the node against which the debug box transformation matrix is calculated * **tm** : :ref:`float3x4 ` - the transformation matrix of the debug box * **box** : :ref:`BBox3D ` - the bounding box to draw * **color** : float4 - the color of the debug box * **frames** : int - the number of frames to render the debug box * **flags** : :ref:`DebugDrawFlags ` - debug rendering flags, see ``DebugDrawFlags`` description Usage example:: draw_box(node1, node2.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red 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) .. _function-debug_render_draw_text_string_float3_float4_int_float: .. das:function:: draw_text(text: string; position: float3; color: float4 = float4(1f,1f,1f,1f); frames: int = 10; font_size: float = 16f) Draws a debug text. :Arguments: * **text** : string - the text to draw * **position** : float3 - the position of the debug text * **color** : float4 - the color of the debug text * **frames** : int - the number of frames to render the debug text * **font_size** : float - the font size of the debug text Usage example:: draw_text("Hello, World!", float3(0), float4(1, 0, 0, 1)) // Draws "Hello, World!" in red at (0, 0, 0)