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?

  • \$\begingroup\$ 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? \$\endgroup\$ Apr 26, 2012 at 15:07
  • \$\begingroup\$ 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. \$\endgroup\$
    – Joel
    Apr 27, 2012 at 2:33

1 Answer 1


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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .