diff --git a/main.cpp b/main.cpp index be7b47d..af970d4 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,8 @@ stim::camera cam; int mx, my; //mouse coordinates in the window space -stim::gl_spharmonics S; +stim::spharmonics S; +stim::gl_spharmonics R; //spherical harmonics to render float d = 1.5; //initial distance between the camera and the sphere @@ -27,6 +28,12 @@ stim::arglist args; //class for processing command line arguments bool zaxis = false; //render the z-axis (set via a command line flag) +/// INTERPOLATION +stim::gl_spharmonics Si; +bool interp = false; //if we are interpolating +float alpha = 0.0; //alpha value for interpolation +float dalpha = 0.1; //change in alpha value with a key press + bool init(){ //set the clear color to white @@ -38,7 +45,7 @@ bool init(){ cam.setFOV(40); //initialize the texture map stuff - S.glInit(256); + R.glInit(256); return true; } @@ -67,7 +74,12 @@ void display(){ gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], u[0], u[1], u[2]); //draw the sphere - S.glRender(); + if (interp) + R = (S * (1.0f - alpha) + Si * alpha); + else + R = S; + R.glRender(); + //glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); @@ -130,7 +142,7 @@ std::vector > sample_sphere(int num_samples, float radius = 1.0) { - float solidAngle = 2*stim::PI; ///Solid angle to sample over + float solidAngle = stim::TAU; ///Solid angle to sample over float PHI[2], Z[2], range; ///Range of angles in cylinderical coordinates PHI[0] = solidAngle/2; ///project the solid angle into spherical coords PHI[1] = asin(0); /// @@ -148,7 +160,7 @@ sample_sphere(int num_samples, float radius = 1.0) for(int i = 0; i < num_samples; i++) { z = uniformRandom()*range + Z[1]; - theta = uniformRandom()*stim::TAU; + theta = uniformRandom() * stim::TAU; phi = acos(z); stim::vec3 sph(1, theta, phi); stim::vec3 cart = sph.sph2cart(); @@ -185,6 +197,7 @@ void process_arguments(int argc, char* argv[]){ args.add("out", "filename for outputting spherical harmonics coefficients", "", "filename"); args.add("zaxis", "render the z-axis as a green line"); args.add("pdf", "outputs the PDF if an OBJ files is given"); + args.add("interp", "interpolates between two specified sets of coefficients", "", "[c0 c1 c2 c3 ...]"); //process the command line arguments args.parse(argc, argv); @@ -193,6 +206,11 @@ void process_arguments(int argc, char* argv[]){ if(args["zaxis"].is_set()) zaxis = true; + if (args["interp"]) { //if an interpolation harmonic is provided + for (unsigned int a = 0; a < args["interp"].nargs(); a++) + Si.push(args["interp"].as_float(a)); + } + //if arguments are specified, push them as coefficients if(args.nargs() > 0){ //push all of the arguments to the spherical harmonics class as coefficients -- libgit2 0.21.4