void ShotTrackMap_SetCamera(BoundingBox box) { _camera = new CameraOrtho() { Position = new Vector3(box.GetCenter().X, box.Maximum.Y + DefaultMargin, box.GetCenter().Z), FarZ = box.GetSizeY() + DefaultMargin * 2, Target = box.GetCenter(), Up = new Vector3(0.0f, 0.0f, -1.0f), Width = box.GetSizeX() + DefaultMargin * 2, Height = box.GetSizeZ() + DefaultMargin * 2 }; }
void ShotBodyShadow_SetCamera() { var pos = -_objectPos; pos.Y = 0; _camera = new CameraOrtho { Position = pos + new Vector3(0, -0.01f, 0), FarZ = CarSize.Y + 0.02f, Target = pos, Width = AmbientBodyShadowSize.X * 2, Height = AmbientBodyShadowSize.Z * 2 }; }
void ShotWheelShadow_SetCamera(Vector3 wheelPos) { var pos = wheelPos - _objectPos; pos.Y = 0; _camera = new CameraOrtho { Position = pos + new Vector3(0, -0.01f, 0), FarZ = AmbientWheelShadowSize.X / 2 + 0.02f, Target = pos, Width = AmbientWheelShadowSize.X * 2, Height = AmbientWheelShadowSize.Z * 2 }; }
void LoadScene(string filename, int skinNumber, VisualMode mode) { _mode = mode; _filename = filename; _kn5 = Kn5.FromFile(filename, mode == VisualMode.BODY_SHADOW || mode == VisualMode.TRACK_MAP); if (_kn5.IsWithoutTextures()) { var mainFile = FileUtils.GetMainCarFilename(Path.GetDirectoryName(filename)); if (mainFile != null) { _kn5.LoadTexturesFrom(mainFile); } } _textures = new Dictionary <string, ShaderResourceView>(_kn5.Textures.Count); LoadMaterials(); GetObjects(); _wireframeBackgroundColor = new Color4(0x292826); switch (_mode) { case VisualMode.SIMPLE_PREVIEW_GT5: { _camera = new CameraOrbit(0.08f * MathF.PI) { Alpha = 1.1f, Beta = -0.04f, Radius = 8.0f, Target = new Vector3(0, 0.78f, 0) }; _dirLight = new DirectionalLight { Ambient = new Color4(0.65f, 0.66f, 0.64f), Diffuse = new Color4(1.84f, 1.87f, 1.88f), Specular = new Color4(0.95f, 0.96f, 1.13f), Direction = new Vector3(-1.57735f, -2.57735f, 0.57735f) }; _backgroundColor = new Color4(0.0f, 0.0f, 0.0f, 0.0f); _reflectionCubemap = ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomReflection); } break; case VisualMode.SIMPLE_PREVIEW_GT6: { _camera = new CameraOrbit(0.011f * MathF.PI) { Alpha = 0.0f, Beta = 0.0f, NearZ = 1.0f, Radius = 90.0f, Target = new Vector3(0, 0.78f, 0) }; _dirLight = new DirectionalLight { Ambient = new Color4(0.65f, 0.66f, 0.64f), Diffuse = new Color4(1.84f, 1.87f, 1.88f), Specular = new Color4(0.95f, 0.96f, 1.13f), Direction = new Vector3(-1.57735f, -2.57735f, 0.57735f) }; _backgroundColor = new Color4(0.0f, 0.0f, 0.0f, 0.0f); _reflectionCubemap = ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomReflection); } break; case VisualMode.LIVERY_VIEW: { _dirLight = new DirectionalLight { Ambient = new Color4(2.5f, 2.5f, 2.5f), Diffuse = new Color4(0.0f, 0.0f, 0.0f), Specular = new Color4(0.0f, 0.0f, 0.0f), Direction = new Vector3(0.0f, -1.0f, 0.0f) }; var pos = -_objectPos; pos.Y = CarSize.Y + 1.0f; _camera = new CameraOrtho() { Position = pos, FarZ = CarSize.Y + 10.0f, Target = pos - Vector3.UnitY, Width = CarSize.X, Height = CarSize.Z }; foreach (var obj in _objs) { if (obj.Blen != null) { obj.Blen.Dispose(); var transDesc = new BlendStateDescription { AlphaToCoverageEnable = false, IndependentBlendEnable = false }; transDesc.RenderTargets[0].BlendEnable = true; transDesc.RenderTargets[0].SourceBlend = BlendOption.Zero; transDesc.RenderTargets[0].DestinationBlend = BlendOption.Zero; transDesc.RenderTargets[0].BlendOperation = BlendOperation.Add; transDesc.RenderTargets[0].SourceBlendAlpha = BlendOption.Zero; transDesc.RenderTargets[0].DestinationBlendAlpha = BlendOption.Zero; transDesc.RenderTargets[0].BlendOperationAlpha = BlendOperation.Add; transDesc.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All; obj.Blen = BlendState.FromDescription(CurrentDevice, transDesc); } } _backgroundColor = new Color4(0.0f, 0.0f, 0.0f, 0.0f); } break; case VisualMode.SIMPLE_PREVIEW_SEAT_LEON_EUROCUP: { _camera = new CameraOrbit(0.011f * MathF.PI) { Alpha = 0.0f, Beta = 0.0f, NearZ = 1.0f, Radius = 90.0f, Target = new Vector3(0, 0.78f, 0) }; _dirLight = new DirectionalLight { Ambient = new Color4(0.65f, 0.66f, 0.64f), Diffuse = new Color4(1.89f, 1.89f, 1.84f), Specular = new Color4(2.95f, 2.96f, 2.13f), Direction = new Vector3(-1.57735f, -0.57735f, 0.57735f) }; _backgroundColor = new Color4(0.68f, 0.68f, 0.68f); _reflectionCubemap = ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomReflection); } break; case VisualMode.DARK_ROOM: { _camera = new CameraOrbit(0.15f * MathF.PI) { Alpha = 1.1f, Beta = 0.021f, Radius = 5.4f, Target = new Vector3(0, 0.78f, 0) }; _dirLight = new DirectionalLight { Ambient = new Color4(1.45f, 1.46f, 1.44f), Diffuse = new Color4(2.24f, 2.23f, 2.20f), Specular = new Color4(0.0f, 0.0f, 0.0f), Direction = new Vector3(-1.57735f, -2.57735f, 0.57735f) }; _backgroundColor = new Color4(0.0f, 0.0f, 0.0f); _reflectionCubemap = ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomReflection); var size = CarSize; var maxSize = System.Math.Max(size.X, size.Z) * 0.8f; var pos = _objectPos; pos.Y = 0; CreateTexturedPlace(Matrix.Scaling(maxSize, 1.0f, maxSize) * Matrix.Translation(pos), ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomFloor)); LoadShadows(); } break; case VisualMode.BRIGHT_ROOM: { _camera = new CameraOrbit(0.15f * MathF.PI) { Alpha = 1.1f, Beta = 0.021f, Radius = 5.4f, Target = new Vector3(0, 0.78f, 0) }; _dirLight = new DirectionalLight { Ambient = new Color4(2.36f, 2.36f, 2.36f), Diffuse = new Color4(1.08f, 1.08f, 1.08f), Specular = new Color4(0.0f, 0.0f, 0.0f), Direction = new Vector3(1.57735f, -2.57735f, 0.57735f) }; _backgroundColor = new Color4(0.9f, 0.92f, 0.97f); _reflectionCubemap = ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomReflection); var size = CarSize; var maxSize = System.Math.Max(size.X, size.Z) * 0.8f; var pos = _objectPos; pos.Y = 0; CreateTexturedPlace(Matrix.Scaling(maxSize, 1.0f, maxSize) * Matrix.Translation(pos), ShaderResourceView.FromMemory(CurrentDevice, Properties.Resources.TextureDarkRoomFloor)).Visible = false; LoadShadows(); } break; case VisualMode.BODY_SHADOW: { LoadShadowsSize(); } return; case VisualMode.TRACK_MAP: return; } LoadSkins(); if (skinNumber >= 0 && skinNumber < Skins.Count) { LoadSkin(skinNumber); } LoadTextures(); }