Package snap.gfx3d
Class Camera
java.lang.Object
snap.gfx3d.Camera
This class represent a camera focusing on a scene and manages a display list of simple paths based on
the scene shapes and the camera transform.
Camera transform is currently relative to scene. At some point, that may become an option instead.
3D conventions:
Coordinate system: Right handed (not left handed)
Polygon front: Right hand rule (counter-clockwise defined polygons face forward)
Transforms: Row major notation (as opposed to column major, points are assumed row vectors)
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add listener.double
Returns the optimal distance from center of scene to camera when in gimbal mode.protected void
Clears cached values.void
Copy attributes of another camera.protected final void
firePropChange
(String aProp, Object oldVal, Object newVal) Fires a property change for given property name, old value, new value and index.protected void
firePropChange
(PropChange aPCE) Fires a given property change.Returns the transform from camera coords to clip space (AKA the 'Projection' matrix).double[]
Returns the CameraToClip transform as double array.Returns the transform from camera to View space.double
Returns the field of view of the camera (derived from focalLength).double
Returns the field of view Y of camera (derived from focalLength).double
Returns the focal length of the camera (derived from the field of view and with view size).double
Returns the distance from center of scene to camera when in gimbal mode.Returns the camera normal as a vector.double
getPitch()
Returns the rotation about the X axis in degrees.double
Returns the optimal distance from center of scene to camera when in gimbal mode.void
getRayToViewPoint
(double aX, double aY, Point3D rayOrigin, Vector3D rayDir) Calculates and sets the ray (origin,dir) from camera origin to 2D point in camera view coords.Returns the renderer.double
getRoll()
Returns the rotation about the Z axis in degrees.getScene()
Returns the scene this camera is associated with.Returns the bounding rect for camera paths.Returns the transform from scene coords to camera coords.double[]
Returns the SceneToCamera transform as double array.Returns the transform from scene to View space.double
Returns the height of the camera viewing plane.double
Returns the width of the camera viewing plane.double
getYaw()
Returns the rotation about the Y axis in degrees.boolean
Returns whether a vector is facing camera.boolean
isFacingAway
(Vector3D aV3D) Returns whether a vector is facing away from camera.boolean
isOrtho()
Returns whether camera is viewing in orthographic projection (no perspective).boolean
Returns whether PrefGimbalRadius is explicitly set.void
paintScene
(Painter aPntr) Paints the scene from the view of this camera for given painter.void
processEvent
(ViewEvent anEvent) Viewer method.void
Remove listener.protected void
Called when Scene changes.void
setFieldOfViewY
(double aValue) Sets the field of view Y of camera.void
setFocalLength
(double aValue) Sets the focal length of the camera.protected void
setGimbalRadius
(double aValue) Sets the distance from center of scene to camera when in gimbal mode.void
setOrtho
(boolean aValue) Sets whether camera is viewing in orthographic projection (no perspective).void
setPitch
(double aValue) Sets the rotation about the X axis in degrees.void
setPrefGimbalRadius
(double aValue) Sets the optimal distance from center of scene to camera when in gimbal mode.void
setRenderer
(Renderer aRenderer) Sets the renderer.void
setRoll
(double aValue) Sets the rotation about the Z axis in degrees.void
Sets the scene this camera is associated with.void
setViewHeight
(double aValue) Sets the height of the camera viewing plane.void
setViewWidth
(double aValue) Sets the width of the camera viewing plane.void
setYaw
(double aValue) Sets the rotation about the Y axis in degrees.void
setYawPitchRollForSideAndPos
(Side3D aSide, Pos aPos) Set camera view to given side.
-
Field Details
-
_pcs
-
ViewWidth_Prop
- See Also:
-
ViewHeight_Prop
- See Also:
-
Yaw_Prop
- See Also:
-
Pitch_Prop
- See Also:
-
Roll_Prop
- See Also:
-
FocalLength_Prop
- See Also:
-
GimbalRadius_Prop
- See Also:
-
Ortho_Prop
- See Also:
-
PrefGimbalRadius_Prop
- See Also:
-
Renderer_Prop
- See Also:
-
-
Constructor Details
-
Camera
public Camera()Constructor.
-
-
Method Details
-
getScene
Returns the scene this camera is associated with. -
setScene
Sets the scene this camera is associated with. -
getViewWidth
public double getViewWidth()Returns the width of the camera viewing plane. -
setViewWidth
public void setViewWidth(double aValue) Sets the width of the camera viewing plane. -
getViewHeight
public double getViewHeight()Returns the height of the camera viewing plane. -
setViewHeight
public void setViewHeight(double aValue) Sets the height of the camera viewing plane. -
getYaw
public double getYaw()Returns the rotation about the Y axis in degrees. -
setYaw
public void setYaw(double aValue) Sets the rotation about the Y axis in degrees. -
getPitch
public double getPitch()Returns the rotation about the X axis in degrees. -
setPitch
public void setPitch(double aValue) Sets the rotation about the X axis in degrees. -
getRoll
public double getRoll()Returns the rotation about the Z axis in degrees. -
setRoll
public void setRoll(double aValue) Sets the rotation about the Z axis in degrees. -
getFocalLength
public double getFocalLength()Returns the focal length of the camera (derived from the field of view and with view size). -
setFocalLength
public void setFocalLength(double aValue) Sets the focal length of the camera. Two feet is normal (1728 points). -
getGimbalRadius
public double getGimbalRadius()Returns the distance from center of scene to camera when in gimbal mode. -
setGimbalRadius
protected void setGimbalRadius(double aValue) Sets the distance from center of scene to camera when in gimbal mode. -
isPrefGimbalRadiusSet
public boolean isPrefGimbalRadiusSet()Returns whether PrefGimbalRadius is explicitly set. -
getPrefGimbalRadius
public double getPrefGimbalRadius()Returns the optimal distance from center of scene to camera when in gimbal mode. -
setPrefGimbalRadius
public void setPrefGimbalRadius(double aValue) Sets the optimal distance from center of scene to camera when in gimbal mode. -
calcPrefGimbalRadius
public double calcPrefGimbalRadius()Returns the optimal distance from center of scene to camera when in gimbal mode. -
getFieldOfViewX
public double getFieldOfViewX()Returns the field of view of the camera (derived from focalLength). -
getFieldOfViewY
public double getFieldOfViewY()Returns the field of view Y of camera (derived from focalLength). -
setFieldOfViewY
public void setFieldOfViewY(double aValue) Sets the field of view Y of camera. -
isOrtho
public boolean isOrtho()Returns whether camera is viewing in orthographic projection (no perspective). -
setOrtho
public void setOrtho(boolean aValue) Sets whether camera is viewing in orthographic projection (no perspective). -
getNormal
Returns the camera normal as a vector. -
getSceneToCamera
Returns the transform from scene coords to camera coords. -
getCameraToClip
Returns the transform from camera coords to clip space (AKA the 'Projection' matrix). -
getCameraToView
Returns the transform from camera to View space. -
getSceneToView
Returns the transform from scene to View space. -
getSceneToCameraArray
public double[] getSceneToCameraArray()Returns the SceneToCamera transform as double array. -
getCameraToClipArray
public double[] getCameraToClipArray()Returns the CameraToClip transform as double array. -
setYawPitchRollForSideAndPos
Set camera view to given side. -
isFacing
Returns whether a vector is facing camera. -
isFacingAway
Returns whether a vector is facing away from camera. -
getRenderer
Returns the renderer. -
setRenderer
Sets the renderer. -
getRayToViewPoint
Calculates and sets the ray (origin,dir) from camera origin to 2D point in camera view coords. -
paintScene
Paints the scene from the view of this camera for given painter. -
processEvent
Viewer method. -
getSceneBounds2D
Returns the bounding rect for camera paths. -
sceneDidChange
protected void sceneDidChange()Called when Scene changes. -
clearCachedValues
protected void clearCachedValues()Clears cached values. -
copy3D
Copy attributes of another camera. -
addPropChangeListener
Add listener. -
removePropChangeListener
Remove listener. -
firePropChange
Fires a property change for given property name, old value, new value and index. -
firePropChange
Fires a given property change.
-