Package gov.nasa.worldwind.view
Class BasicView
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.view.BasicView
-
- All Implemented Interfaces:
AVList,MessageListener,Restorable,View,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
BasicFlyView,BasicOrbitView
public class BasicView extends WWObjectImpl implements View
A base class from whichViewimplementations can be derived. CurrentlyBasicFlyViewandBasicOrbitVieware both derived fromBasicViewBasicViewmodels the view in terms of a geographic position, and a pitch, heading, and roll. It provides a mapping from that geocentric view model to a 3D graphics modelview matrix. BasicView also manages the projection matrix via aFrustum.The view model is based on
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCOLLISION_NUM_ITERATIONSprotected static doubleCOLLISION_THRESHOLDprotected DrawContextdcprotected static doubleDEFAULT_DEPTH_RESOLUTIONThe views's default worst-case depth resolution, in meters.protected booleandetectCollisionsprotected PositioneyePositionprotected doublefarClipDistanceprotected AnglefieldOfViewThe field of view in degrees.protected Frustumfrustumprotected Globeglobeprotected booleanhadCollisionsprotected Angleheadingprotected doublehorizonDistanceprotected Vec4lastEyePointprotected PositionlastEyePositionprotected Vec4lastForwardVectorprotected FrustumlastFrustumInModelCoordsprotected Vec4lastUpVectorprotected static doubleMINIMUM_FAR_DISTANCEprotected static doubleMINIMUM_NEAR_DISTANCEprotected Matrixmodelviewprotected MatrixmodelviewInvprotected doublenearClipDistanceprotected Anglepitchprotected Matrixprojectionprotected Anglerollprotected ViewInputHandlerviewInputHandlerprotected ViewPropertyLimitsviewLimitsprotected java.awt.Rectangleviewportprotected longviewStateIDIdentifier for the modelview matrix state.-
Fields inherited from interface gov.nasa.worldwind.View
VIEW_STOPPED
-
-
Constructor Summary
Constructors Constructor Description BasicView()Construct a BasicView
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnimator(Animator animator)Add an animator to the this View.voidapply(DrawContext dc)Calculates and applies thisView'sinternal state to the graphics context in the specifieddc.protected PositioncomputeEyePositionFromModelview()protected doublecomputeFarClipDistance()protected doublecomputeFarDistance(Position eyePosition)protected doublecomputeHorizonDistance()protected doublecomputeHorizonDistance(Position eyePosition)protected doublecomputeNearClipDistance()protected doublecomputeNearDistance(Position eyePosition)doublecomputePixelSizeAtDistance(double distance)Computes the dimension (in meters) that a screen pixel would cover at a given distance from the eye point (also in meters).PositioncomputePositionFromScreenPoint(double x, double y)Computes the intersection of a line originating from the eye point and passing through (x, y) with theGlobe.LinecomputeRayFromScreenPoint(double x, double y)Computes a line, in model coordinates, originating from the eye point, and passing through the point contained by (x, y) on theView'sprojection plane (or after projection into model space).voidcopyViewState(View view)Copy the state of the givenView.protected voiddoApply(DrawContext dc)protected voiddoGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)protected voiddoRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)Vec4getCenterPoint()Gets the center point of the view.PositiongetCenterPosition()Vec4getCurrentEyePoint()Returns the most up-to-date location of the eye in cartesian coordinates.PositiongetCurrentEyePosition()Returns the current geographic coordinates of this view's eye position, as determined from this view's current parameters.Vec4getCurrentForwardVector()Returns the most up-to-date forward vector.DrawContextgetDC()Vec4getEyePoint()Returns the location of the eye in cartesian coordinates.PositiongetEyePosition()Returns the current geographic coordinates of this view's eye position, as computed for the most recent model traversal.doublegetFarClipDistance()Returns the far clipping plane distance, in eye coordinates.AnglegetFieldOfView()Returns the horizontal field-of-view angle (the angle of visibility), or null if the implementation does not support a field-of-view.Vec4getForwardVector()Returns the forward axis in cartesian coordinates.FrustumgetFrustum()Returns the viewingFrustumin eye coordinates.FrustumgetFrustumInModelCoordinates()Returns the viewingFrustumin model coordinates.GlobegetGlobe()Gets the globe associated with this view.AnglegetHeading()Returns the view's current heading.doublegetHorizonDistance()Returns the horizon distance for this view's most recently used eye position.MatrixgetModelviewMatrix()Returns the modelview matrix.doublegetNearClipDistance()Returns the near clipping plane distance, in eye coordinates.AnglegetPitch()Returns the view's current pitch.MatrixgetProjectionMatrix()Gets the projection matrix.java.lang.StringgetRestorableState()Returns an XML document string describing the object's state.AnglegetRoll()Returns this View's current roll.Vec4getUpVector()Returns the up axis in cartesian coordinates.ViewInputHandlergetViewInputHandler()Gets theViewInputHandlerbeing used to map input events toViewcontrols.java.awt.RectanglegetViewport()Returns the bounds (x, y, width, height) of the viewport.ViewPropertyLimitsgetViewPropertyLimits()Get theViewPropertyLimitsfor this view.longgetViewStateID()Get an identifier for the current state of the modelview matrix.voidgoTo(Position position, double distance)Animate to the specified position.booleanhadCollisions()booleanisAnimating()Determine if there are any animations active in theView.booleanisDetectCollisions()static voidloadGLViewState(DrawContext dc, Matrix modelview, Matrix projection)Sets the the opengl modelview and projection matrices to the given matrices.voidpopReferenceCenter(DrawContext dc)Removes the model-view matrix on top of the matrix stack, and restores the original matrix.Vec4project(Vec4 modelPoint)Maps aPointin model (cartesian) coordinates to aPointin screen coordinates.Vec4project(Vec4 point, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)Transforms the specified object coordinates into window coordinates using the given modelview and projection matrices, and viewport.MatrixpushReferenceCenter(DrawContext dc, Vec4 referenceCenter)Defines and applies a new model-view matrix in which the world origin is located atreferenceCenter.voidrestoreState(java.lang.String stateInXml)Restores the object's state to what is described in the specified XML document string.voidsetDetectCollisions(boolean detectCollisions)voidsetEyePosition(Position eyePosition)Sets the geographic position of the eye.protected voidsetFarClipDistance(double clipDistance)voidsetFieldOfView(Angle fieldOfView)Sets the horizontal field-of-view angle (the angle of visibility) to the specifiedfieldOfView.voidsetGlobe(Globe globe)Set the globe associated with this view.voidsetHeading(Angle heading)Sets the heading of the view.protected voidsetNearClipDistance(double clipDistance)voidsetOrientation(Position eyePosition, Position centerPosition)Sets the location of the eye, and the center of the screen in geographic coordinates.voidsetPitch(Angle pitch)Sets the pitch of the view.MatrixsetReferenceCenter(DrawContext dc, Vec4 referenceCenter)Sets the reference center matrix without pushing the stack.voidsetRoll(Angle roll)Set the roll of the view.voidsetViewInputHandler(ViewInputHandler viewInputHandler)protected voidsetViewState(ViewUtil.ViewState modelCoords)voidstopAnimations()Stops any animations that are active in thisViewvoidstopMovement()Stops any movement associated with thisView.Vec4unProject(Vec4 windowPoint)Maps aPointin screen coordinates to aPointin model coordinates.Vec4unProject(Vec4 windowPoint, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)Maps the given window coordinates into model coordinates using the given matrices and viewport.protected voidupdateModelViewStateID()Update the modelview state identifier.-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
fieldOfView
protected Angle fieldOfView
The field of view in degrees.
-
nearClipDistance
protected double nearClipDistance
-
farClipDistance
protected double farClipDistance
-
modelview
protected Matrix modelview
-
modelviewInv
protected Matrix modelviewInv
-
projection
protected Matrix projection
-
viewport
protected java.awt.Rectangle viewport
-
frustum
protected Frustum frustum
-
lastFrustumInModelCoords
protected Frustum lastFrustumInModelCoords
-
viewLimits
protected ViewPropertyLimits viewLimits
-
dc
protected DrawContext dc
-
detectCollisions
protected boolean detectCollisions
-
hadCollisions
protected boolean hadCollisions
-
viewInputHandler
protected ViewInputHandler viewInputHandler
-
globe
protected Globe globe
-
eyePosition
protected Position eyePosition
-
horizonDistance
protected double horizonDistance
-
roll
protected Angle roll
-
pitch
protected Angle pitch
-
heading
protected Angle heading
-
lastEyePosition
protected Position lastEyePosition
-
lastEyePoint
protected Vec4 lastEyePoint
-
lastUpVector
protected Vec4 lastUpVector
-
lastForwardVector
protected Vec4 lastForwardVector
-
viewStateID
protected long viewStateID
Identifier for the modelview matrix state. This number is incremented when one of the fields that affects the modelview matrix is set.
-
MINIMUM_NEAR_DISTANCE
protected static final double MINIMUM_NEAR_DISTANCE
- See Also:
- Constant Field Values
-
MINIMUM_FAR_DISTANCE
protected static final double MINIMUM_FAR_DISTANCE
- See Also:
- Constant Field Values
-
DEFAULT_DEPTH_RESOLUTION
protected static final double DEFAULT_DEPTH_RESOLUTION
The views's default worst-case depth resolution, in meters. May be specified in the WorldWind configuration file as thegov.nasa.worldwind.avkey.DepthResolutionproperty. The default if not specified in the configuration is 3.0 meters.
-
COLLISION_THRESHOLD
protected static final double COLLISION_THRESHOLD
- See Also:
- Constant Field Values
-
COLLISION_NUM_ITERATIONS
protected static final int COLLISION_NUM_ITERATIONS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getGlobe
public Globe getGlobe()
Description copied from interface:ViewGets the globe associated with this view. The Globe is updated at the beginning of each frame, duringView.apply().View.getGlobe()returns null if called before the first invocation ofView.apply().
-
setGlobe
public void setGlobe(Globe globe)
Set the globe associated with this view. Note that the globe is reset each frame.- Parameters:
globe- New globe.
-
getDC
public DrawContext getDC()
-
getViewInputHandler
public ViewInputHandler getViewInputHandler()
Description copied from interface:ViewGets theViewInputHandlerbeing used to map input events toViewcontrols.- Specified by:
getViewInputHandlerin interfaceView- Returns:
- the
ViewInputHandlerbeing used to map input events toViewcontrols.
-
setViewInputHandler
public void setViewInputHandler(ViewInputHandler viewInputHandler)
-
isDetectCollisions
public boolean isDetectCollisions()
-
setDetectCollisions
public void setDetectCollisions(boolean detectCollisions)
-
hadCollisions
public boolean hadCollisions()
-
copyViewState
public void copyViewState(View view)
Description copied from interface:ViewCopy the state of the givenView.- Specified by:
copyViewStatein interfaceView- Parameters:
view- TheViewwhose state is to be copied.
-
apply
public void apply(DrawContext dc)
Description copied from interface:ViewCalculates and applies thisView'sinternal state to the graphics context in the specifieddc. All subsequently rendered objects use this new state. Upon return, the OpenGL graphics context reflects the values of this view, as do any computed values of the view, such as the modelview matrix, projection matrix and viewing frustum.
-
doApply
protected void doApply(DrawContext dc)
-
stopMovement
public void stopMovement()
Description copied from interface:ViewStops any movement associated with thisView.- Specified by:
stopMovementin interfaceView
-
getViewport
public java.awt.Rectangle getViewport()
Description copied from interface:ViewReturns the bounds (x, y, width, height) of the viewport. The implementation will configure itself to render in this viewport. This value is computed in the most recent call toapply.- Specified by:
getViewportin interfaceView- Returns:
- the Rectangle of the viewport.
-
getFrustum
public Frustum getFrustum()
Description copied from interface:ViewReturns the viewingFrustumin eye coordinates. TheFrustumis the portion of viewable space defined by three sets of parallel 'clipping' planes. This value is computed in the most recent call toapply.- Specified by:
getFrustumin interfaceView- Returns:
- viewing Frustum in eye coordinates.
-
getFrustumInModelCoordinates
public Frustum getFrustumInModelCoordinates()
Description copied from interface:ViewReturns the viewingFrustumin model coordinates. Model coordinate frustums are useful for performing visibility tests against world geometry. This frustum has the same shape as the frustum returned ingetFrustum, but it has been transformed into model space. This value is computed in the most recent call toapply.- Specified by:
getFrustumInModelCoordinatesin interfaceView- Returns:
- viewing Frustum in model coordinates.
-
setFieldOfView
public void setFieldOfView(Angle fieldOfView)
Description copied from interface:ViewSets the horizontal field-of-view angle (the angle of visibility) to the specifiedfieldOfView. This may be ignored if the implementation that do not support a field-of-view.- Specified by:
setFieldOfViewin interfaceView- Parameters:
fieldOfView- the horizontal field-of-view angle.
-
getNearClipDistance
public double getNearClipDistance()
Description copied from interface:ViewReturns the near clipping plane distance, in eye coordinates. Implementations of theViewinterface are not required to have a method for setting the near and far distance. Applications that need to control the near and far clipping distances can derive fromBasicOrbitVieworBasicFlyView- Specified by:
getNearClipDistancein interfaceView- Returns:
- near clipping plane distance, in eye coordinates.
-
setNearClipDistance
protected void setNearClipDistance(double clipDistance)
-
getFarClipDistance
public double getFarClipDistance()
Description copied from interface:ViewReturns the far clipping plane distance, in eye coordinates. Implementations of theViewinterface are not required to have a method for setting the near and far distance. Applications that need to control the near and far clipping distances can derive fromBasicOrbitVieworBasicFlyView- Specified by:
getFarClipDistancein interfaceView- Returns:
- far clipping plane distance, in eye coordinates.
-
setFarClipDistance
protected void setFarClipDistance(double clipDistance)
-
getModelviewMatrix
public Matrix getModelviewMatrix()
Description copied from interface:ViewReturns the modelview matrix. The modelview matrix transforms model coordinates to eye coordinates. This matrix is constructed using the model space translation and orientation specific to each the implementation. This value is computed in the most recent call toapply.- Specified by:
getModelviewMatrixin interfaceView- Returns:
- the current model-view matrix.
-
getViewStateID
public long getViewStateID()
Get an identifier for the current state of the modelview matrix. The modelview matrix transforms model coordinates to eye coordinates. This identifier can be used to determine if the view has changed state since a previous frame.- Specified by:
getViewStateIDin interfaceView- Returns:
- an identifier for the current modelview matrix state.
-
getFieldOfView
public Angle getFieldOfView()
Description copied from interface:ViewReturns the horizontal field-of-view angle (the angle of visibility), or null if the implementation does not support a field-of-view.- Specified by:
getFieldOfViewin interfaceView- Returns:
- Angle of the horizontal field-of-view, or null if none exists.
-
project
public Vec4 project(Vec4 modelPoint)
Description copied from interface:ViewMaps aPointin model (cartesian) coordinates to aPointin screen coordinates. The returned x and y are relative to the lower left hand screen corner, while z is the screen depth-coordinate. If the model point cannot be successfully mapped, this will return null.
-
unProject
public Vec4 unProject(Vec4 windowPoint)
Description copied from interface:ViewMaps aPointin screen coordinates to aPointin model coordinates. The input x and y are relative to the lower left hand screen corner, while z is the screen depth-coordinate. If the screen point cannot be successfully mapped, this will return null.
-
getEyePoint
public Vec4 getEyePoint()
Description copied from interface:ViewReturns the location of the eye in cartesian coordinates. This value is computed in the most recent call toapply.- Specified by:
getEyePointin interfaceView- Returns:
- Vec4 of the eye.
-
getCenterPoint
public Vec4 getCenterPoint()
Description copied from interface:ViewGets the center point of the view.- Specified by:
getCenterPointin interfaceView- Returns:
- the center point of the view if that point is on the globe, otherwise, return null
-
getCenterPosition
public Position getCenterPosition()
-
getCurrentEyePoint
public Vec4 getCurrentEyePoint()
Description copied from interface:ViewReturns the most up-to-date location of the eye in cartesian coordinates. UnlikeView.getEyePosition()andView.getEyePoint(), getCurrentEyePoint will return the View's immediate position.- Specified by:
getCurrentEyePointin interfaceView- Returns:
- Vec4 of the eye.
-
getCurrentEyePosition
public Position getCurrentEyePosition()
Description copied from interface:ViewReturns the current geographic coordinates of this view's eye position, as determined from this view's current parameters.Note: The value returned is not necessarily the value specified to
View.setEyePosition(gov.nasa.worldwind.geom.Position)but is the eye position corresponding to this view's current parameters.- Specified by:
getCurrentEyePositionin interfaceView- Returns:
- the position of the eye corresponding to the current parameters of this view.
-
getEyePosition
public Position getEyePosition()
Description copied from interface:ViewReturns the current geographic coordinates of this view's eye position, as computed for the most recent model traversal.Note: The value returned is not necessarily the value specified to
View.setEyePosition(gov.nasa.worldwind.geom.Position)but is the eye position corresponding to this view's most recently applied state.- Specified by:
getEyePositionin interfaceView- Returns:
- the position of the eye corresponding to the most recent application of this view, or null if the view has not yet been applied.
-
setEyePosition
public void setEyePosition(Position eyePosition)
Description copied from interface:ViewSets the geographic position of the eye.- Specified by:
setEyePositionin interfaceView- Parameters:
eyePosition- the eye position.
-
getHeading
public Angle getHeading()
Description copied from interface:ViewReturns the view's current heading.- Specified by:
getHeadingin interfaceView- Returns:
- Angle of the view's heading.
-
setHeading
public void setHeading(Angle heading)
Description copied from interface:ViewSets the heading of the view. The implementation may interpret this command in whatever way it chooses.- Specified by:
setHeadingin interfaceView- Parameters:
heading- The direction to aim the view in degrees
-
getPitch
public Angle getPitch()
Description copied from interface:ViewReturns the view's current pitch.
-
setPitch
public void setPitch(Angle pitch)
Description copied from interface:ViewSets the pitch of the view. The implementation may interpret pitch as it chooses
-
setRoll
public void setRoll(Angle roll)
Description copied from interface:ViewSet the roll of the view. The implementation may interpret roll as it chooses.
-
getRoll
public Angle getRoll()
Description copied from interface:ViewReturns this View's current roll.
-
getUpVector
public Vec4 getUpVector()
Description copied from interface:ViewReturns the up axis in cartesian coordinates. This value is computed in the most recent call toapply.- Specified by:
getUpVectorin interfaceView- Returns:
- Vec4 of the up axis.
-
getForwardVector
public Vec4 getForwardVector()
Description copied from interface:ViewReturns the forward axis in cartesian coordinates. This value is computed in the most recent call toapply.- Specified by:
getForwardVectorin interfaceView- Returns:
- Vec4 of the forward axis.
-
getCurrentForwardVector
public Vec4 getCurrentForwardVector()
Returns the most up-to-date forward vector. UnlikegetForwardVector(), this method will return the View's immediate forward vector.- Returns:
- Vec4 of the forward axis.
-
setViewState
protected void setViewState(ViewUtil.ViewState modelCoords)
-
setOrientation
public void setOrientation(Position eyePosition, Position centerPosition)
Description copied from interface:ViewSets the location of the eye, and the center of the screen in geographic coordinates. The implementation may interpret this command in whatever way it chooses, so long as the eye is placed at the specifiedeyePosition, and the center of the screen is the specifiedcenterPosition. Specifically, implementations must determine what the up direction will be given these parameters, and apply these parameters in a meaningful way.- Specified by:
setOrientationin interfaceView- Parameters:
eyePosition- Position of they eye.centerPosition- Position of the screen center.
-
stopAnimations
public void stopAnimations()
Description copied from interface:ViewStops any animations that are active in thisView- Specified by:
stopAnimationsin interfaceView
-
isAnimating
public boolean isAnimating()
Description copied from interface:ViewDetermine if there are any animations active in theView.- Specified by:
isAnimatingin interfaceView- Returns:
- true if there are active animations, false otherwise.
-
goTo
public void goTo(Position position, double distance)
Description copied from interface:ViewAnimate to the specified position. The implementation is expected to animate theViewto look at the given position from the given elevation.
-
computeRayFromScreenPoint
public Line computeRayFromScreenPoint(double x, double y)
Description copied from interface:ViewComputes a line, in model coordinates, originating from the eye point, and passing through the point contained by (x, y) on theView'sprojection plane (or after projection into model space).- Specified by:
computeRayFromScreenPointin interfaceView- Parameters:
x- the horizontal coordinate originating from the left side ofView'sprojection plane.y- the vertical coordinate originating from the top ofView'sprojection plane.- Returns:
- a line beginning at the
View'seye point and passing through (x, y) transformed into model space.
-
computePositionFromScreenPoint
public Position computePositionFromScreenPoint(double x, double y)
Description copied from interface:ViewComputes the intersection of a line originating from the eye point and passing through (x, y) with theGlobe. Only the ellipsoid itself is considered; terrain elevations are not incorporated.- Specified by:
computePositionFromScreenPointin interfaceView- Parameters:
x- the horizontal coordinate originating from the left side ofView'sprojection plane.y- the vertical coordinate originating from the top ofView'sprojection plane.- Returns:
- the point on the surface in polar coordinates.
-
computePixelSizeAtDistance
public double computePixelSizeAtDistance(double distance)
Description copied from interface:ViewComputes the dimension (in meters) that a screen pixel would cover at a given distance from the eye point (also in meters). The distance is interpreted as the linear distance between the eye point and the world point in question. This computation assumes that pixels dimensions are square, and therefore returns a single dimension.- Specified by:
computePixelSizeAtDistancein interfaceView- Parameters:
distance- the distance in meters from the eye point. This value must be positive but is otherwise unbounded.- Returns:
- the dimension of a pixel in meters at the given distance.
-
computeEyePositionFromModelview
protected Position computeEyePositionFromModelview()
-
getHorizonDistance
public double getHorizonDistance()
Description copied from interface:ViewReturns the horizon distance for this view's most recently used eye position. The eye position changes when this view changes, so the horizon distance also changes when this view changes. The value returned is the value used during the most recent model traversal.- Specified by:
getHorizonDistancein interfaceView- Returns:
- the horizon position, in meters, or 0 if this view has not yet been applied.
-
computeHorizonDistance
protected double computeHorizonDistance()
-
computeHorizonDistance
protected double computeHorizonDistance(Position eyePosition)
-
getViewPropertyLimits
public ViewPropertyLimits getViewPropertyLimits()
Description copied from interface:ViewGet theViewPropertyLimitsfor this view.- Specified by:
getViewPropertyLimitsin interfaceView- Returns:
- the
ViewPropertyLimitsfor this view.
-
computeNearClipDistance
protected double computeNearClipDistance()
-
computeFarClipDistance
protected double computeFarClipDistance()
-
computeNearDistance
protected double computeNearDistance(Position eyePosition)
-
computeFarDistance
protected double computeFarDistance(Position eyePosition)
-
getProjectionMatrix
public Matrix getProjectionMatrix()
Description copied from interface:ViewGets the projection matrix. The projection matrix transforms eye coordinates to screen coordinates. This matrix is constructed using the projection parameters specific to each implementation ofView. The methodView.getFrustum()returns the geometry corresponding to this matrix. This value is computed in the most recent call toapply.- Specified by:
getProjectionMatrixin interfaceView- Returns:
- the current projection matrix.
-
getRestorableState
public java.lang.String getRestorableState()
Description copied from interface:RestorableReturns an XML document string describing the object's state. This state can be restored later by callingrestoreStateand passing the XML document.- Specified by:
getRestorableStatein interfaceRestorable- Returns:
- an XML document string describing the object's state.
-
restoreState
public void restoreState(java.lang.String stateInXml)
Description copied from interface:RestorableRestores the object's state to what is described in the specified XML document string.- Specified by:
restoreStatein interfaceRestorable- Parameters:
stateInXml- an XML document string describing an object's state.
-
updateModelViewStateID
protected void updateModelViewStateID()
Update the modelview state identifier. This method should be called whenever one of the fields that affects the modelview matrix is changed.
-
doGetRestorableState
protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
-
doRestoreState
protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
-
pushReferenceCenter
public Matrix pushReferenceCenter(DrawContext dc, Vec4 referenceCenter)
Description copied from interface:ViewDefines and applies a new model-view matrix in which the world origin is located atreferenceCenter. Geometry rendered after a call topushReferenceCentershould be transformed with respect toreferenceCenter, rather than the canonical origin (0, 0, 0). Calls topushReferenceCentermust be followed bypopReferenceCenterafter rendering is complete. Note that calls toView.getModelviewMatrix()will not return reference-center model-view matrix, but the original matrix.- Specified by:
pushReferenceCenterin interfaceView- Parameters:
dc- the current WorldWind drawing context on which new model-view state will be applied.referenceCenter- the location to become the new world origin.- Returns:
- a new model-view matrix with origin is at
referenceCenter, or null if this method failed.
-
setReferenceCenter
public Matrix setReferenceCenter(DrawContext dc, Vec4 referenceCenter)
Description copied from interface:ViewSets the reference center matrix without pushing the stack.- Specified by:
setReferenceCenterin interfaceView- Parameters:
dc- the drawing context.referenceCenter- the new reference center- Returns:
- a new model-view matrix with origin is at
referenceCenter, or null if this method failed. - See Also:
View.pushReferenceCenter(gov.nasa.worldwind.render.DrawContext, gov.nasa.worldwind.geom.Vec4)
-
popReferenceCenter
public void popReferenceCenter(DrawContext dc)
Removes the model-view matrix on top of the matrix stack, and restores the original matrix.- Specified by:
popReferenceCenterin interfaceView- Parameters:
dc- the current WorldWind drawing context on which the original matrix will be restored.- Throws:
java.lang.IllegalArgumentException- ifdcis null, or if theGlobeorGLinstances indcare null.
-
project
public Vec4 project(Vec4 point, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)
Transforms the specified object coordinates into window coordinates using the given modelview and projection matrices, and viewport.- Parameters:
point- The object coordinate to transformmodelview- The modelview matrixprojection- The projection matrixviewport- The viewport- Returns:
- the transformed coordinates
-
unProject
public Vec4 unProject(Vec4 windowPoint, Matrix modelview, Matrix projection, java.awt.Rectangle viewport)
Maps the given window coordinates into model coordinates using the given matrices and viewport.- Parameters:
windowPoint- the window pointmodelview- the modelview matrixprojection- the projection matrixviewport- the window viewport- Returns:
- the unprojected point
-
loadGLViewState
public static void loadGLViewState(DrawContext dc, Matrix modelview, Matrix projection)
Sets the the opengl modelview and projection matrices to the given matrices.- Parameters:
dc- the drawing contextmodelview- the modelview matrixprojection- the projection matrix
-
addAnimator
public void addAnimator(Animator animator)
Add an animator to the this View. The View does not start the animator.- Specified by:
addAnimatorin interfaceView- Parameters:
animator- theAnimatorto be added
-
-