View Full Version : Subobjects' transforms exposed to maxscript?!
loocas 09252005, 07:48 PM Hi there guys,
I'm trying to solve a big problem right now!
Are Subobject elements (faces, vertexes etc...) actually exposed to maxscript transform wise?
Ok, I have a Editable Poly object, I have a Polygon selected and I need to ROTATE that polygon along it's local Z axis... I can extract all the maxtrix3 data necessary to make the rotation by any angle... HOWEVER... How the hell do I say to maxscript that I wanna ROTATE that polygon?!
Rotate() works only with nodes
RotateZ() only changes the Quat values of the rotation matrix :(
How do I do that?!
Thanks in advance for any suggestions, help, answers...
cheers,
 loocas


Hi there guys,
I'm trying to solve a big problem right now!
Are Subobject elements (faces, vertexes etc...) actually exposed to maxscript transform wise?
Ok, I have a Editable Poly object, I have a Polygon selected and I need to ROTATE that polygon along it's local Z axis... I can extract all the maxtrix3 data necessary to make the rotation by any angle... HOWEVER... How the hell do I say to maxscript that I wanna ROTATE that polygon?!
Rotate() works only with nodes
RotateZ() only changes the Quat values of the rotation matrix :(
How do I do that?!
Thanks in advance for any suggestions, help, answers...
cheers,
 loocas
Rotations are actually position changes using a matrix transformation :)
Here is an example which creates a plane and rotates one polygon about its center around the face normal  360 times at 1 degree
create a plane with some arbitrary location and orientation
theObj = convertTo (plane pos:[10,20,30] rotation:(quat 45 [1,1,0])) editable_poly
select theObj select the plane
thePolyIndex = 1 decide which poly to rotate
theVerts = polyop.getVertsUsingFace theObj thePolyIndex get all its vertices
in coordsys local all operations in object space
(
theCenter = polyOp.getFaceCenter theObj thePolyIndex get the face center in object space
theNormal = polyOp.getFaceNormal theObj thePolyIndex get the face normal in object space
theTM = matrixFromNormal theNormal build a matrix from the normal  the face local space matrix
theTM.row4 = theCenter set the center of the matrix to the center of the face in object space
theInvTM = inverse theTM calculate the inverse of the matrix
theRotTM = (rotateZMatrix 1.0) * theTM calculate the rotation matrix for 1 degree about Z
for t = 1 to 360 do repeat 36 times
(
for i in theVerts do loop through all vertices
(
theVert = (polyop.getVert theObj i) * theInvTM get the vertex in the face normal space
theVert *= theRotTM rotate the vertex in the face normal space at 1 degree about Z
polyop.setVert theObj i theVert  write the vertex back into the mesh
)end i loop
max views redraw force a redraw
sleep 0.01 and wait a bit to see the result
)end t loop
)end local space
loocas
09262005, 12:20 AM
Rotations are actually position changes using a matrix transformation :)
Here is an example which creates a plane and rotates one polygon about its center around the face normal  360 times at 1 degree
create a plane with some arbitrary location and orientation
theObj = convertTo (plane pos:[10,20,30] rotation:(quat 45 [1,1,0])) editable_poly
select theObj select the plane
thePolyIndex = 1 decide which poly to rotate
theVerts = polyop.getVertsUsingFace theObj thePolyIndex get all its vertices
in coordsys local all operations in object space
(
theCenter = polyOp.getFaceCenter theObj thePolyIndex get the face center in object space
theNormal = polyOp.getFaceNormal theObj thePolyIndex get the face normal in object space
theTM = matrixFromNormal theNormal build a matrix from the normal  the face local space matrix
theTM.row4 = theCenter set the center of the matrix to the center of the face in object space
theInvTM = inverse theTM calculate the inverse of the matrix
theRotTM = (rotateZMatrix 1.0) * theTM calculate the rotation matrix for 1 degree about Z
for t = 1 to 360 do repeat 36 times
(
for i in theVerts do loop through all vertices
(
theVert = (polyop.getVert theObj i) * theInvTM get the vertex in the face normal space
theVert *= theRotTM rotate the vertex in the face normal space at 1 degree about Z
polyop.setVert theObj i theVert  write the vertex back into the mesh
)end i loop
max views redraw force a redraw
sleep 0.01 and wait a bit to see the result
)end t loop
)end local space
You are the man Bobo! :buttrock: You're da man! :bowdown:
Thanks a lot! :thumbsup:
You are the man Bobo! :buttrock: You're da man! :bowdown:
Thanks a lot! :thumbsup:
No problem, here is a much shorter version with less matrix transformations:
theObj = convertTo (plane pos:[10,20,30] rotation:(quat 45 [1,1,0])) editable_poly
select theObj select the plane
thePolyIndex = 6 decide which poly to rotate
theVerts = polyop.getVertsUsingFace theObj thePolyIndex get all its vertices
theTM = matrixFromNormal (polyOp.getFaceNormal theObj thePolyIndex )
theTM.row4 = polyOp.getFaceCenter theObj thePolyIndex
theRotTM = (rotateZMatrix 1.0) * theTM
for t = 1 to 360 do
(
for i in theVerts do
(
in coordsys theTM theVert = (polyop.getVert theObj i)
theVert *= theRotTM
polyop.setVert theObj i theVert
)end i loop
redrawViews()
)end t loop
loocas
09262005, 10:10 AM
No problem, here is a much shorter version with less matrix transformations:
theObj = convertTo (plane pos:[10,20,30] rotation:(quat 45 [1,1,0])) editable_poly
select theObj select the plane
thePolyIndex = 6 decide which poly to rotate
theVerts = polyop.getVertsUsingFace theObj thePolyIndex get all its vertices
theTM = matrixFromNormal (polyOp.getFaceNormal theObj thePolyIndex )
theTM.row4 = polyOp.getFaceCenter theObj thePolyIndex
theRotTM = (rotateZMatrix 1.0) * theTM
for t = 1 to 360 do
(
for i in theVerts do
(
in coordsys theTM theVert = (polyop.getVert theObj i)
theVert *= theRotTM
polyop.setVert theObj i theVert
)end i loop
redrawViews()
)end t loop
Thanks a lot man! I really appretiate it! :thumbsup:
CGTalk Moderation
09262005, 10:10 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.