Esempio n. 1
0
        /// <summary>
        /// See BlWindow3D for details.
        /// </summary>
        protected override void Setup()
        {
            // 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");

            var width  = 128;
            var height = 128;

            // Create the surface triangles
            var SurfaceArray = BlGeometry.CreatePlanarSurface
                               (
                (x, y) => .06 * Math.Sin(((x - width / 2) * (y - height / 2)) / 300.0),
                width,
                height
                               );

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

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

            // When drawing this sprite, don't cull any polygons so that we can see both sides of them
            Surface.PreDraw = (s) =>
            {
                Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
                return(BlSprite.PreDrawCmd.Continue);
            };

            // Undo the previous 'CullNone' after the sprite is drawn so that other sprites use the default mode
            // (although there are no other sprites in this example, so this isn't technically necessary here)
            Surface.DrawCleanup = (s) =>
            {
                Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
            };
        }
Esempio n. 2
0
        /// <summary>
        /// See BlWindow3D for details.
        /// </summary>
        protected override void Setup()
        {
            // 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  = 128;
            var height = 128;

            // Create the surface triangles
            var SurfaceArray = BlGeometry.CreatePlanarSurface
                               (
                (x, y) => .06 * Math.Sin(((x - width / 2) * (y - height / 2)) / 300.0),
                width,
                height
                               );

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

            // The sprite we draw in this window
            Surface             = new BlSprite(Graphics, "Surface");
            Surface.BoundSphere = new BoundingSphere(Vector3.Zero, 1);
            Surface.LODs.Add(vertexBuf);
            Surface.SetAllMaterialBlack();
            Surface.Color   = new Vector3(1, 1, 1);
            Surface.PreDraw = (s) =>
            {
                Graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
                return(BlSprite.PreDrawCmd.Continue);
            };
        }
Esempio n. 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);
        }
Esempio n. 4
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 = 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);
        }