/** * draw a sphere with center and radius. view scaling is used to know how many triangles are * needed * * @param center center of the sphere * @param radius radius of the sphere * @param longitude longitude length for rendering, corresponding to 2*PI (must be power of 2) * @param longitudeStart for sphere parts, first longitude to draw * @param longitudeLength for sphere parts, longitude width (must be power of 2) */ public void drawSphere( Coords center, double radius, int longitude, double longitudeStart, int longitudeLength) { drawSphere( center, radius, longitude, longitudeStart, longitudeLength, manager.getView3D().getFrustumRadius()); }
/** * draw an ellipsoid * * @param center center * @param ev0 first eigenvector * @param ev1 second eigenvector * @param ev2 third eigenvector * @param r0 first half axis * @param r1 second half axis * @param r2 third half axis * @param longitude longitude length for rendering */ public void drawEllipsoid( Coords center, Coords ev0, Coords ev1, Coords ev2, double r0, double r1, double r2, int longitude) { if (managerElements == null) { managerElements = new ManagerElementForGLList(manager.getRenderer(), manager.getView3D(), manager); plotterElements = new PlotterSurfaceElements(managerElements); } plotterElements.drawEllipsoid(center, ev0, ev1, ev2, r0, r1, r2, longitude); }
/** * draw a paraboloid * * @param center center * @param ev0 first eigenvector * @param ev1 second eigenvector * @param ev2 third eigenvector * @param r0 first half axis * @param r1 second half axis * @param longitude longitude length for rendering * @param min minimum parameter for axis * @param max maximum parameter for axis * @param fading if we need fading or not */ public void drawParaboloid( Coords center, Coords ev0, Coords ev1, Coords ev2, double r0, double r1, int longitude, double min, double max, boolean fading) { if (managerElements == null) { managerElements = new ManagerElementForGLList(manager.getRenderer(), manager.getView3D(), manager); plotterElements = new PlotterSurfaceElements(managerElements); } plotterElements.drawParaboloid(center, ev0, ev1, ev2, r0, r1, longitude, min, max, fading); }
/** * draw a parabolic cylinder * * @param center center * @param ev0 first eigenvector * @param ev1 second eigenvector * @param ev2 third eigenvector * @param r half axis * @param min minimum parameter for quadric axis * @param max maximum parameter for quadric axis * @param lineMin minimum parameter for line axis * @param lineMax maximum parameter for line axis * @param fading if we need fading or not */ public void drawParabolicCylinder( Coords center, Coords ev0, Coords ev1, Coords ev2, double r, double min, double max, double lineMin, double lineMax, boolean fading) { if (managerElements == null) { managerElements = new ManagerElementForGLList(manager.getRenderer(), manager.getView3D(), manager); plotterElements = new PlotterSurfaceElements(managerElements); } plotterElements.drawParabolicCylinder( center, ev0, ev1, ev2, r, min, max, lineMin, lineMax, fading); }
/** * draw an hyperbolic paraboloid * * @param center center * @param ev0 first eigenvector * @param ev1 second eigenvector * @param ev2 third eigenvector * @param r0 first half axis * @param r1 second half axis * @param min0 minimum parameter for first axis * @param max0 maximum parameter for first axis * @param min1 minimum parameter for second axis * @param max1 maximum parameter for second axis * @param fading if we need fading or not */ public void drawHyperbolicParaboloid( Coords center, Coords ev0, Coords ev1, Coords ev2, double r0, double r1, double min0, double max0, double min1, double max1, boolean fading) { if (managerElements == null) { managerElements = new ManagerElementForGLList(manager.getRenderer(), manager.getView3D(), manager); plotterElements = new PlotterSurfaceElements(managerElements); } plotterElements.drawHyperbolicParaboloid( center, ev0, ev1, ev2, r0, r1, min0, max0, min1, max1, fading); }
public void drawSphere( Coords center, double radius, int longitude, double longitudeStart, int longitudeLength, double frustumRadius) { manager.startGeometry(Manager.Type.TRIANGLES); // set texture to (0,0) manager.setDummyTexture(); int latitude = longitude / 4; // check which parts are visible (latitudes) Coords o = manager.getView3D().getCenter(); double z = center.getZ(); double zMin = o.getZ() - frustumRadius; double zMax = o.getZ() + frustumRadius; int latitudeMaxTop = 0; latitudeMaxTop = latitude; if (Kernel.isGreater(z + radius, zMax)) { double angle = Math.asin((zMax - z) / radius); latitudeMaxTop = (int) (latitude * 2 * angle / Math.PI) + 2; } int latitudeMaxBottom = 0; latitudeMaxBottom = latitude; if (Kernel.isGreater(zMin, z - radius)) { double angle = Math.asin((z - zMin) / radius); latitudeMaxBottom = (int) (latitude * 2 * angle / Math.PI) + 2; } // Log.debug(latitudeMaxBottom+","+latitudeMaxTop); int latitudeMax = Math.max(latitudeMaxTop, latitudeMaxBottom); int latitudeMin = 0; // start on equator if (latitudeMaxTop < 0) { // start below equator latitudeMin = -latitudeMaxTop; } else if (latitudeMaxBottom < 0) { // start above equator latitudeMin = -latitudeMaxBottom; } // check which parts are visible (longitudes) // start drawing if (coordsArray.length <= longitudeLength) { coordsArray = new Coords[longitudeLength + 1]; for (int ui = 0; ui <= longitudeLength; ui++) { coordsArray[ui] = new Coords(4); } } Coords norm1 = new Coords(4), norm2 = new Coords(4), n1b = new Coords(4), n2b = new Coords(4); double[] cosSinV = new double[2]; // equator // cosSinV[0] = 1; // cos(0) // cosSinV[1] = 0; // sin(0) cosSin(latitudeMin, latitude, cosSinV); double lastCos = 1; for (int ui = 0; ui <= longitudeLength; ui++) { sphericalCoords(ui, longitude, longitudeStart, cosSinV, coordsArray[ui]); } // shift for longitude int shift = 1; boolean jumpNeeded = false; for (int vi = latitudeMin + 1; vi < latitudeMax; vi++) { cosSin(vi, latitude, cosSinV); // check if parallel is small enough to make jumps if (2 * cosSinV[0] < lastCos) { lastCos = lastCos / 2; jumpNeeded = true; } else { jumpNeeded = false; } // first values norm2.set(coordsArray[0]); sphericalCoords(0, longitude, longitudeStart, cosSinV, n2b); // first : no jump boolean jump = jumpNeeded; for (int ui = shift; ui <= longitudeLength; ui += shift) { // last latitude values norm1.set(norm2); norm2.set(coordsArray[ui]); // new latitude values and draw triangles n1b.set(n2b); if (jumpNeeded) { if (jump) { // draw edge triangle and center triangle sphericalCoords(ui + shift, longitude, longitudeStart, cosSinV, n2b); if (vi < latitudeMaxTop) { // top triangles drawNCr(norm1, center, radius); drawNCr(norm2, center, radius); drawNCr(n1b, center, radius); drawNCr(n1b, center, radius); drawNCr(norm2, center, radius); drawNCr(n2b, center, radius); } if (vi < latitudeMaxBottom) { // bottom triangles drawNCrm(norm1, center, radius); drawNCrm(n1b, center, radius); drawNCrm(norm2, center, radius); drawNCrm(n1b, center, radius); drawNCrm(n2b, center, radius); drawNCrm(norm2, center, radius); } } else { // draw edge triangle sphericalCoords(ui, longitude, longitudeStart, cosSinV, n2b); if (vi < latitudeMaxTop) { // top triangles drawNCr(norm1, center, radius); drawNCr(norm2, center, radius); drawNCr(n1b, center, radius); } if (vi < latitudeMaxBottom) { // bottom triangles drawNCrm(norm1, center, radius); drawNCrm(n1b, center, radius); drawNCrm(norm2, center, radius); } } } else { // no jump : draw two triangles sphericalCoords(ui, longitude, longitudeStart, cosSinV, n2b); if (vi < latitudeMaxTop) { // top triangles drawNCr(norm1, center, radius); drawNCr(norm2, center, radius); drawNCr(n1b, center, radius); drawNCr(norm2, center, radius); drawNCr(n2b, center, radius); drawNCr(n1b, center, radius); } if (vi < latitudeMaxBottom) { // bottom triangles drawNCrm(norm1, center, radius); drawNCrm(n1b, center, radius); drawNCrm(norm2, center, radius); drawNCrm(norm2, center, radius); drawNCrm(n1b, center, radius); drawNCrm(n2b, center, radius); } } coordsArray[ui].set(n2b); if (jumpNeeded) { jump = !jump; } } // if just jumps done, next shift is twice if (jumpNeeded) { shift = shift * 2; } sphericalCoords(0, longitude, longitudeStart, cosSinV, coordsArray[0]); } if (latitudeMax == latitude) { // pole norm2.set(coordsArray[0]); for (int ui = shift; ui <= longitudeLength; ui += shift) { norm1.set(norm2); norm2.set(coordsArray[ui]); if (latitudeMaxTop == latitude) { // top triangles drawNCr(norm1, center, radius); drawNCr(norm2, center, radius); drawNCr(Coords.VZ, center, radius); } if (latitudeMaxBottom == latitude) { // bottom triangles drawNCrm(norm1, center, radius); drawNCrm(Coords.VZ, center, radius); drawNCrm(norm2, center, radius); } } } manager.endGeometry(); }