Ejemplo n.º 1
0
        /// <summary>
        ///    Procesa la linea para crear un nuevo Poligono
        /// </summary>
        /// <param name="line">Clase ObjMaterialLader</param>
        /// <param name="objMeshContainer">Clase ObjMaterialLader</param>
        public override void ProccesLine(string line, ObjMeshContainer objMeshContainer)
        {
            var f            = CheckFaceFormatCorrect(line);
            var arrayVertex1 = CheckTriangleFormatCorrect(f[0]);
            var arrayVertex2 = CheckTriangleFormatCorrect(f[1]);
            var arrayVertex3 = CheckTriangleFormatCorrect(f[2]);

            var face = new FaceTriangle(arrayVertex1[Vertex], arrayVertex2[Vertex], arrayVertex3[Vertex]);

            if (arrayVertex1.Length + arrayVertex2.Length + arrayVertex3.Length == CompleteArray)
            {
                face.SetTexturesValues(arrayVertex1[Texture], arrayVertex2[Texture], arrayVertex3[Texture]);
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(arrayVertex1[Texture]))
                {
                    face.SetTexturesValues(arrayVertex1[Texture], arrayVertex2[Texture], arrayVertex3[Texture]);
                }
                face.SetNormalValues(arrayVertex1[Normal], arrayVertex2[Normal], arrayVertex3[Normal]);
            }
            face.Usemtl = objMeshContainer.ListObjMesh.Last().Usemtl.Count > 0 ? objMeshContainer.ListObjMesh.Last().Usemtl.Last() : null;

            objMeshContainer.ListObjMesh.Last().FaceTriangles.Add(face);
        }
        /// <summary>
        /// Produces a triangular pyramid with 4 faces.
        /// </summary>
        /// <param name="sideLength">The length the edges of the triangles should be in pixels.</param>
        /// <param name="height">The height of the triangle in pixels.</param>
        public ShapeTriangularPyramid(float sideLength, float height)
        {
            SideLength = sideLength;
            Height     = height;

            // Front is towards you
            // Back is away from you
            Vector3 front = new Vector3(
                0,
                sideLength / 2,
                height / 2 * -1
                );
            Vector3 backLeft = new Vector3(
                sideLength / 2,
                sideLength / 2 * -1,
                height / 2 * -1
                );
            Vector3 backRight = new Vector3(
                sideLength / 2 * -1,
                sideLength / 2 * -1,
                height / 2 * -1
                );

            Vector3 top = new Vector3(
                0,
                0,
                height / 2
                );

            FaceFrontLeft = new FaceTriangle(
                top,
                backLeft,
                front
                );

            FaceFrontRight = new FaceTriangle(
                top,
                front,
                backRight
                );

            FaceBack = new FaceTriangle(
                top,
                backLeft,
                backRight
                );

            FaceBottom = new FaceTriangle(
                front,
                backLeft,
                backRight
                );

            Faces.Add(FaceFrontLeft);
            Faces.Add(FaceFrontRight);
            Faces.Add(FaceBack);
            Faces.Add(FaceBottom);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Produces a diamond with 8 sides, two square pyramids. One on top, one on the bottom.
        /// </summary>
        /// <param name="length">The length (x) of the diamonds's center in pixels.</param>
        /// <param name="width">The width (y) of the diamonds's center in pixels.</param>
        /// <param name="height">The height (z) of the total diamonds in pixels.</param>
        public ShapeDiamond(float length, float width, float height)
        {
            Height = height;
            Length = length;
            Width  = width;

            Vector3 centerTop =
                new Vector3(
                    0,
                    0,
                    height / 2);

            Vector3 centerBottom =
                new Vector3(
                    0,
                    0,
                    height / 2 * -1);

            FaceTopFront = new FaceTriangle(
                centerTop,
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    0),
                new Vector3(
                    length / 2,
                    width / 2,
                    0)
                );

            FaceTopBack = new FaceTriangle(
                centerTop,
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    0),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    0)
                );

            FaceTopLeft = new FaceTriangle(
                centerTop,
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    0),
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    0)
                );

            FaceTopRight = new FaceTriangle(
                centerTop,
                new Vector3(
                    length / 2,
                    width / 2,
                    0),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    0)
                );

            FaceBottomFront = new FaceTriangle(
                centerBottom,
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    0),
                new Vector3(
                    length / 2,
                    width / 2,
                    0)
                );

            FaceBottomBack = new FaceTriangle(
                centerBottom,
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    0),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    0)
                );

            FaceBottomLeft = new FaceTriangle(
                centerBottom,
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    0),
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    0)
                );

            FaceBottomRight = new FaceTriangle(
                centerBottom,
                new Vector3(
                    length / 2,
                    width / 2,
                    0),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    0)
                );

            Faces.Add(FaceTopFront);
            Faces.Add(FaceTopBack);
            Faces.Add(FaceTopLeft);
            Faces.Add(FaceTopRight);
            Faces.Add(FaceBottomFront);
            Faces.Add(FaceBottomBack);
            Faces.Add(FaceBottomLeft);
            Faces.Add(FaceBottomRight);
        }
        /// <summary>
        /// Produces a square pyramid with 5 faces.
        /// </summary>
        /// <param name="length">The length (x) of the pyramid's base in pixels.</param>
        /// <param name="width">The width (y) of the pyramid's base in pixels.</param>
        /// <param name="height">The height (z) of the pyramid in pixels.</param>
        public ShapeSquarePyramid(float length, float width, float height)
        {
            Length = length;
            Width  = width;
            Height = height;

            // Front is towards you
            // Back is away from you
            Vector3 center =
                new Vector3(
                    0,
                    0,
                    height / 2);

            FaceFront = new FaceTriangle(
                center,
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    height / 2 * -1),
                new Vector3(
                    length / 2,
                    width / 2,
                    height / 2 * -1)
                );

            FaceBack = new FaceTriangle(
                center,
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    height / 2 * -1),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    height / 2 * -1)
                );

            FaceLeft = new FaceTriangle(
                center,
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    height / 2 * -1),
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    height / 2 * -1)
                );

            FaceRight = new FaceTriangle(
                center,
                new Vector3(
                    length / 2,
                    width / 2,
                    height / 2 * -1),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    height / 2 * -1)
                );

            FaceBottom = new FaceSquare(
                new Vector3(
                    length / 2 * -1,
                    width / 2,
                    height / 2 * -1),
                new Vector3(
                    length / 2,
                    width / 2,
                    height / 2 * -1),
                new Vector3(
                    length / 2 * -1,
                    width / 2 * -1,
                    height / 2 * -1),
                new Vector3(
                    length / 2,
                    width / 2 * -1,
                    height / 2 * -1)
                );

            Faces.Add(FaceFront);
            Faces.Add(FaceBack);
            Faces.Add(FaceLeft);
            Faces.Add(FaceRight);
            Faces.Add(FaceBottom);
        }