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 Vector3directionThe direction in which this ray will be castprivate doubleepsilonThe maximum error for which a ray will approximate an intersectionprivate Vector3positionThe ray's starting positionprivate doublerenderDistanceThe maximum distance the ray will render objects up to -
Constructor Summary
-
Method Summary
Modifier and Type Method Description intcalculate(Scene scene)Calculates which color this ray will be after marching forwardsVector3getDirection()doublegetEpsilon()Vector3getPosition()doublegetRenderDistance()voidsetDirection(Vector3 direction)voidsetEpsilon(double epsilon)voidsetPosition(Vector3 position)voidsetRenderDistance(double renderDistance)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
direction
The direction in which this ray will be cast -
position
The ray's starting position -
renderDistance
private double renderDistanceThe maximum distance the ray will render objects up to -
epsilon
private double epsilonThe maximum error for which a ray will approximate an intersection
-
-
Constructor Details
-
Ray
Creates a ray with a given start position and direction- Parameters:
position- the origin point of the ray in 3D spacedirection- the direction in which the ray marchesrenderDistance- the maximum distance the ray will render objects up to
-
-
Method Details
-
getDirection
- Returns:
- the current direction the ray is being cast in
-
setDirection
- Parameters:
direction- the new direction for the ray to be cast in
-
getPosition
- Returns:
- the current position the ray is cast from
-
setPosition
- 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
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.
-