...
The in game compiler has all the game supported features and is highly recommended to use. The best option is to load the model in game and compile using compileloadedasciimodels in the console. You can load lots of models using tools like Jasperre's Model Viewer.
If not defined, it has the small drawback of generating vert normals from smoothing groups which can generate seams (only applicable on complex models with multiple skinmeshes).
...
Console Command | Parameters | Description and Notes |
---|
compileloadedmodels |
| Compiles all loaded models, including binary. You can load lots of models using tools like Jasperre's Model Viewer. |
compileloadedasciimodels |
| Compiles all loaded models, only ones loaded from ASCII. You can load lots of models using tools like Jasperre's Model Viewer. This is the recommended way to compile your models, since they should be in ASCII before compiling, and removes some bugs to do with skinmesh or lighting/shadows/generated tangents the command line parameter has. |
compilemodel <name> | <name> is a resref name, eg; "mymodel" for "mymodel.mdl" | Specific model, will load and unload it for you even if it is not currently loaded. Note: like the command line this will not work with skinmesh models unless the model is loaded and visible to the client (and in those cases just use compileloadedmodels instead). |
Command Line Parameter | Parameters | Description and Notes |
---|
nwmain.exe compilemodel <name> | <name> is a resref name, eg; "mymodel" for "mymodel.mdl" | Same as the above console command; will compile the model and exit the game immediately. Have the model file somewhere the game can find it - eg the override or development folder (development trumps all others if you are using the same model name as base model) Note 1: Since this isn't properly loading the model in game as such, this may produce the wrong vertex lighting/shadowing, as noted below. Note 2: Skinmesh models will not compile using this since it has the error in the log: Model compile error: xxxxxxxxxxx contains skinmeshes not yet initialized. Correct by calling the function with the skinmeshed model in view. To fix; load the game, load the model into view and use compileloadedasciimodels instead. |
...
This is cleverer then the CMD file below and will check for any files that have already been processed.
Expand |
---|
Code Block |
---|
# By Andrew Armstrong (Jasperre) compile all models in the given folder (development or override)
# Script should be put in the My Document\Neverwinter Nights folder
# Path to folder inside of NWN documents folder; override or development
$folder = "development"
# Path to main EXE location
$runpath = "D:\Steam\steamapps\common\Neverwinter Nights\bin\win32\"
######## Code
Write-Output "Compile Models in $folder folder"
$exepath = $runpath + "nwmain.exe"
if(!(Test-Path $exepath))
{
Write-Error "Error: Cannot find nwmain.exe. Provided path: $exepath. Exiting..." -Category ObjectNotFound
return
}
if(!(Test-Path $folder))
{
Write-Error "Error: folder $folder not found! Exiting..." -Category ObjectNotFound
return
}
$source = (Get-ChildItem "$folder\*.mdl").BaseName | foreach {$_.Split(".")[0]}
$sourcecount = $source.count*100
if($sourcecount -eq 0)
{
# What are you doing, no models to compile...
Write-Error "Error: No models found to compile! Exiting..." -Category ObjectNotFound
return
}
# Make sure modelcompiler exists
if(!(Test-Path "modelcompiler"))
{
New-Item -Name "modelcompiler" -ItemType "directory"
}
# If the destination is blank just compile everything
if((Get-ChildItem "modelcompiler\*.mdl").Count -eq 0)
{
Write-Output "Compiling All models in $folder"
foreach ($sourcefile in $source)
{
$i = $i+1
Write-Progress -Activity "Compiling Models" -Status "Progress:" -PercentComplete ($i/$sourcecount)
Write-Output "Compiling $sourcefile"
Start-Process -FilePath $exepath -WorkingDirectory $runpath -ArgumentList "compilemodel $sourcefile" -WindowStyle Minimized -Wait #-PassThru
}
}
else
{
# Compile some things
Write-Output "Compiling some models in $folder based on what is in modelcompiler folder"
$destination = (Get-ChildItem "modelcompiler\*.mdl").BaseName | foreach {$_.Split(".")[0]}
$found = 0
$foundfile = ""
$i = 0
foreach ($sourcefile in $source)
{
$i = $i+1
Write-Progress -Activity "Compiling Models" -Status "Progress:" -PercentComplete ($i/$sourcecount)
$found = 0
$foundfile = ""
foreach ($destinationfile in $destination)
{
if($sourcefile -match $destinationfile)
{
$found = 1
$foundfile = $destinationfile
}
}
if($found -eq 1)
{
Write-Output "Ignoring $sourcefile since it matches something in the modelcompiler folder"
}
else
{
Write-Output "Compiling $sourcefile (does not match anything in modelcompiler folder)"
Start-Process -FilePath $exepath -WorkingDirectory $runpath -ArgumentList "compilemodel $sourcefile" -WindowStyle Minimized -Wait #-PassThru
}
}
}
Write-Output "Done Compile Models in $folder folder"
|
|
...