EngineReplaceModel notes: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
==Method 1: Move camera away during replace process== | ==Method 1: Move camera away during replace process== | ||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local modelId = 12853 | local modelId = 12853 | ||
| Line 17: | Line 18: | ||
setTimer( function() | setTimer( function() | ||
setCameraTarget( localPlayer ) -- Move camera back after a delay | |||
end, 50, 1 ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==Method 2: Create custom object and hide original== | ==Method 2: Create custom object and hide original== | ||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local modelId = 12853 | local modelId = 12853 | ||
| Line 39: | Line 41: | ||
engineReplaceModel( dff, modelId ) | engineReplaceModel( dff, modelId ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
====Additonal code if model has LOD:==== | ====Additonal code if model has LOD:==== | ||
Revision as of 18:50, 24 September 2019
Replacing models in the original GTA map
There are two ways to replace models in the original GTA map:
Method 1: Move camera away during replace process
Click to collapse [-]
Client local modelId = 12853
setCameraMatrix( 10000, 0, 0 ) -- Move camera far away
col = engineLoadCOL( "garage.col" )
txd = engineLoadTXD( "garage.txd" )
dff = engineLoadDFF( "garage.dff", 0 )
engineReplaceCOL( col, modelId )
engineImportTXD( txd, modelId )
engineReplaceModel( dff, modelId )
setTimer( function()
setCameraTarget( localPlayer ) -- Move camera back after a delay
end, 50, 1 )
Method 2: Create custom object and hide original
Click to collapse [-]
Client local modelId = 12853
local x,y,z = 661, -561, 17
obj = createObject( modelId, x,y,z )
removeWorldModel( modelId, 100, x,y,z ) -- Hide original
col = engineLoadCOL( "garage.col" )
txd = engineLoadTXD( "garage.txd" )
dff = engineLoadDFF( "garage.dff", 0 )
engineReplaceCOL( col, modelId )
engineImportTXD( txd, modelId )
engineReplaceModel( dff, modelId )
Additonal code if model has LOD:
(To determine the LOD model ID, use the editor resource, or refer to this this table)
If the model has a LOD version, that will need to be hidden:
local modelIdLOD = 13245
removeWorldModel ( modelIdLOD, 100, x,y,z ) -- Hide LOD
Optionally create a MTA LOD replacement so there is no hole in the map from a distance:
-- This step is optional
objLOD = createObject( modelIdLOD, x,y,z, 0, 0, 0, true )
setLowLODElement(obj, objLOD)
And for extra points, add a custom dff for the MTA LOD replacement:
-- This step is optional
txdLOD = engineLoadTXD( "garageLOD.txd" )
dffLOD = engineLoadDFF( "garageLOD.dff", 0 )
engineImportTXD( txdLOD, modelIdLOD )
engineReplaceModel( dffLOD, modelIdLOD )