Package com.massifmaps.graphics
Class ViewState
java.lang.Object
com.massifmaps.graphics.ViewState
A class containing various view parameters for a view state.
-
Method Summary
Modifier and TypeMethodDescriptiondoubleThe distance from the camera to the focus point - tangram's m_pos.z, which is what their
near and far planes are built on.Returns the unit direction the camera looks along, including the look above the horizon
that a negative tilt adds.doublecalculateViewDistance(Options options) How far from the camera the map is drawn, in internal units - tangram's rule, scaled by
TerrainOptions::ViewDistanceFactor.voidTurns the terrain zoom bound off (no terrain, or a non-planar projection).booleanChecks if this object is equal to the specified object.floatReturns the aspect ratio of the map screen.floatReturns the tilt the CAMERA POSITION is built at: the camera-to-focus vector is at this
angle, never below the horizon, and the difference to the view tilt is a rotation of the
view about the camera (see calculateLookatMat).floatgetDPI()Returns the dots per inch parameter of the screen.floatReturns a value that is used for converting display independent pixels (dp) to pixels (px).
This values depends on the screen density.floatgetFar()Returns the far plane distance.intgetFOVY()Returns the vertical field of view angle.intReturns the height of the map screen.Returns the view frustum grown by the label padding band, the one tiles must reach for
their labels to be placed before they scroll in.floatgetNear()Returns the near plane distance.doublegetOrbitDistance(float zoom) Returns the camera-to-focus distance at the given zoom, what the zoom is calibrated on.floatThe zoom the RENDERER works in: the reported zoom plus Options::ZoomOffset.floatReturns the camera rotation angle.intReturns the screen height.intReturns the screen width.floatReturns the normalized device y below which no ray from the screen reaches the sky -
the horizon, in other words, in the space the sky quad is drawn in.floatReturns the maximum zoom allowed by the terrain clearance, or infinity when
no terrain bound is active.floatgetTilt()Returns the camera tilt angle.floatReturns the conversion ratio between internal map units and screen density independent pixels (DP or DIP).floatReturns the conversion ratio between internal map units and screen pixels.intgetWidth()Returns the width of the map screen.floatgetZoom()Returns the camera zoom level.floatReturns the distance between the focus and the camera position, when the zoom level is set to 0.
This parameter depends on the screen size, DPI, tile draw size and field of view settings.inthashCode()Returns the hash value of this object.booleanReturns the state of the camera changed flag.voidliftFocus(double deltaZ) Moves the focus AND the camera by deltaZ, keeping zoom, tilt and rotation: the
camera-to-focus vector is untouched.voidsetTerrainHeightRange(float minZ, float maxZ) Sets the terrain height range (in internal units).voidsetViewTilt(float tilt) Sets the tilt of the VIEW only, leaving the camera where it is.
-
Method Details
-
equals
Checks if this object is equal to the specified object. -
hashCode
public int hashCode()Returns the hash value of this object. -
liftFocus
public void liftFocus(double deltaZ) Moves the focus AND the camera by deltaZ, keeping zoom, tilt and rotation: the
camera-to-focus vector is untouched. MapRenderer uses it to keep the focus ON the
terrain under it, which is what makes the zoom the camera's distance to the ground at
the focus, as in mapbox, rather than to sea level. -
getTilt
public float getTilt()Returns the camera tilt angle. A NEGATIVE tilt means the view looks above the horizon.- Returns:
- The camera tilt angle in degrees.
-
setViewTilt
public void setViewTilt(float tilt) Sets the tilt of the VIEW only, leaving the camera where it is. The difference between
the camera tilt and this one is applied as a rotation of the view about the camera, so
the camera does not move at all - which is what a first person look is.- Parameters:
tilt- The new view tilt angle in degrees.
-
getCameraTilt
public float getCameraTilt()Returns the tilt the CAMERA POSITION is built at: the camera-to-focus vector is at this
angle, never below the horizon, and the difference to the view tilt is a rotation of the
view about the camera (see calculateLookatMat).- Returns:
- The camera tilt angle in degrees, never negative.
-
calculateViewDir
Returns the unit direction the camera looks along, including the look above the horizon
that a negative tilt adds.- Returns:
- The view direction, or a zero vector if the camera and the focus coincide.
-
getZoom
public float getZoom()Returns the camera zoom level.- Returns:
- The camera zoom level.
-
isCameraChanged
public boolean isCameraChanged()Returns the state of the camera changed flag.- Returns:
- True if camera has changed since the last frame.
-
getRotation
public float getRotation()Returns the camera rotation angle.- Returns:
- The camera rotation angle in degrees.
-
getRenderZoom
public float getRenderZoom()The zoom the RENDERER works in: the reported zoom plus Options::ZoomOffset. vt sizes by
`2^(zoom - tileZoom)`, so it needs the zoom the tiles were chosen for.- Returns:
- The renderer's zoom level.
-
getZoom0Distance
public float getZoom0Distance()Returns the distance between the focus and the camera position, when the zoom level is set to 0.
This parameter depends on the screen size, DPI, tile draw size and field of view settings.- Returns:
- The distance between focus to camera position, when zoom level = 0.
-
getWidth
public int getWidth()Returns the width of the map screen.- Returns:
- The map screen width.
-
getHeight
public int getHeight()Returns the height of the map screen.- Returns:
- The map screen height.
-
getAspectRatio
public float getAspectRatio()Returns the aspect ratio of the map screen. Equal to width / height.- Returns:
- The aspect ratio of the map screen.
-
getNear
public float getNear()Returns the near plane distance.- Returns:
- The new plane distance.
-
getFar
public float getFar()Returns the far plane distance.- Returns:
- The far plane distance.
-
setTerrainHeightRange
public void setTerrainHeightRange(float minZ, float maxZ) Sets the terrain height range (in internal units). The range extends the
near/far plane calculation so that displaced terrain is not clipped.- Parameters:
minZ- The minimum terrain height.maxZ- The maximum terrain height.
-
clearTerrainCameraReference
public void clearTerrainCameraReference()Turns the terrain zoom bound off (no terrain, or a non-planar projection). -
getTerrainMaxZoom
public float getTerrainMaxZoom()Returns the maximum zoom allowed by the terrain clearance, or infinity when
no terrain bound is active. Evaluated against the CURRENT camera state, so it
carries no frame lag: zooming in by this delta lands the camera exactly on the
clearance shell. Every zoom path (gesture, animation, kinetic fling, API) is
clamped by it, which is what keeps the camera from being pushed into the
terrain and then corrected back out - the correction/gesture fight that makes
zooming jump back and forth. Below the current zoom when the camera is already
under the shell: the bound then stops a zoom in, and MapRenderer's correction
lifts the camera.- Returns:
- The terrain-imposed maximum zoom.
-
getOrbitDistance
public double getOrbitDistance(float zoom) Returns the camera-to-focus distance at the given zoom, what the zoom is calibrated on.- Parameters:
zoom- The zoom.- Returns:
- The distance in internal units.
-
getFOVY
public int getFOVY()Returns the vertical field of view angle.- Returns:
- The vertical field of view angle in degrees.
-
getDPToPX
public float getDPToPX()Returns a value that is used for converting display independent pixels (dp) to pixels (px).
This values depends on the screen density.- Returns:
- The dp to px value.
-
getDPI
public float getDPI()Returns the dots per inch parameter of the screen.- Returns:
- The screen DPI parameter.
-
getUnitToPXCoef
public float getUnitToPXCoef()Returns the conversion ratio between internal map units and screen pixels. This parameter is dependent
on the zoom level and other screen parameters.- Returns:
- The conversion ratio between internal map units and screen pixels.
-
getUnitToDPCoef
public float getUnitToDPCoef()Returns the conversion ratio between internal map units and screen density independent pixels (DP or DIP).
This parameter is dependent on the zoom level, DPI and other screen parameters.- Returns:
- The conversion ratio between internal map units and screen density independent pixels.
-
getLabelFrustum
Returns the view frustum grown by the label padding band, the one tiles must reach for
their labels to be placed before they scroll in. See vt::ViewState::labelPadding.- Returns:
- The label view frustum.
-
getScreenWidth
public int getScreenWidth()Returns the screen width.- Returns:
- The current screen width.
-
getScreenHeight
public int getScreenHeight()Returns the screen height.- Returns:
- The current screen height.
-
getSkyHorizonNDC
public float getSkyHorizonNDC()Returns the normalized device y below which no ray from the screen reaches the sky -
the horizon, in other words, in the space the sky quad is drawn in. 1 when no sky is
visible at all. Only meaningful when isSkyVisible() is true.- Returns:
- The horizon's position in normalized device coordinates, -1 (bottom) to 1 (top).
-
calculateViewDistance
How far from the camera the map is drawn, in internal units - tangram's rule, scaled by
TerrainOptions::ViewDistanceFactor. Both the far plane and the tile walk stop here, so
the tiles fetched are exactly the tiles the frustum can show. 0 means "as far as the
visible ground goes" (factor 0).- Parameters:
options- The options object.- Returns:
- The view distance in internal units, or 0 if it is unbounded.
-
calculateCameraDistance
public double calculateCameraDistance()The distance from the camera to the focus point - tangram's m_pos.z, which is what their
near and far planes are built on. It is a function of the zoom alone, so the depth budget
does not change with the terrain under the camera.- Returns:
- The camera to focus distance in internal units.
-