JavaView® v2.12

jv.viewer
Class PvCamera

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.viewer.PvCamera
All Implemented Interfaces:
java.lang.Cloneable, PsUpdateIf, PvCameraIf, java.io.Serializable

public final class PvCamera
extends PsObject
implements PvCameraIf

Camera for PvDisplay. Four different projection types. Handled by PvDisplay.

If camera info panel is showing, then it is updated when geometry is rotated. On slow machines just switch the visible panel to stop the panel update.

Version:
15.03.01, 2.10 revised (kp) Methods for horizontal clipping added.
27.03.00, 2.02 revised (ep) implements PvCameraIf.
21.06.99, 2.01 revised (kp) Clipping activated.
00.00.98, 2.00 revised (kp) Revised.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PvDisplay, Serialized Form

Field Summary
 PdMatrix m_trans
           
 PdMatrix m_transInv
           
 PdMatrix m_view
           
 PdMatrix m_viewInv
           
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, NUM_TAGS
 
Constructor Summary
PvCamera(PvDisplay display, int projMode)
           
 
Method Summary
 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.
 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.
 void setDist(double newDist)
          Set distance of camera position from point of interest in world coordinates.
 void setEnabledClip(boolean flag)
          Enable horizontal clipping.
 void setFarClip(double dist)
          Get distance of far clipping plane.
 void setFieldOfView(double angle)
          Set opening angle of camera.
 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 setUpVector(PdVector up)
          Set normalized up vector of camera in world coordinates.
 void setViewDir(PdVector pos)
          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. call: super.update(event, e.g. this) event == null : geometry has change by widget event which has been handled call: super.update(null) event == else : we must handle the event here or pass it to superclass.
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.object.PsUpdateIf
getFather, getName, setParent
 

Field Detail

m_view

public PdMatrix m_view

m_viewInv

public PdMatrix m_viewInv

m_trans

public PdMatrix m_trans

m_transInv

public PdMatrix m_transInv
Constructor Detail

PvCamera

public PvCamera(PvDisplay display,
                int projMode)
Method Detail

init

public void init()
Initializes and resets current camera.
Overrides:
init in class PsObject

update

public 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. call: super.update(event, e.g. this) event == null : geometry has change by widget event which has been handled call: super.update(null) event == else : we must handle the event here or pass it to superclass. If no superclass can handle this event, then error. call: super.update(event)
Specified by:
update in interface PsUpdateIf
Overrides:
update in class PsObject
Following copied from interface: jv.object.PsUpdateIf
Parameters:
event - carries a lot of information
Returns:
true if event has been handled, otherwise false
See Also:
PsObject, PsUpdateIf.getFather(), PsUpdateIf.setParent(PsUpdateIf)

getProjectionMode

public int getProjectionMode()
Get projection mode of the camera, for example, perspective, xy-projection etc. For a list of possible type see PvDisplayIf#CAMERA_ORTHO_XY.
Specified by:
getProjectionMode in interface PvCameraIf
Returns:
current projection mode
See Also:
PvDisplayIf

setProjectionMode

public void setProjectionMode(int mode)
Set projection mode of the camera, for example, perspective, xy-projection etc. For a list of possible type see PvDisplayIf#CAMERA_ORTHO_XY.
Specified by:
setProjectionMode in interface PvCameraIf
Parameters:
new - projection mode
See Also:
PvDisplayIf

isEnabledClip

public boolean isEnabledClip()
Determine whether horizontal clipping is enabled.
Specified by:
isEnabledClip in interface PvCameraIf

setEnabledClip

public void setEnabledClip(boolean flag)
Enable horizontal clipping.
Specified by:
setEnabledClip in interface PvCameraIf

getNearClip

public double getNearClip()
Get distance of the near clipping plane. The near and far clipping planes of a camera are orthogonal to the viewing direction at a positive distance. The near clip plane is closer to the camera than the far clip plane, and this order is not allowed to change.
Specified by:
getNearClip in interface PvCameraIf
Returns:
positive distance of the near clip plane

setNearClip

public void setNearClip(double dist)
Get distance of the near clipping plane. The near and far clipping planes of a camera are orthogonal to the viewing direction at a positive distance. The near clip plane is closer to the camera than the far clip plane, and this order is not allowed to change.
Specified by:
setNearClip in interface PvCameraIf
Parameters:
dist - positive distance of the near clip plane

getFarClip

public double getFarClip()
Get distance of the far clipping plane. The near and far clipping planes of a camera are orthogonal to the viewing direction at a positive distance. The near clip plane is closer to the camera than the far clip plane, and this order is not allowed to change.
Specified by:
getFarClip in interface PvCameraIf
Returns:
positive distance of the far clip plane

setFarClip

public void setFarClip(double dist)
Get distance of far clipping plane. The near and far clipping planes of a camera are orthogonal to the viewing direction at a positive distance. The near clip plane is closer to the camera than the far clip plane, and this order is not allowed to change.
Specified by:
setFarClip in interface PvCameraIf
Parameters:
dist - positive distance of the far clip plane

getViewDir

public PdVector getViewDir()
Get normalized viewing direction as the vector pointing from the camera to its interest.

Internally the viewing direction is the negative of third row of the viewing matrix divided by the scaling factor.

viewDir = -view[2][.] / getScale()
.
Specified by:
getViewDir in interface PvCameraIf
Returns:
normalized viewing direction in world coordinates

setViewDir

public void setViewDir(PdVector pos)
Set viewing direction as the vector pointing from the camera to its interest. Length of vector is irrelevant.
Specified by:
setViewDir in interface PvCameraIf
Parameters:
viewing - direction in world coordinates

getDist

public double getDist()
Get distance of camera position from point of interest in world coordinates. Distance is inverse to scaling factor of viewing matrix.
Specified by:
getDist in interface PvCameraIf
Returns:
distance of camera to interest in world coordinates.
See Also:
getScale()

setDist

public void setDist(double newDist)
Set distance of camera position from point of interest in world coordinates. Scale view matrix with factor=newDist/currDist.
Specified by:
setDist in interface PvCameraIf
Parameters:
distance - of camera to interest in world coordinates.
See Also:
setScale(double)

getScale

public double getScale()
Get zoom factor of camera.
Specified by:
getScale in interface PvCameraIf
Returns:
zoom factor of camera.
See Also:
getDist()

setScale

public void setScale(double newScale)
Set zoom factor of camera.
Specified by:
setScale in interface PvCameraIf
Parameters:
zoom - factor of camera.
See Also:
setDist(double)

getFieldOfView

public double getFieldOfView()
Get opening angle of camera.
Specified by:
getFieldOfView in interface PvCameraIf
Returns:
angle in (0,180)
See Also:
setFieldOfView(double)

setFieldOfView

public void setFieldOfView(double angle)
Set opening angle of camera.
Specified by:
setFieldOfView in interface PvCameraIf
Parameters:
angle - in (0,180)
See Also:
getFieldOfView()

getRoll

public double getRoll()
Get angle which camera is rotated around viewing direction against default position. The default position depends on the projection mode of the camera.

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.

Specified by:
getRoll in interface PvCameraIf
Returns:
angle in (-pi,pi)
See Also:
setRoll(double)

setRoll

public void setRoll(double roll)
Set angle which camera is rotated around viewing direction against default position. The default position depends on the projection mode of the camera.
Specified by:
setRoll in interface PvCameraIf
Parameters:
angle - in (-pi,pi)
See Also:
getRoll()

getInterest

public PdVector getInterest()
Get position at which camera is directed, i.e. the point of interest. Interest is implicitly stores as the 4th column of the inverse viewing matrix.
interest = viewInv[.][3]
Specified by:
getInterest in interface PvCameraIf
Returns:
3d-coordinates of interest in world coordinates.

setInterest

public void setInterest(PdVector pos)
Set location at which camera is directed, i.e. the point of interest. This method does not change the viewing direction, that means, implicitly the camera position is moved parallel in order to keep the same viewing direction.

This behaviour results from the steering inside the camera panel where a user may change the interest, viewing direction and distance. User 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 the interest.

Specified by:
setInterest in interface PvCameraIf
Parameters:
pos - 3d-coordinates of interest in world coordinates.

getPosition

public PdVector getPosition()
Get position of camera in world coordinates. The camera position is implicitly stored and computed from
position = interest - dist*viewDir
.
Specified by:
getPosition in interface PvCameraIf
Returns:
3d-position of camera in world coordinates.

setPosition

public void setPosition(PdVector pos)
Set position of camera in world coordinates. The camera position is implicitly stored by equation
position = interest - dist*viewDir
.
Specified by:
setPosition in interface PvCameraIf
Parameters:
pos - 3d-position of camera in world coordinates.

getUpVector

public PdVector getUpVector()
Get up vector as second row of viewing matrix divided by scaling factor.
upDir = -view[1][.] / getScale()
.
Specified by:
getUpVector in interface PvCameraIf
Returns:
normalized up vector of camera in world coordinates.

setUpVector

public void setUpVector(PdVector up)
Set normalized up vector of camera in world coordinates.
Specified by:
setUpVector in interface PvCameraIf
Parameters:
normalized - up vector of camera in world coordinates.

fit

public void fit(double diameter)
Fit object with given diameter into current display window. Compute scaling factor such that diameter (in world coordinates) corresponds to width of image.

getBounds

public PdVector[] getBounds()
Get transformed bounding box used in clipping.

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.