DxDrawModel3D: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Fernando187 (talk | contribs) m (→Example) |
||
| (12 intermediate revisions by 5 users not shown) | |||
| Line 4: | Line 4: | ||
{{Important Note|This function doesn't obey any streaming limits, you can draw as many models as you want}} | {{Important Note|This function doesn't obey any streaming limits, you can draw as many models as you want}} | ||
{{Important Note|You can not render model to render target.}} | {{Important Note|You can not render model to render target.}} | ||
{{New feature/item|3.0161|1.6.0| | {{New feature/item|3.0161|1.6.0|22708| | ||
This function draws a 3D model - rendered for '''one''' frame. Drawn models are indistinguishable from this one created by [[createObject]] function. This should be used in conjunction with [[onClientRender]] in order to display continuously. | This function draws a 3D model - rendered for '''one''' frame. Drawn models are indistinguishable from this one created by [[createObject]] function. This should be used in conjunction with [[onClientRender]] or [[onClientPreRender]] in order to display continuously. Note that a model must be loaded at the time this function is called. A model can be loaded and unloaded with the help of [[engineStreamingRequestModel]] and [[engineStreamingReleaseModel]] functions. | ||
}} | }} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool | bool dxDrawModel3D( int modelId, float positionX, float positionY, float positionZ, float rotationX, float rotationY, float rotationZ [, float scaleX = 1, float scaleY = 1, float scaleZ = 1, float lighting = 0 ]) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 17: | Line 17: | ||
===Required Arguments=== | ===Required Arguments=== | ||
* '''modelId:''' | * '''modelId:''' [[object]] you want to draw, must be regular object, you can not draw vehicles and peds. See [[Object_IDs|Object IDs]] for a list of model IDs. | ||
* '''positionX | *'''positionX:''' A floating point number representing the X coordinate on the map. | ||
* ''' | *'''positionY:''' A floating point number representing the Y coordinate on the map. | ||
*'''positionZ:''' A floating point number representing the Z coordinate on the map. | |||
*'''rotationX:''' A floating point number representing the rotation about the X axis in degrees. | |||
*'''rotationY:''' A floating point number representing the rotation about the Y axis in degrees. | |||
*'''rotationZ:''' A floating point number representing the rotation about the Z axis in degrees. | |||
===Optional Arguments=== | ===Optional Arguments=== | ||
* '''scaleX | *'''scaleX''': a float containing the new scale on the X axis | ||
*'''scaleY''': a float containing the new scale on the Y axis | |||
*'''scaleZ''': a float containing the new scale on the Z axis | |||
{{New feature/item|3.0161|1.6.0|22862| | |||
*'''lighting:''' Lighting of model. Allowed range is [0, 1]. | |||
}} | |||
===Returns=== | ===Returns=== | ||
Returns true if the operation was successful, false otherwise. | Returns true if the operation was successful, false otherwise. | ||
==Example== | |||
<section name="Simple example" class="client" show="true"> | |||
This example draws a model | |||
<syntaxhighlight lang="lua"> | |||
local modelId = 1337 | |||
local function drawMyModel() | |||
dxDrawModel3D(modelId, 0, 0, 4, 0, 0, 0) | |||
end | |||
local function startDraw() | |||
engineStreamingRequestModel(modelId, true, true) | |||
addEventHandler("onClientPreRender", root, drawMyModel) | |||
end | |||
local function stopDraw() | |||
engineStreamingReleaseModel(modelId, true) | |||
removeEventHandler("onClientPreRender", root, drawMyModel) | |||
end | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Latest revision as of 10:13, 10 November 2025
| Important Note: You can not use this function to draw vehicles and ped |
| Important Note: This function doesn't obey any streaming limits, you can draw as many models as you want |
| Important Note: You can not render model to render target. |
Syntax
bool dxDrawModel3D( int modelId, float positionX, float positionY, float positionZ, float rotationX, float rotationY, float rotationZ [, float scaleX = 1, float scaleY = 1, float scaleZ = 1, float lighting = 0 ])
Required Arguments
- modelId: object you want to draw, must be regular object, you can not draw vehicles and peds. See Object IDs for a list of model IDs.
- positionX: A floating point number representing the X coordinate on the map.
- positionY: A floating point number representing the Y coordinate on the map.
- positionZ: A floating point number representing the Z coordinate on the map.
- rotationX: A floating point number representing the rotation about the X axis in degrees.
- rotationY: A floating point number representing the rotation about the Y axis in degrees.
- rotationZ: A floating point number representing the rotation about the Z axis in degrees.
Optional Arguments
- scaleX: a float containing the new scale on the X axis
- scaleY: a float containing the new scale on the Y axis
- scaleZ: a float containing the new scale on the Z axis
Returns
Returns true if the operation was successful, false otherwise.
Example
Click to collapse [-]
Simple exampleThis example draws a model
local modelId = 1337
local function drawMyModel()
dxDrawModel3D(modelId, 0, 0, 4, 0, 0, 0)
end
local function startDraw()
engineStreamingRequestModel(modelId, true, true)
addEventHandler("onClientPreRender", root, drawMyModel)
end
local function stopDraw()
engineStreamingReleaseModel(modelId, true)
removeEventHandler("onClientPreRender", root, drawMyModel)
end
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