コード例 #1
0
        public void RotationNoMove()
        {
            ISpline3DPlaneEditor spline = PrepareSpline();

            float3 a = new float3(10f, 5f, 0f);

            spline.AddControlPoint(a);
            TestHelpers.CheckFloat3(a, spline.GetControlPoint3DWorld(0));
            TestHelpers.CheckFloat2(a.xy, spline.GetControlPoint2DLocal(0));

            // rotate
            Quaternion targetRotation = Quaternion.Euler(0f, 90f, 0f);

            spline.Forward = targetRotation;
            float3 rotatedPoint = targetRotation * a;

            TestHelpers.CheckFloat3(rotatedPoint, spline.GetControlPoint3DWorld(0));
            TestHelpers.CheckFloat2(a.xy, spline.GetControlPoint2DLocal(0));

            // update the cp position along the axis parallel to the plain
            float3 perpendicularPlain = new float3(10f, 0f, 0f);
            float3 newWorldLocation   = new float3(0f, 5f, -10f);

            spline.UpdateControlPointWorld(0, newWorldLocation + perpendicularPlain, SplinePoint.Point);
            TestHelpers.CheckFloat3(newWorldLocation, spline.GetControlPoint3DWorld(0));
            TestHelpers.CheckFloat2(a.xy, spline.GetControlPoint2DLocal(0));

            // undo movement and check that the point is where we expect
            spline.Forward = Quaternion.identity;
            MoveGameobject(spline, new float3(0f));
            TestHelpers.CheckFloat3(a, spline.GetControlPoint3DWorld(0));
            TestHelpers.CheckFloat2(a.xy, spline.GetControlPoint2DLocal(0));
        }
コード例 #2
0
        public float3 GetControlPointWorldSpace(ISpline3DPlane spline, int index, SplinePoint pointType)
        {
            ISpline3DPlaneEditor spline3D = spline as ISpline3DPlaneEditor;

            Assert.NotNull(spline3D);

            return(spline3D.GetControlPoint3DWorld(index));
        }
コード例 #3
0
        public void ConversionMove()
        {
            ISpline3DPlaneEditor spline = PrepareSpline();

            float3 a = new float3(10f, 5f, 0f);

            spline.AddControlPoint(a);
            TestHelpers.CheckFloat3(a, spline.GetControlPoint3DLocal(0));
            TestHelpers.CheckFloat3(a, spline.GetControlPoint3DWorld(0));

            float3 origin = new float3(0f, 0f, 10f);

            MoveGameobject(spline, origin);
            TestHelpers.CheckFloat3(a, spline.GetControlPoint3DLocal(0));
            TestHelpers.CheckFloat3(a + origin, spline.GetControlPoint3DWorld(0));

            a = a + new float3(1f, 1f, 0f);
            float3 additionalTranslation = a + origin;

            spline.UpdateControlPointWorld(0, additionalTranslation, SplinePoint.Point);
            TestHelpers.CheckFloat3(additionalTranslation, spline.GetControlPoint3DWorld(0));
            TestHelpers.CheckFloat3(a, spline.GetControlPoint3DLocal(0));
            TestHelpers.CheckFloat2(additionalTranslation.xy, spline.GetControlPoint2DLocal(0));
        }