コード例 #1
0
ファイル: ImportTool.cs プロジェクト: saint-angels/ToadRunner
 void OnScene(SceneView current)
 {
     for (int i = 0; i < imported.Count; i++)
     {
         SplineDrawer.DrawSplineComputer(imported[i]);
     }
 }
コード例 #2
0
 public override void DrawScene()
 {
     base.DrawScene();
     if (drawComputer)
     {
         for (int i = 0; i < splines.Length; i++)
         {
             SplineDrawer.DrawSplineComputer(splines[i]);
         }
     }
     if (drawConnectedComputers)
     {
         for (int i = 0; i < splines.Length; i++)
         {
             List <SplineComputer> computers = splines[i].GetConnectedComputers();
             for (int j = 1; j < computers.Count; j++)
             {
                 SplineDrawer.DrawSplineComputer(computers[j], 0.0, 1.0, 0.5f);
             }
         }
     }
     if (module >= 0 && module < modules.Length)
     {
         modules[module].DrawScene();
     }
 }
コード例 #3
0
        public override void DrawScene()
        {
            base.DrawScene();
            if (spline.isClosed)
            {
                return;
            }
            Camera editorCamera = SceneView.currentDrawingSceneView.camera;

            for (int i = 0; i < availableMergeComputers.Length; i++)
            {
                SplineDrawer.DrawSplineComputer(availableMergeComputers[i]);
                SplinePoint startPoint = availableMergeComputers[i].GetPoint(0);
                SplinePoint endPoint   = availableMergeComputers[i].GetPoint(availableMergeComputers[i].pointCount - 1);
                Handles.color = availableMergeComputers[i].editorPathColor;

                if (SplineEditorHandles.CircleButton(startPoint.position, Quaternion.LookRotation(editorCamera.transform.position - startPoint.position), HandleUtility.GetHandleSize(startPoint.position) * 0.15f, 1f, availableMergeComputers[i].editorPathColor))
                {
                    Merge(i, MergeSide.Start);
                    break;
                }
                if (SplineEditorHandles.CircleButton(endPoint.position, Quaternion.LookRotation(editorCamera.transform.position - endPoint.position), HandleUtility.GetHandleSize(endPoint.position) * 0.15f, 1f, availableMergeComputers[i].editorPathColor))
                {
                    Merge(i, MergeSide.End);
                    break;
                }
            }
            Handles.color = Color.white;
        }
コード例 #4
0
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();
            SurfaceGenerator user = (SurfaceGenerator)target;

            if (user.extrudeSpline != null)
            {
                SplineDrawer.DrawSplineComputer(user.extrudeSpline, 0.0, 1.0, 0.5f);
            }
        }
コード例 #5
0
 void OnScene(SceneView current)
 {
     for (int i = 0; i < collections.Count; i++)
     {
         if (collections[i].spline != null)
         {
             SplineDrawer.DrawSplineComputer(collections[i].spline);
         }
     }
 }
コード例 #6
0
 void OnScene(SceneView current)
 {
     if (selected.Count > 1)
     {
         for (int i = 0; i < selected.Count; i++)
         {
             if (!sceneSplines[selected[i]].alwaysDraw)
             {
                 SplineDrawer.DrawSplineComputer(sceneSplines[selected[i]]);
             }
         }
     }
 }
コード例 #7
0
        protected virtual void OnSceneGUI()
        {
            if (doRebuild)
            {
                DoRebuild();
            }
            SplineUser user = (SplineUser)target;

            if (user == null)
            {
                return;
            }
            if (user.spline != null)
            {
                SplineComputer        rootComputer = user.GetComponent <SplineComputer>();
                List <SplineComputer> allComputers = user.spline.GetConnectedComputers();
                for (int i = 0; i < allComputers.Count; i++)
                {
                    if (allComputers[i] == rootComputer && _editIndex == -1)
                    {
                        continue;
                    }
                    if (allComputers[i].alwaysDraw)
                    {
                        continue;
                    }
                    SplineDrawer.DrawSplineComputer(allComputers[i], 0.0, 1.0, 0.4f);
                }
                SplineDrawer.DrawSplineComputer(user.spline);
            }
            if (_editIndex == 0)
            {
                SceneClipEdit();
            }
            if (offsetModifierEditor != null)
            {
                offsetModifierEditor.DrawScene();
            }
            if (rotationModifierEditor != null)
            {
                rotationModifierEditor.DrawScene();
            }
            if (colorModifierEditor != null)
            {
                colorModifierEditor.DrawScene();
            }
            if (sizeModifierEditor != null)
            {
                sizeModifierEditor.DrawScene();
            }
        }
コード例 #8
0
        public override void DrawScene()
        {
            bool   change       = false;
            Camera editorCamera = SceneView.currentDrawingSceneView.camera;

            for (int i = 0; i < spline.pointCount; i++)
            {
                Vector3 pos = spline.GetPointPosition(i);
                if (SplineEditorHandles.CircleButton(pos, Quaternion.LookRotation(editorCamera.transform.position - pos), HandleUtility.GetHandleSize(pos) * 0.12f, 1f, spline.editorPathColor))
                {
                    SplitAtPoint(i);
                    change = true;
                    break;
                }
            }
            SplineSample projected = spline.Evaluate(ProjectMouse());

            if (!change)
            {
                float   pointValue = (float)projected.percent * (spline.pointCount - 1);
                int     pointIndex = Mathf.FloorToInt(pointValue);
                float   size       = HandleUtility.GetHandleSize(projected.position) * 0.3f;
                Vector3 up         = Vector3.Cross(editorCamera.transform.forward, projected.forward).normalized *size + projected.position;
                Vector3 down       = Vector3.Cross(projected.forward, editorCamera.transform.forward).normalized *size + projected.position;
                Handles.color = spline.editorPathColor;
                Handles.DrawLine(up, down);
                Handles.color = Color.white;
                if (pointValue - pointIndex > spline.moveStep)
                {
                    if (SplineEditorHandles.CircleButton(projected.position, Quaternion.LookRotation(editorCamera.transform.position - projected.position), HandleUtility.GetHandleSize(projected.position) * 0.12f, 1f, spline.editorPathColor))
                    {
                        SplitAtPercent(projected.percent);
                        change = true;
                    }
                }
                SceneView.RepaintAll();
            }
            Handles.color = Color.white;
            SplineDrawer.DrawSplineComputer(spline, 0.0, projected.percent, 1f);
            SplineDrawer.DrawSplineComputer(spline, projected.percent, 1.0, 0.4f);
        }
コード例 #9
0
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();
            ObjectBender bender = (ObjectBender)target;

            if (selected.Count > 0)
            {
                Handles.BeginGUI();
                for (int i = 0; i < selected.Count; i++)
                {
                    Vector2 screenPosition = HandleUtility.WorldToGUIPoint(bender.bendProperties[selected[i]].transform.transform.position);
                    DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + bender.bendProperties[selected[i]].transform.transform.name.Length * 4, screenPosition.y, 120, 25), bender.bendProperties[selected[i]].transform.transform.name);
                }
                Handles.EndGUI();
            }
            for (int i = 0; i < bender.bendProperties.Length; i++)
            {
                if (bender.bendProperties[i].bendSpline && bender.bendProperties[i].splineComputer != null)
                {
                    SplineDrawer.DrawSplineComputer(bender.bendProperties[i].splineComputer, 0.0, 1.0, 0.2f);
                }
            }

            //Draw bounds
            if (bender.bend)
            {
                return;
            }
            TS_Bounds bound = bender.GetBounds();
            Vector3   a     = bender.transform.TransformPoint(bound.min);
            Vector3   b     = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.min.z));
            Vector3   c     = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.max.z));
            Vector3   d     = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.min.y, bound.max.z));

            Vector3 e = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.min.z));
            Vector3 f = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.min.z));
            Vector3 g = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.max.z));
            Vector3 h = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.max.z));

            Handles.color = Color.gray;
            Handles.DrawLine(a, b);
            Handles.DrawLine(b, c);
            Handles.DrawLine(c, d);
            Handles.DrawLine(d, a);

            Handles.DrawLine(e, f);
            Handles.DrawLine(f, g);
            Handles.DrawLine(g, h);
            Handles.DrawLine(h, e);

            Handles.DrawLine(a, e);
            Handles.DrawLine(b, f);
            Handles.DrawLine(c, g);
            Handles.DrawLine(d, h);

            Vector3 r  = bender.transform.right;
            Vector3 fr = bender.transform.forward;

            switch (bender.axis)
            {
            case ObjectBender.Axis.Z: Handles.color = Color.blue; Handles.DrawLine(r + b, r + c);  break;

            case ObjectBender.Axis.X: Handles.color = Color.red; Handles.DrawLine(b - fr, a - fr); break;

            case ObjectBender.Axis.Y: Handles.color = Color.green; Handles.DrawLine(b - fr + r, f - fr + r); break;
            }
        }
コード例 #10
0
        public override void DrawScene()
        {
            base.DrawScene();
            if (drawComputer)
            {
                for (int i = 0; i < splines.Length; i++)
                {
                    SplineDrawer.DrawSplineComputer(splines[i]);
                }
            }
            if (drawConnectedComputers)
            {
                for (int i = 0; i < splines.Length; i++)
                {
                    List <SplineComputer> computers = splines[i].GetConnectedComputers();
                    for (int j = 1; j < computers.Count; j++)
                    {
                        SplineDrawer.DrawSplineComputer(computers[j], 0.0, 1.0, 0.5f);
                    }
                }
            }



            if (pathEditor.currentModule == null)
            {
                switch (transformTool)
                {
                case 1:
                    for (int i = 0; i < splines.Length; i++)
                    {
                        Vector3 position = splines[i].transform.position;
                        position = Handles.PositionHandle(position, splines[i].transform.rotation);
                        if (position != splines[i].transform.position)
                        {
                            RecordUndo("Move spline computer");
                            Undo.RecordObject(splines[i].transform, "Move spline computer");
                            splines[i].transform.position = position;
                            splines[i].SetPoints(pathEditor.points);
                            pathEditor.Refresh();
                        }
                    }
                    break;

                case 2:
                    for (int i = 0; i < splines.Length; i++)
                    {
                        Quaternion rotation = splines[i].transform.rotation;
                        rotation = Handles.RotationHandle(rotation, splines[i].transform.position);
                        if (rotation != splines[i].transform.rotation)
                        {
                            RecordUndo("Rotate spline computer");
                            Undo.RecordObject(splines[i].transform, "Rotate spline computer");
                            splines[i].transform.rotation = rotation;
                            splines[i].SetPoints(pathEditor.points);
                            pathEditor.Refresh();
                        }
                    }
                    break;

                case 3:
                    for (int i = 0; i < splines.Length; i++)
                    {
                        Vector3 scale = splines[i].transform.localScale;
                        scale = Handles.ScaleHandle(scale, splines[i].transform.position, splines[i].transform.rotation,
                                                    HandleUtility.GetHandleSize(splines[i].transform.position));
                        if (scale != splines[i].transform.localScale)
                        {
                            RecordUndo("Scale spline computer");
                            Undo.RecordObject(splines[i].transform, "Scale spline computer");
                            splines[i].transform.localScale = scale;
                            splines[i].SetPoints(pathEditor.points);
                            pathEditor.Refresh();
                        }
                    }
                    break;
                }
                if (transformTool > 0)
                {
                    for (int i = 0; i < splines.Length; i++)
                    {
                        Vector2 screenPosition = HandleUtility.WorldToGUIPoint(splines[i].transform.position);
                        screenPosition.y += 20f;
                        Handles.BeginGUI();
                        DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + splines[i].name.Length * 4, screenPosition.y, 120, 25), splines[i].name);
                        Handles.EndGUI();
                    }
                }
            }
            if (module >= 0 && module < modules.Length)
            {
                modules[module].DrawScene();
            }
        }
コード例 #11
0
        protected virtual void OnSceneGUI()
        {
            Node node = (Node)target;

            Node.Connection[] connections = node.GetConnections();
#if DREAMTECK_SPLINES
            for (int i = 0; i < connections.Length; i++)
            {
                SplineDrawer.DrawSplineComputer(connections[i].spline, 0.0, 1.0, 0.5f);
            }
#endif
            bool update = false;
            if (position != node.transform.position)
            {
                position = node.transform.position;
                update   = true;
            }
            if (scale != node.transform.localScale)
            {
                scale  = node.transform.localScale;
                update = true;
            }
            if (rotation != node.transform.rotation)
            {
                rotation = node.transform.rotation;
                update   = true;
            }
            if (update)
            {
                node.UpdateConnectedComputers();
            }

            if (addComp == null)
            {
                if (connections.Length > 0)
                {
                    bool bezier = false;
                    for (int i = 0; i < connections.Length; i++)
                    {
                        if (connections[i].spline == null)
                        {
                            continue;
                        }
                        if (connections[i].spline.type == Spline.Type.Bezier)
                        {
                            bezier = true;
                            continue;
                        }
                    }
                    if (bezier && node.type == Node.Type.Smooth)
                    {
                        if (connections[0].spline != null)
                        {
                            SplinePoint point = node.GetPoint(0, true);
                            Handles.DrawDottedLine(node.transform.position, point.tangent, 6f);
                            Handles.DrawDottedLine(node.transform.position, point.tangent2, 6f);
                            Vector3 lastPos  = point.tangent;
                            bool    setPoint = false;
                            point.SetTangentPosition(Handles.PositionHandle(point.tangent, node.transform.rotation));
                            if (lastPos != point.tangent)
                            {
                                setPoint = true;
                            }
                            lastPos = point.tangent2;
                            point.SetTangent2Position(Handles.PositionHandle(point.tangent2, node.transform.rotation));
                            if (lastPos != point.tangent2)
                            {
                                setPoint = true;
                            }

                            if (setPoint)
                            {
                                node.SetPoint(0, point, true);
                                node.UpdateConnectedComputers();
                            }
                        }
                    }
                }
                return;
            }
            SplinePoint[] points       = addComp.GetPoints();
            Transform     camTransform = SceneView.currentDrawingSceneView.camera.transform;
#if DREAMTECK_SPLINES
            SplineDrawer.DrawSplineComputer(addComp, 0.0, 1.0, 0.5f);
#endif
            TextAnchor originalAlignment = GUI.skin.label.alignment;
            Color      originalColor     = GUI.skin.label.normal.textColor;

            GUI.skin.label.alignment        = TextAnchor.MiddleCenter;
            GUI.skin.label.normal.textColor = addComp.editorPathColor;
            for (int i = 0; i < availablePoints.Length; i++)
            {
                if (addComp.isClosed && i == points.Length - 1)
                {
                    break;
                }

                Handles.Label(points[i].position + Camera.current.transform.up * HandleUtility.GetHandleSize(points[i].position) * 0.3f, (i + 1).ToString());
                if (SplineEditorHandles.CircleButton(points[availablePoints[i]].position, Quaternion.LookRotation(-camTransform.forward, camTransform.up), HandleUtility.GetHandleSize(points[availablePoints[i]].position) * 0.1f, 2f, addComp.editorPathColor))
                {
                    AddConnection(addComp, availablePoints[i]);
                    break;
                }
            }
            GUI.skin.label.alignment        = originalAlignment;
            GUI.skin.label.normal.textColor = originalColor;
        }