Ejemplo n.º 1
0
        protected override void InitializeInner()
        {
            base.InitializeInner();
            DeviceContextHolder.Set <IMaterialsFactory>(new MaterialsProviderDeferred());

            Scene.Add(SkyObject.Create(500f));

            foreach (var showroom in _kn5.Skip(1))
            {
                Scene.Add(new Kn5RenderableFile(showroom, Matrix.Identity));
            }

            if (_kn5.Length > 1)
            {
                _car = new DeferredRenderableCar(CarDescription.FromKn5(_kn5[0]), Matrix.Identity, shadowsHeight: 0.001f, lights: Lights)
                {
                    IsReflectable = false
                };
                Scene.Add(_car);
            }

            Scene.UpdateBoundingBox();

            Camera = new CameraOrbit(32)
            {
                Alpha  = 0.9f,
                Beta   = 0.1f,
                Radius = _car?.BoundingBox?.GetSize().Length() * 1.2f ?? 4.8f,
                Target = (_car?.BoundingBox?.GetCenter() ?? Vector3.Zero) - new Vector3(0f, 0.05f, 0f)
            };

            _resetCamera = (CameraOrbit)Camera.Clone();

            Sun = new DirectionalLight {
                Color     = FixLight(new Vector3(1.2f, 1.0f, 0.9f)) * 5f,
                Direction = Vector3.Normalize(new Vector3(-1.2f, -3.4f, -2.2f))
            };

            _effect = DeviceContextHolder.GetEffect <EffectDeferredGObject>();
        }