Hi Bob,

whoa, that great. I think this deserves an option (set cartoonsElliptical true/false) and not be limited to such high hermiteLevels. I would need some time to figure out how to add such an option, though I would tackle it. Let me now.

Attached is a patch that enable the seam adjusting for nucleic cartoons. Also I think renderMesh is unnecessarily called twice.

The seam adjusting does not work when exporting to e.g. .obj or .pov, but I did not figure out why :-(


Alexander

### Eclipse Workspace Patch 1.0
#P Jmol3
Index: src/org/jmol/renderbio/BioShapeRenderer.java
===================================================================
--- src/org/jmol/renderbio/BioShapeRenderer.java        (revision 17642)
+++ src/org/jmol/renderbio/BioShapeRenderer.java        (working copy)
@@ -62,7 +62,7 @@
 
   private Mesh[] meshes;
   private boolean[] meshReady;
-  private BitSet bsRenderMesh;
+  protected BitSet bsRenderMesh;
 
 
   protected int monomerCount;
@@ -106,7 +106,7 @@
     val = (val <= 0 ? -val : viewer.getInMotion() ? 0 : val);
     if (val != hermiteLevel && val != 0)
       invalidateMesh = true;
-    hermiteLevel = Math.min(val, 8);
+    hermiteLevel = Math.min(val, 12); // increased max value - probably only 
reasonable for export. AR
     if (hermiteLevel == 0)
       aspectRatio = 0;
 
@@ -131,7 +131,7 @@
       if (bioShape.monomerCount >= 2 && initializePolymer(bioShape)) {
         bsRenderMesh.clearAll();    
         renderBioShape(bioShape);
-        renderMeshes();
+        //renderMeshes(); // that's not necessary, or is it? AR
         freeTempArrays();
       }
     }
@@ -627,8 +627,9 @@
   void adjustCartoonSeamNormals(int i, int nPer) {
     if (bsTemp == null)
       bsTemp = Normix.newVertexBitSet();
+    // non nucleic, rendering direction from monomerCount-1 to 0
     if (i == iNext - 1 && iNext < monomerCount
-        && monomers[i].getStrucNo() == monomers[iNext].getStrucNo()
+        && monomers[i].getStrucNo() == monomers[iNext].getStrucNo() 
         && meshReady[i] && meshReady[iNext]) {
       try {
         Vector3f[] normals2 = meshes[iNext].getNormalsTemp();
@@ -642,10 +643,26 @@
         }
       } catch (Exception e) {
       }
+    // nucleic, reversed rendering direction
+    }else if(i == iPrev + 1 && iPrev < monomerCount
+        && monomers[i].isNucleic() && monomers[iPrev].isNucleic() 
+        && meshReady[i] && meshReady[iPrev]) {
+      try {
+        Vector3f[] normals2 = meshes[iPrev].getNormalsTemp();
+        Vector3f[] normals = meshes[i].getNormalsTemp();
+        int normixCount = normals.length;
+        for (int j = 1; j <= nPer; ++j) {
+          norml.add2(normals[nPer - j], normals2[normixCount - j]);
+          norml.normalize();
+          meshes[i].normalsTemp[nPer - j].setT(norml);
+          meshes[iPrev].normalsTemp[normixCount - j].setT(norml);
+        }
+      } catch (Exception e) {
+      }
     }
   }
 
-  private void renderMeshes() {
+  protected void renderMeshes() {
     for (int i = bsRenderMesh.nextSetBit(0); i >= 0; i = bsRenderMesh
         .nextSetBit(i + 1)) {
       if (meshes[i].normalsTemp != null) {
Index: src/org/jmol/renderbio/CartoonRenderer.java
===================================================================
--- src/org/jmol/renderbio/CartoonRenderer.java (revision 17637)
+++ src/org/jmol/renderbio/CartoonRenderer.java (working copy)
@@ -85,6 +85,7 @@
       colixHoogsteenEdge = Colix.getColixTranslucent(Colix.BLUE, 
isTranslucent, tl);
     }
     boolean isTraceAlpha = viewer.getTraceAlpha();
+    bsRenderMesh.clearAll();
     for (int i = bsVisible.nextSetBit(0); i >= 0; i = bsVisible
         .nextSetBit(i + 1)) {
       if (isTraceAlpha) {
@@ -100,6 +101,7 @@
       if (g3d.setColix(colix))
         renderNucleicBaseStep((NucleicMonomer) monomers[i], mads[i], 
ptConnect);
     }
+    renderMeshes();
   }
 
   @Override

Am 08.10.2012 um 14:19 schrieb Robert Hanson:

Alexander,

check out the new feature!

set hermitelevel 6
set ribbonAspectRatio 4

Hermite level >= 6 or <= -6 changes the helix and sheet cartoons to have an elliptical cross-section, like various other programs in use.

Bob


On Sat, Oct 6, 2012 at 4:44 PM, Alexander Rose <alexander.r...@weirdbyte.de> wrote:
Hi,

I created an initial patch that aims to fix the seams between cartoon mesh elements of consecutive residues. Attached are two images to illustrate the seams. The seams occur because the (lighting) vertex normals are calculated for each cartoon mesh elements individually without considering the adjacent elements. The patch includes a helper function that smoothes the vertex normals for the overlapping vertices two consecutive cartoon meshes. I also needed to slightly change the way by which the mesh of turn/loop elements is created so that the start/end vertices of two turn/loop elements always overlap.


The patch is against revision 17624.

There are problems. I adjust the normals between two consecutive elements when constructing the second element's mesh, so the first element's mesh has been already created (needed to adjust the normals) and also once rendered/drawn. Therefor to see the adjusted normals the meshes need to be rendered/drawn again. Just interacting with Jmol, e.g. zooming, naturally triggers a redraw. However its not nice initially. An idea. I could trigger a redraw in Jmol after cartoon mesh constructions. How? Or do you have other suggestions?

Also I need to carefully check if the code works also when individual residues are (randomly) displayed/hidden one after the other.

Please let me know what you think!

Best
Alexander






------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers




--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Chemistry Department
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to