public void CrtMeshBuilderFunctions_GenerateApproximateSphereAtUnitRadius_TestSimple90DegreeAzimuthAndInclination() { //Covers the centre one quarter of one side of a sphere ICrtMeshBuilderFunctions functions = new CrtMeshBuilderFunctions(); var verts = functions.GenerateSphereSurfacePatchAtUnitRadiusWithExtraVertexOverhangForNormalCalculation(1.0f, 3, 0.25f * (float)Math.PI, 0.25f * (float)Math.PI, 0.0f); var ort = 0.70710678118f; // 1/sqrt(2) var centre = verts[12]; var cpos = centre.Position; var ctex = centre.TexCoord; Assert.Equal(1.0f, cpos.Z, 3); Assert.Equal(0.0f, cpos.X, 3); Assert.Equal(0.0f, cpos.Y, 3); Assert.Equal(0.5f, ctex.X, 3); Assert.Equal(0.5f, ctex.Y, 3); var topleft = verts[6]; var tpos = topleft.Position; var ttex = topleft.TexCoord; Assert.Equal(0.5f, tpos.Z, 3); Assert.Equal(-0.5f, tpos.X, 3); Assert.Equal(ort, tpos.Y, 3); Assert.Equal(0.0f, ttex.X, 3); Assert.Equal(0.0f, ttex.Y, 3); var bottomright = verts[18]; var bpos = bottomright.Position; var btex = bottomright.TexCoord; Assert.Equal(0.5f, bpos.Z, 3); Assert.Equal(0.5f, bpos.X, 3); Assert.Equal(-ort, bpos.Y, 3); Assert.Equal(1.0f, btex.X, 3); Assert.Equal(1.0f, btex.Y, 3); }
public void CrtMeshBuilderFunctions_GenerateApproximateSphereAtUnitRadius_TestSimple180DegreeAzimuthAndInclination() { //Basically creates have a sphere covered, so top and bottom verts are all at the poles ICrtMeshBuilderFunctions functions = new CrtMeshBuilderFunctions(); var verts = functions.GenerateSphereSurfacePatchAtUnitRadiusWithExtraVertexOverhangForNormalCalculation(1.0f, 3, 0.5f * (float)Math.PI, 0.5f * (float)Math.PI, 0.0f); var centre = verts[12]; var cpos = centre.Position; var ctex = centre.TexCoord; Assert.Equal(1.0f, cpos.Z, 3); Assert.Equal(0.0f, cpos.X, 3); Assert.Equal(0.0f, cpos.Y, 3); Assert.Equal(0.5f, ctex.X, 3); Assert.Equal(0.5f, ctex.Y, 3); var topleft = verts[6]; var tpos = topleft.Position; var ttex = topleft.TexCoord; Assert.Equal(0.0f, tpos.Z, 3); Assert.Equal(0.0f, tpos.X, 3); Assert.Equal(1.0f, tpos.Y, 3); Assert.Equal(0.0f, ttex.X, 3); Assert.Equal(0.0f, ttex.Y, 3); var bottomright = verts[18]; var bpos = bottomright.Position; var btex = bottomright.TexCoord; Assert.Equal(0.0f, bpos.Z, 3); Assert.Equal(0.0f, bpos.X, 3); Assert.Equal(-1.0f, bpos.Y, 3); Assert.Equal(1.0f, btex.X, 3); Assert.Equal(1.0f, btex.Y, 3); }
public void CrtMeshBuilderFunctions_GenerateApproximateSphereAtUnitRadius_TestSimpleCornerRounding() { //Covers the centre one quarter of one side of a sphere ICrtMeshBuilderFunctions functions = new CrtMeshBuilderFunctions(); var verts = functions.GenerateSphereSurfacePatchAtUnitRadiusWithExtraVertexOverhangForNormalCalculation(1.0f, 4, 0.25f * (float)Math.PI, 0.25f * (float)Math.PI, 1.0f); /* * * 0 1 2 3 * 4 5 6 7 * 8 9 10 11 * 12 13 14 15 * * 4 and 11 should be half way along corner radii * */ var ort = 0.70710678118f; // 1/sqrt(2) var topleft = verts[8]; var tpos = topleft.Position; var ttex = topleft.TexCoord; Assert.Equal(ort, tpos.Z, 3); Assert.Equal(0.0f, tpos.X, 3); Assert.Equal(0.707106f, tpos.Y, 3); Assert.Equal(0.5f, ttex.X, 3); Assert.Equal(0.0f, ttex.Y, 3); var bottomright = verts[28]; var bpos = bottomright.Position; var btex = bottomright.TexCoord; Assert.Equal(ort, bpos.Z, 3); Assert.Equal(0.0f, bpos.X, 3); Assert.Equal(-0.707106f, bpos.Y, 3); Assert.Equal(0.5f, btex.X, 3); Assert.Equal(1.0f, btex.Y, 3); var leftthird = verts[13]; var lpos = leftthird.Position; var ltex = leftthird.TexCoord; Assert.Equal(0.712992f, lpos.Z, 3); Assert.Equal(-0.651654f, lpos.X, 3); Assert.Equal(0.25881f, lpos.Y, 3); Assert.Equal(0.0285954f, ltex.X, 3); Assert.Equal(0.333f, ltex.Y, 3); var rightlastthird = verts[22]; var rpos = rightlastthird.Position; var rtex = rightlastthird.TexCoord; Assert.Equal(0.712992f, rpos.Z, 3); Assert.Equal(0.651654f, rpos.X, 3); Assert.Equal(-0.25881f, rpos.Y, 3); Assert.Equal(0.97140f, rtex.X, 3); Assert.Equal(0.6666f, rtex.Y, 3); }