public class TLspViewXYZWorldTransformation3D extends ALspViewXYZWorldTransformation
An ALspViewXYZWorldTransformation
which provides 3D perspective projection for an ILspView
. This transformation is defined by an orthogonal coordinate frame which is in turn
specified by an "eye point", a "reference point" and an "up vector". The eye point is the
location of the viewpoint in the 3D world; the reference point is a point in the world towards
which the viewer is oriented, and the up vector is a normalized vector, relative to the eye
point, which defines the "up" direction of the viewer.
The eye point, reference point and up vector cannot be manipulated directly. Instead, the
viewer can be positioned using the more intuitive lookAt(com.luciad.shape.ILcdPoint, double, double, double, double)
and lookFrom(com.luciad.shape.ILcdPoint, double, double, double, double)
methods,
both of which express the orientation of the viewer in terms of yaw, pitch and roll angles. The
definition of these angles is as follows:
This transformation is not thread-safe for writing and should only be modified from the painting thread. The transformation is thread-safe for reading. However, to obtain consistent results on asynchronous tasks, an immutable clone should be used.
TLspViewTransformationUtil
ALspViewXYZWorldTransformation.LocationMode, ALspViewXYZWorldTransformation.OutputDevice
Constructor and Description |
---|
TLspViewXYZWorldTransformation3D(ILspView aView)
Constructs a new, uninitialized transformation.
|
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation3D> aConstraint)
Adds a new constraint.
|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Registers the given
PropertyChangeListener to be notified when this object's
properties change. |
void |
apply(ILcdGLDrawable aGLDrawable)
Applies the current world-to-view transformation to the specified
ILcdGLDrawable . |
void |
applyLocalOrigin(ILcdGLDrawable aGLDrawable,
ILcdPoint aOrigin)
Applies a local coordinate origin to the viewer.
|
void |
clip2viewSFCT(ILcdPoint aClipPoint,
double aW,
ILcd3DEditablePoint aViewPointSFCT)
Transforms the given point in clip coordinates to a point in view coordinates.
|
TLspViewXYZWorldTransformation3D |
clone()
Returns a deep clone of this transformation.
|
double |
getAspectRatio()
Returns the aspect ratio of the view's width and height.
|
Iterable<ALspCameraConstraint<TLspViewXYZWorldTransformation3D>> |
getConstraints()
Returns an (unmodifiable)
Iterable containing all the constraints currently set on
this TLspViewXYZWorldTransformation3D . |
double |
getDistance()
Returns the distance from the eye point to the reference point.
|
ILcdPoint |
getEyePoint()
Returns the position of the viewer in world coordinates.
|
double |
getFar()
Returns the far clipping plane distance of the frustum.
|
double |
getFieldOfView()
Returns the vertical field-of-view angle of the viewer in degrees.
|
TLspFrustum |
getFrustum()
Returns the current view frustum.
|
ILcdComplexPolygon |
getGeodeticVisibleArea()
Returns a polygon which approximates the area of the globe which is
visible in the current view.
|
int |
getHeight()
Returns the height of the viewport in pixels.
|
Object |
getIdentifier()
Returns an identifier object that can be used to efficiently
compare transformations.
|
TLspViewXYZWorldTransformation3D |
getImmutableClone()
Returns an immutable deep clone of this transformation
|
double[] |
getModelViewMatrix()
Gets the model-view matrix.
|
double |
getNear()
Returns the near clipping plane distance of the frustum.
|
double |
getPitch()
Returns the pitch angle of the viewer.
|
double[] |
getProjectionMatrix()
Gets the projection matrix.
|
ILcdPoint |
getReferencePoint()
Returns the reference point of the viewer in world coordinates.
|
double |
getRoll()
Returns the roll angle of the viewer.
|
double |
getScaleX()
Returns the horizontal scale for which to paint objects.
|
double |
getScaleY()
Returns the vertical scale for which to paint objects.
|
TLspViewXYZWorldTransformation3D |
getStereoTransformation(TLspPaintPhase.PaintStereo aStereoPhase)
Returns a view-to-world transformation that corresponds with the eye position for the provided
stereo phase.
|
ILcdPoint |
getUpVector()
Returns the up vector of the viewer.
|
int |
getWidth()
Returns the width of the viewport in pixels.
|
double |
getYaw()
Returns the yaw angle of the viewer.
|
boolean |
isAdjustDepthRange()
This method returns true when the near and far plane are automatically adjusted each time
lookAt(com.luciad.shape.ILcdPoint, double, double, double, double) or lookFrom(com.luciad.shape.ILcdPoint, double, double, double, double) is called. |
void |
lookAt(ILcdPoint aLookAt,
double aDistance,
double aYaw,
double aPitch,
double aRoll)
Orients the viewer towards a given reference point.
|
void |
lookFrom(ILcdPoint aLookFrom,
double aDistance,
double aYaw,
double aPitch,
double aRoll)
Positions the viewer at a given eye point.
|
void |
removeConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation3D> aConstraint)
Removes the given constraint.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
De-registers the given
PropertyChangeListener from receiving property change events
for this object. |
void |
restoreLocalOrigin(ILcdGLDrawable aGLDrawable)
Undoes a previously applied local coordinate origin.
|
void |
set(ALspViewXYZWorldTransformation aOther)
Sets this view transformation's properties to be equal to the other one.
|
void |
setAdjustDepthRange(boolean aAdjustDepthRange)
Enables or disables automatically adjusting depth ranges.
|
void |
setFar(double aFar)
Sets the far clipping plane distance of the frustum.
|
void |
setFieldOfView(double aFieldOfView)
Sets the vertical field-of-view angle of the viewer.
|
void |
setNear(double aNear)
Sets the near clipping plane distance of the frustum.
|
void |
setSize(int aWidth,
int aHeight)
Sets the size of the viewport.
|
String |
toString() |
void |
viewPoint2WorldSFCT(ILcdPoint aViewPoint,
ILcd3DEditablePoint aWorldPointSFCT)
Transforms a point in view coordinates to a point in world coordinates.
|
double |
worldPoint2ClipSFCT(ILcdPoint aWorldPoint,
ILcd3DEditablePoint aClipPointSFCT)
Transforms the given point in world coordinates to a point in clip coordinates.
|
void |
worldPoint2ViewSFCT(ILcdPoint aWorldPoint,
ILcd3DEditablePoint aViewPointSFCT)
Transforms a point in world coordinates to a point in view coordinates.
|
getClip, getFeatureScale, getMapScale, getOutputDevice, getScale, getView, toolkitPoint2ViewSFCT, toolkitPoint2WorldSFCT, toolkitPoint2WorldSFCT, viewAWTPoint2worldSFCT, viewBounds2worldSFCT, viewPoint2ToolkitSFCT, viewPoint2WorldSFCT, worldBounds2viewSFCT, worldPoint2ToolkitSFCT
public TLspViewXYZWorldTransformation3D(ILspView aView)
lookAt(com.luciad.shape.ILcdPoint, double, double, double, double)
or lookFrom(com.luciad.shape.ILcdPoint, double, double, double, double)
to
set an initial viewer location before using this transformation, or use
TLspViewTransformationUtil
to
preserve the visible area.aView
- the view for which this transformation can be used.public TLspViewXYZWorldTransformation3D getImmutableClone()
ALspViewXYZWorldTransformation
Use this clone for example to pass the view-to-world transformation to another thread than the painting thread.
getImmutableClone
in class ALspViewXYZWorldTransformation
public boolean isAdjustDepthRange()
lookAt(com.luciad.shape.ILcdPoint, double, double, double, double)
or lookFrom(com.luciad.shape.ILcdPoint, double, double, double, double)
is called.public void setAdjustDepthRange(boolean aAdjustDepthRange)
setNear(double)
and setFar(double)
. The default
value is true.aAdjustDepthRange
- true to enable and false to disable automatically adjusting the depth range.public void addConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation3D> aConstraint)
aConstraint
- a constraint.public void removeConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation3D> aConstraint)
aConstraint
- a constraint.public Iterable<ALspCameraConstraint<TLspViewXYZWorldTransformation3D>> getConstraints()
Iterable
containing all the constraints currently set on
this TLspViewXYZWorldTransformation3D
.public void lookAt(ILcdPoint aLookAt, double aDistance, double aYaw, double aPitch, double aRoll)
aLookAt
- the point (in world coordinates) at which to put the viewer's
reference pointaDistance
- the distance from the reference point at which to put the eye pointaYaw
- the desired yaw angle from the eye point to the reference point (in
degrees)aPitch
- the desired pitch angle from the eye point to the reference point
(in degrees)aRoll
- the desired roll angle of the viewer around its line-of-sight axis
(in degrees)TLspViewXYZWorldTransformation3D
public void lookFrom(ILcdPoint aLookFrom, double aDistance, double aYaw, double aPitch, double aRoll)
aLookFrom
- the point (in world coordinates) at which to put the eye pointaDistance
- the distance from the eye point at which to put the viewer's
reference pointaYaw
- the desired yaw angle from the eye point to the reference point (in
degrees)aPitch
- the desired pitch angle from the eye point to the reference point
(in
degrees)aRoll
- the desired roll angle of the viewer around its line-of-sight axis
(in degrees)TLspViewXYZWorldTransformation3D
public void set(ALspViewXYZWorldTransformation aOther)
set
in class ALspViewXYZWorldTransformation
aOther
- the transformation to copy the properties fromIllegalArgumentException
- if aOther is not a TLspViewXYZWorldTransformation3DTLspViewXYZWorldTransformation2D.set(ALspViewXYZWorldTransformation)
,
set(ALspViewXYZWorldTransformation)
public double getDistance()
public double getYaw()
public double getPitch()
public double getRoll()
public TLspViewXYZWorldTransformation3D clone()
Note: this method doesn't copy over or clone the added constraints.
clone
in class ALspViewXYZWorldTransformation
public void apply(ILcdGLDrawable aGLDrawable)
ALspViewXYZWorldTransformation
ILcdGLDrawable
. This method sets the OpenGL modelview and projection
matrices as appropriate.apply
in class ALspViewXYZWorldTransformation
aGLDrawable
- the ILcdGLDrawable
to be configuredpublic TLspFrustum getFrustum()
ALspViewXYZWorldTransformation
getFrustum
in class ALspViewXYZWorldTransformation
public void worldPoint2ViewSFCT(ILcdPoint aWorldPoint, ILcd3DEditablePoint aViewPointSFCT)
ALspViewXYZWorldTransformation
See the class documentation for important information about view coordinates and DPI scaling.
worldPoint2ViewSFCT
in class ALspViewXYZWorldTransformation
aWorldPoint
- the world point to transformaViewPointSFCT
- the point to be setpublic void viewPoint2WorldSFCT(ILcdPoint aViewPoint, ILcd3DEditablePoint aWorldPointSFCT)
ALspViewXYZWorldTransformation
Transforms a point in view coordinates to a point in world coordinates. The result of the transformation is stored in the second point parameter.
Note: this method interprets the z value ([0,1]) of the given point as the depth value
in view space. If you are using 2D view points (e.g. the x and y coordinates of the mouse), it
is advised to use ALspViewXYZWorldTransformation.viewPoint2WorldSFCT(Point, LocationMode, ILcd3DEditablePoint)
, which can calculate
the world point at sea level or on the surface closest to the viewer.
See the class documentation for important information about view coordinates and DPI scaling.
viewPoint2WorldSFCT
in class ALspViewXYZWorldTransformation
aViewPoint
- the view point to transform to world coordinatesaWorldPointSFCT
- the point to setpublic void setSize(int aWidth, int aHeight)
ALspViewXYZWorldTransformation
setSize
in class ALspViewXYZWorldTransformation
aWidth
- the new width of the viewportaHeight
- the new height of the viewportpublic int getWidth()
ALspViewXYZWorldTransformation
getWidth
in class ALspViewXYZWorldTransformation
public int getHeight()
ALspViewXYZWorldTransformation
getHeight
in class ALspViewXYZWorldTransformation
public Object getIdentifier()
ALspViewXYZWorldTransformation
Object yourIdentifier = ...;
ALspViewXYZWorldTransformation v2w = ...;
Object myIdentifier = v2w.getIdentifier();
boolean transformationValid = yourIdentifier.equals(myIdentifier);
getIdentifier
in class ALspViewXYZWorldTransformation
public void addPropertyChangeListener(PropertyChangeListener aListener)
ILcdPropertyChangeSource
Registers the given PropertyChangeListener
to be notified when this object's
properties change.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source,
you can use a ALcdWeakPropertyChangeListener
instance as property change listener.
aListener
- The listener to be notifiedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aListener)
ILcdPropertyChangeSource
De-registers the given PropertyChangeListener
from receiving property change events
for this object.
If the listener was added more than once, it will be notified one less time after being
removed.
If the listener is null
, or was never added, no exception is thrown and no action is taken.
aListener
- the listener that should no longer be notified of changes of
this object's propertiesILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
public ILcdPoint getEyePoint()
public ILcdPoint getReferencePoint()
public ILcdPoint getUpVector()
public double getFieldOfView()
public void setFieldOfView(double aFieldOfView)
aFieldOfView
- the desired vertical field-of-view angle in degreespublic double getNear()
public void setNear(double aNear)
aNear
- the desired near clipping plane distance, in world unitspublic double getFar()
public void setFar(double aFar)
aFar
- the desired far clipping plane distance, in world unitspublic double getAspectRatio()
public void applyLocalOrigin(ILcdGLDrawable aGLDrawable, ILcdPoint aOrigin)
applyLocalOrigin
in class ALspViewXYZWorldTransformation
aGLDrawable
- the access point to OpenGLaOrigin
- the local origin to applypublic void restoreLocalOrigin(ILcdGLDrawable aGLDrawable)
restoreLocalOrigin
in class ALspViewXYZWorldTransformation
aGLDrawable
- the access point to OpenGLpublic double[] getModelViewMatrix()
The array is a linearized 4x4 matrix where result[0] corresponds to row=0 and column=0, result[1] corresponds to row=1, column=0, etc. Note that this corresponds to how OpenGL expects matrices to be linearized.
public double[] getProjectionMatrix()
The array is a linearized 4x4 matrix where result[0] corresponds to row=0 and column=0, result[1] corresponds to row=1, column=0, etc. Note that this corresponds to how OpenGL expects matrices to be linearized.
public double worldPoint2ClipSFCT(ILcdPoint aWorldPoint, ILcd3DEditablePoint aClipPointSFCT)
Transforming a point from world to clip coordinates and from clip to view coordinates yields the same result as transforming the point directly from world to view coordinates.
aWorldPoint
- the point in world coordinatesaClipPointSFCT
- the resulting clip point's XYZ coordinatesclip2viewSFCT(com.luciad.shape.ILcdPoint, double, com.luciad.shape.shape3D.ILcd3DEditablePoint)
,
worldPoint2ViewSFCT(com.luciad.shape.ILcdPoint, com.luciad.shape.shape3D.ILcd3DEditablePoint)
public void clip2viewSFCT(ILcdPoint aClipPoint, double aW, ILcd3DEditablePoint aViewPointSFCT)
aClipPoint
- the XYZ coordinates of the point in clip coordinatesaW
- the W coordinate of the point in clip coordinatesaViewPointSFCT
- the resulting view pointworldPoint2ClipSFCT(com.luciad.shape.ILcdPoint, com.luciad.shape.shape3D.ILcd3DEditablePoint)
public double getScaleX()
ALspViewXYZWorldTransformation
ILcdXYWorldReference
of the registered view. For example, a view displaying
geographical data could use a scale in pixels per meter.getScaleX
in class ALspViewXYZWorldTransformation
public double getScaleY()
ALspViewXYZWorldTransformation
ILcdXYWorldReference
of the registered view. For example, a view displaying
geographical data could use a scale in pixels per meter.getScaleY
in class ALspViewXYZWorldTransformation
public ILcdComplexPolygon getGeodeticVisibleArea()
ALspViewXYZWorldTransformation
null
.getGeodeticVisibleArea
in class ALspViewXYZWorldTransformation
public TLspViewXYZWorldTransformation3D getStereoTransformation(TLspPaintPhase.PaintStereo aStereoPhase)
aStereoPhase
- the stereo phase