Esempio n. 1
0
        public void DeleteByRadiusCommandRedo()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(2, 3, 4));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(3, 3, 3));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(4, 3, 2));
            Invoker.ExecuteCommand(command);

            ICommand deleteCommand = new DeleteControlPointsByRadiusCommand(this.LineSketchObject, new Vector3(3, 3.5f, 3), .6f);

            Invoker.ExecuteCommand(deleteCommand);
            Invoker.Undo();
            Invoker.Redo();

            Assert.AreEqual(2, this.LineSketchObject.getNumberOfControlPoints());
            Assert.AreEqual((2 + 2) * 7, this.LineSketchObject.GetComponent <MeshFilter>().sharedMesh.vertices.Length);

            LineSketchObject[] lines = GameObject.FindObjectsOfType <LineSketchObject>();
            Assert.AreEqual(2, lines.Length);
            foreach (LineSketchObject line in lines)
            {
                if (line != this.LineSketchObject)
                {
                    Assert.AreEqual(1, line.getNumberOfControlPoints());
                    Assert.AreEqual(new Vector3(4, 3, 2), line.GetControlPoints()[0]);
                }
            }
        }
        public void SetBrushOnStrokeSketchObjectRedo()
        {
            ICommand addCommand = new AddControlPointCommand(this.Stroke, new Vector3(0, 0, 0));

            Invoker.ExecuteCommand(addCommand);
            addCommand = new AddControlPointCommand(this.Stroke, new Vector3(1, 1, 1));
            Invoker.ExecuteCommand(addCommand);
            addCommand = new AddControlPointCommand(this.Stroke, new Vector3(2, 2, 0));
            Invoker.ExecuteCommand(addCommand);
            Assert.AreEqual((2 * 20 + 2) * 7, this.Stroke.GetComponent <MeshFilter>().sharedMesh.vertices.Length);

            StrokeBrush brush = this.Stroke.GetBrush() as StrokeBrush;

            brush.SketchMaterial.AlbedoColor = Color.green;
            brush.CrossSectionVertices.Add(Vector3.one);
            brush.CrossSectionNormals.Add(Vector3.one);
            ICommand SetBrushCommand = new SetBrushCommand(this.Stroke, brush);

            Invoker.ExecuteCommand(SetBrushCommand);
            Invoker.Undo();
            Invoker.Redo();

            Assert.AreEqual(Color.green, this.Stroke.GetComponent <MeshRenderer>().sharedMaterial.color);
            StrokeBrush updatedBrush = this.Stroke.GetBrush() as StrokeBrush;

            Assert.AreEqual(Color.green, updatedBrush.SketchMaterial.AlbedoColor);
            Assert.AreEqual((2 * 20 + 2) * 8, this.Stroke.GetComponent <MeshFilter>().sharedMesh.vertices.Length);
        }
Esempio n. 3
0
        public void AddOneControlPointToLineWithCommand()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);
            Assert.IsTrue(this.LineSketchObject.GetControlPoints()[0] == new Vector3(1, 2, 3));
        }
Esempio n. 4
0
        public void AddOneControlPointToLineWithCommandUndo()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);
            Invoker.Undo();

            Assert.AreEqual(this.LineSketchObject.getNumberOfControlPoints(), 0);
            Assert.IsTrue(SketchWorld.ActiveSketchWorld.IsObjectDeleted(this.LineSketchObject));
        }
Esempio n. 5
0
        public void AddOneControlPointToLineWithCommandRedo()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);
            Invoker.Undo();
            Invoker.Redo();

            Assert.IsTrue(this.LineSketchObject.GetControlPoints()[0] == new Vector3(1, 2, 3));
            Assert.IsFalse(SketchWorld.ActiveSketchWorld.IsObjectDeleted(this.LineSketchObject));
        }
        public void DeleteOneControlPointWithCommand()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.StrokeSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);

            DeleteControlPointCommand deleteCommand = new DeleteControlPointCommand(this.StrokeSketchObject);

            Invoker.ExecuteCommand(deleteCommand);
            Assert.AreEqual(this.StrokeSketchObject.getNumberOfControlPoints(), 0);
            Assert.IsTrue(SketchWorld.ActiveSketchWorld.IsObjectDeleted(this.StrokeSketchObject));
        }
Esempio n. 7
0
        public void AddMultipleControlPointsWithCommand()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(2, 3, 4));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(3, 3, 3));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(4, 3, 2));
            Invoker.ExecuteCommand(command);

            Assert.AreEqual(this.LineSketchObject.getNumberOfControlPoints(), 4);
            Assert.AreEqual((3 * 20 + 2) * 7, this.LineSketchObject.GetComponent <MeshFilter>().sharedMesh.vertices.Length);
        }
Esempio n. 8
0
        public void DeleteByRadiusCommand()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(2, 3, 4));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(3, 3, 3));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.LineSketchObject, new Vector3(4, 3, 2));
            Invoker.ExecuteCommand(command);

            ICommand deleteCommand = new DeleteControlPointsByRadiusCommand(this.LineSketchObject, new Vector3(3, 3.5f, 3), .6f);

            Invoker.ExecuteCommand(deleteCommand);

            Assert.AreEqual(2, this.LineSketchObject.getNumberOfControlPoints());
            Assert.AreEqual((2 + 2) * 7, this.LineSketchObject.GetComponent <MeshFilter>().sharedMesh.vertices.Length);
        }
        public void AddMultipleControlPointsAndDeleteOneWithCommandRedo()
        {
            AddControlPointCommand command = new AddControlPointCommand(this.StrokeSketchObject, new Vector3(1, 2, 3));

            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.StrokeSketchObject, new Vector3(2, 3, 4));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.StrokeSketchObject, new Vector3(3, 3, 3));
            Invoker.ExecuteCommand(command);

            command = new AddControlPointCommand(this.StrokeSketchObject, new Vector3(4, 3, 2));
            Invoker.ExecuteCommand(command);

            ICommand deleteCommand = new DeleteControlPointCommand(this.StrokeSketchObject);

            Invoker.ExecuteCommand(deleteCommand);
            Invoker.Undo();
            Invoker.Redo();

            Assert.AreEqual(this.StrokeSketchObject.getNumberOfControlPoints(), 3);
            Assert.AreEqual((2 * 20 + 2) * 7, this.StrokeSketchObject.GetComponent <MeshFilter>().sharedMesh.vertices.Length);
        }