Package raymarcher

Class Ray

java.lang.Object
raymarcher.Ray

public class Ray
extends java.lang.Object
Represents a ray shot from the camera to calculate the value of a screen pixel
  • Field Summary

    Fields
    Modifier and Type Field Description
    private Vector3 direction
    The direction in which this ray will be cast
    private double epsilon
    The maximum error for which a ray will approximate an intersection
    private Vector3 position
    The ray's starting position
    private double renderDistance
    The maximum distance the ray will render objects up to
  • Constructor Summary

    Constructors
    Constructor Description
    Ray​(Vector3 position, Vector3 direction, double renderDistance)
    Creates a ray with a given start position and direction
  • Method Summary

    Modifier and Type Method Description
    int calculate​(Scene scene)
    Calculates which color this ray will be after marching forwards
    Vector3 getDirection()  
    double getEpsilon()  
    Vector3 getPosition()  
    double getRenderDistance()  
    void setDirection​(Vector3 direction)  
    void setEpsilon​(double epsilon)  
    void setPosition​(Vector3 position)  
    void setRenderDistance​(double renderDistance)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • direction

      private Vector3 direction
      The direction in which this ray will be cast
    • position

      private Vector3 position
      The ray's starting position
    • renderDistance

      private double renderDistance
      The maximum distance the ray will render objects up to
    • epsilon

      private double epsilon
      The maximum error for which a ray will approximate an intersection
  • Constructor Details

    • Ray

      public Ray​(Vector3 position, Vector3 direction, double renderDistance)
      Creates a ray with a given start position and direction
      Parameters:
      position - the origin point of the ray in 3D space
      direction - the direction in which the ray marches
      renderDistance - the maximum distance the ray will render objects up to
  • Method Details

    • getDirection

      public Vector3 getDirection()
      Returns:
      the current direction the ray is being cast in
    • setDirection

      public void setDirection​(Vector3 direction)
      Parameters:
      direction - the new direction for the ray to be cast in
    • getPosition

      public Vector3 getPosition()
      Returns:
      the current position the ray is cast from
    • setPosition

      public void setPosition​(Vector3 position)
      Parameters:
      position - the new starting position of the ray
    • getRenderDistance

      public double getRenderDistance()
      Returns:
      the current maximum distance the ray will render to
    • setRenderDistance

      public void setRenderDistance​(double renderDistance)
      Parameters:
      renderDistance - the new maximum distance the ray will render
    • getEpsilon

      public double getEpsilon()
      Returns:
      the distance away from the object the ray will consider an intersection
    • setEpsilon

      public void setEpsilon​(double epsilon)
      Parameters:
      epsilon - the distance away from the object the ray will consider an intersection
    • calculate

      public int calculate​(Scene scene)
      Calculates which color this ray will be after marching forwards
      Parameters:
      scene - The scene which includes all meshes to search for ray hits with
      Returns:
      The color value of the pixel corresponding to this ray, as an int RGB value representing the color in the default sRGB ColorModel.