dxDrawLine3D
Client-side
Server-side
Shared
This function draws a 3D line between two points in the 3D world - rendered for one frame. This should be used in conjunction with onClientRender/onClientPreRender in order to display continuously.
Syntax
bool dxDrawLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ int color = 0xFFFFFFFF, float width = 1.0, string stage = "postfx" ] )Required Arguments
- startX: The start X position of the 3D line, representing a coordinate in the GTA world.
- startY: The start Y position of the 3D line, representing a coordinate in the GTA world.
- startZ: The start Z position of the 3D line, representing a coordinate in the GTA world.
- endX: The end X position of the 3D line, representing a coordinate in the GTA world.
- endY: The end Y position of the 3D line, representing a coordinate in the GTA world.
- endZ: The end Z position of the 3D line, representing a coordinate in the GTA world.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- color (default: 0xFFFFFFFF): An integer of the hex color, produced using tocolor or 0xAARRGGBB.
- width (default: 1.0): The width/thickness of the line.
- stage (default: "postfx"): A string representing a stage at which the actual drawcall should happen.
- prefx: Lines are rendered before the color correction. This stage makes lines look natural to SA but colors could be distorted.
- postfx: Lines are rendered after the color correction. This stage conveys a color from the function to a screen without distortions.
- postgui: Lines are rendered after GUI. The line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
Returns
- bool: result
Returns a true if the operation was successful, false otherwise.
Code Examples
client
This is a small example of creating 3D Line / "Rope" between vehicle and player.
local testVehicle
function createLine() if (not testVehicle) then return end
local x1, y1, z1 = getElementPosition(testVehicle) -- Get test vehicles position. local x2, y2, z2 = getElementPosition(localPlayer) -- Get local players position. dxDrawLine3D(x1, y1, z1, x2, y2, z2, tocolor(0, 255, 0, 230), 2) -- Create 3D Line between test vehicle and local player.end
function makeLineAppear() testVehicle = createVehicle(411, 0, 0, 5) -- Create our test vehicle. addEventHandler("onClientRender", root, createLine) -- onClientRender keeps the 3D Line visible.endaddCommandHandler("line", makeLineAppear)Changelog
The postGUI argument has been removed and replaced with a stage argument.
See Also
Drawing Functions
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTargetUpdated
- dxCreateScreenSource
- dxCreateShader
- dxCreateTextureUpdated
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawModel3DNew
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsFormat
- dxGetPixelsSize
- dxGetStatusUpdated
- dxGetTextSize
- dxGetTexturePixelsUpdated
- dxGetTextWidth
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetShaderValue
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource