DxDrawPrimitive3D: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
(One intermediate revision by the same user not shown)
Line 3: Line 3:
This function draws a 3D primitive in the 3D world - rendered for '''one''' frame.  This should be used in conjunction with [[onClientRender]] in order to display continuously.
This function draws a 3D primitive in the 3D world - rendered for '''one''' frame.  This should be used in conjunction with [[onClientRender]] in order to display continuously.


{{Deprecated items|3.0159|1.5.9|
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 34: Line 35:
===Returns===
===Returns===
Returns a ''true'' if the operation was successful, ''false'' otherwise.
Returns a ''true'' if the operation was successful, ''false'' otherwise.
|22465}}
{{Updated feature/item|1.5.9|1.5.9|22465|
==Syntax==
<syntaxhighlight lang="lua">
bool dxDrawPrimitive3D ( string primitiveType, string stage, table vertex1, table vertex2, table vertex3 [, table vertex4, ...] )
</syntaxhighlight>
[[File:Primitive.png|thumb|A four vertex primitive example using "trianglefan"]]
===Required Arguments===
* '''primitiveType:''' The type of primitive to be drawn. This could be:
    "pointlist"
    "linelist"
    "linestrip"
    "trianglefan"
    "trianglelist"
    "trianglestrip"
* '''stage:''' A string representing a stage at which the actual drawcall should happen:
** prefx - Primitives are rendered before the color correction. This stage makes primitives 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 primitive should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
* '''vertex1:''' A table with the coordinates of the vertex plus its color.
* '''vertex2:''' A table with the coordinates of the vertex plus its color.
* '''vertex3:''' A table with the coordinates of the vertex plus its color.
The vertex should be passed like this:
<syntaxhighlight lang="lua">
{x, y, z, color}
</syntaxhighlight>
==Optional Arguments==
{{OptionalArg}}
* '''vertexN:''' A table with the coordinates of the vertex plus its color. You can add as much as you want.
===Returns===
Returns a ''true'' if the operation was successful, ''false'' otherwise.
}}


==Example==  
==Example==  

Revision as of 04:41, 27 May 2024

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

BEFORE VERSION 1.5.9 r22465:

Syntax

bool dxDrawPrimitive3D ( string primitiveType, bool postGUI, table vertex1, table vertex2, table vertex3 [, table vertex4, ...] )
A four vertex primitive example using "trianglefan"

Required Arguments

  • primitiveType: The type of primitive to be drawn. This could be:
   "pointlist"
   "linelist"
   "linestrip"
   "trianglefan"
   "trianglelist"
   "trianglestrip"
  • postGUI: A bool representing whether the line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
  • vertex1: A table with the coordinates of the vertex plus its color.
  • vertex2: A table with the coordinates of the vertex plus its color.
  • vertex3: A table with the coordinates of the vertex plus its color.

The vertex should be passed like this:

{x, y, z, color}

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.

  • vertexN: A table with the coordinates of the vertex plus its color. You can add as much as you want.

Returns

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

Syntax

bool dxDrawPrimitive3D ( string primitiveType, string stage, table vertex1, table vertex2, table vertex3 [, table vertex4, ...] )
A four vertex primitive example using "trianglefan"

Required Arguments

  • primitiveType: The type of primitive to be drawn. This could be:
   "pointlist"
   "linelist"
   "linestrip"
   "trianglefan"
   "trianglelist"
   "trianglestrip"
  • stage: A string representing a stage at which the actual drawcall should happen:
    • prefx - Primitives are rendered before the color correction. This stage makes primitives 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 primitive should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
  • vertex1: A table with the coordinates of the vertex plus its color.
  • vertex2: A table with the coordinates of the vertex plus its color.
  • vertex3: A table with the coordinates of the vertex plus its color.

The vertex should be passed like this:

{x, y, z, color}

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.

  • vertexN: A table with the coordinates of the vertex plus its color. You can add as much as you want.

Returns

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

Example

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)

Requirements

Minimum server version n/a
Minimum client version 1.5.7-9.19626

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.5.7-9.19626" />

See Also