Package org.sunflow.core
Class Camera
- java.lang.Object
-
- org.sunflow.core.Camera
-
- All Implemented Interfaces:
RenderObject
public class Camera extends java.lang.Object implements RenderObject
This class represents a camera to the renderer. It handles the mapping of camera space to world space, as well as the mounting ofCameraLens
objects which compute the actual projection.
-
-
Field Summary
Fields Modifier and Type Field Description private MovingMatrix4
c2w
private CameraLens
lens
private float
shutterClose
private float
shutterOpen
private MovingMatrix4
w2c
-
Constructor Summary
Constructors Constructor Description Camera(CameraLens lens)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) Matrix4
getCameraToWorld(float time)
Returns a transformation matrix mapping camera space to world space.Ray
getRay(float x, float y, int imageWidth, int imageHeight, double lensX, double lensY, float time)
Generate a ray passing though the specified point on the image plane.(package private) Ray
getRay(Point3 p, float time)
Generate a ray from the origin of camera space toward the specified point.float
getTime(float time)
Computes actual time from a time sample in the interval [0,1).(package private) Matrix4
getWorldToCamera(float time)
Returns a transformation matrix mapping world space to camera space.boolean
update(ParameterList pl, SunflowAPI api)
Update this object given a list of parameters.
-
-
-
Field Detail
-
lens
private final CameraLens lens
-
shutterOpen
private float shutterOpen
-
shutterClose
private float shutterClose
-
c2w
private MovingMatrix4 c2w
-
w2c
private MovingMatrix4 w2c
-
-
Constructor Detail
-
Camera
public Camera(CameraLens lens)
-
-
Method Detail
-
update
public boolean update(ParameterList pl, SunflowAPI api)
Description copied from interface:RenderObject
Update this object given a list of parameters. This method is guarenteed to be called at least once on every object, but it should correctly handle empty parameter lists. This means that the object should be in a valid state from the time it is constructed. This method should also return true or false depending on whether the update was succesfull or not.- Specified by:
update
in interfaceRenderObject
- Parameters:
pl
- list of parameters to read fromapi
- reference to the current scene- Returns:
true
if the update is succesfull,false
otherwise
-
getTime
public float getTime(float time)
Computes actual time from a time sample in the interval [0,1). This random number is mapped somewhere between the shutterOpen and shutterClose times.- Parameters:
time
-- Returns:
-
getRay
public Ray getRay(float x, float y, int imageWidth, int imageHeight, double lensX, double lensY, float time)
Generate a ray passing though the specified point on the image plane. Additional random variables are provided for the lens to optionally compute depth-of-field or motion blur effects. Note that the camera may returnnull
for invalid arguments or for pixels which don't project to anything.- Parameters:
x
- x pixel coordinatey
- y pixel coordinateimageWidth
- width of the image in pixelsimageHeight
- height of the image in pixelslensX
- a random variable in [0,1) to be used for DOF samplinglensY
- a random variable in [0,1) to be used for DOF samplingtime
- a random variable in [0,1) to be used for motion blur sampling- Returns:
- a ray passing through the specified pixel, or
null
-
getRay
Ray getRay(Point3 p, float time)
Generate a ray from the origin of camera space toward the specified point.- Parameters:
p
- point in world space- Returns:
- ray from the origin of camera space to the specified point
-
getCameraToWorld
Matrix4 getCameraToWorld(float time)
Returns a transformation matrix mapping camera space to world space.- Returns:
- a transformation matrix
-
getWorldToCamera
Matrix4 getWorldToCamera(float time)
Returns a transformation matrix mapping world space to camera space.- Returns:
- a transformation matrix
-
-