-- NW4C Menu Script(2010/12/07) -- Version 0.5.0d -- (c)2010 Nintendo fileIn "NW4C_utils.ms.inc" nw4cExportRollout = undefined rollout nw4cSR_Output "Output Options" ( label lbl4 "Export Target" /*width:96 height:20*/ align:#left across: 3 radioButtons rdoSelection "" /*width:80*/ height:16 labels:#("All", "Selection") columns:2 align:#left offset:[-30,0] label lblDummyOut1 "" label lbl2 "File name:" /*width:72*/ height:20 align:#left across: 4 --offset:[0,-10] editText editFilename "" width:256 align:#left offset:[-30,0] button btnNameNode "Node" width:45 height:16 align:#right offset:[60,0] button btnNameScene "Scene" width:45 height:16 align:#right radiobuttons rdoFileSel "" labels:#("Output 3D Intermediate Files") align:#left label lbl1 " File path:" width:72 height:20 align:#left across:4 editText editFilepath "" width:332 offset:[-30,0] label lblDummy1 "" button btnSelectPath "..." width:20 height:16 toolTip:"Select folder" align:#right radiobuttons rdoUseCS "" labels:#("Use Creative Studio") align:#left offset:[0,-5] label lblDummy3 "" height:4 checkbox chkMergeCmdl "Merge cmdl" width:80 height:16 align:#left across:4 editText editMergeFile "" width:332 offset:[-30,0] label lblDummy2 "" button btnSelectMerge "..." width:20 height:16 toolTip:"Select Merge File" align:#right on btnSelectPath pressed do ( local filepath = getSavePath initialDir:editFilepath.text if(filepath != undefined) do editFilepath.text = filepath ) on btnNameNode pressed do ( sel = getCurrentSelection() if sel.count > 0 do ( editFilename.text = sel[1].name ) ) on btnNameScene pressed do ( if(maxFilePath != "") do ( editFilename.text = (getFilenameFile maxFileName) ) ) on btnSelectMerge pressed do ( local filepath = getOpenFileName initialDir:editMergeFile.text types:"NW4C Model(*.cmdl)|*.cmdl|All|*.*|" if(filepath != undefined) do editMergeFile.text = filepath ) on chkMergeCmdl changed val do nw4cExportRollout.redrawItems() --on chkUseCS changed val do nw4cExportRollout.redrawItems() on nw4cSR_Output rolledUp val do nw4cExportRollout.resizeAll() on rdoUseCS changed val do ( if val == 1 do rdoFileSel.state = 0 editFilepath.enabled = btnSelectPath.enabled = (val != 1) ) on rdoFileSel changed val do ( if val == 1 do rdoUseCS.state = 0 editFilepath.enabled = btnSelectPath.enabled = (val == 1) ) ) rollout nw4cSR_General "General Options" ( spinner spnMagnify "Magnify: " width:120 height:16 range:[0.0001,10000,1] type:#float scale:0.1 across:2 align:#left checkbox chkUseFigureMode "Use FigureMode and SkinPose" height:16 align:#left label lbl8 "Start/End Frame:" width:112 height:20 across:4 align:#left radioButtons rdoTimeRange "" width:104 height:16 labels:#("All", "Range") columns:2 align:#left spinner spnTimeStart "" width:64 height:16 range:[0,100000,0] type:#integer scale:1 align:#left spinner spnTimeEnd "" width:64 height:16 range:[0,100000,100] type:#integer scale:1 align:#left offset:[-40,0] on rdoTimeRange changed val do nw4cExportRollout.redrawItems() on nw4cSR_General rolledUp val do nw4cExportRollout.resizeAll() ) rollout nw4cSR_FileSelection "Output File Selection" ( label lblExportModel "Model Data " align:#right offset:[20,0] across:4 checkbox chkExportModel "[.cmdl]" align:#left offset:[20,0] label lblExportMtlAnim "Material Animation Data " align:#right offset:[20,0] checkbox chkExportMtlAnim "[.cmata]" align:#left offset:[20,0] label lblExportTex "Texture Data " align:#right offset:[20,0] across:4 checkbox chkExportTex "[.ctex]" align:#left offset:[20,0] label lblExportCamera "Camera Data " align:#right offset:[20,0] checkbox chkExportCamera "[.ccam]" align:#left offset:[20,0] label lblExportMdlAnim "Model Animation Data " align:#right offset:[20,0] across:4 checkbox chkExportMdlAnim "[.cmdla]" align:#left offset:[20,0] label lblExportLight "Light Data " align:#right offset:[20,0] checkbox chkExportLight "[.clgt]" align:#left offset:[20,0] label lblExportSkelAnim "Skeletal Animation Data " align:#right offset:[20,0] across:4 checkbox chkExportSkelAnim "[.cskla]" align:#left offset:[20,0] label lblExportEnv "Environment Data " align:#right offset:[20,0] checkbox chkExportEnv "[.cenv]" align:#left offset:[20,0] on nw4cSR_FileSelection rolledUp val do nw4cExportRollout.resizeAll() ) rollout nw4cSR_Optimization "Optimization Options" ( dropDownList ddlCompressNode "Compress Node" width:140 height:41 \ items:#("None", "Cull Useless Node", "Cull Uninfluential Node", "Unite Compressible Node", "Unite All Node") across:3 dropDownList ddlOptimizeMtl "Compress Material" width:140 height:41 \ items:#("None", "Compress Same Material") --offset:[32,0] label lblDummy "" --checkbox chkDisableSimplification "Disable SkeletalModel- Simplification" width:166 height:28 pos:[320,30] checkbox chkOptimizePrim "Optimize Primitive" width:166 height:16 pos:[320,8] checkbox chkConvertToModel "Convert To Model" width:166 height:16 pos:[320,30] on chkConvertToModel changed val do nw4cExportRollout.redrawItems() on nw4cSR_Optimization rolledUp val do nw4cExportRollout.resizeAll() ) rollout nw4cSR_Quantization "Quantization Options" ( dropDownList ddlQuantPosition "Position" width:64 height:41 items:#("Float", "Short", "Byte") across:6 dropDownList ddlQuantNormal "Normal" width:64 height:41 items:#("Float", "Short", "Byte") dropDownList ddlQuantTex "Tex Coord" width:64 height:41 items:#("Float", "Short", "Byte") label lblDummyQO1 ""; label lblDummyQO2 ""; label lblDummyQO3 "" on nw4cSR_Quantization rolledUp val do nw4cExportRollout.resizeAll() ) rollout nw4cSR_Model "Model Options" ( dropDownList ddlSkinningMode "Adjust Skinning" width:120 items:#("None If Possible", "Rigid Skinning") across:3 dropDownList ddlModelBindBy "Mesh Visibility Mode" width:120 items:#("Bind By Index", "Bind By Name") label lblDummyMDL2 "" checkbox chkNonUniformScale "Non-Uniform Scale" width:140 height:16 across:3 spinner spnReserveUniform "Max Reserved Uniform Registers:" width:160 range:[0,60,0] type:#integer scale:1\ align:#left label lblDummyMDL1 "" /* dropDownList ddlModelBindBy "Mesh Visibility Mode" width:120 items:#("Bind By Index", "Bind By Name") offset:[8,0] spinner spnReserveUniform "Max Reserved Uniform Registers:" width:80 range:[0,60,0] type:#integer scale:1\ align:#left offset:[0,-24] */ on nw4cSR_Model rolledUp val do nw4cExportRollout.resizeAll() ) rollout nw4cSR_Animation "Animation Options" ( dropDownList ddlAnimationPrecision "Frame Precision" width:104 height:41 items:#("1.0", "0.5", "0.2", "0.1") --across:4 checkbox chkAnimationLoop "Loop" --width:80 height:16 checkbox chkFrameFormat "Frame Format" --width:80 height:16 label lblAO3 "Translate Quantize Quality:" align:#right pos:[155,12] width:140 editText editTransQuality "" width:32 pos:[295,10] slider sldTransQuality "" range:[0,9,9] type:#integer width:135 pos:[336,0] label lblAO2 " Rotate Quantize Quality:" align:#right pos:[155,44] width:140 editText editRotateQuality "" width:32 pos:[295,42] slider sldRotateQuality "" range:[0,9,9] type:#integer width:135 pos:[336,32] label lblAO1 " Scale Quantize Quality:" align:#right pos:[155,76] width:140 editText editScaleQuality "" width:32 pos:[295,74] slider sldScaleQuality "" range:[0,9,9] type:#integer width:135 ticks:10 pos:[336,64] fn validateSliderVal it = ( local val = it.text as integer if val == undefined do return undefined if (0 <= val and val <= 9) do return val return undefined ) fn updateQuality isEdit = ( if isEdit do ( local val val = validateSliderVal editScaleQuality if val != undefined do sldScaleQuality.value = val val = validateSliderVal editRotateQuality if val != undefined do sldRotateQuality.value = val val = validateSliderVal editTransQuality if val != undefined do sldTransQuality.value = val ) editScaleQuality.text = sldScaleQuality.value as string editRotateQuality.text = sldRotateQuality.value as string editTransQuality.text = sldTransQuality.value as string ) on editScaleQuality entered val do (updateQuality true) on editRotateQuality entered val do (updateQuality true) on editTransQuality entered val do (updateQuality true) on sldScaleQuality changed val do (updateQuality false) on sldRotateQuality changed val do (updateQuality false) on sldTransQuality changed val do (updateQuality false) on nw4cSR_Animation rolledUp val do nw4cExportRollout.resizeAll() ) rollout nw4cSR_Toletance "Tolerance Options" ( spinner spnToleranceNodeT "Node Translate:" width:80 height:16 range:[0.0001,100,0.01] type:#float scale:0.01 align:#right across:3 spinner spnToleranceTexT "Tex Translate:" width:80 height:16 range:[0.0001,100,0.01] type:#float scale:0.01 align:#right spinner spnToleranceColor "Color:" width:80 height:16 range:[0.0001,100,0.001] type:#float scale:0.01 align:#right spinner spnToleranceNodeR " Node Rotate:" width:80 height:16 range:[0.0001,100,0.1] type:#float scale:0.01 align:#right across:3 spinner spnToleranceTexR " Tex Rotate:" width:80 height:16 range:[0.0001,100,0.1] type:#float scale:0.01 align:#right label lblDummyTO1 "" spinner spnToleranceNodeS " Node Scale:" width:80 height:16 range:[0.0001,100,0.1] type:#float scale:0.01 align:#right across:3 spinner spnToleranceTexS " Tex Scale:" width:80 height:16 range:[0.0001,100,0.1] type:#float scale:0.01 align:#right label lblDummyTO2 "" on nw4cSR_Toletance rolledUp val do nw4cExportRollout.resizeAll() ) -- Main rollout nw4cExportRollout_subOpen = #() nw4cExportRollout_height = 600 rollout nw4cExportRollout "NW4C Export Setting" width:500 height:600 ( local utils = nw4c_utils() -- sub rollouts local srOutput, srGeneral, srFileSelection, srOptimization, srQuantization, srModel, srAnimation, srToletance SubRollout ro "" width:480 height:860 align:#center --offset:[-5,0] button btnExport "Export" width:144 height:24 across:3 button btnApply "Apply" width:144 height:24 button btnClose "Close" width:144 height:24 fn redrawItems = ( srGeneral.spnTimeStart.enabled = srGeneral.spnTimeEnd.enabled = (srGeneral.rdoTimeRange.state == 2) srOutput.editMergeFile.enabled = srOutput.btnSelectMerge.enabled = srOutput.chkMergeCmdl.state --srOutput.editFilepath.enabled = srOutput.btnSelectPath.enabled = not srOutput.chkUseCS.state srOutput.editFilepath.enabled = srOutput.btnSelectPath.enabled = (srOutput.rdoUseCS.state != 1) nw4cSR_Optimization.ddlCompressNode.enabled = (not nw4cSR_Optimization.chkConvertToModel.state) srAnimation.updateQuality false ) fn loadConfig loadFromScene:true = ( --print "load config" local nw4c = nw4cmax if loadFromScene do nw4c.LoadSetting() srOutput.editFilepath.text = nw4c.outFolder srOutput.editFilename.text = nw4c.filename --srOutput.chkUseCS.state = nw4c.UseCreativeStudio srOutput.rdoUseCS.state = if nw4c.UseCreativeStudio then 1 else 0 srOutput.rdoFileSel.state = 1 - srOutput.rdoUseCS.state srFileSelection.chkExportModel.state = nw4c.doesExportModel srFileSelection.chkExportTex.state = nw4c.doesExportTexture srFileSelection.chkExportSkelAnim.state = nw4c.doesExportAnimation srFileSelection.chkExportCamera.state = nw4c.doesExportCamera srFileSelection.chkExportLight.state = nw4c.doesExportLight srFileSelection.chkExportMtlAnim.state = nw4c.doesExportMtlAnim srFileSelection.chkExportMdlAnim.state = nw4c.doesExportModelAnim srFileSelection.chkExportEnv.state = nw4c.doesExportEnv -- srOutput.rdoSelection.state = (if nw4c.doesExportSelected then 2 else 1) -- srGeneral.spnMagnify.value = nw4c.Magnify -- srGeneral.rdoTimeRange.state = (if nw4c.doesExportAllFrames then 1 else 2) srGeneral.spnTimeStart.value = nw4c.StartFrame srGeneral.spnTimeEnd.value = nw4c.EndFrame srAnimation.chkAnimationLoop.state = nw4c.IsLoop srAnimation.ddlAnimationPrecision.selection = case of ( (1 >= nw4c.AnimPrecision) : 1 (2 >= nw4c.AnimPrecision) : 2 (5 >= nw4c.AnimPrecision) : 3 (10 >= nw4c.AnimPrecision) : 4 default: 1 ) -- srOptimization.ddlCompressNode.selection = if nw4c.CompressNode == 6 then 1 else nw4c.CompressNode -- Unite Bleow Nodeを廃止 srOptimization.chkOptimizePrim.state = nw4c.OptimizePrimitive --chkOptimizeMtl.state = nw4c.OptimizeMaterial srOptimization.ddlOptimizeMtl.selection = if nw4c.OptimizeMaterial then 2 else 1 srOptimization.chkConvertToModel.state = (not nw4c.DisableModelSimplification) srModel.chkNonUniformScale.state = nw4c.NonUniformScale srModel.spnReserveUniform.value = nw4c.ReservedUniformRegister srModel.ddlModelBindBy.selection = (if nw4c.VisibilityBindByName then 2 else 1) --srModel.ddlSkinningMode.selection = (if nw4c.SkinningMode <=1 then 1 else nw4c.SkinningMode) srModel.ddlSkinningMode.selection = nw4c.SkinningMode -- srToletance.spnToleranceNodeT.value = nw4c.ToleranceTrans srToletance.spnToleranceNodeR.value = nw4c.ToleranceRotate srToletance.spnToleranceNodeS.value = nw4c.ToleranceScale -- srToletance.spnToleranceTexT.value = nw4c.ToleranceUVTrans srToletance.spnToleranceTexR.value = nw4c.ToleranceUVRotate srToletance.spnToleranceTexS.value = nw4c.ToleranceUVScale srToletance.spnToleranceColor.value = nw4c.ToleranceColor -- --spnPrecisionTrans.value = nw4c.PrecisionTrans --spnPrecisionRotate.value = nw4c.PrecisionRotate --spnPrecisionScale.value = nw4c.PrecisionScale -- /*spnScaleQuality.value = nw4c.ScaleQuality --spnRotateQuality.value = nw4c.RotateQuality --spnTransQuality.value = nw4c.TransQuality */ srAnimation.sldScaleQuality.value = nw4c.ScaleQuality srAnimation.sldRotateQuality.value = nw4c.RotateQuality srAnimation.sldTransQuality.value = nw4c.TransQuality -- srQuantization.ddlQuantPosition.selection = nw4c.QuantPos srQuantization.ddlQuantNormal.selection = nw4c.QuantNormal srQuantization.ddlQuantTex.selection = nw4c.QuantTex -- srGeneral.chkUseFigureMode.state = nw4c.UseFiguremode --rdoFrameFormat.state = (if nw4c.IsFrameFormat then 2 else 1) srAnimation.chkFrameFormat.state = nw4c.IsFrameFormat -- srOutput.chkMergeCmdl.state = nw4c.UseMerge srOutput.editMergeFile.text = nw4c.MergeFilename -- ファイル名、パスが空白の場合に適当な値を入れる if(srOutput.editFilepath.text == "") do ( -- maxファイルが読み込み・保存されていない場合 if(maxFilePath == "") then srOutput.editFilepath.text = (pathConfig.getDir #export) else srOutput.editFilepath.text = maxFilePath ) if(srOutput.editFilename.text == "") do ( -- maxファイルが読み込み・保存されていない場合 if(maxFilePath == "") then srOutput.editFilename.text = "nw4c" else srOutput.editFilename.text = (getFilenameFile maxFileName) ) redrawItems() ) fn saveConfig saveToScene:true = ( --print "save config" local nw4c = nw4cmax nw4c.doesExportSelected = (srOutput.rdoSelection.state == 2) nw4c.outFolder = srOutput.editFilepath.text nw4c.filename = srOutput.editFilename.text nw4c.UseCreativeStudio = (srOutput.rdoUseCS.state == 1) nw4c.doesExportModel = srFileSelection.chkExportModel.state nw4c.doesExportTexture = srFileSelection.chkExportTex.state nw4c.doesExportAnimation = srFileSelection.chkExportSkelAnim.state nw4c.doesExportCamera = srFileSelection.chkExportCamera.state nw4c.doesExportLight = srFileSelection.chkExportLight.state nw4c.doesExportMtlAnim = srFileSelection.chkExportMtlAnim.state nw4c.doesExportModelAnim = srFileSelection.chkExportMdlAnim.state nw4c.doesExportEnv = srFileSelection.chkExportEnv.state -- nw4c.Magnify = srGeneral.spnMagnify.value -- nw4c.doesExportAllFrames = (srGeneral.rdoTimeRange.state == 1) nw4c.StartFrame = srGeneral.spnTimeStart.value nw4c.EndFrame = srGeneral.spnTimeEnd.value nw4c.IsLoop = srAnimation.chkAnimationLoop.state nw4c.AnimPrecision = case srAnimation.ddlAnimationPrecision.selection of ( 1: 1 2: 2 3: 5 4: 10 default: 1 ) -- nw4c.CompressNode = srOptimization.ddlCompressNode.selection nw4c.OptimizePrimitive = srOptimization.chkOptimizePrim.state -- nw4c.OptimizeMaterial = chkOptimizeMtl.state nw4c.OptimizeMaterial = (srOptimization.ddlOptimizeMtl.selection == 2) nw4c.DisableModelSimplification = (not srOptimization.chkConvertToModel.state) nw4c.NonUniformScale = srModel.chkNonUniformScale.state nw4c.ReservedUniformRegister = srModel.spnReserveUniform.value nw4c.VisibilityBindByName = (srModel.ddlModelBindBy.selection == 2) nw4c.SkinningMode = srModel.ddlSkinningMode.selection -- nw4c.ToleranceTrans = srToletance.spnToleranceNodeT.value nw4c.ToleranceRotate = srToletance.spnToleranceNodeR.value nw4c.ToleranceScale = srToletance.spnToleranceNodeS.value -- nw4c.ToleranceUVTrans = srToletance.spnToleranceTexT.value nw4c.ToleranceUVRotate = srToletance.spnToleranceTexR.value nw4c.ToleranceUVScale = srToletance.spnToleranceTexS.value nw4c.ToleranceColor = srToletance.spnToleranceColor.value -- --nw4c.PrecisionTrans = spnPrecisionTrans.value --nw4c.PrecisionRotate = spnPrecisionRotate.value --nw4c.PrecisionScale = spnPrecisionScale.value -- nw4c.QuantPos = srQuantization.ddlQuantPosition.selection nw4c.QuantNormal = srQuantization.ddlQuantNormal.selection nw4c.QuantTex = srQuantization.ddlQuantTex.selection -- --nw4c.ScaleQuality = spnScaleQuality.value --nw4c.RotateQuality = spnRotateQuality.value --nw4c.TransQuality = spnTransQuality.value nw4c.ScaleQuality = srAnimation.sldScaleQuality.value nw4c.RotateQuality = srAnimation.sldRotateQuality.value nw4c.TransQuality = srAnimation.sldTransQuality.value -- nw4c.useFiguremode = srGeneral.chkUseFigureMode.state --nw4c.IsFrameFormat = (rdoFrameFormat.state == 2) nw4c.IsFrameFormat = srAnimation.chkFrameFormat.state -- nw4c.UseMerge = srOutput.chkMergeCmdl.state nw4c.MergeFilename = srOutput.editMergeFile.text if saveToScene do nw4c.SaveSetting() ) fn checkOverwriteFiles fName = ( local nw4c = nw4cmax local owflag = false if nw4c.doesExportModel and doesFileExist(fName + ".cmdl") do ( owflag = true) if nw4c.doesExportAnimation and doesFileExist(fName + ".cskla") do ( owflag = true) if nw4c.doesExportCamera and doesFileExist(fName + ".ccam") do ( owflag = true) if nw4c.doesExportLight and doesFileExist(fName + ".clgt") do ( owflag = true) if nw4c.doesExportModelAnim and doesFileExist(fName + ".cmdla") do ( owflag = true) if nw4c.doesExportMtlAnim and doesFileExist(fName + ".cmata") do ( owflag = true) if nw4c.doesExportEnv and doesFileExist(fName + ".cenv") do ( owflag = true) if owflag == false do ( return true ) mes = fName + ".*\n" + " already exists.\nOverwrite ?" local ret = queryBox mes title:"confirm overwrite" return ret ) fn doExport = ( local fname = srOutput.editFilepath.text local nw4c = nw4cMax if(fname[fname.count] != "\\") do append fname "\\" if (srOutput.rdoUseCS.state != 1) do ( if (fname.count) <= 1 or not (doesFileExist fname) do ( messageBox "Output Folder is wrong" return undefined ) ) if (srOutput.editFilename.text.count <= 0)do ( messageBox "Output File Name is wrong" return undefined ) -- time if (srGeneral.rdoTimeRange.state == 2) do ( if(srGeneral.spnTimeStart.value > srGeneral.spnTimeEnd.value) do ( messageBox "Time Range is wrong" return undefined ) ) if (srModel.spnReserveUniform.value + (if srModel.chkNonUniformScale.state then 6 else 3) ) > 60 do ( messageBox "Max Reserved Uniform Registers is wrong" return undefined ) saveConfig saveToScene:utils.enableSaveToScene utils.saveSettingDefault() if (srOutput.rdoUseCS.state != 1) do ( ret = checkOverwriteFiles (fname + srOutput.editFilename.text) if not ret do ( return undefined ) ) displayTempPrompt "Exporting..." 99999999 setWaitCursor() local ret = nw4cMax.doExport(srOutput.rdoSelection.state == 2) setArrowCursor() removeTempPrompt() return ret ) fn resizeAll = ( local sHeight = 0 for i = 1 to nw4cExportRollout.ro.rollouts.count do ( local sro = nw4cExportRollout.ro.rollouts[i] sHeight += 25 sHeight += if sro.open then sro.height else -4 ) --sHeight = if sHeight < 700 then sHeight else 700 nw4cExportRollout.ro.height = sHeight btnExport.pos.y = sHeight + 10 btnApply.pos.y = sHeight + 10 btnClose.pos.y = sHeight + 10 nw4cExportRollout.height = sHeight + 40 ) on nw4cExportRollout open do ( nw4cExportRollout.ro.visible = false AddSubRollout ro nw4cSR_Output AddSubRollout ro nw4cSR_General AddSubRollout ro nw4cSR_FileSelection AddSubRollout ro nw4cSR_Optimization AddSubRollout ro nw4cSR_Quantization AddSubRollout ro nw4cSR_Model AddSubRollout ro nw4cSR_Animation AddSubRollout ro nw4cSR_Toletance srOutput = ro.nw4cSR_Output srGeneral = ro.nw4cSR_General srFileSelection = ro.nw4cSR_FileSelection srOptimization = ro.nw4cSR_Optimization srQuantization = ro.nw4cSR_Quantization srModel = ro.nw4cSR_Model srAnimation = ro.nw4cSR_Animation srToletance = ro.nw4cSR_Toletance if nw4cExportRollout_subOpen.count == nw4cExportRollout.ro.rollouts.count do ( for i = 1 to nw4cExportRollout_subOpen.count do ( nw4cExportRollout.ro.rollouts[i].open = nw4cExportRollout_subOpen[i] as booleanClass ) ) resizeAll() nw4cExportRollout.utils.loadSettingDefault() loadConfig loadFromScene:utils.enableSaveToScene nw4cExportRollout.ro.visible = true ) on nw4cExportRollout close do ( --nw4cExportRollout.utils.saveSettingDefault() --nw4cExportRollout.utils.saveSettingConfig() nw4cExportRollout_subOpen.count = nw4cExportRollout.ro.rollouts.count for i = 1 to nw4cExportRollout_subOpen.count do ( nw4cExportRollout_subOpen[i] = nw4cExportRollout.ro.rollouts[i].open ) nw4cExportRollout_height = nw4cExportRollout.height ) on btnExport pressed do ( local ret = doExport() if ret == true then ( DestroyDialog nw4cExportRollout ) else if ret == false then ( messageBox "Export Error!" ) else if ret == undefined then ( -- donothing ) ) on btnApply pressed do ( local ret = doExport() if ret == false then ( messageBox "Export Error!" ) else if ret == undefined then ( -- donothing ) ) on btnClose pressed do DestroyDialog nw4cExportRollout ) -- rollout ----------------------------------------------------- -- main menu rcMenu NW4CSettingMenu ( subMenu "NW4C Settings" ( menuItem mi_scene "Save / Load Scene Settings" checked:false menuItem mi_resetScene "Reset Scene Settings" menuItem mi_deleteScene "Delete Scene Settings" separator sep1 menuItem mi_loadFile "Load Settings from c3es File" menuItem mi_saveFile "Save Settings to c3es File" ) fn updateMenu = ( mi_scene.checked = nw4cExportRollout.utils.enableSaveToScene ) on mi_scene picked do ( local val = nw4cExportRollout.utils.enableSaveToScene nw4cExportRollout.utils.enableSaveToScene = not val nw4cExportRollout.utils.saveSettingConfig() updateMenu() ) on mi_resetScene picked do ( if (queryBox "Reset NW4C Settings?") do ( nw4cmax.ResetSetting() nw4cExportRollout.loadConfig loadFromScene:false updateMenu() ) ) on mi_deleteScene picked do ( if (queryBox "Delete NW4C Settings?") do ( deleteItem rootnode.custattributes "NW4C Custom Attribute" nw4cExportRollout.loadConfig loadFromScene:false updateMenu() ) ) on mi_saveFile picked do ( --print "mi_saveFile" nw4cExportRollout.saveConfig saveToScene:false local fname = getSaveFileName caption:"Save NW4C Setting File" types:"NW4C Settings(*.c3es)|*.c3es|All|*.*|" historyCategory:"NW4C_Setting_File" if not (nw4cExportRollout.utils.saveSettingToFile fname) do ( messageBox "c3es save error" ) ) on mi_loadFile picked do ( --print "mi_loadFile" local fname = getOpenFileName caption:"Load NW4C Setting File" types:"NW4C Settings(*.c3es)|*.c3es|All|*.*|" historyCategory:"NW4C_Setting_File" if not (nw4cExportRollout.utils.loadSettingFromFile fname) do ( messageBox "c3es load error" ) nw4cExportRollout.loadConfig loadFromScene:false ) on NW4CSettingMenu open do updateMenu() on NW4CSettingMenu update do updateMenu() ) macroScript nw4cMS_ExportWithSetting category:"NW4C" ( on execute do ( CreateDialog nw4cExportRollout menu:NW4CSettingMenu height:nw4cExportRollout_height --modal:true ) ) macroScript ResetExportSetting category:"NW4C" ( on execute do ( local ret = queryBox "Reset Export Setting?" title:"confirm reset" if ret do ( nw4cmax.ResetSetting() nw4cmax.SaveSetting() ) ) ) macroScript nw4cMS_ExportNow category:"NW4C" ( on execute do ( local nw4c = nw4cmax local fromScene = nw4cExportRollout.utils.loadSettingDefault() if fromScene do nw4c.LoadSetting() local fname = nw4c.outFolder local nw4c = nw4cMax if(fname[fname.count] != "\\") do append fname "\\" if (nw4c.UseCreativeStudio == false) do ( if not (doesFileExist fname) do ( messageBox "Output Folder is wrong" return false ) ret = nw4cExportRollout.checkOverwriteFiles (fname + nw4c.filename) if not ret do ( return false ) ) if (nw4c.filename.count <= 0)do ( messageBox "Output File Name is wrong" return false ) fname = fname + nw4c.filename + ".cmdl" displayTempPrompt "Exporting..." 99999999 setWaitCursor() local ret = nw4c.doExport nw4c.doesExportSelected setArrowCursor() removeTempPrompt() if not ret do ( messageBox "Export error!" ) ) ) macroScript nw4cMS_SetNoCompressNode category:"NW4C" ( on execute do ( CreateDialog nw4cNodeRollout ) ) macroScript nw4cMS_SetBillboard category:"NW4C" ( on execute do ( CreateDialog nw4cBillboardRollout ) ) macroScript nw4cMS_SetMaterial category:"NW4C" ( on execute do ( CreateDialog nw4cMaterialRollout ) ) macroScript nw4cMS_SetRenderPriority category:"NW4C" ( on execute do ( CreateDialog nw4cRenderPriorityRollout ) ) macroScript nw4cMS_SetCombineGroup category:"NW4C" ( on execute do ( CreateDialog nw4cCombineRollout ) ) macroScript nw4cMS_SetForceExportKey category:"NW4C" ( on execute do ( CreateDialog nw4cForceKeyRollout ) ) macroScript nw4cMS_SetNodeUserData category:"NW4C" ( on execute do ( CreateDialog nw4cNodeUserDataRollout ) ) macroScript nw4cMS_PluginVersion category:"NW4C" ( on execute do ( local nw4c = nw4cmax if nw4c == undefined do return() mes = "NintendoWare for CTR\n" mes += "3ds Max Plugin Ver " + nw4c.GetVersionString() mes += "\n" mes += "(C)2010 Nintendo.,Ltd.\n" mes += "All rights reserved" messageBox mes title:"NW4C 3ds Max Plugin Version" ) ) fn getNw4cMenu = ( local mainMenuBar = menuman.getMainMenuBar() for i = 1 to mainMenuBar.numitems() do ( local mi = mainMenuBar.getItem i if ( (mi.getTitle()) == "NW4C" ) do ( return mi ) ) -- NW4Cメニューが未登録 local subMenu = menuMan.createMenu "NW4C" local subMenuItem = menuMan.createSubMenuItem "Test Menu" subMenu -- メイン メニュー バーの最後から 2 番目のメニュー項目のインデックスを計算します。 local subMenuIndex = mainMenuBar.numItems() - 1 -- サブメニューを最後から 2 番目のスロットに追加します。 mainMenuBar.addItem subMenuItem subMenuIndex return subMenuItem ) fn resetMenuActions mi = ( local menu = mi.getSubMenu() -- まず登録済みのサブメニューアイテムを削除 while (menu.numItems() > 0) do ( menu.removeItemByPosition 1 ) local dialogItem dialogItem = menuMan.createActionItem "nw4cMS_ExportNow" "NW4C" dialogItem.setTitle "NW4C Export" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_ExportWithSetting" "NW4C" dialogItem.setTitle "NW4C Export With Setting" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createSeparatorItem() menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetMaterial" "NW4C" dialogItem.setTitle "NW4C Set Material Attribute" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetRenderPriority" "NW4C" dialogItem.setTitle "NW4C Set Render Priority" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createSeparatorItem() menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetNoCompressNode" "NW4C" dialogItem.setTitle "NW4C Set No Compress Node" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetBillboard" "NW4C" dialogItem.setTitle "NW4C Set Billboard" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetCombineGroup" "NW4C" dialogItem.setTitle "NW4C Set Combine Group" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetForceExportKey" "NW4C" dialogItem.setTitle "NW4C Set Force Export Key" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_SetNodeUserData" "NW4C" dialogItem.setTitle "NW4C Set User Data" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 dialogItem = menuMan.createSeparatorItem() menu.addItem dialogItem -1 dialogItem = menuMan.createActionItem "nw4cMS_PluginVersion" "NW4C" dialogItem.setTitle "Plugin Version" dialogItem.setUseCustomTitle true menu.addItem dialogItem -1 ) fileIn "NW4C_node.ms.inc" fileIn "NW4C_mtl.ms.inc" ---------------------------------------------- -- NW4C Main fn nw4cmain = ( -- メインメニューにNW4Cメニューを追加 local nw4cMenu = getNw4cMenu() resetMenuActions nw4cMenu -- マテリアルエディタにNW4Cメニューを追加 local nw4cMtlMenu = getNw4cMtlMenu() resetMtlMenuActions nw4cMtlMenu nw4cExportRollout.utils.loadSettingDefault() menuMan.updateMenuBar() --DestroyDialog nw4cExportRollout --CreateDialog nw4cExportRollout menu:NW4CSettingMenu --modal:true ) -- nw4cプラグインが読み込まれていない場合は何もしない。 if nw4cmax != undefined do ( --print "NW4C menu loaded" nw4cMain() )