diff --git a/examples/patches/example.cpp b/examples/patches/example.cpp index ea40f76bd..9a74158d2 100644 --- a/examples/patches/example.cpp +++ b/examples/patches/example.cpp @@ -75,6 +75,13 @@ enum RotationType NUM_ROTATION_TYPES = 2, } rotation_type; +enum OrientMethod +{ + ORIENT_METHOD_OUTWARD = 0, + ORIENT_METHOD_AO = 1, + NUM_ORIENT_METHODS = 2, +} orient_method = ORIENT_METHOD_AO; + std::stack undo_stack; std::stack redo_stack; @@ -97,6 +104,10 @@ Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0); #define REBAR_NAME "temp.rbr" igl::ReTwBar rebar; +// Forward +void init_patches(); +void init_relative(); + void push_undo() { undo_stack.push(s); @@ -112,6 +123,23 @@ void TW_CALL set_camera_rotation(const void * value, void *clientData) std::copy(quat,quat+4,s.camera.rotation); } +void TW_CALL set_orient_method(const void * value, void * clientData) +{ + const OrientMethod old_orient_method = orient_method; + orient_method = *(const OrientMethod *)value; + if(orient_method != old_orient_method) + { + init_patches(); + init_relative(); + } +} + +void TW_CALL get_orient_method(void * value, void *clientData) +{ + OrientMethod * om = (OrientMethod *)(value); + *om = orient_method; +} + void TW_CALL set_rotation_type(const void * value, void * clientData) { using namespace Eigen; @@ -539,20 +567,20 @@ void init_patches() } bfs_orient(F,F,CC); VectorXi I; - char c; - cout << "use ambient occlusion to determine patch orientation? (y/n):"; - cin >> c; - if (c == 'y') + switch(orient_method) { - orient_outward_ao(V,F,CC,F.rows() * 100,F,I); - } - else - { - orient_outward(V,F,CC,F,I); + case ORIENT_METHOD_AO: + cout<<"orient_outward_ao()"<"); + rebar.TwAddVarRW("wireframe_visible",TW_TYPE_BOOLCPP,&wireframe_visible,"key=l"); rebar.TwAddVarRW("fill_visible",TW_TYPE_BOOLCPP,&fill_visible,"key=f"); rebar.TwAddButton("randomize colors",randomize_colors,NULL,"key=c"); diff --git a/examples/patches/temp.rbr b/examples/patches/temp.rbr index de8af8813..b99b092cf 100644 --- a/examples/patches/temp.rbr +++ b/examples/patches/temp.rbr @@ -1,5 +1,6 @@ wireframe_visible: TW_TYPE_BOOLCPP 1 fill_visible: TW_TYPE_BOOLCPP 1 -camera_rotation: TW_TYPE_QUAT4D 0.20801 0.244181 0.0537125 0.945633 +camera_rotation: TW_TYPE_QUAT4D 0.0807446 0.213478 0.0177076 0.973444 rotation_type: RotationType two axis fixed up +orient_method: OrientMethod ambient occlusion