This reflects the state of the Simple Mesh Format when the function was coded. By studying the code and examining the file output you'll be able to understand how objects are built.
type VertData
x as float
y as float
z as float
xn as float
yn as float
zn as float
u as float
v as float
endtype
dim indexdata()
dim vertexdata() as VertData
backdrop off
make object cube 1, 5
SaveSimpleMesh(1, "Mesh.txt")
print "Done! Press any key to exit."
wait key
end
function SaveSimpleMesh(ObjID as integer, FName as string)
local vertices as integer
local indices as integer
lock vertexdata for limb ObjID, 0
vertices = get vertexdata vertex count()
indices = get vertexdata index count()
for i = 0 to vertices - 1
array insert at bottom vertexdata()
vertexdata(i).x = get vertexdata position x(i)
vertexdata(i).y = get vertexdata position y(i)
vertexdata(i).z = get vertexdata position z(i)
vertexdata(i).xn = get vertexdata normals x(i)
vertexdata(i).yn = get vertexdata normals y(i)
vertexdata(i).zn = get vertexdata normals z(i)
vertexdata(i).u = get vertexdata u(i)
vertexdata(i).v = get vertexdata v(i)
next i
for i = 0 to indices - 1
array insert at bottom indexdata()
indexdata(i) = get indexdata(i)
next i
unlock vertexdata
if file exist(FName)
delete file FName
endif
open to write 1, FName
write string 1, "SimpleMeshFormat 1"
write string 1, "1"
write string 1, "Mesh"
write string 1, str$(vertices)
for i = 0 to vertices - 1
vertexline$ = str$(vertexdata(i).x) + " " + str$(vertexdata(i).y) + " " + str$(vertexdata(i).z)
write string 1, vertexline$
next i
write string 1, str$(indices / 3)
for i = 0 to indices - 3 step 3
indices$ = str$(indexdata(i)) + " " + str$(indexdata(i + 1)) + " " + str$(indexdata(i + 2))
normals1$ = str$(vertexdata(indexdata(i)).xn) + " " + str$(vertexdata(indexdata(i)).yn) + " " + str$(vertexdata(indexdata(i)).zn)
normals2$ = str$(vertexdata(indexdata(i + 1)).xn) + " " + str$(vertexdata(indexdata(i + 1)).yn) + " " + str$(vertexdata(indexdata(i + 1)).zn)
normals3$ = str$(vertexdata(indexdata(i + 2)).xn) + " " + str$(vertexdata(indexdata(i + 2)).yn) + " " + str$(vertexdata(indexdata(i + 2)).zn)
uv1$ = str$(vertexdata(indexdata(i)).u) + " " + str$(vertexdata(indexdata(i)).v)
uv2$ = str$(vertexdata(indexdata(i + 1)).u) + " " + str$(vertexdata(indexdata(i + 1)).v)
uv3$ = str$(vertexdata(indexdata(i + 2)).u) + " " + str$(vertexdata(indexdata(i + 2)).v)
indexline$ = indices$ + " " + normals1$ + " " + normals2$ + " " + normals3$ + " " + uv1$ + " " + uv2$ + " " + uv3$
write string 1, indexline$
next i
close file 1
empty array vertexdata()
empty array indexdata()
endfunction