Jump to content
  • Advertisement
Sign in to follow this  
ZoomBoy

Matrices in a scene

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working my way through a arcade flight sim and my objects are going to have sub-objects. I can get the sub-objects onto the screen. But in order to do collision detection and possibly culling, I need to get their world position. Up until now to display them, I just glPushMatrix() and glPopMatrix(). Do I need to set aside a world transformation matrix of the sub-object or can I just extract it for the current Matrix?

Share this post


Link to post
Share on other sites
Advertisement
You can get the current transformation matrix with the following code:

float modelview_matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelview_matrix);


This way the objects' positions can be transformed into world-space by multiplying them by that matrix.

Share this post


Link to post
Share on other sites
Hmmmm... i am in a similar situation, and im not sure how well this method will work. Currently, at each frame, i first update the objects based on their properties (velocity, etc.), check for collisions and reposition the objects that are colliding, and then draw all of them. The problem is that the OpenGL matrices for each object is calculated as i draw them. However, i need them for collision detection, which occurs *before* i draw. So if i grab the matrices from OpenGL, they will all be one frame behind.

Im sure many other ppl have had this problem too. What were your solutions?

Share this post


Link to post
Share on other sites
Thanks for the discussion on the scenegraph. I was more focused on the subobjects. As the inputs will be by keystroke where I purposely change the main orientation of the plane and by AI functions, I'm going to have to do my own system of tracking the Matrices of the sub-objects.
I'll probably have pointers to parent matrices and maybe Identify the level of graph where the subobject is located.
Going to have to review my math library for this stuff.
Been useful.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!