Jump to content
  • Advertisement
Sign in to follow this  
BlueSpud

Separating Camera Movement for a first person camera into another thread?

This topic is 1907 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 had a camera working, but it would move every frame, so the higher the framerate, the faster you would be able to move. I made the camera movement so it depends on time, and now the movement is framerate independent. Unfortunately, the function only gets called in the glutMain Loop where the render is also done right after. At 60 FPS, the camera seems a bit jittery, but at 100 frames it seems fine. My question is: Would it make more sense to make a new thread in which there is another game loop where I update physics, etc so movement can be based on time and look nice, regardless of the framerate. (Unless its terrible < 10 because that means there is a code problem or the computer is slow). Any insight or help would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Advertisement

seems like you might be doing something wrong... the general pseudo-code is as follows:

 

velocity = ( current_time - last_render_time ) * factor;

 

of course, it is best if this is done outside of the render function for precision and accuracy.. but it should still work smoothly regardless

 

is this basically what you're doing? Or something different?

Share this post


Link to post
Share on other sites

seems like you might be doing something wrong... the general pseudo-code is as follows:

 

velocity = ( current_time - last_render_time ) * factor;

 

of course, it is best if this is done outside of the render function for precision and accuracy.. but it should still work smoothly regardless

 

is this basically what you're doing? Or something different?

Yes it is, and I believe that  my time is being measured in nanoseconds.

Share this post


Link to post
Share on other sites

note that current_time probably shouldn't be the actual time function call... you should have something like this:

...

last_render_time = current_time;

current_time = getTime();

...

velocity = ( current_time - last_render_time ) * factor;

...

 

If you don't have that - try it and see if that makes a difference

Share this post


Link to post
Share on other sites

note that current_time probably shouldn't be the actual time function call... you should have something like this:

...

last_render_time = current_time;

current_time = getTime();

...

velocity = ( current_time - last_render_time ) * factor;

...

 

If you don't have that - try it and see if that makes a difference

Did you mean that last render time shouldn't be the function call? Because in your little example, current time is still a function call.

Share this post


Link to post
Share on other sites

no. i mean that you should set is as a variable first before you use it in the `velocity` assignment, instead of putting the call right in the `velocity` assignment statement

Share this post


Link to post
Share on other sites

no. i mean that you should set is as a variable first before you use it in the `velocity` assignment, instead of putting the call right in the `velocity` assignment statement

I see what you mean, in my code I do this.

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.

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!