Archives Posts
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…..
Archives Posts
random maxscript questions
just some random questions i had when starting with a maxscript exporter…
how do i read animated values ?
for printing an object position at time T, do:
print at time T obj.pos.x
getting information about scene animation
animationrange.end animationrange.start
what is the current framerate ?
use the global variable “frameRate”
how do i rewind or set the max timeline?
use the global variable sliderTime to set it.
sliderTime =0
how to get vertex normals ?
this way your normals look like you wanted them. (”smoothing groups safe”)
for ve = 1 to mesh.numfaces do
(
norm=meshop.getFaceRNormals mesh ve
format "% % %" norm[1].x norm[1].y norm[1].z
format "% % %" norm[2].x norm[2].y norm[2].z
format "% % %" norm[3].x norm[3].y norm[3].z
)
what is the color i set at rendering->environment->background color ?
use the global variable “backgroundColor” :)
how to test if an object is animated ?
you can check (boolean) “obj.isanimated”.
i think this works not if vertices of the object are animated. only if position/rotation/etc. are animated..
also this is false if the object is linked to a bone, which is animated!
