void render( short colixA, short colixB, byte endcaps, int diameter, int xA, int yA, int zA, int xB, int yB, int zB) { if (diameter > (g3d.width + g3d.height) * MAX_FIX) return; // XIE: begin: deal with long sticks to prevent huge raster arrays from being produced dxB = xB - xA; dyB = yB - yA; if (dxB * dxB + dyB * dyB > 4.0 * g3d.width * g3d.width) return; // XIE: end dzB = zB - zA; int r = diameter / 2 + 1; int codeMinA = line3d.clipCode(xA - r, yA - r, zA - r); int codeMaxA = line3d.clipCode(xA + r, yA + r, zA + r); int codeMinB = line3d.clipCode(xB - r, yB - r, zB - r); int codeMaxB = line3d.clipCode(xB + r, yB + r, zB + r); // all bits 0 --> no clipping notClipped = ((codeMinA | codeMaxA | codeMinB | codeMaxB) == 0); // any two bits same in all cases --> fully clipped if ((codeMinA & codeMaxB & codeMaxA & codeMinB) != 0) return; // fully clipped; zShift = g3d.getZShift((zA + zB) >> 1); if (diameter <= 1) { line3d.plotLineDelta( g3d.getColixArgb(colixA), Graphics3D.isColixTranslucent(colixA), g3d.getColixArgb(colixB), Graphics3D.isColixTranslucent(colixB), xA, yA, zA, dxB, dyB, dzB, notClipped); return; } drawBackside = (!notClipped || endcaps == Graphics3D.ENDCAPS_FLAT); this.diameter = diameter; this.xA = xA; this.yA = yA; this.zA = zA; this.endcaps = endcaps; shadesA = g3d.getShades(this.colixA = colixA); shadesB = g3d.getShades(this.colixB = colixB); isScreenedA = (colixA & Graphics3D.TRANSLUCENT_MASK) != 0; isScreenedB = (colixB & Graphics3D.TRANSLUCENT_MASK) != 0; calcArgbEndcap(true); generateBaseEllipse(); if (endcaps == Graphics3D.ENDCAPS_FLAT) renderFlatEndcap(true); for (int i = rasterCount; --i >= 0; ) plotRaster(i); if (endcaps == Graphics3D.ENDCAPS_SPHERICAL) renderSphericalEndcaps(); }
void renderBits( short colixA, short colixB, byte endcaps, int diameter, float xA, float yA, float zA, float xB, float yB, float zB) { if (diameter > (g3d.width + g3d.height) * MAX_FIX) // XIE return; // oops -- problem here if diameter < 0 is that we may have already clipped it! int r = diameter / 2 + 1; int codeMinA = line3d.clipCode((int) xA - r, (int) yA - r, (int) zA - r); int codeMaxA = line3d.clipCode((int) xA + r, (int) yA + r, (int) zA + r); int codeMinB = line3d.clipCode((int) xB - r, (int) yB - r, (int) zB - r); int codeMaxB = line3d.clipCode((int) xB + r, (int) yB + r, (int) zB + r); // all bits 0 --> no clipping notClipped = ((codeMinA | codeMaxA | codeMinB | codeMaxB) == 0); // any two bits same in all cases --> fully clipped if ((codeMinA & codeMaxB & codeMaxA & codeMinB) != 0) return; // fully clipped; dxBf = xB - xA; dyBf = yB - yA; dzBf = zB - zA; if (diameter == 0 || diameter == 1) { line3d.plotLineDelta( g3d.getColixArgb(colixA), Graphics3D.isColixTranslucent(colixA), g3d.getColixArgb(colixB), Graphics3D.isColixTranslucent(colixB), (int) xA, (int) yA, (int) zA, dxB, dyB, dzB, notClipped); return; } if (diameter > 0) { this.diameter = diameter; this.xAf = xA; this.yAf = yA; this.zAf = zA; } drawBackside = (!notClipped || endcaps == Graphics3D.ENDCAPS_FLAT); this.xA = (int) xAf; this.yA = (int) yAf; this.zA = (int) zAf; this.dxB = (int) dxBf; this.dyB = (int) dyBf; this.dzB = (int) dzBf; this.shadesA = g3d.getShades(this.colixA = colixA); this.shadesB = g3d.getShades(this.colixB = colixB); this.isScreenedA = (colixA & Graphics3D.TRANSLUCENT_MASK) != 0; this.isScreenedB = (colixB & Graphics3D.TRANSLUCENT_MASK) != 0; this.endcaps = endcaps; calcArgbEndcap(true); if (diameter > 0) generateBaseEllipsePrecisely(); if (endcaps == Graphics3D.ENDCAPS_FLAT) renderFlatEndcap(true); line3d.setLineBits(this.dxBf, this.dyBf); for (int i = rasterCount; --i >= 0; ) plotRasterBits(i); if (endcaps == Graphics3D.ENDCAPS_SPHERICAL) renderSphericalEndcaps(); this.xAf += dxBf; this.yAf += dyBf; this.zAf += dzBf; }