Пример #1
0
        /// <summary>
        /// See BlWindow3D for details.
        /// </summary>
        protected override void Setup()
        {
            Graphics.Lights.Clear();
            var light = new BlGraphicsDeviceManager.Light();

            light.LightDiffuseColor = new Vector3(1, 1, .5f);
            light.LightDirection    = new Vector3(1, 0, 0);
            Graphics.Lights.Add(light);

            // We need to create one ContentManager object for each top-level content folder we'll be
            // loading things from. Here "Content" is the most senior folder name of the content tree.
            // (Content [models, fonts, etc.] are added to the project with the Content utility. Double-click
            // 'Content.mgcb' in solution explorer.). You can create multiple content managers if content
            // is spread over diverse folders.
            var MyContent = new ContentManager(Services, "Content");

            // The font we will use to draw the menu on the screen.
            // "Arial14" is the pathname to the font file
            Font = MyContent.Load <SpriteFont>("Arial14");

            // load the terrain image
            var terrain = Graphics.LoadFromImageFile("terrain.png", true);

            // The vertices of the surface
            var SurfaceArray = Graphics.CreateMeshSurfaceFromImage(terrain, .001);

            // The sprite we draw in this window
            Surface        = new BlSprite(Graphics, "Surface");
            Surface.Mipmap = terrain;
            Surface.LODs.Add(SurfaceArray);
            Surface.BoundSphere = new BoundingSphere(Vector3.Zero, 1);
            Surface.SetAllMaterialBlack();
            Surface.Color = new Vector3(1, 1, 1);
        }
Пример #2
0
        /// <summary>
        /// See BlWindow3D for details.
        /// </summary>
        protected override void Setup()
        {
            Graphics.Lights.Clear();
            var light = new BlGraphicsDeviceManager.Light();

            light.LightDiffuseColor = new Vector3(1, 1, .5f);
            light.LightDirection    = new Vector3(1, 0, 0);
            Graphics.Lights.Add(light);

            // We need to create one ContentManager object for each top-level content folder we'll be
            // loading things from. Here "Content" is the most senior folder name of the content tree.
            // (Content [models, fonts, etc.] are added to the project with the Content utility. Double-click
            // 'Content.mgcb' in solution explorer.). You can create multiple content managers if content
            // is spread over diverse folders.
            var MyContent = new ContentManager(Services, "Content");

            // The font we will use to draw the menu on the screen.
            // "Arial14" is the pathname to the font file
            Font = MyContent.Load <SpriteFont>("Arial14");

            var width  = 512;
            var height = 512;

            var totalVertices = width * height;

            var data = new int[totalVertices];

            Parallel.For(0, width, (x) =>
            {
                Parallel.For(0, height, (y) =>
                {
                    // The '1e6' makes sure we use most of the resolution of an int
                    var v = (int)(1e6 * (Math.Sin((x * y) / 9000.0) + 1));
                    data[x + width * y] = v;
                });
            });

            // The vertices of the surface
            var SurfaceArray = Graphics.CreateMeshSurface(data, width, height, 1e-7);

            // The sprite we draw in this window
            Surface = new BlSprite(Graphics, "Surface");
            Surface.LODs.Add(SurfaceArray);
            Surface.BoundSphere = new BoundingSphere(Vector3.Zero, 1);
            Surface.SetAllMaterialBlack();
            Surface.Color = new Vector3(1, 1, 1);
        }
Пример #3
0
        /// <summary>
        /// See BlWindow3D for details.
        /// </summary>
        protected override void Setup()
        {
            Graphics.Lights.Clear();
            var light = new BlGraphicsDeviceManager.Light();

            light.LightDiffuseColor = new Vector3(1, 1, .5f);
            light.LightDirection    = new Vector3(1, 0, 0);
            Graphics.Lights.Add(light);

            // Any type of content (3D models, fonts, images, etc.) can be converted to an XNB file by downloading and
            // using the mgcb-editor (see Blotch3D.chm for details). XNB files are then normally added to the project
            // and loaded as shown here. 'Content', here, is the folder that contains the XNB files or subfolders with
            // XNB files. We need to create one ContentManager object for each top-level content folder we'll be loading
            // XNB files from. You can create multiple content managers if content is spread over diverse folders. Some
            // content can also be loaded in its native format using platform specific code (may not be portable) or
            // certain Blotch3D/Monogame methods, like BlGraphicsDeviceManager.LoadFromImageFile.
            var MyContent = new ContentManager(Services, "Content");

            // The font we will use to draw the menu on the screen.
            // "Arial14" is the pathname to the font file
            Font = MyContent.Load <SpriteFont>("Arial14");

            // load the terrain image
            var terrain = Graphics.LoadFromImageFile("Content/terrain.png", true);

            // The vertices of the surface
            var SurfaceArray = BlGeometry.CreatePlanarSurface(terrain);

            // convert to vertex buffer
            var vertexBuf = BlGeometry.TrianglesToVertexBuffer(Graphics.GraphicsDevice, SurfaceArray);

            // The sprite we draw in this window
            Surface        = new BlSprite(Graphics, "Surface");
            Surface.Mipmap = terrain;
            Surface.LODs.Add(vertexBuf);
            Surface.BoundSphere = new BoundingSphere(Vector3.Zero, 1);
            Surface.SetAllMaterialBlack();
            Surface.Color = new Vector3(1, 1, 1);
        }