From: <ha...@us...> - 2007-10-26 22:00:45
|
Revision: 8520 http://jmol.svn.sourceforge.net/jmol/?rev=8520&view=rev Author: hansonr Date: 2007-10-26 15:00:42 -0700 (Fri, 26 Oct 2007) Log Message: ----------- for Rolf -- antialias test Modified Paths: -------------- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/g3d/Graphics3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-10-26 17:58:14 UTC (rev 8519) +++ trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-10-26 22:00:42 UTC (rev 8520) @@ -63,7 +63,7 @@ Normix3D normix3d; boolean isFullSceneAntialiasingEnabled; private boolean antialiasThisFrame; - private boolean antialiasTranslucent; + private boolean antialias2; private boolean antialiasEnabled; /** @@ -200,7 +200,7 @@ public void setWindowParameters(int width, int height, boolean antialias) { windowWidth = width; windowHeight = height; - //System.out.println("Graphics3D setWindowParameters width=" + width + " height=" + height + " antialias=" + antialias); + System.out.println("Graphics3D setWindowParameters width=" + width + " height=" + height + " antialias=" + antialias); antialiasThisFrame = isFullSceneAntialiasingEnabled = antialias; setWidthHeight(antialiasThisFrame); } @@ -212,6 +212,9 @@ width *= 2; height *= 2; } + System.out.println("Graphics3D setWidthHeight width=" + width + " height=" + height + + " isAntialiased=" + isAntialiased + + " window width,height: " + windowWidth + "," + windowHeight); xLast = width - 1; yLast = height - 1; displayMinX = -(width >> 1); @@ -230,17 +233,18 @@ public void beginRendering(//int clipX, int clipY, //int clipWidth, int clipHeight, Matrix3f rotationMatrix, - boolean antialiasThisFrame, - boolean twoPass) { + boolean antialiasThisFrame) { if (currentlyRendering) endRendering(); normix3d.setRotationMatrix(rotationMatrix); antialiasThisFrame &= isFullSceneAntialiasingEnabled; antialiasEnabled = this.antialiasThisFrame = antialiasThisFrame; currentlyRendering = true; - this.twoPass = twoPass; + twoPass = true; //only for testing -- set false to disallow second pass isPass2 = false; - //System.out.println("pass1"); + System.out.println("Graphics3D beginRendering width=" + width + " height=" + height + + " window width,height: " + windowWidth + "," + windowHeight); + System.out.println("pass1 antialiasEnabled=" + antialiasEnabled); colixCurrent = 0; haveAlphaTranslucent = false; addAllPixels = true; @@ -250,7 +254,6 @@ pbuf = platform.pBuffer; zbuf = platform.zBuffer; } - //System.out.println("Graphics3D beginRendering width=" + width + " height=" + height + " antialiasThisFrame=" + antialiasThisFrame); setWidthHeight(antialiasThisFrame); //setRectClip(clipX, clipY, clipWidth, clipHeight); platform.obtainScreenBuffer(); @@ -263,15 +266,14 @@ //System.out.println("pass2"); colixCurrent = 0; addAllPixels = true; - antialiasTranslucent = antialiasTranslucent && antialiasThisFrame; if (antialiasThisFrame && !antialiasTranslucent) downSampleFullSceneAntialiasing(true); - if (pbufT == null || this.antialiasTranslucent != antialiasTranslucent) { + if (pbufT == null || antialias2 != antialiasTranslucent) { platform.allocateTBuffers(antialiasTranslucent); pbufT = platform.pBufferT; zbufT = platform.zBufferT; } - this.antialiasTranslucent = antialiasTranslucent; + antialias2 = antialiasTranslucent; //System.out.println("Graphics3D setPass2 width=" + width + " height=" + height + " antialiasTranslucent=" + antialiasTranslucent); platform.clearTBuffer(); return true; @@ -282,11 +284,11 @@ if (!currentlyRendering) return; if (pbuf != null) { - if (isPass2 && antialiasTranslucent) + if (isPass2 && antialias2) mergeOpaqueAndTranslucentBuffers(); if (antialiasThisFrame) - downSampleFullSceneAntialiasing(isPass2 && !antialiasTranslucent); - if (isPass2 && !antialiasTranslucent) + downSampleFullSceneAntialiasing(isPass2 && !antialias2); + if (isPass2 && !antialias2) mergeOpaqueAndTranslucentBuffers(); } platform.notifyEndOfRendering(); @@ -294,13 +296,15 @@ currentlyRendering = false; } + int anaglyphLength; public void snapshotAnaglyphChannelBytes() { if (currentlyRendering) throw new NullPointerException(); + anaglyphLength = windowWidth * windowHeight; if (anaglyphChannelBytes == null || - anaglyphChannelBytes.length != pbuf.length) - anaglyphChannelBytes = new byte[pbuf.length]; - for (int i = pbuf.length; --i >= 0; ) + anaglyphChannelBytes.length != anaglyphLength) + anaglyphChannelBytes = new byte[anaglyphLength]; + for (int i = anaglyphLength; --i >= 0; ) anaglyphChannelBytes[i] = (byte)pbuf[i]; } @@ -308,7 +312,7 @@ //best if complementary, but they do not have to be0 int color1 = stereoColors[0]; int color2 = stereoColors[1] & 0x00FFFFFF; - for (int i = pbuf.length; --i >= 0;) { + for (int i = anaglyphLength; --i >= 0;) { int a = anaglyphChannelBytes[i] & 0x000000FF; a = (a | ((a | (a << 8)) << 8)) & color2; pbuf[i] = (pbuf[i] & color1) | a; @@ -316,21 +320,21 @@ } public void applyGreenAnaglyph() { - for (int i = pbuf.length; --i >= 0; ) { + for (int i = anaglyphLength; --i >= 0; ) { int green = (anaglyphChannelBytes[i] & 0x000000FF) << 8; pbuf[i] = (pbuf[i] & 0xFFFF0000) | green; } } public void applyBlueAnaglyph() { - for (int i = pbuf.length; --i >= 0; ) { + for (int i = anaglyphLength; --i >= 0; ) { int blue = anaglyphChannelBytes[i] & 0x000000FF; pbuf[i] = (pbuf[i] & 0xFFFF0000) | blue; } } public void applyCyanAnaglyph() { - for (int i = pbuf.length; --i >= 0; ) { + for (int i = anaglyphLength; --i >= 0; ) { int blue = anaglyphChannelBytes[i] & 0x000000FF; int cyan = (blue << 8) | blue; pbuf[i] = pbuf[i] & 0xFFFF0000 | cyan; Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2007-10-26 17:58:14 UTC (rev 8519) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2007-10-26 22:00:42 UTC (rev 8520) @@ -1113,16 +1113,25 @@ this.antialias = antialias; width = (antialias ? screenWidth * 2 : screenWidth); height = (antialias ? screenHeight * 2 : screenHeight); + System.out.println("transformManager setScreenParameters screenWidth,Height, useZoomLarge, antialias, resetSlab, resetZoom " + + useZoomLarge + ","+antialias + "," + resetSlab + "," + resetZoom); + scaleFitToScreen(false, useZoomLarge, resetSlab, resetZoom); } void setAntialias(boolean TF) { + System.out.println("setAntialias antialias=" + antialias + " TF=" + TF + + " width=" + width + " height=" + height + " screenWidth/height" + + screenWidth + "," + screenHeight); + boolean isNew = (antialias != TF); antialias = TF; width = (antialias ? screenWidth * 2 : screenWidth); height = (antialias ? screenHeight * 2 : screenHeight); if (isNew) scaleFitToScreen(false, useZoomLarge, false, false); + System.out.println("setAntialias2 " + TF + "width=" + width + " height=" + height + + " screenWidth/height" + screenWidth + "," + screenHeight); } private float defaultScaleToScreen(float radius) { @@ -1142,13 +1151,20 @@ } void scaleFitToScreen(boolean andCenter) { + System.out.println("transformManager scaleFitToSreen " + andCenter); scaleFitToScreen(andCenter, viewer.getZoomLarge(), true, true); } void scaleFitToScreen(boolean andCenter, boolean zoomLarge, boolean resetSlab, boolean resetZoom) { + System.out.println("transformManager scaleFitToScreen andcenter " + andCenter + + " screenWidth,Height, " + screenWidth + "," + screenHeight + + " zoomLarge, antialias, resetSlab, resetZoom width/height " + + zoomLarge + ","+antialias + "," + resetSlab + "," + resetZoom + + " " + width + "/" + height); if (width == 0 || height == 0) return; + // translate to the middle of the screen fixedTranslation.set(width * (andCenter ? 0.5f : xTranslationFraction), height * (andCenter ? 0.5f : yTranslationFraction), 0); @@ -1275,6 +1291,8 @@ // cale to screen coordinates matrixTemp.setZero(); matrixTemp.set(scalePixelsPerAngstrom); + + System.out.println("calcTransMatrix scalepixelsperangstrom=" + scalePixelsPerAngstrom); if (!axesOrientationRasmol) { // negate y (for screen) and z (for zbuf) matrixTemp.m11 = matrixTemp.m22 = -scalePixelsPerAngstrom; Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-10-26 17:58:14 UTC (rev 8519) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-10-26 22:00:42 UTC (rev 8520) @@ -2907,65 +2907,49 @@ int stereoMode = getStereoMode(); switch (stereoMode) { case JmolConstants.STEREO_DOUBLE: - render1(g, getImage(true, false), dimScreen.width, 0); + render1(g, getImage(true), dimScreen.width, 0); case JmolConstants.STEREO_NONE: - render1(g, getImage(false, global.antialiasDisplay - //&& !getInMotion() - ), 0, 0); + render1(g, getImage(false), 0, 0); break; case JmolConstants.STEREO_REDCYAN: case JmolConstants.STEREO_REDBLUE: case JmolConstants.STEREO_REDGREEN: case JmolConstants.STEREO_CUSTOM: - render1(g, getStereoImage(stereoMode, false), 0, 0); + render1(g, getStereoImage(stereoMode), 0, 0); break; } repaintView(); } - private Image getImage(boolean isDouble, boolean antialias) { - Matrix3f matrixRotate = transformManager.getStereoRotationMatrix(isDouble); - boolean twoPass = !getTestFlag1(); - g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, - matrixRotate, antialias, twoPass); - repaintManager.render(g3d, modelSet); //, rectClip - if (twoPass && g3d.setPass2(global.antialiasTranslucent)) { - if (!global.antialiasTranslucent) - transformManager.setAntialias(false); - repaintManager.render(g3d, modelSet); //, rectClip - if (!global.antialiasTranslucent) - transformManager.setAntialias(antialias); - } - // mth 2003-01-09 Linux Sun JVM 1.4.2_02 - // Sun is throwing a NullPointerExceptions inside graphics routines - // while the window is resized. + private Image getImage(boolean isDouble) { + g3d.beginRendering(transformManager.getStereoRotationMatrix(isDouble), + global.antialiasDisplay); + render(); g3d.endRendering(); return g3d.getScreenImage(); } - private Image getStereoImage(int stereoMode, boolean antialias) { - boolean twoPass = !getTestFlag1(); - g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, - transformManager.getStereoRotationMatrix(true), antialias, twoPass); - repaintManager.render(g3d, modelSet);//, rectClip - if (twoPass && g3d.setPass2(global.antialiasTranslucent)) { - if (antialias && !global.antialiasTranslucent) - transformManager.setAntialias(false); + private void render() { + boolean antialiasON = global.antialiasDisplay; + boolean antialias2 = antialiasON && global.antialiasTranslucent; + transformManager.setAntialias(antialiasON); + repaintManager.render(g3d, modelSet); //, rectClip + if (g3d.setPass2(antialias2)) { + transformManager.setAntialias(antialias2); repaintManager.render(g3d, modelSet); //, rectClip - if (antialias && !global.antialiasTranslucent) - transformManager.setAntialias(true); - } + transformManager.setAntialias(antialiasON); + } + } + + private Image getStereoImage(int stereoMode) { + g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, + transformManager.getStereoRotationMatrix(true), global.antialiasDisplay); + render(); g3d.endRendering(); g3d.snapshotAnaglyphChannelBytes(); g3d.beginRendering(//rectClip.x, rectClip.y, rectClip.width, rectClip.height, - transformManager.getStereoRotationMatrix(false), antialias, twoPass); - if (twoPass && g3d.setPass2(global.antialiasTranslucent)) { - if (antialias && !global.antialiasTranslucent) - transformManager.setAntialias(false); - repaintManager.render(g3d, modelSet); //, rectClip - if (antialias && !global.antialiasTranslucent) - transformManager.setAntialias(true); - } + transformManager.getStereoRotationMatrix(false), global.antialiasDisplay); + render(); g3d.endRendering(); switch (stereoMode) { case JmolConstants.STEREO_REDCYAN: @@ -2995,7 +2979,6 @@ } public Image getScreenImage() { - boolean antialias = true; boolean isStereo = false; //setRectClip(null); int stereoMode = getStereoMode(); @@ -3009,9 +2992,9 @@ case JmolConstants.STEREO_REDBLUE: case JmolConstants.STEREO_REDGREEN: case JmolConstants.STEREO_CUSTOM: - return getStereoImage(stereoMode, false); + return getStereoImage(stereoMode); } - return getImage(isStereo, antialias); + return getImage(isStereo); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |