Exemplo n.º 1
0
        public void SetShowroom(string showroomKn5)
        {
            // TODO: errors handling!

            try {
                if (ShowroomNode != null)
                {
                    ShowroomNode.Dispose();
                    Scene.Remove(ShowroomNode);
                    ShowroomNode = null;
                    GC.Collect();
                }

                var node = LoadShowroom(showroomKn5);
                ShowroomNode = node;

                if (node != null)
                {
                    Scene.Insert(0, node);
                }
            } catch (Exception e) {
                AcToolsLogging.Write(e);
            } finally {
                CubemapReflection = ShowroomNode != null;
                Scene.UpdateBoundingBox();
                IsDirty     = true;
                _sceneDirty = true;
            }
        }
Exemplo n.º 2
0
        private void ApplyCarState()
        {
            var carData = CarData;

            if (carData == null)
            {
                return;
            }

            if (_dataWheels)
            {
                Kn5RenderableFile.UpdateModelMatrixInverted(CarNode);
                Kn5RenderableCar.SetWheelsByData(CarNode, carData.GetWheels(_suspensionModifiers), Matrix.Invert(carData.GetGraphicMatrix()));
            }

            Kn5RenderableCar.AdjustPosition(CarNode);

            if (_leftDoorOpen)
            {
                Kn5RenderableCar.CreateAnimator(carData.CarDirectory, carData.GetLeftDoorAnimation())?.SetImmediate(CarNode, 1f, null);
            }

            if (_rightDoorOpen)
            {
                Kn5RenderableCar.CreateAnimator(carData.CarDirectory, carData.GetRightDoorAnimation())?.SetImmediate(CarNode, 1f, null);
            }

            if (_headlightsEnabled)
            {
                foreach (var animation in carData.GetLightsAnimations())
                {
                    Kn5RenderableCar.CreateAnimator(carData.CarDirectory, animation)?.SetImmediate(CarNode, 1f, null);
                }
            }

            Kn5RenderableCar.SetCockpitLrActive(CarNode, _cockpitLrActive);
            Kn5RenderableCar.SetSeatbeltActive(CarNode, _seatbeltOnActive);
            Kn5RenderableCar.SetBlurredObjects(CarNode, carData.GetBlurredObjects().ToArray(), _blurredNodesActive ? 100f : 0f);

            if (_wingsStates != null)
            {
                var i = 0;
                foreach (var animation in carData.GetWingsAnimations())
                {
                    if (_wingsStates[i++])
                    {
                        Kn5RenderableCar.CreateAnimator(carData.CarDirectory, animation)?.SetImmediate(CarNode, 1f, null);
                    }
                }
            }

            if (_extraAnimationsStates != null)
            {
                var i = 0;
                foreach (var animation in carData.GetExtraAnimations())
                {
                    if (_extraAnimationsStates[i++])
                    {
                        Kn5RenderableCar.CreateAnimator(carData.CarDirectory, animation)?.SetImmediate(CarNode, 1f, null);
                    }
                }
            }
        }
Exemplo n.º 3
0
 protected override void InitializeInner()
 {
     DeviceContextHolder.Set <IMaterialsFactory>(new UvMaterialsFactory());
     _carNode = new Kn5RenderableFile(_kn5, Matrix.Identity);
 }