Draw object do transformations and get new points.

This topic is 4788 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 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 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 on other sites
Thank you for your replies. I'll have a look at what you said. :)

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• Forum Statistics

• Total Topics
634090
• Total Posts
3015432
×