/// <summary> /// Handles the FrameRender. /// </summary> /// <param name="device"></param> /// <param name="totalTime"></param> /// <param name="elapsedTime"></param> public void OnFrameRender(Device device, double totalTime, float elapsedTime) { if (!Framework.Instance.CurrentCamera.Reflected) { // Render the shadow (if not reflecting) Vector3 p1; Vector3 p2; Vector3 p3; Vector3 p4 = new Vector3(0, 0.005f, 0); heightmap.GetPoints(airplane.Position.X, airplane.Position.Z, out p1, out p2, out p3); airplane.OnRenderShadow(device, p1 + p4, p2 + p4, p3 + p4, new Vector3(0, -1, 0)); ripples.OnFrameRender(device, totalTime, elapsedTime); } //debugObject.OnFrameRender(device, totalTime, elapsedTime); if (iFlightModel.CableEnabled) { towLine.OnFrameRender(device, totalTime, elapsedTime); } //windVector.OnFrameRender(device, totalTime, elapsedTime); if (Framework.Instance.CurrentCamera.CameraModeName.Equals("cockpit")) { airplane.Visible = false; } else { airplane.Visible = true; } airplane.OnFrameRender(device, totalTime, elapsedTime); if (towing != null) { towing.OnFrameRender(device, totalTime, elapsedTime); } smoke.OnFrameRender(device, totalTime, elapsedTime); //normalObject.OnFrameRender(device, totalTime, elapsedTime); }
public void OnFrameRender(Microsoft.DirectX.Direct3D.Device device, double totalTime, float elapsedTime) { currentTime = totalTime; if ((modelControl != null) && (modelControl.Reflection != null)) { //if (screen == null) // screen = device.GetRenderTarget(0); modelControl.Reflection.UpdateCubeMap(device, totalTime, elapsedTime, modelControl.AirplaneModel.Position); //device.SetRenderTarget(0, screen); } bool beginSceneCalled = false; // Clear the render target and the zbuffer device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, 0x00424B79, 1.0f, 0); try { device.BeginScene(); Framework.Instance.Device.RenderState.Ambient = Color.FromArgb(148, 148, 148); beginSceneCalled = true; Framework.Instance.CurrentCamera.OnFrameRender(device, totalTime, elapsedTime); sky.OnFrameRender(device, totalTime, elapsedTime); scenery.OnFrameRender(device, totalTime, elapsedTime); modelControl.OnFrameRender(device, totalTime, elapsedTime); if (CollisionPointsVisible && (!modelControl.Flying)) { collisionPoints.OnFrameRender(device, totalTime, elapsedTime); } transparentObjectManager.OnFrameRender(device, totalTime, elapsedTime); if ((toolbox != null) && (toolbox.CurrentObject != null) && (!modelControl.Flying)) { // Render the wireframe device.RenderState.FillMode = FillMode.WireFrame; toolbox.CurrentObject.OnFrameRender(device, totalTime, elapsedTime); // Render the rotationaxis ControlSurface surface = toolbox.CurrentObject as ControlSurface; if (surface != null) { rotationAxisMesh.Vertex1 = surface.WorldPosition * modelControl.AirplaneModel.AirplaneControl.AircraftParameters.Scale; rotationAxisMesh.Vertex2 = (surface.WorldPosition + 2 * surface.RotationAxis) * modelControl.AirplaneModel.AirplaneControl.AircraftParameters.Scale; rotationAxisMesh.OnFrameRender(device, totalTime, elapsedTime); } device.RenderState.FillMode = FillMode.Solid; } if (CursorVisible) { cursor3d.OnFrameRender(device, totalTime, elapsedTime); } if (Cursor2Visible) { cursor3d2.OnFrameRender(device, totalTime, elapsedTime); } // Get the world matrix //Matrix worldMatrix = worldCenter * camera.WorldMatrix; // Show UI //hud.OnRender(elapsedTime); } finally { if (beginSceneCalled) { device.EndScene(); } } }