Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.67 KB | None | 0 0
  1. procedure TMainForm.SetCameraDistance(Distance: Single);
  2. begin
  3.   fCameraDistance := Distance;
  4.  
  5.   // To be at 45 degrees to the map we'll need to offset two coords by this much:
  6.   var Offset := Distance / Sqrt(2);
  7.  
  8.   // And we can work out how high we need to be at this distance to be looking at 0, 0, 0
  9.   var Height := Distance * Tan(DegToRad(30));
  10.  
  11.   // Rotate and move camera so it is looking 45 degrees around and 30 degrees down
  12.   // and set the view angle to a very small value to remove perspective
  13.   Camera.RotationAngle.Point := TPoint3D.Create(-30, 45, 0);
  14.   Camera.Position.Point := TPoint3D.Create(-Offset, -Height, -Offset);
  15.   Camera.AngleOfView := 1;
  16. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement