dxDrawPrimitive3D | Multi Theft Auto: Wiki Skip to content

dxDrawPrimitive3D

Client-side
Server-side
Shared

This function draws a 3D primitive in the 3D world - rendered for one frame. This should be used in conjunction with onClientRender/onClientPreRender in order to display continuously.

Syntax

bool dxDrawPrimitive3D ( ​string pType, ​string stage, ​table vertex1, [ ​table vertex2... = nil ] )
Required Arguments
  • pType: Type of primitive to be drawn.
    • pointlist: Renders the vertices as a collection of isolated points.
    • linelist: Renders the vertices as a list of isolated straight line segments.
    • linestrip: Renders the vertices as a single polyline.
    • trianglelist: Renders the specified vertices as a sequence of isolated triangles. Each group of three vertices defines a separate triangle.
    • trianglestrip: Renders the vertices as a triangle strip.
    • trianglefan: Renders the vertices as a triangle fan.
  • stage: A string representing a stage at which the actual drawcall should happen.
    • prefx: Primitives are rendered before the color correction. This stage makes lines look natural to SA but colors could be distorted.
    • postfx: Primitives are rendered after the color correction. This stage conveys a color from the function to a screen without distortions.
    • postgui: Primitives are rendered after GUI. The line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
  • vertex1: Tables representing each primitive vertex, required amount of them is determined by primitive type. See vertices format below:
    • posX - An float representing the X position of the vertex in the GTA world.
    • posY - An float representing the Y position of the vertex in the GTA world.
    • posZ - An float representing the Z position of the vertex in the GTA world.
    • color (optional) - An integer of the hex color, produced using tocolor or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue). If it's not specified, white color is used.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • vertex2... (default: nil): Tables representing each primitive vertex, required amount of them is determined by primitive type. Check table format above.

Returns

  • bool: result

Returns a true if the operation was successful, false otherwise.

Code Examples

client

This is a small example of creating 3D Primitive object with 4 vertex that will spawn on 'The Well Stacked Pizza Co.' in Idlewood.

local primitive = {
{2087.8, -1804.2, 13.5, tocolor(255, 0, 0)},
{2087.7, -1810.5, 13.5, tocolor(0, 255, 0)},
{2092.7, -1813.6, 17.7, tocolor(0, 0, 255)},
{2097.5, -1806.8, 16, tocolor(255, 255, 255)}
}
function draw()
dxDrawPrimitive3D("trianglefan", false, unpack(primitive))
end
addEventHandler("onClientRender", root, draw)

Changelog

  • 1.5.9 r22465

    The postGUI argument has been removed and replaced with a stage argument.