DxDrawMaterialSectionLine3D: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Remove obsolete Requirements section)
 
(16 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}  
{{Client function}}  
{{Needs Example}}
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'.


{{Legacy|legacy/dxDrawMaterialSectionLine3D}}
{{Updated feature/item|1.5.9|1.5.9|22465|
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dxDrawMaterialSectionLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, float u, float v, float usize, float vsize,
bool dxDrawMaterialSectionLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ,
                                  element material, int width [, int color = white, float faceTowardX, float faceTowardY, float faceTowardZ ] )
                                  float u, float v, float usize, float vsize, [ bool flipUV = false, ] element material, float width,
                                [ int color = white, [ bool stage = "postfx", ] float faceTowardX, float faceTowardY, float faceTowardZ ] )
</syntaxhighlight>
</syntaxhighlight>


Line 19: Line 22:
*'''usize:''' the absolute width of the section
*'''usize:''' the absolute width of the section
*'''vsize:''' the absolute height of the section
*'''vsize:''' the absolute height of the section
* '''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==
* '''color:''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).
{{Added feature/item|1.5.9|1.5.8|20862|
* '''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 direction the front of the line should face towards. If this is not set, the front of the line always faces toward the camera.
* '''faceTowardX/Y/Z:''' The direction the front of the line should face towards. If this is not set, the front of the line always 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==  
<section name="Client" class="client" show="true">
This example draws corona like effects near the player
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
   TODO
coronaTexture = dxCreateTexture("corona.png")
red = tocolor(255,0,0)
green = tocolor(0,255,0)
blue = tocolor(0,0,255)
 
addEventHandler("onClientPreRender",root,
    function()
        local x,y,z = getElementPosition(localPlayer)
 
        dxSetBlendMode("add")   -- Add blend mode looks best for corona effects
        drawCorona( x+2, y+2, z+1, 1, red )
        drawCorona( x+1, y+3, z+2, 1, green )
        drawCorona( x-1, y+2, z+3, 1, blue )
        dxSetBlendMode("blend") -- Restore default
    end
)
 
-- Draw the corona texture
function drawCorona( x, y, z, size, color )
    dxDrawMaterialSectionLine3D ( x, y, z+size,
                                  x, y, z-size,
                                  0,0,1,1, coronaTexture, size, color)
end
 
</syntaxhighlight>
</syntaxhighlight>
</section>
 
==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}}
[[hu:dxDrawMaterialSectionLine3D]]

Latest revision as of 17:03, 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'.


Dialog-info.png This page describes the current implementation. For older versions check legacy version



Syntax

bool dxDrawMaterialSectionLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ,
                                   float u, float v, float usize, float vsize, [ bool flipUV = false, ] element material, float width,
                                 [ int color = white, [ bool 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.
  • u: the absolute X coordinate of the top left corner of the section
  • v: the absolute Y coordinate of the top left corner of the section
  • usize: the absolute width of the section
  • vsize: the absolute height of the section
  • 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

  • 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 direction the front of the line should face towards. If this is not set, the front of the line always faces toward the camera.

Returns

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

Example

This example draws corona like effects near the player

coronaTexture = dxCreateTexture("corona.png")
red = tocolor(255,0,0)
green = tocolor(0,255,0)
blue = tocolor(0,0,255)

addEventHandler("onClientPreRender",root,
    function()
        local x,y,z = getElementPosition(localPlayer)

        dxSetBlendMode("add")   -- Add blend mode looks best for corona effects
        drawCorona( x+2, y+2, z+1, 1, red )
        drawCorona( x+1, y+3, z+2, 1, green )
        drawCorona( x-1, y+2, z+3, 1, blue )
        dxSetBlendMode("blend") -- Restore default
    end
)

-- Draw the corona texture
function drawCorona( x, y, z, size, color )
    dxDrawMaterialSectionLine3D ( x, y, z+size,
                                  x, y, z-size,
                                  0,0,1,1, coronaTexture, size, color)
end

Changelog

Version Description
1.5.5-9.11998 Added postGUI argument
1.5.8-9.20862 Added flipUV argument

See Also