public final class PvCamera extends PsObject implements PvCameraIf
A camera may be in one of four different projection types,
for example, PvCameraIf.CAMERA_PERSPECTIVE.
The camera compute the transformation matrices based in the mouse pick
and drag positions. The size of the picking device and of the target image
may differ.
If the camera info panel is showing, then it is updated when the camera is changed. On slow machines just disable the camera panel to avoid immediate panel updates.
PvDisplay,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
PdMatrix |
m_defTrans
Default transformation matrix is the product of projection and viewing matrix.
|
PdMatrix |
m_defTransInv
Default inverse of the transformation matrix.
|
PdMatrix |
m_defView
Default viewing matrix transforms the scene into normal coordinates.
|
PdMatrix |
m_defViewInv
Default inverse of the viewing matrix.
|
PdMatrix |
m_trans
Transformation matrix is the product of projection and viewing matrix.
|
PdMatrix |
m_transInv
Inverse of the transformation matrix.
|
PdMatrix |
m_transNon
Non-perspective part of transformation matrix is the product of projection and viewing matrix.
|
PdMatrix |
m_transNonInv
Non-perspective part of inverse of the transformation matrix.
|
PdMatrix |
m_view
Viewing matrix transforms the scene into normal coordinates.
|
PdMatrix |
m_viewInv
Inverse of the viewing matrix.
|
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGSCAMERA_MODEL, CAMERA_NAME, CAMERA_ORTHO_XY, CAMERA_ORTHO_XZ, CAMERA_ORTHO_YZ, CAMERA_PERSPECTIVE| Constructor and Description |
|---|
PvCamera(PvDisplay display,
int projMode)
Constructor of camera associates the display
and initializes the current projection mode.
|
| Modifier and Type | Method and Description |
|---|---|
void |
fit(double diameter)
Fit object with given diameter into current display window.
|
PdVector[] |
getBounds()
Get transformed bounding box used in clipping.
|
double |
getDist()
Get distance of camera position from point of interest in world coordinates.
|
double |
getFarClip()
Get distance of the far clipping plane.
|
double |
getFieldOfView()
Get opening angle of camera.
|
PdVector |
getInterest()
Get position at which camera is directed, i.e. the point of interest.
|
double |
getNearClip()
Get distance of the near clipping plane.
|
PdVector |
getPosition()
Get position of camera in world coordinates.
|
int |
getProjectionMode()
Get projection mode of the camera, for example, perspective, xy-projection etc.
|
double |
getRoll()
Get angle which camera is rotated around viewing direction against default position.
|
double |
getScale()
Get zoom factor of camera.
|
PdMatrix |
getTransMatrix(int type)
Get transformation matrices PV, P, V and their inverses in current camera and display.
|
PdVector |
getUpVector()
Get up vector as second row of viewing matrix divided by scaling factor.
|
PdVector |
getViewDir()
Get normalized viewing direction as the vector pointing from the camera
to its interest.
|
void |
init()
Initializes and resets current camera.
|
boolean |
isEnabledClip()
Determine whether horizontal clipping is enabled.
|
boolean |
isEnabledSceneRatio()
Check of aspect ratio of scene bounding box is enabled.
|
void |
reset()
Reset the current transformation matrices to default values.
|
void |
saveAsDefault()
Save the current transformation matrices as default.
|
void |
setBoxRatio(PdVector ratio)
Set the scaling factor for all three camera axis to produce a non-square
viewing frustum.
|
void |
setDist(double newDist)
Set distance of camera position from point of interest in world coordinates.
|
void |
setEnabledBoxRatio(boolean flag)
Enable usage of a variable aspect ratio for the viewing frustum of this camera.
|
void |
setEnabledClip(boolean flag)
Enable horizontal clipping.
|
void |
setEnabledSceneRatio(boolean flag)
Set aspect ratio of scene bounding box.
|
void |
setFarClip(double dist)
Get distance of far clipping plane.
|
void |
setFieldOfView(double angle)
Set opening angle of camera.
|
void |
setFullPosition(PdVector interest,
PdVector position,
PdVector upDir)
Set full orientation and location of camera in world coordinates.
|
void |
setInterest(PdVector pos)
Set location at which camera is directed, i.e. the point of interest.
|
void |
setNearClip(double dist)
Get distance of the near clipping plane.
|
void |
setPosition(PdVector pos)
Set position of camera in world coordinates.
|
void |
setProjectionMode(int mode)
Set projection mode of the camera, for example, perspective, xy-projection etc.
|
void |
setRoll(double roll)
Set angle which camera is rotated around viewing direction against default position.
|
void |
setScale(double newScale)
Set zoom factor of camera.
|
void |
setTransMatrix(int type,
PdMatrix mat)
Set transformation matrices PV, P, V and their inverses in current camera and display.
|
void |
setUpVector(PdVector up)
Set normalized up vector of camera in world coordinates.
|
void |
setViewDir(PdVector dir)
Set viewing direction as the vector pointing from the camera
to its interest.
|
boolean |
update(java.lang.Object event)
event == this : geometry has changed by itself without widget event,
therefore somewhere in a superclass the infoPanel must be updated.
|
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanelsequals, getClass, hashCode, notify, notifyAll, wait, wait, waitsetNamegetFather, getName, setParentpublic PdMatrix m_defView
public PdMatrix m_defViewInv
public PdMatrix m_defTrans
public PdMatrix m_defTransInv
public PdMatrix m_transNon
public PdMatrix m_transNonInv
public PdMatrix m_view
public PdMatrix m_viewInv
public PdMatrix m_trans
public PdMatrix m_transInv
public PvCamera(PvDisplay display, int projMode)
PvCameraIf.CAMERA_PERSPECTIVE.display - associate displayprojMode - current projection mode of this camerapublic void saveAsDefault()
saveAsDefault in interface PvCameraIfreset()public void reset()
saveAsDefault()public boolean update(java.lang.Object event)
update in interface PsUpdateIfupdate in class PsObjectevent - carries a lot of informationPsObject.setParent(PsUpdateIf),
PsObject.getFather(),
PsObject.addUpdateListener(PsUpdateIf)public int getProjectionMode()
PvCameraIf#CAMERA_ORTHO_XY.getProjectionMode in interface PvCameraIfPvDisplayIfpublic void setProjectionMode(int mode)
PvCameraIf#CAMERA_ORTHO_XY.setProjectionMode in interface PvCameraIfmode - new projection modePvDisplayIfpublic boolean isEnabledClip()
isEnabledClip in interface PvCameraIfpublic void setEnabledClip(boolean flag)
setEnabledClip in interface PvCameraIfpublic double getNearClip()
getNearClip in interface PvCameraIfpublic void setNearClip(double dist)
setNearClip in interface PvCameraIfdist - positive distance of the near clip planepublic double getFarClip()
getFarClip in interface PvCameraIfpublic void setFarClip(double dist)
setFarClip in interface PvCameraIfdist - positive distance of the far clip planepublic PdVector getViewDir()
Internally the viewing direction is the negative of third row of the viewing matrix divided by the scaling factor.
viewDir = -view[2][.] / getScale().
getViewDir in interface PvCameraIfpublic void setViewDir(PdVector dir)
setViewDir in interface PvCameraIfdir - viewing direction in world coordinatespublic double getDist()
getDist in interface PvCameraIfgetScale()public void setDist(double newDist)
factor=newDist/currDist.setDist in interface PvCameraIfnewDist - distance of camera to interest in world coordinates.setScale(double)public double getScale()
getScale in interface PvCameraIfgetDist()public void setScale(double newScale)
setScale in interface PvCameraIfnewScale - zoom factor of camera.setDist(double)public double getFieldOfView()
getFieldOfView in interface PvCameraIfsetFieldOfView(double)public void setFieldOfView(double angle)
setFieldOfView in interface PvCameraIfangle - angle in (0,180)getFieldOfView()public double getRoll()
Mathematically, the roll is the angle between the two planes p1=(viewDir, defaultUpVector) and p2=(viewDir, upVector). The defaultUpVector depends on the projection mode, in xy-projection mode we have defaultUpVector=(0,1,0) since camera looks down the negative z-axis and the positive y-axis is showing upward.
getRoll in interface PvCameraIfsetRoll(double)public void setRoll(double roll)
setRoll in interface PvCameraIfroll - angle in (-180, 180)getRoll()public PdVector getInterest()
interest = viewInv[.][3]
getInterest in interface PvCameraIfpublic void setInterest(PdVector pos)
This behaviour results from the steering inside the camera panel where a user may change the interest, viewing direction and distance. Users who want to set camera position and interest are advised either to first set the interest and then the position, or to set the viewing direction and then the interest.
setInterest in interface PvCameraIfpos - 3d-coordinates of interest in world coordinates.public PdVector getPosition()
position = interest - dist*viewDir.
getPosition in interface PvCameraIfpublic void setPosition(PdVector pos)
position = interest - dist*viewDir.
setPosition in interface PvCameraIfpos - 3d-position of camera in world coordinates.public PdVector getUpVector()
upDir = -view[1][.] / getScale().
getUpVector in interface PvCameraIfpublic void setUpVector(PdVector up)
setUpVector in interface PvCameraIfup - normalized up vector of camera in world coordinates.public void setFullPosition(PdVector interest, PdVector position, PdVector upDir)
position = interest - dist*viewDir.
UpDir must be orthogonal to the vector interest-position.
setFullPosition in interface PvCameraIfinterest - 3d-coordinates of point of interest in world coordinates.position - 3d-coordinates of position of camera in world coordinates.upDir - normalized up vector of camera in world coordinates.public void fit(double diameter)
public boolean isEnabledSceneRatio()
isEnabledSceneRatio in interface PvCameraIfpublic void setEnabledSceneRatio(boolean flag)
setEnabledSceneRatio in interface PvCameraIfpublic void setEnabledBoxRatio(boolean flag)
setEnabledBoxRatio in interface PvCameraIfpublic void setBoxRatio(PdVector ratio)
setBoxRatio in interface PvCameraIfratio - three scaling factors, default square has (1.,1.,1.).public PdVector[] getBounds()
public PdMatrix getTransMatrix(int type)
Modeling matrix should be set in original geometry model.
getTransMatrix in interface PvCameraIftype - type of transformation matrix, see PvDisplay.MATRIX_public void setTransMatrix(int type,
PdMatrix mat)
Modeling matrix should be set in original geometry model.
setTransMatrix in interface PvCameraIftype - type of transformation matrix, see PvDisplay.MATRIX_mat - new transformation matrix"