fragmented sphere - new object pivot problem
Hello,
I have this Sphere. I fragment it in lets say 20 fragments. The fragments get the pivot point of the sphere. I want to put a bend modifier on each fragment object so i need each object to have its pivot with the z axis pointing outside the sphere. How can i use maxscript to alter the original pivot of each object to point in the right direction? i'm quite new to maxscript and i can't figure it out. If i get the normals from a face or vertex can i use that to modify the pivot rotation for that object?
Thank you!
Mihai
Comments
Thanks for that bit of
Thanks for that bit of code. It's exactly what I was missing when trying to write a script that does the same thing. Here's what I came up with using your script and mine. Basically it takes any editmesh object and rotates the pivot to align to the normal of an index face. If all your objects only have 1 face just put 1 in the index and it should work.
fn RotatePivotOnly theobj index=
(
rot = (matrixFromNormal (getFaceNormal theobj index)*theobj.transform ) as quat
rotValInv=inverse rot
animate off in coordsys local obj.rotation*=RotValInv
obj.objectoffsetrot*=RotValInv
obj.objectoffsetpos*=RotValInv
)
correction: fn
correction:
fn RotatePivotOnly obj index=
(
rot = (matrixFromNormal (getFaceNormal obj index)*obj.transform ) as quat
rotValInv=inverse rot
animate off in coordsys local obj.rotation*=RotValInv
obj.objectoffsetrot*=RotValInv
obj.objectoffsetpos*=RotValInv
)
for i = 1 to selection.count do RotatePivotOnly selection[i] 1
Hi Perhaps, this can help
Hi
Perhaps, this can help you
I think, you need code like a placed Center Pivot to each the object.
the script like this :
for i in selection do i.pivot = i.center
well, the script for pivot angle axis transform back to normal :
for i in selection do ResetXForm i -- this will Reset with add xform modifier
ok this is the script with
ok this is the script with witch i've managed to rotate the pivot from a vertex normal:
fn RotatePivotOnly obj rotation= ( local rotValInv=inverse (rotation as quat)
animate off in coordsys local obj.rotation*=RotValInv
obj.objectoffsetrot*=RotValInv
obj.objectoffsetpos*=RotValInv
)
for obj in $TPOP_Export* do
(
if classof obj == Editable_mesh do
(
obj.wirecolor = red
RotatePivotOnly obj (MatrixFromNormal (getNormal obj 1))
addmodifier obj (meshsmooth iterations:1)
addmodifier obj (bend direction:(random -4.0 4.0))
animate on
(
at time 0 obj.bend.angle = 0
at time 180 obj.bend.angle = 150
)
)
)
anyway i get the normals from 1 vertex and that vertex is not pointing always in the right direction. so this does not solve the problem. I think i have to make an average of all the vertexes.