public void GetData_Rotation()
        {
            this.StrokeSketchObject.transform.rotation = Quaternion.Euler(0, 25, 0);
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            Assert.That(data.Rotation, Is.EqualTo(Quaternion.Euler(0, 25, 0)).Using(QuaternionEqualityComparer.Instance));
        }
        public void GetData_Scale()
        {
            this.StrokeSketchObject.transform.localScale = new Vector3(3, 3, 3);
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            Assert.AreEqual(new Vector3(3, 3, 3), data.Scale);
        }
        SerializableComponentData ISerializableComponent.GetData()
        {
            StrokeSketchObjectData data = base.GetData();

            data.Interpolation = StrokeSketchObjectData.InterpolationType.Linear;
            return(data);
        }
        public void GetData_Position()
        {
            this.StrokeSketchObject.transform.position = new Vector3(1, 2, 3);
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            Assert.AreEqual(new Vector3(1, 2, 3), data.Position);
        }
        public void ApplyData_Scale()
        {
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            data.Scale = new Vector3(1, 2, 3);
            this.SerializableSketchObject.ApplyData(data);
            Assert.AreEqual(new Vector3(1, 2, 3), this.StrokeSketchObject.gameObject.transform.localScale);
        }
        public void ApplyData_Rotation()
        {
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            data.Rotation = Quaternion.Euler(10, 20, 30);
            this.SerializableSketchObject.ApplyData(data);
            Assert.That(this.StrokeSketchObject.gameObject.transform.rotation, Is.EqualTo(Quaternion.Euler(10, 20, 30)).Using(QuaternionEqualityComparer.Instance));
        }
        public void ApplyData_Position()
        {
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            data.Position = new Vector3(2, 5, 8);
            this.SerializableSketchObject.ApplyData(data);
            Assert.AreEqual(new Vector3(2, 5, 8), this.StrokeSketchObject.gameObject.transform.position);
        }
        public void GetData_ControlPoints()
        {
            this.StrokeSketchObject.SetControlPointsLocalSpace(new List <Vector3> {
                new Vector3(1, 2, 3), new Vector3(3, 2, 1), new Vector3(1, 1, 1), new Vector3(2, 2, 2)
            });
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            Assert.AreEqual(new Vector3(3, 2, 1), data.ControlPoints[1]);
        }
        public void ApplyData_ControlPoints()
        {
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            data.ControlPoints = new List <Vector3> {
                new Vector3(1, 2, 3), new Vector3(3, 2, 1), new Vector3(1, 1, 1), new Vector3(2, 2, 2)
            };
            this.SerializableSketchObject.ApplyData(data);
            Assert.AreEqual(new Vector3(3, 2, 1), this.StrokeSketchObject.GetControlPoints()[1]);
            Assert.AreEqual((3 * 20 + 2) * 7, this.StrokeSketchObject.gameObject.GetComponent <MeshFilter>().sharedMesh.vertexCount);
        }
        private void ApplyData(StrokeSketchObjectData data)
        {
            this.transform.position = Vector3.zero;
            this.transform.rotation = Quaternion.identity;
            this.SetInterpolationSteps(data.InterpolationSteps);
            this.SetStrokeCrossSection(data.CrossSectionVertices, data.CrossSectionNormals, data.CrossSectionScale);
            this.SetControlPointsLocalSpace(data.ControlPoints);
            data.ApplyDataToTransform(this.transform);

            this.SetMaterial(Defaults.GetMaterialFromDictionary(data.SketchMaterial));
        }
        public void GetData_CrossSection()
        {
            List <Vector3> crossSection = new List <Vector3> {
                new Vector3(0, 0, 1), new Vector3(.5f, 0, 0), new Vector3(-.5f, 0, 0)
            };

            this.StrokeSketchObject.SetStrokeCrossSection(crossSection, crossSection, .3f);
            StrokeSketchObjectData data = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;

            Assert.AreEqual(new Vector3(.5f, 0, 0), data.CrossSectionVertices[1]);
            Assert.AreEqual(new Vector3(0, 0, 1), data.CrossSectionVertices[0]);
            Assert.AreEqual(.3f, data.CrossSectionScale);
        }
        public void ApplyData_CrossSection()
        {
            StrokeSketchObjectData data         = this.SerializableSketchObject.GetData() as StrokeSketchObjectData;
            List <Vector3>         crossSection = new List <Vector3> {
                new Vector3(0, 0, 1), new Vector3(.5f, 0, 0), new Vector3(-.5f, 0, 0)
            };

            data.ControlPoints = new List <Vector3> {
                new Vector3(1, 2, 3), new Vector3(3, 2, 1), new Vector3(1, 1, 1), new Vector3(2, 2, 2)
            };
            data.CrossSectionVertices = crossSection;
            data.CrossSectionNormals  = crossSection;
            data.CrossSectionScale    = 3.0f;
            this.SerializableSketchObject.ApplyData(data);
            Assert.AreEqual(new Vector3(3, 2, 1), this.StrokeSketchObject.GetControlPoints()[1]);
            Assert.AreEqual((3 * 20 + 2) * 3, this.StrokeSketchObject.gameObject.GetComponent <MeshFilter>().sharedMesh.vertexCount);
        }
        protected StrokeSketchObjectData GetData()
        {
            StrokeSketchObjectData data = new StrokeSketchObjectData
            {
                Interpolation      = StrokeSketchObjectData.InterpolationType.Cubic,
                ControlPoints      = GetControlPoints(),
                CrossSectionScale  = this.lineDiameter,
                InterpolationSteps = this.InterpolationSteps
            };

            data.SetDataFromTransform(this.transform);

            SplineMesh.GetCrossSectionShape(out data.CrossSectionVertices, out data.CrossSectionNormals);

            data.SketchMaterial = new SketchMaterialData(this.meshRenderer.sharedMaterial);

            return(data);
        }