-- NW4C Menu Utilities(2010/10/20) -- Version 0.4.7 -- (c)2010 Nintendo struct nw4c_utils ( enableSaveToScene = true, fn outComment fs str = ( format "# %\n" str to:fs ), fn outReturn fs= ( format "\n" to:fs ), fn outValue fs key v = ( format "%=\"%\"\n" key (v as string) to:fs ), fn outVersion fs key v = ( local str = "" for i = 1 to 3 do ( local d = (mod v 10) as integer v = (v - d) / 10 str = (d as string) + str if i != 3 do str = "." + str ) outValue fs key str ), fn outQuantValue fs key v = ( local str = case v of ( 3: "Byte" 2: "Short" default: "Float" ) outValue fs key str ), fn QuantStrToInt str = ( local val = toLower str case val of ( "byte": 3 "short": 2 default: 1 ) ), fn loadSettingFromFile filename isDefault:false = ( local nw4c = nw4cmax if nw4c == undefined do return false if filename == undefined do return false local fs = openFile filename mode:"rt" if fs == undefined do ( format "File Open Error(%)\n" filename return false ) -- read header if (findString (readLine fs) "NW4C_Export settings") == undefined do return false local str, key, val local isEOF = false while isEOF == false do ( str = readLine fs -- skip comment and null line if (str.count < 1) or (str[1] == "#") do continue local elem = filterString str "=" if (classof elem != Array) or elem.count != 2 do continue key = elem[1] val = substituteString elem[2] "\"" "" --format "\"%\"=\"%\"\n" key val case key of ( "ExportTarget": ( nw4c.doesExportSelected = ((stricmp val "Selection") == 0) ) "OutputFileName": nw4c.filename = val "OutputFolder": nw4c.outFolder = val "OutputMode": nw4c.UseCreativeStudio = ((stricmp val "CreativeStudio") == 0) "MergeCmdl": nw4c.UseMerge = val as booleanclass "MergeCmdlPath": nw4c.MergeFilename = val "Magnify": nw4c.Magnify = val as float "FrameRange": nw4c.doesExportAllFrames = ((stricmp val "Range") != 0) "StartFrame": nw4c.StartFrame = val as integer "EndFrame": nw4c.EndFrame = val as integer "UseFigureMode": nw4c.useFiguremode = val as booleanclass "OutputCmdl": nw4c.doesExportModel = val as booleanclass "OutputCtex": nw4c.doesExportTexture = val as booleanclass "OutputCskla": nw4c.doesExportAnimation = val as booleanclass "OutputCmata": nw4c.doesExportMtlAnim = val as booleanclass "OutputCcam": nw4c.doesExportCamera = val as booleanclass "OutputClgt": nw4c.doesExportLight = val as booleanclass "OutputCenv": nw4c.doesExportEnv = val as booleanclass "OutputCmdla": nw4c.doesExportModelAnim = val as booleanclass "CompressNode": ( nw4c.CompressNode = case val of ( "Cull": 2 "CullUninfluential": 3 "UniteCompressible": 4 "UniteAll": 5 default: 1 ) ) "CompressMaterial": ()--nw4c. "OptimizePrimitive": nw4c.OptimizePrimitive = val as booleanclass "ConvertToModel": nw4c.DisableModelSimplification = not (val as booleanclass) "QuantizePos": nw4c.QuantPos = QuantStrToInt val "QuantizeNrm": nw4c.QuantNormal = QuantStrToInt val "QuantizeTex": nw4c.QuantTex = QuantStrToInt val "NonUniformScale": nw4c.NonUniformScale = val as booleanclass "MaxReservedUniformRegisters": nw4c.ReservedUniformRegister = val as integer "MeshVisibilityMode": nw4c.VisibilityBindByName = ((stricmp val "BindByName") == 0) "BakeAllAnim": () "FramePrecision": ( local fval = val as float if fval > 0.0 do ( local ival = (1.0 / fval) as integer nw4c.AnimPrecision = case of ( (ival <= 1): 1 (ival <= 2): 2 (ival <= 5): 5 default: 10 ) ) ) "LoopAnim": nw4c.IsLoop = val as booleanclass "FrameFormat": nw4c.IsFrameFormat = val as booleanclass "BinPrecisionScale": ()--nw4c.PrecisionScale = val as float "BinPrecisionRotate": ()--nw4c.PrecisionRotate = val as float "BinPrecisionTranslate": ()--nw4c.PrecisionTrans = val as float "ScaleQuantizeQuality": nw4c.ScaleQuality = val as integer "RotateQuantizeQuality": nw4c.RotateQuality = val as integer "TranslateQuantizeQuality": nw4c.TransQuality = val as integer "ToleranceScale": nw4c.ToleranceScale = val as float "ToleranceRotate": nw4c.ToleranceRotate = val as float "ToleranceTranslate": nw4c.ToleranceTrans = val as float "ToleranceUVScale": nw4c.ToleranceUVScale = val as float "ToleranceUVRotate": nw4c.ToleranceUVRotate = val as float "ToleranceUVTranslate": nw4c.ToleranceUVTrans = val as float "ToleranceColor": nw4c.ToleranceColor= val as float "3dsmax_SaveToScene": ( --if isDefault do enableSaveToScene = val as booleanclass ) "SettingsVersion": () "GeneratorName": () "GeneratorVersion": () "Date": () default: format "WARNING: unknown key found in c3es(%=%)\n" key val ) --detect eof if eof fs do ( isEOF = true ) ) return true ), fn saveSettingToFile filename isDefault:false = ( local nw4c = nw4cmax if nw4c == undefined do return false if filename == undefined do return false local fs = openFile filename mode:"wt" if fs == undefined do ( format "File Open Error(%)\n" filename return false ) outComment fs "NW4C_Export settings" local ver = nw4c.GetVersion() outVersion fs "SettingsVersion" ver local str = "3ds Max " append str (((maxVersion())[1] / 1000 + 1998) as string) append str " NW4C_Export" outValue fs "GeneratorName" str outVersion fs "GeneratorVersion" ver local dt = getLocalTime() local ss = stringStream "" format "%-%-%T%:%:%" dt[1] dt[2] dt[4] dt[5] dt[6] dt[7] to:ss outValue fs "Date" (ss as string) if isDefault do ( --outValue fs "3dsmax_SaveToScene" enableSaveToScene ) outReturn fs -- outComment fs "Output Options" outValue fs "ExportTarget" (if nw4c.doesExportSelected then "Selection" else "All") outValue fs "OutputFileName" nw4c.filename outValue fs "OutputMode" (if nw4c.UseCreativeStudio then "CreativeStudio" else "File") outValue fs "OutputFolder" nw4c.outFolder outValue fs "MergeCmdl" nw4c.UseMerge outValue fs "MergeCmdlPath" nw4c.MergeFilename outReturn fs -- outComment fs "General Options" outValue fs "Magnify" nw4c.Magnify outValue fs "FrameRange" (if nw4c.doesExportAllFrames then "All" else "Range") outValue fs "StartFrame" nw4c.StartFrame outValue fs "EndFrame" nw4c.EndFrame outValue fs "UseFigureMode" nw4c.useFiguremode outReturn fs -- outComment fs "Output File Selection" outValue fs "OutputCmdl" nw4c.doesExportModel outValue fs "OutputCtex" nw4c.doesExportTexture outValue fs "OutputCskla" nw4c.doesExportAnimation outValue fs "OutputCmata" nw4c.doesExportMtlAnim outValue fs "OutputCcam" nw4c.doesExportCamera outValue fs "OutputClgt" nw4c.doesExportLight outValue fs "OutputCenv" nw4c.doesExportEnv outValue fs "OutputCmdla" nw4c.doesExportModelAnim outReturn fs -- outComment fs "Optimization Options" outValue fs "CompressNode" ( case nw4c.CompressNode of ( 2: "Cull" 3: "CullUninfluential" 4: "UniteCompressible" 5: "UniteAll" default: "None" ) ) outValue fs "CompressMaterial" nw4c.OptimizeMaterial outValue fs "OptimizePrimitive" nw4c.OptimizePrimitive outValue fs "ConvertToModel" (not nw4c.DisableModelSimplification) outReturn fs -- outComment fs "Quantization Options" outQuantValue fs "QuantizePos" nw4c.QuantPos outQuantValue fs "QuantizeNrm" nw4c.QuantNormal outQuantValue fs "QuantizeTex" nw4c.QuantTex outReturn fs -- outComment fs "Model Options" outValue fs "NonUniformScale" nw4c.NonUniformScale outValue fs "MaxReservedUniformRegisters" nw4c.ReservedUniformRegister outValue fs "MeshVisibilityMode" ( if nw4c.VisibilityBindByName then "BindByName" else "BindByIndex") outReturn fs -- outComment fs "Animation Options" outValue fs "BakeAllAnim" true outValue fs "FramePrecision" (1.0 / nw4c.AnimPrecision) outValue fs "LoopAnim" nw4c.IsLoop outValue fs "FrameFormat" nw4c.IsFrameFormat --outValue fs "BinPrecisionScale" nw4c.PrecisionScale --outValue fs "BinPrecisionRotate" nw4c.PrecisionRotate --outValue fs "BinPrecisionTranslate" nw4c.PrecisionTrans outValue fs "ScaleQuantizeQuality" nw4c.ScaleQuality outValue fs "RotateQuantizeQuality" nw4c.RotateQuality outValue fs "TranslateQuantizeQuality" nw4c.TransQuality outReturn fs -- outComment fs "Tolerance Options" outValue fs "ToleranceScale" nw4c.ToleranceScale outValue fs "ToleranceRotate" nw4c.ToleranceRotate outValue fs "ToleranceTranslate" nw4c.ToleranceTrans outValue fs "ToleranceUVScale" nw4c.ToleranceUVScale outValue fs "ToleranceUVRotate" nw4c.ToleranceUVRotate outValue fs "ToleranceUVTranslate" nw4c.ToleranceUVTrans outValue fs "ToleranceColor" nw4c.ToleranceColor close fs return true ), fn loadSettingConfig = ( local fname = GetDir #plugcfg append fname "\\nw4cmax.ini" local val = getINISetting fname "nw4c_exporter" "enableSaveToScene" enableSaveToScene = if val == "false" then false else true ), fn saveSettingConfig = ( local fname = GetDir #plugcfg append fname "\\nw4cmax.ini" setINISetting fname "nw4c_exporter" "enableSaveToScene" (enableSaveToScene as string) ), fn loadSettingDefault = ( --print "loadSettingDefault" local fname = GetDir #plugcfg append fname "\\nw4cmax.c3es" if doesFileExist fname then ( loadSettingFromFile fname isDefault:true loadSettingConfig() ) else ( false ) ), fn saveSettingDefault = ( --print "saveSettingDefault" local fname = GetDir #plugcfg append fname "\\nw4cmax.c3es" saveSettingToFile fname isDefault:true saveSettingConfig() ) )