|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectartofillusion.Camera
public class Camera
The Camera class has two functions. First, it keeps track of the transformations between the various coordinate systems used by the program. These include:
Second, the camera class is responsible for drawing various simple shapes. These include straight lines, rectangular boxes, and Bezier curves.
The Camera class does *not* represent a "camera" which the user creates and positions within a scene. That is represented by the SceneCamera class.
Field Summary | |
---|---|
static double |
DEFAULT_DISTANCE_TO_SCREEN
|
static int |
NEEDS_CLIPPING
|
static int |
NOT_VISIBLE
|
static int |
VISIBLE
|
Constructor Summary | |
---|---|
Camera()
|
Method Summary | |
---|---|
Vec3 |
convertScreenToWorld(java.awt.Point p,
double depth)
Given a point in screen coordinates, find the corresponding point in world coordinates which is at a specified depth from the viewpoint. |
Vec3 |
convertScreenToWorld(java.awt.Point p,
double depth,
boolean snapToGrid)
Given a point in screen coordinates, find the corresponding point in world coordinates which is at a specified depth from the viewpoint. |
Vec3 |
convertScreenToWorld(Vec2 p,
double depth,
boolean snapToGrid)
Given a point in screen coordinates, find the corresponding point in world coordinates which is at a specified depth from the viewpoint. |
void |
drawBezier(java.awt.Graphics g,
Vec3 v1,
Vec3 v2,
Vec3 v3,
Vec3 v4)
Draw a cubic Bezier curve, using the four specified control vertices. |
void |
drawBezier2(java.awt.Graphics g,
Vec3 v1,
Vec3 v2,
Vec3 v3,
Vec3 v4)
Draw a cubic Bezier curve, using the four specified control vertices. |
void |
drawBox(java.awt.Graphics g,
BoundingBox bb)
Draw a bounding box (specified in object coordinates). |
void |
drawClippedBezier(java.awt.Graphics g,
Vec3 v1,
Vec3 v2,
Vec3 v3,
Vec3 v4)
Same as above, except clip the curve to the front clipping plane. |
void |
drawClippedBox(java.awt.Graphics g,
BoundingBox bb)
Same as above, except clip all the edges of the box to the front clipping plane. |
void |
drawClippedLine(java.awt.Graphics g,
Vec3 from,
Vec3 to)
Same as above, except clip the line to the front clipping plane. |
void |
drawClippedLineTo(java.awt.Graphics g,
Vec3 to)
Same as above, except clip the line to the front clipping plane. |
void |
drawLine(java.awt.Graphics g,
Vec3 from,
Vec3 to)
Draw a line between two points (specified in object coordinates). |
void |
drawLineTo(java.awt.Graphics g,
Vec3 to)
Draw a line from the endpoint of the previous line to a new point. |
Camera |
duplicate()
Create a duplicate of this camera. |
Vec3 |
findDragVector(Vec3 p,
double dx,
double dy)
The following routine is used for dragging objects on the screen. |
Vec3 |
findDragVector(Vec3 p,
int dx,
int dy)
This is provided for backward compatibility. |
java.awt.Rectangle |
findScreenBounds(BoundingBox bb)
Given a bounding box (specified in object coordinates), return a rectangle which describes the object's position on the screen. |
CoordinateSystem |
getCameraCoordinates()
Get the camera's coordinate system. |
double |
getClipDistance()
|
double |
getDistToScreen()
|
Mat4 |
getObjectToScreen()
|
Mat4 |
getObjectToView()
|
Mat4 |
getObjectToWorld()
The following routines return the various transformation matrices maintained by the Camera object. |
java.awt.Dimension |
getSize()
Get the dimension's of the camera's viewport. |
Mat4 |
getViewToScreen()
|
Mat4 |
getViewToWorld()
|
Mat4 |
getWorldToScreen()
|
Mat4 |
getWorldToView()
|
boolean |
isPerspective()
Determine whether the camera is in perspective or parallel projection mode. |
void |
setCameraCoordinates(CoordinateSystem coords)
Set the camera's coordinate system. |
void |
setClipDistance(double distance)
|
void |
setDistToScreen(double dist)
Deprecated. use setScreenParams() instead |
void |
setGrid(double spacing)
Set the grid spacing. |
void |
setObjectTransform(Mat4 m)
Set the transformation for converting object coordinates to world coordinates. |
void |
setScreenParams(double newViewDist,
double newScale,
int newHres,
int newVres)
Set the camera to perspective mode with the specified parameters. |
void |
setScreenParamsParallel(double newScale,
int newHres,
int newVres)
Set the camera to parallel projection mode with the specified parameters. |
void |
setScreenTransform(Mat4 screenTransform,
int width,
int height)
Set the transformation which maps from view coordinates to screen coordinates. |
void |
setSize(int newHres,
int newVres)
Deprecated. use setScreenTransform(), setScreenParams() or setScreenParamsParallel() instead |
void |
setViewTransform(Mat4 worldToView,
Mat4 viewToWorld)
Explicitly set the transformation between world and view coordinates. |
int |
visibility(BoundingBox bb)
Given a bounding box (specified in object coordinates), determine whether the object is visible. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double DEFAULT_DISTANCE_TO_SCREEN
public static final int NOT_VISIBLE
public static final int NEEDS_CLIPPING
public static final int VISIBLE
Constructor Detail |
---|
public Camera()
Method Detail |
---|
public void setDistToScreen(double dist)
public double getDistToScreen()
public double getClipDistance()
public void setClipDistance(double distance)
public boolean isPerspective()
public Camera duplicate()
public void setScreenTransform(Mat4 screenTransform, int width, int height)
screenTransform
- the transformation from view coordinates to screen coordinateswidth
- the screen width in pixelsheight
- the screen height in pixelspublic void setScreenParams(double newViewDist, double newScale, int newHres, int newVres)
public void setScreenParamsParallel(double newScale, int newHres, int newVres)
public void setSize(int newHres, int newVres)
public java.awt.Dimension getSize()
public void setGrid(double spacing)
public void setCameraCoordinates(CoordinateSystem coords)
public void setViewTransform(Mat4 worldToView, Mat4 viewToWorld)
public CoordinateSystem getCameraCoordinates()
public void setObjectTransform(Mat4 m)
public final Mat4 getObjectToWorld()
public final Mat4 getObjectToView()
public final Mat4 getObjectToScreen()
public final Mat4 getWorldToView()
public final Mat4 getWorldToScreen()
public final Mat4 getViewToScreen()
public final Mat4 getViewToWorld()
public Vec3 convertScreenToWorld(java.awt.Point p, double depth)
public Vec3 convertScreenToWorld(java.awt.Point p, double depth, boolean snapToGrid)
public Vec3 convertScreenToWorld(Vec2 p, double depth, boolean snapToGrid)
public Vec3 findDragVector(Vec3 p, int dx, int dy)
public Vec3 findDragVector(Vec3 p, double dx, double dy)
public java.awt.Rectangle findScreenBounds(BoundingBox bb)
public int visibility(BoundingBox bb)
public void drawLine(java.awt.Graphics g, Vec3 from, Vec3 to)
public void drawClippedLine(java.awt.Graphics g, Vec3 from, Vec3 to)
public void drawLineTo(java.awt.Graphics g, Vec3 to)
public void drawClippedLineTo(java.awt.Graphics g, Vec3 to)
public void drawBox(java.awt.Graphics g, BoundingBox bb)
public void drawClippedBox(java.awt.Graphics g, BoundingBox bb)
public void drawBezier(java.awt.Graphics g, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4)
public void drawClippedBezier(java.awt.Graphics g, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4)
public void drawBezier2(java.awt.Graphics g, Vec3 v1, Vec3 v2, Vec3 v3, Vec3 v4)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |