Esempio n. 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            _textureEffect          = Content.Load <Effect>("Shaders\\Texture");
            _positionColorEffect    = Content.Load <Effect>("Shaders\\PositionColor");
            _positionColorEffectWvp = _positionColorEffect.Parameters["wvpMatrix"];
            BoundingSphereRenderer.Init(_positionColorEffectWvp, _positionColorEffect);
            _textureEffectWvp   = _textureEffect.Parameters["wvpMatrix"];
            _textureEffectImage = _textureEffect.Parameters["textureImage"];


            const float border = Boundary;
            var         uv     = new Vector2(0.0f, 0.0f);
            var         pos    = new Vector3(0.0f, 0.0f, 0.0f);
            Color       color  = Color.White;

            // top left
            uv.X  = 0.0f;
            uv.Y  = 0.0f;
            pos.X = -border;
            pos.Y = 0.0f;
            pos.Z = -border;
            _groundVertices[0] = new VertexPositionColorTexture(pos, color, uv);

            // bottom left
            uv.X  = 0.0f;
            uv.Y  = 10.0f;
            pos.X = -border;
            pos.Y = 0.0f;
            pos.Z = border;
            _groundVertices[1] = new VertexPositionColorTexture(pos, color, uv);

            // top right
            uv.X  = 10.0f;
            uv.Y  = 0.0f;
            pos.X = border;
            pos.Y = 0.0f;
            pos.Z = -border;
            _groundVertices[2] = new VertexPositionColorTexture(pos, color, uv);

            // bottom right
            uv.X  = 10.0f;
            uv.Y  = 10.0f;
            pos.X = border;
            pos.Y = 0.0f;
            pos.Z = border;
            _groundVertices[3] = new VertexPositionColorTexture(pos, color, uv);


            _menu = new Menu();

            //Using the sprite batch messes up these settings
            _rs  = GraphicsDevice.RasterizerState;
            _dss = GraphicsDevice.DepthStencilState;
            _bs  = GraphicsDevice.BlendState;
            _ss  = GraphicsDevice.SamplerStates[0];

            base.Initialize();
        }
Esempio n. 2
0
 /// <summary>
 /// Draws the collision object.
 /// </summary>
 /// <param name="graphicsDevice">The graphics device.</param>
 /// <param name="view">The view.</param>
 /// <param name="projection">The projection.</param>
 public void Draw(GraphicsDevice graphicsDevice, Matrix view, Matrix projection)
 {
     BoundingSphereRenderer.Render(graphicsDevice, this, view, projection);
 }