I am in the process of creating some software in Java for generating 3D gear geometry and saving it as an STL file. I am looking at a means of drawing the geometry so that the user can view the geometry before saving as an STL file. The intended result should appear along the lines of the following:
So far, rendering using ray casting appears to be the best way to approach this. For each pixel, a ray is extended out from the camera in the appropriate direction and its intersection with the triangles that make up the geometry is tested, keeping the closest intersection: simple in concept, doesn't mess around with unnecessary effects, and seems like it should run fast.
My main concern is: will it render fast enough? In my program, it should be possible to rotate and pan the visualisation, and have it render on the fly. My concern stems from this: the largest screen I want to draw the visualisation on will be 1280px by 800px (although in general use it may be somewhat less than this), which means up to 1024,000 pixels need to be processed, and so an equal number of rays will be projected. In each 3D geometric part, there could easily be upward of thousands of triangular facets. That already means have to perform at least $10^9$ operations, a number similar to the order of magnitude of operations per second. Surely it appears ray-casting won't run fast enough, especially if you want to refresh the visualisation at a rate of 10Hz.
What is done to ensure that the rendering is done quickly enough? Is it a matter of using a single ray for every 2x2, 3x3 or larger sub-array of pixels? Is an alternative algorithm to ray casting used? There certainly appears to be a solution to this, as STL visualisation software is not a new thing, with the app MeshLab and the site viewstl.com being perfectly adequate.