drawPoly
DRAW_POLY0xAC26716048436851The GTA V native DRAW_POLY of the GRAPHICS namespace, as LS:MP client scripts call it: the global function drawPoly, in JavaScript and in Lua.
drawPoly(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
x3: number,
y3: number,
z3: number,
red: number,
green: number,
blue: number,
alpha: number
): voiddrawPoly(
x1: number,
y1: number,
z1: number,
x2: number,
y2: number,
z2: number,
x3: number,
y3: number,
z3: number,
red: integer,
green: integer,
blue: integer,
alpha: integer
)Usage
drawPoly(x1, y1, z1, x2, y2, z2, x3, y3, z3, red, green, blue, alpha);drawPoly(x1, y1, z1, x2, y2, z2, x3, y3, z3, red, green, blue, alpha)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
drawPoly(pos1, pos2, pos3, red, green, blue, alpha);drawPoly(pos1, pos2, pos3, red, green, blue, alpha)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
x1 | float | number | number |
y1 | float | number | number |
z1 | float | number | number |
x2 | float | number | number |
y2 | float | number | number |
z2 | float | number | number |
x3 | float | number | number |
y3 | float | number | number |
z3 | float | number | number |
red | int | number | integer |
green | int | number | integer |
blue | int | number | integer |
alpha | int | number | integer |
Returns
Nothing. In JavaScript the call evaluates to undefined.
Notes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
x/y/z - Location of a vertex (in world coords), presumably.
x1, y1, z1 : Coordinates for the first point
x2, y2, z2 : Coordinates for the second point
x3, y3, z3 : Coordinates for the third point
r, g, b, alpha : Color with RGBA-Values
Keep in mind that only one side of the drawn triangle is visible: It's the side, in which the vector-product of the vectors heads to: (b-a)x(c-a) Or (b-a)x(c-b).
But be aware: The function seems to work somehow differently. I have trouble having them drawn in rotated orientation. Try it yourself and if you somehow succeed, please edit this and post your solution.
I recommend using a predefined function to call this.
[VB.NET]
Public Sub DrawPoly(a As Vector3, b As Vector3, c As Vector3, col As Color)
[Function].Call(Hash.DRAW_POLY, a.X, a.Y, a.Z, b.X, b.Y, b.Z, c.X, c.Y, c.Z, col.R, col.G, col.B, col.A)
End Sub[C#]
public void DrawPoly(Vector3 a, Vector3 b, Vector3 c, Color col)
{
Function.Call(Hash.DRAW_POLY, a.X, a.Y, a.Z, b.X, b.Y, b.Z, c.X, c.Y, c.Z, col.R, col.G, col.B, col.A);
}BTW: Intersecting triangles are not supported: They overlap in the order they were called.
Reference
- Namespace
- Graphics GRAPHICS
- In the game
void DRAW_POLY(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, int red, int green, int blue, int alpha)- Hash
0xAC26716048436851