Class ViewSpaceTracker

java.lang.Object
eu.svjatoslav.sixth.e3d.gui.ViewSpaceTracker

public class ViewSpaceTracker extends Object
Tracks an object's position in view/camera space for distance and angle calculations.

Used primarily for level-of-detail (LOD) decisions based on how far and at what angle the viewer is from an object. The tracker maintains the object's center point transformed into view space, and optionally orientation axes for angle calculations.

See Also:
  • Field Details

    • center

      public Vertex center
      The object's center point (0,0,0 in object space) transformed to view space.
    • down

      public Vertex down
      Point at (0,10,0) in object space, used for YZ angle calculation. Only initialized if orientation tracking is enabled.
  • Constructor Details

    • ViewSpaceTracker

      public ViewSpaceTracker()
      Creates a new view space tracker.
  • Method Details

    • analyze

      public void analyze(TransformStack transformPipe, RenderingContext renderingContext)
      Transforms the tracked points from object space to view space.
      Parameters:
      transformPipe - the current transform stack
      renderingContext - the rendering context for frame info
    • enableOrientationTracking

      public void enableOrientationTracking()
      Enables tracking of orientation axes for angle calculations. Disabled by default to save computation when angles are not needed.
    • getAngleXY

      public double getAngleXY(RenderingContext renderingContext)
      Returns the angle between the viewer and object in the XY plane.
      Returns:
      the XY angle in radians
    • getAngleXZ

      public double getAngleXZ(RenderingContext renderingContext)
      Returns the angle between the viewer and object in the XZ plane.
      Returns:
      the XZ angle in radians
    • getAngleYZ

      public double getAngleYZ(RenderingContext renderingContext)
      Returns the angle between the viewer and object in the YZ plane.
      Returns:
      the YZ angle in radians
    • getDistanceToCamera

      public double getDistanceToCamera(RenderingContext renderingContext)
      Returns the distance from the camera to the object's center. Used for level-of-detail calculations.
      Returns:
      the distance in world units