コード例 #1
0
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();
            SplineTracer tracer = (SplineTracer)target;

            if (triggerFoldout)
            {
                for (int i = 0; i < tracer.triggers.Length; i++)
                {
                    SplineEditorHandles.SplineSliderGizmo gizmo = SplineEditorHandles.SplineSliderGizmo.DualArrow;
                    switch (tracer.triggers[i].type)
                    {
                    case Trigger.Type.Backward: gizmo = SplineEditorHandles.SplineSliderGizmo.BackwardTriangle; break;

                    case Trigger.Type.Forward: gizmo = SplineEditorHandles.SplineSliderGizmo.ForwardTriangle; break;

                    case Trigger.Type.Double: gizmo = SplineEditorHandles.SplineSliderGizmo.DualArrow; break;
                    }
                    double last = tracer.triggers[i].position;
                    if (SplineEditorHandles.Slider(tracer, ref tracer.triggers[i].position, tracer.triggers[i].color, tracer.triggers[i].name, gizmo) || last != tracer.triggers[i].position)
                    {
                        trigger = i;
                        Repaint();
                    }
                }
            }
            if (customOffsetEditor.isOpen)
            {
                if (customOffsetEditor.DrawScene(tracer))
                {
                    tracer.Rebuild(false);
                }
            }

            if (customRotationEditor.isOpen)
            {
                if (customRotationEditor.DrawScene(tracer))
                {
                    tracer.Rebuild(false);
                }
            }
        }
コード例 #2
0
        void SceneClipEdit()
        {
            SplineUser user = (SplineUser)target;
            Color      col  = Color.white;

            if (user.computer != null)
            {
                col = user.computer.editorPathColor;
            }
            double val = user.clipFrom;

            SplineEditorHandles.Slider(user, ref val, col, "Clip From", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle);
            if (val != user.clipFrom)
            {
                user.clipFrom = val;
            }
            val = user.clipTo;
            SplineEditorHandles.Slider(user, ref val, col, "Clip To", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle);
            if (val != user.clipTo)
            {
                user.clipTo = val;
            }
        }
コード例 #3
0
        public bool DrawScene(SplineUser user)
        {
            bool         changed = false;
            bool         is2D    = user.rootUser.computer.is2D;
            SplineResult result  = new SplineResult();

            for (int i = 0; i < group.keys.Count; i++)
            {
                if (selected >= 0 && i != selected)
                {
                    continue;
                }
                user.Evaluate(result, group.keys[i].position);
                matrix.SetTRS(result.position, Quaternion.LookRotation(result.direction, result.normal), Vector3.one * result.size);
                Vector3 pos = matrix.MultiplyPoint(group.keys[i].offset);
                if (is2D)
                {
                    Handles.DrawLine(result.position, result.position + result.right * group.keys[i].offset.x * result.size);
                    Handles.DrawLine(result.position, result.position - result.right * group.keys[i].offset.x * result.size);
                }
                else
                {
                    Handles.DrawWireDisc(result.position, result.direction, group.keys[i].offset.magnitude * result.size);
                }
                Handles.DrawLine(result.position, pos);
            }

            if (selected >= 0 && selected < group.keys.Count)
            {
                double value = group.keys[selected].position;
                user.Evaluate(result, value);
                matrix.SetTRS(result.position, Quaternion.LookRotation(result.direction, result.normal), Vector3.one * result.size);
                Vector3 pos = matrix.MultiplyPoint(group.keys[selected].offset);
                if (editOffset)
                {
                    Vector3 lastPos = pos;
                    pos = SplineEditorHandles.FreeMoveRectangle(pos, HandleUtility.GetHandleSize(pos) * 0.1f);
                    if (pos != lastPos)
                    {
                        pos   = matrix.inverse.MultiplyPoint(pos);
                        pos.z = 0f;
                        if (is2D)
                        {
                            group.keys[selected].offset = Vector2.right * pos.x;
                        }
                        else
                        {
                            group.keys[selected].offset = pos;
                        }
                        changed = true;
                    }
                }
                else
                {
                    double lastValue = value;
                    SplineEditorHandles.Slider(user, ref value, user.rootUser.computer.editorPathColor, "Center", SplineEditorHandles.SplineSliderGizmo.Circle, 0.6f);
                    if (value != lastValue)
                    {
                        changed = true;
                    }
                    if (group.keys[selected].from > group.keys[selected].to)
                    {
                        double fromToEndDistance     = 1.0 - group.keys[selected].from;
                        double toToBeginningDistance = group.keys[selected].to;
                        double totalDistance         = fromToEndDistance + toToBeginningDistance;
                        if (value > group.keys[selected].from)
                        {
                            group.keys[selected].center = DMath.InverseLerp(group.keys[selected].from, group.keys[selected].from + totalDistance, value);
                        }
                        else if (value < group.keys[selected].to)
                        {
                            group.keys[selected].center = DMath.InverseLerp(-fromToEndDistance, group.keys[selected].to, value);
                        }
                    }
                    else
                    {
                        group.keys[selected].center = DMath.InverseLerp(group.keys[selected].from, group.keys[selected].to, value);
                    }
                }
                value = group.keys[selected].from;
                SplineEditorHandles.Slider(user, ref value, user.rootUser.computer.editorPathColor, "Start", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle, 1f);
                if (group.keys[selected].from != value)
                {
                    group.keys[selected].from = value;
                    changed = true;
                }

                value = group.keys[selected].to;
                SplineEditorHandles.Slider(user, ref value, user.rootUser.computer.editorPathColor, "End", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle, 1f);
                if (group.keys[selected].to != value)
                {
                    group.keys[selected].to = value;
                    changed = true;
                }
            }
            return(changed);
        }
コード例 #4
0
        public bool DrawScene(SplineUser user)
        {
            bool         changed = false;
            SplineResult result  = new SplineResult();

            for (int i = 0; i < group.keys.Count; i++)
            {
                if (selected >= 0 && i != selected)
                {
                    continue;
                }
                user.Evaluate(result, group.keys[i].position);
                Quaternion directionRot = Quaternion.LookRotation(result.direction, result.normal);
                Quaternion rot          = directionRot * Quaternion.Euler(group.keys[i].rotation);
                SplineEditorHandles.DrawArrowCap(result.position, rot, HandleUtility.GetHandleSize(result.position));
            }
            if (selected >= 0 && selected < group.keys.Count)
            {
                double value = group.keys[selected].position;
                user.Evaluate(result, value);
                Quaternion directionRot = Quaternion.LookRotation(result.direction, result.normal);
                Quaternion rot          = directionRot * Quaternion.Euler(group.keys[selected].rotation);

                if (editRotation)
                {
                    rot = Handles.RotationHandle(rot, result.position);
                    rot = Quaternion.Inverse(directionRot) * rot;
                    if (rot.eulerAngles != group.keys[selected].rotation)
                    {
                        changed = true;
                    }
                    group.keys[selected].rotation = rot.eulerAngles;
                }
                else
                {
                    double lastValue = value;
                    SplineEditorHandles.Slider(user, ref value, user.rootUser.computer.editorPathColor, "Center", SplineEditorHandles.SplineSliderGizmo.Circle, 0.6f);
                    if (value != lastValue)
                    {
                        changed = true;
                    }
                    if (group.keys[selected].from > group.keys[selected].to)
                    {
                        double fromToEndDistance     = 1.0 - group.keys[selected].from;
                        double toToBeginningDistance = group.keys[selected].to;
                        double totalDistance         = fromToEndDistance + toToBeginningDistance;
                        if (value > group.keys[selected].from)
                        {
                            group.keys[selected].center = DMath.InverseLerp(group.keys[selected].from, group.keys[selected].from + totalDistance, value);
                        }
                        else if (value < group.keys[selected].to)
                        {
                            group.keys[selected].center = DMath.InverseLerp(-fromToEndDistance, group.keys[selected].to, value);
                        }
                    }
                    else
                    {
                        group.keys[selected].center = DMath.InverseLerp(group.keys[selected].from, group.keys[selected].to, value);
                    }
                }

                value = group.keys[selected].from;
                SplineEditorHandles.Slider(user, ref value, user.rootUser.computer.editorPathColor, "Start", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle, 1f);
                if (group.keys[selected].from != value)
                {
                    group.keys[selected].from = value;
                    changed = true;
                }

                value = group.keys[selected].to;
                SplineEditorHandles.Slider(user, ref value, user.rootUser.computer.editorPathColor, "End", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle, 1f);
                if (group.keys[selected].to != value)
                {
                    group.keys[selected].to = value;
                    changed = true;
                }
            }
            return(changed);
        }