Sign in to follow this  
mind in a box

Framerate based smoothing

Recommended Posts

So, I have another problem: I want my Camera to move and rotate smoothly, but I just can't figure out how to do this FPS based. what I mean is: When you have a player, and you add 1 to hims location every frame, he will be too fast with many FPS, and too slow with low FPS. To fix this, you can easily do Speed/FPS, but what can I do when I want it smooth? Here is what I'm currently doing:
void Camera::Tick()
{
	bool bDoneSomething=false;
	if(SmoothLocation!=D3DXVECTOR3(0,0,0))
	{
		Location+=SmoothLocation;
		SmoothLocation*=SmoothSpeed;
		bDoneSomething=true;
	}

	if(SmoothRotation!=D3DXVECTOR3(0,0,0))
	{
		Rotation+=SmoothRotation;
		SmoothRotation*=SmoothSpeed;
		bDoneSomething=true;
	}

...

SmoothSpeed is a float at 0.5. Can you help me with this?

Share this post


Link to post
Share on other sites
Quote:
Original post by mind in a box
Yes, thats a nice tutorial, but where is the stuff about smooth moving objects? Or did I just missed it?
The coded uses a timer class that averages the last few frames to smooth out spikes, and then uses that smoothed time to move objects based on a speed in units / sec and the time elapsed that frame.
The actual object update is done in D3DWindow::UpdateLogic() and Sprite::Tick().

Share this post


Link to post
Share on other sites
This is very useful, and I'm building it in at the moment, but not exactly that what I wanted. Just imagine you control a spaceship. When you touch one of your move-keys, it will move. What else, its a move key :P. But when you release it, the ship will need some time to stand still. Your Tutorial seem to be only about smoothing the FPS, and not about FPS based smoothing...

Share this post


Link to post
Share on other sites
Quote:
Original post by mind in a box
This is very useful, and I'm building it in at the moment, but not exactly that what I wanted. Just imagine you control a spaceship. When you touch one of your move-keys, it will move. What else, its a move key :P. But when you release it, the ship will need some time to stand still. Your Tutorial seem to be only about smoothing the FPS, and not about FPS based smoothing...


You aren't describing FPS-based smoothing, though, you're describing inertia. For that you want to look into things like springs, damping and friction :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this