Draw3D
Info
Dependencies:
- PermMem
- HookEngine
Implementation:
 Draw3D.d on GitHub
This package allows you to draw various shapes (such as lines or bounding boxes) in three-dimensional space. This makes debugging visualizations of coordinates in the world possible.
Initialization
Initialize with LeGo_Draw3D flag.
Functions
Line
DrawLine
DrawLine
Creates and draws a new line and returns its handle.
- var int startPosPtr
 Pointer to the float array with world coordinates of the starting point of the line
- var int endPosPtr
 Pointer to the float array with world coordinates of the ending point of the line
- var int color
 Color of the line as- zCOLOR
Return value
The function returns a new PermMem handle to the line.
DrawLine3
DrawLine3
DrawLine, but with world coordinates as parameters, instead of zVEC3 pointers.
- var int x1, y1, z1
 X, Y, and Z coordinates of the starting point of the line
- var int x2, y2, z2
 X, Y, and Z coordinates of the ending point of the line
- var int color
 Color of the line as- zCOLOR
Return value
The function returns a new PermMem handle to the line.
DrawLineAddr
DrawLineAddr
DrawLine, but with the address of a line as parameter.
- var int linePtr
 Pointer to the float array array with six values (startAndEndPos[6])
- var int color
 Color of the line as- zCOLOR
Return value
The function returns a new PermMem handle to the line.
UpdateLine
UpdateLine
Changes the coordinates of a specific line.
- var int hndl
 Handle returned from- DrawLine
- var int startPosPtr
 Pointer to an integer float array with world coordinates of the starting point of the line
- var int endPosPtr
 Pointer to an integer float array with world coordinates of the ending point of the line
UpdateLine3
UpdateLine3
UpdateLine, but with world coordinates as parameters, instead of zVEC3 pointers.
- var int hndl
 Handle returned from- DrawLine
- var int x1, y1, z1
 X, Y, and Z coordinates of the starting point of the line
- var int x2, y2, z2
 X, Y, and Z coordinates of the ending point of the line
UpdateLineAddr
UpdateLineAddr
UpdateLine, but with the address of a line as parameter.
- var int hndl
 Handle returned from- DrawLine
- var int linePtr
 Pointer to an integer float array with six values (startAndEndPos[6])
SetLineColor
SetLineColor
Changes the color of a specific line.
EraseLine
EraseLine
Deletes a line from the world and the handle.
- var int hndl
 Handle returned from- DrawLine
LineVisible
LineVisible
Returns whether a line is visible.
- var int hndl
 Handle returned from- DrawLine
Return value
The function returns TRUE if the line is visible/displayed. FALSE is returned otherwise.
ShowLine
HideLine
ToggleLine
ToggleLine
Changes the visibility of a line. If displayed - hide, if hidden - display.
- var int hndl
 Handle returned from- DrawLine
Sphere
DrawSphere
DrawSphere
Creates and draws a new sphere (visualized as a circle) and returns its handle.
- var int centerPosPtr
 Pointer to an integer float array with world coordinates of the sphere's center (- centerPos[3])
- var int radius
 Radius of the sphere as an integer float
- var int color
 Color of the sphere as- zCOLOR
Return value
The function returns a new PermMem handle to the sphere.
DrawSphere3
DrawSphere3
DrawSphere, but with world coordinates as parameters, instead of zVEC3 pointers.
- var int x1, y1, z1
 World coordinates of the sphere's center
- var int radius
 Radius of the sphere as an integer float
- var int color
 Color of the sphere as- zCOLOR
Return value
The function returns a new PermMem handle to the sphere.
DrawSphereAddr
DrawSphereAddr
DrawSphere, but with the address of a sphere as a parameter.
- var int spherePtr
 Pointer to a- zTBSphere3Dstructure
- var int color
 Color of the sphere as- zCOLOR
Return value
The function returns a new PermMem handle to the sphere.
UpdateSphere
UpdateSphere
Changes the coordinates and/or size of an existing sphere.
- var int hndl
 Handle returned from- DrawSphere
- var int centerPosPtr
 Pointer to an integer float array with world coordinates of the sphere's center (- centerPos[3])
- var int radius
 Radius of the sphere as an integer float
UpdateSphere3
UpdateSphere3
UpdateSphere, but with world coordinates as parameters, instead of zVEC3 pointers.
- var int hndl
 Handle returned from- DrawSphere
- var int x1, y1, z1
 World coordinates of the sphere's center
- var int radius
 Radius of the sphere as an integer float
UpdateSphereAddr
UpdateSphereAddr
UpdateSphere, but with the address of a sphere as a parameter.
- var int hndl
 Handle returned from- DrawSphere
- var int spherePtr
 Pointer to a- zTBSphere3Dstructure
SetSphereColor
SetSphereColor
Changes the color of a specific sphere.
- var int hndl
 Handle returned from- DrawSphere
- var int color
 New color of the sphere as- zCOLOR
EraseSphere
EraseSphere
Deletes a sphere from the world and its handle.
- var int hndl
 Handle returned from- DrawSphere
SphereVisible
SphereVisible
Returns whether a sphere is visible.
- var int hndl
 Handle returned from- DrawSphere
Return value
The function returns TRUE if the sphere is visible/displayed. FALSE is returned otherwise.
ShowSphere
HideSphere
ToggleSphere
ToggleSphere
Changes the visibility of a sphere. If displayed - hide, if hidden - display.
- var int hndl
 Handle returned from- DrawSphere
Bounding Box
DrawBBox
DrawBBox
Creates and draws a new bounding box and returns its handle.
- var int startPosPtr
 Pointer to an integer float array with world coordinates of the bounding box's first point (- startPos[3])
- var int endPosPtr
 Pointer to an integer float array with world coordinates of the bounding box's second point (- endPos[3])
- var int color
 Color of the bounding box as- zCOLOR
Return value
The function returns a new PermMem handle to the bounding box.
DrawBBox3
DrawBBox3
DrawBBox, but with world coordinates as parameters, instead of zVEC3 pointers.
- var int x1, y1, z1
 World coordinates of the bounding box's first point
- var int x2, y2, z2
 World coordinates of the bounding box's second point
- var int color
 Color of the bounding box as- zCOLOR
Return value
The function returns a new PermMem handle to the bounding box.
DrawBBoxAddr
DrawBBoxAddr
DrawBBox, but with the address of a bounding box as a parameter.
- var int bboxPtr
 Pointer to an integer float array with six values (startAndEndPos[6])
- var int color
 Color of the bounding box as- zCOLOR
Return value
The function returns a new PermMem handle to the bounding box.
UpdateBBox
UpdateBBox
Changes the coordinates of an existing bounding box.
- var int hndl
 Handle returned from- DrawBBox
- var int startPosPtr
 Pointer to an integer float array with world coordinates of the bounding box's first point (- startPos[3])
- var int endPosPtr
 Pointer to an integer float array with world coordinates of the bounding box's second point (- endPos[3])
UpdateBBox3
UpdateBBox3
UpdateBBox, but with world coordinates as parameters, instead of zVEC3 pointers.
- var int hndl
 Handle returned from- DrawBBox
- var int x1, y1, z1
 World coordinates of the bounding box's first point
- var int x2, y2, z2
 World coordinates of the bounding box's second point
UpdateBBoxAddr
UpdateBBoxAddr
UpdateBBox, but with the address of a bounding box as a parameter.
- var int hndl
 Handle returned from- DrawBBox
- var int bboxPtr
 Pointer to an integer float array with six values (startAndEndPos[6])
SetBBoxColor
SetBBoxColor
Changes the color of a specific bounding box.
EraseBBox
EraseBBox
Deletes a bounding box from the world and its handle.
- var int hndl
 Handle returned from- DrawBBox
BBoxVisible
BBoxVisible
Returns whether a bounding box is visible.
- var int hndl
 Handle returned from- DrawBBox
Return value
The function returns TRUE if the bounding box is visible/displayed. FALSE is returned otherwise.
ShowBBox
HideBBox
ToggleBBox
ToggleBBox
Changes the visibility of a bounding box. If displayed - hide, if hidden - display.
- var int hndl
 Handle returned from- DrawBBox
Oriented Bounding Box
DrawOBBoxAddr
DrawOBBoxAddr
Creates and draws a new oriented bounding box based on the address of an oriented bounding box and returns its handle.
- var int oBBoxPtr
 Pointer to a- zCOBBox3Dstructure
- var int color
 Color of the oriented bounding box as- zCOLOR
Return value
The function returns a new PermMem handle to the oriented bounding box.
UpdateOBBoxAddr
UpdateOBBoxAddr
Changes the coordinates and orientation of an existing oriented bounding box.
- var int hndl
 Handle returned from- DrawOBBoxAddr
- var int oBBoxPtr
 Pointer to a- zCOBBox3Dstructure
SetOBBoxColor
SetOBBoxColor
Changes the color of a specific oriented bounding box.
- var int hndl
 Handle returned from- DrawOBBoxAddr
- var int color
 New color of the oriented bounding box as- zCOLOR
EraseOBBox
EraseOBBox
Deletes an oriented bounding box from the world and its handle.
- var int hndl
 Handle returned from- DrawOBBoxAddr
OBBoxVisible
OBBoxVisible
Returns whether an oriented bounding box is visible.
- var int hndl
 Handle returned from- DrawOBBoxAddr
Return value
The function returns TRUE if the oriented bounding box is visible/displayed. FALSE is returned otherwise.
ShowOBBox
ShowOBBox
Displays the oriented bounding box.
- var int hndl
 Handle returned from- DrawOBBoxAddr
HideOBBox
HideOBBox
Hides the oriented bounding box.
- var int hndl
 Handle returned from- DrawOBBoxAddr
ToggleOBBox
ToggleOBBox
Changes the visibility of an oriented bounding box. If displayed - hide, if hidden - display.
- var int hndl
 Handle returned from- DrawOBBoxAddr
EraseAll
Examples
World coordinates are not particularly informative. This package aims to help and allows visualizing world coordinates in the form of lines, spheres (as circles), bounding boxes, and oriented bounding boxes in three-dimensional space.
Visualizing Straight Line to an NPC
To draw a line between two NPCs, you only need the coordinates of the two NPCs.
This function can now be called continuously using FrameFunction to continuously adjust the straight line according to the positions of the characters.
Alternatively, you can write the function as follows:
Visualizing a Distance of 5 Meters
It becomes more interesting when dealing with "abstract" coordinates. For instance, you can visualize a "safety distance" around the player using a bounding box or a sphere, to check AI reactions at certain distances.
To draw a sphere with a radius of 5 meters centered at a specific point, you only need the coordinates of the sphere's center.
Similarly, you could continuously update the bounding box/sphere using a FrameFunction.
Changing Color or Hiding/Deleting Draw Elements
If you want to visualize an AI reaction, for example, you can change the color. Color values can be created using the RGBA function based on RGB values.
Draw elements can also be easily hidden or completely deleted.