Пример #1
0
        public void FreeFormBody_Sequence_Valid()
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            curve.SequenceCurves.Add(new ObjCurveIndex(4.0f, 5.0f, 2));
            curve.SequenceCurves.Add(new ObjCurveIndex(6.0f, 7.0f, 3));

            string text     = WriteObj(obj);
            string expected =
                @"cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
scrv 4.000000 5.000000 2 6.000000 7.000000 3
end
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #2
0
        public void RenderAttributes_ApproximationTechnique_Null_Valid()
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            curve.CurveApproximationTechnique   = null;
            curve.SurfaceApproximationTechnique = null;

            string text     = WriteObj(obj);
            string expected =
                @"cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #3
0
        public void FreeFormBody_Parameter_Valid(string value, int type)
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            IList <float> parameters = type == 0 ? obj.Curves[0].ParametersU : obj.Curves[0].ParametersV;

            parameters.Add(2.0f);
            parameters.Add(3.0f);
            parameters.Add(4.0f);

            string text     = WriteObj(obj);
            string expected =
                @"cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
parm " + value + @" 2.000000 3.000000 4.000000
end
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #4
0
        public void FreeFormAttributes_Step_Valid(string value, float u, float v)
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            curve.StepU = u;
            curve.StepV = v;

            string text     = WriteObj(obj);
            string expected =
                @"cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step " + value + @"
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #5
0
        public void FreeFormAttributes_BasisMatrix_Valid()
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            curve.BasicMatrixU = new float[] { 2, 3, 4, 5 };
            curve.BasicMatrixV = new float[] { 6, 7, 8, 9 };

            string text     = WriteObj(obj);
            string expected =
                @"cstype rat bmatrix
deg 1 1
bmat u 2.000000 3.000000 4.000000 5.000000
bmat v 6.000000 7.000000 8.000000 9.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #6
0
        public void FreeFormAttributes_Type_Valid(string value, bool rational, ObjFreeFormType type)
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            curve.FreeFormType   = type;
            curve.IsRationalForm = rational;

            string text     = WriteObj(obj);
            string expected =
                @"cstype " + value + @"
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #7
0
        public void FreeFormAttributes_UnknownType_Valid()
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            curve.FreeFormType   = ObjFreeFormType.Taylor + 1;
            curve.IsRationalForm = false;

            string text     = WriteObj(obj);
            string expected =
                @"deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #8
0
        public static void Element_Curve_Valid()
        {
            var obj = new ObjFile();

            obj.Groups.Add(new ObjGroup("b"));
            obj.Vertices.Add(new ObjVertex(0, 0, 0));
            obj.Vertices.Add(new ObjVertex(0, 0, 0));
            obj.Vertices.Add(new ObjVertex(0, 0, 0));
            obj.Vertices.Add(new ObjVertex(0, 0, 0));
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            obj.Groups[0].Curves.Add(curve);
            curve.ObjectName                = "a";
            curve.LevelOfDetail             = 2;
            curve.MapName                   = "c";
            curve.MaterialName              = "d";
            curve.MergingGroupNumber        = 10;
            obj.MergingGroupResolutions[10] = 1.0f;
            FillFreeFormAttributes(curve);

            string text     = WriteObj(obj);
            string expected =
                @"v 0.000000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 0.000000 0.000000
g b
o a
lod 2
usemap c
usemtl d
mg 10 1.000000
cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #9
0
        public void MergingGroup_Valid()
        {
            var obj    = new ObjFile();
            var curve1 = new ObjCurve();

            curve1.StartParameter = 5.0f;
            curve1.EndParameter   = 6.0f;
            curve1.Vertices.Add(2);
            curve1.Vertices.Add(3);
            curve1.Vertices.Add(4);
            obj.Curves.Add(curve1);
            curve1.MergingGroupNumber       = 10;
            obj.MergingGroupResolutions[10] = 1.0f;
            FillFreeFormAttributes(curve1);
            var curve2 = new ObjCurve();

            curve2.StartParameter = 5.0f;
            curve2.EndParameter   = 6.0f;
            curve2.Vertices.Add(2);
            curve2.Vertices.Add(3);
            curve2.Vertices.Add(4);
            obj.Curves.Add(curve2);
            curve2.MergingGroupNumber = 0;
            FillFreeFormAttributes(curve2);

            string text     = WriteObj(obj);
            string expected =
                @"mg 10 1.000000
cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
mg off
cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
ctech cparm 1.000000
stech cparma 1.000000 2.000000
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }
Пример #10
0
        public void RenderAttributes_ApproximationTechnique_Curvature_Valid(string value1, string value2, float distance, float angle, int type)
        {
            var obj   = new ObjFile();
            var curve = new ObjCurve();

            curve.StartParameter = 5.0f;
            curve.EndParameter   = 6.0f;
            curve.Vertices.Add(2);
            curve.Vertices.Add(3);
            curve.Vertices.Add(4);
            obj.Curves.Add(curve);
            FillFreeFormAttributes(curve);

            var technique = new ObjCurvatureDependentSubdivisionTechnique(distance, angle);

            switch (type)
            {
            case 0:
                curve.CurveApproximationTechnique = technique;
                break;

            case 1:
                curve.SurfaceApproximationTechnique = technique;
                break;
            }

            string text     = WriteObj(obj);
            string expected =
                @"cstype rat bmatrix
deg 1 1
bmat u 0.000000 0.000000 0.000000 0.000000
bmat v 0.000000 0.000000 0.000000 0.000000
step 0.500000 0.500000
" + value1 + @"
" + value2 + @"
curv 5.000000 6.000000 2 3 4
";

            AssertExtensions.TextEqual(expected, text);
        }