public class Camera extends AbstractViewportManager
Camera
allow to define on the view and target points in a cartesian
coordinate system.
The Camera
provides the following services:
CameraMode
.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_CAMERA_DISTANCE_MODE
Defines if camera distance is real, or only squared (squared distance
avoid computing Math.sqrt() and is thus faster).
|
static Coord3d |
DEFAULT_VIEW
The polar default view point, i.e.
|
protected Coord3d |
eye |
protected float |
far |
protected float |
near |
protected float |
radius |
protected Coord3d |
target |
protected Coord3d |
up |
protected boolean |
useSquaredDistance |
lastViewPort, mode, ratioHeight, ratioWidth, screenBottom, screenGridDisplayed, screenHeight, screenLeft, screenSquaredDim, screenWidth, screenXOffset, screenYOffset
Constructor and Description |
---|
Camera(Coord3d target)
Set up a Camera looking at target, with a viewpoint standing at
target+(0,0,100).
|
Modifier and Type | Method and Description |
---|---|
protected double |
computeFieldOfView(double size,
double distance)
Compute the field of View, in order to occupy the entire screen in
PERSPECTIVE mode.
|
void |
doShoot(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
CameraMode projection) |
protected void |
failedProjection(String message) |
double |
getDistance(AbstractDrawable drawable)
Return the distance between the camera eye and the given drawable's
barycenter.
|
double |
getDistance(AbstractDrawable drawable,
Coord3d viewScale)
Apply scaling before computing distance between the camera eye and the
given drawable's barycenter.
|
double |
getDistance(Coord3d coord)
Return the distance between the camera eye and the given coordinate.
|
double |
getDistance(Coord3d coord,
Coord3d viewScale)
Apply scaling before computing distance between the camera eye and the
given coordinate.
|
Coord3d |
getEye()
Returns the eye's position.
|
float |
getFar()
Return the position of the "far" clipping plane
|
protected double[] |
getModelViewAsDouble(com.jogamp.opengl.GL gl) |
protected float[] |
getModelViewAsFloat(com.jogamp.opengl.GL gl) |
float |
getNear()
Return the position of the "near" clipping plane
|
protected double[] |
getProjectionAsDouble(com.jogamp.opengl.GL gl) |
protected float[] |
getProjectionAsFloat(com.jogamp.opengl.GL gl) |
float |
getRenderingSphereRadius()
Return the radius of the sphere that will be contained into the rendered
view.
|
Coord3d |
getTarget()
Returns the target's position that was set at the last call to lookAt().
|
Coord3d |
getUp()
Returns the top of the camera.
|
protected int[] |
getViewPortAsInt(com.jogamp.opengl.GL gl) |
boolean |
isTiltUp()
Returns true if the camera is 'looking up', in other word if the eye's Z
value is inferior to the target's Z value.
|
boolean |
isUseSquaredDistance() |
ArrayList<ArrayList<Coord3d>> |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
ArrayList<ArrayList<Coord3d>> polygons) |
Coord3d |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Coord3d point)
Transform a 3d point coordinate into its screen position.
|
Coord3d[] |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Coord3d[] points) |
Coord3d[][] |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Coord3d[][] points) |
Grid |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Grid grid) |
List<Coord3d> |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
List<Coord3d> points) |
PolygonArray |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
PolygonArray polygon) |
PolygonArray[][] |
modelToScreen(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
PolygonArray[][] polygons) |
Coord3d |
screenToModel(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Coord3d screen)
Transform a 2d screen coordinate into a 3d coordinate.
|
void |
setEye(Coord3d eye)
Set the eye's position.
|
void |
setRenderingDepth(float near,
float far)
Manually set the rendering depth (near and far clipping planes).
|
void |
setRenderingSphereRadius(float radius)
Set the radius of the sphere that will be contained into the rendered
view.
|
void |
setTarget(Coord3d target)
Set the target point of the camera.
|
void |
setUp(Coord3d up)
Set the top of the camera.
|
void |
setUseSquaredDistance(boolean useSquaredDistance)
Defines what getDistance(...) will return, either:
Squared distance (faster to compute since no Math.sqrt(...) at the
end)
Real distance
Default value is set to true, meaning it use the faster squared distance.
|
void |
shoot(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
CameraMode projection)
Sets the projection and the mapping of the 3d model to 2d screen.
|
void |
shoot(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
CameraMode projection,
boolean doPushMatrixBeforeShooting) |
void |
show(com.jogamp.opengl.GL gl,
Transform transform,
Coord3d scaling) |
boolean |
side(Coord3d point)
Return true if the given point is on the left of the vector eye->target.
|
String |
toString()
Print out in console information concerning the camera.
|
protected String |
toString(Coord3d eye,
Coord3d target,
Coord3d up) |
applyViewport, getLastViewPort, getMode, getRectangle, renderSubScreenGrid, setScreenGridDisplayed, setViewPort, setViewPort, setViewPort, setViewportMode
public static final Coord3d DEFAULT_VIEW
public static final boolean DEFAULT_CAMERA_DISTANCE_MODE
protected Coord3d eye
protected Coord3d target
protected Coord3d up
protected float radius
protected float near
protected float far
protected boolean useSquaredDistance
public Camera(Coord3d target)
public void setEye(Coord3d eye)
public Coord3d getEye()
public void setTarget(Coord3d target)
public Coord3d getTarget()
public void setUp(Coord3d up)
public Coord3d getUp()
public boolean isTiltUp()
public void setRenderingSphereRadius(float radius)
public float getRenderingSphereRadius()
public void setRenderingDepth(float near, float far)
Camera.setRenderingSphereRadius
modified the "far" clipping
plane.public float getNear()
public float getFar()
public boolean side(Coord3d point)
public Coord3d screenToModel(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d screen)
Camera
.a
- RuntimeException if an error occured while trying to retrieve
model coordinatespublic Coord3d modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d point)
a
- RuntimeException if an error occured while trying to retrieve
model coordinatespublic Coord3d[] modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d[] points)
public Coord3d[][] modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d[][] points)
public List<Coord3d> modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, List<Coord3d> points)
public ArrayList<ArrayList<Coord3d>> modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, ArrayList<ArrayList<Coord3d>> polygons)
public PolygonArray modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, PolygonArray polygon)
public Grid modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Grid grid)
public PolygonArray[][] modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, PolygonArray[][] polygons)
protected void failedProjection(String message)
protected int[] getViewPortAsInt(com.jogamp.opengl.GL gl)
protected double[] getProjectionAsDouble(com.jogamp.opengl.GL gl)
protected float[] getProjectionAsFloat(com.jogamp.opengl.GL gl)
protected double[] getModelViewAsDouble(com.jogamp.opengl.GL gl)
protected float[] getModelViewAsFloat(com.jogamp.opengl.GL gl)
public void shoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection)
gl
- GL2 context.glu
- GLU context.projection
- the projection mode.a
- Runtime Exception if the projection mode is neither
Camera.PERSPECTIVE nor Camera.ORTHOGONAL.public void shoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection, boolean doPushMatrixBeforeShooting)
public void doShoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection)
protected double computeFieldOfView(double size, double distance)
public double getDistance(AbstractDrawable drawable)
public double getDistance(AbstractDrawable drawable, Coord3d viewScale)
public double getDistance(Coord3d coord)
public double getDistance(Coord3d coord, Coord3d viewScale)
public boolean isUseSquaredDistance()
public void setUseSquaredDistance(boolean useSquaredDistance)
public String toString()
Copyright © 2016. All rights reserved.