/// <summary> /// Funkce se postara o rendering cele sceny /// </summary> /// <param name="time">Cas uplynuly od spusteni aplikace v milisekundach</param> public void Render(float time) { sceneManager.ResetCounters(); #region Rendering tests bool deviceLost = initializator.IsDeviceLost(); if (deviceLost) { ResourceUnload(); } if (!initializator.BeginRender()) { return; } if (unloadResources) { DeviceReset(); unloadResources = false; } #endregion #region Vyrenderovani kolizni mapy (1x) if (terrain != null && terrain.GetCollissionMap() == null) { RenderCollisionMap(0); terrain.SetCollissionMap(BitmapOperation.TextureToColorArray(collisionMap.GetTexture()), true); } #endregion #region Generovani shadow mapy podle prvniho svetla, existuje-li nejake if ((int)currentDetail >= 2) { List <SceneManager.SceneObject> lights = sceneManager.GetDirectionLights(); if (lights.Count > 0) { Vector4 moonPosition = lights[0].light.GetLightPosition(); Matrix view = CameraDriver.GetTerainViewMatrix(new Vector3(moonPosition.X, moonPosition.Y, moonPosition.Z)); Matrix OrthoProjectionMatrix = CameraDriver.GetTerainOrthoProjectionMatrix(); sceneManager.SetLightViewProjection(view * OrthoProjectionMatrix); sceneManager.SetRenderShadowsNonEmitterObjects(false); sceneManager.SetComputeVisibility(false); shadowMap.BeginScene(); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.White, 1f, 0); if (enableshadows) { sceneManager.RenderSceneBasic(time, sceneManager["ShadowMap"]); } shadowMap.EndScene(Filter.Linear); sceneManager.SetShadowMap(shadowMap.GetTexture()); sceneManager.SetRenderShadowsNonEmitterObjects(true); sceneManager.SetComputeVisibility(true); } } #endregion #region Nastaveni optimalizace if (usedoptimize == OptimizeType.QuadTree) { sceneManager.SetComputeVisibility(true); } else if (usedoptimize == OptimizeType.OcclussionCulling) { occlusion.DoCulling(); sceneManager.SetComputeVisibility(false); } #endregion device.BeginScene(); sceneManager.RenderScene(time, sceneManager["Shadows"]); if (showBoundingSpheres) { sceneManager.RenderSceneBasic(time, sceneManager["Base"], true, false); } RenderHUD(); device.EndScene(); initializator.EndRender(); CountFPS(); }