Good day, comrades!
I got little problem with Camera.Direction.
When i was make minimap, i use radians for rotation of TCastleTransform.
It seems like:
, where LookTo is a number 0, 1, 2…, 7. Zero is a look to the north, 1 - to the north-east and seven - north-west; RDir - rotation direction, 1 or -1 (in real this code bigger for smooth rotation, but this is principal part to set position).
So, when i multiply 45 deegres (Pi*0.25) to 0-7, i get angle of rotation. It works nice with minimap TCastleTransforms.
But it work wrong with camera in 3D scene: only .LookTo := 7, 1 or 0 can set camera to the right position, other values don’t move they. I observe to .LookTo and radians calculation in console, howewer they are ok. Moreover, minimap use this variables too and work like they must, but camera freezed between .LookTo 1 and 7.
I maked simple procedure for set camera inside .Update:
procedure CameraRotation(var Viewport: TCastleViewport; var Player: THero);
begin
Viewport.Camera.Direction := Vector3(-Pi * 0.25 * Player.LookTo, 0, 0);
end;
This is results in console: (.LookTo / radians; Camera doesn’t change position between 1 and 7):
Rotate using Rotation. The rotation is performed around the Center point. The rotation may be alternatively controlled using the Direction and Up vectors.
Thanks.
Sometimes i incorrectly understand documentation… Must take more time to English learning
So, i think to use .Rotation to camera, because it will allow use same procedure for two Viewports - minimap and environment observer… Or .Direction can take something benefits in compare with .Rotation in my case?
Underneath, both ways (setting Rotation or setting Direction) are equivalent. That is, setting Direction internally actually just uses OrientationFromDirectionUp and then it sets the Rotation.
So use whichever one it is simpler to “think about” in a particular case.