public SceneBattle(ContentManager content, GraphicsDevice graphicsDevice)
        {
            whitekeys.Add(Keys.T);
            whitekeys.Add(Keys.G);
            whitekeys.Add(Keys.F);
            whitekeys.Add(Keys.H);
            whitekeys.Add(Keys.O);
            whitekeys.Add(Keys.P);

            blackkeys.Add(Keys.Up);
            blackkeys.Add(Keys.Down);
            blackkeys.Add(Keys.Left);
            blackkeys.Add(Keys.Right);
            blackkeys.Add(Keys.NumPad5);
            blackkeys.Add(Keys.NumPad6);

            white = new WhiteModel(content.Load<Model>(@"Models\Fighter"), whitekeys, new Vector3(-25, 0, 0), new Vector3(0, MathHelper.PiOver2, 0), new Vector3(0.05f));
            black = new BlackModel(content.Load<Model>(@"Models\Cleric"), blackkeys, new Vector3(25, 0, 0), new Vector3(0, -MathHelper.PiOver2, 0), new Vector3(0.06f));

            camera = new PerspectiveCamera();
            ((PerspectiveCamera)camera).Initialize(
                cameraPosition,
                new Vector3(0, 0, 0),
                Vector3.Up,
                MathHelper.PiOver4,
                (float)Util.screenWidth /
                (float)Util.screenHeight,
                1, 10000);

            landscape = new Model3D(@"Models/scene_e", content, Matrix.Identity, new Vector3(70, 4.3f, 70));
        }
        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera)
        {
            //effect.Parameters["World"].SetValue(this.World);
            effect.Parameters["View"].SetValue(camera.View);
            effect.Parameters["Projection"].SetValue(camera.Projection);
            effect.Parameters["Texture1"].SetValue(this.texture);
            effect.CurrentTechnique = effect.Techniques["Technique1"];

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                /*graphicsDevice.DrawUserPrimitives<VertexPositionColor>
                    (PrimitiveType.TriangleList, vertices, 0, 2, VertexPositionColor.VertexDeclaration);*/
                graphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                    (PrimitiveType.TriangleList, vertices, 0, 2, VertexPositionTexture.VertexDeclaration);
            }
        }
        public void Draw(Camera camera)
        {
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (SkinnedEffect effect in mesh.Effects)
                {
                    effect.SetBoneTransforms(bones);

                    effect.View = camera.View;
                    effect.Projection = camera.Projection;
                    effect.World = world;
                    effect.EnableDefaultLighting();

                    effect.SpecularColor = new Vector3(0.25f);
                    effect.SpecularPower = 16;
                }
                mesh.Draw();
            }
        }
Example #4
0
        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera)
        {
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect eff in mesh.Effects)
                {
                    eff.World = _world;
                    eff.View = camera.View;
                    eff.Projection = camera.Projection;

                    eff.LightingEnabled = true;
                    eff.DirectionalLight0.Direction = direct;
                    eff.DirectionalLight0.DiffuseColor = diffuse;
                    eff.AmbientLightColor = ambient;
                    eff.SpecularColor = specular;
                }
                mesh.Draw();
            }
        }
Example #5
0
        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera, Vector2 color)
        {
            effectDepth.Parameters["World"].SetValue(Matrix.CreateRotationX(MathHelper.PiOver2) * _world);
            effectDepth.Parameters["View"].SetValue(camera.View);
            effectDepth.Parameters["Projection"].SetValue(camera.Projection);
            effectDepth.Parameters["myColor"].SetValue(new Vector4((color.X + 1) / 8.0f, 0, (color.Y + 1) / 8.0f, 1));
            effectDepth.CurrentTechnique = effectDepth.Techniques["Technique1"];

            foreach (EffectPass pass in effectDepth.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserPrimitives<Vector3>
                    (PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3, VertexPositionColor.VertexDeclaration);
            }
        }
 public virtual void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera, Vector2 color, Matrix world)
 {
     _model.World = world;
     _model.Draw(gameTime, graphicsDevice, camera, color);
 }
 public virtual void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera, Vector2 color)
 {
     _model.Draw(gameTime, graphicsDevice, camera, color);
 }
 public virtual void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera)
 {
     _model.Draw(gameTime, graphicsDevice, camera);
 }
Example #9
0
 public virtual void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera, Vector2 color)
 {
 }
Example #10
0
 public virtual void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera)
 {
 }
        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera, Vector2 color, Matrix world)
        {
            effectDepth.Parameters["World"].SetValue(world);
            effectDepth.Parameters["View"].SetValue(camera.View);
            effectDepth.Parameters["Projection"].SetValue(camera.Projection);
            effectDepth.Parameters["myColor"].SetValue(new Vector4((color.X + 1) / 8.0f, 0, (color.Y + 1) / 8.0f, 1));
            effectDepth.CurrentTechnique = effectDepth.Techniques["Technique1"];

            foreach (EffectPass pass in effectDepth.CurrentTechnique.Passes)
            {
                pass.Apply();
                /*graphicsDevice.DrawUserPrimitives<VertexPositionColor>
                    (PrimitiveType.TriangleList, vertices, 0, 2, VertexPositionColor.VertexDeclaration);*/
                graphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                    (PrimitiveType.TriangleList, vertices, 0, 2, VertexPositionTexture.VertexDeclaration);
            }
        }
Example #12
0
        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Camera camera)
        {
            myEffect.Parameters["World"].SetValue(World);
            myEffect.Parameters["View"].SetValue(camera.View);
            myEffect.Parameters["Projection"].SetValue(camera.Projection);
            myEffect.Parameters["Width"].SetValue(n);
            myEffect.Parameters["Height"].SetValue(m);
            myEffect.Parameters["UnderTexture"].SetValue(Under);
            //myEffect.Parameters["WhiteTexture"].SetValue(White);
            //myEffect.Parameters["BlackTexture"].SetValue(Black);
            myEffect.Parameters["FilledTexture"].SetValue(FillTex);
            myEffect.CurrentTechnique = myEffect.Techniques["Technique2"];

            foreach (EffectPass pass in myEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                for (int r = 0; r < m - 1; ++r)
                    graphicsDevice.DrawUserPrimitives<VertexPositionColor>
                        (PrimitiveType.TriangleList, _vertices, r * 6 * (n - 1), 2 * (n - 1), VertexPositionColor.VertexDeclaration);
            }
        }
        public SceneChessBoard(ContentManager content, GraphicsDevice graphicsDevice)
        {
            //Get the current presentation parameters
            var pp = graphicsDevice.PresentationParameters;
            //Create our new render target
            mainRenderTarget = new RenderTarget2D(graphicsDevice,
                                 pp.BackBufferWidth, //Same width as backbuffer
                                 pp.BackBufferHeight, //Same height
                                 false, //No mip-mapping
                                 pp.BackBufferFormat, //Same colour format
                                 pp.DepthStencilFormat); //Same depth stencil

            camera = new PerspectiveCamera();
            float t = Util.cellWidthSpace;
            ((PerspectiveCamera)camera).Initialize(
                new Vector3(-t * 4, 20, t * 4),
                new Vector3(t * 4, 0, t * 4),
                Vector3.Up,
                MathHelper.PiOver4,
                (float)Util.screenWidth /
                (float)Util.screenHeight,
                1, 1000);

            Vector3 rotation = Vector3.Zero;
            float scale = Util.chessPieceScale;

            for (int i = 0; i < 64; ++i)
            {
                int nk = _sampleBoard[i];
                switch (Math.Abs(nk))
                {
                    case 0:
                        pieces[i] = null;
                        break;
                    case 1:
                        pieces[i] = new Pawn(nk > 0, content, rotation, scale, i % 8, i / 8);
                        break;
                    case 2:
                        pieces[i] = new Rook(nk > 0, content, rotation, scale, i % 8, i / 8);
                        break;
                    case 3:
                        pieces[i] = new Knight(nk > 0, content, rotation, scale, i % 8, i / 8);
                        break;
                    case 4:
                        pieces[i] = new Bishop(nk > 0, content, rotation, scale, i % 8, i / 8);
                        break;
                    case 5:
                        pieces[i] = new Queen(nk > 0, content, rotation, scale, i % 8, i / 8);
                        break;
                    case 6:
                        pieces[i] = new King(nk > 0, content, rotation, scale, i % 8, i / 8);
                        break;
                }
            }

            board = new ChessBoard(@"Terrains/BoardGray128", content, Matrix.CreateScale(Util.boardScale));
            circlePos = new PlanarObject(content, @"Terrains/circlePos", 2);
            circleHover = new PlanarObject(content, @"Terrains/circleHover", 2);
            circleDie = new PlanarObject(content, @"Terrains/circleDie", 2);
            circleSpecial = new PlanarObject(content, @"Terrains/circleSpecial", 2);
            circleSelect = new PlanarObject(content, @"Terrains/circleSelect", 2);
            circleCheck = new PlanarObject(content, @"Terrains/circleCheck", 2);

            avatarW = content.Load<Texture2D>(@"Images/Avatar/avatarW");
            avatarB = content.Load<Texture2D>(@"Images/Avatar/avatarB");
            avatarBorder = content.Load<Texture2D>(@"Images/Avatar/avatarBorder");

            surrender = new FrameButton(content, "Surrender", FrameButton.MyButtonAlignment.Left, new Rectangle(360, avatarMargin, 960, 340));
            back = new FrameButton(content, "Back", FrameButton.MyButtonAlignment.Left, new Rectangle(600, avatarMargin, 960, 340));

            landscape = new Model3D(@"Models/scene_e", content, Matrix.Identity, new Vector3(7.2f, 0.8f, 4.8f * 3));
        }