Interface Camera
- All Known Implementing Classes:
Camera
Title: Camera
Description: This class provides access to the position of the camera, its focus point and its distance to the projection screen that are used to view the 3D scenes. The camera can also be rotated around the line of sight (i.e. the line which conects the camera with the focus point).
The camera position can be set using either the desired X,Y,Z coordinates or spherical coordinates around the focus point. This makes it easy to rotate the scene both horizontally and vertically (around the focus).
Panning can be achieved by moving the focus point to one side.
Zooming is done increasing (positive zoom) or decreasing the distance between the camera and the projection screen.
The projection screen is always normal to the line of sight and has its origin at the intersection of this line with the screen itself.
The camera provides fives different modes of projecting points in space to the screen. Two modes are truly three-dimensional. The other three are planar modes.
- Version:
- June 2005
- Author:
- Francisco Esquembre
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies its configuration from another cameradouble
Get the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point.double
Get the horizontal angle of the camera position in spherical coordinates with respect to the focus point.double
Returns the distance from the camera to the projecting screen.double
Returns the focus X coordinatedouble
Returns the focus Y coordinatedouble
Returns the focus Z coordinateint
Gets the projecting mode of the camera.double
Returns the angle that the camera is rotated along the line of sight.Returns the transfomation used to project (x,y,z) points in space to points of the form (a,b,distance).double
getX()
Returns the camera X coordinatedouble
getY()
Returns the camera Y coordinatedouble
getZ()
Returns the camera Z coordinatevoid
reset()
Resets the camera to the default.void
setAltitude
(double angle) Set the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point.void
setAzimuth
(double angle) Set the azimuthal (horizontal) angle of the camera position in spherical coordinates with respect to the focus point.void
setAzimuthAndAltitude
(double azimuth, double altitude) Set the angles of the camera position in spherical coordinates with respect to the focus point.void
setDistanceToScreen
(double distance) Sets the distance from the camera to the projecting screen.void
setFocusXYZ
(double[] point) Sets the focus of the camera.void
setFocusXYZ
(double x, double y, double z) Sets the focus point of the camera.void
setProjectionMode
(int mode) Sets one of the projecting modes.void
setRotation
(double angle) Sets the angle that the camera is rotated along the line of sight.void
setXYZ
(double[] point) Sets the position of the camera.void
setXYZ
(double x, double y, double z) Sets the position of the camera.
-
Field Details
-
MODE_PLANAR_XY
static final int MODE_PLANAR_XY- See Also:
-
MODE_PLANAR_XZ
static final int MODE_PLANAR_XZ- See Also:
-
MODE_PLANAR_YZ
static final int MODE_PLANAR_YZ- See Also:
-
MODE_PERSPECTIVE_OFF
static final int MODE_PERSPECTIVE_OFF- See Also:
-
MODE_PERSPECTIVE_ON
static final int MODE_PERSPECTIVE_ON- See Also:
-
MODE_NO_PERSPECTIVE
static final int MODE_NO_PERSPECTIVE- See Also:
-
MODE_PERSPECTIVE
static final int MODE_PERSPECTIVE- See Also:
-
-
Method Details
-
setProjectionMode
void setProjectionMode(int mode) Sets one of the projecting modes. Possible values are:- MODE_PERSPECTIVE or MODE_PERSPECTIVE_ON: 3D mode in which objects far away look smaller.
- MODE_NO_PERSPECTIVE or MODE_PERSPECTIVE_OFF: 3D mode in which distance doesn't affect the size of the objects
- MODE_PLANAR_XY: 2D mode in which only the X and Y coordinates are displayed.
- MODE_PLANAR_XZ: 2D mode in which only the X and Z coordinates are displayed.
- MODE_PLANAR_YZ: 2D mode in which only the Y and Z coordinates are displayed.
Changing the mode does not reset the camera.
- Parameters:
mode
- int
-
getProjectionMode
int getProjectionMode()Gets the projecting mode of the camera.- Returns:
- int #see #setProjectionMode(int)
-
reset
void reset()Resets the camera to the default. The camera is placed along the X direction, at a reasonable distance from the center of the panel, which becomes the focus, and is not rotated. The screen is also placed at a reasonable distance so that to view the whole scene. -
setXYZ
void setXYZ(double x, double y, double z) Sets the position of the camera.- Parameters:
x
- doubley
- doublez
- double
-
setXYZ
void setXYZ(double[] point) Sets the position of the camera.- Parameters:
point
- double[]
-
getX
double getX()Returns the camera X coordinate- Returns:
- double the X coordinate of the camera position
-
getY
double getY()Returns the camera Y coordinate- Returns:
- double the Y coordinate of the camera position
-
getZ
double getZ()Returns the camera Z coordinate- Returns:
- double the Z coordinate of the camera position
-
setFocusXYZ
void setFocusXYZ(double x, double y, double z) Sets the focus point of the camera. That it, the point in space at which the camera is pointing.- Parameters:
x
- doubley
- doublez
- double
-
setFocusXYZ
void setFocusXYZ(double[] point) Sets the focus of the camera.- Parameters:
point
- double[]
-
getFocusX
double getFocusX()Returns the focus X coordinate- Returns:
- double the X coordinate of the focus position
-
getFocusY
double getFocusY()Returns the focus Y coordinate- Returns:
- double the Y coordinate of the focus position
-
getFocusZ
double getFocusZ()Returns the focus Z coordinate- Returns:
- double the Z coordinate of the focus position
-
setRotation
void setRotation(double angle) Sets the angle that the camera is rotated along the line of sight. Default is 0.- Parameters:
angle
- double The angle in radians
-
getRotation
double getRotation()Returns the angle that the camera is rotated along the line of sight.- Returns:
- double
-
setDistanceToScreen
void setDistanceToScreen(double distance) Sets the distance from the camera to the projecting screen.- Parameters:
distance
- double
-
getDistanceToScreen
double getDistanceToScreen()Returns the distance from the camera to the projecting screen.- Returns:
- double
-
setAzimuth
void setAzimuth(double angle) Set the azimuthal (horizontal) angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 places the camera in the XZ plane.- Parameters:
angle
- the desired angle in radians
-
getAzimuth
double getAzimuth()Get the horizontal angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 means the camera is in the XZ plane.- Returns:
- double
-
setAltitude
void setAltitude(double angle) Set the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 places the camera is in the XY plane.- Parameters:
angle
- the desired angle in radians in the range [-Math.PI/2,Math.PI/2]
-
getAltitude
double getAltitude()Get the elevation (vertical) angle of the camera position in spherical coordinates with respect to the focus point. A value of 0 means the camera is in the XY plane.- Returns:
- double
-
setAzimuthAndAltitude
void setAzimuthAndAltitude(double azimuth, double altitude) Set the angles of the camera position in spherical coordinates with respect to the focus point.- Parameters:
azimuth
- the desired azimuthal angle in radiansaltitude
- the desired altitude angle in radians in the range [-Math.PI/2,Math.PI/2]
-
getTransformation
Transformation getTransformation()Returns the transfomation used to project (x,y,z) points in space to points of the form (a,b,distance). (a,b) are the coordinates of the projected point in the screen coordinate system. distance is a measure of how far the point is from the camera. Typically, points in the plane parallel to the screen at the focus point are at distance=1.- Returns:
- double
-
copyFrom
Copies its configuration from another camera- Parameters:
camera
-
-