Is there any simple way? Rotate doesn’t work or I don’t know how to make it work.
Please help, it’s several days now I’m trying to do this. It’s the only thing I need to finish the surface developing script, my due is close.
Thanks
Get the face, get the vertices used by face, transform them by whatever transformation matrix you want.
Rotations at Sub-Object level are actually translations of vertices. Same applies to edges.
OK ... transformation matrix ... that sounds like a fun
I tried to use Editable Mesh instead, rotate works there but getting of neighbor faces from edge works weird.
Couldn’t you throw in some sample piece of code showing how to rotate bitarray of vertices?
Anyway, thanks for fast reaction, it will help me.
OK, I found out what transform matrices are, and how I can transform objects with them, but transforming vertices…
Here is an example:
fn rotateSelectedPolyFaces theObj theAngle thePivot: = ( local theSel = polyOp.getFaceSelection theObj --# get the selected faces local theVerts = polyOp.getVertsUsingFace theObj theSel --# convert to vertex selection local theMatrix = theAngle as matrix3 --# convert the quaternion to a matrix local thePivotMatrix = if thePivot == unsupplied then matrix3 1 --# if no pivot node is provided, use identity matrix - this will result in rotation about world origin else thePivot.transform --# otherwise use the transformation matrix of the supplied node --# calculate the transformation matrix - get the vertex out of world space into the space of the pivot node, --# multiply by the rotation matrix and convert back to world space local theTM = inverse thePivotMatrix * theMatrix * thePivotMatrix for v in theVerts do --# for every vertex, get the position, transform by the matrix and set back as new position polyOp.setVert theObj v ((polyOp.getVert theObj v)* theTM) redrawViews() --# force a viewport update )
--# Create a Sphere, collapse to EPoly, select some faces. --# Also create a Point helper as Reference coordinate system --# EXAMPLES: rotateSelectedPolyFaces $Sphere01 (quat 30 [0,0,-1]) --# rotate about world origin's Z rotateSelectedPolyFaces $Sphere01 (quat 30 [1,0,0]) thePivot:$Sphere01 --# rotate about local origin's X rotateSelectedPolyFaces $Sphere01 (quat 30 [0,1,0]) thePivot:$Point01 --# rotate about Point01's Y
Everything you see and do in Max ends up using transformation matrices one way or another. All the object and sub-object rotations, scaling, translations, viewport and camera projections, rendering, shading etc. use them. They are like The Force, binding the 3D world together… Learn to use them.