SetLowLODElement: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(9 intermediate revisions by 6 users not shown) | |||
Line 2: | Line 2: | ||
{{Server client function}} | {{Server client function}} | ||
This function assigns a low LOD element to an element. The low LOD element is displayed when its associated element is not fully visible. If a low LOD element is assigned to several elements, it will be displayed when any of these elements are not fully visible. | This function assigns a low LOD element to an element. The low LOD element is displayed when its associated element is not fully visible. If a low LOD element is assigned to several elements, it will be displayed when any of these elements are not fully visible. | ||
{{Note|The only valid elements types for assigning LODs with this function are [[Object]] and [[Building]].}} | |||
==Syntax== | ==Syntax== | ||
Line 7: | Line 9: | ||
bool setLowLODElement ( element theElement, element lowLODElement ) | bool setLowLODElement ( element theElement, element lowLODElement ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[element]]:setLowLOD|lowLOD|getLowLODElement}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' The [[element]] whose low LOD version we want to change. | *'''theElement:''' The [[element]] whose low LOD version we want to change. | ||
Line 20: | Line 22: | ||
This example shows how to create and link a normal and low LOD object: | This example shows how to create and link a normal and low LOD object: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Create | -- Create a normal object | ||
objNormal = createObject ( 3620, x,y,z,0,0,0 ) | local objNormal = createObject ( 3620, x,y,z,0,0,0 ) | ||
-- Create a low LOD object | -- Create a low LOD object | ||
objLowLOD = createObject ( 5154, x,y,z,0,0,0,true ) | local objLowLOD = createObject ( 5154, x,y,z,0,0,0,true ) | ||
-- | -- Assign the LOD object with the Normal object | ||
setLowLODElement ( objNormal, objLowLOD ) | setLowLODElement ( objNormal, objLowLOD ) | ||
-- Set the LOD object's parent to the Normal object so it is destroyed together | |||
setElementParent( objLowLOD, objNormal ) | |||
-- Set the draw distance for the model we are using for low LOD to maximum | -- Set the draw distance for the model we are using for low LOD to maximum | ||
Line 55: | Line 59: | ||
-- Attach low LOD object so it moves with the main model | -- Attach low LOD object so it moves with the main model | ||
attachElements ( objlowLOD, objMainBit, 0, 0, 0 ) | attachElements ( objlowLOD, objMainBit, 0, 0, 0 ) | ||
-- Set the low LOD object's parent to the main object so it is destroyed together | |||
setElementParent( objLowLOD, objMainBit ) | |||
-- Set associations so the low LOD model is displayed when the main parts are not full visible | -- Set associations so the low LOD model is displayed when the main parts are not full visible | ||
Line 68: | Line 75: | ||
</section> | </section> | ||
<section name="Clientside" class="client" show="true"> | <section name="Clientside" class="client" show="true"> | ||
Changing the draw distance for a model has to done on the client: | Changing the draw distance for a model has to be done on the client: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEvent("onClientChangeModelLODDistance",true) | addEvent("onClientChangeModelLODDistance",true) | ||
Line 78: | Line 85: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
==See Also== | ==See Also== | ||
{{Element_functions}} | {{Element_functions}} |
Latest revision as of 15:36, 7 November 2024
This function assigns a low LOD element to an element. The low LOD element is displayed when its associated element is not fully visible. If a low LOD element is assigned to several elements, it will be displayed when any of these elements are not fully visible.
Syntax
bool setLowLODElement ( element theElement, element lowLODElement )
OOP Syntax Help! I don't understand this!
- Method: element:setLowLOD(...)
- Variable: .lowLOD
- Counterpart: getLowLODElement
Required Arguments
- theElement: The element whose low LOD version we want to change.
- lowLODElement : A low LOD element to display when the first element is not fully visible.
Returns
Returns true if the assignment was successful, false otherwise.
Example
Example 1
Click to collapse [-]
ClientsideThis example shows how to create and link a normal and low LOD object:
-- Create a normal object local objNormal = createObject ( 3620, x,y,z,0,0,0 ) -- Create a low LOD object local objLowLOD = createObject ( 5154, x,y,z,0,0,0,true ) -- Assign the LOD object with the Normal object setLowLODElement ( objNormal, objLowLOD ) -- Set the LOD object's parent to the Normal object so it is destroyed together setElementParent( objLowLOD, objNormal ) -- Set the draw distance for the model we are using for low LOD to maximum engineSetModelLODDistance ( 5154, 300 )
Example 2
Click to collapse [-]
ServersideThis example shows how to create and link a composite object
-- Create composite object objMainBit = createObject ( 3620, x,y,z ) objLeftBit = createObject ( 5158, x,y,z ) objRightBit = createObject ( 5158, x,y,z ) objDetailBit1 = createObject ( 1337, x,y,z ) objDetailBit2 = createObject ( 1337, x,y,z ) objInternalBit = createObject ( 1337, x,y,z ) attachElements ( objLeftBit, objMainBit, -10, 0, 0 ) attachElements ( objRightBit, objMainBit, 10, 0, 0 ) attachElements ( objDetailBit1, objMainBit, 5, 0, 0 ) attachElements ( objDetailBit2, objLeftBit, 5, 5, 0 ) attachElements ( objInternalBit, objRightBit, 5, 7, 0 ) -- Create low LOD object (which represents the whole composite model) objlowLOD = createObject ( 5154, x,y,z, 0, 0, 0, true ) -- Attach low LOD object so it moves with the main model attachElements ( objlowLOD, objMainBit, 0, 0, 0 ) -- Set the low LOD object's parent to the main object so it is destroyed together setElementParent( objLowLOD, objMainBit ) -- Set associations so the low LOD model is displayed when the main parts are not full visible setLowLODElement ( objMainBit, objlowLOD ) setLowLODElement ( objLeftBit, objlowLOD ) setLowLODElement ( objRightBit, objlowLOD ) -- Note that the detail and internal parts have not been associated to the low LOD object -- Set the draw distance for the model we are using for low LOD to maximum triggerClientEvent("onClientChangeModelLODDistance", resourceRoot, 5154, 300 )
Click to collapse [-]
ClientsideChanging the draw distance for a model has to be done on the client:
addEvent("onClientChangeModelLODDistance",true) addEventHandler("onClientChangeModelLODDistance", resourceRoot, function(model,distance) engineSetModelLODDistance ( model, distance ) end )
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement