Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a skeletal animation system for a game i am working on. To draw lines that represent a skeleton, i use the GL matrix, and multiply it by each bone a long the body. For example before drawing the left hand, GL.multMatrix has been called for the lower back, upper back, left shoulder, left upper arm and left lower arm.

Currently i am now trying to deal with hitboxes. After this series of matrix transformations have been made, i am drawing a box with the local coordinates of -2,-2,-2 to 2,2,2. This works fine, the animated skeleton has a box around the hand.

However i've reached the stage of actually needing to use the hitbox, to check if it collides with another hitbox. I've worked out the algorithms i shall use for checking if there is a collision, but i first need to change those coordinates from their local to the hand coordinates, into coordinates i can use against other things in the world.

For example the left hand hitbox has the same local coordinates as the right hand hitbox, but how could i change that all back to global coordinates so i can get their proper world coordinates?

Thanks for any help!

share|improve this question
So you start with the original world coordinates, run them through the matrices and then draw the box, correct? Is there any reason you cannot keep the original world coordinates and simply -/+ the x,y by 2 to get your box? – Joshua Drake Apr 26 '12 at 15:07
the box had to be rotated etc. And it was getting the world coordinates in the first place that was the issue. Though it's all solved now. – Randomman159 Apr 27 '12 at 2:33
up vote 1 down vote accepted

OpenGL stores its model matrix and view matrix together. As far as i know, you can't separate them once they are together.

To solve this, i simply ended up storing my own model matrix, which i then used GL.MultMatrix() to combine with the view matrix when it came time to draw. To access coordinates all i had to do then was to get M41, M42 and M43 (x, y and z) from the model matrix, and to get offset coordinates for a box, creating a translation of the offset of each vertex gave me the new coordinates of each respective vertex.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.