Most Efficient Way To Generate Thumbnail?

This isn’t a Rhino question, but I am trying to create a little shell extension to generate a thumbnail and visualize all the STL’s I’ve created in Rhino. 500k is my average triangle count, so it needs to be light and fast. Before I build this thing, I just want to know if it’s a good idea or a stupid idea.

I plan to do a sudo ray trace of the STL with the mesh rotated -30deg on the x and 30deg on the z to provide a good view.

As I read the STL, for each triangle I check the dot product of the facet normal and my orthogonal view normal and if it’s >=0, I know it’s forward facing and to keep it. I save the dot product (4 bytes - later used for shading) and vertex1 (3 x 4bytes = 12bytes). I figure that since I’m translating 500k triangles into 200 pixels, 1 vertex is as good as 3. That drops the number of subsequent operations and the 500k mesh’s memory footprint from 24MB down to 4MB ((4 + 12) x 250k vs 12 x 4byte points x 500k).

Next I’ll do a matrix transformation on all the vertex points to convert them to my desired orthogonal view. Then search to find the XY bounding box and divide that up based on my resolution into pixel boundaries. For each pixel boundary, I grab the dot product of the normals for the point that is nearest to the camera and use that to assign each pixel’s color.


It sure is an interesting route.
Do think to gain much speed increase?
In any case I’d also try to find what speeds you get by just grabbing a small rendered viewport.
It could be just as fast and maybe even faster than a self-build raytracer.

Let us know how it works out!


I think it’s rasterization rather than ray tracing.

I’ve already tried grabbing a single frame from a directx window, but the initial loading is pretty heavy (2s for a simple 2MB model). It’s a lot of overhead when you just need the first frame.

Plus loading the file into directx was single threaded. I’m thinking I could use one thread to load the file while workers do the calculations in the background. I may be able to render it as fast as I can read it.

I will try it this weekend!