Changed: #1092 Improved build pipeline scripts to properly avoid 3ds max hanging and handle crashes without user interference

This commit is contained in:
kaetemi 2010-09-26 17:07:13 +02:00
parent 5d9db22b91
commit 76b1a30af9
23 changed files with 1562 additions and 704 deletions

View file

@ -90,8 +90,6 @@ def generateSimpleMaxExporter(processName, fileExtension, sourceDirectoriesVaria
generateSimpleMaxExporter("pacs_prim", "pacs_prim", "PacsPrimSourceDirectories", "PacsPrimExportDirectory", "PacsPrimInstallDirectory") generateSimpleMaxExporter("pacs_prim", "pacs_prim", "PacsPrimSourceDirectories", "PacsPrimExportDirectory", "PacsPrimInstallDirectory")
generateSimpleMaxExporter("anim", "anim", "AnimSourceDirectories", "AnimExportDirectory", "AnimInstallDirectory")
generateSimpleMaxExporter("skel", "skel", "SkelSourceDirectories", "SkelExportDirectory", "SkelInstallDirectory") generateSimpleMaxExporter("skel", "skel", "SkelSourceDirectories", "SkelExportDirectory", "SkelInstallDirectory")
generateSimpleMaxExporter("swt", "swt", "SwtSourceDirectories", "SwtExportDirectory", "SwtInstallDirectory") generateSimpleMaxExporter("swt", "swt", "SwtSourceDirectories", "SwtExportDirectory", "SwtInstallDirectory")

View file

@ -108,6 +108,10 @@ generateTaggedMaxExporter("rbank", "cmb", "RBankCmbSourceDirectories", "RBankCmb
generateTaggedMaxExporter("veget", "veget", "VegetSourceDirectories", "VegetExportDirectory", "VegetTagExportDirectory", "VegetInstallDirectory") generateTaggedMaxExporter("veget", "veget", "VegetSourceDirectories", "VegetExportDirectory", "VegetTagExportDirectory", "VegetInstallDirectory")
generateTaggedMaxScript("shape", "shape")
generateTaggedMaxExporter("anim", "anim", "AnimSourceDirectories", "AnimExportDirectory", "AnimTagExportDirectory", "AnimInstallDirectory")
printLog(log, "") printLog(log, "")

View file

@ -5,7 +5,7 @@ NEL3D_APPDATA_EXPORT_NODE_ANIMATION = 1423062800
fn runNelMaxExport inputMaxFile = fn runNelMaxExport inputMaxFile =
( (
outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".%PreGenFileExtension%") outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".%PreGenFileExtension%")
tagThisFile = false tagThisFile = true
-- Unhide category -- Unhide category
unhidecategory() unhidecategory()
@ -55,13 +55,12 @@ fn runNelMaxExport inputMaxFile =
else else
( (
nlerror("OK " + outputNelFile) nlerror("OK " + outputNelFile)
tagThisFile = true
) )
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting animation: no node animated to export in file " + inputMaxFile) nlerror("WARNING exporting animation: no node animated to export in file " + inputMaxFile)
) )
return tagThisFile return tagThisFile

View file

@ -0,0 +1,361 @@
-- Some globals
NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized
-- "0" = is not an accelerator and IS NOT clusterized (always visible)
-- "1" = is an accelerator type PORTAL
-- "2" = is an accelerator type CLUSTER
-- "6" = is an accelerator type CLUSTER FATHER-VISIBLE
-- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER
-- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER
-- "17" = is an accelerator type PORTAL DYNAMIC
NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me
-- "0" = export me
-- "1" = DONT export me
NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10
NEL3D_APPDATA_LOD = 1423062537
NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD
NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1
NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX
NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1
NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1
NEL3D_APPDATA_COLLISION = 1423062613
NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614
NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617
-- This node is n accelerator ?
fn isAccelerator node =
(
accel = getappdata node NEL3D_APPDATA_ACCEL
if (accel != undefined) then
(
if (accel == "0") or (accel == "32") then
return false
else
return true
)
return false
)
-- Must export this node ?
fn isToBeExported node =
(
if (isAccelerator node) == true then
return false
if ((classof node) == RklPatch) then
return false
if ((classof node) == nel_ps) then
return false
if ((classof node) == nel_pacs_cylinder) then
return false
if ((classof node) == nel_pacs_box) then
return false
doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
return true
)
-- Must export this node ?
fn isAnimToBeExported node =
(
automaticAnimation = getappdata node NEL3D_APPDATA_AUTOMATIC_ANIMATION
if (automaticAnimation == undefined) then
return false
if (automaticAnimation == "0") then
return false
if (isAccelerator node) == true then
return false
if ((classof node) == nel_pacs_cylinder) then
return false
if ((classof node) == nel_pacs_box) then
return false
doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
return true
)
-- Cast shadow ?
fn isCastShadow node =
(
if (classof node == nel_ps) then
return false
if (isAccelerator node) == true then
(
return false
)
else
(
return true
)
)
-- List the lod
lod_array = #()
-- is a lod ?
fn isLod node =
(
for i = 1 to lod_array.count do
(
if (lod_array[i] == node) then
return true
)
return false
)
-- have a coarse mesh ?
fn haveCoarseMesh node =
(
-- Get lod count
nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT
if (nodeCount != undefined) then
(
-- For each lod
nodeCountNum = nodeCount as Integer
for lod = 1 to nodeCountNum do
(
-- Get the lod
lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1)
-- Exist ?
if (lod != undefined) then
(
-- Select a node
nd = execute ("$'"+lod+"'")
-- Node exist ?
if (nd != undefined) then
(
-- Is a coarse mesh ?
if (getappdata nd NEL3D_APPDATA_LOD_COARSE_MESH == "1") then
return true
)
)
)
)
return false
)
fn runNelMaxExport inputMaxFile =
(
tagThisFile = false
-- Unhide category
unhidecategory()
-- Unhide
max unhide all
-- unselect
max select none
-- Exported object count
exported = 0
-- Add the lod
for node in geometry do
(
-- Get lod count
nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT
if (nodeCount != undefined) then
(
-- For each lod
nodeCountNum = nodeCount as Integer
for lod = 1 to nodeCountNum do
(
-- Get the lod
lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1)
-- Exist ?
if (lod != undefined) then
(
-- Select a node
try
(
nd = execute("$'"+lod+"'")
)
catch
(
nlerror("Error in Execute $'"+lod+"' from node "+node.name)
nd = undefined
)
-- Node exist ?
if (nd != undefined) then
(
append lod_array nd
)
)
)
)
)
-- Select objects for shadows
for node in geometry do
(
if (node.parent == undefined) then
(
-- Cast shadow ?
if (isCastShadow node == true) then
(
-- Select this node
selectmore node
)
)
)
-- Tag this file ?
tagThisFile = true
-- Array of node to export
array_node = #()
-- Add geometry
for node in geometry do
append array_node node
-- Add shapes
for node in shapes do
append array_node node
-- For each node
for node in array_node do
(
-- It is root ?
if (node.parent == undefined) then
(
-- Is not a skeleton ?
if (node.name != "Bip01") then
(
-- Can be exported ?
if (isToBeExported node == true) then
(
-- Not a lod ?
if ((isLod node) == false) then
(
-- Output directory
if (haveCoarseMesh node) == true then
output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
else
output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
-- Compare file date
if (NeLTestFileDate output inputMaxFile) == true then
(
try
(
-- Export the shape
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
(
nlerror("OK "+output)
exported = exported +1
)
else
(
-- Error
nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
tagThisFile = false
)
)
catch
(
-- Error
nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
tagThisFile = false
)
)
else
(
nlerror("SKIPPED " + output)
exported = exported + 1
)
)
)
)
)
)
-- Export default animations
for node in objects do
(
-- Can export it ?
if (isAnimToBeExported node) == true then
(
-- Anim output directory
output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim")
-- Export the animation
if (NelExportAnimation #(node) output false) == false then
(
nlerror ("ERROR exporting animation " + output)
tagThisFile = false
)
else
(
nlerror("OK " + output)
)
)
)
-- Something exported
if exported == 0 then
(
-- Error
nlerror("WARNING no shape exported from the file " + inputMaxFile)
)
return tagThisFile
)

View file

@ -1,7 +1,9 @@
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"):
os.remove("log.log")
shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -33,7 +33,9 @@ sys.path.append("../../configuration")
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
log = open("log.log", "w") if os.path.isfile("temp_log.log"):
os.remove("temp_log.log")
log = open("temp_log.log", "w")
from scripts import * from scripts import *
from buildsite import * from buildsite import *
from process import * from process import *
@ -69,6 +71,7 @@ if MaxAvailable:
outputDirectory = ExportBuildDirectory + "/" + %PreGenExportDirectoryVariable% outputDirectory = ExportBuildDirectory + "/" + %PreGenExportDirectoryVariable%
tagDirectory = ExportBuildDirectory + "/" + %PreGenTagExportDirectoryVariable% tagDirectory = ExportBuildDirectory + "/" + %PreGenTagExportDirectoryVariable%
maxSourceDir = DatabaseDirectory + "/" + dir maxSourceDir = DatabaseDirectory + "/" + dir
maxRunningTagFile = tagDirectory + "/max_running.tag"
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
tagLen = len(tagList) tagLen = len(tagList)
if os.path.isfile(scriptDst): if os.path.isfile(scriptDst):
@ -84,13 +87,44 @@ if MaxAvailable:
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
zeroRetryLimit = 3
while tagDiff > 0: while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst) printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "%PreGenFileExtension%_export.ms", "-q", "-mi", "-vn" ]) subprocess.call([ Max, "-U", "MAXScript", "%PreGenFileExtension%_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
newTagLen = len(tagList) newTagLen = len(tagList)
tagDiff = newTagLen - tagLen tagDiff = newTagLen - tagLen
tagLen = newTagLen tagLen = newTagLen
addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!") printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
printLog(log, "")

View file

@ -1,89 +1,125 @@
removeRunningTag = true
try try
( (
-- Get files in the %MaxSourceDirectory% directory undo off
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
-- For each files -- Get files in the %MaxSourceDirectory% directory
for i = 1 to files.count do files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
inputMaxFile = files[i] -- For each files
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") for i = 1 to files.count do
try
( (
-- Compare file date inputMaxFile = files[i]
if (NeLTestFileDate outputTagFile inputMaxFile) == true then outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
(
-- Free memory and file handles --try
gc() --(
heapfree -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagThisFile = runNelMaxExport(inputMaxFile) -- Free memory and file handles
gc()
heapfree
-- Write a tag file -- Reset 3dsmax
if tagThisFile == true then resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagFile = createFile outputTagFile tagThisFile = runNelMaxExport(inputMaxFile)
if tagFile == undefined then
-- Write a tag file
if tagThisFile == true then
( (
nlerror("WARNING can't create tag file " + outputTagFile) tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
) )
else else
( (
print "mukyu" to: tagFile removeRunningTag = false
close tagFile
) )
) )
else
(
-- Error
nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile)
removeRunningTag = false
)
) )
else else
( (
-- Error nlerror("SKIPPED BY TAG " + inputMaxFile)
nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile)
) )
) --)
else --catch
( --(
nlerror("SKIPPED BY TAG " + inputMaxFile) -- -- Error
) -- nlerror("ERROR error exporting '%PreGenFileExtension%' in file " + inputMaxFile)
) -- removeRunningTag = false
catch --)
(
-- Error
nlerror("ERROR error exporting '%PreGenFileExtension%' in files " + inputMaxFile)
) )
) )
) else
else (
( nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") )
) )
) )
catch catch
( (
-- Error -- Error
nlerror("ERROR fatal error exporting '%PreGenFileExtension%' in folder %MaxSourceDirectory%") nlerror("ERROR fatal error exporting '%PreGenFileExtension%' in folder %MaxSourceDirectory%")
removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
if (removeRunningTag) then
(
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
) )
-- Bye -- Bye
nlerror("BYE")
resetMAXFile #noprompt
quitMAX #noPrompt quitMAX #noPrompt
quitMAX() #noPrompt quitMAX() #noPrompt

View file

@ -8,6 +8,9 @@
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%" nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then

View file

@ -6,7 +6,7 @@
# #
# \file 1_export.py # \file 1_export.py
# \brief Export anim # \brief Export anim
# \date 2010-09-19-14-19-GMT # \date 2010-09-26-08-38-GMT
# \author Jan Boon (Kaetemi) # \author Jan Boon (Kaetemi)
# Python port of game data build pipeline. # Python port of game data build pipeline.
# Export anim # Export anim
@ -33,7 +33,9 @@ sys.path.append("../../configuration")
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
log = open("log.log", "w") if os.path.isfile("temp_log.log"):
os.remove("temp_log.log")
log = open("temp_log.log", "w")
from scripts import * from scripts import *
from buildsite import * from buildsite import *
from process import * from process import *
@ -47,6 +49,7 @@ printLog(log, "-------")
printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
printLog(log, "") printLog(log, "")
# Find tools # Find tools
# ... # ...
@ -58,15 +61,18 @@ if MaxAvailable:
printLog(log, ">>> Export anim 3dsmax <<<") printLog(log, ">>> Export anim 3dsmax <<<")
mkPath(log, ExportBuildDirectory + "/" + AnimExportDirectory) mkPath(log, ExportBuildDirectory + "/" + AnimExportDirectory)
mkPath(log, ExportBuildDirectory + "/" + AnimTagExportDirectory)
for dir in AnimSourceDirectories: for dir in AnimSourceDirectories:
mkPath(log, DatabaseDirectory + "/" + dir) mkPath(log, DatabaseDirectory + "/" + dir)
if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + AnimExportDirectory, ".anim")): if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + AnimTagExportDirectory, ".max.tag")):
scriptSrc = "maxscript/anim_export.ms" scriptSrc = "maxscript/anim_export.ms"
scriptDst = MaxUserDirectory + "/scripts/anim_export.ms" scriptDst = MaxUserDirectory + "/scripts/anim_export.ms"
outputLogfile = ScriptDirectory + "/processes/anim/log.log" outputLogfile = ScriptDirectory + "/processes/anim/log.log"
outputDirectory = ExportBuildDirectory + "/" + AnimExportDirectory outputDirectory = ExportBuildDirectory + "/" + AnimExportDirectory
tagDirectory = ExportBuildDirectory + "/" + AnimTagExportDirectory
maxSourceDir = DatabaseDirectory + "/" + dir maxSourceDir = DatabaseDirectory + "/" + dir
tagList = findFiles(log, outputDirectory, "", ".anim") maxRunningTagFile = tagDirectory + "/max_running.tag"
tagList = findFiles(log, tagDirectory, "", ".max.tag")
tagLen = len(tagList) tagLen = len(tagList)
if os.path.isfile(scriptDst): if os.path.isfile(scriptDst):
os.remove(scriptDst) os.remove(scriptDst)
@ -77,23 +83,57 @@ if MaxAvailable:
newline = line.replace("%OutputLogfile%", outputLogfile) newline = line.replace("%OutputLogfile%", outputLogfile)
newline = newline.replace("%MaxSourceDirectory%", maxSourceDir) newline = newline.replace("%MaxSourceDirectory%", maxSourceDir)
newline = newline.replace("%OutputDirectory%", outputDirectory) newline = newline.replace("%OutputDirectory%", outputDirectory)
newline = newline.replace("%TagDirectory%", tagDirectory)
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
zeroRetryLimit = 3
while tagDiff > 0: while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst) printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "anim_export.ms", "-q", "-mi", "-vn" ]) subprocess.call([ Max, "-U", "MAXScript", "anim_export.ms", "-q", "-mi", "-vn" ])
tagList = findFiles(log, outputDirectory, "", ".anim") if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".max.tag")
newTagLen = len(tagList) newTagLen = len(tagList)
tagDiff = newTagLen - tagLen tagDiff = newTagLen - tagLen
tagLen = newTagLen tagLen = newTagLen
printLog(log, "Exported " + str(tagDiff) + " .anim files!") addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
printLog(log, "")
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"):
os.remove("log.log")
shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -8,6 +8,9 @@
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%" nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then
@ -68,7 +71,7 @@ NEL3D_APPDATA_EXPORT_NODE_ANIMATION = 1423062800
fn runNelMaxExport inputMaxFile = fn runNelMaxExport inputMaxFile =
( (
outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".anim") outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".anim")
tagThisFile = false tagThisFile = true
-- Unhide category -- Unhide category
unhidecategory() unhidecategory()
@ -118,13 +121,12 @@ fn runNelMaxExport inputMaxFile =
else else
( (
nlerror("OK " + outputNelFile) nlerror("OK " + outputNelFile)
tagThisFile = true
) )
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting animation: no node animated to export in file " + inputMaxFile) nlerror("WARNING exporting animation: no node animated to export in file " + inputMaxFile)
) )
return tagThisFile return tagThisFile
@ -132,75 +134,126 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
( (
-- Get files in the %MaxSourceDirectory% directory undo off
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
-- For each files -- Get files in the %MaxSourceDirectory% directory
for i = 1 to files.count do files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
inputMaxFile = files[i] -- For each files
outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".anim") for i = 1 to files.count do
try
( (
-- Compare file date inputMaxFile = files[i]
if (NeLTestFileDate outputNelFile inputMaxFile) == true then outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
(
-- Free memory and file handles --try
gc() --(
heapfree -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
runNelMaxExport(inputMaxFile) -- Free memory and file handles
gc()
heapfree
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
(
tagThisFile = runNelMaxExport(inputMaxFile)
-- Write a tag file
if tagThisFile == true then
(
tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
)
else
(
removeRunningTag = false
)
)
else
(
-- Error
nlerror("ERROR exporting 'anim': can't open the file " + inputMaxFile)
removeRunningTag = false
)
) )
else else
( (
-- Error nlerror("SKIPPED BY TAG " + inputMaxFile)
nlerror("ERROR exporting 'anim': can't open the file " + inputMaxFile)
) )
) --)
else --catch
( --(
nlerror("SKIPPED " + inputMaxFile) -- -- Error
) -- nlerror("ERROR error exporting 'anim' in file " + inputMaxFile)
) -- removeRunningTag = false
catch --)
(
-- Error
nlerror("ERROR error exporting 'anim' in files " + inputMaxFile)
) )
) )
) else
else (
( nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") )
) )
) )
catch catch
( (
-- Error -- Error
nlerror("ERROR fatal error exporting 'anim' in folder %MaxSourceDirectory%") nlerror("ERROR fatal error exporting 'anim' in folder %MaxSourceDirectory%")
removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
if (removeRunningTag) then
(
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
) )
-- Bye -- Bye
nlerror("BYE")
resetMAXFile #noprompt
quitMAX #noPrompt quitMAX #noPrompt
quitMAX() #noPrompt quitMAX() #noPrompt

View file

@ -6,7 +6,7 @@
# #
# \file 1_export.py # \file 1_export.py
# \brief Export clodbank # \brief Export clodbank
# \date 2010-09-19-14-19-GMT # \date 2010-09-26-08-38-GMT
# \author Jan Boon (Kaetemi) # \author Jan Boon (Kaetemi)
# Python port of game data build pipeline. # Python port of game data build pipeline.
# Export clodbank # Export clodbank
@ -33,7 +33,9 @@ sys.path.append("../../configuration")
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
log = open("log.log", "w") if os.path.isfile("temp_log.log"):
os.remove("temp_log.log")
log = open("temp_log.log", "w")
from scripts import * from scripts import *
from buildsite import * from buildsite import *
from process import * from process import *
@ -69,6 +71,7 @@ if MaxAvailable:
outputDirectory = ExportBuildDirectory + "/" + ClodExportDirectory outputDirectory = ExportBuildDirectory + "/" + ClodExportDirectory
tagDirectory = ExportBuildDirectory + "/" + ClodTagExportDirectory tagDirectory = ExportBuildDirectory + "/" + ClodTagExportDirectory
maxSourceDir = DatabaseDirectory + "/" + dir maxSourceDir = DatabaseDirectory + "/" + dir
maxRunningTagFile = tagDirectory + "/max_running.tag"
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
tagLen = len(tagList) tagLen = len(tagList)
if os.path.isfile(scriptDst): if os.path.isfile(scriptDst):
@ -84,20 +87,53 @@ if MaxAvailable:
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
zeroRetryLimit = 3
while tagDiff > 0: while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst) printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "clod_export.ms", "-q", "-mi", "-vn" ]) subprocess.call([ Max, "-U", "MAXScript", "clod_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
newTagLen = len(tagList) newTagLen = len(tagList)
tagDiff = newTagLen - tagLen tagDiff = newTagLen - tagLen
tagLen = newTagLen tagLen = newTagLen
addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!") printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
printLog(log, "")
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"):
os.remove("log.log")
shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -8,6 +8,9 @@
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%" nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then
@ -186,90 +189,126 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
( (
-- Get files in the %MaxSourceDirectory% directory undo off
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
-- For each files -- Get files in the %MaxSourceDirectory% directory
for i = 1 to files.count do files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
inputMaxFile = files[i] -- For each files
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") for i = 1 to files.count do
try
( (
-- Compare file date inputMaxFile = files[i]
if (NeLTestFileDate outputTagFile inputMaxFile) == true then outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
(
-- Free memory and file handles --try
gc() --(
heapfree -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagThisFile = runNelMaxExport(inputMaxFile) -- Free memory and file handles
gc()
heapfree
-- Write a tag file -- Reset 3dsmax
if tagThisFile == true then resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagFile = createFile outputTagFile tagThisFile = runNelMaxExport(inputMaxFile)
if tagFile == undefined then
-- Write a tag file
if tagThisFile == true then
( (
nlerror("WARNING can't create tag file " + outputTagFile) tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
) )
else else
( (
print "mukyu" to: tagFile removeRunningTag = false
close tagFile
) )
) )
else
(
-- Error
nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile)
removeRunningTag = false
)
) )
else else
( (
-- Error nlerror("SKIPPED BY TAG " + inputMaxFile)
nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile)
) )
) --)
else --catch
( --(
nlerror("SKIPPED BY TAG " + inputMaxFile) -- -- Error
) -- nlerror("ERROR error exporting 'clod' in file " + inputMaxFile)
) -- removeRunningTag = false
catch --)
(
-- Error
nlerror("ERROR error exporting 'clod' in files " + inputMaxFile)
) )
) )
) else
else (
( nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") )
) )
) )
catch catch
( (
-- Error -- Error
nlerror("ERROR fatal error exporting 'clod' in folder %MaxSourceDirectory%") nlerror("ERROR fatal error exporting 'clod' in folder %MaxSourceDirectory%")
removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
if (removeRunningTag) then
(
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
) )
-- Bye -- Bye
nlerror("BYE")
resetMAXFile #noprompt
quitMAX #noPrompt quitMAX #noPrompt
quitMAX() #noPrompt quitMAX() #noPrompt

View file

@ -29,7 +29,9 @@ sys.path.append("../../configuration")
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
log = open("log.log", "w") if os.path.isfile("temp_log.log"):
os.remove("temp_log.log")
log = open("temp_log.log", "w")
from scripts import * from scripts import *
from buildsite import * from buildsite import *
from process import * from process import *
@ -53,6 +55,7 @@ def igExport(sourceDir, targetDir):
tagDirectory = ExportBuildDirectory + "/" + IgStaticTagExportDirectory tagDirectory = ExportBuildDirectory + "/" + IgStaticTagExportDirectory
outputDirectory = ExportBuildDirectory + "/" + targetDir outputDirectory = ExportBuildDirectory + "/" + targetDir
maxSourceDir = DatabaseDirectory + "/" + sourceDir maxSourceDir = DatabaseDirectory + "/" + sourceDir
maxRunningTagFile = tagDirectory + "/max_running.tag"
if (needUpdateDirByTagLog(log, maxSourceDir, ".max", tagDirectory, ".max.tag")): if (needUpdateDirByTagLog(log, maxSourceDir, ".max", tagDirectory, ".max.tag")):
tagList = findFiles(log, tagDirectory, "", ".tag") tagList = findFiles(log, tagDirectory, "", ".tag")
tagLen = len(tagList) tagLen = len(tagList)
@ -69,14 +72,44 @@ def igExport(sourceDir, targetDir):
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
zeroRetryLimit = 3
while tagDiff > 0: while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst) printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "ig_export.ms", "-q", "-mi", "-vn" ]) subprocess.call([ Max, "-U", "MAXScript", "ig_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".tag") tagList = findFiles(log, tagDirectory, "", ".tag")
newTagLen = len(tagList) newTagLen = len(tagList)
tagDiff = newTagLen - tagLen tagDiff = newTagLen - tagLen
tagLen = newTagLen tagLen = newTagLen
addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!") printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
return return
@ -95,6 +128,7 @@ if MaxAvailable:
for dir in IgLandSourceDirectories: for dir in IgLandSourceDirectories:
mkPath(log, DatabaseDirectory + "/" + dir) mkPath(log, DatabaseDirectory + "/" + dir)
igExport(dir, IgStaticLandExportDirectory) igExport(dir, IgStaticLandExportDirectory)
printLog(log, "")
# Export ig other 3dsmax # Export ig other 3dsmax
printLog(log, ">>> Export ig other 3dsmax <<<") printLog(log, ">>> Export ig other 3dsmax <<<")
@ -102,11 +136,13 @@ if MaxAvailable:
for dir in IgOtherSourceDirectories: for dir in IgOtherSourceDirectories:
mkPath(log, DatabaseDirectory + "/" + dir) mkPath(log, DatabaseDirectory + "/" + dir)
igExport(dir, IgStaticOtherExportDirectory) igExport(dir, IgStaticOtherExportDirectory)
printLog(log, "")
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"):
os.remove("log.log")
shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -8,6 +8,9 @@
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%" nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then
@ -235,90 +238,126 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
( (
-- Get files in the %MaxSourceDirectory% directory undo off
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
-- For each files -- Get files in the %MaxSourceDirectory% directory
for i = 1 to files.count do files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
inputMaxFile = files[i] -- For each files
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") for i = 1 to files.count do
try
( (
-- Compare file date inputMaxFile = files[i]
if (NeLTestFileDate outputTagFile inputMaxFile) == true then outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
(
-- Free memory and file handles --try
gc() --(
heapfree -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagThisFile = runNelMaxExport(inputMaxFile) -- Free memory and file handles
gc()
heapfree
-- Write a tag file -- Reset 3dsmax
if tagThisFile == true then resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagFile = createFile outputTagFile tagThisFile = runNelMaxExport(inputMaxFile)
if tagFile == undefined then
-- Write a tag file
if tagThisFile == true then
( (
nlerror("WARNING can't create tag file " + outputTagFile) tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
) )
else else
( (
print "mukyu" to: tagFile removeRunningTag = false
close tagFile
) )
) )
else
(
-- Error
nlerror("ERROR exporting 'ig': can't open the file " + inputMaxFile)
removeRunningTag = false
)
) )
else else
( (
-- Error nlerror("SKIPPED BY TAG " + inputMaxFile)
nlerror("ERROR exporting 'ig': can't open the file " + inputMaxFile)
) )
) --)
else --catch
( --(
nlerror("SKIPPED BY TAG " + inputMaxFile) -- -- Error
) -- nlerror("ERROR error exporting 'ig' in file " + inputMaxFile)
) -- removeRunningTag = false
catch --)
(
-- Error
nlerror("ERROR error exporting 'ig' in files " + inputMaxFile)
) )
) )
) else
else (
( nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") )
) )
) )
catch catch
( (
-- Error -- Error
nlerror("ERROR fatal error exporting 'ig' in folder %MaxSourceDirectory%") nlerror("ERROR fatal error exporting 'ig' in folder %MaxSourceDirectory%")
removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
if (removeRunningTag) then
(
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
) )
-- Bye -- Bye
nlerror("BYE")
resetMAXFile #noprompt
quitMAX #noPrompt quitMAX #noPrompt
quitMAX() #noPrompt quitMAX() #noPrompt

View file

@ -6,7 +6,7 @@
# #
# \file 1_export.py # \file 1_export.py
# \brief Export rbank # \brief Export rbank
# \date 2010-09-19-14-19-GMT # \date 2010-09-26-08-38-GMT
# \author Jan Boon (Kaetemi) # \author Jan Boon (Kaetemi)
# Python port of game data build pipeline. # Python port of game data build pipeline.
# Export rbank # Export rbank
@ -33,7 +33,9 @@ sys.path.append("../../configuration")
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
log = open("log.log", "w") if os.path.isfile("temp_log.log"):
os.remove("temp_log.log")
log = open("temp_log.log", "w")
from scripts import * from scripts import *
from buildsite import * from buildsite import *
from process import * from process import *
@ -69,6 +71,7 @@ if MaxAvailable:
outputDirectory = ExportBuildDirectory + "/" + RBankCmbExportDirectory outputDirectory = ExportBuildDirectory + "/" + RBankCmbExportDirectory
tagDirectory = ExportBuildDirectory + "/" + RBankCmbTagExportDirectory tagDirectory = ExportBuildDirectory + "/" + RBankCmbTagExportDirectory
maxSourceDir = DatabaseDirectory + "/" + dir maxSourceDir = DatabaseDirectory + "/" + dir
maxRunningTagFile = tagDirectory + "/max_running.tag"
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
tagLen = len(tagList) tagLen = len(tagList)
if os.path.isfile(scriptDst): if os.path.isfile(scriptDst):
@ -84,20 +87,53 @@ if MaxAvailable:
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
zeroRetryLimit = 3
while tagDiff > 0: while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst) printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "cmb_export.ms", "-q", "-mi", "-vn" ]) subprocess.call([ Max, "-U", "MAXScript", "cmb_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
newTagLen = len(tagList) newTagLen = len(tagList)
tagDiff = newTagLen - tagLen tagDiff = newTagLen - tagLen
tagLen = newTagLen tagLen = newTagLen
addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!") printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
printLog(log, "")
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"):
os.remove("log.log")
shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -8,6 +8,9 @@
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%" nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then
@ -122,90 +125,126 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
( (
-- Get files in the %MaxSourceDirectory% directory undo off
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
-- For each files -- Get files in the %MaxSourceDirectory% directory
for i = 1 to files.count do files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
inputMaxFile = files[i] -- For each files
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") for i = 1 to files.count do
try
( (
-- Compare file date inputMaxFile = files[i]
if (NeLTestFileDate outputTagFile inputMaxFile) == true then outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
(
-- Free memory and file handles --try
gc() --(
heapfree -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagThisFile = runNelMaxExport(inputMaxFile) -- Free memory and file handles
gc()
heapfree
-- Write a tag file -- Reset 3dsmax
if tagThisFile == true then resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagFile = createFile outputTagFile tagThisFile = runNelMaxExport(inputMaxFile)
if tagFile == undefined then
-- Write a tag file
if tagThisFile == true then
( (
nlerror("WARNING can't create tag file " + outputTagFile) tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
) )
else else
( (
print "mukyu" to: tagFile removeRunningTag = false
close tagFile
) )
) )
else
(
-- Error
nlerror("ERROR exporting 'cmb': can't open the file " + inputMaxFile)
removeRunningTag = false
)
) )
else else
( (
-- Error nlerror("SKIPPED BY TAG " + inputMaxFile)
nlerror("ERROR exporting 'cmb': can't open the file " + inputMaxFile)
) )
) --)
else --catch
( --(
nlerror("SKIPPED BY TAG " + inputMaxFile) -- -- Error
) -- nlerror("ERROR error exporting 'cmb' in file " + inputMaxFile)
) -- removeRunningTag = false
catch --)
(
-- Error
nlerror("ERROR error exporting 'cmb' in files " + inputMaxFile)
) )
) )
) else
else (
( nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") )
) )
) )
catch catch
( (
-- Error -- Error
nlerror("ERROR fatal error exporting 'cmb' in folder %MaxSourceDirectory%") nlerror("ERROR fatal error exporting 'cmb' in folder %MaxSourceDirectory%")
removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
if (removeRunningTag) then
(
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
) )
-- Bye -- Bye
nlerror("BYE")
resetMAXFile #noprompt
quitMAX #noPrompt quitMAX #noPrompt
quitMAX() #noPrompt quitMAX() #noPrompt

View file

@ -2,7 +2,7 @@
# #
# \file 1_export.py # \file 1_export.py
# \brief Export shape # \brief Export shape
# \date 2010-05-24 13:42GMT # \date 2010-09-20-18-35-GMT
# \author Jan Boon (Kaetemi) # \author Jan Boon (Kaetemi)
# Python port of game data build pipeline. # Python port of game data build pipeline.
# Export shape # Export shape
@ -38,9 +38,6 @@ from process import *
from tools import * from tools import *
from directories import * from directories import *
def getTagFileName(filePath):
return os.path.split(filePath)[1] + ".tag"
printLog(log, "") printLog(log, "")
printLog(log, "-------") printLog(log, "-------")
printLog(log, "--- Export shape") printLog(log, "--- Export shape")
@ -56,22 +53,19 @@ if BuildQuality == 0:
ShapeExportOptLumelSize = "0.25" ShapeExportOptLumelSize = "0.25"
ShapeExportOptOversampling = 1 ShapeExportOptOversampling = 1
# Find tools
# ...
# Export shape 3dsmax
if MaxAvailable: if MaxAvailable:
# Find tools # Find tools
Max = findMax(log, MaxDirectory, MaxExecutable) Max = findMax(log, MaxDirectory, MaxExecutable)
ExecTimeout = findTool(log, ToolDirectories, ExecTimeoutTool, ToolSuffix)
printLog(log, "") printLog(log, "")
# Export shape 3dsmax
printLog(log, ">>> Export shape 3dsmax <<<") printLog(log, ">>> Export shape 3dsmax <<<")
tagDirectory = ExportBuildDirectory + "/" + ShapeTagExportDirectory
# Build paths mkPath(log, tagDirectory)
scriptSrc = "maxscript/shape_export.ms"
# scriptDst = MaxDirectory + "/scripts/shape_export.ms"
scriptDst = MaxUserDirectory + "/scripts/shape_export.ms"
logFile = ScriptDirectory + "/processes/shape/log.log"
outDirTag = ExportBuildDirectory + "/" + ShapeTagExportDirectory
mkPath(log, outDirTag)
outDirWithoutCoarse = ExportBuildDirectory + "/" + ShapeNotOptimizedExportDirectory outDirWithoutCoarse = ExportBuildDirectory + "/" + ShapeNotOptimizedExportDirectory
mkPath(log, outDirWithoutCoarse) mkPath(log, outDirWithoutCoarse)
outDirWithCoarse = ExportBuildDirectory + "/" + ShapeWithCoarseMeshExportDirectory outDirWithCoarse = ExportBuildDirectory + "/" + ShapeWithCoarseMeshExportDirectory
@ -80,89 +74,83 @@ if MaxAvailable:
mkPath(log, outDirLightmap) mkPath(log, outDirLightmap)
outDirAnim = ExportBuildDirectory + "/" + ShapeAnimExportDirectory outDirAnim = ExportBuildDirectory + "/" + ShapeAnimExportDirectory
mkPath(log, outDirAnim) mkPath(log, outDirAnim)
tagList = findFiles(log, outDirTag, "", ".tag")
tagLen = len(tagList)
# For each directoy
if os.path.isfile(scriptDst):
os.remove(scriptDst)
for dir in ShapeSourceDirectories: for dir in ShapeSourceDirectories:
tagDiff = 1 mkPath(log, DatabaseDirectory + "/" + dir)
secondTry = 1 if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + ShapeTagExportDirectory, ".max.tag")):
shapeSourceDir = DatabaseDirectory + "/" + dir scriptSrc = "maxscript/shape_export.ms"
mkPath(log, shapeSourceDir) scriptDst = MaxUserDirectory + "/scripts/shape_export.ms"
maxFiles = findFilesNoSubdir(log, shapeSourceDir, ".max") outputLogfile = ScriptDirectory + "/processes/shape/log.log"
for maxFile in maxFiles: maxRunningTagFile = tagDirectory + "/max_running.tag"
maxFilePath = shapeSourceDir + "/" + maxFile maxSourceDir = DatabaseDirectory + "/" + dir
tagFilePath = outDirTag + "/" + getTagFileName(maxFilePath) tagList = findFiles(log, tagDirectory, "", ".max.tag")
if (needUpdate(log, maxFilePath, tagFilePath)): tagLen = len(tagList)
sSrc = open(scriptSrc, "r") if os.path.isfile(scriptDst):
sDst = open(scriptDst, "w")
for line in sSrc:
newline = line.replace("output_logfile", logFile)
# newline = newline.replace("shape_source_directory", shapeSourceDir)
newline = newline.replace("shape_max_file_path", maxFilePath)
newline = newline.replace("output_directory_tag", outDirTag)
newline = newline.replace("output_directory_without_coarse_mesh", outDirWithoutCoarse)
newline = newline.replace("output_directory_with_coarse_mesh", outDirWithCoarse)
newline = newline.replace("shape_export_opt_export_lighting", ShapeExportOptExportLighting)
newline = newline.replace("shape_export_opt_shadow", ShapeExportOptShadow)
newline = newline.replace("shape_export_opt_lighting_limit", str(ShapeExportOptLightingLimit))
newline = newline.replace("shape_export_opt_lumel_size", ShapeExportOptLumelSize)
newline = newline.replace("shape_export_opt_oversampling", str(ShapeExportOptOversampling))
newline = newline.replace("shape_export_opt_lightmap_log", ShapeExportOptLightmapLog)
newline = newline.replace("shape_lightmap_path", outDirLightmap)
newline = newline.replace("output_directory_anim", outDirAnim)
sDst.write(newline)
sSrc.close()
sDst.close()
retriesLeft = 5
while retriesLeft > 0:
printLog(log, "MAXSCRIPT " + scriptDst + "; " + maxFilePath)
subprocess.call([ ExecTimeout, str(MaxShapeExportTimeout), Max, "-U", "MAXScript", "shape_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(logFile):
try:
lSrc = open(logFile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(logFile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
if (not needUpdate(log, maxFilePath, tagFilePath)):
printLog(log, "OK " + maxFilePath)
retriesLeft = 0
else:
printLog(log, "FAIL " + maxFilePath)
retriesLeft = retriesLeft - 1
os.remove(scriptDst) os.remove(scriptDst)
else: tagDiff = 1
printLog(log, "SKIP " + maxFilePath) sSrc = open(scriptSrc, "r")
sDst = open(scriptDst, "w")
# Export clod 3dsmax for line in sSrc:
# this is historical garbage, just use the clodbank process.. :-) newline = line.replace("%OutputLogfile%", outputLogfile)
#printLog(log, ">>> Export character lod shape files (.clod) from Max <<<") newline = newline.replace("%MaxSourceDirectory%", maxSourceDir)
#printLog(log, "********************************") newline = newline.replace("%TagDirectory%", tagDirectory)
#printLog(log, "******** TODO ********") newline = newline.replace("%OutputDirectoryWithoutCoarseMesh%", outDirWithoutCoarse)
#printLog(log, "********************************") newline = newline.replace("%OutputDirectoryWithCoarseMesh%", outDirWithCoarse)
newline = newline.replace("%OutputDirectoryLightmap%", outDirLightmap)
# cat ../clodbank/maxscript/clod_export.ms newline = newline.replace("%OutputDirectoryAnim%", outDirAnim)
#| sed -e "s&shape_source_directory&$database_directory/$i&g" newline = newline.replace("%ShapeExportOptExportLighting%", ShapeExportOptExportLighting)
#| sed -e "s&output_directory_clod&$build_gamedata_directory/processes/shape/clod&g" newline = newline.replace("%ShapeExportOptShadow%", ShapeExportOptShadow)
#| sed -e "s&output_directory_tag&$build_gamedata_directory/processes/shape/tag&g" newline = newline.replace("%ShapeExportOptLightingLimit%", str(ShapeExportOptLightingLimit))
# > $max_directory/scripts/clod_export.ms newline = newline.replace("%ShapeExportOptLumelSize%", ShapeExportOptLumelSize)
newline = newline.replace("%ShapeExportOptOversampling%", str(ShapeExportOptOversampling))
newline = newline.replace("%ShapeExportOptLightmapLog%", ShapeExportOptLightmapLog)
printLog(log, "") sDst.write(newline)
sSrc.close()
sDst.close()
zeroRetryLimit = 3
while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "shape_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".max.tag")
newTagLen = len(tagList)
tagDiff = newTagLen - tagLen
tagLen = newTagLen
addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst)
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
shutil.move("temp_log.log", "log.log") shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -1,33 +1,17 @@
-- Some globals
NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized
-- "0" = is not an accelerator and IS NOT clusterized (always visible)
-- "1" = is an accelerator type PORTAL
-- "2" = is an accelerator type CLUSTER
-- "6" = is an accelerator type CLUSTER FATHER-VISIBLE
-- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER
-- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER
-- "17" = is an accelerator type PORTAL DYNAMIC
NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me
-- "0" = export me
-- "1" = DONT export me
NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10 -- #################################################################
NEL3D_APPDATA_LOD = 1423062537 -- ## WARNING : this is a generated file, don't change it !
NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD -- #################################################################
NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1
NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX
NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1
NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1
NEL3D_APPDATA_COLLISION = 1423062613
NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614
NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
nlErrorFilename = "output_logfile" -- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then
nlErrorStream = createFile nlErrorFilename nlErrorStream = createFile nlErrorFilename
@ -80,6 +64,34 @@ fn nlerror message =
print message print message
) )
-- Some globals
NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized
-- "0" = is not an accelerator and IS NOT clusterized (always visible)
-- "1" = is an accelerator type PORTAL
-- "2" = is an accelerator type CLUSTER
-- "6" = is an accelerator type CLUSTER FATHER-VISIBLE
-- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER
-- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER
-- "17" = is an accelerator type PORTAL DYNAMIC
NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me
-- "0" = export me
-- "1" = DONT export me
NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10
NEL3D_APPDATA_LOD = 1423062537
NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD
NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1
NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX
NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1
NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1
NEL3D_APPDATA_COLLISION = 1423062613
NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614
NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617
-- This node is n accelerator ? -- This node is n accelerator ?
fn isAccelerator node = fn isAccelerator node =
( (
@ -241,275 +253,300 @@ fn haveCoarseMesh node =
return false return false
) )
fn goShapeExport = fn runNelMaxExport inputMaxFile =
( (
try tagThisFile = false
-- Unhide category
unhidecategory()
-- Unhide
max unhide all
-- unselect
max select none
-- Exported object count
exported = 0
-- Add the lod
for node in geometry do
( (
-- Get filepath -- Get lod count
filePath = "shape_max_file_path" nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT
if (nodeCount != undefined) then
try
( (
-- Delete lod files -- For each lod
lod_array = #() nodeCountNum = nodeCount as Integer
for lod = 1 to nodeCountNum do
-- Ok ?
ok = false
-- Free memory and file handles
gc ()
-- Reset 3dsmax
resetMAXFile #noprompt
-- Get the tag file name
tag = ("output_directory_tag/" + (getFilenameFile filePath) + (getFilenameType filePath) + ".tag")
-- Open the max project
nlerror ("Scanning file " + filePath + " ...")
if loadMaxFile filePath quiet:true == true then
( (
-- Unhide category -- Get the lod
unhidecategory() lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1)
-- Unhide -- Exist ?
max unhide all if (lod != undefined) then
-- unselect
max select none
-- Exported object count
exported = 0
-- Add the lod
for node in geometry do
( (
-- Get lod count -- Select a node
nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT try
if (nodeCount != undefined) then
( (
-- For each lod nd = execute("$'"+lod+"'")
nodeCountNum = nodeCount as Integer )
for lod = 1 to nodeCountNum do catch
( (
-- Get the lod nlerror("Error in Execute $'"+lod+"' from node "+node.name)
lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1) nd = undefined
)
-- Exist ?
if (lod != undefined) then -- Node exist ?
( if (nd != undefined) then
-- Select a node (
try append lod_array nd
(
nd = execute ("$'"+lod+"'")
)
catch
(
nlerror ("Error in Execute $'"+lod+"' from node "+node.name)
nd = undefined
)
-- Node exist ?
if (nd != undefined) then
(
append lod_array nd
)
)
)
) )
) )
)
-- Select objects for shadows )
for node in geometry do )
-- Select objects for shadows
for node in geometry do
(
if (node.parent == undefined) then
(
-- Cast shadow ?
if (isCastShadow node == true) then
(
-- Select this node
selectmore node
)
)
)
-- Tag this file ?
tagThisFile = true
-- Array of node to export
array_node = #()
-- Add geometry
for node in geometry do
append array_node node
-- Add shapes
for node in shapes do
append array_node node
-- For each node
for node in array_node do
(
-- It is root ?
if (node.parent == undefined) then
(
-- Is not a skeleton ?
if (node.name != "Bip01") then
(
-- Can be exported ?
if (isToBeExported node == true) then
( (
if (node.parent == undefined) then -- Not a lod ?
if ((isLod node) == false) then
( (
-- Cast shadow ? -- Output directory
if (isCastShadow node == true) then if (haveCoarseMesh node) == true then
( output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
-- Select this node else
selectmore node output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
)
)
)
-- Tag this file ?
tagThisFile = true
-- Array of node to export
array_node = #()
-- Add geometry
for node in geometry do
append array_node node
-- Add shapes
for node in shapes do
append array_node node
-- For each node
for node in array_node do
(
-- It is root ?
if (node.parent == undefined) then
(
-- Is not a skeleton ?
if (node.name != "Bip01") then
(
-- Can be exported ?
if (isToBeExported node == true) then
(
-- Not a lod ?
if ((isLod node) == false) then
(
-- Output directory
if (haveCoarseMesh node) == true then
output = ("output_directory_with_coarse_mesh/"+(node.name)+".shape")
else
output = ("output_directory_without_coarse_mesh/"+(node.name)+".shape")
-- Compare file date
if (NeLTestFileDate output filePath) == true then
(
try
(
-- Export the shape
if (NelExportShapeEx node output shape_export_opt_shadow shape_export_opt_export_lighting "shape_lightmap_path" shape_export_opt_lighting_limit shape_export_opt_lumel_size shape_export_opt_oversampling true false shape_export_opt_lightmap_log) == true then
(
nlerror ("OK "+output)
exported = exported+1
)
else
(
-- Error
nlerror ("ERROR exporting shape "+node.name+" in file "+filePath)
tagThisFile = false
return 0
)
)
catch
(
-- Error
nlerror ("ERROR fatal error exporting shape "+node.name+" in file "+filePath)
tagThisFile = false
return 0
)
)
else
(
-- Error
nlerror ("SKIPPED "+output)
exported = exported+1
)
)
)
)
)
)
-- Export default animations
for node in objects do
(
-- Can export it ?
if (isAnimToBeExported node) == true then
(
-- Anim output directory
output = ("output_directory_anim/"+(node.name)+".anim")
-- Export the animation -- Compare file date
if (NelExportAnimation #(node) output false) == false then if (NeLTestFileDate output inputMaxFile) == true then
( (
nlerror ("ERROR exporting animation "+output) try
return 0 (
-- Export the shape
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
(
nlerror("OK "+output)
exported = exported +1
)
else
(
-- Error
nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
tagThisFile = false
)
)
catch
(
-- Error
nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
tagThisFile = false
)
) )
else else
( (
nlerror ("OK "+output) nlerror("SKIPPED " + output)
exported = exported + 1
) )
) )
) )
)
-- Write a tag file )
if tagThisFile == true then )
(
tagFile = createFile tag -- Export default animations
if tagFile == undefined then
( for node in objects do
nlerror ("WARNING can't create tag file "+tag) (
) -- Can export it ?
else if (isAnimToBeExported node) == true then
( (
print "toto" to: tagFile -- Anim output directory
close tagFile output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim")
)
) -- Export the animation
if (NelExportAnimation #(node) output false) == false then
-- Something exported (
if exported == 0 then nlerror ("ERROR exporting animation " + output)
( tagThisFile = false
-- Error
nlerror ("WARNING no shape exported from the file "+filePath)
)
) )
else else
( (
-- Error nlerror("OK " + output)
nlerror ("ERROR exporting shape: can't open the file "+filePath)
) )
try
(
gc ()
)
catch
(
nlerror ("ERROR gc " + getCurrentException())
)
try
(
-- Reset 3dsmax
resetMAXFile #noprompt
)
catch
(
nlerror ("ERROR resetMAXFile " + getCurrentException())
)
try
(
gc ()
)
catch
(
nlerror ("ERROR gc " + getCurrentException())
)
)
catch
(
-- Error
nlerror ("ERROR fatal error exporting shape in file " + filePath)
return 0
) )
) )
catch
-- Something exported
if exported == 0 then
( (
-- Error -- Error
nlerror ("ERROR fatal error exporting shape in file") nlerror("WARNING no shape exported from the file " + inputMaxFile)
return 0 )
return tagThisFile
)
removeRunningTag = true
try
(
undo off
(
-- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
(
-- For each files
for i = 1 to files.count do
(
inputMaxFile = files[i]
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
--try
--(
-- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
(
-- Free memory and file handles
gc()
heapfree
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
(
tagThisFile = runNelMaxExport(inputMaxFile)
-- Write a tag file
if tagThisFile == true then
(
tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
)
else
(
removeRunningTag = false
)
)
else
(
-- Error
nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile)
removeRunningTag = false
)
)
else
(
nlerror("SKIPPED BY TAG " + inputMaxFile)
)
--)
--catch
--(
-- -- Error
-- nlerror("ERROR error exporting 'shape' in file " + inputMaxFile)
-- removeRunningTag = false
--)
)
)
else
(
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
)
) )
) )
catch
undo off
( (
goShapeExport() -- Error
nlerror("ERROR fatal error exporting 'shape' in folder %MaxSourceDirectory%")
removeRunningTag = false
) )
nlerror ("BYE") try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
quitMAX #noPrompt if (removeRunningTag) then
quitMAX () #noPrompt (
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
)
-- Bye
nlerror("BYE")
quitMAX #noPrompt quitMAX #noPrompt
quitMAX () #noPrompt quitMAX() #noPrompt

View file

@ -6,7 +6,7 @@
# #
# \file 1_export.py # \file 1_export.py
# \brief Export veget # \brief Export veget
# \date 2010-09-19-14-19-GMT # \date 2010-09-26-08-38-GMT
# \author Jan Boon (Kaetemi) # \author Jan Boon (Kaetemi)
# Python port of game data build pipeline. # Python port of game data build pipeline.
# Export veget # Export veget
@ -33,7 +33,9 @@ sys.path.append("../../configuration")
if os.path.isfile("log.log"): if os.path.isfile("log.log"):
os.remove("log.log") os.remove("log.log")
log = open("log.log", "w") if os.path.isfile("temp_log.log"):
os.remove("temp_log.log")
log = open("temp_log.log", "w")
from scripts import * from scripts import *
from buildsite import * from buildsite import *
from process import * from process import *
@ -69,6 +71,7 @@ if MaxAvailable:
outputDirectory = ExportBuildDirectory + "/" + VegetExportDirectory outputDirectory = ExportBuildDirectory + "/" + VegetExportDirectory
tagDirectory = ExportBuildDirectory + "/" + VegetTagExportDirectory tagDirectory = ExportBuildDirectory + "/" + VegetTagExportDirectory
maxSourceDir = DatabaseDirectory + "/" + dir maxSourceDir = DatabaseDirectory + "/" + dir
maxRunningTagFile = tagDirectory + "/max_running.tag"
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
tagLen = len(tagList) tagLen = len(tagList)
if os.path.isfile(scriptDst): if os.path.isfile(scriptDst):
@ -84,20 +87,53 @@ if MaxAvailable:
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
zeroRetryLimit = 3
while tagDiff > 0: while tagDiff > 0:
mrt = open(maxRunningTagFile, "w")
mrt.write("moe-moe-kyun")
mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst) printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "veget_export.ms", "-q", "-mi", "-vn" ]) subprocess.call([ Max, "-U", "MAXScript", "veget_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try:
lSrc = open(outputLogfile, "r")
for line in lSrc:
lineStrip = line.strip()
if (len(lineStrip) > 0):
printLog(log, lineStrip)
lSrc.close()
os.remove(outputLogfile)
except Exception:
printLog(log, "ERROR Failed to read 3dsmax log")
else:
printLog(log, "WARNING No 3dsmax log")
tagList = findFiles(log, tagDirectory, "", ".max.tag") tagList = findFiles(log, tagDirectory, "", ".max.tag")
newTagLen = len(tagList) newTagLen = len(tagList)
tagDiff = newTagLen - tagLen tagDiff = newTagLen - tagLen
tagLen = newTagLen tagLen = newTagLen
addTagDiff = 0
if os.path.exists(maxRunningTagFile):
printLog(log, "FAIL 3ds Max crashed and/or file export failed!")
if tagDiff == 0:
if zeroRetryLimit > 0:
zeroRetryLimit = zeroRetryLimit - 1
addTagDiff = 1
else:
printLog(log, "FAIL Retry limit reached!")
else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!") printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
printLog(log, "")
printLog(log, "")
log.close() log.close()
if os.path.isfile("log.log"):
os.remove("log.log")
shutil.move("temp_log.log", "log.log")
# end of file # end of file

View file

@ -8,6 +8,9 @@
-- Allocate 20 Me for the script -- Allocate 20 Me for the script
heapSize += 15000000 heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
nlErrorFilename = "%OutputLogfile%" nlErrorFilename = "%OutputLogfile%"
nlErrorStream = openFile nlErrorFilename mode:"a" nlErrorStream = openFile nlErrorFilename mode:"a"
if nlErrorStream == undefined then if nlErrorStream == undefined then
@ -176,90 +179,126 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
( (
-- Get files in the %MaxSourceDirectory% directory undo off
files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
-- For each files -- Get files in the %MaxSourceDirectory% directory
for i = 1 to files.count do files = getFiles "%MaxSourceDirectory%/*.max"
gc()
-- Sort files
sort files
gc()
-- No file ?
if files.count != 0 then
( (
inputMaxFile = files[i] -- For each files
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") for i = 1 to files.count do
try
( (
-- Compare file date inputMaxFile = files[i]
if (NeLTestFileDate outputTagFile inputMaxFile) == true then outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
(
-- Free memory and file handles --try
gc() --(
heapfree -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
-- Reset 3dsmax
resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagThisFile = runNelMaxExport(inputMaxFile) -- Free memory and file handles
gc()
heapfree
-- Write a tag file -- Reset 3dsmax
if tagThisFile == true then resetMAXFile #noprompt
-- Open the max project
nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then
( (
tagFile = createFile outputTagFile tagThisFile = runNelMaxExport(inputMaxFile)
if tagFile == undefined then
-- Write a tag file
if tagThisFile == true then
( (
nlerror("WARNING can't create tag file " + outputTagFile) tagFile = createFile outputTagFile
if tagFile == undefined then
(
nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
)
else
(
print "mukyu" to: tagFile
close tagFile
)
) )
else else
( (
print "mukyu" to: tagFile removeRunningTag = false
close tagFile
) )
) )
else
(
-- Error
nlerror("ERROR exporting 'veget': can't open the file " + inputMaxFile)
removeRunningTag = false
)
) )
else else
( (
-- Error nlerror("SKIPPED BY TAG " + inputMaxFile)
nlerror("ERROR exporting 'veget': can't open the file " + inputMaxFile)
) )
) --)
else --catch
( --(
nlerror("SKIPPED BY TAG " + inputMaxFile) -- -- Error
) -- nlerror("ERROR error exporting 'veget' in file " + inputMaxFile)
) -- removeRunningTag = false
catch --)
(
-- Error
nlerror("ERROR error exporting 'veget' in files " + inputMaxFile)
) )
) )
) else
else (
( nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") )
) )
) )
catch catch
( (
-- Error -- Error
nlerror("ERROR fatal error exporting 'veget' in folder %MaxSourceDirectory%") nlerror("ERROR fatal error exporting 'veget' in folder %MaxSourceDirectory%")
removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
)
)
catch
(
nlerror("FAIL Last reset fails")
removeRunningTag = false
)
if (removeRunningTag) then
(
nlerror("SUCCESS All .max files have been successfully exported")
deleteFile("%TagDirectory%/max_running.tag")
)
else
(
nlerror("FAIL One or more issues occured")
NelForceQuitRightNow()
) )
-- Bye -- Bye
nlerror("BYE")
resetMAXFile #noprompt
quitMAX #noPrompt quitMAX #noPrompt
quitMAX() #noPrompt quitMAX() #noPrompt

View file

@ -143,6 +143,7 @@ ShapeAnimExportDirectory = CommonPath + "/shape_anim"
# Animation directories # Animation directories
AnimExportDirectory = CommonPath + "/anim_export" AnimExportDirectory = CommonPath + "/anim_export"
AnimTagExportDirectory = CommonPath + "/anim_tag"
# cLoD directories # cLoD directories
ClodExportDirectory = CommonPath + "/clod_export" ClodExportDirectory = CommonPath + "/clod_export"

View file

@ -253,6 +253,7 @@ ShapeAnimExportDirectory = CommonPath + "/shape_anim"
# Animation directories # Animation directories
AnimExportDirectory = CommonPath + "/anim_export" AnimExportDirectory = CommonPath + "/anim_export"
AnimTagExportDirectory = CommonPath + "/anim_tag"
# cLoD directories # cLoD directories
ClodExportDirectory = CommonPath + "/clod_export" ClodExportDirectory = CommonPath + "/clod_export"

View file

@ -128,6 +128,7 @@ ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme
# Animation directories # Animation directories
AnimExportDirectory = CommonPath + "/anim_export" AnimExportDirectory = CommonPath + "/anim_export"
AnimTagExportDirectory = CommonPath + "/anim_tag"
# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE ***