|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y25.graphics.Camera
Represents a camera in three dimensional space.
Field Summary | |
protected Transform |
cameraToNDC
The transform that transforms camera coordinates into (NDC) normalized device coordinates. |
protected float |
fov
The field of view angle in degrees. |
protected float |
height
The height of the view area in pixels. |
static float |
maxFOV
The maximal field of view angle in degrees. |
static float |
minFOV
The minimal field of view angle in degrees. |
protected Transform |
ndcToScreen
The transform that transforms NDC coordinates into screen soordinates. |
protected Point3D |
target
The point this camera looks at. |
protected float |
viewDistance
The camera's distance from the target. |
protected float |
viewRotX
The camera's rotation around the x-axis. |
protected float |
viewRotY
The camera's rotation around the y-axis. |
protected float |
viewRotZ
The camera's rotation around the z-axis. |
protected float |
width
The width of the view area in pixels. |
protected float |
width_height
The aspect ratio ( width / height ). |
protected Transform |
worldToCamera
The transform that transforms world coordinates into camera coordinates. |
protected Transform |
worldToScreen
A shortcut transform that transforms world coordinates directly into screen soordinates. |
protected float |
zFar
The z-value of the far clipping plane. |
protected float |
zNear
The z-value of the near clipping plane. |
Constructor Summary | |
Camera()
Creates a default camera. |
Method Summary | |
void |
activateHUD(GLAutoDrawable drawable)
Activates a "Head Up Display" for the given drawable. |
void |
activateProjection(GLAutoDrawable drawable)
Sets the passed drawable's OpenGL projection and modelview matrices to this camera's settings. |
void |
changePerspective(float angle)
Increases or decreases the field of viwe by the given angle while keeping the viewing area as coherent as possible with the previous setting. |
void |
deactivateHUD(GLAutoDrawable drawable)
Deactivates the "Head Up Display" and returns to the previous projection settings. |
float |
getAspectRatio()
Returns the camaera's aspect ratio. |
float |
getFarClippingPlane()
Returns the z-value of the far clipping plane. |
float |
getFOV()
Returns the field of view of this camera in angles. |
Point3D |
getHUDCoordinates(GLAutoDrawable drawable,
Point3D p)
Returns the HUD-Coordinates of the passed point. |
float |
getNearClippingPlane()
Returns the z-value of the near clipping plane. |
Point3D |
getPosition()
Returns the position of the camera. |
float |
getRotationX()
Returns the camera's rotation around the x-axis. |
float |
getRotationY()
Returns the camera's rotation around the y-axis. |
float |
getRotationZ()
Returns the camera's rotation around the z-axis. |
Point3D |
getScreenCoordinates(Point3D p)
Returns the screen coordinates of the passed point. |
Point3D |
getTarget()
Returns the viweing target of this camera. |
Vector3D |
getUpDirection()
Returns the vector in three dimensional space that corresponds to the upward direction in the viewing plane. |
Vector3D |
getViewDirection()
Returns the view direction of the camera. |
float |
getViewDistance()
Returns the distance from this camera to the target. |
void |
rotate(float x,
float y,
float z)
Rotates the camera by the passed angles in degrees. |
void |
setClippingPlanes(BoundingBox bb)
Adjusts the clipping planes of this camera so that the content of the passed bounding box can be displayed correctly. |
void |
setClippingPlanes(float zN,
float zF)
Sets the near and far clipping planes to the specified values. |
void |
setFarClippingPlane(float far)
Sets the far clipping plane of this camera. |
void |
setFOV(float f)
Sets the field of view of this camera in angles. |
void |
setHeight(float h)
Sets the hegiht of the camera's viewing plane in pixels. |
void |
setNearClippingPlane(float near)
Sets the near clipping plane of this camera. |
void |
setPerspective(float angle)
Sets the field of view of this camera while keeping the viewing area as coherent as possible with the previous setting. |
void |
setPosition(Point3D pos)
Sets the position of this camera. |
void |
setRotation(float x,
float y,
float z)
Sets the x,y,z rotation of this camera. |
void |
setTarget(float x,
float y,
float z)
Sets the viewing target of this camera to the passed x,y,z coordinates. |
void |
setTarget(Point3D p)
Sets the viewing target of this camera to the passed point. |
void |
setViewDistance(float viewDist)
Sets the view distance of this camera to the target. |
void |
setWidth(float w)
Sets the width of the camera's viewing plane in pixels. |
Vector3D |
toCamera(GLAutoDrawable drawable,
Point3D from)
Returns a vector that points to the camera. |
String |
toString()
|
void |
zoom(float factor)
Moves the camera with respect to it's viewing direction. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static float minFOV
public static float maxFOV
protected float fov
protected float width
protected float height
protected float width_height
protected float zNear
protected float zFar
protected Point3D target
protected float viewRotX
protected float viewRotY
protected float viewRotZ
protected float viewDistance
protected Transform worldToCamera
protected Transform cameraToNDC
protected Transform ndcToScreen
protected Transform worldToScreen
Constructor Detail |
public Camera()
Method Detail |
public void activateProjection(GLAutoDrawable drawable)
After calling this method, world geometry will be drawn as if viewed from this camera.
public Point3D getScreenCoordinates(Point3D p)
public void activateHUD(GLAutoDrawable drawable)
After calling this method, coordinates retrieved via
glRasterPos
or getHUDCoordinates
can be
passed to glVertex
and they will be rendered to the
correct position.
Every call of this method has to be matched by a call to
deactivateHUD
.
public void deactivateHUD(GLAutoDrawable drawable)
It is an error to call this method before activateHUD
has
been called. It is also an error not to match a call of
activateHUD
with a call to this method.
public Point3D getHUDCoordinates(GLAutoDrawable drawable, Point3D p)
If the passed point lies outside of the viewing area, null
is returned.
Before using the retrieved coordinates to draw elements on the screen,
activateHUD
has to be called.
public Vector3D toCamera(GLAutoDrawable drawable, Point3D from)
Note that this method is different from calculating a vector from
from
to getPosition()
, since the passed
point from
is interpreted with respect to the current
OpenGL matrix stack. This makes it possible to make multiple calls to
glTranslate
, glScale
, etc. and to then
retrieve a vector to the camera without having to transform the local
coordinates to world coordinates first.
public Vector3D getViewDirection()
public Vector3D getUpDirection()
public void setFOV(float f)
public float getFOV()
public void setWidth(float w)
public void setHeight(float h)
public float getAspectRatio()
public void setClippingPlanes(BoundingBox bb)
If the passed bounding box is collapsed, this method has no effect.
public void setClippingPlanes(float zN, float zF)
public void setNearClippingPlane(float near)
public void setFarClippingPlane(float far)
public float getNearClippingPlane()
public float getFarClippingPlane()
public void setPosition(Point3D pos)
The camera's target remains at the same place.
public Point3D getPosition()
public void setTarget(float x, float y, float z)
public void setTarget(Point3D p)
public Point3D getTarget()
public void setRotation(float x, float y, float z)
target
is the center of the coordinate system that is used
for rotation.)
public float getRotationX()
public float getRotationY()
public float getRotationZ()
public void setViewDistance(float viewDist)
public float getViewDistance()
public void rotate(float x, float y, float z)
public void zoom(float factor)
0.1
means getting 10 percent closer to the target, a
factor of -0.1
means moving 10 percent farther away from
the target.
A factor of greater than 1
is not allowed.
public void setPerspective(float angle)
A value of 180
degrees for the parameter
angle
means an overly perspective projection, whereas a
value of 0
degrees means an orthogonal view of the scene.
public void changePerspective(float angle)
When angle
is positive, the 'perspectiveness' gets
stronger. To compensate for the bigger field of view the camera moves
closer to the target.
When angle
is negative, the 'perspectiveness' gets waeker.
To comensate for the smaller field of view the camera moves further away
from the target.
Note that repeatedly calling this method with small angle-steps leads to the famous 'Hitchcock'-effect.
angle
- public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |