Re: [Plib-users] CAM using plib was: Wanted--bitmap
Brought to you by:
sjbaker
From: Marlin M. <mar...@ho...> - 2001-04-24 02:54:19
|
>From: Steve Baker <sjb...@ai...> >I would: > >* Read the model into PPE. >* Delete the wings and tail fins. (Select primitives and Edit/Cut) >* Write the fuselage data out in ".TRI" format. >* Read the data into a C++ program from a 'TRI' format file (it's > *REALLY* easy to write a parser for that format). >* Rotate the model whatever number of degrees is needed using routines > from libplibsg >* Compute the surface normal for each triangle (there is a PLIB/SG routine > for that) - and discard those that are facing away from us. >* Treat each triangle as three edges (each with two vertices). >* Make a table of the UNIQUE vertices in the model...discard duplicate > vertices. >* Make a table of edges in the model - according to which vertices > they share. >* For each edge, check to see if there is a duplicate edge somewhere > on another triangle. Delete all edges that have duplicates - along > with those duplicates. >* Since the only edges remaining came from triangles whose neighbours > were back-face culled, we have a pretty good profile. > > >So, if this works, you owe me a 2 foot tall foam model of Tux - OK? :-) You got it! A few additions to the algorithm. It appears that the MSFS models are often non-contiguous meshes--a forward section of the fuselage placed next to a rear section. So I think the following changes are in order: * You have to build a linked list structure of 3-d verticies in order to detect non-contiguousity. (Hey! A brand new word!) * Plot a final graph. Each 2-D vertex needs an attribute telling it which 3-d network it came from. * On the final 2-D graph, check each remaining edge too see if it intersects with any other edge. If so fix the graph so there's a vertex there. * For each vertex, do a point in polygon to see if that point lies in any OTHER polygon and if so delete it. Nope, Nevermind. This doesn't work, illustrated by the fact that you could have a rectangle determined by four points and another separate graph's rectangle determined by four other verticies and if they were to form a cross, you would get four new intersection verticies, but you couldn't get rid of the new edges that link these new verticies. Well, you could if you bisected any edge touching a new vertex to see if that point was inside any polygon (not just on the edge) and if so, delete the whole edge. No doubt about it, it's starting to get complicated, but I can't see any other way, unless we resort to some sort of hybrid raster operation: * Transform your wire mesh as needed * Plot the ENTIRE mesh in a 2-D map in black on a white background. (retain the vector 2-d mesh in memory for subsequent operations) * Pick a pixel that's outside the bounding rectangle * Flood fill at that point in red. * Examine each node in the vector graph and relocate it's pixel position. * Check it's eight pixel neighbors to see if any are red. If so, it's a keeper. If I only see black and white neighbors, I drop it. The problem with this method is two verticies--one that you care about-- could coexist in the same pixel and keeping both of them screws up your profile. You could probably solve it by replotting the map at a finer resolution if you detect coexistance. Another problem is sharp interior angles not permitting a red pixel to get near a true bounding vertex. But I can live with that since that situation typically won't occur on a fuselage and certainly not on Tux :-) I kind of like the hybrid idea. Any opinions? Any pitfalls? Thanks, Marlin _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com |