Commit 31c961c78f495c8d8342fd511d9f03a9a768de4c

Authored by David Mayerich
1 parent ff427202

interpolation changes (unfinished)

Showing 1 changed file with 23 additions and 5 deletions   Show diff stats
main.cpp
... ... @@ -17,7 +17,8 @@
17 17 stim::camera cam;
18 18 int mx, my; //mouse coordinates in the window space
19 19  
20   -stim::gl_spharmonics<double> S;
  20 +stim::spharmonics<double> S;
  21 +stim::gl_spharmonics<double> R; //spherical harmonics to render
21 22  
22 23 float d = 1.5; //initial distance between the camera and the sphere
23 24  
... ... @@ -27,6 +28,12 @@ stim::arglist args; //class for processing command line arguments
27 28  
28 29 bool zaxis = false; //render the z-axis (set via a command line flag)
29 30  
  31 +/// INTERPOLATION
  32 +stim::gl_spharmonics<double> Si;
  33 +bool interp = false; //if we are interpolating
  34 +float alpha = 0.0; //alpha value for interpolation
  35 +float dalpha = 0.1; //change in alpha value with a key press
  36 +
30 37 bool init(){
31 38  
32 39 //set the clear color to white
... ... @@ -38,7 +45,7 @@ bool init(){
38 45 cam.setFOV(40);
39 46  
40 47 //initialize the texture map stuff
41   - S.glInit(256);
  48 + R.glInit(256);
42 49  
43 50 return true;
44 51 }
... ... @@ -67,7 +74,12 @@ void display(){
67 74 gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], u[0], u[1], u[2]);
68 75  
69 76 //draw the sphere
70   - S.glRender();
  77 + if (interp)
  78 + R = (S * (1.0f - alpha) + Si * alpha);
  79 + else
  80 + R = S;
  81 + R.glRender();
  82 +
71 83  
72 84 //glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
73 85  
... ... @@ -130,7 +142,7 @@ std::vector&lt;stim::vec3 &lt;float&gt; &gt;
130 142 sample_sphere(int num_samples, float radius = 1.0)
131 143 {
132 144  
133   - float solidAngle = 2*stim::PI; ///Solid angle to sample over
  145 + float solidAngle = stim::TAU; ///Solid angle to sample over
134 146 float PHI[2], Z[2], range; ///Range of angles in cylinderical coordinates
135 147 PHI[0] = solidAngle/2; ///project the solid angle into spherical coords
136 148 PHI[1] = asin(0); ///
... ... @@ -148,7 +160,7 @@ sample_sphere(int num_samples, float radius = 1.0)
148 160 for(int i = 0; i < num_samples; i++)
149 161 {
150 162 z = uniformRandom()*range + Z[1];
151   - theta = uniformRandom()*stim::TAU;
  163 + theta = uniformRandom() * stim::TAU;
152 164 phi = acos(z);
153 165 stim::vec3<float> sph(1, theta, phi);
154 166 stim::vec3<float> cart = sph.sph2cart();
... ... @@ -185,6 +197,7 @@ void process_arguments(int argc, char* argv[]){
185 197 args.add("out", "filename for outputting spherical harmonics coefficients", "", "filename");
186 198 args.add("zaxis", "render the z-axis as a green line");
187 199 args.add("pdf", "outputs the PDF if an OBJ files is given");
  200 + args.add("interp", "interpolates between two specified sets of coefficients", "", "[c0 c1 c2 c3 ...]");
188 201  
189 202 //process the command line arguments
190 203 args.parse(argc, argv);
... ... @@ -193,6 +206,11 @@ void process_arguments(int argc, char* argv[]){
193 206 if(args["zaxis"].is_set())
194 207 zaxis = true;
195 208  
  209 + if (args["interp"]) { //if an interpolation harmonic is provided
  210 + for (unsigned int a = 0; a < args["interp"].nargs(); a++)
  211 + Si.push(args["interp"].as_float(a));
  212 + }
  213 +
196 214 //if arguments are specified, push them as coefficients
197 215 if(args.nargs() > 0){
198 216 //push all of the arguments to the spherical harmonics class as coefficients
... ...