From: <ha...@us...> - 2007-04-08 04:16:37
|
Revision: 7353 http://svn.sourceforge.net/jmol/?rev=7353&view=rev Author: hansonr Date: 2007-04-07 21:16:36 -0700 (Sat, 07 Apr 2007) Log Message: ----------- 11.1.28 lighting Modified Paths: -------------- trunk/Jmol/src/org/jmol/g3d/Graphics3D.java trunk/Jmol/src/org/jmol/g3d/Shade3D.java trunk/Jmol/src/org/jmol/viewer/ColorManager.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-04-08 03:50:55 UTC (rev 7352) +++ trunk/Jmol/src/org/jmol/g3d/Graphics3D.java 2007-04-08 04:16:36 UTC (rev 7353) @@ -1897,9 +1897,21 @@ static float ambientFraction = 0.45f; */ - - final float[] lighting = new float[] {1f, 0.22f, 6f, 0.4f, 0.84f, 0.45f}; + final float[] lighting = new float[] { + //user set: + 1f, // specularON + 22f, // specularPercent + 6f, // specularExponent + 40f, // specularPower + 84f, // diffusePercent + 45f, // ambientPercent + //derived: + 0.22f, // intensitySpecular + 0.4f, // intense fraction + 0.84f, // intensity diffuse + 0.45f, // ambient fraction + }; public void setSpecular(boolean specular) { lighting[Shade3D.SPECULAR_ON] = (specular ? 1f : 0f); @@ -1909,38 +1921,51 @@ return (lighting[Shade3D.SPECULAR_ON] != 0); } + public void setSpecularPower(int specularPower) { - if (specularPower >= 0) - lighting[Shade3D.INTENSE_FRACTION] = specularPower / 100f; - else - lighting[Shade3D.SPECULAR_EXPONENT] = -specularPower; + lighting[Shade3D.SPECULAR_POWER] = specularPower; + lighting[Shade3D.INTENSE_FRACTION] = specularPower / 100f; } - public void setAmbientPercent(int ambientPercent) { - lighting[Shade3D.AMBIENT_FRACTION] = ambientPercent / 100f; + public float getSpecularPower() { + return lighting[Shade3D.SPECULAR_POWER]; } + + public void setSpecularPercent(int specularPercent) { + lighting[Shade3D.SPECULAR_PERCENT]= specularPercent; + lighting[Shade3D.INTENSITY_SPECULAR] = specularPercent / 100f; + } - public int getAmbientPercent() { - return (int) (lighting[Shade3D.AMBIENT_FRACTION] * 100); + public int getSpecularPercent() { + return (int) lighting[Shade3D.SPECULAR_PERCENT]; } + + public float getSpecularExponent() { + return lighting[Shade3D.SPECULAR_EXPONENT]; + } + public void setSpecularExponent(int specularExponent) { + lighting[Shade3D.SPECULAR_EXPONENT] = specularExponent; + } + public void setDiffusePercent(int diffusePercent) { + lighting[Shade3D.DIFFUSE_PERCENT]= diffusePercent; lighting[Shade3D.INTENSITY_DIFFUSE]= diffusePercent / 100f; } public int getDiffusePercent() { - return (int) (lighting[Shade3D.INTENSITY_DIFFUSE] * 100); + return (int) lighting[Shade3D.DIFFUSE_PERCENT]; } - - public void setSpecularPercent(int specularPercent) { - lighting[Shade3D.INTENSITY_SPECULAR] = specularPercent / 100f; + public void setAmbientPercent(int ambientPercent) { + lighting[Shade3D.AMBIENT_PERCENT] = ambientPercent; + lighting[Shade3D.AMBIENT_FRACTION] = ambientPercent / 100f; } - public int getSpecularPercent() { - return (int) (lighting[Shade3D.INTENSITY_SPECULAR] * 100); + public int getAmbientPercent() { + return (int) (lighting[Shade3D.AMBIENT_PERCENT]); } - + /* static void dump() { Logger.debug("\n ambientPercent=" + ambientFraction + Modified: trunk/Jmol/src/org/jmol/g3d/Shade3D.java =================================================================== --- trunk/Jmol/src/org/jmol/g3d/Shade3D.java 2007-04-08 03:50:55 UTC (rev 7352) +++ trunk/Jmol/src/org/jmol/g3d/Shade3D.java 2007-04-08 04:16:36 UTC (rev 7353) @@ -67,11 +67,15 @@ // and saved in g3d.lighting static int SPECULAR_ON = 0; // set specular on|off - static int INTENSITY_SPECULAR = 1; + static int SPECULAR_PERCENT = 1; static int SPECULAR_EXPONENT = 2; - static int INTENSE_FRACTION = 3; - static int INTENSITY_DIFFUSE = 4; - static int AMBIENT_FRACTION = 5; + static int SPECULAR_POWER = 3; + static int DIFFUSE_PERCENT = 4; + static int AMBIENT_PERCENT = 5; + static int INTENSITY_SPECULAR = 6; + static int INTENSE_FRACTION = 7; + static int INTENSITY_DIFFUSE = 8; + static int AMBIENT_FRACTION = 9; static int[] getShades(int rgb, boolean greyScale, float[] lighting) { int[] shades = new int[shadeMax]; Modified: trunk/Jmol/src/org/jmol/viewer/ColorManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2007-04-08 03:50:55 UTC (rev 7352) +++ trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2007-04-08 04:16:36 UTC (rev 7353) @@ -381,14 +381,18 @@ return g3d.getColix(JmolConstants.argbsHbondType[argbIndex]); } + /* void flushCachedColors() { } - + */ + private void flushCaches() { g3d.flushShadesAndImageCaches(); } void setSpecular(boolean specular) { + if (g3d.getSpecular() == specular) + return; g3d.setSpecular(specular); flushCaches(); } @@ -397,23 +401,45 @@ return g3d.getSpecular(); } - void setSpecularPower(int specularPower) { - g3d.setSpecularPower(specularPower); + void setSpecularPercent(int specularPercent) { + if (g3d.getSpecularPercent() == specularPercent) + return; + g3d.setSpecularPercent(specularPercent); flushCaches(); } - void setAmbientPercent(int ambientPercent) { - g3d.setAmbientPercent(ambientPercent); + int getSpecularPercent() { + return g3d.getSpecularPercent(); + } + + void setSpecularPower(int specularPower) { + if (specularPower < 0) { + if (g3d.getSpecularExponent() == -specularPower) + return; + g3d.setSpecularExponent(-specularPower); + } else { + if (g3d.getSpecularPower() == specularPower) + return; + g3d.setSpecularPower(specularPower); + } flushCaches(); } - + void setDiffusePercent(int diffusePercent) { + if (g3d.getDiffusePercent() == diffusePercent) + return; g3d.setDiffusePercent(diffusePercent); flushCaches(); } - void setSpecularPercent(int specularPercent) { - g3d.setSpecularPercent(specularPercent); + int getDiffusePercent() { + return g3d.getDiffusePercent(); + } + + void setAmbientPercent(int ambientPercent) { + if (g3d.getAmbientPercent() == ambientPercent) + return; + g3d.setAmbientPercent(ambientPercent); flushCaches(); } @@ -421,14 +447,6 @@ return g3d.getAmbientPercent(); } - int getSpecularPercent() { - return g3d.getSpecularPercent(); - } - - int getDiffusePercent() { - return g3d.getDiffusePercent(); - } - /* void setLightsourceZ(float dist) { g3d.setLightsourceZ(dist); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-04-08 03:50:55 UTC (rev 7352) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-04-08 04:16:36 UTC (rev 7353) @@ -298,13 +298,16 @@ script("reset"); } + + /* final Hashtable imageCache = new Hashtable(); void flushCachedImages() { imageCache.clear(); colorManager.flushCachedColors(); } - + */ + Hashtable getAppletInfo() { Hashtable info = new Hashtable(); info.put("htmlName", htmlName); @@ -959,7 +962,7 @@ int argb = getObjectArgb(objId); if (argb == 0) return getColixBackgroundContrast(); - return g3d.getColix(argb); + return g3d.getColix(argb); } String getObjectState(String name) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |