I'm using Moho 13 Pro.
I can decide parent of bone by the following code.
local frame = 0
local skel = moho:Skeleton()
local child_bone = skel:AddBone(frame)
child_bone.fAnimParent:SetValue(frame, parent_bone_id)
In this case, however, the child bone is connected to the tail of the parent bone.
This behavior is also beneficial, but sometimes I want to connect child bone to tip of parent bone.
Is it possible?
Script: I want to connect child bone to tip of parent bone (not tail)
Moderators: Víctor Paredes, Belgarath, slowtiger
Re: Script: I want to connect child bone to tip of parent bone (not tail)
It doesn't matter wether you (manually) place your child bone at the top or bottom end of the parent bone - it just looks like that. The only position data Moho stores is the distance and angle to the parent bone's origin.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini Plus OS 13.5
Re: Script: I want to connect child bone to tip of parent bone (not tail)
I see. What I should do is move the child bone to the tip of the parent bone.
I don't know how to find the coordinates of the tip of the parent bone, so I will try to find it.
I don't know how to find the coordinates of the tip of the parent bone, so I will try to find it.
Re: Script: I want to connect child bone to tip of parent bone (not tail)
This might get you started:
Code: Select all
local bone = skel:Bone(parent_bone_id)
local boneBase = LM.Vector2:new_local()
local boneTip = LM.Vector2:new_local()
boneBase:Set(0,0)
bone.fMovedMatrix:Transform(boneBase)
if not (bone:IsZeroLength()) then
boneTip:Set(bone.fLength, 0)
bone.fMovedMatrix:Transform(boneTip)
end
Re: Script: I want to connect child bone to tip of parent bone (not tail)
Thank you.
It worked fine the following code.
And I didn't use it this time, but I got a little deeper understanding of how to use matrix.
It worked fine the following code.
Code: Select all
local bone = skel:Bone(parent_bone_id)
local boneTip = LM.Vector2:new_local()
if not (bone:IsZeroLength()) then
boneTip:Set(bone.fLength, 0)
child_bone.fAnimPos:SetValue(frame, boneTip)
end