From e1ec95840ff1b20bbf1a6f9897202c824195b68d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 12 Feb 2017 06:43:09 -0800 Subject: ray: improve camera movement Make the camera orbit around the origin at a varying radius, with kept aimed facing the origin, with some vertical sweep+tilt thrown in. --- src/modules/ray/ray.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index 8c9a001..5210896 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -26,7 +26,7 @@ static void ray(fb_fragment_t *fragment) .specular = 0.2f, }, .normal = { .x = 0.0, .y = 1.0, .z = 0.0 }, - .distance = 3.2f, + .distance = 2.0f, } }, { .sphere = { @@ -114,17 +114,25 @@ static void ray(fb_fragment_t *fragment) static unsigned ncpus; #if 1 /* animated point light source */ - static double r; + static float r; r += .02; - scene.lights[0].light.emitter.point.center.x = cosf(r) * 3.5f; - scene.lights[0].light.emitter.point.center.z = sinf(r) * 3.5f; - camera.orientation.yaw = sinf(r) / 4; - camera.orientation.pitch = sinf(r * 10) / 100; - camera.orientation.roll = RAY_EULER_DEGREES(180.0f) + cosf(r) / 10; - camera.position.x = cosf(r) / 10; - camera.position.z = 4.0f + sinf(r) / 10; + scene.lights[0].light.emitter.point.center.x = cosf(r) * 4.5f; + scene.lights[0].light.emitter.point.center.z = sinf(r * 3.0f) * 4.5f; + + /* move the camera in a circle */ + camera.position.x = sinf(r) * (cosf(r) * 2.0f + 5.0f); + camera.position.z = cosf(r) * (cosf(r) * 2.0f + 5.0f); + + /* also move up and down */ + camera.position.y = cosf(r * 1.3f) * 4.0f + 2.08f; + + /* keep camera facing the origin */ + camera.orientation.yaw = r; + + /* tilt camera pitch in time with up and down movements, phase shifted appreciably */ + camera.orientation.pitch = sinf((M_PI * 1.5f) + r * 1.3f) * .6f + -.35f; #endif if (!initialized) { -- cgit v1.2.3