Skip to content

DrawFilledTriangle

The DrawFilledTriangle function draws a filled triangle in 3D space. This function is useful for visualizing solid triangular areas or regions in the game world.

Parameters

  • x (number): The x-coordinate of the triangle's origin.
  • y (number): The y-coordinate of the triangle's origin.
  • z (number): The z-coordinate of the triangle's origin.
  • r (number): The red color component (0.0 to 1.0).
  • g (number): The green color component (0.0 to 1.0).
  • b (number): The blue color component (0.0 to 1.0).
  • a (number): The alpha (transparency) value (0.0 to 1.0).
  • size (number): The size of the triangle.
  • facing_target (string, optional): The unit the triangle should face.

Example Usage in Lua

Here is an example of how to use the DrawFilledTriangle function in Lua:

local api = ...

-- Function to draw a green filled triangle with specified size and color at the given coordinates
function DrawGreenFilledTriangle(x, y, z, size)
    local r = 0.0
    local g = 1.0
    local b = 0.0
    local a = 1.0
    api.DrawFilledTriangle(x, y, z, r, g, b, a, size)
    print("Drew a green filled triangle at (" .. x .. ", " .. y .. ", " .. z .. ") with size " .. size)
end

-- Example usage: Draw a green filled triangle at coordinates (10, 20, 30) with size 5
DrawGreenFilledTriangle(10, 20, 30, 5)