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 9f256c4d4b
commit a7c6ed7a35
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,6 +1,10 @@
removeRunningTag = true
try try
(
undo off
( (
-- Get files in the %MaxSourceDirectory% directory -- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max" files = getFiles "%MaxSourceDirectory%/*.max"
@ -19,8 +23,8 @@ try
inputMaxFile = files[i] inputMaxFile = files[i]
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
try --try
( --(
-- Compare file date -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then if (NeLTestFileDate outputTagFile inputMaxFile) == true then
( (
@ -44,6 +48,7 @@ try
if tagFile == undefined then if tagFile == undefined then
( (
nlerror("WARNING can't create tag file " + outputTagFile) nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
) )
else else
( (
@ -51,23 +56,29 @@ try
close tagFile close tagFile
) )
) )
else
(
removeRunningTag = false
)
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile) nlerror("ERROR exporting '%PreGenFileExtension%': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
) )
else else
( (
nlerror("SKIPPED BY TAG " + inputMaxFile) nlerror("SKIPPED BY TAG " + inputMaxFile)
) )
) --)
catch --catch
( --(
-- Error -- -- Error
nlerror("ERROR error exporting '%PreGenFileExtension%' in files " + inputMaxFile) -- nlerror("ERROR error exporting '%PreGenFileExtension%' in file " + inputMaxFile)
) -- removeRunningTag = false
--)
) )
) )
else else
@ -75,15 +86,40 @@ try
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,7 +134,11 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
(
undo off
( (
-- Get files in the %MaxSourceDirectory% directory -- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max" files = getFiles "%MaxSourceDirectory%/*.max"
@ -149,12 +155,12 @@ try
for i = 1 to files.count do for i = 1 to files.count do
( (
inputMaxFile = files[i] inputMaxFile = files[i]
outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".anim") outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
try --try
( --(
-- Compare file date -- Compare file date
if (NeLTestFileDate outputNelFile inputMaxFile) == true then if (NeLTestFileDate outputTagFile inputMaxFile) == true then
( (
-- Free memory and file handles -- Free memory and file handles
gc() gc()
@ -167,24 +173,46 @@ try
nlerror("Scanning file " + inputMaxFile + " ...") nlerror("Scanning file " + inputMaxFile + " ...")
if (loadMaxFile inputMaxFile quiet:true) == true then if (loadMaxFile inputMaxFile quiet:true) == true then
( (
runNelMaxExport(inputMaxFile) 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 else
( (
-- Error -- Error
nlerror("ERROR exporting 'anim': can't open the file " + inputMaxFile) nlerror("ERROR exporting 'anim': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
) )
else else
( (
nlerror("SKIPPED " + inputMaxFile) nlerror("SKIPPED BY TAG " + inputMaxFile)
)
)
catch
(
-- Error
nlerror("ERROR error exporting 'anim' in files " + inputMaxFile)
) )
--)
--catch
--(
-- -- Error
-- nlerror("ERROR error exporting 'anim' in file " + inputMaxFile)
-- removeRunningTag = false
--)
) )
) )
else else
@ -192,15 +220,40 @@ try
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,7 +189,11 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
(
undo off
( (
-- Get files in the %MaxSourceDirectory% directory -- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max" files = getFiles "%MaxSourceDirectory%/*.max"
@ -205,8 +212,8 @@ try
inputMaxFile = files[i] inputMaxFile = files[i]
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
try --try
( --(
-- Compare file date -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then if (NeLTestFileDate outputTagFile inputMaxFile) == true then
( (
@ -230,6 +237,7 @@ try
if tagFile == undefined then if tagFile == undefined then
( (
nlerror("WARNING can't create tag file " + outputTagFile) nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
) )
else else
( (
@ -237,23 +245,29 @@ try
close tagFile close tagFile
) )
) )
else
(
removeRunningTag = false
)
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile) nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
) )
else else
( (
nlerror("SKIPPED BY TAG " + inputMaxFile) nlerror("SKIPPED BY TAG " + inputMaxFile)
) )
) --)
catch --catch
( --(
-- Error -- -- Error
nlerror("ERROR error exporting 'clod' in files " + inputMaxFile) -- nlerror("ERROR error exporting 'clod' in file " + inputMaxFile)
) -- removeRunningTag = false
--)
) )
) )
else else
@ -261,15 +275,40 @@ try
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,7 +238,11 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
(
undo off
( (
-- Get files in the %MaxSourceDirectory% directory -- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max" files = getFiles "%MaxSourceDirectory%/*.max"
@ -254,8 +261,8 @@ try
inputMaxFile = files[i] inputMaxFile = files[i]
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
try --try
( --(
-- Compare file date -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then if (NeLTestFileDate outputTagFile inputMaxFile) == true then
( (
@ -279,6 +286,7 @@ try
if tagFile == undefined then if tagFile == undefined then
( (
nlerror("WARNING can't create tag file " + outputTagFile) nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
) )
else else
( (
@ -286,23 +294,29 @@ try
close tagFile close tagFile
) )
) )
else
(
removeRunningTag = false
)
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting 'ig': can't open the file " + inputMaxFile) nlerror("ERROR exporting 'ig': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
) )
else else
( (
nlerror("SKIPPED BY TAG " + inputMaxFile) nlerror("SKIPPED BY TAG " + inputMaxFile)
) )
) --)
catch --catch
( --(
-- Error -- -- Error
nlerror("ERROR error exporting 'ig' in files " + inputMaxFile) -- nlerror("ERROR error exporting 'ig' in file " + inputMaxFile)
) -- removeRunningTag = false
--)
) )
) )
else else
@ -310,15 +324,40 @@ try
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,7 +125,11 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
(
undo off
( (
-- Get files in the %MaxSourceDirectory% directory -- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max" files = getFiles "%MaxSourceDirectory%/*.max"
@ -141,8 +148,8 @@ try
inputMaxFile = files[i] inputMaxFile = files[i]
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
try --try
( --(
-- Compare file date -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then if (NeLTestFileDate outputTagFile inputMaxFile) == true then
( (
@ -166,6 +173,7 @@ try
if tagFile == undefined then if tagFile == undefined then
( (
nlerror("WARNING can't create tag file " + outputTagFile) nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
) )
else else
( (
@ -173,23 +181,29 @@ try
close tagFile close tagFile
) )
) )
else
(
removeRunningTag = false
)
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting 'cmb': can't open the file " + inputMaxFile) nlerror("ERROR exporting 'cmb': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
) )
else else
( (
nlerror("SKIPPED BY TAG " + inputMaxFile) nlerror("SKIPPED BY TAG " + inputMaxFile)
) )
) --)
catch --catch
( --(
-- Error -- -- Error
nlerror("ERROR error exporting 'cmb' in files " + inputMaxFile) -- nlerror("ERROR error exporting 'cmb' in file " + inputMaxFile)
) -- removeRunningTag = false
--)
) )
) )
else else
@ -197,15 +211,40 @@ try
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,84 +74,77 @@ if MaxAvailable:
mkPath(log, outDirLightmap) mkPath(log, outDirLightmap)
outDirAnim = ExportBuildDirectory + "/" + ShapeAnimExportDirectory outDirAnim = ExportBuildDirectory + "/" + ShapeAnimExportDirectory
mkPath(log, outDirAnim) mkPath(log, outDirAnim)
for dir in ShapeSourceDirectories:
tagList = findFiles(log, outDirTag, "", ".tag") mkPath(log, DatabaseDirectory + "/" + dir)
if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + ShapeTagExportDirectory, ".max.tag")):
scriptSrc = "maxscript/shape_export.ms"
scriptDst = MaxUserDirectory + "/scripts/shape_export.ms"
outputLogfile = ScriptDirectory + "/processes/shape/log.log"
maxRunningTagFile = tagDirectory + "/max_running.tag"
maxSourceDir = DatabaseDirectory + "/" + dir
tagList = findFiles(log, tagDirectory, "", ".max.tag")
tagLen = len(tagList) tagLen = len(tagList)
# For each directoy
if os.path.isfile(scriptDst): if os.path.isfile(scriptDst):
os.remove(scriptDst) os.remove(scriptDst)
for dir in ShapeSourceDirectories:
tagDiff = 1 tagDiff = 1
secondTry = 1
shapeSourceDir = DatabaseDirectory + "/" + dir
mkPath(log, shapeSourceDir)
maxFiles = findFilesNoSubdir(log, shapeSourceDir, ".max")
for maxFile in maxFiles:
maxFilePath = shapeSourceDir + "/" + maxFile
tagFilePath = outDirTag + "/" + getTagFileName(maxFilePath)
if (needUpdate(log, maxFilePath, tagFilePath)):
sSrc = open(scriptSrc, "r") sSrc = open(scriptSrc, "r")
sDst = open(scriptDst, "w") sDst = open(scriptDst, "w")
for line in sSrc: for line in sSrc:
newline = line.replace("output_logfile", logFile) newline = line.replace("%OutputLogfile%", outputLogfile)
# newline = newline.replace("shape_source_directory", shapeSourceDir) newline = newline.replace("%MaxSourceDirectory%", maxSourceDir)
newline = newline.replace("shape_max_file_path", maxFilePath) newline = newline.replace("%TagDirectory%", tagDirectory)
newline = newline.replace("output_directory_tag", outDirTag) newline = newline.replace("%OutputDirectoryWithoutCoarseMesh%", outDirWithoutCoarse)
newline = newline.replace("output_directory_without_coarse_mesh", outDirWithoutCoarse) newline = newline.replace("%OutputDirectoryWithCoarseMesh%", outDirWithCoarse)
newline = newline.replace("output_directory_with_coarse_mesh", outDirWithCoarse) newline = newline.replace("%OutputDirectoryLightmap%", outDirLightmap)
newline = newline.replace("shape_export_opt_export_lighting", ShapeExportOptExportLighting) newline = newline.replace("%OutputDirectoryAnim%", outDirAnim)
newline = newline.replace("shape_export_opt_shadow", ShapeExportOptShadow) newline = newline.replace("%ShapeExportOptExportLighting%", ShapeExportOptExportLighting)
newline = newline.replace("shape_export_opt_lighting_limit", str(ShapeExportOptLightingLimit)) newline = newline.replace("%ShapeExportOptShadow%", ShapeExportOptShadow)
newline = newline.replace("shape_export_opt_lumel_size", ShapeExportOptLumelSize) newline = newline.replace("%ShapeExportOptLightingLimit%", str(ShapeExportOptLightingLimit))
newline = newline.replace("shape_export_opt_oversampling", str(ShapeExportOptOversampling)) newline = newline.replace("%ShapeExportOptLumelSize%", ShapeExportOptLumelSize)
newline = newline.replace("shape_export_opt_lightmap_log", ShapeExportOptLightmapLog) newline = newline.replace("%ShapeExportOptOversampling%", str(ShapeExportOptOversampling))
newline = newline.replace("shape_lightmap_path", outDirLightmap) newline = newline.replace("%ShapeExportOptLightmapLog%", ShapeExportOptLightmapLog)
newline = newline.replace("output_directory_anim", outDirAnim)
sDst.write(newline) sDst.write(newline)
sSrc.close() sSrc.close()
sDst.close() sDst.close()
retriesLeft = 5 zeroRetryLimit = 3
while retriesLeft > 0: while tagDiff > 0:
printLog(log, "MAXSCRIPT " + scriptDst + "; " + maxFilePath) mrt = open(maxRunningTagFile, "w")
subprocess.call([ ExecTimeout, str(MaxShapeExportTimeout), Max, "-U", "MAXScript", "shape_export.ms", "-q", "-mi", "-vn" ]) mrt.write("moe-moe-kyun")
if os.path.exists(logFile): mrt.close()
printLog(log, "MAXSCRIPT " + scriptDst)
subprocess.call([ Max, "-U", "MAXScript", "shape_export.ms", "-q", "-mi", "-vn" ])
if os.path.exists(outputLogfile):
try: try:
lSrc = open(logFile, "r") lSrc = open(outputLogfile, "r")
for line in lSrc: for line in lSrc:
lineStrip = line.strip() lineStrip = line.strip()
if (len(lineStrip) > 0): if (len(lineStrip) > 0):
printLog(log, lineStrip) printLog(log, lineStrip)
lSrc.close() lSrc.close()
os.remove(logFile) os.remove(outputLogfile)
except Exception: except Exception:
printLog(log, "ERROR Failed to read 3dsmax log") printLog(log, "ERROR Failed to read 3dsmax log")
else: else:
printLog(log, "WARNING No 3dsmax log") printLog(log, "WARNING No 3dsmax log")
if (not needUpdate(log, maxFilePath, tagFilePath)): tagList = findFiles(log, tagDirectory, "", ".max.tag")
printLog(log, "OK " + maxFilePath) newTagLen = len(tagList)
retriesLeft = 0 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: else:
printLog(log, "FAIL " + maxFilePath) printLog(log, "FAIL Retry limit reached!")
retriesLeft = retriesLeft - 1 else:
addTagDiff = 1
os.remove(maxRunningTagFile)
printLog(log, "Exported " + str(tagDiff) + " .max files!")
tagDiff += addTagDiff
os.remove(scriptDst) os.remove(scriptDst)
else:
printLog(log, "SKIP " + maxFilePath)
# Export clod 3dsmax
# this is historical garbage, just use the clodbank process.. :-)
#printLog(log, ">>> Export character lod shape files (.clod) from Max <<<")
#printLog(log, "********************************")
#printLog(log, "******** TODO ********")
#printLog(log, "********************************")
# cat ../clodbank/maxscript/clod_export.ms
#| sed -e "s&shape_source_directory&$database_directory/$i&g"
#| sed -e "s&output_directory_clod&$build_gamedata_directory/processes/shape/clod&g"
#| sed -e "s&output_directory_tag&$build_gamedata_directory/processes/shape/tag&g"
# > $max_directory/scripts/clod_export.ms
printLog(log, "") printLog(log, "")
log.close() log.close()
@ -165,4 +152,5 @@ 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 -- ## WARNING : this is a generated file, don't change it !
-- "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
-- 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,34 +253,10 @@ fn haveCoarseMesh node =
return false return false
) )
fn goShapeExport = fn runNelMaxExport inputMaxFile =
( (
try tagThisFile = false
(
-- Get filepath
filePath = "shape_max_file_path"
try
(
-- Delete lod files
lod_array = #()
-- 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 -- Unhide category
unhidecategory() unhidecategory()
@ -364,17 +352,17 @@ fn goShapeExport =
( (
-- Output directory -- Output directory
if (haveCoarseMesh node) == true then if (haveCoarseMesh node) == true then
output = ("output_directory_with_coarse_mesh/"+(node.name)+".shape") output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
else else
output = ("output_directory_without_coarse_mesh/"+(node.name)+".shape") output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
-- Compare file date -- Compare file date
if (NeLTestFileDate output filePath) == true then if (NeLTestFileDate output inputMaxFile) == true then
( (
try try
( (
-- Export the shape -- 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 if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
( (
nlerror("OK "+output) nlerror("OK "+output)
exported = exported +1 exported = exported +1
@ -382,22 +370,19 @@ fn goShapeExport =
else else
( (
-- Error -- Error
nlerror ("ERROR exporting shape "+node.name+" in file "+filePath) nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
tagThisFile = false tagThisFile = false
return 0
) )
) )
catch catch
( (
-- Error -- Error
nlerror ("ERROR fatal error exporting shape "+node.name+" in file "+filePath) nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
tagThisFile = false tagThisFile = false
return 0
) )
) )
else else
( (
-- Error
nlerror("SKIPPED " + output) nlerror("SKIPPED " + output)
exported = exported + 1 exported = exported + 1
) )
@ -415,13 +400,13 @@ fn goShapeExport =
if (isAnimToBeExported node) == true then if (isAnimToBeExported node) == true then
( (
-- Anim output directory -- Anim output directory
output = ("output_directory_anim/"+(node.name)+".anim") output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim")
-- Export the animation -- Export the animation
if (NelExportAnimation #(node) output false) == false then if (NelExportAnimation #(node) output false) == false then
( (
nlerror ("ERROR exporting animation " + output) nlerror ("ERROR exporting animation " + output)
return 0 tagThisFile = false
) )
else else
( (
@ -430,86 +415,138 @@ fn goShapeExport =
) )
) )
-- Write a tag file
if tagThisFile == true then
(
tagFile = createFile tag
if tagFile == undefined then
(
nlerror ("WARNING can't create tag file "+tag)
)
else
(
print "toto" to: tagFile
close tagFile
)
)
-- Something exported -- Something exported
if exported == 0 then if exported == 0 then
( (
-- Error -- Error
nlerror ("WARNING no shape exported from the file "+filePath) nlerror("WARNING no shape exported from the file " + inputMaxFile)
)
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 else
( (
-- Error -- Error
nlerror ("ERROR exporting shape: can't open the file "+filePath) nlerror("ERROR exporting 'shape': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
try
(
gc ()
) )
catch else
( (
nlerror ("ERROR gc " + getCurrentException()) nlerror("SKIPPED BY TAG " + inputMaxFile)
) )
--)
try --catch
( --(
-- Reset 3dsmax -- -- Error
resetMAXFile #noprompt -- nlerror("ERROR error exporting 'shape' in file " + inputMaxFile)
-- removeRunningTag = false
--)
) )
catch
(
nlerror ("ERROR resetMAXFile " + getCurrentException())
) )
else
try
( (
gc () nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
) )
catch
(
nlerror ("ERROR gc " + getCurrentException())
) )
) )
catch catch
( (
-- Error -- Error
nlerror ("ERROR fatal error exporting shape in file " + filePath) nlerror("ERROR fatal error exporting 'shape' in folder %MaxSourceDirectory%")
return 0 removeRunningTag = false
)
try
(
if (removeRunningTag) then
(
resetMAXFile #noPrompt
) )
) )
catch catch
( (
-- Error nlerror("FAIL Last reset fails")
nlerror ("ERROR fatal error exporting shape in file") removeRunningTag = false
return 0
)
) )
undo off if (removeRunningTag) then
( (
goShapeExport() 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") nlerror("BYE")
quitMAX #noPrompt quitMAX #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 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,7 +179,11 @@ fn runNelMaxExport inputMaxFile =
removeRunningTag = true
try try
(
undo off
( (
-- Get files in the %MaxSourceDirectory% directory -- Get files in the %MaxSourceDirectory% directory
files = getFiles "%MaxSourceDirectory%/*.max" files = getFiles "%MaxSourceDirectory%/*.max"
@ -195,8 +202,8 @@ try
inputMaxFile = files[i] inputMaxFile = files[i]
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
try --try
( --(
-- Compare file date -- Compare file date
if (NeLTestFileDate outputTagFile inputMaxFile) == true then if (NeLTestFileDate outputTagFile inputMaxFile) == true then
( (
@ -220,6 +227,7 @@ try
if tagFile == undefined then if tagFile == undefined then
( (
nlerror("WARNING can't create tag file " + outputTagFile) nlerror("WARNING can't create tag file " + outputTagFile)
removeRunningTag = false
) )
else else
( (
@ -227,23 +235,29 @@ try
close tagFile close tagFile
) )
) )
else
(
removeRunningTag = false
)
) )
else else
( (
-- Error -- Error
nlerror("ERROR exporting 'veget': can't open the file " + inputMaxFile) nlerror("ERROR exporting 'veget': can't open the file " + inputMaxFile)
removeRunningTag = false
) )
) )
else else
( (
nlerror("SKIPPED BY TAG " + inputMaxFile) nlerror("SKIPPED BY TAG " + inputMaxFile)
) )
) --)
catch --catch
( --(
-- Error -- -- Error
nlerror("ERROR error exporting 'veget' in files " + inputMaxFile) -- nlerror("ERROR error exporting 'veget' in file " + inputMaxFile)
) -- removeRunningTag = false
--)
) )
) )
else else
@ -251,15 +265,40 @@ try
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 ***