Ejemplo n.º 1
0
        public void SetOptions([NotNull] DarkPreviewsOptions options)
        {
            _options = options;

            if (_renderer != null)
            {
                SetRendererOptions(_acRoot, _renderer, options);
                SetRendererCarOptions(_renderer, options);
                UpdateCamera();
            }
        }
Ejemplo n.º 2
0
        public DarkPreviewsUpdater(string acRoot, DarkPreviewsOptions options = null, DarkKn5ObjectRenderer existingRenderer = null)
        {
            _acRoot  = acRoot;
            _options = options ?? new DarkPreviewsOptions();

            if (existingRenderer != null)
            {
                _existingRenderer = true;
                _renderer         = existingRenderer;
                _carId            = existingRenderer.CarNode?.CarId;
            }
        }
Ejemplo n.º 3
0
        private static DarkKn5ObjectRenderer CreateRenderer([NotNull] string acRoot, [NotNull] DarkPreviewsOptions options,
                                                            [CanBeNull] CarDescription initialCar, [CanBeNull] string initialSkinId)
        {
            var renderer = new DarkKn5ObjectRenderer(initialCar, GetShowroomKn5(acRoot, options.Showroom))
            {
                LoadCarLights      = true,
                LoadShowroomLights = true
            };

            SetRendererOptions(acRoot, renderer, options);
            renderer.SelectSkin(initialSkinId);
            renderer.Initialize();
            SetRendererCarOptions(renderer, options);
            return(renderer);
        }
Ejemplo n.º 4
0
        private static void SetRendererCarOptions(DarkKn5ObjectRenderer renderer, DarkPreviewsOptions options)
        {
            var car = renderer.CarNode;

            if (car != null)
            {
                car.HeadlightsEnabled  = options.HeadlightsEnabled;
                car.BrakeLightsEnabled = options.BrakeLightsEnabled;
                car.SteerDeg           = (float)options.SteerDeg;
                car.LeftDoorOpen       = options.LeftDoorOpen;
                car.RightDoorOpen      = options.RightDoorOpen;
                car.IsDriverVisible    = options.ShowDriver;
                car.OnTick(float.MaxValue);
            }
        }
Ejemplo n.º 5
0
        public DarkPreviewsUpdater(string acRoot, DarkPreviewsOptions options = null, DarkKn5ObjectRenderer existingRenderer = null)
        {
            _acRoot  = acRoot;
            _options = options ?? new DarkPreviewsOptions();

            if (existingRenderer != null)
            {
                _existingRenderer = true;
                _renderer         = existingRenderer;
                _carId            = existingRenderer.CarNode?.CarId;

                existingRenderer.LoadCarLights      = true;
                existingRenderer.LoadShowroomLights = true;
                existingRenderer.Lights             = existingRenderer.Lights.Where(x => !x.Tag.IsCarTag && !x.Tag.IsShowroomTag).ToArray();
            }
        }
Ejemplo n.º 6
0
        private static DarkKn5ObjectRenderer CreateRenderer(string acRoot, DarkPreviewsOptions options, CarDescription initialCar, string initialSkinId)
        {
            var showroom = options.Showroom;

            if (showroom != null && !File.Exists(showroom))
            {
                var kn5 = Path.Combine(FileUtils.GetShowroomDirectory(acRoot, showroom), $"{showroom}.kn5");
                showroom = File.Exists(kn5) ? kn5 : null;
            }

            var renderer = new DarkKn5ObjectRenderer(initialCar, showroom);

            SetRendererOptions(renderer, options);

            renderer.SelectSkin(initialSkinId);
            renderer.Initialize();
            SetRendererCarOptions(renderer, options);

            return(renderer);
        }
Ejemplo n.º 7
0
        private static void SetRendererCarOptions(DarkKn5ObjectRenderer renderer, DarkPreviewsOptions options)
        {
            var car = renderer.CarNode;

            if (car != null)
            {
                car.HeadlightsEnabled  = options.HeadlightsEnabled;
                car.BrakeLightsEnabled = options.BrakeLightsEnabled;
                car.SteerDeg           = (float)options.SteerDeg;
                car.LeftDoorOpen       = options.LeftDoorOpen;
                car.RightDoorOpen      = options.RightDoorOpen;
                car.IsDriverVisible    = options.ShowDriver;
                car.OnTick(float.MaxValue);
                car.BlurredNodesActive = false;
                car.CockpitLrActive    = false;
                car.SeatbeltOnActive   = false;

                if (options.SuspensionDebugMode)
                {
                    car.SuspensionDebug = true;
                }
            }
        }
Ejemplo n.º 8
0
        private static void SetRendererCarOptions([NotNull] DarkKn5ObjectRenderer renderer, [NotNull] DarkPreviewsOptions options)
        {
            var car = renderer.CarNode;

            if (car != null)
            {
                car.HeadlightsEnabled  = options.HeadlightsEnabled;
                car.BrakeLightsEnabled = options.BrakeLightsEnabled;
                car.SteerDeg           = (float)options.SteerDeg;
                car.LeftDoorOpen       = options.LeftDoorOpen;
                car.RightDoorOpen      = options.RightDoorOpen;
                car.IsDriverVisible    = options.ShowDriver;

                if (options.ExtraActiveAnimations != null)
                {
                    foreach (var animation in options.ExtraActiveAnimations)
                    {
                        var wing = car.Wings.OfType <Kn5RenderableCar.AnimationEntryBase>().Concat(car.Extras)
                                   .FirstOrDefault(x => x.DisplayName == animation);
                        if (wing != null)
                        {
                            wing.IsActive = true;
                        }
                    }
                }
                car.OnTick(float.MaxValue);
                car.BlurredNodesActive = false;
                car.CockpitLrActive    = false;
                car.SeatbeltOnActive   = false;

                if (options.SuspensionDebugMode)
                {
                    car.SuspensionDebug = true;
                }
            }
        }
Ejemplo n.º 9
0
        private static void SetRendererOptions([NotNull] string acRoot, [NotNull] DarkKn5ObjectRenderer renderer, [NotNull] DarkPreviewsOptions options)
        {
            var showroomKn5 = GetShowroomKn5(acRoot, options.Showroom);

            if (showroomKn5 != renderer.CurrentShowroomKn5)
            {
                renderer.SetShowroom(showroomKn5);
            }

            // Obvious fixed settings
            renderer.AutoRotate           = false;
            renderer.AutoAdjustTarget     = false;
            renderer.AsyncTexturesLoading = false;

            // UI should be off!
            renderer.VisibleUi = false;

            // Size-related options
            renderer.Width  = (int)(options.PreviewWidth * options.SsaaMultiplier);
            renderer.Height = (int)(options.PreviewHeight * options.SsaaMultiplier);
            renderer.ResolutionMultiplier = 1d;
            renderer.UseFxaa         = options.UseFxaa;
            renderer.UseSmaa         = options.UseSmaa;
            renderer.UseMsaa         = options.UseMsaa;
            renderer.MsaaSampleCount = options.MsaaSampleCount;

            // Switches
            renderer.WireframeMode = options.WireframeMode ? WireframeMode.LinesOnly : WireframeMode.Disabled;
            renderer.MeshDebug     = options.MeshDebugMode;

            // Flat mirror
            renderer.AnyGround                 = options.AnyGround;
            renderer.FlatMirror                = options.FlatMirror;
            renderer.FlatMirrorBlurred         = options.FlatMirrorBlurred;
            renderer.FlatMirrorBlurMuiltiplier = (float)options.FlatMirrorBlurMuiltiplier;
            renderer.FlatMirrorReflectiveness  = (float)options.FlatMirrorReflectiveness;
            renderer.FlatMirrorReflectedLight  = options.FlatMirrorReflectedLight;

            // Cool effects
            renderer.CubemapAmbient      = options.CubemapAmbient;
            renderer.CubemapAmbientWhite = options.CubemapAmbientWhite;
            renderer.UseBloom            = options.UseBloom;
            renderer.EnableShadows       = options.EnableShadows;
            renderer.UsePcss             = options.UsePcss;
            renderer.ShadowMapSize       = options.ShadowMapSize;
            renderer.UseSslr             = options.UseSslr;
            renderer.UseAo  = options.UseAo;
            renderer.AoType = options.AoType;
            renderer.ReflectionCubemapAtCamera     = options.ReflectionCubemapAtCamera;
            renderer.ReflectionsWithShadows        = options.ReflectionsWithShadows;
            renderer.ReflectionsWithMultipleLights = options.ReflectionsWithMultipleLights;

            // Colors
            renderer.BackgroundColor = options.BackgroundColor;
            renderer.LightColor      = options.LightColor;
            renderer.AmbientUp       = options.AmbientUp;
            renderer.AmbientDown     = options.AmbientDown;

            // Brightnesses
            renderer.AmbientBrightness    = (float)options.AmbientBrightness;
            renderer.BackgroundBrightness = (float)options.BackgroundBrightness;
            renderer.LightBrightness      = (float)options.LightBrightness;
            renderer.Light = ToVector3(options.LightDirection);

            // Custom reflections
            renderer.UseCustomReflectionCubemap = options.UseCustomReflectionCubemap;
            renderer.CustomReflectionBrightness = (float)options.CustomReflectionBrightness;
            renderer.CustomReflectionCubemap    = options.CustomReflectionCubemapData;

            // Color
            renderer.ToneMapping      = options.ToneMapping;
            renderer.UseDither        = options.UseDither;
            renderer.UseColorGrading  = options.UseColorGrading;
            renderer.ToneExposure     = (float)options.ToneExposure;
            renderer.ToneGamma        = (float)options.ToneGamma;
            renderer.ToneWhitePoint   = (float)options.ToneWhitePoint;
            renderer.ColorGradingData = options.ColorGradingData;

            // Extra
            renderer.BloomRadiusMultiplier   = (float)(options.SsaaMultiplier * options.BloomRadiusMultiplier);
            renderer.MaterialsReflectiveness = (float)options.MaterialsReflectiveness;
            renderer.CarShadowsOpacity       = (float)options.CarShadowsOpacity;
            renderer.PcssLightScale          = (float)options.PcssLightScale;
            renderer.PcssSceneScale          = (float)options.PcssSceneScale;
            renderer.AoOpacity = (float)options.AoOpacity;
            renderer.AoRadius  = (float)options.AoRadius;

            // DOF
            renderer.UseDof                      = options.UseDof;
            renderer.DofFocusPlane               = (float)options.DofFocusPlane;
            renderer.DofScale                    = (float)options.DofScale;
            renderer.UseAccumulationDof          = options.UseAccumulationDof;
            renderer.AccumulationDofBokeh        = options.AccumulationDofBokeh;
            renderer.AccumulationDofIterations   = options.AccumulationDofIterations;
            renderer.AccumulationDofApertureSize = (float)options.AccumulationDofApertureSize;

            // Lights
            renderer.DeserializeLights(DarkLightTag.Extra, JArray.Parse(options.SerializedLights ?? @"[]").OfType <JObject>());
            renderer.TryToGuessCarLights = options.TryToGuessCarLights;
            renderer.LoadCarLights       = options.LoadCarLights;
            renderer.LoadShowroomLights  = options.LoadShowroomLights;
        }
Ejemplo n.º 10
0
        private static void SetRendererOptions(DarkKn5ObjectRenderer renderer, DarkPreviewsOptions options)
        {
            // Obvious fixed settings
            renderer.AutoRotate           = false;
            renderer.AutoAdjustTarget     = false;
            renderer.AsyncTexturesLoading = false;

            // UI should be off!
            renderer.VisibleUi = false;

            // Size-related options
            renderer.Width  = (int)(options.PreviewWidth * options.SsaaMultiplier);
            renderer.Height = (int)(options.PreviewHeight * options.SsaaMultiplier);
            renderer.ResolutionMultiplier = 1d;
            renderer.UseFxaa         = options.UseFxaa;
            renderer.UseSmaa         = options.UseSmaa;
            renderer.UseMsaa         = options.UseMsaa;
            renderer.MsaaSampleCount = options.MsaaSampleCount;

            // Switches
            renderer.ShowWireframe = options.WireframeMode;
            renderer.MeshDebug     = options.MeshDebugMode;

            // Flat mirror
            renderer.FlatMirror               = options.FlatMirror;
            renderer.FlatMirrorBlurred        = options.FlatMirrorBlurred;
            renderer.FlatMirrorReflectiveness = (float)options.FlatMirrorReflectiveness;

            // Cool effects
            renderer.CubemapAmbient      = options.CubemapAmbient;
            renderer.CubemapAmbientWhite = options.CubemapAmbientWhite;
            renderer.UseBloom            = options.UseBloom;
            renderer.EnableShadows       = options.EnableShadows;
            renderer.UsePcss             = options.UsePcss;
            renderer.ShadowMapSize       = options.ShadowMapSize;
            renderer.UseSslr             = options.UseSslr;
            renderer.UseAo  = options.UseAo;
            renderer.AoType = options.AoType;
            renderer.ReflectionCubemapAtCamera = options.ReflectionCubemapAtCamera;
            renderer.ReflectionsWithShadows    = options.ReflectionsWithShadows;

            // Colors
            renderer.BackgroundColor = options.BackgroundColor;
            renderer.LightColor      = options.LightColor;
            renderer.AmbientUp       = options.AmbientUp;
            renderer.AmbientDown     = options.AmbientDown;

            // Brightnesses
            renderer.AmbientBrightness    = (float)options.AmbientBrightness;
            renderer.BackgroundBrightness = (float)options.BackgroundBrightness;
            renderer.LightBrightness      = (float)options.LightBrightness;
            renderer.Light = ToVector3(options.LightDirection);

            // Color
            renderer.ToneMapping      = options.ToneMapping;
            renderer.UseColorGrading  = options.UseColorGrading;
            renderer.ToneExposure     = (float)options.ToneExposure;
            renderer.ToneGamma        = (float)options.ToneGamma;
            renderer.ToneWhitePoint   = (float)options.ToneWhitePoint;
            renderer.ColorGradingData = options.ColorGradingData;

            // Extra
            renderer.BloomRadiusMultiplier   = (float)(options.SsaaMultiplier * options.BloomRadiusMultiplier);
            renderer.MaterialsReflectiveness = (float)options.MaterialsReflectiveness;
            renderer.PcssLightScale          = (float)options.PcssLightScale;
            renderer.PcssSceneScale          = (float)options.PcssSceneScale;
            renderer.AoOpacity = (float)options.SsaoOpacity;

            // DOF
            renderer.UseDof                      = options.UseDof;
            renderer.DofFocusPlane               = (float)options.DofFocusPlane;
            renderer.DofScale                    = (float)options.DofScale;
            renderer.UseAccumulationDof          = options.UseAccumulationDof;
            renderer.AccumulationDofIterations   = options.AccumulationDofIterations;
            renderer.AccumulationDofApertureSize = (float)options.AccumulationDofApertureSize;

            // Lights
            AcToolsLogging.Write(options.SerializedLights);
            renderer.DeserializeLights(DarkLightTag.Extra, JArray.Parse(options.SerializedLights ?? @"[]").OfType <JObject>());
        }
Ejemplo n.º 11
0
        private static void SetRendererOptions(DarkKn5ObjectRenderer renderer, DarkPreviewsOptions options)
        {
            // Obvious fixed settings
            renderer.AutoRotate           = false;
            renderer.AutoAdjustTarget     = false;
            renderer.AsyncTexturesLoading = false;

            // Size-related options
            renderer.Width                 = (int)(options.PreviewWidth * options.SsaaMultiplier);
            renderer.Height                = (int)(options.PreviewHeight * options.SsaaMultiplier);
            renderer.UseFxaa               = options.UseFxaa;
            renderer.UseSmaa               = options.UseSmaa;
            renderer.UseMsaa               = options.UseMsaa;
            renderer.MsaaSampleCount       = options.MsaaSampleCount;
            renderer.KeepFxaaWhileShooting = true;

            // Switches
            renderer.ShowWireframe   = options.WireframeMode;
            renderer.MeshDebug       = options.MeshDebugMode;
            renderer.SuspensionDebug = options.SuspensionDebugMode;

            // Flat mirror
            renderer.FlatMirror               = options.FlatMirror;
            renderer.FlatMirrorBlurred        = options.FlatMirrorBlurred;
            renderer.FlatMirrorReflectiveness = (float)options.FlatMirrorReflectiveness;

            // Cool effects
            renderer.CubemapAmbient      = options.CubemapAmbient;
            renderer.CubemapAmbientWhite = options.CubemapAmbientWhite;
            renderer.UseBloom            = options.UseBloom;
            renderer.EnableShadows       = options.EnableShadows;
            renderer.UsePcss             = options.UsePcss;
            renderer.ShadowMapSize       = options.ShadowMapSize;
            renderer.UseSslr             = options.UseSslr;
            renderer.UseAo  = options.UseAo;
            renderer.AoType = options.AoType;
            renderer.ReflectionCubemapAtCamera = options.ReflectionCubemapAtCamera;
            renderer.ReflectionsWithShadows    = options.ReflectionsWithShadows;

            // Colors
            renderer.BackgroundColor = options.BackgroundColor;
            renderer.LightColor      = options.LightColor;
            renderer.AmbientUp       = options.AmbientUp;
            renderer.AmbientDown     = options.AmbientDown;

            // Brightnesses
            renderer.AmbientBrightness    = (float)options.AmbientBrightness;
            renderer.BackgroundBrightness = (float)options.BackgroundBrightness;
            renderer.LightBrightness      = (float)options.LightBrightness;
            renderer.Light = ToVector3(options.LightDirection);

            // Color
            renderer.ToneMapping      = options.ToneMapping;
            renderer.UseColorGrading  = options.UseColorGrading;
            renderer.ToneExposure     = (float)options.ToneExposure;
            renderer.ToneGamma        = (float)options.ToneGamma;
            renderer.ToneWhitePoint   = (float)options.ToneWhitePoint;
            renderer.ColorGradingData = options.ColorGradingData;

            // Extra
            renderer.BloomRadiusMultiplier   = (float)(options.SsaaMultiplier * options.BloomRadiusMultiplier);
            renderer.MaterialsReflectiveness = (float)options.MaterialsReflectiveness;
            renderer.PcssLightScale          = (float)options.PcssLightScale;
            renderer.PcssSceneScale          = (float)options.PcssSceneScale;
            renderer.AoOpacity = (float)options.SsaoOpacity;
        }