Pretty texture coord calculation

I use a 3d modeler tool to build my 3d models, and then dump their info to a custom file format. The tool’s capabilities are satisfying, except when it comes to texturing. All it can do is stretch it and distort it all over. At best, I can supply a U/V offset and scaling factor.

So, here’s what I’m looking for:
A few algorithms to calculate appropriate texture coordinates. Here are a few examples to demonstrate the goals I’d like to achieve.

For instance, I have a right-angled triangle. I’d expect the texture I map onto it to be cut in half, and eventually scaled to stay square. That isn’t complicated, as I simply have to find the plane the triangle lies on, calculate its proportion in comparison to a perfect square, and I’m set.
That’s one algorithm.

Things get more complicated when it comes to more complex shapes. For a box, I just plan on splitting it into 6 separate faces, and apply algorithm 1 on each.

but what about a sphere, for instance? if I cut it in two, and apply Algo 1., the texture fragments on the tip of the two half-spheres will look correct, while those lying close to the edge of the cut will look rather stretched. If I consider it as a whole, the texture will be repeated on one half of it.

Are there some documents out there that describe some algorithms to attemp such feats? If there are more than one that could apply, and only the modeler’s tastes might tell which is better, I can just code them all and select the one I want on a per-case basis.

Thanks for your time.

Hi Setzer,

UV mapping can be a real rascal. Here’s an article you might find interesting:
http://www.gamasutra.com/gdc2004/features/20040325/banninga_01.shtml

If you really want to do this yourself, check out the mesh parameterization techniques of Hughes Hoppe. His papers will have references to some simpler techniques.