Quote:Original post by adder_noir
Ok thanks I read that, very humourous in places!!!! Hahahah you obviously have alot of experience in the field ;oD
I'm still having hell getting blender to export this stuff. It will show smooth in the program but the script is powerless to do anything with it. Even the internal console in blender doesn't shift it. It only responds to the setsmooth command in the environment menu, never directly from python and it also doesn;t export what it shows in the environment window!!
Thanks! If you can post a screenshot of the good and bad cases, I'm sure someone can see about the issue in more detail.
Quote:Original post by adder_noir
Just one last question before I start using your code to get stuff happening here (good template btw thanks a bundle). How do I acquire the adjacency data?
I'm au fait on the other stuff I've written my own ccross product functions before and stuff. Only the adjacency stuf bugs me. So far my export writes an indexed list (with duplicated indices many times over), vertex list and some crappy normals that make the model blocky and look like calculus going the wrong way.
Can I acquire everything I need from this? Sounds really good this is what I'll be working on now, even if just for the hell of it! Thanks so much ;o)
You're very welcome. Adjacency data comes in several flavors (people give different namings for it, but the conventions never seem to be the same), and it serves to be able to answer the following commonly asked questions:
- Given a triangle, what are its neighboring triangles? (are there T-junctions for this triangle?)
- Given a position of a vertex, which triangles have a corner at this vertex position?
- Given a position of a vertex, which vertex positions are reachable from this vertex just by traversing a single edge in the mesh?
- Given an edge (a pair of vertices), which triangles share their edges with this edge?
- Given a vertex (by its index in the vertex buffer or by position), which other vertices (by their indices in the vertex buffer) lie at the same position?
- etc, whatever you can think of.
You can think of this data to be a lookup table to accelerate these kinds of queries, since technically you wouldn't need to calculate this data and you could just compute the information on-the-fly by looping through the geometry, but generating this lookup table improves your performance by a factor (or two, in some cases) of n (# tris or vertices), i.e. it's the sane thing to do.
Now in your case, you're doing queries of the form #2 and possibly #5. The first foreach loop in the pseudo-code in my above post shows how to compute #2. If you want to re-do smooth/hard edge division, you'll need to recreate the per-vertex data and re-index the mesh, for which you'll need #5. This is often done by just converting the indiced geometry to an unindiced triangle list, then doing the computations, and then converting back to indiced geometry.
So, in effect, there's not really any magic to generating adjacency data, you just loop through the primitives you're interested in (triangles, vertices) and store into a lookup table the interesting information you want for each of those primitives. Then when processing, you have that data in a neat table to help the actual work.