Ejemplo n.º 1
0
        private void SetBodyShadowCamera()
        {
            var size = CarNode.BoundingBox?.GetSize().Length() ?? 4f;

            _shadowCamera = new CameraOrtho {
                Width          = size,
                Height         = size,
                NearZ          = 1f,
                FarZ           = 20f,
                DisableFrustum = true
            };
            _shadowCamera.SetLens(1f);
        }
Ejemplo n.º 2
0
        private void SetWheelShadowCamera()
        {
            _shadowSize = CarData?.GetWheelShadowSize() * (1f + 2f * WheelPadding / WheelSize) ?? new Vector3(1f, 0f, 1f);
            var size = Math.Max(_shadowSize.X, _shadowSize.Z) * 2f;

            _shadowCamera = new CameraOrtho {
                Width          = size,
                Height         = size,
                NearZ          = 0.001f,
                FarZ           = size + 20f,
                DisableFrustum = true
            };
            _shadowCamera.SetLens(1f);
            _shadowDestinationTransform = Matrix.Scaling(new Vector3(-_shadowSize.X, _shadowSize.Y, _shadowSize.Z)) * Matrix.RotationY(MathF.PI);
        }
Ejemplo n.º 3
0
        private void SetBodyShadowCamera()
        {
            _shadowSize = _ambientBodyShadowSize * (1f + 2f * BodyPadding / BodySize);
            var size = Math.Max(_shadowSize.X, _shadowSize.Z) * 2f;

            _shadowCamera = new CameraOrtho {
                Width          = size,
                Height         = size,
                NearZ          = 0.001f,
                FarZ           = size + 20f,
                DisableFrustum = true
            };
            _shadowCamera.SetLens(1f);
            _shadowDestinationTransform = Matrix.Scaling(new Vector3(-_shadowSize.X, _shadowSize.Y, _shadowSize.Z)) * Matrix.RotationY(MathF.PI);
        }
Ejemplo n.º 4
0
            public override void LookAt(Vector3 pos, Vector3 target, Vector3 up)
            {
                base.LookAt(pos, target, up);

                if (!Equals(_innerCamera.FarZ, FarZ))
                {
                    _innerCamera.Aspect = Aspect;
                    _innerCamera.NearZ  = NearZ;
                    _innerCamera.FarZ   = FarZ;
                    _innerCamera.Width  = Width * 0.95f;
                    _innerCamera.Height = Height * 0.95f;
                    _innerCamera.SetLens(1f);
                }

                _innerCamera.LookAt(pos, target, up);
            }
Ejemplo n.º 5
0
            private CameraOrtho GetCamera(DeviceContextHolder holder)
            {
                if (_camera == null)
                {
                    if (_dirty)
                    {
                        Initialize(holder);
                    }

                    var laneBox = _obj.BoundingBox ?? new BoundingBox();

                    var boxWidth  = DataSize.X;
                    var boxHeight = DataSize.Y;
                    var boxMinX   = -DataOffset.X + DataMargin;
                    var boxMinY   = -DataOffset.Y + DataMargin;

                    var box = new BoundingBox(
                        new Vector3(boxMinX, laneBox.Minimum.Y, boxMinY),
                        new Vector3(boxMinX + boxWidth, laneBox.Maximum.Y, boxMinY + boxHeight));

                    _camera = new CameraOrtho {
                        Position       = new Vector3(box.GetCenter().X, box.Maximum.Y + 1f, box.GetCenter().Z),
                        FarZ           = box.GetSize().Y + 2f,
                        Target         = box.GetCenter(),
                        Up             = new Vector3(0.0f, 0.0f, -1.0f),
                        Width          = box.GetSize().X + 2 * DataMargin,
                        Height         = box.GetSize().Z + 2 * DataMargin,
                        DisableFrustum = true
                    };

                    _camera.SetLens();
                    _camera.UpdateViewMatrix();
                }

                return(_camera);
            }
Ejemplo n.º 6
0
 public CameraOrthoShadow()
 {
     _innerCamera = new CameraOrtho();
     _innerCamera.SetLens(1f);
 }