How to output an object to upper left corner HelloSupport Junior Member Posts: 16 Threads: 7 Joined: Jul 2019 Reputation: 0 08-04-2024, 01:53 AM I have a diagram that I wish to start in the upper left corner.  I can do this setting the camera with FitIntoView but I don't want the entire diagram to be displayed.    My understanding is that position (0, 0, 0)  is the center of the screen and if I make the X coordinate of an objet negative, the object location moves to the left.   In your sample code Lines3DSample, the first line is drawn with:                 How do I calculate the StartPosition so that that line starts in the upper left hand corner? Find Reply abenedik Administrator Posts: 731 Threads: 8 Joined: Sep 2009 Reputation: 35 08-13-2024, 10:30 AM 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 Find Reply

Forum Jump:

 Users browsing this thread: 1 Guest(s)