Created
November 11, 2015 04:44
-
-
Save zwcloud/b05d7e1c01e10cd44a62 to your computer and use it in GitHub Desktop.
MaxScript that convert a mesh into text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tmesh = $Mesh0 | |
num_verts = $Mesh0.numverts | |
num_faces = $Mesh0.numfaces | |
format "%,%\n" num_verts num_faces | |
units.MetricType = #meters | |
for v = 1 to num_verts do | |
( | |
vert = getVert tmesh v | |
if(abs vert.x < 0.001f) then vert.x = 0f | |
if(abs vert.y < 0.001f) then vert.y = 0f | |
if(abs vert.z < 0.001f) then vert.z = 0f | |
format "new Vector3(%f, %f, %f),\n" \ | |
(units.formatValue vert.x)\ | |
(units.formatValue vert.y)\ | |
(units.formatValue vert.z)\ | |
) | |
format "\n" | |
for f = 1 to num_faces do | |
( | |
face = getFace tmesh f | |
format "%,%,%," \ | |
((face.x-1)as integer) \ | |
((face.y-1)as integer) \ | |
((face.z-1)as integer) | |
) | |
format "\n" | |
texture_coords = #() | |
for count = 1 to num_faces do | |
( | |
local face = getFace tmesh count | |
local t_face = getTVFace tmesh count | |
texture_coords[face.x] = getTVert tmesh t_face.x | |
texture_coords[face.y] = getTVert tmesh t_face.y | |
texture_coords[face.z] = getTVert tmesh t_face.z | |
) | |
for tex_coord in texture_coords do | |
( | |
format "new Vector2(%f, %f),\n" \ | |
(tex_coord.x) \ | |
(tex_coord.y) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment