DxSetShaderTransform: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 56: Line 56:
==See Also==
==See Also==
{{Drawing_functions}}
{{Drawing_functions}}
[[hu:setShaderTransform]]

Revision as of 14:56, 11 June 2023

Accessories-text-editor.png Script Example Missing Function DxSetShaderTransform needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.


This function applies a 3D transformation to a shader element when it is drawn with dxDrawImage.

Syntax

bool dxSetShaderTransform ( element theShader,
                            float rotationX, float rotationY, float rotationZ,
                          [ float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, float rotationCenterOffsetZ = 0,
                            bool bRotationCenterOffsetOriginIsScreen = false,
                            float perspectiveCenterOffsetX = 0, float perspectiveCenterOffsetY = 0,
                            bool bPerspectiveCenterOffsetOriginIsScreen = false ] )

OOP Syntax Help! I don't understand this!

Method: shader:setTransform(...)


Required Arguments

  • theShader: The shader element whose transformation is to be changed
  • rotationX: Rotation angle in degrees around the X axis (Left,right). This will make the shader rotate along its width.
  • rotationY: Rotation angle in degrees around the Y axis (Up,down). This will make the shader rotate along its height.
  • rotationZ: Rotation angle in degrees around the Z axis (In,out). This will make the shader rotate in a similar way to the rotation argument in dxDrawImage.

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.

  • rotationCenterOffsetX : The center of rotation offset X position in screen relative units.
  • rotationCenterOffsetY : The center of rotation offset Y position in screen relative units.
  • rotationCenterOffsetZ : The center of rotation offset Z position in screen relative units.
  • bRotationCenterOffsetOriginIsScreen : Set to true if the center of rotation origin should be the center of the screen rather than the center of the image.
  • perspectiveCenterOffsetX : The center of perspective offset X position in screen relative units.
  • perspectiveCenterOffsetY : The center of perspective offset Y position in screen relative units.
  • bPerspectiveCenterOffsetOriginIsScreen : Set to true if the center of perspective origin should be the center of the screen rather than the center of the image.

To convert screen relative units into screen pixel coordinates, multiply by the screen size. Conversely, to convert screen pixel coordinates to screen relative units, divide by the screen size.

Returns

Returns true if the shader element's transform was successfully changed, false otherwise.

Example

myShader = dxCreateShader( "shader.fx" )
myTexture = dxCreateTexture( "picture.png" )
dxSetShaderValue( myShader, "texture0", myTexture ) -- Set a texture

transform = 0

addEventHandler( "onClientRender", root, function()
    transform = transform + 1
    dxSetShaderTransform( myShader, transform )
    dxDrawImage( 400, 300, 100, 100, myShader )
end)

Requirements

This template will be deleted.

See Also