Beispiel #1
0
        public static void PoseMixerInspector(PoseMixer poseMixer, HumanoidControl humanoid)
        {
            int i = 0;

            foreach (MixedPose pose in poseMixer.mixedPoses)
            {
                Pose oldPose = pose.pose;
                HumanoidPoseInspector(poseMixer, pose, i, humanoid);
                if (pose.pose != oldPose && pose.pose == null)
                {
                    // We deleted a pose, let's undo it's effect
                    pose.value = 0;
                    pose.pose  = oldPose;
                    poseMixer.ShowPose(humanoid);
                    pose.pose = null;
                }
                i++;
            }

            EditorGUILayout.BeginHorizontal();
            Pose addPose = (Pose)EditorGUILayout.ObjectField(null, typeof(Pose), false, GUILayout.Width(200));

            if (addPose != null)
            {
                MixedPose newPose = poseMixer.Add();
                newPose.pose = addPose;
            }
            EditorGUILayout.EndHorizontal();
        }
Beispiel #2
0
        public static MixedPose HumanoidPoseInspector(PoseMixer poseMixer, MixedPose mixedPose, int poseIx, HumanoidControl humanoid)
        {
            EditorGUILayout.BeginHorizontal();

            mixedPose.pose = (Pose)EditorGUILayout.ObjectField(mixedPose.pose, typeof(Pose), false, GUILayout.Width(200));
            if (mixedPose.pose != null)
            {
                if (mixedPose.isEdited)
                {
                    EditorGUILayout.Slider(mixedPose.value, 0, 1);
                    //poseMixer.SetPoseValue(mixedPose, 1);
                    poseMixer.SetPoseValue(poseIx, 1);
                }
                else
                {
                    float value = EditorGUILayout.Slider(mixedPose.value, 0, 1);
                    if (value != mixedPose.value)
                    {
                        //poseMixer.SetPoseValue(mixedPose, value);
                        poseMixer.SetPoseValue(poseIx, value);
                    }
                }
                if (!Application.isPlaying)
                {
                    bool isEdited = EditorGUILayout.Toggle(mixedPose.isEdited, "button", GUILayout.Width(19));
                    if (mixedPose.isEdited != isEdited)
                    {
                        SceneView.RepaintAll();
                    }
                    mixedPose.isEdited = isEdited;
                }
                else
                {
                    EditorGUILayout.FloatField(mixedPose.pose.GetScore(humanoid, Side.Left));
                }
            }

            EditorGUILayout.EndHorizontal();
            return(mixedPose);
        }
Beispiel #3
0
        public static void UpdateScene(HumanoidControl humanoid, ITarget target, PoseMixer poseMixer, ref BonePose selectedBone, Side side = Side.AnySide)
        {
            //if (!Application.isPlaying)
            //    poseMixer.ShowPose(humanoid);

            MixedPose currentPose = poseMixer.GetEditedPose();

            if (currentPose == null || !currentPose.isEdited)
            {
                Tools.hidden = false;
                return;
            }

            Tools.hidden = true;

            HumanoidTarget.TargetedBone[] bones = target.GetBones();
            int[]  controlIds = new int[bones.Length];
            Bone[] boneIds    = new Bone[bones.Length];

            for (int i = 0; i < bones.Length; i++)
            {
                if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null)
                {
                    continue;
                }

                Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID);
                controlIds[i] = lastControlID;
                boneIds[i]    = bones[i].boneId;
            }

            FindSelectedHandle(controlIds, boneIds, ref boneIndex);
            if (boneIndex == -1)
            {
                return;
            }

            HumanoidTarget.TargetedBone targetedBone = FindTargetedBone(bones, boneIds[boneIndex]);
            if (targetedBone == null || targetedBone.bone.transform == null)
            {
                return;
            }

            GUIStyle style = new GUIStyle();

            style.normal.textColor = Color.yellow;
            Handles.Label(targetedBone.bone.transform.position + Vector3.up * 0.01F, targetedBone.name, style);
            Handles.color = Color.white;

            switch (Tools.current)
            {
            case Tool.Move:
                selectedBone = currentPose.pose.CheckBone(boneIds[boneIndex], true);
                Vector3 handlePosition = Handles.PositionHandle(targetedBone.target.transform.position, targetedBone.bone.transform.rotation);
                targetedBone.target.transform.position = handlePosition;
                selectedBone.setTranslation            = true;
                selectedBone.SetReferenceLocal(humanoid, side);
                selectedBone.UpdateTranslation(humanoid, side);
                break;

            case Tool.Rotate:
                selectedBone = currentPose.pose.CheckBone(boneIds[boneIndex], true);
                Quaternion handleRotation = Handles.RotationHandle(targetedBone.target.transform.rotation, targetedBone.bone.transform.position);
                targetedBone.target.transform.rotation = handleRotation;
                selectedBone.setRotation = true;
                selectedBone.SetReferenceLocal(humanoid, side);
                selectedBone.UpdateRotation(humanoid, side);
                break;

            case Tool.Scale:
                //Handles.ScaleHandle(selectedBone.transform.localScale, selectedBone.transform.position, selectedBone.transform.rotation, HandleUtility.GetHandleSize(selectedBone.transform.position));
                // need to all morphScale first...
                break;
            }

            Handles.BeginGUI();
            ResetBoneButton(selectedBone, humanoid);
            Handles.EndGUI();
        }