diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-10-20 21:18:18 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2010-10-21 00:31:16 -0700 |
commit | 1b258b21770d3c46e16ca74433bff98d0ad2466e (patch) | |
tree | f9adaabbb2908a5d000b87bb324ccfee5196c111 | |
parent | cac6cddd34fe2b700ce63c67cc3dedd3316e762c (diff) |
Calculate initial C0 curves based off of the original code points.
Signed-off-by: Ian Romanick <idr@freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@freedesktop.org>
-rwxr-xr-x | src/main.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/main.cpp b/src/main.cpp index bdd9393..b2d5091 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,21 +50,7 @@ static const GLUvec4 linear_control_points[] = { /** * Basic C0 cameara control curves that hit the points in linear_control_points */ -static const bezier_curve camera_curves[] = { - bezier_curve(linear_control_points[0], // start point - GLUvec4(10.0f, 3.5f, 20.0f, 0.0f), // control - GLUvec4(15.0f, 3.5f, 5.0f, 0.0f), // control - linear_control_points[1]), // end point - bezier_curve(linear_control_points[1], - GLUvec4(15.0f, 1.5f, -20.0f, 0.0f), - GLUvec4(-10.0f, 1.5f, -35.0f, 0.0f), - linear_control_points[2]), - bezier_curve(linear_control_points[2], - GLUvec4(-40.0f, -0.5f, -10.0f, 0.0f), - GLUvec4(-25.0f, -0.5f, 12.0f, 0.0f), - linear_control_points[0]), - -}; +static bezier_curve camera_curves[ELEMENTS_OF(linear_control_points)]; /** * Control curves from camera_curves "fixed" to be G1. @@ -300,6 +286,25 @@ load_and_compile_program_code(const char *shader) /** + * Create initial bezier curves based on the given linear control points that + * the camera must hit. These have C0 continuity. + */ +void +make_initial_curves() +{ + for (unsigned i = 0; i < 3; i++) { + unsigned next = (i + 1) % 3; + GLUvec4 a = lerp(linear_control_points[i], + linear_control_points[next], 1. / 3.) * 2.; + GLUvec4 b = lerp(linear_control_points[i], + linear_control_points[next], 2. / 3.) * 2.; + camera_curves[i] = bezier_curve(linear_control_points[i], a, b, + linear_control_points[next]); + } +} + + +/** * Modify the control points of two C0 curves to make the G1 * * The curves generated by this function will only modify the neighboring @@ -394,6 +399,7 @@ Init(void) " c: Re-load and compile shader program code.\n" " ESC: Exit program.\n"); + make_initial_curves(); for (int i = 0; i < 3; i++) { camera_curves_G1[i] = camera_curves[i]; camera_curves_C1[i] = camera_curves[i]; |