PDA

View Full Version : Group of vertices - Collision detection



Hach-Que
03-31-2009, 04:54 PM
The title probably isn't too clear, because there's no easy way of explaining this.

We (my team) want to start with a flat plane of vertices, but we want the user to be able to pull and push vertices away from the camera. So the user should be able to select a group of vertices and then use the mouse to move them around.

We aren't sure how to tackle this problem however, so we've come here looking for help.

scratt
03-31-2009, 08:00 PM
My first stab at this would be to go look at the coldet library on SourceForge.
It's quite old, but reasonably well documented in the code, and simple enough to be flexible and customizable to your needs.

It has (if I remember correctly) the ability to put bunches of triangles into a big database which you can then do ray collision detection with on a triangle or vertex level.

It also has the ability to apply the current model transformation matrix, or not, when you do those collision detections.

You can shoot a ray from the mouse position on screen into the mesh by using gluUnProject twice as documented on the OpenGL site here..
http://www.opengl.org/resources/faq/technical/selection.htm

You'd most likely have to modify coldet slightly to give each triangle or vertex a handle to refer back to your drawing data, or you could perhaps draw the data, and manipulate it within coldet directly. Up to you.