--- начало файла MaXport.ms ---
utility MaXport "MaXport 1.0" width:162 height:160
(
local ostream, a, b, ut
GroupBox grp1 "Properties" pos:[4,7] width:154 height:89
checkbox cb_exportSelOnly "Selected only" pos:[13,26] width:129 height:15
button btn_export "Export" pos:[5,103] width:60 height:21
button btn_about "About" pos:[5,133] width:60 height:21
progressBar pb "" pos:[70,103] width:87 height:21
edittext edit_fname "" pos:[5,70] width:146 height:21
label lbl2 "File name" pos:[13,51] width:46 height:13
button btn_browse "Browse" pos:[96,47] width:55 height:17 posdf:[96,49]
-------------------------------------------------------------------------------------
function ExportMesh meshObj =
(
if (meshObj.numTVerts>0 and meshObj.name != 'NoTex' and b!=1)or
((meshObj.numTVerts==0 or meshObj.name == 'NoTex') and b==1)then
(
a = a + 1
if a<3 then
(
pb.value=0
v = meshObj.numVerts + meshObj.numFaces + MeshObj.numTVerts
v = 100.0/v
x = 0
y = 0
pb.value = 0
if meshObj.numTVerts == 0 or meshObj.name == 'NoTex' then
ut=ut+1
if meshObj.numTVerts <= 0 or meshObj.name == 'NoTex' then
Format ("%\n% 0 %\n") meshObj.name meshObj.numverts meshObj.numfaces to
stream
else
Format ("%\n% % %\n") meshObj.name meshObj.numverts meshObj.numTVerts meshObj.numfaces to
stream
if meshObj.numVerts > 0 then
(
for i = 1 to meshObj.numVerts do
(
Format ("% % % ") ((GetVert meshObj i).x - meshObj.Center.x) ((GetVert meshObj i).y - meshObj.Center.y) ((GetVert meshObj i).z - meshObj.Center.z) to
stream
Format ("% % %\n") (GetNormal meshObj i).x (GetNormal meshObj i).y (GetNormal meshObj i).z to
stream
x = x + 1
if (x-y)*v >= 1 then
(
pb.value = x * v
y = x
)
)
)
if MeshObj.numTVerts > 0 and meshObj.name != 'NoTex' then
(
for i = 1 to meshObj.NumTVerts do
(
Format ("% % %\n") (GetTVert meshObj i).x (GetTVert meshObj i).y (GetTVert meshObj i).z to
stream
x = x + 1
if (x-y)*v >= 1 then
(
pb.value = x * v
y = x
)
)
)
if meshObj.numFaces > 0 then
(
for i = 1 to meshObj.numFaces do
(
Format ("% % % ") ((GetFace meshObj i).x as Integer) ((GetFace meshObj i).y as integer) ((GetFace meshObj i).z as Integer) to
stream
if meshObj.numTVerts>0 or meshObj.name == 'NoTex' then
Format ("% % %") ((GetTVFace meshObj i).x as Integer) ((GetTVFace meshObj i).y as Integer) ((GetTVFace meshObj i).z as Integer) to
stream
Format ("\n") to
stream
x = x + 1
if (x-y)*v >= 1 then
(
pb.value = x * v
y = x
)
)
)
)
)
)
-------------------------------------------------------------------------------------
function ExportPoint pObj =
(
Format ("%\n% % %\n") pObj.name pObj.center.x pObj.center.y pObj.center.z to
stream
)
-------------------------------------------------------------------------------------
function ExportNode node =
(
if b==100 and SuperClassOf node == GeometryClass and ClassOf node == Editable_mesh and (node.numTVerts == 0 or node.name == 'NoTex') then ut=ut+1
if b==100 and SuperClassOf node == GeometryClass and ClassOf node == Editable_mesh then a=a+1 else
if b==0 and SuperClassOf node == GeometryClass and ClassOf node == Editable_mesh then ExportMesh node
else
if b==1 and SuperClassOf node == GeometryClass and ClassOf node == Editable_mesh then ExportMesh node
else
if b==2 and SuperClassOf node == helper and ClassOf node == point then ExportPoint node
)
-------------------------------------------------------------------------------------
function RecursiveExportNode node =
(
ExportNode node
for child in node.children do
RecursiveExportNode child
)
-------------------------------------------------------------------------------------
on btn_export pressed do
(
btn_export.Enabled = false
ostream = CreateFile edit_fname.text
if ostream == undefined then
(
MessageBox "MaXport. Version 1.00\n Cannot access file." title:"MaXport export error"
)else(
Format ("MaXport 1.0\n") to
stream
ut=0;
a=0
ut=0
b=100
if cb_exportSelOnly.checked then
for node in selection do ExportNode node
else
for node in rootnode.children do RecursiveExportNode node
Format ("%\n") a to
stream
a=0
b=0
if (a-ut)<=1 then
(
if cb_exportSelOnly.checked then
(
for node in selection do ExportNode node
b=1
for node in selection do ExportNode node
b=2
for node in selection do ExportNode node
)else(
for node in rootnode.children do RecursiveExportNode node
b=1
for node in rootnode.children do RecursiveExportNode node
b=2
for node in rootnode.children do RecursiveExportNode node
)
)else(
MessageBox "MaXport. Version 1.00\n There can be only 2 meshes: textured and untextured parts, the second part must be named 'NoTex'." title:"MaXport export error"
)
Close ostream
ostream = OpenFile edit_fname.text
Close ostream
)
btn_export.Enabled = true
)
on btn_about pressed do
(
MessageBox "MaXport. Version 1.00\n Ярышев Юрий 2003г. Москва." title:"About MaXport"
)
on btn_browse pressed do
(
fname = GetSaveFileName types:"Max export files (*.mxf)|*.mxf|All Files(*.*)|*.*|"
if fname!=undefined then
(
edit_fname.text = fname
)
)
)
--- Конец файла ---