EngineReplaceModel notes: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "=Replacing models in the original GTA map= Replacing models in the original GTA map may not work correctly. There are two work arounds: ==Work around 1:== Move camera away du...")
 
No edit summary
Line 2: Line 2:
Replacing models in the original GTA map may not work correctly. There are two work arounds:
Replacing models in the original GTA map may not work correctly. There are two work arounds:


==Work around 1:==
==Work around 1: Move camera away during replace process==
Move camera away during replace process:
''Pros: Simple''<br/>
''Cons: Looks messy during replace''<br/>
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
     local modelId = 12853
     local modelId = 12853
Line 23: Line 24:
</syntaxhighlight>
</syntaxhighlight>


==Work around 2:==
 
Create custom object and hide original:<br/>
==Work around 2: Create custom object and hide original==
''(Requires col, txd and dff)''
''Pros: Looks ok during replace''<br/>
''Cons: You will have to handle LOD (see below)''
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
     local modelId = 12853
     local modelId = 12853
    local modelLODId = 13245
     local x,y,z = 661, -561, 17
     local x,y,z = 661, -561, 17


Line 40: Line 43:
     engineImportTXD( txd, modelId )
     engineImportTXD( txd, modelId )
     engineReplaceModel( dff, modelId )
     engineReplaceModel( dff, modelId )
</syntaxhighlight>
====Additonal code if model has LOD:====
If the model has a LOD version, that will need to be hidden:
<syntaxhighlight lang="lua">
    local modelIdLOD = 13245
    removeWorldModel ( modelIdLOD, 100, x,y,z ) -- Hide LOD
</syntaxhighlight>
Optionally create a MTA LOD replacement so there is no hole in the map from a distance:
<syntaxhighlight lang="lua">
    -- This step is optional
    objLOD = createObject( modelIdLOD, x,y,z, 0, 0, 0, true )
    setLowLODElement(obj, objLOD)
</syntaxhighlight>
And for extra points, add a custom dff for the MTA LOD replacement:
<syntaxhighlight lang="lua">
    -- This step is optional
    txdLOD = engineLoadTXD( "garageLOD.txd" )
    dffLOD = engineLoadDFF( "garageLOD.dff", 0 )
    engineImportTXD( txdLOD, modelIdLOD )
    engineReplaceModel( dffLOD, modelIdLOD )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 07:42, 12 June 2014

Replacing models in the original GTA map

Replacing models in the original GTA map may not work correctly. There are two work arounds:

Work around 1: Move camera away during replace process

Pros: Simple
Cons: Looks messy during replace

    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 )


Work around 2: Create custom object and hide original

Pros: Looks ok during replace
Cons: You will have to handle LOD (see below)

    local modelId = 12853
    local modelLODId = 13245
    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:

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 )