Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

neonoblivion

camera rotation

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

I''m trying to make my camera move based on my frame rate, but this current code I''m working on make it rotate at the right speed but my framerate droped by about 7 times .
  	
   ticks=(clock()-lasttime)/CLK_TCK;
   lasttime=(float)clock();
   	
	if (KEY_DOWN(VK_ESCAPE) || KEY_DOWN(VK_SPACE)){
		PostMessage(hwnd, WM_DESTROY,0,0);
		return(0);
	}
	if(KEY_DOWN(VK_UP)){
		if(rx<45)
		rx+=ticks*33;
	}

	if(KEY_DOWN(VK_DOWN)){
		if(rx>-20)
		rx-=ticks*33;
	}
	
	if(KEY_DOWN(VK_LEFT)){
		ry+=ticks*33;
	}

	if(KEY_DOWN(VK_RIGHT)){
		ry-=ticks*33;
	}
	
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	glTranslatef(0.0f,10.0f,0.0f);
	glRotatef(-190,1.0f,0.0f,0.0f);
	glRotatef(rx,1.0f,0.0f,0.0f);
	glRotatef(ry,0.0f,1.0f,0.0f);
  
links to tutorials would be cool. thanks, Klaus

Share this post


Link to post
Share on other sites
Advertisement
That is the way you usually make framerate independant camera movement. I don''t see why your framerate should drop by 7 times by using it. Maybe you could optimise it by doing less float to int or int to float conversions. They can be a nasty bottleneck. Also I''d check your clock routine for speed, because I don''t think that that code should cause a framerate drop of that much. What is the framerate that you are getting anyway?

Also, this isn''t directly related to your question, but don''t you usually rotate and THEN translate, rather than translate and rotate? Thats the way my engine works.

- Weasalmongler

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!