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 linevar int endPosPtr
Pointer to the float array with world coordinates of the ending point of the linevar int color
Color of the line aszCOLOR
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 linevar int x2, y2, z2
X, Y, and Z coordinates of the ending point of the linevar int color
Color of the line aszCOLOR
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 aszCOLOR
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 fromDrawLine
var int startPosPtr
Pointer to an integer float array with world coordinates of the starting point of the linevar 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 fromDrawLine
var int x1, y1, z1
X, Y, and Z coordinates of the starting point of the linevar 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 fromDrawLine
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 fromDrawLine
LineVisible
LineVisible
Returns whether a line is visible.
var int hndl
Handle returned fromDrawLine
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 fromDrawLine
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 floatvar int color
Color of the sphere aszCOLOR
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 centervar int radius
Radius of the sphere as an integer floatvar int color
Color of the sphere aszCOLOR
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 azTBSphere3D
structurevar int color
Color of the sphere aszCOLOR
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 fromDrawSphere
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 fromDrawSphere
var int x1, y1, z1
World coordinates of the sphere's centervar 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 fromDrawSphere
var int spherePtr
Pointer to azTBSphere3D
structure
SetSphereColor
SetSphereColor
Changes the color of a specific sphere.
var int hndl
Handle returned fromDrawSphere
var int color
New color of the sphere aszCOLOR
EraseSphere
EraseSphere
Deletes a sphere from the world and its handle.
var int hndl
Handle returned fromDrawSphere
SphereVisible
SphereVisible
Returns whether a sphere is visible.
var int hndl
Handle returned fromDrawSphere
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 fromDrawSphere
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 aszCOLOR
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 pointvar int x2, y2, z2
World coordinates of the bounding box's second pointvar int color
Color of the bounding box aszCOLOR
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 aszCOLOR
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 fromDrawBBox
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 fromDrawBBox
var int x1, y1, z1
World coordinates of the bounding box's first pointvar 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 fromDrawBBox
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 fromDrawBBox
BBoxVisible
BBoxVisible
Returns whether a bounding box is visible.
var int hndl
Handle returned fromDrawBBox
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 fromDrawBBox
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 azCOBBox3D
structurevar int color
Color of the oriented bounding box aszCOLOR
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 fromDrawOBBoxAddr
var int oBBoxPtr
Pointer to azCOBBox3D
structure
SetOBBoxColor
SetOBBoxColor
Changes the color of a specific oriented bounding box.
var int hndl
Handle returned fromDrawOBBoxAddr
var int color
New color of the oriented bounding box aszCOLOR
EraseOBBox
EraseOBBox
Deletes an oriented bounding box from the world and its handle.
var int hndl
Handle returned fromDrawOBBoxAddr
OBBoxVisible
OBBoxVisible
Returns whether an oriented bounding box is visible.
var int hndl
Handle returned fromDrawOBBoxAddr
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 fromDrawOBBoxAddr
HideOBBox
HideOBBox
Hides the oriented bounding box.
var int hndl
Handle returned fromDrawOBBoxAddr
ToggleOBBox
ToggleOBBox
Changes the visibility of an oriented bounding box. If displayed - hide, if hidden - display.
var int hndl
Handle returned fromDrawOBBoxAddr
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.