I am trying to write a simple mesh exporter in maxscript. It's nothing fancy, it just has to export faces, vertices and tvertices. I have the code as good as working, but sometimes I get really weird values in vertex positions (-1.1234e-005 for example). I understand it is some kind of really big number, but the problem is, my verts aren't anywhere near the position that number indicates (I have seen this happen with a 1m*1m*1m box). I have found that when it happens with a mesh, it always happens with that mesh and with the same vertex, untill I move that specific vertex (scaling/moving the whole thing doesn't work). I use this code to export the vertex positions:
num_verts = sel_mesh.numverts
for i=1 to num_verts do (
v = getVert sel_mesh i
format "v %\n" v to:out_file
)
format "\n" to:out_file
I have tried Googling the problem, but no one seems to have the same issue. I use the same code for my tvertices and those are exported perfectly fine. I can post the whole exporter if neccesary. Please let me know if you need to see more code :).
This is infact a very small number.
-1.1234e-005
is -1.1234 * (10 ^ -5)
, which is very small.
Contrary to your comment, formattedPrint
does 'fix' this.
formattedPrint -1.1234e-005 format:".6f"
output: "-0.000011"
You can use it as such in your exporter:
num_verts = sel_mesh.numverts
for i=1 to num_verts do (
v = getVert sel_mesh i
format "v %\n" (formattedPrint v format:".6f") to:out_file
)
format "\n" to:out_file