Package raymarcher.meshes
Class Box
java.lang.Object
raymarcher.meshes.Box
- All Implemented Interfaces:
Mesh
public class Box extends java.lang.Object implements Mesh
An implementation of the Mesh interface that renders a box (rectangular prism).
Can also be used to produce 2D planes or rectangles if an axis' dimensions is 0.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description java.awt.Color
getMeshColor()
Gives the mesh's colorVector3
getPosition()
Vector3
getSize()
double
sdf(Vector3 position)
The signed distance function for the mesh, which tells the mesh's distance to a point in 3D spacevoid
setMeshColor(java.awt.Color meshColor)
void
setPosition(Vector3 position)
void
setSize(Vector3 size)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
position
The position of the box's center -
size
A vector representing the box's dimensions -
meshColor
private java.awt.Color meshColorThe color of the mesh
-
-
Constructor Details
-
Box
Create a box mesh- Parameters:
position
- The position in 3D space to center the boxsize
- A vector to represent the box's dimensions. The x coordinate is the length of the box in the x-axis, the y-coordinate is the height, and the z-coordinate is the widthmeshColor
- The color of the box
-
-
Method Details
-
getPosition
- Returns:
- the current position of the center of the box
-
setPosition
- Parameters:
position
- the new center of the box
-
getSize
- Returns:
- the box's current size as a vector
-
setSize
- Parameters:
size
- A vector to represent the box's new dimensions. The x-coordinate is the length of the box in the x-axis, the y-coordinate is the height, and the z-coordinate is the width
-
setMeshColor
public void setMeshColor(java.awt.Color meshColor)- Parameters:
meshColor
- The new color to set the mesh to
-
getMeshColor
public java.awt.Color getMeshColor()Description copied from interface:Mesh
Gives the mesh's color- Specified by:
getMeshColor
in interfaceMesh
- Returns:
- The color of the mesh
-
sdf
Description copied from interface:Mesh
The signed distance function for the mesh, which tells the mesh's distance to a point in 3D space- Specified by:
sdf
in interfaceMesh
- Parameters:
position
- The vector representation of the position of the point to measure the distance to- Returns:
- The signed distance of the mesh to the point. Values > 0 indicate the point is outside the mesh, values = 0 are points on the surface, and values < 0 are points inside the mesh.
-