diff --git a/jzy3d-api/src/api/org/jzy3d/plot3d/primitives/axes/AxeBox.java b/jzy3d-api/src/api/org/jzy3d/plot3d/primitives/axes/AxeBox.java index fe9493c0..a9176618 100644 --- a/jzy3d-api/src/api/org/jzy3d/plot3d/primitives/axes/AxeBox.java +++ b/jzy3d-api/src/api/org/jzy3d/plot3d/primitives/axes/AxeBox.java @@ -713,31 +713,34 @@ public class AxeBox implements IAxe { /* COMPUTATION OF HIDDEN QUADS */ - public void updateHiddenQuads(GL gl, Camera camera) { + protected void updateHiddenQuads(GL gl, Camera camera) { quadIsHidden = getHiddenQuads(gl, camera); } /** Computes the visibility of each cube face. */ protected boolean[] getHiddenQuads(GL gl, Camera cam) { + Coord3d scaledEye = cam.getEye().div(scale); + return getHiddenQuads(scaledEye, center); + } + + public boolean[] getHiddenQuads(Coord3d scaledEye, Coord3d center) { boolean[] status = new boolean[6]; - - Coord3d se = cam.getEye().div(scale); - - if (se.x <= center.x) { + + if (scaledEye.x <= center.x) { status[0] = false; status[1] = true; } else { status[0] = true; status[1] = false; } - if (se.y <= center.y) { + if (scaledEye.y <= center.y) { status[2] = false; status[3] = true; } else { status[2] = true; status[3] = false; } - if (se.z <= center.z) { + if (scaledEye.z <= center.z) { status[4] = false; status[5] = true; } else { diff --git a/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/Camera.java b/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/Camera.java index 686c3e80..66511f13 100644 --- a/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/Camera.java +++ b/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/Camera.java @@ -281,7 +281,7 @@ public class Camera extends AbstractViewportManager { return new PolygonArray(x, y, z); } - public Grid modelToScreen(GL gl, GLU glu, Grid grid) { + /*public Grid modelToScreen(GL gl, GLU glu, Grid grid) { int viewport[] = getViewPortAsInt(gl); double screencoord[] = new double[3]; @@ -293,9 +293,9 @@ public class Camera extends AbstractViewportManager { for (int i = 0; i < xlen; i++) { for (int j = 0; j < ylen; j++) { - // if( ! glu.gluProject( grid.getX()[i], grid.getY()[i], - // grid.getZ()[i][j], getModelViewAsFloat(gl), 0, - // getProjectionAsFloat(gl), 0, viewport, 0, screencoord, 0 ) ) + if( ! glu.gluProject( grid.getX()[i], grid.getY()[i], + grid.getZ()[i][j], getModelViewAsFloat(gl), 0, + getProjectionAsFloat(gl), 0, viewport, 0, screencoord, 0 ) ) failedProjection("Could not retrieve model coordinates in screen for point " + i); x[i] = (float) screencoord[0]; y[j] = (float) screencoord[1]; // STUPID :) @@ -303,7 +303,7 @@ public class Camera extends AbstractViewportManager { } } return new Grid(x, y, z); - } + }*/ public PolygonArray[][] modelToScreen(GL gl, GLU glu, PolygonArray[][] polygons) { int viewport[] = getViewPortAsInt(gl); @@ -399,6 +399,7 @@ public class Camera extends AbstractViewportManager { gl.getGL2().glBegin(GL.GL_POINTS); gl.getGL2().glPointSize(camWidth); gl.getGL2().glColor4f(camColor.r, camColor.g, camColor.b, camColor.a); + gl.getGL2().glVertex3f(eye.x, eye.y, eye.z); gl.getGL2().glEnd(); } @@ -470,10 +471,14 @@ public class Camera extends AbstractViewportManager { throw new RuntimeException("Camera.shoot(): unknown projection mode '" + projection + "'"); // Set camera position + doLookAt(glu); + } + + protected void doLookAt(GLU glu) { glu.gluLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, up.x, up.y, up.z); } - private void projectionOrthoGLES2(ViewportConfiguration viewport) { + protected void projectionOrthoGLES2(ViewportConfiguration viewport) { if (ViewportMode.STRETCH_TO_FILL.equals(viewport.getMode())) GLES2CompatUtils.glOrtho(-radius, +radius, -radius, +radius, near, far); else if (ViewportMode.RECTANGLE_NO_STRETCH.equals(viewport.getMode())) @@ -482,7 +487,7 @@ public class Camera extends AbstractViewportManager { GLES2CompatUtils.glOrtho(-radius, +radius, -radius, +radius, near, far); } - private void projectionOrthoGL2(GL gl, ViewportConfiguration viewport) { + protected void projectionOrthoGL2(GL gl, ViewportConfiguration viewport) { if (ViewportMode.STRETCH_TO_FILL.equals(viewport.getMode())) gl.getGL2().glOrtho(-radius, +radius, -radius, +radius, near, far); else if (ViewportMode.RECTANGLE_NO_STRETCH.equals(viewport.getMode())) diff --git a/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/View.java b/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/View.java index b8ee916c..b83d1101 100644 --- a/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/View.java +++ b/jzy3d-api/src/api/org/jzy3d/plot3d/rendering/view/View.java @@ -650,13 +650,11 @@ public class View { float lmax = 1; if (bounds != null) { - xLen = bounds.getXmax() - bounds.getXmin(); - yLen = bounds.getYmax() - bounds.getYmin(); - zLen = bounds.getZmax() - bounds.getZmin(); + Coord3d range = squarifyComputeBoundsRanges(bounds); + xLen = range.x; + yLen = range.y; + zLen = range.z; - /*xLen = spaceTransformer.getX().compute(bounds.getXmax()) - spaceTransformer.getX().compute(bounds.getXmin()); - yLen = spaceTransformer.getY().compute(bounds.getYmax()) - spaceTransformer.getY().compute(bounds.getYmin()); - zLen = spaceTransformer.getZ().compute(bounds.getZmax()) - spaceTransformer.getZ().compute(bounds.getZmin());*/ lmax = Math.max(Math.max(xLen, yLen), zLen); } @@ -675,6 +673,13 @@ public class View { float zscale = (float) ((double) lmax / (double) zLen); return new Coord3d(xscale, yscale, zscale); } + + protected Coord3d squarifyComputeBoundsRanges(BoundingBox3d bounds){ + return bounds.getRange(); + /*xLen = spaceTransformer.getX().compute(bounds.getXmax()) - spaceTransformer.getX().compute(bounds.getXmin()); + yLen = spaceTransformer.getY().compute(bounds.getYmax()) - spaceTransformer.getY().compute(bounds.getYmin()); + zLen = spaceTransformer.getZ().compute(bounds.getZmax()) - spaceTransformer.getZ().compute(bounds.getZmin());*/ + } /* GL */