If you remember, I told you I have a unique mouse picking method, I give every object a bounding box generated automatically, or the 3d artist can make his own bounding box, and group it with the object, and if this object is called "boundingbox" my x3d viewer will replace the default bounding box with the one the 3d artist created, this bounding box gives the artist more control over the area that is sensitive to mouse clicking, so my bounding box is made up of 8 points, that don't have to be a cube, they can be of different shapes, I also created an object which is half transparent to show the shape of the bounding box around the object, just for testing. this object is shaped by the 8 points that make up the bounding box of the object, my problem starts when the bounding box of the object is shaped in a very twisted form, how do I know which point is the upper left, and which is the downright and so on, I used to sort the 8 points by their Y position, and assume the 4 upper ones are the top ones and the 4 lower ones are the bottom, but this works only if the shape is more or less cubic, not if it is twisted. so I'm looking for a way to create an object from a cloud of vertices, and I know in 3d max you can map an object and then unwrap it in to a 2d map, so mathematically this is possible.
I ended up using a different method for mouse picking, I render all objects each with a color that is generated from the object index number in the objects array, then I use getPixel to find out the color under the mouse click, but I still want the other method to be optional for the 3d artist, and it will probably will be useful if I'll add a simulation feature, so I still want to find a way to project the 8 point object on 2d and will then use Voronoi
to connect them with triangles.