Esempio n. 1
0
        public void DrawGround(GraphicsDevice device, FirstPersonCamera camera)
        {
            SamplerState ss = new SamplerState();

            ss.AddressU             = TextureAddressMode.Clamp;
            ss.AddressV             = TextureAddressMode.Clamp;
            device.SamplerStates[0] = ss;

            DepthStencilState dss = new DepthStencilState();

            dss.DepthBufferEnable    = false;
            device.DepthStencilState = dss;

            Matrix[] groundTransforms = new Matrix[ground.Bones.Count];
            ground.CopyAbsoluteBoneTransformsTo(groundTransforms);
            int i = 0;

            foreach (ModelMesh mesh in ground.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    Matrix worldMatrix = groundTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(new Vector3(camera.Position.X, 0, camera.Position.Z));
                    currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"];
                    currentEffect.Parameters["xWorld"].SetValue(worldMatrix);
                    currentEffect.Parameters["xView"].SetValue(camera.ViewMatrix);
                    currentEffect.Parameters["xProjection"].SetValue(camera.ProjectionMatrix);
                    currentEffect.Parameters["xTexture"].SetValue(groundTextures[i++]);
                }
                mesh.Draw();
            }

            dss = new DepthStencilState();
            dss.DepthBufferEnable    = true;
            device.DepthStencilState = dss;
        }
Esempio n. 2
0
 public void Draw(GraphicsDevice device, FirstPersonCamera camera)
 {
     //
     DrawSkybox(device, camera);
     DrawGround(device, camera);
 }