Specific matrix question

Started by
15 comments, last by middy 19 years, 8 months ago
>>The smaller object is a bullet stream, coming from a gun. When I rotate the gun the bullets (even though they have left the gun) rotates with it.<<

weh the bullet is fired work out
bullet_velocity = ship_dir * bullet_speed
and just add that vector to the bullets position every frame
Advertisement
I finally solved it.


I copied the matrix and it still had the same error.. but that was because the ship rotatinig did not have a push/pop command and thus would affect and matrix defined afterwards (DUH)


Thanks everyone
hmm I still have a problem

What I am doing now is copying the ship matrix. But this means that the bullet flies from the center of the ship.

I have a point on my ship in wich I would like the bullet to fly from. But this point is in model space, eg only relative to the model as its drawn in origo.


So I have to translate the rotation and position of the ship to that point. I have to to make the modelPoint a worldcoordinate point.

How can I do this, cause it has to be a function of models world position and rotation??




So apply the matrix to the point.
Your "ship matrix" is actually a matrix that transforms points from object coordinates to world coordinates.
Well I need the point in world coordinates, so I can calculate intersection. The shot does not need to go from ship position but with a little offset.

But maybe I misunderstand you when you say apply matrix.
Ok, you have a point in object coordinates that is where on the ship a bullet should appear at. You also have a copy of the modelview matrix that is used to position the ship - i.e. transform it from object coordinates to worlds coordinates.
So if you apply this matrix to the point - i.e. multiply the matrix with the point - you will get a point in world coordinates.
AH, thanks Thomas, yes it makes perfect sense.. Well as I stated in my first post I prolly did not understand OpenGl correctly.

This topic is closed to new replies.

Advertisement