Beispiel #1
0
        public override void Draw(GameTime gameTime)
        {
            Prepare3DRenderer.PrepareGraphicsDevice();
            Game.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;

            //draw the skybox
            Game.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;

            skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);

            foreach (ModelMesh mesh in skyboxModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World      = skyboxTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(_camera.Position);
                    effect.View       = _camera.View;
                    effect.Projection = _camera.Projection;
                }
                mesh.Draw();
            }


            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            base.Draw(gameTime);
        }
Beispiel #2
0
        public override void Draw(GameTime gameTime)
        {
            Prepare3DRenderer.PrepareGraphicsDevice();

            GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

            GraphicsDevice.RasterizerState = actualRasterizer;
            _effect.World      = Matrix.Identity;
            _effect.View       = _camera.View;
            _effect.Projection = _camera.Projection;


            _effect.EnableDefaultLighting();
            _effect.DirectionalLight0.Direction = new Vector3(1, -1, 1);
            _effect.DirectionalLight0.Enabled   = true;
            _effect.AmbientLightColor           = new Vector3(0.3f, 0.3f, 0.3f);
            _effect.DirectionalLight1.Enabled   = false;
            _effect.DirectionalLight2.Enabled   = false;
            _effect.SpecularColor = new Vector3(0, 0, 0);


            _effect.PreferPerPixelLighting = false;

            _effect.Texture        = _texture;
            _effect.TextureEnabled = true;

            _effect.FogEnabled = false;
            _effect.FogColor   = new Vector3(1, 0, 0);
            _effect.FogStart   = 1;
            _effect.FogEnd     = 250;


            if (_showNormals)
            {
                GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, _normalsList, 0, _normalsList.Length / 2);
            }


            GraphicsDevice.SetVertexBuffer(_vertexBuffer);
            GraphicsDevice.Indices = _indexBuffer;



            foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, _width * _height, 0, _width * 2 * (_height - 1) - 2);
            }

            base.Draw(gameTime);
        }
Beispiel #3
0
        public override void Draw(GameTime gameTime)
        {
            Prepare3DRenderer.PrepareGraphicsDevice();

            basicEffect.CurrentTechnique.Passes[0].Apply();
            basicEffect.World      = Matrix.Identity;
            basicEffect.View       = _camera.View;
            basicEffect.Projection = _camera.Projection;

            GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 3);

            base.Draw(gameTime);
        }
Beispiel #4
0
        public override void DrawModel(Camera camera)
        {
            Prepare3DRenderer.PrepareGraphicsDevice();
            // Set the world matrix as the root transform of the model.
            //_model.Root.Transform = Matrix.CreateScale(_scale) * _orientation * Matrix.CreateTranslation(Position);

            leftBackWheelBone.Transform   = _wheelRollMatrix * leftBackWheelTransform;
            rightBackWheelBone.Transform  = _wheelRollMatrix * rightBackWheelTransform;
            leftFrontWheelBone.Transform  = _wheelRollMatrix * leftFrontWheelTransform;
            rightFrontWheelBone.Transform = _wheelRollMatrix * rightFrontWheelTransform;
            _model.CopyAbsoluteBoneTransformsTo(_boneTransforms);

            Matrix worldMatrix  = _orientation * Matrix.CreateTranslation(Position);
            Matrix turretMatrix = _turretOrientation * Matrix.CreateTranslation(Position);
            Matrix canonMatrix  = Matrix.CreateScale(_scale) * _canonOrientation * Matrix.CreateTranslation(Position);

            _model.CopyAbsoluteBoneTransformsTo(_boneTransforms);


            WZGame.GraphicsDevice.BlendState = BlendState.AlphaBlend;

            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    switch (mesh.Name)
                    {
                    case "canon_geo":
                        //effect.World = _boneTransforms[mesh.ParentBone.Index] * canonMatrix;
                        effect.World = _boneTransforms[mesh.ParentBone.Index] * turretMatrix;
                        break;

                    case "hatch_geo":
                    case "turret_geo":
                        effect.World = _boneTransforms[mesh.ParentBone.Index] * turretMatrix;
                        break;

                    default:
                        effect.World = _boneTransforms[mesh.ParentBone.Index] * worldMatrix;
                        break;
                    }

                    //effect.World = _boneTransforms[mesh.ParentBone.Index];
                    effect.View       = camera.View;
                    effect.Projection = camera.Projection;
                    effect.EnableDefaultLighting();
                    effect.PreferPerPixelLighting = true;

                    if (IsGhost)
                    {
                        effect.Alpha = 0.5f;
                    }
                    else
                    {
                        effect.Alpha = 1f;
                    }



                    if (isAiEnemy)
                    {
                        effect.SpecularColor = _specularColor_red;
                    }
                    else
                    {
                        effect.SpecularColor = _specularColor_original;
                    }
                }
                mesh.Draw();
            }
            WZGame.GraphicsDevice.BlendState = BlendState.Opaque;
        }