Camera Interpolation

Started by
0 comments, last by lubby 18 years, 9 months ago
I'm working on a intro for my game. It involves me scripting a camera (in OpenGL) somehow that'll follow something and then once that object hits it's destination then the camera will zoom far out revealing this even bigger object. Would anybody have any idea how to run this? I have camerapos and camerarotation vectors. I just need some interpolation functions or something to get me started. Any pitfalls people have come under while doing this? Any information will help! Thanks!
Advertisement
If you want the camera position to interpolate from one point to another in a straight line.

Will do an exaple here of moving from 0,0,0 to 10,10,10 - You will need a little bit of vector mathematics here

Vector3 destinationPos(10.0f, 10.0f, 10.0f);Vector3 sourcePos(0.0f, 0.0f, 0.0f);float speed = 0.1f;while (moving){  // speedup/slow down on user input  if (key == speedup)    speed += 0.1f;  else if (key == slowdown)    speed -= 0.1f  Vector3 vecDifference = destinationPos - sourcePos;  // check if we reached the destination  if (vecDifference.Length() < EPSILON)   moving = false;  // update position  sourcePos += vecDifference * speed; // multiply by a scalar not a vector}


If you dont want it to follow a straight line, you will need to step along a spline of some kind, just increasing t as you go. You can do exactly the same thing with the cameras look at position.

This topic is closed to new replies.

Advertisement