My code
Code: Select all
rollout SWG_roll "Model exporter" (
--GUI--
spinner fscale "Scale : " fieldwidth:60 range:[0.001, 1000, 1]
button expMSH "Export MSH" width:150 Height:25 align:#center
label lbl1 ""
label lbl2 "Based off Fatduck Importer" align:#right
on expMSH pressed do (
fname = getSaveFileName caption:"Select Star Wars Galaxies Model file" types:"MSH File (*.msh)|*.msh|All Files (*.*)|*.*|"
if fname != undefined then (
f = createfile fname
close f
stream = fopen fname "wb"
for iObIndex = 1 to $objects.count do (
obj = selection
tmesh = snapshotAsMesh selection[1]
num_faces = getNumFaces tmesh
vertDupx = #(5.2)
vertDupy = #(5.2)
vertDupz = #(5.2)
for f=1 to num_faces do(
faceVertIndex = getFace tmesh f
tVertIndex = getTVFace tmesh f
for i=1 to 3 do(
check = false
vpos = getVert tmesh faceVertIndex[i]
for leng = 1 to vertDupx.count do (
if ((vpos.x == vertDupx[leng]) and (vpos.y == vertDupy[leng]) and (vpos.z == vertDupz[leng])) then (
check = true
continue
)
)
if (not check) then (
append vertDupx vpos.x
append vertDupy vpos.y
append vertDupz vpos.z
writeFloat stream vpos.x
writeFloat stream vpos.y
writeFloat stream vpos.z
normals = getNormal tmesh faceVertIndex[i]
n1 = sqrt(normals.x^2 + normals.y^2 + normals.z^2)
if (n1 == 0) then (
nx = 0
ny = 0
nz = 0
) else (
nx = (normals.x/n1)
ny = (normals.y/n1)
nz = (normals.z/n1)
)
writeFloat stream nx
writeFloat stream ny
WriteFloat stream nz
vuvpos = getTVert tmesh tVertIndex[i]
writeFloat stream vuvpos.x
writeFloat stream vuvpos.y
)
)
)
)
fclose stream
)--end if fname
)--end on impMGN
)--end rollout SWG_roll
floater = newRolloutFloater "Star Wars Galaxies" 200 175 10 70
addRollout SWG_roll floater

