From: Jonathan B. <blo...@go...> - 2001-07-23 21:32:39
|
In GollyGee Blocks, most of the objects do not have texture coordinates previously assigned, and we've got a technique which works reasonably well and you might find useful for vpython. Starting with a list of vertices and faces (stored by vertex index) we end up with a uv coordinate for each vertex index on a face. In psuedocode: For each face Find the major axis of the face (the x, y, or z axis with the greatest normal component) For each vertex in the face Drop the coordinate of the major axis from the vertex The texture coordinates are the remaining two coordinates normalized using the bounding box of the object For the simple case of a cube, it puts the whole texture on the whole face of a cube. It's not the most perfect scheme, but it was easy to code and is fairly effective. It's also best for flat rather than smooth shaded objects. JB Jonathan Blocksom GollyGee Software, Inc. -- http://www.gollygee.com 703-437-8342 |