Example #1
0
    public void OnSceneGUI()
    {
        PHIKEndEffectorBehaviour phIKEEBehaviour = (PHIKEndEffectorBehaviour)target;

        // ----- ----- ----- ----- -----
        // Target Position Handle
        if (phIKEEBehaviour.showTargetPositionHandle)
        {
            Tools.current = Tool.None;
            if (phIKEEBehaviour.iktarget == null)
            {
                if (phIKEEBehaviour.phIKEndEffector != null)
                {
                    Vector3 currTargetPos = phIKEEBehaviour.phIKEndEffector.GetTargetPosition().ToVector3();
                    Vector3 handlePos     = Handles.PositionHandle(currTargetPos, Quaternion.identity);
                    phIKEEBehaviour.desc.targetPosition = handlePos.ToVec3d();
                    phIKEEBehaviour.phIKEndEffector.SetTargetPosition(handlePos.ToVec3d());
                }
                else if (phIKEEBehaviour.desc != null)
                {
                    Vector3 currTargetPos = ((Vec3d)(phIKEEBehaviour.desc.targetPosition)).ToVector3();
                    Vector3 handlePos     = Handles.PositionHandle(currTargetPos, Quaternion.identity);
                    phIKEEBehaviour.desc.targetPosition = handlePos.ToVec3d();
                }
            }
        }

        // ----- ----- ----- ----- -----
        // Target Orientation Handle
        if (phIKEEBehaviour.showTargetOrientationHandle)
        {
            Tools.current = Tool.None;
            if (phIKEEBehaviour.iktarget == null)
            {
                if (phIKEEBehaviour.phIKEndEffector != null)
                {
                    Vector3    currTargetPos = phIKEEBehaviour.phIKEndEffector.GetTargetPosition().ToVector3();
                    Quaternion currTargetOri = phIKEEBehaviour.phIKEndEffector.GetTargetOrientation().ToQuaternion();
                    Quaternion handleOri     = Handles.RotationHandle(currTargetOri, currTargetPos);
                    phIKEEBehaviour.desc.targetOrientation = handleOri.ToQuaterniond();
                    phIKEEBehaviour.phIKEndEffector.SetTargetOrientation(handleOri.ToQuaterniond());
                }
                else if (phIKEEBehaviour.desc != null)
                {
                    Vector3    currTargetPos = ((Vec3d)(phIKEEBehaviour.desc.targetPosition)).ToVector3();
                    Quaternion currTargetOri = ((Quaterniond)(phIKEEBehaviour.desc.targetOrientation)).ToQuaternion();
                    Quaternion handleOri     = Handles.RotationHandle(currTargetOri, currTargetPos);
                    phIKEEBehaviour.desc.targetOrientation = handleOri.ToQuaterniond();
                }
            }
        }
    }
Example #2
0
 public void RegisterPHIKEndEffectorBehaviour(PHIKEndEffectorBehaviour phIKEndEffector)
 {
     phIKEndEffectorBehaviours.Add(phIKEndEffector);
 }