コード例 #1
0
ファイル: IK_Segment.cs プロジェクト: superowner/UnityIK
    public void AddSegment(IK_Segment existingSegment)
    {
        end.AddChild(existingSegment.root);
        childrenSegments.Add(existingSegment);

        existingSegment.joints.Insert(0, end);
        existingSegment.joints[1].parentJoint = end; // Old root
        existingSegment.root          = end;
        existingSegment.parentSegment = existingSegment;


        end.UpdateJointDetails();
        existingSegment.root.parentJoint.UpdateJointDetails();
    }
コード例 #2
0
    public IK_Joint(IK_Joint _parentJoint, float _distanceToParent = 0)
    {
        id = joint_id;
        joint_id++;

        parentJoint = _parentJoint;
        if (_parentJoint == null) // If there is no parent (null), return early
        {
            return;
        }

        distanceToParent = _distanceToParent;
        distanceToRoot   = _parentJoint.distanceToRoot + 1;

        _parentJoint.AddChild(this);
        childIndex = _parentJoint.childrenJoints.Count - 1;
        limbIndex  = _parentJoint.limbIndex + 1;

        ForAllChildren(_parentJoint, (IK_Joint joint) => {
            joint.UpdateJointDetails();
        });
    }