
Definition at line 30 of file CoordinateTransformation.java.
| org::scilab::modules::renderer::utils::CoordinateTransformation::CoordinateTransformation | ( | ) | [inline] |
default constructor
Definition at line 61 of file CoordinateTransformation.java.
References additionalTranslation, additionalTranslationPix, completeProjectMatrix, is2dMode, modelViewMatrix, projectionMatrix, unprojectMatrix, VIEW_PORT_SIZE, viewPort, zFar, and zNear.
00061 { 00062 completeProjectMatrix = null; 00063 unprojectMatrix = null; 00064 projectionMatrix = new Matrix4D(); 00065 modelViewMatrix = new Matrix4D(); 00066 viewPort = new double[VIEW_PORT_SIZE]; 00067 additionalTranslation = null; 00068 additionalTranslationPix = null; 00069 zNear = 0.0; 00070 zFar = 1.0; 00071 is2dMode = false; 00072 }
| void org::scilab::modules::renderer::utils::CoordinateTransformation::set2dMode | ( | boolean | is2d | ) | [inline] |
| is2d | specify if the drawing is 2d or not |
Definition at line 78 of file CoordinateTransformation.java.
Referenced by org::scilab::modules::renderer::subwinDrawing::DrawableSubwinGL::setIs2d().

| Matrix4D org::scilab::modules::renderer::utils::CoordinateTransformation::getCompleteProjectionMatrix | ( | ) | [inline] |
Definition at line 85 of file CoordinateTransformation.java.
References completeProjectMatrix.
Referenced by org::scilab::modules::renderer::subwinDrawing::CameraGL::placeCamera().
00085 { 00086 return completeProjectMatrix; 00087 }

| Matrix4D org::scilab::modules::renderer::utils::CoordinateTransformation::getModelViewMatrix | ( | ) | [inline] |
Definition at line 92 of file CoordinateTransformation.java.
References modelViewMatrix.
00092 { 00093 return modelViewMatrix; 00094 }
| Matrix4D org::scilab::modules::renderer::utils::CoordinateTransformation::getUnprojectMatrix | ( | ) | [inline] |
Definition at line 99 of file CoordinateTransformation.java.
References unprojectMatrix.
Referenced by org::scilab::modules::renderer::subwinDrawing::CameraGL::placeCamera().
00099 { 00100 return unprojectMatrix; 00101 }

| double [] org::scilab::modules::renderer::utils::CoordinateTransformation::getViewPort | ( | ) | [inline] |
Definition at line 106 of file CoordinateTransformation.java.
References viewPort.
Referenced by org::scilab::modules::renderer::subwinDrawing::CameraGL::getViewPort(), and org::scilab::modules::renderer::utils::glTools::GLTools::usePixelCoordinates().
00106 { 00107 return viewPort; 00108 }

| void org::scilab::modules::renderer::utils::CoordinateTransformation::setAdditionalTranslation | ( | Vector3D | trans | ) | [inline] |
| trans | translation to apply |
Definition at line 113 of file CoordinateTransformation.java.
Referenced by org::scilab::modules::renderer::DrawableObjectGL::endTranslate(), and org::scilab::modules::renderer::DrawableObjectGL::translate().
00113 { 00114 this.additionalTranslation = trans; 00115 this.additionalTranslationPix = null; // not up to date 00116 00117 }

| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::getAdditionalTranslation | ( | ) | [inline] |
Definition at line 122 of file CoordinateTransformation.java.
References additionalTranslation.
Referenced by org::scilab::modules::renderer::utils::glTools::GLTools::endPixelCoordinates().
00122 { 00123 return additionalTranslation; 00124 }

| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::getAdditionalTranslationPix | ( | GL | gl | ) | [inline] |
| gl | current OpenGL pipeline |
Definition at line 130 of file CoordinateTransformation.java.
References additionalTranslation, additionalTranslationPix, and getCanvasDirection().
Referenced by org::scilab::modules::renderer::utils::glTools::GLTools::usePixelCoordinates().
00130 { 00131 if (additionalTranslation == null) { 00132 return null; 00133 } else if (additionalTranslationPix == null) { 00134 additionalTranslationPix = getCanvasDirection(gl, additionalTranslation); 00135 return additionalTranslationPix; 00136 } else { 00137 return additionalTranslationPix; 00138 } 00139 }


| void org::scilab::modules::renderer::utils::CoordinateTransformation::update | ( | GL | gl | ) | [inline] |
Update the projection data of the coordinates.
| gl | current Gl pipeline |
Definition at line 145 of file CoordinateTransformation.java.
References completeProjectMatrix, org::scilab::modules::renderer::utils::geom3D::Matrix4D::getInverse(), MATRIX_4X4_SIZE, modelViewMatrix, org::scilab::modules::renderer::utils::geom3D::Matrix4D::mult(), projectionMatrix, org::scilab::modules::renderer::utils::geom3D::Matrix4D::setFromOpenGLRepresentation(), unprojectMatrix, and viewPort.
Referenced by org::scilab::modules::renderer::subwinDrawing::CameraGL::backTo3DCoordinates(), org::scilab::modules::renderer::utils::glTools::UnitaryCubeGL::getCubeScreenExtent(), org::scilab::modules::renderer::subwinDrawing::CameraGL::showCamera(), and org::scilab::modules::renderer::subwinDrawing::CameraGL::switchTo2DCoordinates().
00145 { 00146 // get OpenGL transformation matrices 00147 double[] oglModelViewMatrix = new double[MATRIX_4X4_SIZE]; 00148 double[] oglProjectionMatrix = new double[MATRIX_4X4_SIZE]; 00149 gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, oglModelViewMatrix, 0); 00150 gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, oglProjectionMatrix, 0); 00151 gl.glGetDoublev(GL.GL_VIEWPORT, viewPort, 0); 00152 // force values to 0 to be compatible when 00153 // OpenGL pipeline is enable. The viewport position 00154 // is modified. See http://www.javagaming.org/forums/index.php?topic=16414.0. 00155 viewPort[0] = 0; 00156 viewPort[1] = 0; 00157 00158 // projection (without viewport is done by v' = P.M.v 00159 // where v' is the canvas coordinates and v scene coordinates 00160 projectionMatrix.setFromOpenGLRepresentation(oglProjectionMatrix); 00161 modelViewMatrix.setFromOpenGLRepresentation(oglModelViewMatrix); 00162 completeProjectMatrix = projectionMatrix.mult(modelViewMatrix); 00163 00164 // unproject is done by v = (P.M)^-1.v' 00165 unprojectMatrix = completeProjectMatrix.getInverse(); 00166 }


| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::getCanvasCoordinates | ( | GL | gl, | |
| Vector3D | pos | |||
| ) | [inline] |
Get the coordinate of a 3D position in a canvas frame from its user coordinates.
| gl | current OpenGL pipeline | |
| pos | coordinates of the position. |
Definition at line 174 of file CoordinateTransformation.java.
References project().
Referenced by org::scilab::modules::renderer::textDrawing::TextContentDrawerGL::drawTextContent3D(), org::scilab::modules::renderer::subwinDrawing::TicksDrawerGL::drawTicks(), org::scilab::modules::renderer::textDrawing::TextContentDrawerGL::getBoundingRectangle2D(), getCanvasCoordinates(), getCanvasDirection(), org::scilab::modules::renderer::utils::glTools::UnitaryCubeGL::getCubeScreenExtent(), org::scilab::modules::renderer::utils::glTools::MovableClipPlane3D::pushPlane(), org::scilab::modules::renderer::drawers::ArrowHeadDrawerGL::redrawArrowHeads(), org::scilab::modules::renderer::drawers::MarkDrawerGL::redrawMarks(), and org::scilab::modules::renderer::drawers::ArrowHeadDrawerGL::setAxesBounds().
00174 { 00175 // I first used gluProject, but it is slower since it will always perform matrices multiplications and inverse. 00176 //return projectMatrix.mult(pos); 00177 return project(gl, pos); 00178 }


| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::project | ( | GL | gl, | |
| Vector3D | pos | |||
| ) | [inline] |
Perform the same operation as gluProject.
| gl | unused | |
| pos | scene position |
Definition at line 186 of file CoordinateTransformation.java.
References completeProjectMatrix, org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getZ(), org::scilab::modules::renderer::utils::geom3D::Matrix4D::mult(), org::scilab::modules::renderer::utils::geom3D::Vector3D::setX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::setY(), org::scilab::modules::renderer::utils::geom3D::Vector3D::setZ(), VIEW_PORT_SIZE, and viewPort.
Referenced by getCanvasCoordinates().
00186 { 00187 Vector3D canvasCoord = completeProjectMatrix.mult(pos); 00188 canvasCoord.setX(viewPort[0] + viewPort[2] * (canvasCoord.getX() + 1.0) / 2.0); 00189 canvasCoord.setY(viewPort[1] + viewPort[VIEW_PORT_SIZE - 1] * (canvasCoord.getY() + 1.0) / 2.0); 00190 canvasCoord.setZ((canvasCoord.getZ() + 1.0) / 2.0); 00191 return canvasCoord; 00192 }


| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::unProject | ( | GL | gl, | |
| Vector3D | canvasPos | |||
| ) | [inline] |
Perform the same operation as gluUnproject.
| gl | unused | |
| canvasPos | canvas position |
Definition at line 200 of file CoordinateTransformation.java.
References org::scilab::modules::renderer::utils::geom3D::Vector3D::getX(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getY(), org::scilab::modules::renderer::utils::geom3D::Vector3D::getZ(), org::scilab::modules::renderer::utils::geom3D::Matrix4D::mult(), unprojectMatrix, VIEW_PORT_SIZE, and viewPort.
Referenced by retrieveSceneCoordinates().
00200 { 00201 Vector3D sceneCoord 00202 = new Vector3D(2.0 * (canvasPos.getX() - viewPort[0]) / viewPort[2] - 1.0, 00203 2.0 * (canvasPos.getY() - viewPort[1]) / viewPort[VIEW_PORT_SIZE - 1] - 1.0, 00204 2.0 * canvasPos.getZ() - 1.0); 00205 return unprojectMatrix.mult(sceneCoord); 00206 00207 }


| Vector3D [] org::scilab::modules::renderer::utils::CoordinateTransformation::getCanvasCoordinates | ( | GL | gl, | |
| Vector3D[] | positions | |||
| ) | [inline] |
Convert several user coordinates to the canvas one
| gl | current OpenGL pipeline | |
| positions | coordinates of the different position (size n x 3). |
Definition at line 216 of file CoordinateTransformation.java.
References getCanvasCoordinates(), and i.
00216 { 00217 int nbCoords = positions.length; 00218 Vector3D[] canvasCoords = new Vector3D[nbCoords]; 00219 00220 for (int i = 0; i < nbCoords; i++) { 00221 canvasCoords[i] = getCanvasCoordinates(gl, positions[i]); 00222 } 00223 return canvasCoords; 00224 }

| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::getCanvasDirection | ( | GL | gl, | |
| Vector3D | direction | |||
| ) | [inline] |
Convert a direction in pixels
| gl | current GL pipeline | |
| direction | direction to transform |
Definition at line 232 of file CoordinateTransformation.java.
References getCanvasCoordinates(), res, and org::scilab::modules::renderer::utils::geom3D::Vector3D::substract().
Referenced by getAdditionalTranslationPix().
00232 { 00233 Vector3D originPix = getCanvasCoordinates(gl, Vector3D.ORIGIN); 00234 Vector3D res = getCanvasCoordinates(gl, direction); 00235 return res.substract(originPix); 00236 }


| Vector3D org::scilab::modules::renderer::utils::CoordinateTransformation::retrieveSceneCoordinates | ( | GL | gl, | |
| Vector3D | canvasPos | |||
| ) | [inline] |
Opposite transformation od getCanvasCoordinates. Compute back scene coordinates from window coordinates.
| gl | current OpengL pipeline | |
| canvasPos | coordinates of the point in the canvas frame |
Definition at line 245 of file CoordinateTransformation.java.
References unProject().
Referenced by org::scilab::modules::renderer::subwinDrawing::TicksDrawerGL::drawLabels(), and org::scilab::modules::renderer::textDrawing::TextContentDrawerGL::drawTextContent3D().
00245 { 00246 // I first used gluUnproject, but it is slower since it will always perform matrices multiplications and inverse. 00247 00248 //return unprojectMatrix.mult(canvasPos); 00249 return unProject(gl, canvasPos); 00250 }

