Notifications
Clear all
[Closed] Bones mirroring
Aug 24, 2021 5:29 am
Hey guys, I’m trying to make a script that will mirror max bones, without axis flipping, I have several variations, but each of them has its own problems.
This option works well, but it makes the wrong rotation about the X-axis.
Bones_L = selection as Array
Bones_R = #()
parentBone = undefined
for b in Bones_L do (
newBone = BoneSys.createBone[-b.pos.x,b.pos.y,b.pos.z] [1,1,1] [1,1,1]
newBone.name = "newBone"
newBone.dir = b.dir
if parentbone != undefined then (newBone.parent = parentBone)
parentBone = newBone
append Bones_R newBone
)
for b in Bones_R do (
b.realignBoneToChild()
b.resetBoneStretch()
)
this one is working great when i’m testing it on the regular boxes, but with the bones it starts to crash
newBone = BoneSys.createBone[1,0,0] [0,20,0] [0,0,10]
newBone.rotation = quat (random -360 360) (random -360 360) (random -360 360) (random -360 360)
newBone2 = copy newBone
newBone2.rotation = quat newBone.rotation.x -newBone.rotation.y -newBone.rotation.z newBone.rotation.w
I will be grateful for any help!
1 Reply
Aug 24, 2021 5:29 am
Denis is really the man for this sort of thing…
but this might do the job for you…
fn mirror_across_yz_plane tm =
(
mtm = matrix3 [-1, 0, 0] [0, 1, 0] [0, 0, 1] [0, 0, 0];
rtm = tm * mtm;
rtm.row2 = rtm.row2 * -1;
rtm;
)
$bone02.transform = mirror_across_yz_plane $bone02.transform