From f37cf039114d48ceace8e27047b4c7071195ef46 Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Tue, 24 Jan 2017 16:59:11 -0600 Subject: [PATCH] added transitional visualization using the tag --interp --- CMakeLists.txt | 5 +++++ main.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d289428..d107e4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,11 @@ if ( MSVC ) add_definitions(-D_SCL_SECURE_NO_WARNINGS) endif ( MSVC ) +if( CMAKE_COMPILER_IS_GNUCC ) + set(CMAKE_C_FLAGS "-O3") + set(CMAKE_CXX_FLAGS "-O3 -std=c++11 -fpermissive") +endif( CMAKE_COMPILER_IS_GNUCC ) + #find the STIM library find_package(STIM REQUIRED) diff --git a/main.cpp b/main.cpp index af970d4..e9b33e9 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,7 @@ stim::camera cam; int mx, my; //mouse coordinates in the window space -stim::spharmonics S; +stim::gl_spharmonics S; stim::gl_spharmonics R; //spherical harmonics to render float d = 1.5; //initial distance between the camera and the sphere @@ -31,8 +31,8 @@ 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 +double alpha = 0.0; //alpha value for interpolation +double dalpha = 0.1; //change in alpha value with a key press bool init(){ @@ -72,12 +72,16 @@ void display(){ //specify the camera parameters to OpenGL gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], u[0], u[1], u[2]); + if(interp) + { + R=S*(1.0-alpha)+Si*alpha; + R.glInit(); + interp = false; + } + std::cout << "R " << R.str() << std::endl; //draw the sphere - if (interp) - R = (S * (1.0f - alpha) + Si * alpha); - else - R = S; + R.glRender(); @@ -97,6 +101,23 @@ void display(){ glutSwapBuffers(); } +//Process Arrow Key presses. +void +processSpecialKeys(int key, int xx, int yy) +{ + switch(key) + { + case GLUT_KEY_UP: + alpha = alpha + dalpha; + break; + case GLUT_KEY_DOWN: + alpha = alpha - dalpha; + break; + } + interp = true; + glutPostRedisplay(); +} + void mouse_press(int button, int state, int x, int y){ //set the camera motion mode based on the mouse button pressed @@ -206,18 +227,27 @@ 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){ + if(args.nargs() > 0 && !args["interp"]){ //push all of the arguments to the spherical harmonics class as coefficients - for(unsigned int a = 0; a < args.nargs(); a++) + for(unsigned int a = 0; a < args.nargs(); a++){ S.push(atof(args.arg(a).c_str())); + R = S; + } } + else if(args.nargs() > 0 && args["interp"]){ + for(unsigned int a = 0; a < args.nargs(); a++){ + S.push(atof(args.arg(a).c_str())); + } + + for (unsigned int a = 0; a < args["interp"].nargs(); a++) + Si.push(args["interp"].as_float(a)); + + R = S+Si*0.0; + + + } //if the user wants to use a random set of SH coefficients else if(args["rand"].is_set()){ @@ -350,6 +380,7 @@ void process_arguments(int argc, char* argv[]){ { std::cout << i << sphere[i] << " " << weights[i] << std::endl; } + //std::cout << i << sphere[i] << " " << weights[i] << std::endl; stim::vec3 sph = sphere[i].cart2sph(); S.mcSample(sph[1], sph[2], weights[i]); } @@ -429,6 +460,8 @@ void process_arguments(int argc, char* argv[]){ std::cout<