DxDrawMaterialLine3D: Difference between revisions
(Created page with "__NOTOC__ {{Client function}} This function draws a textured 3D line between two points in the 3D world - rendered for one frame. This should be used in conjunction with [[onC...") |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(31 intermediate revisions by 16 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function draws a textured 3D line between two points in the 3D world - rendered for one frame. This should be used in conjunction with [[onClientPreRender]] in order to display continuously. | This function draws a textured 3D line between two points in the 3D world - rendered for one frame. This should be used in conjunction with [[onClientPreRender]] in order to display continuously. | ||
The 3D line with a large width value effectively becomes a rectangle, so it it possible to construct basic shapes such as boxes with several large width lines and the appropriate values for 'faceToward'. | The 3D line with a large width value effectively becomes a rectangle, so it it possible to construct basic shapes such as boxes with several large width lines and the appropriate values for 'faceToward'. | ||
3D lines are drawn at a particular place in the [[Game_Processing_Order|game processing order]], so use [[onClientPreRender]] for drawing if you are attaching them to world elements. | |||
{{Legacy|legacy/dxDrawMaterialLine3D}} | |||
{{Updated feature/item|1.5.9|1.5.9|22465| | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool dxDrawMaterialLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, element material, | bool dxDrawMaterialLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool flipUV = false, ] element material, float width, | ||
[ int color = white, [ string stage = "postfx", ] float faceTowardX, float faceTowardY, float faceTowardZ ] ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 14: | Line 19: | ||
* '''startX/Y/Z:''' The start position of the 3D line, representing a coordinate in the GTA world. | * '''startX/Y/Z:''' The start position of the 3D line, representing a coordinate in the GTA world. | ||
* '''endX/Y/Z:''' The end position of the 3D line, representing a coordinate in the GTA world. | * '''endX/Y/Z:''' The end position of the 3D line, representing a coordinate in the GTA world. | ||
* '''material:''' A material to draw the line with. | * '''material:''' A [[material]] to draw the line with. | ||
* '''width:''' The width/thickness of the line in GTA world units. (This is 1/75th of the width used in dxDrawLine3D) | * '''width:''' The width/thickness of the line in GTA world units. (This is 1/75th of the width used in dxDrawLine3D) | ||
==Optional Arguments== | ==Optional Arguments== | ||
{{OptionalArg}} | {{OptionalArg}} | ||
* '''color:''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB ( | {{Added feature/item|1.5.9|1.5.8|20862| | ||
* '''faceTowardX/Y/Z:''' The | * '''flipUV''': A bool representing whether a UV orientation should be flipped. | ||
}} | |||
* '''color:''' An [[int|integer]] of the hex color, produced using [[tocolor]] or 0xAARRGGBB. | |||
* '''stage:''' 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). | |||
* '''faceTowardX/Y/Z:''' The position the front of the line should face towards. If this is not set, the camera position is used, so the front of the line faces toward the camera. | |||
===Returns=== | ===Returns=== | ||
Returns a ''true'' if the operation was successful, ''false'' otherwise. | Returns a ''true'' if the operation was successful, ''false'' otherwise. | ||
}} | |||
==Example== | ==Example== | ||
Draws [[:File:DxDrawMaterialLine3D-example.png|an image]] in coordiantes -2422.68555, -608.78986, 132.56250: | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local redcircle = dxCreateTexture("red.png") | |||
x,y,z = -2422.68555, -608.78986, 132.56250 | |||
size = 1 | |||
addEventHandler("onClientRender", root, function() | |||
dxDrawMaterialLine3D(x+size, y+size, z-0.95, x-size, y-size, z-0.95, redcircle, size*2,tocolor(255, 255, 255, 255), false, x, y, z) | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Changelog== | |||
{{ChangelogHeader}} | |||
{{ChangelogItem|1.5.5-9.11998|Added ''postGUI'' argument}} | |||
{{ChangelogItem|1.5.8-9.20862|Added ''flipUV'' argument}} | |||
==See Also== | ==See Also== | ||
{{Drawing_functions}} | {{Drawing_functions}} |
Latest revision as of 17:01, 7 November 2024
This function draws a textured 3D line between two points in the 3D world - rendered for one frame. This should be used in conjunction with onClientPreRender in order to display continuously.
The 3D line with a large width value effectively becomes a rectangle, so it it possible to construct basic shapes such as boxes with several large width lines and the appropriate values for 'faceToward'.
3D lines are drawn at a particular place in the game processing order, so use onClientPreRender for drawing if you are attaching them to world elements.
This page describes the current implementation. For older versions check legacy version | |
Syntax
bool dxDrawMaterialLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool flipUV = false, ] element material, float width, [ int color = white, [ string stage = "postfx", ] float faceTowardX, float faceTowardY, float faceTowardZ ] )
Required Arguments
- startX/Y/Z: The start position of the 3D line, representing a coordinate in the GTA world.
- endX/Y/Z: The end position of the 3D line, representing a coordinate in the GTA world.
- material: A material to draw the line with.
- width: The width/thickness of the line in GTA world units. (This is 1/75th of the width used in dxDrawLine3D)
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- flipUV: A bool representing whether a UV orientation should be flipped.
- color: An integer of the hex color, produced using tocolor or 0xAARRGGBB.
- stage: 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).
- faceTowardX/Y/Z: The position the front of the line should face towards. If this is not set, the camera position is used, so the front of the line faces toward the camera.
Returns
Returns a true if the operation was successful, false otherwise.
Example
Draws an image in coordiantes -2422.68555, -608.78986, 132.56250:
local redcircle = dxCreateTexture("red.png") x,y,z = -2422.68555, -608.78986, 132.56250 size = 1 addEventHandler("onClientRender", root, function() dxDrawMaterialLine3D(x+size, y+size, z-0.95, x-size, y-size, z-0.95, redcircle, size*2,tocolor(255, 255, 255, 255), false, x, y, z) end)
Changelog
Version | Description |
---|
1.5.5-9.11998 | Added postGUI argument |
1.5.8-9.20862 | Added flipUV argument |
See Also
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextSize
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource