Inheritance: RenderableList
Exemple #1
0
        private void UPinit()
        {
            if (!_up)
            {
                _up = true;

                _l = new Kn5RenderableList(Kn5Node.CreateBaseNode("L"), null)
                {
                    LocalMatrix    = Matrix.Translation(_swRadius, 0, _swOffset),
                    HighlightDummy = true
                };
                _r = new Kn5RenderableList(Kn5Node.CreateBaseNode("R"), null)
                {
                    LocalMatrix    = Matrix.Translation(-_swRadius, 0, _swOffset),
                    HighlightDummy = true
                };

                _dbg0 = new Kn5RenderableList(Kn5Node.CreateBaseNode("debug"), null)
                {
                    HighlightDummy = true
                };

                _dbg1 = new Kn5RenderableList(Kn5Node.CreateBaseNode("debug"), null)
                {
                    HighlightDummy = true
                };

                //_steer.Add(_l);
                //_steer.Add(_r);

                _la = new Arm(_driver, true);
                _ra = new Arm(_driver, false);
            }
        }
Exemple #2
0
        protected override void InitializeInner() {
            _materialsProvider = new UvMaterialProvider();
            DeviceContextHolder.Set(_materialsProvider);

            _materialsProvider.SetKn5(_kn5);
            _carNode = (Kn5RenderableList)Kn5Converter.Convert(_kn5.RootNode, DeviceContextHolder);
        }
Exemple #3
0
            internal Arm(Kn5RenderableDriver _driver, bool isLeft)
            {
                var s = isLeft ? "L" : "R";

                _side = isLeft ? 1f : -1f;

                _clave      = _driver.GetDummyByName($"DRIVER:RIG_Clave_{s}");
                _arm        = _driver.GetDummyByName($"DRIVER:RIG_Arm_{s}");
                _forearm    = _driver.GetDummyByName($"DRIVER:RIG_ForeArm_{s}");
                _forearmEnd = _driver.GetDummyByName($"DRIVER:RIG_ForeArm_END_{s}");
                _hand       = _driver.GetDummyByName($"DRIVER:RIG_HAND_{s}");

                _index = _hand?.GetDummyByName(isLeft ? "DRIVER:HAND_Index1" : "DRIVER:HAND_Index4");
                _thumb = _hand?.GetDummyByName($"DRIVER:HAND_{s}_Thumb3");

                _indexf = new Finger(new[] {
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Index1" : "DRIVER:HAND_Index4",
                                  new Vector3(-3f, -5f, _side * -20.5f), new Vector3(-3f, -5f, _side * -67.5f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Index2" : "DRIVER:HAND_Index5",
                                  new Vector3(-2.7f, 0.2f, _side * -10.5f), new Vector3(-2.7f, 0.2f, _side * -34f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Index3" : "DRIVER:HAND_Index6",
                                  new Vector3(0.5f, -2.2f, _side * -4.5f), new Vector3(0.5f, -2.2f, _side * -32.5f))
                });

                _middle = new Finger(new[] {
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Middle1" : "DRIVER:HAND_Middle4",
                                  new Vector3(10f, -1f, _side * -20.5f), new Vector3(10f, -1f, _side * -72.5f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Middle2" : "DRIVER:HAND_Middle5",
                                  new Vector3(-2f, 1f, _side * -10.5f), new Vector3(-2f, 1f, _side * -39f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Middle3" : "DRIVER:HAND_Middle6",
                                  new Vector3(3.6f, -3.9f, _side * -4.5f), new Vector3(3.6f, -3.9f, _side * -32.5f))
                });

                _ring = new Finger(new[] {
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Ring1" : "DRIVER:HAND_Ring4",
                                  new Vector3(11.5f, 5f, _side * -20.5f), new Vector3(11.5f, 5f, _side * -83.5f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Ring2" : "DRIVER:HAND_Ring5",
                                  new Vector3(0, 0, _side * -10.5f), new Vector3(0, 0, _side * -41f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Ring3" : "DRIVER:HAND_Ring6",
                                  new Vector3(0, 0, _side * -4.5f), new Vector3(0, 0, _side * -32.5f))
                });

                _pinkie = new Finger(new[] {
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Pinkie1" : "DRIVER:HAND_Pinkie4",
                                  new Vector3(12.16f, 3.4f, _side * -20.5f), new Vector3(12.16f, 3.4f, _side * -87.5f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Pinkie2" : "DRIVER:HAND_Pinkie5",
                                  new Vector3(-2f, 3f, _side * -10.5f), new Vector3(-2f, 3f, _side * -45f)),
                    new FingerBit(_hand, isLeft ? "DRIVER:HAND_Pinkie3" : "DRIVER:HAND_Pinkie6",
                                  new Vector3(-1.1f, -1.9f, _side * -4.5f), new Vector3(-1.1f, -1.9f, _side * -32.5f))
                });

                Init();
            }
Exemple #4
0
                public FingerBit(Kn5RenderableList parent, string name, Vector3 relaxedRotation, Vector3 grabbyRotation)
                {
                    Node = parent.GetDummyByName(name);
                    if (Node == null)
                    {
                        return;
                    }

                    _translation     = Node.LocalMatrix.GetTranslationVector();
                    _relaxedRotation = relaxedRotation * MathF.ToRad;
                    _grabbyRotation  = grabbyRotation * MathF.ToRad;
                    _relaxed         = Quaternion.RotationYawPitchRoll(relaxedRotation.X, relaxedRotation.Y, relaxedRotation.Z);
                    _grabby          = Quaternion.RotationYawPitchRoll(grabbyRotation.X, grabbyRotation.Y, grabbyRotation.Z);
                }
        private void LoadAndAdjustKn5() {
            _materialsProvider = new DepthMaterialProvider();
            _texturesProvider = new TexturesProvider();
            DeviceContextHolder.Set(_materialsProvider);
            DeviceContextHolder.Set(_texturesProvider);

            _materialsProvider.SetKn5(_kn5);

            _carNode = (Kn5RenderableList)Kn5Converter.Convert(_kn5.RootNode, DeviceContextHolder);
            _scene.Add(_carNode);

            _carNode.UpdateBoundingBox();
            _carNode.LocalMatrix = Matrix.Translation(0, UpDelta - (_carNode.BoundingBox?.Minimum.Y ?? 0f), 0) * _carNode.LocalMatrix;
            _scene.UpdateBoundingBox();
        }
Exemple #6
0
        private Matrix GetWheelAmbientShadowMatrix([NotNull] Kn5RenderableList wheel)
        {
            // try to get information about the wheel if available
            var desc = _wheelsDesc?.FirstOrDefault(x => wheel.Name?.EndsWith(x.Name) == true);

            // find relative-to-car wheel matrix
            Matrix wheelMatrix;

            if (desc == null)
            {
                UpdateModelMatrixInverted();
                wheelMatrix = wheel.Matrix * wheel.ModelMatrixInverted;
            }
            else
            {
                wheelMatrix = GetWheelMatrix(desc, true) * _wheelsFixMatrix;
            }

            // calculate shadow position
            var translation = wheelMatrix.GetTranslationVector();

            // offset if needed
            translation += _carData.GetWheelGraphicOffset(wheel.Name);

            // for properly set wheels, calculate offset
            if (desc != null)
            {
                var down = Vector3.TransformNormal(-Vector3.UnitY, wheelMatrix);
                translation.X += down.X * (wheel.BoundingBox?.GetSize().Y ?? 0f) / 2f;
            }

            // move the shadow down
            translation.Y = _shadowsHeight;

            return(Matrix.Scaling(_carData.GetWheelShadowSize()) *            // shadow size
                   Matrix.RotationY(MathF.PI - _steerDeg * MathF.PI / 180f) * // steering
                   Matrix.Translation(translation));
        }
Exemple #7
0
 public Up(Kn5RenderableDriver driver, Kn5RenderableList steer)
 {
     _driver = driver;
     _steer  = steer;
 }
Exemple #8
0
 private void LoadLights(Kn5RenderableList node) {
     CarLights = _carHelper.LoadLights<DeferredCarLight>(node).ToList();
     Lights.AddRange(CarLights);
 }
        protected override void InitializeInner() {
            base.InitializeInner();

            MaterialsProvider = new MaterialsProviderSimple();
            TexturesProvider = new TexturesProvider();
            DeviceContextHolder.Set(MaterialsProvider);
            DeviceContextHolder.Set(TexturesProvider);
            
            CarHelper.SetKn5(DeviceContextHolder);
            CarHelper.SkinTextureUpdated += (sender, args) => IsDirty = true;

            var node = Kn5Converter.Convert(Kn5.RootNode, DeviceContextHolder);
            Scene.Add(node);

            CarNode = node as Kn5RenderableList;
            if (CarNode != null) {
                Scene.InsertRange(0, CarHelper.LoadAmbientShadows(CarNode, 0f));
                CarHelper.AdjustPosition(CarNode);
                CarHelper.LoadMirrors(CarNode, DeviceContextHolder);

                _carLights = CarHelper.LoadLights(CarNode).ToList();
            }

            Scene.UpdateBoundingBox();
            TrianglesCount = node.TrianglesCount;
            ObjectsCount = node.ObjectsCount;

            Camera = CreateCamera(node);
            _resetCamera = (CameraOrbit)Camera.Clone();

            if (_selectSkin != null) {
                SelectSkin(_selectSkin);
                _selectSkin = null;
            }
        }
Exemple #10
0
 public virtual void Initialize(CarLightType type, Kn5RenderableList main, IniFileSection section) {
     Type = type;
     Name = section.GetNonEmpty("NAME");
     Emissive = section.GetVector3("COLOR").Select(y => (float)y).ToArray().ToVector3();
     Node = main.GetByName(Name);
 }