Problem solved. Thanks, again, Miguel. It was, in fact, the vertex normal problem; it is solved now. As for you not seeing the normals, Miguel, your browser probably cached the JAR files. If you still don't see the white lines, take a look at

http://www.stolaf.edu/people/hansonr/jmol/test/proto/jvxl-compare-normal.jpg

White lines are vertex normals; dots are grid points. Triangles are shrunk by 10% so as to distinguish them. I found this very helpful in understanding how that triangulation works. (I can see how it was worth a patent! Someone can be very proud of that little trick!)

What I've done is just a little additional summing of the vertex normals. Rather than just for each associated triangle, I add in any triangles associated with the generating grid point whenever the intersecting surface point is within 30% of the distance to a grid point.

The final code replaces Mesh.initialize() with:

  void initializeMesh() {
    int vertexCount = currentMesh.vertexCount;
    Vector3f[] vectorSums = new Vector3f[vertexCount];

    for (int i = vertexCount; --i >= 0;) {
      vectorSums[i] = (assocGridPointMap.containsKey("" + i) ?
(Vector3f) assocGridPointNormals.get((String) assocGridPointMap.get("" + i))
          : new Vector3f());
    }
    currentMesh.sumVertexNormals(vectorSums);
    currentMesh.normixes = new short[vertexCount];
      for (int i = vertexCount; --i >= 0;)
        currentMesh.normixes[i] = g3d.getNormix(vectorSums[i]);
  }


  Hashtable assocGridPointMap;
  Hashtable assocGridPointNormals;
  int addVertexCopy(Point3f vertex, boolean iHaveAssociation, String sKey) {
    int vPt = currentMesh.addVertexCopy(vertex);
    if (vPt == 0) {
      assocGridPointMap = new Hashtable();
      assocGridPointNormals = new Hashtable();
    }
    if (iHaveAssociation) {
      assocGridPointMap.put("" + vPt, sKey);
      if (!assocGridPointNormals.containsKey(sKey))
        assocGridPointNormals.put(sKey, new Vector3f(0, 0, 0));
    }
    return vPt;
  }


In this JPG you can see how this aligns the normals, thus guaranteeing the same specular reflection for all nearby triangle points. Mind you, these images were taken at specular 80, specpower 80, so that's rather ridiculous. When you back off to the default specular 22, specpower 45 it's much more subtle.

In the end, I'm not convinced it's really worth the trouble, but since it's almost no additional computational effort, I think I'll leave it in this way. It was certainly an interesting challenge, and we can have fun with the depictions, anyway.

OK, I have to stop fooling around!

Bob


Miguel wrote:


Your idea of smoothing the normals is a good one. These normals get
calculated only once. You could spend as much time as you want running
some kind of smoothing/averaging filter over the normals and it would be
fine.

I'm satisfied that the solution I arrived at is fine.


The computer graphics people spend a lot of time on this problem. The
problem of 'optimally' tessellating a surface is an area of active
research. Everybody wants to have the triangles be about the same size and
within some acceptable range of not too-acute nor too-obtuse. It has
significant academic and commercial value.

You know that I spent a great deal of time trying to come up with a
'better' algorithm for the solvent-accessible-surface. Much of my
motiviation was to eliminate these sliver triangles. It just really bugged
me that most of the triangles in the SAS were for generating the convex
'spheres' of atoms sticking out on the surface. I thought that I should be
able to generate these portions of spheres as truly spherical ... or that
I could tesselate them perfectly (as with the 'dots' representation) and
have prettier triangles ... but no luck so far.


Miguel



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

--
--

Robert M. Hanson, [EMAIL PROTECTED], 507-646-3107
Professor of Chemistry, St. Olaf College
1520 St. Olaf Ave., Northfield, MN 55057
mailto:[EMAIL PROTECTED]
http://www.stolaf.edu/people/hansonr

"Imagination is more important than knowledge." - Albert Einstein



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to