mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-13 18:59:05 +00:00
Changed: #964 Properly update nel material texture changes in viewport/render, handle more cases for max file path conversion, added conversion log, allow use of a timestamp tag file to facilitate resuming the conversion process.
This commit is contained in:
parent
2fdbeea4da
commit
d421adf908
2 changed files with 367 additions and 1 deletions
|
@ -1,4 +1,26 @@
|
||||||
|
|
||||||
|
NEL3D_APPDATA_INTERFACE_FILE = 1423062700
|
||||||
|
|
||||||
|
-- Allocate 20 Me for the script
|
||||||
|
heapSize += 15000000
|
||||||
|
|
||||||
|
nlErrorFilename = "W:/database/conversion.log"
|
||||||
|
nlErrorStream = openFile nlErrorFilename mode:"w"
|
||||||
|
if nlErrorStream == undefined then
|
||||||
|
nlErrorStream = createFile nlErrorFilename
|
||||||
|
|
||||||
|
-- Log a message
|
||||||
|
fn nllog message =
|
||||||
|
(
|
||||||
|
if nlErrorStream != undefined then
|
||||||
|
(
|
||||||
|
format "%\n" message to:nlErrorStream
|
||||||
|
flush nlErrorStream
|
||||||
|
)
|
||||||
|
|
||||||
|
-- To the console
|
||||||
|
print message
|
||||||
|
)
|
||||||
|
|
||||||
include "nel_utility.ms"
|
include "nel_utility.ms"
|
||||||
|
|
||||||
|
@ -17,6 +39,10 @@ fn getAbsoluteDestination t =
|
||||||
(
|
(
|
||||||
return ("W:\\" + (substring (getFilenamePath t) 11 -1) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png")
|
return ("W:\\" + (substring (getFilenamePath t) 11 -1) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png")
|
||||||
)
|
)
|
||||||
|
else if (((findString t "\\\\Database") != undefined) or ((findString t "\\\\database") != undefined)) and ((findString t "W:\\") == undefined) then
|
||||||
|
(
|
||||||
|
return ("W:\\" + (getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png")
|
||||||
|
)
|
||||||
else if ((findString t "W:\\") != undefined) then
|
else if ((findString t "W:\\") != undefined) then
|
||||||
(
|
(
|
||||||
return ((getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png")
|
return ((getFilenamePath t) + "\\" + (getFilenameFile (filenameFromPath t)) + ".png")
|
||||||
|
@ -43,6 +69,26 @@ fn getAbsoluteDestination t =
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fn getMaxDestination mf =
|
||||||
|
(
|
||||||
|
if ((findString mf "\\\\Amiga") != undefined) then
|
||||||
|
(
|
||||||
|
return ("W:\\" + (substring mf 11 -1))
|
||||||
|
)
|
||||||
|
else if ((findString mf "\\\\amiga") != undefined) then
|
||||||
|
(
|
||||||
|
return ("W:\\" + (substring mf 11 -1))
|
||||||
|
)
|
||||||
|
else if (((findString mf "\\\\Database") != undefined) or ((findString mf "\\\\database") != undefined)) and ((findString mf "W:\\") == undefined) then
|
||||||
|
(
|
||||||
|
return ("W:\\" + mf)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
return mf
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
fn getFixedTexturePath t =
|
fn getFixedTexturePath t =
|
||||||
(
|
(
|
||||||
absoluteDestination = (getAbsoluteDestination t)
|
absoluteDestination = (getAbsoluteDestination t)
|
||||||
|
@ -245,6 +291,21 @@ rollout assets_png_rollout "Properties"
|
||||||
m.delegate.RefractionMap = undefined
|
m.delegate.RefractionMap = undefined
|
||||||
)
|
)
|
||||||
|
|
||||||
|
max select none
|
||||||
|
|
||||||
|
for node in geometry do
|
||||||
|
(
|
||||||
|
itfMaxFile = getAppData node NEL3D_APPDATA_INTERFACE_FILE
|
||||||
|
if (itfMaxFile != undefined) then
|
||||||
|
(
|
||||||
|
if (itfMaxFile != "") then
|
||||||
|
(
|
||||||
|
itfMaxFile = getMaxDestination itfMaxFile
|
||||||
|
setAppData node NEL3D_APPDATA_INTERFACE_FILE itfMaxFile
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||||
actionMan.executeAction 0 "40807" -- Views: Activate All Maps
|
actionMan.executeAction 0 "40807" -- Views: Activate All Maps
|
||||||
|
@ -256,7 +317,287 @@ rollout assets_png_rollout "Properties"
|
||||||
return 1
|
return 1
|
||||||
)
|
)
|
||||||
|
|
||||||
include "nel_batched_mergesave.ms"
|
-- This script is a base script to include to add multiple functionality to your script
|
||||||
|
|
||||||
|
-- To use this script
|
||||||
|
-- Include it in your script into the rollout at the begining.
|
||||||
|
-- Implement a do_it function to do the job in your rollout.
|
||||||
|
-- The function should retun -1 if an arror occured, else the count of modification done
|
||||||
|
-- It the function returns <1, the project will not be overwritten
|
||||||
|
|
||||||
|
Group "Running properties"
|
||||||
|
(
|
||||||
|
RadioButtons SourceFiles "Source projects" labels:#("Current project", "All Projects in a folder") align:#left
|
||||||
|
|
||||||
|
Label DirectoryLabel "Source directory" align:#left
|
||||||
|
EditText Directory "" width:500 align:#left enabled:false
|
||||||
|
Button BrowseDirectory "Browse..." align:#left enabled:false
|
||||||
|
|
||||||
|
CheckBox Recurse "Look in subfolders" checked:true enabled:false
|
||||||
|
CheckBox Test "Test only, do not save" checked:false enabled:false
|
||||||
|
CheckBox BackupFiles "Backup files" checked:false enabled:false
|
||||||
|
CheckBox StopOnError "Stop on error" checked:false enabled:false
|
||||||
|
CheckBox UseTag "Use tag" checked:false enabled:false
|
||||||
|
|
||||||
|
Label ProgressText width:500 align:#left
|
||||||
|
ProgressBar Progress width:500 align:#left
|
||||||
|
|
||||||
|
Button GoButton "Go" width:500 align:#left
|
||||||
|
)
|
||||||
|
|
||||||
|
local countModifications
|
||||||
|
local countErrors
|
||||||
|
local fileModified
|
||||||
|
local fileParsed
|
||||||
|
|
||||||
|
fn UpdateData =
|
||||||
|
(
|
||||||
|
if SourceFiles.state == 2 then
|
||||||
|
isSourceDir = true
|
||||||
|
else
|
||||||
|
isSourceDir = false
|
||||||
|
if Test.checked == true then
|
||||||
|
isTest = true
|
||||||
|
else
|
||||||
|
isTest = false
|
||||||
|
|
||||||
|
Directory.enabled = isSourceDir
|
||||||
|
BrowseDirectory.enabled = isSourceDir
|
||||||
|
Recurse.enabled = isSourceDir
|
||||||
|
Test.enabled = isSourceDir
|
||||||
|
BackupFiles.enabled = isSourceDir and (isTest == false)
|
||||||
|
StopOnError.enabled = isSourceDir
|
||||||
|
UseTag.enabled = isSourceDir
|
||||||
|
)
|
||||||
|
|
||||||
|
on SourceFiles changed state do
|
||||||
|
(
|
||||||
|
UpdateData ()
|
||||||
|
)
|
||||||
|
|
||||||
|
on Test changed state do
|
||||||
|
(
|
||||||
|
UpdateData ()
|
||||||
|
)
|
||||||
|
|
||||||
|
fn call_do_it =
|
||||||
|
(
|
||||||
|
local result
|
||||||
|
|
||||||
|
-- One more project
|
||||||
|
fileParsed = fileParsed + 1
|
||||||
|
|
||||||
|
-- Call it
|
||||||
|
result = do_it ()
|
||||||
|
|
||||||
|
-- Error ?
|
||||||
|
if result < 0 then
|
||||||
|
countErrors = countErrors + 1
|
||||||
|
else
|
||||||
|
countModifications = countModifications + result
|
||||||
|
|
||||||
|
-- Return result
|
||||||
|
return result
|
||||||
|
)
|
||||||
|
|
||||||
|
fn BackupFile file =
|
||||||
|
(
|
||||||
|
local i
|
||||||
|
local newFilename
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while true do
|
||||||
|
(
|
||||||
|
-- New file name
|
||||||
|
newFilename = file + ".backup_" + (i as string)
|
||||||
|
|
||||||
|
-- File exist ?
|
||||||
|
if (fileExist newFilename) == false then
|
||||||
|
(
|
||||||
|
if (copyFile file newFilename) == false then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
)
|
||||||
|
i = i + 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fn RecurseFolder currentDirectory =
|
||||||
|
(
|
||||||
|
resetMAXFile #noprompt
|
||||||
|
|
||||||
|
local result
|
||||||
|
local file
|
||||||
|
local files
|
||||||
|
local origAnimStart
|
||||||
|
local origAnimEnd
|
||||||
|
local origFrameRate
|
||||||
|
|
||||||
|
-- Parse files
|
||||||
|
files = getFiles (currentDirectory+"/*.max")
|
||||||
|
|
||||||
|
-- For each files
|
||||||
|
for i = 1 to files.count do
|
||||||
|
(
|
||||||
|
-- File name
|
||||||
|
file = files[i]
|
||||||
|
|
||||||
|
-- Progress bar
|
||||||
|
ProgressText.text = "In directory "+currentDirectory+", compute file \"" + (getFilenameFile file) + "\""
|
||||||
|
Progress.value = i*100/files.count
|
||||||
|
|
||||||
|
if (UseTag.checked == false) or ((NeLTestFileDate file "W:/database/conversion.tag") == true) then
|
||||||
|
(
|
||||||
|
resetMAXFile #noprompt
|
||||||
|
|
||||||
|
nllog("CONVERT " + file)
|
||||||
|
|
||||||
|
-- Open the max project
|
||||||
|
if loadMaxFile file quiet:true == true then
|
||||||
|
(
|
||||||
|
origAnimStart = animationRange.start
|
||||||
|
origAnimEnd = animationRange.end
|
||||||
|
origFrameRate = frameRate
|
||||||
|
|
||||||
|
resetMAXFile #noprompt
|
||||||
|
|
||||||
|
animationRange = interval origAnimStart origAnimEnd
|
||||||
|
frameRate = origFrameRate
|
||||||
|
|
||||||
|
-- Merge the max project
|
||||||
|
if mergeMaxFile file quiet:true == true then
|
||||||
|
(
|
||||||
|
result = call_do_it ()
|
||||||
|
|
||||||
|
-- Error ?
|
||||||
|
if result < 0 then
|
||||||
|
(
|
||||||
|
if StopOnError.checked == true then
|
||||||
|
Messagebox ("Error in file " + file)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
-- Save the max project ?
|
||||||
|
if (Test.checked == false) and (result != 0) then
|
||||||
|
(
|
||||||
|
-- Backup the max project ?
|
||||||
|
local ok
|
||||||
|
ok = true
|
||||||
|
if BackupFiles.checked == true then
|
||||||
|
(
|
||||||
|
-- Backup the file
|
||||||
|
if (BackupFile file) == false then
|
||||||
|
(
|
||||||
|
-- Don't save the file because backup has failed
|
||||||
|
ok = false
|
||||||
|
|
||||||
|
if StopOnError.checked == true then
|
||||||
|
Messagebox ("Can't backup file " + file)
|
||||||
|
|
||||||
|
-- One more error
|
||||||
|
countErrors = countErrors + 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Save the max project ?
|
||||||
|
if ok == true then
|
||||||
|
(
|
||||||
|
if (saveMaxFile file) == true then
|
||||||
|
(
|
||||||
|
fileModified = fileModified + 1
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
if StopOnError.checked == true then
|
||||||
|
Messagebox ("Can't write file " + file)
|
||||||
|
|
||||||
|
-- One more error
|
||||||
|
countErrors = countErrors + 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
if StopOnError.checked == true then
|
||||||
|
Messagebox ("Can't load file " + file)
|
||||||
|
|
||||||
|
-- One more error
|
||||||
|
countErrors = countErrors + 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
nllog("SKIP " + file + " by tag")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Parse sub directory ?
|
||||||
|
if (Recurse.checked == true) then
|
||||||
|
(
|
||||||
|
local directories
|
||||||
|
|
||||||
|
-- Get the directories
|
||||||
|
directories = getDirectories (currentDirectory+"/*")
|
||||||
|
|
||||||
|
-- For each directories
|
||||||
|
for dir in directories do
|
||||||
|
(
|
||||||
|
RecurseFolder dir
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
on BrowseDirectory pressed do
|
||||||
|
(
|
||||||
|
local dir
|
||||||
|
try
|
||||||
|
(
|
||||||
|
dir = getSavePath () -- caption:"Select the projects directory"
|
||||||
|
if dir != undefined then
|
||||||
|
Directory.text = dir
|
||||||
|
)
|
||||||
|
catch
|
||||||
|
(
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
on GoButton pressed do
|
||||||
|
(
|
||||||
|
-- Reset count
|
||||||
|
countModifications = 0
|
||||||
|
countErrors = 0
|
||||||
|
fileModified = 0
|
||||||
|
fileParsed = 0
|
||||||
|
|
||||||
|
-- Get files in the shape_source_directory
|
||||||
|
if SourceFiles.state == 2 then
|
||||||
|
(
|
||||||
|
-- Should warning user ?
|
||||||
|
if (SourceFiles.state == 2) and (Test.checked == false) then
|
||||||
|
(
|
||||||
|
-- Warning !
|
||||||
|
if ((queryBox "Warning, all the files in the specified folders will be overwrited.\nYou should backup your files before executing this script.\nDo you want to continue executing this script ?" beep:true) == true) then
|
||||||
|
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
RecurseFolder (adjustPathStringForScript Directory.text)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
(
|
||||||
|
-- Just compute the current project
|
||||||
|
call_do_it ()
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Show errors
|
||||||
|
ProgressText.text = (fileParsed as string) + " project(s) opened, " + (countModifications as string) + " project modification(s), " + (fileModified as string) + " project(s) saved, " + (countErrors as string) + " error(s)."
|
||||||
|
Progress.value = 100
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
assets_png_floater = newRolloutFloater "NeL Assets PNG Database" 550 874
|
assets_png_floater = newRolloutFloater "NeL Assets PNG Database" 550 874
|
||||||
|
|
|
@ -969,6 +969,20 @@ plugin material NelMaterial
|
||||||
cbTexGen_7.enabled = bNormalShader and bEnableSlot_7 and (not bLightmap) and (not bSpecular) and (not bUserColor) and (not bNormalShader) and (not bPerPixelLightingShader)
|
cbTexGen_7.enabled = bNormalShader and bEnableSlot_7 and (not bLightmap) and (not bSpecular) and (not bUserColor) and (not bNormalShader) and (not bPerPixelLightingShader)
|
||||||
cbTexGen_8.enabled = bNormalShader and bEnableSlot_8 and (not bLightmap) and (not bSpecular) and (not bUserColor) and (not bNormalShader) and (not bPerPixelLightingShader)
|
cbTexGen_8.enabled = bNormalShader and bEnableSlot_8 and (not bLightmap) and (not bSpecular) and (not bUserColor) and (not bNormalShader) and (not bPerPixelLightingShader)
|
||||||
|
|
||||||
|
delegate.DiffuseMapEnable = bEnableSlot_1
|
||||||
|
delegate.DiffuseMap = tTexture_1
|
||||||
|
delegate.AmbientMapEnable = bEnableSlot_1
|
||||||
|
delegate.AmbientMap = tTexture_1
|
||||||
|
delegate.SpecularMapEnable = bEnableSlot_2
|
||||||
|
delegate.SpecularMap = tTexture_2
|
||||||
|
delegate.SelfIllumMap = undefined
|
||||||
|
delegate.OpacityMap = undefined
|
||||||
|
delegate.FilterMap = undefined
|
||||||
|
delegate.BumpMap = undefined
|
||||||
|
delegate.DisplacementMap = undefined
|
||||||
|
delegate.ReflectionMap = undefined
|
||||||
|
delegate.RefractionMap = undefined
|
||||||
|
|
||||||
btLoadShader.enabled = bNormalShader
|
btLoadShader.enabled = bNormalShader
|
||||||
dlShader.enabled = bNormalShader
|
dlShader.enabled = bNormalShader
|
||||||
|
|
||||||
|
@ -1059,6 +1073,17 @@ plugin material NelMaterial
|
||||||
on NelTexture close do
|
on NelTexture close do
|
||||||
(
|
(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
on tTexture_1 changed newState do
|
||||||
|
(
|
||||||
|
delegate.DiffuseMap = tTexture_1
|
||||||
|
delegate.AmbientMap = tTexture_1
|
||||||
|
)
|
||||||
|
|
||||||
|
on tTexture_2 changed newState do
|
||||||
|
(
|
||||||
|
delegate.SpecularMap = tTexture_2
|
||||||
|
)
|
||||||
|
|
||||||
on cbEnableSlot_1 changed newState do
|
on cbEnableSlot_1 changed newState do
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in a new issue