public void HandleTurningAdjustments(KeyboardActions _kbdActions, int _msticks) { Vector3 _cameraActionRotation = Vector3.Zero; var angle = (float)_msticks * 0.075f; if (_kbdActions.Action(KeyboardActions.ActionType.YawLeft)) { _cameraActionRotation.Z = -angle; } if (_kbdActions.Action(KeyboardActions.ActionType.YawRight)) { _cameraActionRotation.Z = angle; } if (_kbdActions.Action(KeyboardActions.ActionType.Dive)) { _cameraActionRotation.X = -angle; } if (_kbdActions.Action(KeyboardActions.ActionType.Pitch)) { _cameraActionRotation.X = angle; } if (_kbdActions.Action(KeyboardActions.ActionType.RollLeft)) { _cameraActionRotation.Y = -angle; } if (_kbdActions.Action(KeyboardActions.ActionType.RollRight)) { _cameraActionRotation.Y = angle; } if (_cameraActionRotation.LengthSquared > 0) { _cameraDir.X = BoundedAngle(_cameraDir.X + _cameraActionRotation.X); _cameraDir.Y = BoundedAngle(_cameraDir.Y + _cameraActionRotation.Y); _cameraDir.Z = BoundedAngle(_cameraDir.Z + _cameraActionRotation.Z); // rotate camera by asked value // Limit camera pitch if (_cameraDir.X < 0 && _cameraDir.X > -90) { _cameraDir.X = 0; } if (_cameraDir.X > 180 || _cameraDir.X <= -90) { _cameraDir.X = 180; } } }
public void HandleZoomAdjustmentKeys(KeyboardActions _kbdActions, int _msticks) { var adjustment = 1.0f + ((float)_msticks * 0.002f); if (_kbdActions.Action(KeyboardActions.ActionType.ZoomIn)) { _zoom *= (float)adjustment; if (_zoom > ZoomMax) _zoom = (float)ZoomMax; } if (_kbdActions.Action(KeyboardActions.ActionType.ZoomOut)) { _zoom /= (float)adjustment; if (_zoom < ZoomMin) _zoom = (float)ZoomMin; } float newzoom = 0; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom1)) newzoom = ZoomMax; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom2)) newzoom = 100; // Factor 3 scale if (_kbdActions.Action(KeyboardActions.ActionType.Zoom3)) newzoom =33; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom4)) newzoom =11F; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom5)) newzoom =3.7F; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom6)) newzoom =1.23F; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom7)) newzoom =0.4F; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom8)) newzoom =0.133F; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom9)) newzoom = ZoomMin; if (newzoom != 0) StartZoom(newzoom, -1); }
public void HandleMovementAdjustments(KeyboardActions _kbdActions, int _msticks, float _zoom, bool elitemovement) { Vector3 _cameraActionMovement = Vector3.Zero; float zoomlimited = Math.Min(Math.Max(_zoom, 0.01F), 15.0F); var distance = _msticks * (1.0f / zoomlimited); if (_kbdActions.Shift) { distance *= 2.0F; } //Console.WriteLine("Distance " + distance + " zoom " + _zoom + " lzoom " + zoomlimited ); if (_kbdActions.Action(KeyboardActions.ActionType.Left)) { _cameraActionMovement.X = -distance; } else if (_kbdActions.Action(KeyboardActions.ActionType.Right)) { _cameraActionMovement.X = distance; } if (_kbdActions.Action(KeyboardActions.ActionType.PgUp)) // pgup/r { if (InPerspectiveMode) { _cameraActionMovement.Z = distance; } } else if (_kbdActions.Action(KeyboardActions.ActionType.PgDown)) //pgdown/f { if (InPerspectiveMode) { _cameraActionMovement.Z = -distance; } } if (_kbdActions.Action(KeyboardActions.ActionType.Up)) // w/UP { if (InPerspectiveMode) { _cameraActionMovement.Y = distance; } else { _cameraActionMovement.Z = distance; } } else if (_kbdActions.Action(KeyboardActions.ActionType.Down)) // S/Down { if (InPerspectiveMode) { _cameraActionMovement.Y = -distance; } else { _cameraActionMovement.Z = -distance; } } if (_cameraActionMovement.LengthSquared > 0) { if (!InPerspectiveMode) { elitemovement = false; } var rotZ = Matrix4.CreateRotationZ(DegreesToRadians(_cameraDir.Z)); var rotX = Matrix4.CreateRotationX(DegreesToRadians(_cameraDir.X)); var rotY = Matrix4.CreateRotationY(DegreesToRadians(_cameraDir.Y)); Vector3 requestedmove = new Vector3(_cameraActionMovement.X, _cameraActionMovement.Y, (elitemovement) ? 0 : _cameraActionMovement.Z); var translation = Matrix4.CreateTranslation(requestedmove); var cameramove = Matrix4.Identity; cameramove *= translation; cameramove *= rotZ; cameramove *= rotX; cameramove *= rotY; Vector3 trans = cameramove.ExtractTranslation(); if (elitemovement) // if in elite movement, Y is not affected { // by ASDW. trans.Y = 0; // no Y translation even if camera rotated the vector into Y components _viewtargetpos += trans; _viewtargetpos.Y -= _cameraActionMovement.Z; // translation appears in Z axis due to way the camera rotation is set up } else { _viewtargetpos += trans; } } }
public void HandleZoomAdjustmentKeys(KeyboardActions _kbdActions, int _msticks) { var adjustment = 1.0f + ((float)_msticks * 0.002f); if (_kbdActions.Action(KeyboardActions.ActionType.ZoomIn)) { _zoom *= (float)adjustment; if (_zoom > ZoomMax) { _zoom = (float)ZoomMax; } } if (_kbdActions.Action(KeyboardActions.ActionType.ZoomOut)) { _zoom /= (float)adjustment; if (_zoom < ZoomMin) { _zoom = (float)ZoomMin; } } float newzoom = 0; if (_kbdActions.Action(KeyboardActions.ActionType.Zoom1)) { newzoom = ZoomMax; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom2)) { newzoom = 100; // Factor 3 scale } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom3)) { newzoom = 33; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom4)) { newzoom = 11F; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom5)) { newzoom = 3.7F; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom6)) { newzoom = 1.23F; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom7)) { newzoom = 0.4F; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom8)) { newzoom = 0.133F; } if (_kbdActions.Action(KeyboardActions.ActionType.Zoom9)) { newzoom = ZoomMin; } if (newzoom != 0) { StartZoom(newzoom, -1); } }
public void HandleTurningAdjustments(KeyboardActions _kbdActions, int _msticks ) { Vector3 _cameraActionRotation = Vector3.Zero; var angle = (float)_msticks * 0.075f; if (_kbdActions.Action(KeyboardActions.ActionType.YawLeft)) { _cameraActionRotation.Z = -angle; } if (_kbdActions.Action(KeyboardActions.ActionType.YawRight)) { _cameraActionRotation.Z = angle; } if (_kbdActions.Action(KeyboardActions.ActionType.Dive)) { _cameraActionRotation.X = -angle; } if (_kbdActions.Action(KeyboardActions.ActionType.Pitch)) { _cameraActionRotation.X = angle; } if (_kbdActions.Action(KeyboardActions.ActionType.RollLeft)) { _cameraActionRotation.Y = -angle; } if (_kbdActions.Action(KeyboardActions.ActionType.RollRight)) { _cameraActionRotation.Y = angle; } if (_cameraActionRotation.LengthSquared > 0) { _cameraDir.X = BoundedAngle(_cameraDir.X + _cameraActionRotation.X); _cameraDir.Y = BoundedAngle(_cameraDir.Y + _cameraActionRotation.Y); _cameraDir.Z = BoundedAngle(_cameraDir.Z + _cameraActionRotation.Z); // rotate camera by asked value // Limit camera pitch if (_cameraDir.X < 0 && _cameraDir.X > -90) _cameraDir.X = 0; if (_cameraDir.X > 180 || _cameraDir.X <= -90) _cameraDir.X = 180; } }
public void HandleMovementAdjustments(KeyboardActions _kbdActions, int _msticks, float _zoom, bool elitemovement) { Vector3 _cameraActionMovement = Vector3.Zero; float zoomlimited = Math.Min(Math.Max(_zoom, 0.01F), 15.0F); var distance = _msticks * (1.0f / zoomlimited); if ( _kbdActions.Shift ) distance *= 2.0F; //Console.WriteLine("Distance " + distance + " zoom " + _zoom + " lzoom " + zoomlimited ); if (_kbdActions.Action(KeyboardActions.ActionType.Left)) { _cameraActionMovement.X = -distance; } else if (_kbdActions.Action(KeyboardActions.ActionType.Right)) { _cameraActionMovement.X = distance; } if (_kbdActions.Action(KeyboardActions.ActionType.PgUp)) // pgup/r { if (InPerspectiveMode) _cameraActionMovement.Z = distance; } else if (_kbdActions.Action(KeyboardActions.ActionType.PgDown) ) //pgdown/f { if (InPerspectiveMode) _cameraActionMovement.Z = -distance; } if (_kbdActions.Action(KeyboardActions.ActionType.Up)) // w/UP { if (InPerspectiveMode) _cameraActionMovement.Y = distance; else _cameraActionMovement.Z = distance; } else if (_kbdActions.Action(KeyboardActions.ActionType.Down)) // S/Down { if (InPerspectiveMode) _cameraActionMovement.Y = -distance; else _cameraActionMovement.Z = -distance; } if (_cameraActionMovement.LengthSquared > 0) { if (!InPerspectiveMode) elitemovement = false; var rotZ = Matrix4.CreateRotationZ(DegreesToRadians(_cameraDir.Z)); var rotX = Matrix4.CreateRotationX(DegreesToRadians(_cameraDir.X)); var rotY = Matrix4.CreateRotationY(DegreesToRadians(_cameraDir.Y)); Vector3 requestedmove = new Vector3(_cameraActionMovement.X, _cameraActionMovement.Y, (elitemovement) ? 0 : _cameraActionMovement.Z); var translation = Matrix4.CreateTranslation(requestedmove); var cameramove = Matrix4.Identity; cameramove *= translation; cameramove *= rotZ; cameramove *= rotX; cameramove *= rotY; Vector3 trans = cameramove.ExtractTranslation(); if (elitemovement) // if in elite movement, Y is not affected { // by ASDW. trans.Y = 0; // no Y translation even if camera rotated the vector into Y components _viewtargetpos += trans; _viewtargetpos.Y -= _cameraActionMovement.Z; // translation appears in Z axis due to way the camera rotation is set up } else _viewtargetpos += trans; } }