[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.65,1.66 View.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-12-01 10:10:18
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3390/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java View.java View3D.java Log Message: removed the two timers from the system and added a renamed rotationtool to cameratool. Changed camera rotation so that it uses the geometry class from the model package. It is now relatively good rotation and drag in the right directions. The are one question ralated to horizontal rotation either we shall rotate about the z-axis or the up vector, as it is now I use the up vector but that makes rotation a bit wird in some situations. If we choose to use the z-axis we cant rotate if we look from above. Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** AbstractView.java 30 Nov 2005 23:04:54 -0000 1.65 --- AbstractView.java 1 Dec 2005 10:10:02 -0000 1.66 *************** *** 109,115 **** protected GLUT glut = new GLUT(); - /** The zoomFactor in the parent view */ - protected double zoomFactor = 1.0; - /** The GLView */ protected GLView glv = null; --- 109,112 ---- *************** *** 1234,1238 **** * @param change The change in R+ (is divided with the window height) */ ! public void translateRotationX(double change) { } --- 1231,1235 ---- * @param change The change in R+ (is divided with the window height) */ ! public void rotateVertical(double change) { } *************** *** 1241,1260 **** * @param change The change in R+ (is divided with the window height) */ ! public void translateRotationY(double change) { } /** - * Change the zoom factor of the camera take only R+ - * 1-oo is increase zoom and 0-1 decrease 1 keep the current zoom - * @param zoom the zoom factor change - */ - public void zoom(double zoom) { - if (zoom > 0) { - zoom *= getZoomFactor(); - setZoomFactor(zoom); - } - } - - /** * Change view to 3d, XY, XZ, or YZ * @param value One of 3d_VIEW, XY_VIEW, XZ_VIEW, YZ_VIEW --- 1238,1245 ---- * @param change The change in R+ (is divided with the window height) */ ! public void rotateHorizontal(double change) { } /** * Change view to 3d, XY, XZ, or YZ * @param value One of 3d_VIEW, XY_VIEW, XZ_VIEW, YZ_VIEW *************** *** 1262,1281 **** public void changeView(int value) { } - /** - * setter for zoomFactor - * @param z The new zoomFactor - */ - public void setZoomFactor(double z) { - zoomFactor = z; - } - - /** - * getter for zoomFactor - * @return The parent zoomFactor - */ - public double getZoomFactor() { - return zoomFactor; - } - /** * Getter for activeEdge --- 1247,1250 ---- *************** *** 1607,1611 **** * @param mv the move vector */ ! public abstract void translateCenter(double [] mv); /** --- 1576,1580 ---- * @param mv the move vector */ ! public abstract void translate(double [] mv); /** Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** View3D.java 24 Nov 2005 10:31:22 -0000 1.23 --- View3D.java 1 Dec 2005 10:10:02 -0000 1.24 *************** *** 89,94 **** double aspect = width / height; ! double near = 1 * getZoomFactor(); ! double far = 1000.0 * getZoomFactor(); focalwidth = 60.0; if (aspect < 1.0) { --- 89,97 ---- double aspect = width / height; ! double length = Math.sqrt((camera[0] - center[0]) * (camera[0] - center[0]) + ! (camera[1] - center[1]) * (camera[1] - center[1]) + ! (camera[2] - center[2]) * (camera[2] - center[2])); ! double near = length / 10; ! double far = length * 100.0; focalwidth = 60.0; if (aspect < 1.0) { *************** *** 102,108 **** gl.glLoadIdentity(); ! glu.gluLookAt(center[0] + (camera[0] - center[0]) * getZoomFactor(), ! center[1] + (camera[1] - center[1]) * getZoomFactor(), ! center[2] + (camera[2] - center[2]) * getZoomFactor(), center[0], center[1], center[2], roll[0], roll[1], roll[2]); --- 105,111 ---- gl.glLoadIdentity(); ! glu.gluLookAt(center[0] + (camera[0] - center[0]), ! center[1] + (camera[1] - center[1]), ! center[2] + (camera[2] - center[2]), center[0], center[1], center[2], roll[0], roll[1], roll[2]); *************** *** 145,159 **** * @param mv the move vector */ ! public void translateCenter(double [] mv) { if (mv.length == 3) { ! double x = modelMatrix[0] * mv[0] - modelMatrix[1] * mv[1] + modelMatrix[2] * mv[2]; ! double y = modelMatrix[4] * mv[0] - modelMatrix[5] * mv[1] + modelMatrix[6] * mv[2]; ! double z = modelMatrix[8] * mv[0] - modelMatrix[9] * mv[1] + modelMatrix[10] * mv[2]; ! center[0] += x * getZoomFactor(); ! center[1] += y * getZoomFactor(); ! center[2] += z * getZoomFactor(); ! camera[0] += x * getZoomFactor(); ! camera[1] += y * getZoomFactor(); ! camera[2] += z * getZoomFactor(); } else { log.error("[translateViewMatrix] Wrong parameter size"); --- 148,159 ---- * @param mv the move vector */ ! public void translate(double [] mv) { if (mv.length == 3) { ! center[0] += mv[0]; ! center[1] += mv[1]; ! center[2] += mv[2]; ! camera[0] += mv[0]; ! camera[1] += mv[1]; ! camera[2] += mv[2]; } else { log.error("[translateViewMatrix] Wrong parameter size"); *************** *** 178,183 **** * @param change The change in R+ (is divided with the window height) */ ! public void translateRotationX(double change) { ! translateRotationX(change, center); } --- 178,183 ---- * @param change The change in R+ (is divided with the window height) */ ! public void rotateVertical(double change) { ! rotateVertical(change, center); } *************** *** 187,191 **** * @param c The point to rotate about */ ! public void translateRotationX(double change, double[] c) { double angle = change / width; rotate(-angle, c, modelMatrix[0], modelMatrix[4], modelMatrix[8]); --- 187,191 ---- * @param c The point to rotate about */ ! public void rotateVertical(double change, double[] c) { double angle = change / width; rotate(-angle, c, modelMatrix[0], modelMatrix[4], modelMatrix[8]); *************** *** 202,208 **** public void rotate(double angle, double[] c, double x, double y, double z) { double rx, ry, rz; ! double dx = (camera[0] - c[0]); ! double dy = (camera[1] - c[1]); ! double dz = (camera[2] - c[2]); double sinx, cosx, siny, sinz, cosy, cosz; --- 202,208 ---- public void rotate(double angle, double[] c, double x, double y, double z) { double rx, ry, rz; ! double dx = (camera[0]); ! double dy = (camera[1]); ! double dz = (camera[2]); double sinx, cosx, siny, sinz, cosy, cosz; *************** *** 232,242 **** rz = dx * rot[6] + dy * rot[7] + dz * rot[8]; ! camera[0] = rx + c[0]; ! camera[1] = ry + c[1]; ! camera[2] = rz + c[2]; ! roll[0] = roll[0] * rot[0] + roll[1] * rot[1] + roll[2] * rot[2]; roll[1] = roll[0] * rot[3] + roll[1] * rot[4] + roll[2] * rot[5]; roll[2] = roll[0] * rot[6] + roll[1] * rot[7] + roll[2] * rot[8]; } --- 232,249 ---- rz = dx * rot[6] + dy * rot[7] + dz * rot[8]; ! camera[0] = rx; ! camera[1] = ry; ! camera[2] = rz; ! if (c != center) { ! //rotate center as well ! center[0] = center[0] * rot[0] + center[1] * rot[1] + center[2] * rot[2]; ! center[1] = center[0] * rot[3] + center[1] * rot[4] + center[2] * rot[5]; ! center[2] = center[0] * rot[6] + center[1] * rot[7] + center[2] * rot[8]; ! } ! /* roll[0] = roll[0] * rot[0] + roll[1] * rot[1] + roll[2] * rot[2]; roll[1] = roll[0] * rot[3] + roll[1] * rot[4] + roll[2] * rot[5]; roll[2] = roll[0] * rot[6] + roll[1] * rot[7] + roll[2] * rot[8]; + */ } *************** *** 280,284 **** * @param c The point to rotate about */ ! public void translateRotationY(double change, double[] c) { double angle = change / height; if (roll[2] < 0) { --- 287,291 ---- * @param c The point to rotate about */ ! public void rotateHorizontal(double change, double[] c) { double angle = change / height; if (roll[2] < 0) { *************** *** 293,298 **** * @param change The change in R+ (is divided with the window height) */ ! public void translateRotationY(double change) { ! translateRotationY(change, center); } --- 300,305 ---- * @param change The change in R+ (is divided with the window height) */ ! public void rotateHorizontal(double change) { ! rotateHorizontal(change, center); } *************** *** 312,316 **** camera[2] = 25.0; roll[0] = .0; ! roll[1] = .1; roll[2] = .0; } --- 319,323 ---- camera[2] = 25.0; roll[0] = .0; ! roll[1] = 1.0; roll[2] = .0; } *************** *** 326,330 **** roll[0] = .0; roll[1] = .0; ! roll[2] = .1; } if (value == View.VIEW_YZ) { --- 333,337 ---- roll[0] = .0; roll[1] = .0; ! roll[2] = 1.0; } if (value == View.VIEW_YZ) { *************** *** 339,343 **** roll[0] = .0; roll[1] = .0; ! roll[2] = .1; } if (value == View.VIEW_3D) { --- 346,350 ---- roll[0] = .0; roll[1] = .0; ! roll[2] = 1.0; } if (value == View.VIEW_3D) { *************** *** 437,443 **** return vertex; } ! } ! log.warn("Too many arguments"); ! return new Vertex(""); } --- 444,451 ---- return vertex; } ! } else { ! log.warn("Too many arguments " + coords.length + ", " + plane.toString()); ! } ! return null; } *************** *** 449,452 **** return new Transformation(glu, modelMatrix, projMatrix, screenport); } ! } --- 457,477 ---- return new Transformation(glu, modelMatrix, projMatrix, screenport); } ! ! /** ! * Function to zoom in ! */ ! public void zoomin() { ! camera[0] -= (camera[0] - center[0]) * 0.1; ! camera[1] -= (camera[1] - center[1]) * 0.1; ! camera[2] -= (camera[2] - center[2]) * 0.1; ! } ! ! /** ! * Function to zoom out ! */ ! public void zoomout() { ! camera[0] += (camera[0] - center[0]) * 0.1; ! camera[1] += (camera[1] - center[1]) * 0.1; ! camera[2] += (camera[2] - center[2]) * 0.1; ! } } Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** View.java 30 Nov 2005 23:04:54 -0000 1.24 --- View.java 1 Dec 2005 10:10:02 -0000 1.25 *************** *** 118,155 **** * @param mv the move vector */ ! public void translateCenter(double[] mv); /** ! * Change the zoom factor of the camera take only R+ ! * 1-oo is increase zoom and 0-1 decrease 1 keep the current zoom ! * @param zoom the zoom factor change */ ! public void zoom(double zoom); /** ! * Change the rotation about the x axis. Only usable in 3D ! * @param change The change in R+ (is divided with the window height) */ ! public void translateRotationX(double change); /** ! * Change the rotation about the y axis. Only usable in 3D * @param change The change in R+ (is divided with the window height) */ ! public void translateRotationY(double change); ! /** ! * Change the rotation about the y axis * @param change The change in R+ (is divided with the window height) * @param center The point to rotate about */ ! public void translateRotationY(double change, double[] center); /** ! * Change the rotation about the x axis * @param change The change in R+ (is divided with the window height) * @param center The point to rotate about */ ! public void translateRotationX(double change, double[] center); /** --- 118,158 ---- * @param mv the move vector */ ! public void translate(double[] mv); /** ! * zoom the camera in */ ! public void zoomin(); /** ! * zoom the camera out */ ! public void zoomout(); /** ! * Change the rotation about the x axis. Only usable in 3D * @param change The change in R+ (is divided with the window height) */ ! public void rotateVertical(double change); ! /** ! * Change the rotation about the x axis * @param change The change in R+ (is divided with the window height) * @param center The point to rotate about */ ! public void rotateVertical(double change, double[] center); /** ! * Change the rotation about the y axis. Only usable in 3D ! * @param change The change in R+ (is divided with the window height) ! */ ! public void rotateHorizontal(double change); ! ! /** ! * Change the rotation about the y axis * @param change The change in R+ (is divided with the window height) * @param center The point to rotate about */ ! public void rotateHorizontal(double change, double[] center); /** *************** *** 184,193 **** /** - * getter for zoomFactor - * @return The parent zoomFactor - */ - public double getZoomFactor(); - - /** * Setter for snapVertex * @param v The new snapVertex --- 187,190 ---- |