Ejemplo n.º 1
0
        /// <summary>
        /// Creates a 3D plane
        /// </summary>
        /// <param name="width"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static StaticModel CreatePlane(int width, int length)
        {
            MeshVertex[] data = new MeshVertex[4];

            data[0].Position = new Vector3(0, 0, 0);
            data[0].Normal   = Vector3.UnitY;
            data[0].UV       = new Vector2(0, 0);
            data[0].Color    = new Vector4(1, 0, 0, 1);

            data[1].Position = new Vector3(width, 0, 0);
            data[1].Normal   = Vector3.UnitY;
            data[1].UV       = new Vector2(1, 0);
            data[1].Color    = new Vector4(1, 0, 0, 1);

            data[2].Position = new Vector3(width, 0, length);
            data[2].Normal   = Vector3.UnitY;
            data[2].UV       = new Vector2(1, 1);
            data[2].Color    = new Vector4(1, 0, 0, 1);

            data[3].Position = new Vector3(0, 0, length);
            data[3].Normal   = Vector3.UnitY;
            data[3].UV       = new Vector2(0, 1);
            data[3].Color    = new Vector4(1, 0, 0, 1);

            ushort[] indices = new ushort[6] {
                0, 1, 2, 2, 3, 0
            };

            Mesh m = new Mesh(data, indices);

            StaticModel model = new StaticModel();

            model.Meshes    = new Mesh[1];
            model.Meshes[0] = m;

            return(model);
        }