Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global BSDExport
- (
- if BSDExport != undefined do ( closerolloutfloater BSDExport )
- BSDExport = newrolloutfloater "BSD Export" 250 150
- global exportRollout
- fn writeBSDsFromMorphers exportPath objectNode =
- (
- try
- (
- for i=objectNode.modifiers.count to 1 by -1 do
- (
- local m = objectNode.modifiers[i]
- if isKindOf m Morpher then
- (
- for c=1 to 100 do
- (
- if WM3_MC_HasData m c then
- (
- local storeCount = 0
- local morphName = WM3_MC_GetName m c
- WM3_MC_SetValue m c 100.0
- snapshot objectNode name:morphName
- WM3_MC_SetValue m c 0.0
- local newMesh = GetNodeByName morphName
- local numVerts = meshop.getnumverts objectNode
- local filePath = exportPath + morphName + ".bsd"
- local f=fopen filePath "wb"
- WriteLong f storeCount #unsigned
- for v=1 to numVerts do
- (
- local sVert = meshop.getVert objectNode v
- local tVert = meshop.getVert newMesh v
- local mx = (tVert.x - sVert.x)
- local my = (tVert.y - sVert.y)
- local mz = (tVert.z - sVert.z)
- if abs(mx) > 0.0001 or abs(my) > 0.0001 or abs(mz) > 0.0001 then
- (
- local iOffset = v - 1
- WriteLong f iOffset #unsigned
- WriteFloat f mx
- WriteFloat f my
- WriteFloat f mz
- storeCount += 1
- )
- )
- fseek f 0 #seek_set
- WriteLong f storeCount #unsigned
- delete newMesh
- fclose f
- )
- )
- )
- )
- )
- catch
- (
- throw
- )
- )
- rollout exportRollout "Export"
- (
- editText exportFilePath "Export File Path" labelOnTop:true
- button openFileButton "Browse..."
- button exportButton "Export"
- on openFileButton pressed do
- (
- local exportPath = getSavePath caption:"Select Folder" initialDir:exportFilePath.text
- if exportPath != undefined do
- (
- exportFilePath.text = exportPath + "\\"
- )
- )
- on exportButton pressed do
- (
- local workingDirectory = pathConfig.getCurrentProjectFolder() + "\\"
- if exportFilePath.text != "" then
- workingDirectory = exportFilePath.text
- writeBSDsFromMorphers workingDirectory $
- MessageBox("Export finished.")
- )
- )
- addRollout exportRollout BSDExport rolledup:false
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement