Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View3D.java,1.20,1.21
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-11-18 01:28:09
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31672/src/net/sourceforge/bprocessor/gl/view Modified Files: View3D.java Log Message: new cursors for drag and rotate along with better rotation and drag, still small bugs when rotating while an surface is selected and zoomfactor different from 1 Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** View3D.java 17 Nov 2005 18:14:00 -0000 1.20 --- View3D.java 18 Nov 2005 01:27:56 -0000 1.21 *************** *** 66,70 **** double aspect = width / height; double near = 1 * getZoomFactor(); ! double far = 200.0 * getZoomFactor(); focalwidth = 60.0; if (aspect < 1.0) { --- 66,70 ---- double aspect = width / height; double near = 1 * getZoomFactor(); ! double far = 1000.0 * getZoomFactor(); focalwidth = 60.0; if (aspect < 1.0) { *************** *** 78,87 **** gl.glLoadIdentity(); ! glu.gluLookAt(camera[0] * getZoomFactor(), ! camera[1] * getZoomFactor(), ! camera[2] * getZoomFactor(), center[0], center[1], center[2], roll[0], roll[1], roll[2]); - //gl.glMultMatrixd(modelMatrix); if (reset) { --- 78,86 ---- 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]); if (reset) { *************** *** 124,136 **** public void translateCenter(double [] mv) { if (mv.length == 3) { ! double dx = modelMatrix[0] * mv[0] + modelMatrix[1] * -mv[1] + modelMatrix[2] * mv[2]; ! double dy = modelMatrix[4] * mv[0] + modelMatrix[5] * -mv[1] + modelMatrix[6] * mv[2]; ! double dz = modelMatrix[8] * mv[0] + modelMatrix[9] * -mv[1] + modelMatrix[10] * mv[2]; ! center[0] += dx; ! center[1] += dy; ! center[2] += dz; ! camera[0] += dx; ! camera[1] += dy; ! camera[2] += dz; } else { log.error("[translateViewMatrix] Wrong parameter size"); --- 123,135 ---- 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"); *************** *** 179,187 **** 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; - double pro = x * y * z; sinx = Math.sin(x * angle); --- 178,185 ---- 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; sinx = Math.sin(x * angle); *************** *** 225,260 **** public void rollCamera(double angle) { angle /= width; ! double dx = camera[0] - center[0]; ! double dy = camera[1] - center[1]; ! double dz = camera[2] - center[2]; ! double length = Math.sqrt(dx * dx + dy * dy + dz * dz); ! ! double sinx = Math.sin(dx / length * angle); ! double cosx = Math.cos(dx / length * angle); ! double siny = Math.sin(dy / length * angle); ! double cosy = Math.cos(dy / length * angle); ! double sinz = Math.sin(dz / length * angle); ! double cosz = Math.cos(dz / length * angle); ! ! double[] rotx = new double[] {1, 0, 0, ! 0, cosx, sinx, ! 0, -sinx, cosx}; ! double[] roty = new double[] {cosy, 0, -siny, ! 0, 1, 0, ! siny, 0, cosy}; ! double[] rotz = new double[] {cosz, sinz, 0, ! -sinz, cosz, 0, ! 0, 0, 1}; ! ! double[] rot = multMatrix3(rotx, roty); ! rot = multMatrix3(rot, rotz); ! ! double rx = roll[0] * rot[0] + roll[1] * rot[1] + roll[2] * rot[2]; ! double ry = roll[0] * rot[3] + roll[1] * rot[4] + roll[2] * rot[5]; ! double rz = roll[0] * rot[6] + roll[1] * rot[7] + roll[2] * rot[8]; ! ! roll[0] = rx; ! roll[1] = ry; ! roll[2] = rz; } --- 223,227 ---- public void rollCamera(double angle) { angle /= width; ! rotate(angle, center, modelMatrix[2], modelMatrix[6], modelMatrix[10]); } *************** *** 292,298 **** double angle = change / height; if (roll[2] < 0) { ! rotate(-angle, c, 0, 0, -1); } else { ! rotate(-angle, c, 0, 0, 1); } } --- 259,265 ---- double angle = change / height; if (roll[2] < 0) { ! rotate(-angle, c, 0, 0, -1); } else { ! rotate(-angle, c, 0, 0, 1); } } |