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;
}
...
Framerate based smoothing
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:
SmoothSpeed is a float at 0.5. Can you help me with this?
I covered this in my most recent tutorial - you should be able to extract the relevant code fairly easily.
Yes, thats a nice tutorial, but where is the stuff about smooth moving objects? Or did I just missed it?
Quote:Original post by mind in a boxThe 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.
Yes, thats a nice tutorial, but where is the stuff about smooth moving objects? Or did I just missed it?
The actual object update is done in D3DWindow::UpdateLogic() and Sprite::Tick().
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...
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 :)
Yes, maybe. I don't know. When you multiply a value every frame with 0.9 it will go to 0 smoothly. Thats what I want to do, but with implying the FPS.
I just want that my Camera has a smooth rotation...
I just want that my Camera has a smooth rotation...
Like:
Position += Velocity * deltaTime;
Velocity *= 0.9f * deltaTime;
Where deltaTime is the amount of time between this point and the last frame.
Position += Velocity * deltaTime;
Velocity *= 0.9f * deltaTime;
Where deltaTime is the amount of time between this point and the last frame.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement