texture mapping a cube
A while back I made a cube using DrawTriangles, based on what others have done, which was just using vector graphics. I tried to map a bitmap onto it and had poor results – some of the sides were fine, but others were stretched. I soon realized it was because my texture points were being referenced by the (of which I only had 8), and so different sides were sharing texture co-ordinates. When I looked UV Mapping up on wikipedia, it said that texture co-ordinates should be mapped to triangle (the indices in flash terminology) not to the vertices of the mesh itself (which is how it works in Flash Player 10). I’m not sure why the api was done this way – perhaps it is more efficient, since it uses less uvt coordinates – but it is limiting when you need to map a bitmap onto a surface of a solid shape, as the bitmap will be horribly distorted on some of the faces. Unless I’m missing something.
So I had the idea that I could simply add more to support texture-mapping a cube. I took the approach of unfolding the texture map and then defining the faces as objects with a and uvts array each. Then I looped through them to add the vertices, indices, and uvts. If you don’t have a clue what I’m talking about, don’t worry, here’s the end result :
flash 10 required
I know the controls aren’t very usable.. sorry. I’m going to set up some click-n-drag-to-rotate goodness very soon
Here’s the texture map I used:

Artwork is by Albertus Seba , from his marvellous Cabinet of Curiosities.
Here’s how I unwrapped the cube (it’s in the source, but it looks a bit wonky in svn)…
//corners of cube - 8
/* vertices: ABCD = front , EFGH = back
E --- F
| / |
| / |
E --- A --- B --- F --- E
| / | / | / | / |
| / | / | / | / |
H --- D --- C --- G --- H
| / |
| / |
H --- G
*/