Beispiel #1
0
        private void DrawMotion(BioJoint.Motion motion, Color color, bool final)
        {
            if (Target.SelectedSegment == motion.Joint.Segment && final)
            {
                DrawArrow(motion.Joint.GetAnchorInWorldSpace(), motion.Joint.Segment.Transform.rotation * Quaternion.LookRotation(motion.Axis), 0.125f, motion.IsEnabled() ? color : Color.grey);

                if (!motion.IsEnabled() || !motion.Constrained)
                {
                    return;
                }

                if (motion.Joint.JointType == JointType.Rotational)
                {
                    if (motion == motion.Joint.X)
                    {
                        DrawSolidArc(
                            motion.Joint.GetAnchorInWorldSpace(),
                            motion.Joint.Segment.Transform.rotation * motion.Axis,
                            Quaternion.AngleAxis((float)motion.GetLowerLimit(), motion.Joint.Segment.Transform.rotation * motion.Axis) * motion.Joint.Segment.Transform.rotation * motion.Joint.Y.Axis,
                            (float)motion.GetUpperLimit() - (float)motion.GetLowerLimit(),
                            0.125f,
                            new Color(1f, 0f, 0f, 0.25f)
                            );
                    }
                    if (motion == motion.Joint.Y)
                    {
                        DrawSolidArc(
                            motion.Joint.GetAnchorInWorldSpace(),
                            motion.Joint.Segment.Transform.rotation * motion.Axis,
                            Quaternion.AngleAxis((float)motion.GetLowerLimit(), motion.Joint.Segment.Transform.rotation * motion.Axis) * motion.Joint.Segment.Transform.rotation * motion.Joint.Z.Axis,
                            (float)motion.GetUpperLimit() - (float)motion.GetLowerLimit(),
                            0.125f,
                            new Color(0f, 1f, 0f, 0.25f)
                            );
                    }
                    if (motion == motion.Joint.Z)
                    {
                        DrawSolidArc(
                            motion.Joint.GetAnchorInWorldSpace(),
                            motion.Joint.Segment.Transform.rotation * motion.Axis,
                            Quaternion.AngleAxis((float)motion.GetLowerLimit(), motion.Joint.Segment.Transform.rotation * motion.Axis) * motion.Joint.Segment.Transform.rotation * motion.Joint.X.Axis,
                            (float)motion.GetUpperLimit() - (float)motion.GetLowerLimit(),
                            0.125f,
                            new Color(0f, 0f, 1f, 0.25f)
                            );
                    }
                }

                if (motion.Joint.JointType == JointType.Translational)
                {
                    Vector3 A = motion.Joint.GetAnchorInWorldSpace() + (float)motion.GetLowerLimit() * (motion.Joint.Segment.Transform.rotation * motion.Axis);
                    Vector3 B = motion.Joint.GetAnchorInWorldSpace() + (float)motion.GetUpperLimit() * (motion.Joint.Segment.Transform.rotation * motion.Axis);
                    Color   c = Color.white;
                    if (motion == motion.Joint.X)
                    {
                        c = Color.red;
                    }
                    if (motion == motion.Joint.Y)
                    {
                        c = Color.green;
                    }
                    if (motion == motion.Joint.Z)
                    {
                        c = Color.blue;
                    }
                    DrawLine(A, B, 3f, c);
                    DrawCube(A, motion.Joint.Segment.Transform.rotation, 0.0125f, new Color(c.r, c.g, c.b, 0.5f));
                    DrawCube(B, motion.Joint.Segment.Transform.rotation, 0.0125f, new Color(c.r, c.g, c.b, 0.5f));
                }
            }
            else if (Target.SelectedSegment != motion.Joint.Segment)
            {
                DrawArrow(motion.Joint.GetAnchorInWorldSpace(), motion.Joint.Segment.Transform.rotation * Quaternion.LookRotation(motion.Axis), 0.05f, motion.IsEnabled() ? color : Color.clear);
            }
        }
Beispiel #2
0
        private void InspectMotion(BioJoint.Motion motion, string name)
        {
            SetGUIColor(Color8);
            using (new EditorGUILayout.VerticalScope("Box")) {
                SetGUIColor(Color5);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.HelpBox(name, MessageType.None);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (motion.IsEnabled())
                {
                    SetGUIColor(Color1);
                    motion.Constrained = EditorGUILayout.Toggle("Constrained", motion.Constrained);
                    if (motion.Constrained)
                    {
                        SetGUIColor(Color1);
                        motion.SetLowerLimit(EditorGUILayout.DoubleField("Lower Limit", motion.GetLowerLimit()));
                        SetGUIColor(Color1);
                        motion.SetUpperLimit(EditorGUILayout.DoubleField("Upper Limit", motion.GetUpperLimit()));
                        SetGUIColor(Color1);
                        motion.SetTargetValue(EditorGUILayout.Slider("Target Value", (float)motion.GetTargetValue(), (float)motion.GetLowerLimit(), (float)motion.GetUpperLimit()));
                    }
                    else
                    {
                        SetGUIColor(Color1);
                        motion.SetTargetValue(EditorGUILayout.DoubleField("Target Value", motion.GetTargetValue()));
                    }

                    GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                    SetGUIColor(Color1);
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Disable", GUILayout.Width(250f), GUILayout.Height(20f)))
                    {
                        motion.SetEnabled(false);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                    SetGUIColor(Color1);
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Enable", GUILayout.Width(250f), GUILayout.Height(20f)))
                    {
                        motion.SetEnabled(true);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
            }
        }