private void DrawSphere(Sphere sphere) { // get frustum camera position in planet space Camera frustumCamera = cameraManager.ActiveFrustumCamera; Position3 frustumCameraPosition = frustumCamera.Position - sphere.Position; // update sphere, allowing it to split sphere.Update(frustumCameraPosition, MathHelper.ToRadians(frustumCamera.FieldOfView)); //GraphicsDevice.VertexDeclaration = positionNormalTextureHeight; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.RasterizerState = currentRasterizerState; CalculateProjection(sphere); Camera camera = mainCamera; // get frustum camera position in planet space Position3 cameraPosition = camera.Position - sphere.Position; // calculate horizon angle, using camera position in planet space float horizonAngle = sphere.CalculateHorizonAngle(cameraPosition); Globals.DrawLevel = 0; Globals.DrawCount = 0; Globals.HorizonCullCount = 0; Globals.FrustumCullCount = 0; DrawTerrainNode(sphere.Front, cameraPosition, horizonAngle, sphere, camera); DrawTerrainNode(sphere.Back, cameraPosition, horizonAngle, sphere, camera); DrawTerrainNode(sphere.Left, cameraPosition, horizonAngle, sphere, camera); DrawTerrainNode(sphere.Right, cameraPosition, horizonAngle, sphere, camera); DrawTerrainNode(sphere.Top, cameraPosition, horizonAngle, sphere, camera); DrawTerrainNode(sphere.Bottom, cameraPosition, horizonAngle, sphere, camera); }
private void DrawAtmosphere(Sphere sphere) { // get frustum camera position in planet space Camera frustumCamera = cameraManager.ActiveFrustumCamera; Position3 frustumCameraPosition = frustumCamera.Position - sphere.Position; // update sphere, allowing it to split sphere.Update(frustumCameraPosition, MathHelper.ToRadians(frustumCamera.FieldOfView)); if (fillMode == FillMode.Solid) GraphicsDevice.RasterizerState = CullClockwiseSolid; else GraphicsDevice.RasterizerState = CullClockwiseWireFrame; GraphicsDevice.DepthStencilState = DepthNoWrite; GraphicsDevice.BlendState = BlendState.NonPremultiplied; //CalculateProjection(sphere); Camera camera = mainCamera; // get frustum camera position in planet space Position3 cameraPosition = camera.Position - sphere.Position; // calculate horizon angle, using camera position in planet space float horizonAngle = sphere.CalculateHorizonAngle(cameraPosition); Globals.DrawLevel = 0; Globals.DrawCount = 0; Globals.HorizonCullCount = 0; Globals.FrustumCullCount = 0; DrawAtmosphereNode(sphere.Front, cameraPosition, horizonAngle, sphere, camera); DrawAtmosphereNode(sphere.Back, cameraPosition, horizonAngle, sphere, camera); DrawAtmosphereNode(sphere.Left, cameraPosition, horizonAngle, sphere, camera); DrawAtmosphereNode(sphere.Right, cameraPosition, horizonAngle, sphere, camera); DrawAtmosphereNode(sphere.Top, cameraPosition, horizonAngle, sphere, camera); DrawAtmosphereNode(sphere.Bottom, cameraPosition, horizonAngle, sphere, camera); }