|
Aviatrix3D 2.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j3d.aviatrix3d.SceneGraphObject
org.j3d.aviatrix3d.ViewEnvironment
public class ViewEnvironment
Representation of the physical environment setup used to connect a virtual Viewpoint object to the real one that is rendered on a drawable surface.
Most of the properties of this class are changed during the app update observer callback cycle. Anything that is generated will be done using the currently set data at that time.
A view environment cannot be directly created. You must fetch the
environment from it's parent Scene
instance.
Frustum Generation
The view frustum is generated depends on the aspect ratio. If the user sets an explicit aspect ratio, this is used in preference. If no aspect ratio is set (or the value set to <= 0) then the dimensions of the viewport that this is contained within are used to automatically calculate an aspect ratio.
The aspect ratio is not set by default.
Stereo supportIf the output device is capable of supporting stereo rendering, this class can be used to enable it. Since the stereo flags are supplied here, that allows the end user to control which layer(s) should be rendered in stereo and which should not. For example, a HUD may want to have a text overlay that has no depth applied, rendered over the top of the main layer, which has stereo applied. One environment has the flag set, the other does not.
By default, stereo is disabled.
Field of View and aspect ratio
The field of view calculation defines the viewing angle that is used in the Y axis - definition the minimum and maximum Y extents for the view frustum. If an explicit aspect ratio is set then the X extents are calculated using that, otherwise the dimensions of the viewport are used to calculate an aspect ratio, and finally the X extents.
Internationalisation Resource Names
Field Summary | |
---|---|
static int |
CUSTOM_PROJECTION
The projection type is a custom user-provided matrix |
static int |
INFINITE_PROJECTION
The projection type is an infinite perspective matrix |
static int |
ORTHOGRAPHIC_PROJECTION
The projection type is perspective mode |
static int |
PERSPECTIVE_PROJECTION
The projection type is perspective mode |
static int |
VIEW_HEIGHT
Index into the viewport size array for the height |
static int |
VIEW_WIDTH
Index into the viewport size array for the width |
static int |
VIEW_X
Index into the viewport size array for the X position |
static int |
VIEW_Y
Index into the viewport size array for the Y position |
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler |
Method Summary | |
---|---|
void |
generateViewFrustum(double[] frustum)
Generate a frustum based on the projectionType. |
void |
generateViewFrustumPlanes(javax.vecmath.Vector4f[] planes)
Convenience method to generate the 6 frustum planes from the current projection information held. |
double |
getAspectRatio()
Get the currently set aspect ratio. |
double |
getFarClipDistance()
Get the current setting of the far clip plane. |
double |
getFieldOfView()
Get the currently set field of view. |
double |
getNearClipDistance()
Get the current setting of the far clip plane. |
void |
getPixelLocationInSurface(float x,
float y,
javax.vecmath.Point3f position)
Convert a pixel location to surface coordinates. |
void |
getPixelLocationInSurface(float x,
float y,
javax.vecmath.Point3f offset,
javax.vecmath.Point3f position)
Convert a pixel location to surface coordinates. |
void |
getProjectionMatrix(float[] matrix)
Get the projection matrix that is generated for this environment. |
int |
getProjectionType()
Check to see if stereo has been enabled for this environment. |
int[] |
getScissorDimensions()
Get the currently set dimensions of the scissor area. |
void |
getViewFrustum(double[] frustum)
Get the frustum based on the projectionType. |
int[] |
getViewportDimensions()
Get the currently set dimensions of the viewport. |
boolean |
isStereoEnabled()
Check to see if stereo has been enabled for this environment. |
void |
setAspectRatio(double aspect)
Set aspect ratio, which is the ratio of window Width / Height. |
void |
setClipDistance(double near,
double far)
Set the near clipping distance to be used by the application. |
void |
setFarClipDistance(double d)
Set the far clipping distance to be used by the application. |
void |
setFieldOfView(double angle)
Set the field of view to be used. |
void |
setNearClipDistance(double d)
Set the near clipping distance to be used by the application. |
void |
setOrthoParams(double left,
double right,
double bottom,
double top)
Set the Orthographic view parameters. |
void |
setProjectionMatrix(float[] matrix)
Set a custom projection matrix for this view environment. |
void |
setProjectionType(int type)
Set the perspective projection flag used for this environment. |
void |
setScissorDimensions(int x,
int y,
int width,
int height)
Set the scissor area dimensions to reduce the amount of the parent viewport that is rendered to. |
void |
setStereoEnabled(boolean stereo)
Set the stereo flag used for this environment. |
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PERSPECTIVE_PROJECTION
public static final int ORTHOGRAPHIC_PROJECTION
public static final int INFINITE_PROJECTION
public static final int CUSTOM_PROJECTION
public static final int VIEW_X
public static final int VIEW_Y
public static final int VIEW_WIDTH
public static final int VIEW_HEIGHT
Method Detail |
---|
public boolean isStereoEnabled()
isStereoEnabled
in interface ViewEnvironmentCullable
public int getProjectionType()
getProjectionType
in interface ViewEnvironmentCullable
public int[] getViewportDimensions()
getViewportDimensions
in interface ViewEnvironmentCullable
public int[] getScissorDimensions()
getScissorDimensions
in interface ViewEnvironmentCullable
public void getViewFrustum(double[] frustum)
getViewFrustum
in interface ViewEnvironmentCullable
frustum
- An array at least 6 in length for the values generatedpublic double getFieldOfView()
getFieldOfView
in interface ViewEnvironmentCullable
public void getProjectionMatrix(float[] matrix)
getProjectionMatrix
in interface ViewEnvironmentCullable
matrix
- An array of length 16 to put the projection matrix in to
The format is row-majorpublic void setStereoEnabled(boolean stereo)
stereo
- True if stereo should be rendered
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic void setProjectionType(int type) throws java.lang.IllegalArgumentException
type
- One of ORTHOGRAPHIC_PROJECTION or PERSPECTIVE_PROJECTION
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback method
java.lang.IllegalArgumentException
- The type is not validpublic void setFieldOfView(double angle) throws java.lang.IllegalArgumentException
angle
- The angle in degress
java.lang.IllegalArgumentException
- The angle is less than or equal to zero
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic void setAspectRatio(double aspect)
aspect
- The new aspectRatio ratio.
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic double getAspectRatio()
public void setNearClipDistance(double d)
d
- The distance to set the near clip plane to
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic double getNearClipDistance()
public void setClipDistance(double near, double far)
near
- The distance to set the near clip planefar
- The distance to the far clip plane
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic void setFarClipDistance(double d)
d
- The distance to set the near clip plane to
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic void setProjectionMatrix(float[] matrix)
CUSTOM_PROJECTION
.
matrix
- A length 16 array of the 4x4 matrix, in row major form
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic double getFarClipDistance()
public void setOrthoParams(double left, double right, double bottom, double top)
left
- The left plane coordinateright
- The right plane coordinatebottom
- The bottom plane coordinatetop
- The top plane coordinate
InvalidWriteTimingException
- An attempt was made to write outside
of the ApplicationUpdateObserver callback methodpublic void generateViewFrustum(double[] frustum)
The parameter order for perspective is:
[x min, x max, y min, y max, z near, z far]
Orthographic uses the parameters specified in the setOrthoParams.
The parameter order for orthographic:
[left, right, bottom, top, near, far]
If a custom matrix is provided, this will generate all zeroes in the
returned array values.
frustum
- An array at least 6 in length for the values generatedpublic void generateViewFrustumPlanes(javax.vecmath.Vector4f[] planes)
Planes are in the order: left, right, top, bottom, near, far
planes
- The planes to place the data inpublic void setScissorDimensions(int x, int y, int width, int height)
x
- The lower left x coordinate for the viewy
- The lower left y coordinate for the viewwidth
- The width of the viewport in pixelsheight
- The height of the viewport in pixelspublic void getPixelLocationInSurface(float x, float y, javax.vecmath.Point3f position)
x
- The X coordinatey
- The Y coordinateposition
- The converted position. It must be preallocated.public void getPixelLocationInSurface(float x, float y, javax.vecmath.Point3f offset, javax.vecmath.Point3f position)
x
- The X coordinatey
- The Y coordinateoffset
- Any Eye offset amount needed for a canvas offset or nullposition
- The converted position. It must be preallocated.
|
Aviatrix3D 2.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |