Hi,

here is a small patch to fix two issues with cartoon meshes

(1) the vertices were not correctly ordered around the cartoon control points 
which did not look nice esp. for low hermiteLevel values.

(2) mesh triangles from opposing sides could cut through each other exposing 
the inside of the cartoon mesh

attached are before-after images for cartoon with hermiteLevel 1


I think this makes the lower hermiteLevel values much more usable and thus 
opens the hermiteLevel >0 display for larger structures and screen resolutions.


Alexander

### Eclipse Workspace Patch 1.0
#P Jmol3
Index: src/org/jmol/renderbio/BioShapeRenderer.java
===================================================================
--- src/org/jmol/renderbio/BioShapeRenderer.java        (revision 17669)
+++ src/org/jmol/renderbio/BioShapeRenderer.java        (working copy)
@@ -585,7 +585,8 @@
       pt1.setT(controlHermites[p]);
       float theta = angle;
       for (int k = 0; k < nPer; k++, theta += angle) {
-        if (!isElliptical || !isEccentric)
+        // rotate the wing vector for k>0
+        if (k>0 && (!isElliptical || !isEccentric))
           mat.transform(wing);
         if (isEccentric) {
           if (isElliptical) {
@@ -608,8 +609,29 @@
       }
       if (p > 0) {
         for (int k = 0; k < nPer; k++) {
-          mesh.addQuad(nPoints - nPer + k, nPoints - nPer + ((k + 1) % nPer),
-              nPoints + ((k + 1) % nPer), nPoints + k);
+          // draw the triangles of opposing quads congruent, so they won't 
clip 
+          // esp. for high ribbonAspectRatio values 
+          if (k < nPer/2){
+            mesh.addQuad(
+                nPoints - nPer + k, 
+                nPoints - nPer + ((k + 1) % nPer),
+                nPoints + ((k + 1) % nPer), 
+                nPoints + k
+            );
+          }else{
+            // couldn't find out how to flip the diagonal in a quad without 
flipping
+            // its normal direction too - so I used triangles instead
+            mesh.addTriangle(
+                nPoints - nPer + k, 
+                nPoints - nPer + ((k + 1) % nPer),
+                nPoints + k
+            );
+            mesh.addTriangle( 
+                nPoints - nPer + ((k + 1) % nPer),
+                nPoints + ((k + 1) % nPer),
+                nPoints + k
+            );
+          }
         }
       }
       nPoints += nPer;

<<inline: 1CRN.jpeg>>

<<inline: 1CRN_fix.jpeg>>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to