The camera position and rotation is the exact location of where the center of your screen en the angle of your screen is.

If you use glTranslatef at the beginning of your drawing code then the given position here is the origin of the bullet. You can calculate the direction using the sinus and cosinus of the given angle. The angle of the bullet is equal to the glRotatef rotation.

If you wrote/ found a good vector class you can just use that for storing all the data.

It’s not much, its like 5am in the morning, but I hope it helps though

Hi,

I am making my own first person shooter 3D engine. I am stuck with shooting. I know that I have somehow change my screen coordinates to world coordinates, am I right? This just involves matrixes and I cant do the math, not yet atleast.

More accurately, I have aiming cross at center of the screen and I want to shoot ray to there from players position and if it collides with something it could at this point just print something. All I think I need is to know how to do the conversion from x = WIDTH/2 y = HEIGHT/2 to my world coordinates. Atleast this is what I think I need for now.

There’s propably topics around this and I quickly searched but did’nt find anything I could use. Or how to implement it in my code.

My camera is set up like this:

and OPENGL initialized like this:

and I am trying to draw ammo like this:

Problem is just that I dont know what are those origin and direction coordinates or how to calculate those.