tom.drastic.net

maxscript…

“snapshotAsMesh object” gives you the current object completly collapsed.
bad thing is, the transform matrix is also applied, so all vertices are in world space.
get the vertices back into local space, you multiply every vertex with the inverse transformation matrix:

  mesh = snapshotAsMesh obj
  worldTransform = obj.transform
  invWorldTransform = inverse worldTransform 

  for v = 1 to mesh.numverts  do
  (
    vert=getVert mesh v
    vert*=invWorldTransform -- daadaaa
    WriteFloat f vert.x
    WriteFloat f vert.y
    WriteFloat f vert.z
  )

for your normals you have to do the same, just multiply with the inverse world matrix. but only use rotation this time.

do not use obj.mesh directly to get object space vertex coordinates, or your script will become unbelivable slow…..

April 12th, 2008 | maxscript, dev, 3d, 3dsmax |


Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.