Jump to content

  • Log In with Google      Sign In   
  • Create Account


Camera Interpolation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
24 replies to this topic

#21 BlueSpud   Members   -  Reputation: 418

Like
0Likes
Like

Posted 11 September 2013 - 06:56 PM

so you don't use time for movement. and that is really bad. since s = v * t; (distance travelled  is equal to velocity multiplied by time)

intp is time. intp is the time in between the ticks, which are going at a constant rate of 20 ticks per sec on, giver er take a bit of time here and there. Really the problem at hand is why the camera keeps accelerating and decelerating. 



Sponsor:

#22 L. Spiro   Crossbones+   -  Reputation: 12949

Like
0Likes
Like

Posted 13 September 2013 - 10:45 PM

Is your camera tied to the player?

Does your player only update on logical ticks?

If so, does that mean your camera only updates its position on logical ticks?

 

If so, we have found the problem.

The camera should update every frame based on the interpolated position of the player—the position used for rendering every frame.

 

If this is not your problem, you will need to provide more information.

 

 

L. Spiro


Edited by L. Spiro, 13 September 2013 - 10:56 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#23 BlueSpud   Members   -  Reputation: 418

Like
0Likes
Like

Posted 14 September 2013 - 10:00 PM

Is your camera tied to the player?
Does your player only update on logical ticks?
If so, does that mean your camera only updates its position on logical ticks?

If so, we have found the problem.
The camera should update every frame based on the interpolated position of the player—the position used for rendering every frame.

If this is not your problem, you will need to provide more information.


L. Spiro

the camera, right now is bound to the player. I have narrowed it down to using a higher resolution counter to make it look smooth. My problem not is it constantly accelerates and decelerates. The movement is on an interpolated tick.

#24 Irlan R.   Members   -  Reputation: 1405

Like
0Likes
Like

Posted 23 September 2013 - 08:09 AM

@BlueSpud
 
I do like that:
 
float frameTime = GetFrameTime();
float t = (frameTime * 2.0);


Vector3 vecStart = vecPos (current camera position);
Vector3 vecEnd = player->GetCamOffset() * ( player->GetWorldMatrix() );


if( Length(vecEnd - vecStart) > 0.0)
{

//interpolate
vecPos = vecStart + (vecEnd - vecStart) * t;


//camera variables
vecX = player->GetRotMatrix().GetX();
vecY = player->GetRotMatrix().GetY();
vecZ = player->GetRotMatrix().GetZ();

//camera view matrix
matView = MatrixLookAt(vecPos, player->GetPosition(), Vector3(0, 1, 0) );
}
 
Update the camera position by the half of the frame time based on the camera offset.

Edited by irlanrobson, 23 September 2013 - 08:12 AM.


#25 BlueSpud   Members   -  Reputation: 418

Like
0Likes
Like

Posted 23 September 2013 - 12:38 PM

 

@BlueSpud
 
I do like that:
 
float frameTime = GetFrameTime();
float t = (frameTime * 2.0);


Vector3 vecStart = vecPos (current camera position);
Vector3 vecEnd = player->GetCamOffset() * ( player->GetWorldMatrix() );


if( Length(vecEnd - vecStart) > 0.0)
{

//interpolate
vecPos = vecStart + (vecEnd - vecStart) * t;


//camera variables
vecX = player->GetRotMatrix().GetX();
vecY = player->GetRotMatrix().GetY();
vecZ = player->GetRotMatrix().GetZ();

//camera view matrix
matView = MatrixLookAt(vecPos, player->GetPosition(), Vector3(0, 1, 0) );
}
 
Update the camera position by the half of the frame time based on the camera offset.

 

I ended up using time elapsed instead of time between the tick, but thanks anyways. To anyone else who stumbles upon this topic here is what I ended up doing:

- I used SDL_GetPreformenceCounter() because it has a much higher precision.

- I used elapsed time not the interpolation that Dewitter's game loop entails. This is because the time in between the tick is not very good because it can greatly stutter and even though the game loop is "frame rate independent" Values can vary and not ending up what you want.

 

The game and view is much smoother now, thanks to everyone who has helped.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS