org.jzy3d.plot3d.rendering.view
Class Camera
- java.lang.Object
-
- org.jzy3d.plot3d.rendering.view.AbstractViewportManager
-
- org.jzy3d.plot3d.rendering.view.Camera
-
public class Camera extends AbstractViewportManager
ACameraallow to define on the view and target points in a cartesian coordinate system. TheCameraprovides the following services:- allows setting perspective/orthogonal rendering mode through
CameraMode. - selects the appropriate clipping planes according to a given target box.
- ensure the modelview matrix is always available for GL2 calls related to anything else than projection.
- methods to convert screen coordinates into 3d coordinates and vice-versa
- allows setting perspective/orthogonal rendering mode through
-
-
Field Summary
Fields Modifier and Type Field and Description static booleanDEFAULT_CAMERA_DISTANCE_MODEDefines if camera distance is real, or only squared (squared distance avoid computing Math.sqrt() and is thus faster).static Coord3dDEFAULT_VIEWThe polar default view point, i.e.
-
Constructor Summary
Constructors Constructor and Description Camera(Coord3d target)Set up a Camera looking at target, with a viewpoint standing at target+(0,0,100).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voiddoShoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection)doublegetDistance(AbstractDrawable drawable)Return the distance between the camera eye and the given drawable's barycenter.doublegetDistance(AbstractDrawable drawable, Coord3d viewScale)Apply scaling before computing distance between the camera eye and the given drawable's barycenter.doublegetDistance(Coord3d coord)Return the distance between the camera eye and the given coordinate.doublegetDistance(Coord3d coord, Coord3d viewScale)Apply scaling before computing distance between the camera eye and the given coordinate.Coord3dgetEye()Returns the eye's position.floatgetFar()Return the position of the "far" clipping planefloatgetNear()Return the position of the "near" clipping planefloatgetRenderingSphereRadius()Return the radius of the sphere that will be contained into the rendered view.Coord3dgetTarget()Returns the target's position that was set at the last call to lookAt().Coord3dgetUp()Returns the top of the camera.booleanisTiltUp()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.booleanisUseSquaredDistance()java.util.ArrayList<java.util.ArrayList<Coord3d>>modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, java.util.ArrayList<java.util.ArrayList<Coord3d>> polygons)Coord3dmodelToScreen(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)GridmodelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Grid grid)java.util.List<Coord3d>modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, java.util.List<Coord3d> points)PolygonArraymodelToScreen(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)Coord3dscreenToModel(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d screen)Transform a 2d screen coordinate into a 3d coordinate.voidsetEye(Coord3d eye)Set the eye's position.voidsetRenderingDepth(float near, float far)Manually set the rendering depth (near and far clipping planes).voidsetRenderingSphereRadius(float radius)Set the radius of the sphere that will be contained into the rendered view.voidsetScale(float scale)Set the eye's position.voidsetTarget(Coord3d target)Set the target point of the camera.voidsetUp(Coord3d up)Set the top of the camera.voidsetUseSquaredDistance(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.voidshoot(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.voidshoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection, boolean doPushMatrixBeforeShooting)voidshow(com.jogamp.opengl.GL gl, Transform transform, Coord3d scaling)booleanside(Coord3d point)Return true if the given point is on the left of the vector eye->target.java.lang.StringtoString()Print out in console information concerning the camera.-
Methods inherited from class org.jzy3d.plot3d.rendering.view.AbstractViewportManager
getLastViewPort, getMode, getRectangle, setScreenGridDisplayed, setViewPort, setViewPort, setViewPort, setViewportMode
-
-
-
-
Field Detail
-
DEFAULT_VIEW
public static final Coord3d DEFAULT_VIEW
The polar default view point, i.e. Coord3d(Math.PI/3,Math.PI/5,500).
-
DEFAULT_CAMERA_DISTANCE_MODE
public static final boolean DEFAULT_CAMERA_DISTANCE_MODE
Defines if camera distance is real, or only squared (squared distance avoid computing Math.sqrt() and is thus faster). Second mode requires value true- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Camera
public Camera(Coord3d target)
Set up a Camera looking at target, with a viewpoint standing at target+(0,0,100). The top of the camera is set up toward the positive Z direction.
-
-
Method Detail
-
setScale
public void setScale(float scale)
Set the eye's position.
-
setEye
public void setEye(Coord3d eye)
Set the eye's position.
-
getEye
public Coord3d getEye()
Returns the eye's position.
-
setTarget
public void setTarget(Coord3d target)
Set the target point of the camera.
-
getTarget
public Coord3d getTarget()
Returns the target's position that was set at the last call to lookAt().
-
setUp
public void setUp(Coord3d up)
Set the top of the camera.
-
getUp
public Coord3d getUp()
Returns the top of the camera.
-
isTiltUp
public 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.
-
setRenderingSphereRadius
public void setRenderingSphereRadius(float radius)
Set the radius of the sphere that will be contained into the rendered view. As a side effect, the "far" clipping plane is modified according to the eye-target distance, and the position of the "near" clipping plane.
-
getRenderingSphereRadius
public float getRenderingSphereRadius()
Return the radius of the sphere that will be contained into the rendered view.
-
setRenderingDepth
public void setRenderingDepth(float near, float far)Manually set the rendering depth (near and far clipping planes). Note thatCamera.setRenderingSphereRadiusmodified the "far" clipping plane.
-
getNear
public float getNear()
Return the position of the "near" clipping plane
-
getFar
public float getFar()
Return the position of the "far" clipping plane
-
side
public boolean side(Coord3d point)
Return true if the given point is on the left of the vector eye->target.
-
screenToModel
public Coord3d screenToModel(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d screen)
Transform a 2d screen coordinate into a 3d coordinate. The z component of the screen coordinate indicates a depth value between the near and far clipping plane of theCamera.- Throws:
a- RuntimeException if an error occured while trying to retrieve model coordinates
-
modelToScreen
public Coord3d modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d point)
Transform a 3d point coordinate into its screen position.- Throws:
a- RuntimeException if an error occured while trying to retrieve model coordinates
-
modelToScreen
public Coord3d[] modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d[] points)
-
modelToScreen
public Coord3d[][] modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Coord3d[][] points)
-
modelToScreen
public java.util.List<Coord3d> modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, java.util.List<Coord3d> points)
-
modelToScreen
public java.util.ArrayList<java.util.ArrayList<Coord3d>> modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, java.util.ArrayList<java.util.ArrayList<Coord3d>> polygons)
-
modelToScreen
public PolygonArray modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, PolygonArray polygon)
-
modelToScreen
public Grid modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Grid grid)
-
modelToScreen
public PolygonArray[][] modelToScreen(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, PolygonArray[][] polygons)
-
shoot
public 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. The projection must be either Camera.PERSPECTIVE or Camera.ORTHOGONAL.
shoot() finally calls the GL function glLookAt, according to the stored eye, target, up and scale values.
Note that the Camera set by itselft the MatrixMode to model view at the end of a shoot().- Parameters:
gl- GL2 context.glu- GLU context.projection- the projection mode.- Throws:
a- Runtime Exception if the projection mode is neither Camera.PERSPECTIVE nor Camera.ORTHOGONAL.
-
shoot
public void shoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection, boolean doPushMatrixBeforeShooting)
-
doShoot
public void doShoot(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, CameraMode projection)
-
getDistance
public double getDistance(AbstractDrawable drawable)
Return the distance between the camera eye and the given drawable's barycenter.
-
getDistance
public double getDistance(AbstractDrawable drawable, Coord3d viewScale)
Apply scaling before computing distance between the camera eye and the given drawable's barycenter.
-
getDistance
public double getDistance(Coord3d coord)
Return the distance between the camera eye and the given coordinate.
-
getDistance
public double getDistance(Coord3d coord, Coord3d viewScale)
Apply scaling before computing distance between the camera eye and the given coordinate.
-
isUseSquaredDistance
public boolean isUseSquaredDistance()
-
setUseSquaredDistance
public void setUseSquaredDistance(boolean useSquaredDistance)
Defines what getDistance(...) will return, either:- Squared distance (faster to compute since no Math.sqrt(...) at the end)
- Real distance
-
toString
public java.lang.String toString()
Print out in console information concerning the camera.- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG