How to output an object to upper left corner
#2
If you are using TargetPositionCamera and TragetPosition is set to (0,0,0), Heading = 0 and Attitude = 0, then (0,0,0) is in the center of the view.

If you are using an orthographic camera (targetPositionCamera.ProjectionType = ProjectionTypes.Orthographic), then this is much easier to achieve. In this case you set the ViewWidth that is defined in 3D space coordinates. The ViewHeight is defined as (ViewWidth * SceneView.Height) / SceneView.Width.

For example, if  ViewWidth is 400 (showing positions from -200 to +200) and SceneView.Width == SceneView.Height and TragetPosition is set to (0,0,0), Heading = 0 and Attitude = 0, then the top left position is (-200, -200, z is any value).

If you are using a perspective projection type (by default), then this is much more complicated, because the X and Y coordinates are affected by the distance to the camera. In this case you need to use Math.Tan to calculate the offset:

   
In this case fi angle is camera's FieldOfView angle (this needs to be converted into radians("/ 180 * MathPI")):
MathF.Tan((targetPositionCamera.FieldOfView / 2) / 180 * MathF.PI) = a / b.

b is the camera's Distance.
This way you can get the value a that that tells you how much you need to move the camera.
Andrej Benedik
  


Messages In This Thread
RE: How to output an object to upper left corner - by abenedik - 08-13-2024, 10:30 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)