org::scilab::modules::renderer::subwinDrawing::CameraGL Class Reference

Inheritance diagram for org::scilab::modules::renderer::subwinDrawing::CameraGL:

Inheritance graph
[legend]
Collaboration diagram for org::scilab::modules::renderer::subwinDrawing::CameraGL:

Collaboration graph
[legend]

Public Member Functions

 CameraGL ()
double[] getMarginSize ()
void show (int parentFigureIndex)
void showCamera ()
void redrawCamera ()
void endDrawing ()
void setAxesBounds (double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
void setViewingArea (double transX, double transY, double scaleX, double scaleY)
void setNormalizationParameters (double normalizeScaleX, double normalizeScaleY, double normalizeScaleZ, double transX, double transY, double transZ)
void setAxesReverse (boolean xAxisRevert, boolean yAxisRevert, boolean zAxisRevert)
void setAxesRotationParameters (double centerX, double centerY, double centerZ, double alpha, double theta)
void setFittingScale (double scaleX, double scaleY, double scaleZ)
void placeCamera ()
void replaceCamera ()
double[] getProjectionMatrix ()
double[] getUnprojectMatrix ()
double[] get2dViewProjectionMatrix ()
double[] get2dViewUnprojectMatrix ()
double[] getViewPort ()

Protected Member Functions

abstract void setViewPort ()
void setViewPortSize (double width, double height)
double getViewportWidth ()
double getViewportHeight ()
void moveViewingArea ()
void computeMarginsSize ()
void moveAxesBox ()
void centerAxesBox ()
double[] getBoxScreenExtent (GL gl)
abstract void computeFittingScale ()
void rotateAxesBox ()
void revertAxes ()
void applyRotation (GL gl, double alpha, double theta)
void switchTo2DCoordinates ()
void backTo3DCoordinates ()
boolean is2DCamera ()
void updateDepthRange ()
double[] getAxesBoxDepthRange ()
void setProjectionMatrix (double zNear, double zFar)
double[] getViewPortSize ()

Private Member Functions

double[] getAxesBoxDepthRange (Vector3D[] axesBoxVertices, Matrix4D modelViewMatrix)

Private Attributes

Vector3D viewPortTranslation = new Vector3D()
Vector3D viewPortScale = new Vector3D()
Vector3D normalizeScale = new Vector3D()
Vector3D normalizeTranslation = new Vector3D()
Vector3D rotationCenter = new Vector3D()
double xMin
double xMax
double yMin
double yMax
double zMin
double zMax
double alpha
double theta
Vector3D fittingScale = new Vector3D()
double[] marginSize
boolean xAxisRevert
boolean yAxisRevert
boolean zAxisRevert
Matrix4D projectionMatrix
Matrix4D unprojectMatrix
Matrix4D projectionMatrix2D
Matrix4D unprojectMatrix2D
double viewPortWidth
double viewPortHeight

Static Private Attributes

static final double DEPTH_RANGE_INCREASE = 5.0
static final double DEFAULT_ALPHA = 0.0
static final double DEFAULT_THETA = 270.0

Detailed Description

Class containing the driver dependant routines position the camera.
Author:
Jean-Baptiste Silvy

Definition at line 29 of file CameraGL.java.


Constructor & Destructor Documentation

org::scilab::modules::renderer::subwinDrawing::CameraGL::CameraGL (  )  [inline]

Default constructor

Definition at line 87 of file CameraGL.java.

00087                           {
00088                 super();
00089         }


Member Function Documentation

double [] org::scilab::modules::renderer::subwinDrawing::CameraGL::getMarginSize (  )  [inline]

Returns:
Width and height of the margins in pixels.

Definition at line 95 of file CameraGL.java.

References marginSize.

Referenced by org::scilab::modules::renderer::subwinDrawing::IsoViewCameraGL::computeFittingScale(), and org::scilab::modules::renderer::subwinDrawing::IsometricCameraGL::computeFittingScale().

00095                                         {
00096                 return marginSize;
00097         }

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::show ( int  parentFigureIndex  )  [inline]

Display the object by displaying its display list

Parameters:
parentFigureIndex index of the parent figure in which the object will be drawn

Definition at line 103 of file CameraGL.java.

References showCamera().

00103                                                 {
00104                 showCamera();
00105         }

Here is the call graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::showCamera (  )  [inline]

Place the camera using alredy computed matrices

Definition at line 110 of file CameraGL.java.

References org::scilab::modules::renderer::ObjectGL::getCoordinateTransformation(), org::scilab::modules::renderer::ObjectGL::getGL(), org::scilab::modules::renderer::utils::geom3D::Matrix4D::getOpenGLRepresentation(), projectionMatrix, and org::scilab::modules::renderer::utils::CoordinateTransformation::update().

Referenced by show().

00110                                  {
00111                 GL gl = getGL();
00112                 gl.glMatrixMode(GL.GL_PROJECTION);
00113                 gl.glLoadIdentity();
00114                 gl.glMatrixMode(GL.GL_MODELVIEW);
00115                 gl.glLoadMatrixd(projectionMatrix.getOpenGLRepresentation(), 0);
00116                 gl.glPushMatrix();
00117                 getCoordinateTransformation().update(gl);
00118         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::redrawCamera ( void   )  [inline]

Place the camera using precomputed data

Definition at line 123 of file CameraGL.java.

References placeCamera().

00123                                    {
00124                 placeCamera();
00125         }

Here is the call graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::endDrawing ( void   )  [inline]

Override endrawing to update coordinate transforation.

Reimplemented from org::scilab::modules::renderer::ObjectGL.

Definition at line 130 of file CameraGL.java.

00130                                  {
00131                 super.endDrawing();
00132                 // Camera is placed, update transformation
00133                 //GL gl = getGL();
00134                 //CoordinateTransformation.getTransformation(gl).update(gl);
00135         }

abstract void org::scilab::modules::renderer::subwinDrawing::CameraGL::setViewPort (  )  [protected, pure virtual]

Set the viewPort of the object.

Implemented in org::scilab::modules::renderer::subwinDrawing::IsometricCameraGL, and org::scilab::modules::renderer::subwinDrawing::IsoViewCameraGL.

Referenced by moveViewingArea().

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::setViewPortSize ( double  width,
double  height 
) [inline, protected]

Specify the size of teh OpenGL viewport to use

Parameters:
width width of the viewport in pixel
height heigh tof the viewPport in pixels

Definition at line 148 of file CameraGL.java.

Referenced by org::scilab::modules::renderer::subwinDrawing::IsoViewCameraGL::setViewPort(), and org::scilab::modules::renderer::subwinDrawing::IsometricCameraGL::setViewPort().

00148                                                                     {
00149                 this.viewPortWidth = width;
00150                 this.viewPortHeight = height;
00151         }

Here is the caller graph for this function:

double org::scilab::modules::renderer::subwinDrawing::CameraGL::getViewportWidth (  )  [inline, protected]

Returns:
width of the viewport

Definition at line 156 of file CameraGL.java.

References viewPortWidth.

Referenced by centerAxesBox(), moveViewingArea(), and updateDepthRange().

00156                                             {
00157                 return viewPortWidth;
00158         }

Here is the caller graph for this function:

double org::scilab::modules::renderer::subwinDrawing::CameraGL::getViewportHeight (  )  [inline, protected]

Returns:
height of the viewport

Definition at line 163 of file CameraGL.java.

References viewPortHeight.

Referenced by centerAxesBox(), moveViewingArea(), and updateDepthRange().

00163                                              {
00164                 return viewPortHeight;
00165         }

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::setAxesBounds ( double  xMin,
double  xMax,
double  yMin,
double  yMax,
double  zMin,
double  zMax 
) [inline]

Set the bounds of the axes

Parameters:
xMin a
xMax a
yMin a
yMax a
zMin a
zMax a

Definition at line 177 of file CameraGL.java.

00179                                                                                     {
00180                 this.xMin = xMin;
00181                 this.xMax = xMax;
00182                 this.yMin = yMin;
00183                 this.yMax = yMax;
00184                 this.zMin = zMin;
00185                 this.zMax = zMax;
00186         }

void org::scilab::modules::renderer::subwinDrawing::CameraGL::setViewingArea ( double  transX,
double  transY,
double  scaleX,
double  scaleY 
) [inline]

Set the parameters for positionning viewing area (specified by axes margins)

Parameters:
transX X translation of the viewing area
transY Y translation of the viewing area
scaleX X scale of the viewing area
scaleY Y scale of the viewing area

Definition at line 195 of file CameraGL.java.

References org::scilab::modules::renderer::utils::geom3D::Vector3D::setValues(), viewPortScale, and viewPortTranslation.

00195                                                                                                {
00196                 // we move it in 2D.
00197                 viewPortTranslation.setValues(transX, transY, 0.0);
00198                 viewPortScale.setValues(scaleX, scaleY, 1.0);
00199         }

Here is the call graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::moveViewingArea (  )  [inline, protected]

Position the viewing area in order to respect Subwin position.

Definition at line 204 of file CameraGL.java.

References computeMarginsSize(), org::scilab::modules::renderer::ObjectGL::getGL(), getViewportHeight(), getViewportWidth(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getZ(), setProjectionMatrix(), setViewPort(), viewPortScale, and viewPortTranslation.

Referenced by placeCamera().

00204                                          {
00205                 GL gl = getGL();
00206                 
00207                 setViewPort();
00208                 
00209                 // set the projection matrix with default depth range
00210                 // the real one will be computed after
00211                 setProjectionMatrix(-1.0, 1.0);
00212                 
00213             gl.glMatrixMode(GL.GL_MODELVIEW);
00214             gl.glLoadIdentity();
00215 
00216             gl.glScaled(getViewportWidth(), getViewportHeight(), 1.0);
00217                 gl.glTranslated(viewPortTranslation.getX(), viewPortTranslation.getY(), viewPortTranslation.getZ());
00218                 gl.glScaled(viewPortScale.getX(), viewPortScale.getY(), viewPortScale.getZ());
00219                 
00220                 // save pixel coordinates of the margin box, our axes box needs to fit inside.
00221                 computeMarginsSize();
00222                 
00223         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::computeMarginsSize (  )  [inline, protected]

Compute width and height of the margins in pixels.

Definition at line 228 of file CameraGL.java.

References getViewPortSize(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), marginSize, and viewPortScale.

Referenced by moveViewingArea().

00228                                             {
00229                 // get width ad height of the viewPort
00230                 double[] viewPortSize = getViewPortSize();
00231                 
00232         //marginSize = UnitaryCubeGL.getCubeScreenExtent(getGL(), getCoordinateTransformation());
00233                 marginSize = new double[2];
00234                 marginSize[0] = viewPortSize[0] * viewPortScale.getX();
00235                 marginSize[1] = viewPortSize[1] * viewPortScale.getY();
00236         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::setNormalizationParameters ( double  normalizeScaleX,
double  normalizeScaleY,
double  normalizeScaleZ,
double  transX,
double  transY,
double  transZ 
) [inline]

Set parameters so the axes box is map onto a the [0,1]x[0,1]x[0,1] cube.

Parameters:
normalizeScaleX X scale to fit bounds within [0,1].
normalizeScaleY Y scale to fit bounds within [0,1].
normalizeScaleZ Z scale to fit bounds within [0,1].
transX X translation to put the axes in view.
transY Y translation to put the axes in view.
transZ Z translation to put the axes in view.

Definition at line 247 of file CameraGL.java.

References normalizeScale, normalizeTranslation, and org::scilab::modules::renderer::utils::geom3D::Vector3D::setValues().

00248                                                                                             {
00249                 normalizeScale.setValues(normalizeScaleX, normalizeScaleY, normalizeScaleZ);
00250                 normalizeTranslation.setValues(transX, transY, transZ);
00251         }

Here is the call graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::setAxesReverse ( boolean  xAxisRevert,
boolean  yAxisRevert,
boolean  zAxisRevert 
) [inline]

Specify which axies to revert

Parameters:
xAxisRevert set wether X axis is revert or not.
yAxisRevert set wether Y axis is revert or not.
zAxisRevert set wether Z axis is revert or not.

Definition at line 259 of file CameraGL.java.

00259                                                                                                   {
00260                 this.xAxisRevert = xAxisRevert;
00261                 this.yAxisRevert = yAxisRevert;
00262                 this.zAxisRevert = zAxisRevert;
00263         }

void org::scilab::modules::renderer::subwinDrawing::CameraGL::moveAxesBox (  )  [inline, protected]

Move the axes box so it map the onto a the [0,1]x[0,1]x[0,1] cube.

Definition at line 268 of file CameraGL.java.

References org::scilab::modules::renderer::ObjectGL::getGL(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getZ(), normalizeScale, and normalizeTranslation.

Referenced by placeCamera().

00268                                      {
00269                 GL gl = getGL();
00270                 gl.glScaled(normalizeScale.getX(), normalizeScale.getY(), normalizeScale.getZ());
00271                 
00272                 gl.glTranslated(normalizeTranslation.getX(), normalizeTranslation.getY(), normalizeTranslation.getZ());
00273                 
00274         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::renderer::subwinDrawing::CameraGL::setAxesRotationParameters ( double  centerX,
double  centerY,
double  centerZ,
double  alpha,
double  theta 
) [inline]

Set the parameters for rotating the axes box.

Parameters:
centerX X coordiantes of the rotation center
centerY Y coordinates of the rotation center
centerZ Z coordinates of the rotation center
alpha rotation angle around axe X
theta rotation angle around axe Z

Definition at line 284 of file CameraGL.java.

References rotationCenter, and org::scilab::modules::renderer::utils::geom3D::Vector3D::setValues().

00285                                                                                                           {
00286                 rotationCenter.setValues(centerX, centerY, centerZ);
00287                 this.alpha = alpha;
00288                 this.theta = theta;
00289         }

Here is the call graph for this function: