• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

### #ActualRectangle

Posted 22 April 2013 - 12:41 AM

Sounds like a fun little task.
Well first off, I would attach a target vector to the camera class, as well as some sort of maximum speed limit to act as a scalar value for each axis.
Next, I would have an update function in the camera class which took the delta time between frames as a parameter, and call that function each frame.

In the update function, I would use the typical formula of:

camPos.x += ((camTarget.x - camPos.x) * deltaTime) * speedScalar.x;
camPos.y += ((camTarget.y - camPos.y) * deltaTime) * speedScalar.y;
camPos.z += ((camTarget.z - camPos.z) * deltaTime) * speedScalar.z;


This will animate the camera's current position to eventually match the target camera's position, at a speed based upon the scalar value. You can raise or lower this value as needed until it feels right for you.

As for making the camera "point" in the direction it needs to go, just do a simple "LookAt" transformation (ie, "gluLookAt" or "Matrix.LookAt*" functions) from your camera's current position to the target camera's position, and either set that as the first target camera (to animate the rotation sequence) or determine at which points along the animation you would like to "combine" these animations, and I believe you should get the effect you're looking for. Or at least get you on a pretty good start.

Of course, this is just one way to do it, though.

### #2Rectangle

Posted 22 April 2013 - 12:36 AM

Sounds like a fun little task.
Well first off, I would attach a target vector to the camera class, as well as some sort of maximum speed limit to act as a scalar value for each axis.
Next, I would have an update function in the camera class which took the delta time between frames as a parameter, and call that function each frame.

In the update function, I would use the typical formula of:

camPos.x += ((camTarget.x - camPos.x) * deltaTime) * speedScalar.x;
camPos.y += ((camTarget.y - camPos.y) * deltaTime) * speedScalar.y;
camPos.z += ((camTarget.z - camPos.z) * deltaTime) * speedScalar.z;


This will animate the camera's current position to eventually match the target camera's position, at a speed based upon the scalar value. You can raise or lower this value as needed until it feels right for you.

As for making the camera "point" in the direction it needs to go, just do a simple "LookAt" transformation (ie, "gluLookAt" or "Matrix.LookAt*" functions) from your camera's current position to the target camera's position, and either set that as the first target camera (to animate the rotation sequence) or determine at which points along the animation you would like to "combine" these animations, and I believe you should get the effect you're looking for.

Of course, this is just one way to do it, though.

### #1Rectangle

Posted 22 April 2013 - 12:34 AM

Sounds like a fun little task.
Well first off, I would attach a target vector to the camera class, as well as some sort of maximum speed limit to act as a scalar value for each axis.
Next, I would have an update function in the camera class which took the delta time between frames as a parameter, and call that function each frame.

In the update function, I would use the typical formula of:

camPos.x += ((camTarget.x - camPos.x) * deltaTime) * speedScalar.x;
camPos.y += ((camTarget.y - camPos.y) * deltaTime) * speedScalar.y;
camPos.z += ((camTarget.z - camPos.z) * deltaTime) * speedScalar.z;


This will animate the camera's current position to eventually match the target camera's position, at a speed based upon the scalar value. You can raise or lower this value as needed until it feels right for you.

As for making the camera "point" in the direction it needs to go, just do a simple "LookAt" transformation (ie, "gluLookAt" or "Matrix.LookAt*" functions) from your camera's current position to the target camera's position, and either set that as the first target camera (to animate the rotation sequence) or determine at which points along the animation you would like to "combine" these animations, and I believe you should get the effect you're looking for.

PARTNERS