public class OrbitView extends View
All views maintain a world-to-view transform. In an orbit view, that world-to-view transform is comprised of a world-to-unit-sphere transform and a unit-sphere-to-view transform.
The world-to-unit-sphere transform centers and normalizes the world. A world drawn by an orbit view has a world sphere that, by default, is the bounding sphere of the world when first viewed. The world-to-unit- sphere transform first translates the world sphere's center to the origin, and then scales the world sphere to have unit radius. The purpose of this first transform is to make other orbit view parameters independent of world coordinates. To modify the world-to-unit-sphere transform, set the world sphere.
The second unit-sphere-to-view transform applies a translate, scale, and rotate to the unit sphere, and then applies a final translate down the z-axis to push the transformed sphere into the view frustum. The orbit view applies the first translate, scale, and rotate in that order, so that the scale and rotate occurs about the center of the view.
The rotate part of the unit-sphere-to-view transform is comprised of two rotations, because an orbit view camera has both azimuth and elevation angles. Imagine a line from the center of the unit sphere to the camera. The point where that line intersects the sphere has a latitude and longitude. The azimuth angle is the longitude, positive for degrees East, negative for degrees West. The elevation angle is the latitude, positive for degrees North, negative for degrees South.
An orbit view supports both perspective and orthographic projections. For perspective projections, the field of view is computed by assuming that the distance from the eye to the default screen is approximately equal to the size of that screen.
Modifier and Type | Class and Description |
---|---|
static class |
OrbitView.Projection
Perspective or orthographic projection.
|
Constructor and Description |
---|
OrbitView()
Constructs an orbit view of no world.
|
OrbitView(World world)
Constructs an orbit view of the specified world.
|
Modifier and Type | Method and Description |
---|---|
protected void |
draw(ViewCanvas canvas)
Draws this view on the specified canvas.
|
double |
getAzimuth()
Gets the azimuth for this view.
|
double |
getElevation()
Gets the elevation for this view.
|
OrbitView.Projection |
getProjection()
Gets the projection for this view.
|
double |
getScale()
Gets the scale factor for this view.
|
Vector3 |
getTranslate()
Gets the translate vector for this view.
|
Matrix44 |
getUnitSphereToView()
Gets the unit-sphere-to-view transform for this view.
|
BoundingSphere |
getWorldSphere()
Gets the world sphere used to parameterize this view.
|
Matrix44 |
getWorldToUnitSphere()
Gets the world-to-unit-sphere transform for this view.
|
void |
reset()
Resets this view to its state when constructed.
|
void |
setAzimuth(double azimuth)
Sets the azimuth for this view.
|
void |
setAzimuthAndElevation(double azimuth,
double elevation)
Sets the azimuth and elevation for this view.
|
void |
setElevation(double elevation)
Sets the elevation for this view.
|
void |
setProjection(OrbitView.Projection projection)
Sets the projection for this view.
|
void |
setScale(double scale)
Sets the scale factor for this view.
|
void |
setTranslate(Vector3 translate)
Sets the translate vector for this view.
|
void |
setWorldSphere(BoundingSphere worldSphere)
Sets the world sphere used to parameterize this view.
|
protected void |
updateTransforms(ViewCanvas canvas)
Updates transforms for a canvas on which this view draws.
|
countCanvases, getAxesOrientation, getAxesScale, getCanvases, getWorld, getWorldToView, repaint, setAxesOrientation, setAxesScale, setAxesScale, setWorld, setWorldToView, updateTransforms
public OrbitView()
public OrbitView(World world)
world
- the world.public void reset()
public void setWorldSphere(BoundingSphere worldSphere)
worldSphere
- the world sphere; null, if none.public BoundingSphere getWorldSphere()
public void setProjection(OrbitView.Projection projection)
projection
- the projection.public OrbitView.Projection getProjection()
public void setAzimuth(double azimuth)
azimuth
- the azimuth.public double getAzimuth()
public void setElevation(double elevation)
elevation
- the elevation.public double getElevation()
public void setAzimuthAndElevation(double azimuth, double elevation)
azimuth
- the azimuth.elevation
- the elevation.public void setScale(double scale)
scale
- the scale factor.public double getScale()
public void setTranslate(Vector3 translate)
translate
- the translate vector.public Vector3 getTranslate()
public Matrix44 getWorldToUnitSphere()
public Matrix44 getUnitSphereToView()
protected void updateTransforms(ViewCanvas canvas)
updateTransforms
in class View
canvas
- the view canvas.protected void draw(ViewCanvas canvas)