Jump to content
  • Advertisement
Sign in to follow this  
d h k

OpenGL Placing Weapon In Ego Perspective

This topic is 4710 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

Hello everybody, I am working on a simple ego-shooter at the moment. Everything is fine except, that the weapon model needs to turn correctly around the player, in order to stay placed correctly whenever the player turns. At the moment it just turns around itself and not the player. I know NeHe mentions this point somewhere in his tutorials but I couldn't find anything there. This is my relevant code: ( I based my code upon NeHe's Tutorial 10 )
        // move to player
	GLfloat x, z;
	x = xpos - (float)sin ( heading * piover180 ) * 0.05f;
	z = zpos - (float)cos ( heading * piover180 ) * 0.05f;
	glTranslatef ( x + 0.15f, 0.15f, z - 0.5f );

	// also rotate
	glRotatef ( yrot, 0.0f, 1.0f, 0.0f );
	glRotatef ( -lookupdown, 1.0f, 0.0f, 0.0f );


The translating part works fine now, but still the weapon rotates around its own centre point and not the players. Is there an (easy) way to fix this (I just started with OpenGL two days ago ;) )... Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Nevermind, I just thought about a possible solution, that should work. Sorry for my 'to early' post.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!