protected override void OnActivated() { base.OnActivated(); this.boundingSphere = new BoundingSphere(this.transform3D.Position, (this.transform3D.Scale.X / 2) + 0.5f); this.activeCamera3D = this.Owner.Scene.Managers.RenderManager.ActiveCamera3D; this.mouseDispatcher = activeCamera3D.Display.MouseDispatcher; }
/// <inheritdoc/> protected override void Update(TimeSpan gameTime) { if (this.mouseDispatcher == null) { var display = this.Managers.RenderManager.ActiveCamera3D?.Display; if (display != null) { this.mouseDispatcher = display.MouseDispatcher; } if (this.mouseDispatcher == null) { return; } } if (this.mouseDispatcher.IsButtonDown(MouseButtons.Right)) { var deltaRotation = this.mouseDispatcher.PositionDelta.ToVector2() * this.OrbitFactor; this.theta += deltaRotation.X; this.lambda += deltaRotation.Y; this.lambda = Math.Max(this.MinElevationAngle, Math.Min(this.MaxElevationAngle, this.lambda)); } if (this.mouseDispatcher.ScrollDelta.Y != 0) { var deltazoom = this.mouseDispatcher.ScrollDelta.Y * this.ZoomFactor; this.zoom -= deltazoom; this.zoom = Math.Max(this.MaxZoom, Math.Min(this.MinZoom, this.zoom)); } float elapsedMilliseconds = (float)gameTime.TotalMilliseconds; var direction = Quaternion.CreateFromYawPitchRoll(-this.theta, -this.lambda, 0); this.Transform.LocalOrientation = Quaternion.SmoothDamp( this.Transform.LocalOrientation, direction, ref this.objectOrbitSmoothDampDeriv, this.OrbitSmooth, elapsedMilliseconds); var localPos = this.targetTransform.LocalPosition; localPos.Z = MathHelper.SmoothDamp( localPos.Z, this.zoom, ref this.zoomVelocity, this.ZoomSmooth, elapsedMilliseconds); this.targetTransform.LocalPosition = localPos; }
protected override void OnActivated() { base.OnActivated(); this.mouseDispatcher = this.camera.Display?.MouseDispatcher; if (this.mouseDispatcher != null) { this.RegisterMouseEvents(); } this.targetPosition = this.translationPivot.Position; }
protected override void OnActivated() { base.OnActivated(); _boundingSphere = new BoundingSphere(Transform3D.Position, Transform3D.Scale.X / 2); _activeCamera3D = Owner.Scene.Managers.RenderManager.ActiveCamera3D; _mouseDispatcher = _activeCamera3D.Display.MouseDispatcher; var assetsService = Application.Current.Container.Resolve <AssetsService>(); _rayMaterial = assetsService.Load <Material>(WaveContent.Materials.RayMaterial); _sphereMaterial = assetsService.Load <Material>(WaveContent.Materials.SphereMaterial); }