public abstract class Camera extends Node
ParallelCamera
and PerspectiveCamera
.
The default camera is positioned in the scene such that its projection plane
in the scene coordinate space is at Z = 0, and it is looking into the screen in
the positive Z direction. The distance in Z from the camera to the projection
plane is determined by the width
and height
of the Scene to
which it is attached and its fieldOfView
.
The nearClip
and farClip
of this camera are specified in the
eye coordinate space. This space is defined such that the eye is at its
origin and the projection plane is one unit in front of the eye in the
positive Z direction.
The following pseudo code is the math used to compute the near and far clip distances in the scene coordinate space:
final double tanOfHalfFOV = Math.tan(Math.toRadians(FOV) / 2.0); final double halfHeight = HEIGHT / 2; final double focalLenght = halfHeight / tanOfHalfFOV; final double eyePositionZ = -1.0 * focalLenght; final double nearClipDistance = focalLenght * NEAR + eyePositionZ; final double farClipDistance = focalLenght * FAR + eyePositionZ;
where FOV
is fieldOfView
in degrees,
NEAR
is nearClip
specified in eye space,
and FAR
is farClip
specified in eye space.
Note: Since the ParallelCamera class has no fieldOfView
property, a
30 degrees vertical field of view is used.
Note: For the case of a PerspectiveCamera where the fixedEyeAtCameraZero
attribute is true, the scene coordinate space is normalized in order to fit
into the view frustum (see PerspectiveCamera
for more details). In
this mode, the eye coordinate space is the same as this Camera node's local
coordinate space. Hence the conversion formula mentioned above is not used.
An application should not extend the Camera class directly. Doing so may lead to an UnsupportedOperationException being thrown.
Type | Property and Description |
---|---|
DoubleProperty |
farClip
Specifies the distance from the eye of the far clipping plane of
this
Camera in the eye coordinate space. |
DoubleProperty |
nearClip
Specifies the distance from the eye of the near clipping plane of
this
Camera in the eye coordinate space. |
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, showMnemonicsProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, treeShowingProperty, treeVisibleProperty, viewOrderProperty, visibleProperty
Node.FocusedProperty, Node.TreeShowingPropertyReadOnly, Node.TreeVisiblePropertyReadOnly
Modifier and Type | Field and Description |
---|---|
private boolean |
clipInSceneValid |
private DoubleProperty |
farClip
Specifies the distance from the eye of the far clipping plane of
this
Camera in the eye coordinate space. |
private double |
farClipInScene |
private Affine3D |
localToSceneTx |
private boolean |
localToSceneValid |
private DoubleProperty |
nearClip
Specifies the distance from the eye of the near clipping plane of
this
Camera in the eye coordinate space. |
private double |
nearClipInScene |
private Scene |
ownerScene |
private SubScene |
ownerSubScene |
private Vec3d |
position |
private GeneralTransform3D |
projTx |
private GeneralTransform3D |
projViewTx |
private boolean |
projViewTxValid |
private Affine3D |
sceneToLocalTx
An affine transform that holds the computed scene-to-local transform.
|
private boolean |
sceneToLocalValid |
private double |
viewHeight |
private Affine3D |
viewTx |
private double |
viewWidth |
accessibilityProperties, accessible, BASELINE_OFFSET_SAME_AS_HEIGHT, boundsChanged, cssFlag, pseudoClassStates, styleHelper
Modifier | Constructor and Description |
---|---|
protected |
Camera() |
Modifier and Type | Method and Description |
---|---|
(package private) abstract PickRay |
computePickRay(double x,
double y,
PickRay pickRay)
Computes pick ray for the content rendered by this camera.
|
(package private) abstract Vec3d |
computePosition(Vec3d position)
Computes local position of the camera in the scene.
|
(package private) abstract void |
computeProjectionTransform(GeneralTransform3D proj) |
(package private) abstract void |
computeViewTransform(Affine3D view) |
(package private) Camera |
copy() |
private boolean |
doComputeContains(double localX,
double localY) |
private BaseBounds |
doComputeGeomBounds(BaseBounds bounds,
BaseTransform tx) |
private void |
doMarkDirty(DirtyBits dirtyBit) |
private void |
doUpdatePeer() |
DoubleProperty |
farClipProperty()
Specifies the distance from the eye of the far clipping plane of
this
Camera in the eye coordinate space. |
(package private) Affine3D |
getCameraTransform()
Returns the local-to-scene transform of this camera.
|
double |
getFarClip()
Gets the value of the property farClip.
|
(package private) double |
getFarClipInScene() |
double |
getNearClip()
Gets the value of the property nearClip.
|
(package private) double |
getNearClipInScene() |
(package private) GeneralTransform3D |
getProjViewTransform()
Returns the projView transform of this camera.
|
(package private) Affine3D |
getSceneToLocalTransform() |
(package private) double |
getViewHeight() |
(package private) double |
getViewWidth() |
private void |
markOwnerDirty() |
DoubleProperty |
nearClipProperty()
Specifies the distance from the eye of the near clipping plane of
this
Camera in the eye coordinate space. |
private Point2D |
pickNodeXYPlane(Node node,
double x,
double y)
Computes intersection point of the pick ray cast by the given coordinates
and the node's local XY plane.
|
(package private) Point3D |
pickProjectPlane(double x,
double y)
Computes intersection point of the pick ray cast by the given coordinates
and the projection plane.
|
private Point2D |
project(Point3D p)
Transforms the given 3D point to the flat projected coordinates.
|
void |
setFarClip(double value)
Sets the value of the property farClip.
|
void |
setNearClip(double value)
Sets the value of the property nearClip.
|
(package private) void |
setOwnerScene(Scene s) |
(package private) void |
setOwnerSubScene(SubScene s) |
(package private) void |
setViewHeight(double height) |
(package private) void |
setViewWidth(double width) |
private void |
updateClipPlane() |
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, almostZero, applyCss, autosize, blendModeProperty, boundedSize, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clearDirty, clipProperty, computeAreaInScreen, computeDerivedDepthTest, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, findStyles, fireEvent, focusedProperty, focusTraversableProperty, getAccessible, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBaselineOffset, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getClipParent, getContentBias, getCSSFlags, getCssMetaData, getCurrentLocalToSceneTransformState, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getGeomBounds, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLeafTransform, getLocalBounds, getLocalToParentTransform, getLocalToParentTransform, getLocalToSceneTransform, getMatchingStyles, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getPeer, getPivotX, getPivotY, getPivotZ, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getStyleMap, getSubScene, getTransformedBounds, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasMirroring, hasProperties, hoverProperty, idProperty, indent, inputMethodRequestsProperty, intersects, intersects, intersects, intersectsBounds, isCache, isCanReceiveFocus, isConnected, isDerivedDepthTest, isDirty, isDirtyEmpty, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, isShowMnemonics, isTreeShowing, isTreeVisible, isVisible, layoutBoundsChanged, layoutBoundsProperty, layoutXProperty, layoutYProperty, localBoundsChanged, localToParent, localToParent, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookup, lookupAll, lookupAll, managedProperty, markDirtyLayoutBranch, maxHeight, maxWidth, minHeight, minWidth, mouseTransparentProperty, nodeOrientationProperty, nodeResolvedOrientationChanged, nodeResolvedOrientationInvalidated, notifyAccessibleAttributeChanged, notifyManagedChanged, notifyParentOfBoundsChange, notifyParentsOfInvalidatedCSS, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentResolvedOrientationInvalidated, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickNode, pickOnBoundsProperty, prefHeight, prefWidth, pressedProperty, processCSS, pseudoClassStateChanged, queryAccessibleAttribute, reapplyCSS, releaseAccessible, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, scenesChanged, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDerivedDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setParent, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setScenes, setShowMnemonics, setStyle, setStyleMap, setTranslateX, setTranslateY, setTranslateZ, setTreeShowing, setTreeVisible, setUserData, setViewOrder, setVisible, showMnemonicsProperty, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, syncPeer, toBack, toFront, toString, transformedBoundsChanged, translateXProperty, translateYProperty, translateZProperty, traverse, treeShowingProperty, treeVisibleProperty, updateBounds, updateGeomBounds, updateLocalToParentTransform, updateTxBounds, usesMirroring, viewOrderProperty, visibleProperty, wouldCreateCycle
public final DoubleProperty nearClipProperty
Camera
in the eye coordinate space.
Objects closer to the eye than nearClip
are not drawn.
nearClip
is specified as a value greater than zero. A value less
than or equal to zero is treated as a very small positive number.getNearClip()
,
setNearClip(double)
public final DoubleProperty farClipProperty
Camera
in the eye coordinate space.
Objects farther away from the eye than farClip
are not
drawn.
farClip
is specified as a value greater than nearClip
.
A value less than or equal to nearClip
is treated as
nearClip
plus a very small positive number.getFarClip()
,
setFarClip(double)
private Affine3D localToSceneTx
private double farClipInScene
private double nearClipInScene
private Scene ownerScene
private SubScene ownerSubScene
private GeneralTransform3D projViewTx
private GeneralTransform3D projTx
private Affine3D viewTx
private double viewWidth
private double viewHeight
private Vec3d position
private boolean clipInSceneValid
private boolean projViewTxValid
private boolean localToSceneValid
private boolean sceneToLocalValid
private Affine3D sceneToLocalTx
private DoubleProperty nearClip
Camera
in the eye coordinate space.
Objects closer to the eye than nearClip
are not drawn.
nearClip
is specified as a value greater than zero. A value less
than or equal to zero is treated as a very small positive number.private DoubleProperty farClip
Camera
in the eye coordinate space.
Objects farther away from the eye than farClip
are not
drawn.
farClip
is specified as a value greater than nearClip
.
A value less than or equal to nearClip
is treated as
nearClip
plus a very small positive number.double getFarClipInScene()
double getNearClipInScene()
private void updateClipPlane()
Affine3D getSceneToLocalTransform()
public final void setNearClip(double value)
public final double getNearClip()
public final DoubleProperty nearClipProperty()
Camera
in the eye coordinate space.
Objects closer to the eye than nearClip
are not drawn.
nearClip
is specified as a value greater than zero. A value less
than or equal to zero is treated as a very small positive number.getNearClip()
,
setNearClip(double)
public final void setFarClip(double value)
public final double getFarClip()
public final DoubleProperty farClipProperty()
Camera
in the eye coordinate space.
Objects farther away from the eye than farClip
are not
drawn.
farClip
is specified as a value greater than nearClip
.
A value less than or equal to nearClip
is treated as
nearClip
plus a very small positive number.getFarClip()
,
setFarClip(double)
Camera copy()
private void doUpdatePeer()
void setViewWidth(double width)
double getViewWidth()
void setViewHeight(double height)
double getViewHeight()
void setOwnerScene(Scene s)
void setOwnerSubScene(SubScene s)
private void doMarkDirty(DirtyBits dirtyBit)
private void markOwnerDirty()
Affine3D getCameraTransform()
abstract void computeProjectionTransform(GeneralTransform3D proj)
abstract void computeViewTransform(Affine3D view)
GeneralTransform3D getProjViewTransform()
private Point2D project(Point3D p)
private Point2D pickNodeXYPlane(Node node, double x, double y)
Point3D pickProjectPlane(double x, double y)
abstract PickRay computePickRay(double x, double y, PickRay pickRay)
x
- horizontal coordinate of the pick ray in the projected
view, usually mouse cursor positiony
- vertical coordinate of the pick ray in the projected
view, usually mouse cursor positionpickRay
- pick ray to be reused. New instance is created in case
of null.abstract Vec3d computePosition(Vec3d position)
position
- Position to be reused. New instance is created in case
of null.private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx)
private boolean doComputeContains(double localX, double localY)