Esempio n. 1
0
        public static Mesh CreateTetrahedron(double scale = 1)
        {
            Mesh    tetrahedron = new Mesh();
            Vector2 basePoint   = new Vector2(1, 0);
            double  baseOffsetZ = -Math.Sin(MathHelper.DegreesToRadians(30));

            tetrahedron.Vertices.Add(new Vector3(basePoint, baseOffsetZ));
            tetrahedron.Vertices.Add(new Vector3(Vector2.Rotate(basePoint, MathHelper.Tau / 3), baseOffsetZ));
            tetrahedron.Vertices.Add(new Vector3(Vector2.Rotate(basePoint, 2 * MathHelper.Tau / 3), baseOffsetZ));
            tetrahedron.Vertices.Add(new Vector3(0, 0, 1));

            tetrahedron.Faces.Add(0, 2, 1, tetrahedron.Vertices);             // add reversed because we want to see the bottom.
            tetrahedron.Faces.Add(0, 1, 3, tetrahedron.Vertices);
            tetrahedron.Faces.Add(1, 2, 3, tetrahedron.Vertices);
            tetrahedron.Faces.Add(2, 0, 3, tetrahedron.Vertices);

            if (scale != 1)
            {
                tetrahedron.Transform(Matrix4X4.CreateScale(scale));
            }

            return(tetrahedron);
        }
Esempio n. 2
0
		public static Mesh CreateTetrahedron(double scale = 1)
		{
			Mesh tetrahedron = new Mesh();
			Vector2 basePoint = new Vector2(1, 0);
			double baseOffsetZ = -Math.Sin(MathHelper.DegreesToRadians(30));
			Vertex[] verts = new Vertex[4];
			verts[0] = tetrahedron.CreateVertex(new Vector3(basePoint, baseOffsetZ));
			verts[1] = tetrahedron.CreateVertex(new Vector3(Vector2.Rotate(basePoint, MathHelper.Tau / 3), baseOffsetZ));
			verts[2] = tetrahedron.CreateVertex(new Vector3(Vector2.Rotate(basePoint, 2 * MathHelper.Tau / 3), baseOffsetZ));
			verts[3] = tetrahedron.CreateVertex(new Vector3(0, 0, 1));

			tetrahedron.CreateFace(new Vertex[] { verts[0], verts[2], verts[1] }); // add reversed because we want to see the bottom.
			tetrahedron.CreateFace(new Vertex[] { verts[0], verts[1], verts[3] });
			tetrahedron.CreateFace(new Vertex[] { verts[1], verts[2], verts[3] });
			tetrahedron.CreateFace(new Vertex[] { verts[2], verts[0], verts[3] });

			if(scale != 1)
			{
				tetrahedron.Transform(Matrix4X4.CreateScale(scale));
            }

			return tetrahedron;
		}
Esempio n. 3
0
        public static Mesh CreateTetrahedron(double scale = 1)
        {
            Mesh    tetrahedron = new Mesh();
            Vector2 basePoint   = new Vector2(1, 0);
            double  baseOffsetZ = -Math.Sin(MathHelper.DegreesToRadians(30));

            Vertex[] verts = new Vertex[4];
            verts[0] = tetrahedron.CreateVertex(new Vector3(basePoint, baseOffsetZ));
            verts[1] = tetrahedron.CreateVertex(new Vector3(Vector2.Rotate(basePoint, MathHelper.Tau / 3), baseOffsetZ));
            verts[2] = tetrahedron.CreateVertex(new Vector3(Vector2.Rotate(basePoint, 2 * MathHelper.Tau / 3), baseOffsetZ));
            verts[3] = tetrahedron.CreateVertex(new Vector3(0, 0, 1));

            tetrahedron.CreateFace(new Vertex[] { verts[0], verts[2], verts[1] });             // add reversed because we want to see the bottom.
            tetrahedron.CreateFace(new Vertex[] { verts[0], verts[1], verts[3] });
            tetrahedron.CreateFace(new Vertex[] { verts[1], verts[2], verts[3] });
            tetrahedron.CreateFace(new Vertex[] { verts[2], verts[0], verts[3] });

            if (scale != 1)
            {
                tetrahedron.Transform(Matrix4X4.CreateScale(scale));
            }

            return(tetrahedron);
        }
Esempio n. 4
0
		public static Mesh CreateIcosahedron(double scale = 1)
		{
			Mesh icosahedron = new Mesh();
			double[] icosahedronVertices =
            {
                0, -0.525731, 0.850651,
                0.850651, 0, 0.525731,
                0.850651, 0, -0.525731,
                -0.850651, 0, -0.525731,
                -0.850651, 0, 0.525731,
                -0.525731, 0.850651, 0,
                0.525731, 0.850651, 0,
                0.525731, -0.850651, 0,
                -0.525731, -0.850651, 0,
                0, -0.525731, -0.850651,
                0, 0.525731, -0.850651,
                0, 0.525731, 0.850651
            };

			int[] icosahedronIndicies =
            {
                1, 2, 6,
                1, 7, 2,
                3, 4, 5,
                4, 3, 8,
                6, 5, 11,
                5, 6, 10,
                9, 10, 2,
                10, 9, 3,
                7, 8, 9,
                8, 7, 0,
                11, 0, 1,
                0, 11, 4,
                6, 2, 10,
                1, 6, 11,
                3, 5, 10,
                5, 4, 11,
                2, 7, 9,
                7, 1, 0,
                3, 9, 8,
                4, 8, 0,
            };

			Vertex[] verts = new Vertex[icosahedronVertices.Length / 3];
			for (int i = 0; i < icosahedronVertices.Length / 3; i++)
			{
				verts[i] = icosahedron.CreateVertex(new Vector3(icosahedronVertices[i * 3 + 0], icosahedronVertices[i * 3 + 1], icosahedronVertices[i * 3 + 2]));
			}

			for (int i = 0; i < icosahedronIndicies.Length / 3; i++)
			{
				Vertex[] triangleVertices = new Vertex[]
                {
                    verts[icosahedronIndicies[i * 3 + 0]],
                    verts[icosahedronIndicies[i * 3 + 1]],
                    verts[icosahedronIndicies[i * 3 + 2]],
                };
				icosahedron.CreateFace(triangleVertices);
			}

			icosahedron.Transform(Matrix4X4.CreateScale(scale));

			return icosahedron;
		}
Esempio n. 5
0
        public static Mesh CreateIcosahedron(double scale = 1)
        {
            Mesh icosahedron = new Mesh();

            double[] icosahedronVertices =
            {
                0,         -0.525731,  0.850651,
                0.850651,          0,  0.525731,
                0.850651,          0, -0.525731,
                -0.850651,         0, -0.525731,
                -0.850651,         0,  0.525731,
                -0.525731,  0.850651,         0,
                0.525731,   0.850651,         0,
                0.525731,  -0.850651,         0,
                -0.525731, -0.850651,         0,
                0,         -0.525731, -0.850651,
                0,          0.525731, -0.850651,
                0,          0.525731, 0.850651
            };

            int[] icosahedronIndicies =
            {
                1,   2,  6,
                1,   7,  2,
                3,   4,  5,
                4,   3,  8,
                6,   5, 11,
                5,   6, 10,
                9,  10,  2,
                10,  9,  3,
                7,   8,  9,
                8,   7,  0,
                11,  0,  1,
                0,  11,  4,
                6,   2, 10,
                1,   6, 11,
                3,   5, 10,
                5,   4, 11,
                2,   7,  9,
                7,   1,  0,
                3,   9,  8,
                4,   8,  0,
            };

            Vertex[] verts = new Vertex[icosahedronVertices.Length / 3];
            for (int i = 0; i < icosahedronVertices.Length / 3; i++)
            {
                verts[i] = icosahedron.CreateVertex(new Vector3(icosahedronVertices[i * 3 + 0], icosahedronVertices[i * 3 + 1], icosahedronVertices[i * 3 + 2]));
            }

            for (int i = 0; i < icosahedronIndicies.Length / 3; i++)
            {
                Vertex[] triangleVertices = new Vertex[]
                {
                    verts[icosahedronIndicies[i * 3 + 0]],
                    verts[icosahedronIndicies[i * 3 + 1]],
                    verts[icosahedronIndicies[i * 3 + 2]],
                };
                icosahedron.CreateFace(triangleVertices);
            }

            icosahedron.Transform(Matrix4X4.CreateScale(scale));

            return(icosahedron);
        }