general smoothness

  • Email
  • Sharebar
  • Email
aplesch's picture

Getting gears to appear smooth by explicitly assigning indices to the generated facets got me thinking in more detail of how to accomplish this result in general, for any facets drawn in face mode by turtle graphics.

This is the result of applying a general method for reusing the same index for all point coordinates which are shared by multiple facets. The process works by going through all point coordinates, and checking for each if it was encounterd earlier. If not, the point is recorded in a property list (a sort of associative array, or key-value store) along with its index which will be the first one used for this point. If the point on the other hand was already recorded earlier, its index is recorded along with the index of already recorded point in a separate property list (or regular list).

Then the method simply goes through all indices and uses the second propery list to look up the index of the first recorded point.

There is a minor modification to the wordstolist procedure to deal with commas as separators, and another procedure to group coordinate triplets as lists within a list.

UPDATE: point coordinates

The process sofar only deals with the indices and as a result leaves all of the duplicated point coordinates unreferenced and therefore useless. In a second step these useless coordinates can be removed. However, removing entries in the point coordinate list will then require changes to the existing indices.

After thinking about this, a solution was to not go through a removal process but to recognize that we already have extracted the required list of unique point coordinates and the mapping from the existing indices to the new indices in the previous steps. The new coordinate list and the mapping just needed to be recorded in a list and additional property list. This just required a couple more lines of logo.

After that, it is simply a matter of replacing the existing point coordinates with the new list of unique point coordinets, and again going through the list of existing indices to look up the new index via the recorded map.

For the small helical gear above removing the unneeded points reduced the file size from 49kb to 26kb. Great !

For this detailed gear mesh file size reduces from 942 kb to 414 kb :

https://vrmath2.net/embed/?url=/sites/default/files/user/u342/x3d/helica...

 

Here are the updated and main procedures:

Here is a smooth band generated using the optfacet procedure:

Here is the logo for the band generation:

Remember to save and reload the world to see the smoothed facets.

 

 

 

Comments

Andy's picture

Smooth band looks good

Thanks for explaining the ideas behind the codes. :-) I must implement this in my VRM2 (using javascript) to take advantage of the creaseAngle.

The comma separator is a direct result of dumping DOM or the use of toString(), not sure whether that is native in javascript or x3dom overwrites the toString. X3D validator does complains a lot, typical xml requirement. 

Is the smooth bank a result of some random turtle movements? It reminds me some 3D molecule visualisations by Leonard Daly at http://realism.com/models. 

 

aplesch's picture

Random

Yes, the smooth band is a result of turning right randomly between -20 and 40 degrees. I will add the short logo. It was a test to check if the procedure works on other face sets.

The comma is allowed between the coordinate triplets and was straightforward to check for.

It would be nice to have the crease angle option in logo.

 

Facebook Comments Box