In general, how do you specify the path of your camera when making a scene?
I am creating a simple solar system with 3d shapes for a music video. I can create the scene and populate it with spheres and apply textures to those spheres.
I now would like to specify a path for my camera around the different planets of the solar system. It seems like I can do things like “start at (0,0,1000) and zoom into (0,0,100) at a rate of 10 units per second.” However, this isn’t really the level of control I need for creating a music video.
So I’m not sure how to take that step from camera movement for simply seeing your scene to camera motion for a final render/ movie.
Do people generally make a seperate utility/ debug program for specifying their camera path and tweaking it? I saw http://debugviewart.tumblr.com which is a collection of peoples’ development/ debug interfaces for their programs. Do I need to create something like this?
I also checked out this lecture from Ken joy on camera motion. He explains that most curves aren’t suitable for camera motion because they aren’t smooth enough, and he uses catmull-rom curves to solve that problem: https://www.youtube.com/watch?v=HAJv25Afsz8&index=20&list=PL_w_qWAQZtAZhtzPI5pkAtcUVgmzdAP8g
Thanks in advance!
I usually move the camera procedurally, for example using
cos to move the camera along a circle.
float radius = 100.0f; float t = float( getElapsedSeconds() ); float x = radius * glm::sin( 0.1f * t ); float z = radius * glm::cos( 0.1f * t ); float y = radius * glm::cos( 0.15f * t ); mCamera.lookAt( vec3( x, y, z ), vec3( 0 ) );
If you want more control, you could use a series of
BSpline segments. See the sample.
Regardless of the way you calculate position and target, you can always create smooth motion like this:
vec3 currentPosition = ...; vec3 newPosition = ...; currentPosition += 0.1f * ( newPosition - currentPosition );
Since this is not frame rate independent, you should call the smoothing code a fixed number of times per second.
sin and cos values relative to the number of frames can really give you lots of control. maybe something like this:
with a little bit of math and a few variables you can get a ton of change for your input without redrawing camera paths. don’t like the arc of the path? change the scale value. want some organic nonlinearity? map the range over an easing function. this drawing is 2D but you could of course use sin and cos for y values as well. you could treat the frame count like a timeline and make keyframe style if statements:
one thing I forgot: don’t forget to scale the frame count value that goes into the sin and cos functions. Paul’s example accounts for that. otherwise the camera will move dizzyingly fast (since sin completes a full cycle in 2pi and the framerate is likely > 30 FPS!)
Using easing functions is a good suggestion. You can find them in the Easing.h file. Also have a look at the TimeLine classes, they use easing extensively.