Sign in to follow this  
Krumm

Draw object do transformations and get new points.

Recommended Posts

Hi there, I've developed my own 3D class that: 1) Takes in a list of triangles, each one made up of 3 points (obviously!), and each point being 3D. 2) Also takes in 3 values for rotation, 3 values for scale and 3 values for the position. 3) When I come to draw the object I do something like: glPushMatrix(); glTranslatef(positionX, positionY, positionZ); glRotatef(rotateX,1,0,0); glRotatef(rotateY,0,1,0); glRotatef(rotateZ,0,0,1); glScalef(scaleX, scaleY, scaleZ); //loop through my vector of triangles drawing each one glPopMatrix(); Now, I'm doing my collision detection, but I need to know the points of the object, after all of the transformations. So inbetewen the last scale and the start of the loop, I need to get what all the points are. For example, a simple quad: 0,0,0 1,0,0 1,1,0 0,1,0 is fine, but once it has been rotated, scaled and what-not... the points are certainly not like that anymore... Can anybody please help? Thank you! Krumm.

Share this post


Link to post
Share on other sites
Looks like you need to find a vector maths library. While it's technically possible to do these calculations in OpenGL and then read back the results, it isn't worth it on todays hardware and it wouldn't work the way you expect it to anyway.

I use math3d but it's not supported anymore. mathgl-pp looks good though.

Share this post


Link to post
Share on other sites
You have to track the transformations you supply to OpenGL. Either you write your own matrix class for that purpose, or else you use one already existing, as mrbastard has suggested.

However, you should look whether it is necessary to transform the entire mesh vertex by vertex (I understand your question this way). Normally such effort is needed only if mesh-mesh collision is checked. E.g. if you check a ray-mesh intersection, it would be much less effort to transform the ray into the co-ordinate frame of the mesh, and letting the mesh's vertices as are, instead of transforming the mesh into the co-ordinate frame of the ray. But notice that also this method does not free you from tracking the applied transformations.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this