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 castprivate double
epsilon
The maximum error for which a ray will approximate an intersectionprivate Vector3
position
The ray's starting positionprivate double
renderDistance
The maximum distance the ray will render objects up to -
Constructor Summary
-
Method Summary
Modifier and Type Method Description int
calculate(Scene scene)
Calculates which color this ray will be after marching forwardsVector3
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
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
.
-