protected override void LoadContent() { lightDirection.Normalize(); YrotationSpeed = (float)graphics.PreferredBackBufferWidth / 100000.0f; XrotatiobSpeed = (float)graphics.PreferredBackBufferHeight / 120000.0f; camera = new Camera(graphics.GraphicsDevice); ocean = new Ocean(Content.Load<Model>("Models/ocean"), Content.Load<Effect>("Effects/SimpleOceanShader"), Content.Load<Texture2D>("Textures/water"), Content.Load<Texture2D>("Textures/wavesbump"), lightDirection); sky = new SkyDome(Content.Load<Model>("Models/dome"), Content.Load<Texture2D>("Textures/SkyDay")); lensFlare = new LensFlareComponent(new SpriteBatch(graphics.GraphicsDevice), Content, graphics.GraphicsDevice); screenCenter = new Vector2(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height) / 2; }
public void DrawOcean(GameTime gameTime, GraphicsDeviceManager graphics, Vector3 position, Camera camera) { ModelMesh mesh = ocean.Meshes[0]; ModelMeshPart meshPart = mesh.MeshParts[0]; projectionOceanParameter.SetValue(camera.projection); viewOceanParameter.SetValue(camera.view); worldOceanParameter.SetValue(Matrix.CreateRotationY((float)MathHelper.ToRadians((int)270)) * Matrix.CreateRotationZ((float)MathHelper.ToRadians((int)90)) * Matrix.CreateScale(oceanLengthScale, oceanHeightScale, oceanLengthScale) * Matrix.CreateTranslation(0, -60, 0)); ambientIntensityOceanParameter.SetValue(0.4f); ambientColorOceanParameter.SetValue(Color.White.ToVector4()); diffuseColorOceanParameter.SetValue(Color.White.ToVector4()); diffuseIntensityOceanParameter.SetValue(0.2f); specularColorOceanParameter.SetValue(Color.White.ToVector4()); eyePosOceanParameter.SetValue(position); colorMapTextureOceanParameter.SetValue(diffuseOceanTexture); normalMapTextureOceanParameter.SetValue(normalOceanTexture); totalTimeOceanParameter.SetValue((float)gameTime.TotalGameTime.TotalMilliseconds / 5000f); rippleSpeedParameter.SetValue(rippleSpeed); rippleHeightParameter.SetValue(rippleHeight); lightDirectionOceanParameter.SetValue(lightDirection); graphics.GraphicsDevice.SetVertexBuffer(meshPart.VertexBuffer, meshPart.VertexOffset); graphics.GraphicsDevice.Indices = meshPart.IndexBuffer; graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend; graphics.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead; oceanEffect.CurrentTechnique = oceanEffect.Techniques["Technique1"]; for (int i = 0; i < oceanEffect.CurrentTechnique.Passes.Count; i++) { oceanEffect.CurrentTechnique.Passes[i].Apply(); graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, meshPart.NumVertices, meshPart.StartIndex, meshPart.PrimitiveCount); } }