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 Summary

    Fields
    Modifier and Type
    Field
    Description
    The object's center point (0,0,0 in object space) transformed to view space.
    Point at (0,10,0) in object space, used for YZ angle calculation.
    Point at (10,0,0) in object space, used for XZ angle calculation.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    analyze(TransformStack transformPipe, RenderingContext renderingContext)
    Transforms the tracked points from object space to view space.
    void
    Enables tracking of orientation axes for angle calculations.
    double
    Returns the angle between the viewer and object in the XY plane.
    double
    Returns the angle between the viewer and object in the XZ plane.
    double
    Returns the angle between the viewer and object in the YZ plane.
    double
    Returns the distance from the camera to the object's center.
    double
    Proposes a slice factor for texture LOD based on distance to camera.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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()
  • 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()
      Returns the angle between the viewer and object in the XY plane.
      Returns:
      the XY angle in radians
    • getAngleXZ

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

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

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

      public double proposeSliceFactor()
      Proposes a slice factor for texture LOD based on distance to camera.
      Returns:
      the proposed slice factor