예제 #1
0
        protected override void InitializeInner()
        {
            base.InitializeInner();

            DeviceContextHolder.Set(GetMaterialsFactory());

            if (_showroomKn5Filename != null)
            {
                ShowroomNode = LoadShowroom(_showroomKn5Filename);
                Scene.Insert(0, ShowroomNode);
            }

            _carWrapper = new RenderableList();
            Scene.Add(_carWrapper);

            if (_car != null)
            {
                var carNode = new Kn5RenderableCar(_car, Matrix.Identity, _selectSkinLater ? _selectSkin : Kn5RenderableCar.DefaultSkin,
                                                   asyncTexturesLoading: AsyncTexturesLoading, asyncOverrideTexturesLoading: AsyncOverridesLoading,
                                                   allowSkinnedObjects: AllowSkinnedObjects);
                CarNode = carNode;
                CopyValues(carNode, null);

                _selectSkinLater = false;
                _carWrapper.Add(carNode);
                _carBoundingBox = null;

                ExtendCar(CarNode, _carWrapper);
            }

            // Scene.Add(new Kn5RenderableFile(Kn5.FromFile(_carKn5), Matrix.Identity));

            Scene.UpdateBoundingBox();

            _reflectionCubemap?.Initialize(DeviceContextHolder);

            if (EnableShadows)
            {
                _shadows = CreateShadows();
                _shadows?.Initialize(DeviceContextHolder);
            }

            if (Camera == null)
            {
                Camera       = CreateCamera(CarNode);
                _resetCamera = (CameraOrbit)Camera.Clone();
                PrepareCamera(Camera);
            }

            DeviceContextHolder.SceneUpdated    += OnSceneUpdated;
            DeviceContextHolder.TexturesUpdated += OnTexturesUpdated;
        }
예제 #2
0
        protected override void InitializeInner()
        {
            base.InitializeInner();

            DeviceContextHolder.Set <IMaterialsFactory>(new MaterialsProviderSimple());

            if (_showroom != null)
            {
                var kn5 = Kn5.FromFile(_showroom.Kn5Filename);
                Scene.Insert(0, new Kn5RenderableFile(kn5, Matrix.Identity));
            }

            _carWrapper = new RenderableList();
            Scene.Add(_carWrapper);

            if (_car != null)
            {
                var kn5 = Kn5.FromFile(FileUtils.GetMainCarFilename(_car.Location));
                CarNode          = new Kn5RenderableCar(kn5, _car.Location, Matrix.Identity, _selectSkinLater ? _selectSkin : Kn5RenderableCar.DefaultSkin);
                _selectSkinLater = false;
                _carWrapper.Add(CarNode);

                var reflection = new FlatMirror(CarNode, new Plane(Vector3.Zero, Vector3.UnitY));
                _carWrapper.Add(reflection);
            }

            Scene.UpdateBoundingBox();

            if (CubemapReflection)
            {
                _reflectionCubemap = new ReflectionCubemap(1024);
                _reflectionCubemap.Initialize(DeviceContextHolder);
            }

            if (EffectDarkMaterial.EnableShadows)
            {
                _shadows = new ShadowsDirectional(2048, new[] { 5f });
                _shadows.Initialize(DeviceContextHolder);
            }

            if (Camera == null)
            {
                Camera       = CreateCamera(CarNode);
                _resetCamera = (CameraOrbit)Camera.Clone();
            }
        }
        protected override void InitializeInner()
        {
            _deferredLighting = DeviceContextHolder.GetEffect <EffectDeferredLight>();
            _deferredResult   = DeviceContextHolder.GetEffect <EffectDeferredResult>();
            _ppBasic          = DeviceContextHolder.GetEffect <EffectPpBasic>();

            _gDepthBuffer  = TargetResourceDepthTexture.Create();
            _gBufferBase   = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _gBufferNormal = TargetResourceTexture.Create(Format.R32G32B32A32_Float);
            _gBufferMaps   = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm);

            _temporaryDepthBuffer = TargetResourceDepthTexture.Create();
            _temporaryBuffer0     = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _temporaryBuffer1     = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _temporaryBuffer2     = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _temporaryBuffer3     = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _outputBuffer         = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm);

            _reflectionCubemap = new ReflectionCubemap(1024);
            _reflectionCubemap.Initialize(DeviceContextHolder);

            _sunShadows = new ShadowsDirectional(2048);
            _sunShadows.Initialize(DeviceContextHolder);
        }