Package javafx.scene

Class Camera

  • All Implemented Interfaces:
    Styleable, EventTarget
    Direct Known Subclasses:
    ParallelCamera, PerspectiveCamera

    public abstract class Camera
    extends Node
    Base class for a camera used to render a scene. The camera defines the mapping of the scene coordinate space onto the window. Camera is an abstract class with two concrete subclasses: 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.

    Since:
    JavaFX 2.0
    • Property Detail

      • nearClip

        public final DoubleProperty nearClipProperty
        Specifies the distance from the eye of the near clipping plane of this 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.
        Default value:
        0.1
        Since:
        JavaFX 8.0
        See Also:
        getNearClip(), setNearClip(double)
      • farClip

        public final DoubleProperty farClipProperty
        Specifies the distance from the eye of the far clipping plane of this 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.
        Default value:
        100.0
        Since:
        JavaFX 8.0
        See Also:
        getFarClip(), setFarClip(double)
    • Constructor Detail

      • Camera

        protected Camera()
    • Method Detail

      • setNearClip

        public final void setNearClip​(double value)
        Sets the value of the property nearClip.
        Property description:
        Specifies the distance from the eye of the near clipping plane of this 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.
        Default value:
        0.1
        Since:
        JavaFX 8.0
      • getNearClip

        public final double getNearClip()
        Gets the value of the property nearClip.
        Property description:
        Specifies the distance from the eye of the near clipping plane of this 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.
        Default value:
        0.1
        Since:
        JavaFX 8.0
      • nearClipProperty

        public final DoubleProperty nearClipProperty()
        Specifies the distance from the eye of the near clipping plane of this 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.
        Default value:
        0.1
        Since:
        JavaFX 8.0
        See Also:
        getNearClip(), setNearClip(double)
      • setFarClip

        public final void setFarClip​(double value)
        Sets the value of the property farClip.
        Property description:
        Specifies the distance from the eye of the far clipping plane of this 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.
        Default value:
        100.0
        Since:
        JavaFX 8.0
      • getFarClip

        public final double getFarClip()
        Gets the value of the property farClip.
        Property description:
        Specifies the distance from the eye of the far clipping plane of this 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.
        Default value:
        100.0
        Since:
        JavaFX 8.0
      • farClipProperty

        public final DoubleProperty farClipProperty()
        Specifies the distance from the eye of the far clipping plane of this 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.
        Default value:
        100.0
        Since:
        JavaFX 8.0
        See Also:
        getFarClip(), setFarClip(double)