Where am I drawing?

Started by
4 comments, last by GreyHound 16 years, 10 months ago
I'm creating a solar system, it's all very neat and simple with this matrix math, not a single cosine do I have to calculate to make the planets fly around their concentric ellipse in different orientations. But, since OpenGL does all of the hard part of calculating where to draw the object in the glTranslate, glRotate and glScale functions I have no idea where they actually end up, and I need their coordinates in a common coordinate system to do the collision checking etc. I thought I could extract the current matrix in some way, before drawing the object, and then calculate the coords from that, but I haven't found a way of doing that. Any suggestions of strategies for solving this? (And does anyone know any good sources of information on these kind of more design related issues? I havn't seen much of that around.) Thanks in advance! /Lidestro
Advertisement
float matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
Cheers! Maybe I can use that in some way. (Stragely, this function wasn't in my gl book or on several reference pages, but on msdn...)

But what is a good solution to this basic problem: I draw an object after a serie of translate, rotate and scale, and than I have to find out WHERE I drew it?

/Lidestro
You can use that matrix to transform the point or vector that describes the planets location, and you'll get its actual location.
And this is the only way, or best way, if I don't want to manually calculate where they are?
edit: i totally missed the part aboput collissions. sorry

This topic is closed to new replies.

Advertisement