diff --git a/.gitignore b/.gitignore index 4a8e9eae7..8044c4cf0 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ external/mpfr external/boost external/.cache external/build +external/pybind11 .DS_Store libigl.zip *tags diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 334261809..000000000 --- a/.gitmodules +++ /dev/null @@ -1,33 +0,0 @@ -[submodule "external/embree"] - path = external/embree - url = https://github.com/embree/embree.git -[submodule "external/cgal"] - path = external/cgal - url = https://github.com/CGAL/cgal.git -[submodule "external/tetgen"] - path = external/tetgen - url = https://github.com/libigl/tetgen.git -[submodule "external/triangle"] - path = external/triangle - url = https://github.com/libigl/triangle.git -[submodule "external/tinyxml2"] - path = external/tinyxml2 - url = https://github.com/leethomason/tinyxml2.git -[submodule "external/CoMISo"] - path = external/CoMISo - url = https://github.com/libigl/CoMISo.git -[submodule "external/cork"] - path = external/cork - url = https://github.com/libigl/cork.git -[submodule "external/imgui"] - path = external/imgui/imgui - url = https://github.com/ocornut/imgui.git -[submodule "external/glfw"] - path = external/glfw - url = https://github.com/glfw/glfw.git -[submodule "external/eigen"] - path = external/eigen - url = https://github.com/eigenteam/eigen-git-mirror.git -[submodule "external/pybind11"] - path = external/pybind11 - url = https://github.com/pybind/pybind11 diff --git a/shared/cmake/CXXFeatures.cmake b/cmake/CXXFeatures.cmake similarity index 100% rename from shared/cmake/CXXFeatures.cmake rename to cmake/CXXFeatures.cmake diff --git a/shared/cmake/DownloadProject.CMakeLists.cmake.in b/cmake/DownloadProject.CMakeLists.cmake.in similarity index 100% rename from shared/cmake/DownloadProject.CMakeLists.cmake.in rename to cmake/DownloadProject.CMakeLists.cmake.in diff --git a/shared/cmake/DownloadProject.cmake b/cmake/DownloadProject.cmake similarity index 100% rename from shared/cmake/DownloadProject.cmake rename to cmake/DownloadProject.cmake diff --git a/shared/cmake/FindCORK.cmake b/cmake/FindCORK.cmake similarity index 100% rename from shared/cmake/FindCORK.cmake rename to cmake/FindCORK.cmake diff --git a/shared/cmake/FindMATLAB.cmake b/cmake/FindMATLAB.cmake similarity index 100% rename from shared/cmake/FindMATLAB.cmake rename to cmake/FindMATLAB.cmake diff --git a/shared/cmake/FindMOSEK.cmake b/cmake/FindMOSEK.cmake similarity index 100% rename from shared/cmake/FindMOSEK.cmake rename to cmake/FindMOSEK.cmake diff --git a/cmake/LibiglDownloadExternal.cmake b/cmake/LibiglDownloadExternal.cmake new file mode 100644 index 000000000..e03d9fef3 --- /dev/null +++ b/cmake/LibiglDownloadExternal.cmake @@ -0,0 +1,109 @@ +################################################################################ +include(DownloadProject) + +# Shortcut function +function(igl_download_project name) + download_project( + PROJ ${name} + SOURCE_DIR ${LIBIGL_EXTERNAL}/${name} + DOWNLOAD_DIR ${LIBIGL_EXTERNAL}/.cache/${name} + QUIET + ${ARGN} + ) +endfunction() + +################################################################################ + +## CGAL +function(igl_download_cgal) + igl_download_project(cgal + GIT_REPOSITORY https://github.com/CGAL/cgal.git + GIT_TAG f7c3c8212b56c0d6dae63787efc99093f4383415 + ) +endfunction() + +## CoMISo +function(igl_download_comiso) + igl_download_project(CoMISo + GIT_REPOSITORY https://github.com/libigl/CoMISo.git + GIT_TAG fea3ee0ba7d42ee3eca202d484e4fad855e4d6aa + ) +endfunction() + +## Cork +function(igl_download_cork) + igl_download_project(cork + GIT_REPOSITORY https://github.com/libigl/cork.git + GIT_TAG 27ad8a285838f5a480d856429e39d3d56d4338f9 + ) +endfunction() + +## Eigen +function(igl_download_eigen) + igl_download_project(eigen + URL http://bitbucket.org/eigen/eigen/get/3.2.10.tar.gz + URL_MD5 8ad10ac703a78143a4062c9bda9d8fd3 + ) +endfunction() + +## Embree +function(igl_download_embree) + igl_download_project(embree + URL https://github.com/embree/embree/archive/v2.17.4.tar.gz + URL_MD5 2038f3216b1d626e87453aee72c470e5 + # GIT_REPOSITORY https://github.com/embree/embree.git + # GIT_TAG cb61322db3bb7082caed21913ad14869b436fe78 + ) +endfunction() + +## GLFW +function(igl_download_glfw) + igl_download_project(glfw + GIT_REPOSITORY https://github.com/glfw/glfw.git + GIT_TAG 58cc4b2c5c2c9a245e09451437dd6f5af4d60c84 + ) +endfunction() + +## ImGui +function(igl_download_imgui) + download_project( + PROJ imgui + SOURCE_DIR ${LIBIGL_EXTERNAL}/imgui/imgui + DOWNLOAD_DIR ${LIBIGL_EXTERNAL}/.cache/${name} + GIT_REPOSITORY https://github.com/ocornut/imgui.git + GIT_TAG bc6ac8b2aee0614debd940e45bc9cd0d9b355c86 + ) +endfunction() + +## pybind11 +function(igl_download_pybind11) + igl_download_project(pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG 2d0507db43cd5a117f7843e053b17dffca114107 + ) +endfunction() + +## TetGen +function(igl_download_tetgen) + igl_download_project(tetgen + GIT_REPOSITORY https://github.com/libigl/tetgen.git + GIT_TAG d2dcc33cb8551f16e302c8130ce12fa52992cd09 + ) +endfunction() + +## TinyXML +function(igl_download_tinyxml2) + igl_download_project(tinyxml2 + GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git + GIT_TAG d175e9de0be0d4db75d0a8cf065599a435a87eb6 + ) +endfunction() + +## Triangle +function(igl_download_triangle) + igl_download_project(triangle + GIT_REPOSITORY https://github.com/libigl/triangle.git + GIT_TAG d6761dd691e2e1318c83bf7773fea88d9437464a + ) +endfunction() + diff --git a/shared/cmake/libigl-config.cmake.in b/cmake/libigl-config.cmake.in similarity index 100% rename from shared/cmake/libigl-config.cmake.in rename to cmake/libigl-config.cmake.in diff --git a/shared/cmake/libigl.cmake b/cmake/libigl.cmake similarity index 92% rename from shared/cmake/libigl.cmake rename to cmake/libigl.cmake index 6728f0fc8..2bd680ec6 100644 --- a/shared/cmake/libigl.cmake +++ b/cmake/libigl.cmake @@ -27,17 +27,15 @@ find_package(OpenGL) # --> OPENGL_FOUND ### Available options ### option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" ON) -option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" OFF) option(LIBIGL_WITH_CGAL "Use CGAL" ON) option(LIBIGL_WITH_COMISO "Use CoMiso" ON) option(LIBIGL_WITH_CORK "Use Cork" OFF) option(LIBIGL_WITH_EMBREE "Use Embree" OFF) -option(LIBIGL_WITH_LIM "Use LIM" ON) option(LIBIGL_WITH_MATLAB "Use Matlab" "${Matlab_FOUND}") option(LIBIGL_WITH_MOSEK "Use MOSEK" "${MOSEK_FOUND}") option(LIBIGL_WITH_OPENGL "Use OpenGL" "${OPENGL_FOUND}") option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" "${OPENGL_FOUND}") -option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" ON) +option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" "${OPENGL_FOUND}") option(LIBIGL_WITH_PNG "Use PNG" ON) option(LIBIGL_WITH_TETGEN "Use Tetgen" ON) option(LIBIGL_WITH_TRIANGLE "Use Triangle" ON) @@ -52,7 +50,7 @@ endif() ################################################################################ ### Configuration -set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..") +set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/..") set(LIBIGL_SOURCE_DIR "${LIBIGL_ROOT}/include") set(LIBIGL_EXTERNAL "${LIBIGL_ROOT}/external") @@ -63,6 +61,10 @@ else() set(IGL_SCOPE INTERFACE) endif() +# Download and update 3rdparty libraries +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +include(LibiglDownloadExternal) + ################################################################################ ### IGL Common ################################################################################ @@ -86,6 +88,9 @@ target_compile_features(igl_common INTERFACE ${CXX11_FEATURES}) if(MSVC) # Enable parallel compilation for Visual Studio target_compile_options(igl_common INTERFACE /MP /bigobj) + if(LIBIGL_WITH_CGAL) + target_compile_options(igl_common INTERFACE "/MD$<$:d>") + endif() endif() if(BUILD_SHARED_LIBS) @@ -98,7 +103,8 @@ if(TARGET Eigen3::Eigen) # If an imported target already exists, use it target_link_libraries(igl_common INTERFACE Eigen3::Eigen) else() - target_include_directories(igl_common SYSTEM INTERFACE + igl_download_eigen() + target_include_directories(igl_common SYSTEM INTERFACE $ $ ) @@ -110,20 +116,6 @@ target_link_libraries(igl_common INTERFACE ${CMAKE_THREAD_LIBS_INIT}) ################################################################################ -include(DownloadProject) - -# Shortcut function -function(igl_download_project name) - download_project( - PROJ ${name} - SOURCE_DIR ${LIBIGL_EXTERNAL}/${name} - DOWNLOAD_DIR ${LIBIGL_EXTERNAL}/.cache/${name} - ${ARGN} - ) -endfunction() - -################################################################################ - ## CGAL dependencies on Windows: GMP & MPFR function(igl_download_cgal_deps) if(WIN32) @@ -175,7 +167,6 @@ function(compile_igl_module module_dir) set_property(TARGET ${module_libname} PROPERTY EXPORT_NAME igl::${module_name}) endfunction() - ################################################################################ ### IGL Core ################################################################################ @@ -188,15 +179,9 @@ endif() compile_igl_module("core" ${SOURCES_IGL}) ################################################################################ -## Compile the AntTweakBar part ### -if(LIBIGL_WITH_ANTTWEAKBAR) - set(ANTTWEAKBAR_DIR "${LIBIGL_EXTERNAL}/AntTweakBar") - if(NOT TARGET AntTweakBar) - add_subdirectory("${ANTTWEAKBAR_DIR}" AntTweakBar) - endif() - compile_igl_module("anttweakbar") - target_link_libraries(igl_anttweakbar ${IGL_SCOPE} AntTweakBar) - target_include_directories(igl_anttweakbar ${IGL_SCOPE} "${ANTTWEAKBAR_DIR}/include") +### Download the python part ### +if(LIBIGL_WITH_PYTHON) + igl_download_pybind11() endif() ################################################################################ @@ -207,6 +192,7 @@ if(LIBIGL_WITH_CGAL) # `Exact_predicates_exact_constructions_kernel_with_sqrt` if(NOT TARGET CGAL::CGAL) set(CGAL_DIR "${LIBIGL_EXTERNAL}/cgal") + igl_download_cgal() igl_download_cgal_deps() if(EXISTS ${LIBIGL_EXTERNAL}/boost) set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost") @@ -253,6 +239,7 @@ endfunction() if(LIBIGL_WITH_COMISO) compile_igl_module("comiso") if(NOT TARGET CoMISo) + igl_download_comiso() add_subdirectory("${LIBIGL_EXTERNAL}/CoMISo" CoMISo) endif() target_link_libraries(igl_comiso ${IGL_SCOPE} CoMISo) @@ -265,6 +252,7 @@ if(LIBIGL_WITH_CORK) if(NOT TARGET cork) # call this "lib-cork" instead of "cork", otherwise cmake gets confused about # "cork" executable + igl_download_cork() add_subdirectory("${CORK_DIR}" "lib-cork") endif() compile_igl_module("cork") @@ -293,6 +281,7 @@ if(LIBIGL_WITH_EMBREE) endif() if(NOT TARGET embree) + igl_download_embree() add_subdirectory("${EMBREE_DIR}" "embree") endif() @@ -312,18 +301,6 @@ if(LIBIGL_WITH_EMBREE) endif() endif() -################################################################################ -### Compile the lim part ### -if(LIBIGL_WITH_LIM) - set(LIM_DIR "${LIBIGL_EXTERNAL}/lim") - if(NOT TARGET lim) - add_subdirectory("${LIM_DIR}" "lim") - endif() - compile_igl_module("lim") - target_link_libraries(igl_lim ${IGL_SCOPE} lim) - target_include_directories(igl_lim ${IGL_SCOPE} ${LIM_DIR}) -endif() - ################################################################################ ### Compile the matlab part ### if(LIBIGL_WITH_MATLAB) @@ -370,6 +347,7 @@ if(LIBIGL_WITH_OPENGL_GLFW) set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE) set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE) set(GLFW_INSTALL OFF CACHE BOOL " " FORCE) + igl_download_glfw() add_subdirectory(${LIBIGL_EXTERNAL}/glfw glfw) endif() target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw) @@ -383,6 +361,7 @@ if(LIBIGL_WITH_OPENGL_GLFW_IMGUI) # ImGui module compile_igl_module("opengl/glfw/imgui") if(NOT TARGET imgui) + igl_download_imgui() add_subdirectory(${LIBIGL_EXTERNAL}/imgui imgui) endif() target_link_libraries(igl_opengl_glfw_imgui ${IGL_SCOPE} igl_opengl_glfw imgui) @@ -409,6 +388,7 @@ endif() if(LIBIGL_WITH_TETGEN) set(TETGEN_DIR "${LIBIGL_EXTERNAL}/tetgen") if(NOT TARGET tetgen) + igl_download_tetgen() add_subdirectory("${TETGEN_DIR}" "tetgen") endif() compile_igl_module("tetgen") @@ -421,6 +401,7 @@ endif() if(LIBIGL_WITH_TRIANGLE) set(TRIANGLE_DIR "${LIBIGL_EXTERNAL}/triangle") if(NOT TARGET triangle) + igl_download_triangle() add_subdirectory("${TRIANGLE_DIR}" "triangle") endif() compile_igl_module("triangle") @@ -433,7 +414,9 @@ endif() if(LIBIGL_WITH_XML) set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2") if(NOT TARGET tinyxml2) + igl_download_tinyxml2() add_library(tinyxml2 STATIC ${TINYXML2_DIR}/tinyxml2.cpp ${TINYXML2_DIR}/tinyxml2.h) + target_include_directories(tinyxml2 PUBLIC ${TINYXML2_DIR}) set_target_properties(tinyxml2 PROPERTIES COMPILE_DEFINITIONS "TINYXML2_EXPORT" VERSION "3.0.0" diff --git a/include/igl/anttweakbar/ReAntTweakBar.cpp b/include/igl/anttweakbar/ReAntTweakBar.cpp deleted file mode 100644 index 3664c6bce..000000000 --- a/include/igl/anttweakbar/ReAntTweakBar.cpp +++ /dev/null @@ -1,934 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "ReAntTweakBar.h" - -#include -#include -#include -#include -#include -#include - -// GLOBAL WRAPPERS -namespace -{ - std::map< - TwType,std::pair > - > ReTw_custom_types; -} - -IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnum( - const char *name, - const TwEnumVal *enumValues, - unsigned int nbValues) -{ - using namespace std; - // copy enum valus into vector - std::vector enum_vals; - enum_vals.resize(nbValues); - for(unsigned int j = 0; j >(name,enum_vals); - - return type; -} - -IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnumFromString( - const char * _Name, - const char * _EnumString) -{ - // Taken directly from TwMgr.cpp, just replace TwDefineEnum with - // ReTwDefineEnum - using namespace std; - { - if (_EnumString == NULL) - return ReTwDefineEnum(_Name, NULL, 0); - - // split enumString - stringstream EnumStream(_EnumString); - string Label; - vector Labels; - while( getline(EnumStream, Label, ',') ) { - // trim Label - size_t Start = Label.find_first_not_of(" \n\r\t"); - size_t End = Label.find_last_not_of(" \n\r\t"); - if( Start==string::npos || End==string::npos ) - Label = ""; - else - Label = Label.substr(Start, (End-Start)+1); - // store Label - Labels.push_back(Label); - } - // create TwEnumVal array - vector Vals(Labels.size()); - for( int i=0; i<(int)Labels.size(); i++ ) - { - Vals[i].Value = i; - // Wrong: - //Vals[i].Label = Labels[i].c_str(); - // Allocate char on heap - // http://stackoverflow.com/a/10050258/148668 - char * c_label = new char[Labels[i].length()+1]; - std::strcpy(c_label, Labels[i].c_str()); - Vals[i].Label = c_label; - } - - const TwType type = - ReTwDefineEnum(_Name, Vals.empty() ? - NULL : - &(Vals[0]), (unsigned int)Vals.size()); - return type; - } -} - -namespace -{ - struct ReTwTypeString - { - TwType type; - const char * type_str; - }; - - #define RETW_NUM_DEFAULT_TYPE_STRINGS 23 - ReTwTypeString ReTwDefaultTypeStrings[RETW_NUM_DEFAULT_TYPE_STRINGS] = - { - {TW_TYPE_UNDEF,"TW_TYPE_UNDEF"}, - {TW_TYPE_BOOLCPP,"TW_TYPE_BOOLCPP"}, - {TW_TYPE_BOOL8,"TW_TYPE_BOOL8"}, - {TW_TYPE_BOOL16,"TW_TYPE_BOOL16"}, - {TW_TYPE_BOOL32,"TW_TYPE_BOOL32"}, - {TW_TYPE_CHAR,"TW_TYPE_CHAR"}, - {TW_TYPE_INT8,"TW_TYPE_INT8"}, - {TW_TYPE_UINT8,"TW_TYPE_UINT8"}, - {TW_TYPE_INT16,"TW_TYPE_INT16"}, - {TW_TYPE_UINT16,"TW_TYPE_UINT16"}, - {TW_TYPE_INT32,"TW_TYPE_INT32"}, - {TW_TYPE_UINT32,"TW_TYPE_UINT32"}, - {TW_TYPE_FLOAT,"TW_TYPE_FLOAT"}, - {TW_TYPE_DOUBLE,"TW_TYPE_DOUBLE"}, - {TW_TYPE_COLOR32,"TW_TYPE_COLOR32"}, - {TW_TYPE_COLOR3F,"TW_TYPE_COLOR3F"}, - {TW_TYPE_COLOR4F,"TW_TYPE_COLOR4F"}, - {TW_TYPE_CDSTRING,"TW_TYPE_CDSTRING"}, - {TW_TYPE_STDSTRING,"TW_TYPE_STDSTRING"}, - {TW_TYPE_QUAT4F,"TW_TYPE_QUAT4F"}, - {TW_TYPE_QUAT4D,"TW_TYPE_QUAT4D"}, - {TW_TYPE_DIR3F,"TW_TYPE_DIR3F"}, - {TW_TYPE_DIR3D,"TW_TYPE_DIR3D"} - }; -} - -IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar(): - bar(NULL), - name(), - rw_items(),cb_items() -{ -} - -IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar( - const igl::anttweakbar::ReTwBar & that): - bar(that.bar), - name(that.name), - rw_items(that.rw_items), - cb_items(that.cb_items) -{ -} - -IGL_INLINE igl::anttweakbar::ReTwBar & -igl::anttweakbar::ReTwBar::operator=(const igl::anttweakbar::ReTwBar & that) -{ - // check for self assignment - if(this != &that) - { - bar = that.bar; - rw_items = that.rw_items; - cb_items = that.cb_items; - } - return *this; -} - - -// BAR WRAPPERS -IGL_INLINE void igl::anttweakbar::ReTwBar::TwNewBar(const char * _name) -{ - this->bar = ::TwNewBar(_name); - // Alec: This causes trouble (not sure why) in multiple applications - // (medit, puppet) Probably there is some sort of memory corrpution. - // this->name = _name; - // Suspiciously this also fails: - //this->name = "foobar"; -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRW( - const char *name, - TwType type, - void *var, - const char *def, - const bool record) -{ - int ret = ::TwAddVarRW(this->bar,name,type,var,def); - if(ret && record) - { - rw_items.push_back(ReTwRWItem(name,type,var)); - } - return ret; -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarCB( - const char *name, - TwType type, - TwSetVarCallback setCallback, - TwGetVarCallback getCallback, - void *clientData, - const char *def, - const bool record) -{ - int ret = - ::TwAddVarCB(this->bar,name,type,setCallback,getCallback,clientData,def); - if(ret && record) - { - cb_items.push_back(ReTwCBItem(name,type,setCallback,getCallback,clientData)); - } - return ret; -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRO( - const char *name, - TwType type, - void *var, - const char *def) -{ - int ret = ::TwAddVarRO(this->bar,name,type,var,def); - // Read only variables are not recorded - //if(ret) - //{ - // rw_items.push_back(ReTwRWItem(name,type,var)); - //} - return ret; -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddButton( - const char *name, - TwButtonCallback buttonCallback, - void *clientData, - const char *def) -{ - int ret = - ::TwAddButton(this->bar,name,buttonCallback,clientData,def); - // buttons are not recorded - //if(ret) - //{ - // cb_items.push_back(ReTwCBItem(name,type,setCallback,getCallback,clientData)); - //} - return ret; -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwSetParam( - const char *varName, - const char *paramName, - TwParamValueType paramValueType, - unsigned int inValueCount, - const void *inValues) -{ - // For now just pass these along - return - ::TwSetParam( - this->bar, - varName, - paramName, - paramValueType, - inValueCount, - inValues); -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwGetParam( - const char *varName, - const char *paramName, - TwParamValueType paramValueType, - unsigned int outValueMaxCount, - void *outValues) -{ - return - ::TwGetParam( - this->bar, - varName, - paramName, - paramValueType, - outValueMaxCount, - outValues); -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwRefreshBar() -{ - return ::TwRefreshBar(this->bar); -} - -IGL_INLINE int igl::anttweakbar::ReTwBar::TwTerminate() -{ - //std::cout<<"TwTerminate"<::iterator it = rw_items.begin(); - it != rw_items.end(); - it++) - { - std::string s = (*it).name; - const char * name = s.c_str(); - TwType type = (*it).type; - void * var = (*it).var; - fprintf(fp,"%s: %s\n", - name, - get_value_as_string(var,type).c_str()); - } - - char var[REANTTWEAKBAR_MAX_CB_VAR_SIZE]; - // Print all CB variables - for( - std::vector::iterator it = cb_items.begin(); - it != cb_items.end(); - it++) - { - const char * name = it->name.c_str(); - TwType type = it->type; - //TwSetVarCallback setCallback = it->setCallback; - TwGetVarCallback getCallback = it->getCallback; - void * clientData = it->clientData; - // I'm not sure how to do what I want to do. getCallback needs to be sure - // that it can write to var. So var needs to point to a valid and big - // enough chunk of memory - getCallback(var,clientData); - fprintf(fp,"%s: %s\n", - name, - get_value_as_string(var,type).c_str()); - } - - fprintf(fp,"\n"); - - if(file_name != NULL) - { - fclose(fp); - } - // everything succeeded - return true; -} - -IGL_INLINE std::string igl::anttweakbar::ReTwBar::get_value_as_string( - void * var, - TwType type) -{ - std::stringstream sstr; - switch(type) - { - case TW_TYPE_BOOLCPP: - { - sstr << "TW_TYPE_BOOLCPP" << " "; - sstr << *(static_cast(var)); - break; - } - case TW_TYPE_QUAT4D: - { - sstr << "TW_TYPE_QUAT4D" << " "; - // Q: Why does casting to double* work? shouldn't I have to cast to - // double**? - double * q = static_cast(var); - sstr << std::setprecision(15) << q[0] << " " << q[1] << " " << q[2] << " " << q[3]; - break; - } - case TW_TYPE_QUAT4F: - { - sstr << "TW_TYPE_QUAT4F" << " "; - // Q: Why does casting to float* work? shouldn't I have to cast to - // float**? - float * q = static_cast(var); - sstr << q[0] << " " << q[1] << " " << q[2] << " " << q[3]; - break; - } - case TW_TYPE_COLOR4F: - { - sstr << "TW_TYPE_COLOR4F" << " "; - float * c = static_cast(var); - sstr << c[0] << " " << c[1] << " " << c[2] << " " << c[3]; - break; - } - case TW_TYPE_COLOR3F: - { - sstr << "TW_TYPE_COLOR3F" << " "; - float * c = static_cast(var); - sstr << c[0] << " " << c[1] << " " << c[2]; - break; - } - case TW_TYPE_DIR3D: - { - sstr << "TW_TYPE_DIR3D" << " "; - double * d = static_cast(var); - sstr << std::setprecision(15) << d[0] << " " << d[1] << " " << d[2]; - break; - } - case TW_TYPE_DIR3F: - { - sstr << "TW_TYPE_DIR3F" << " "; - float * d = static_cast(var); - sstr << d[0] << " " << d[1] << " " << d[2]; - break; - } - case TW_TYPE_BOOL32: - { - sstr << "TW_TYPE_BOOL32" << " "; - sstr << *(static_cast(var)); - break; - } - case TW_TYPE_UINT8: - { - sstr << "TW_TYPE_UINT8" << " "; - // Cast to int so that it's human readable - sstr << (int)*(static_cast(var)); - break; - } - case TW_TYPE_INT32: - { - sstr << "TW_TYPE_INT32" << " "; - sstr << *(static_cast(var)); - break; - } - case TW_TYPE_UINT32: - { - sstr << "TW_TYPE_UINT32" << " "; - sstr << *(static_cast(var)); - break; - } - case TW_TYPE_FLOAT: - { - sstr << "TW_TYPE_FLOAT" << " "; - sstr << *(static_cast(var)); - break; - } - case TW_TYPE_DOUBLE: - { - sstr << "TW_TYPE_DOUBLE" << " "; - sstr << std::setprecision(15) << *(static_cast(var)); - break; - } - case TW_TYPE_STDSTRING: - { - sstr << "TW_TYPE_STDSTRING" << " "; - std::string *destPtr = static_cast(var); - sstr << destPtr->c_str(); - break; - } - default: - { - using namespace std; - std::map > >::const_iterator iter = - ReTw_custom_types.find(type); - if(iter != ReTw_custom_types.end()) - { - sstr << (*iter).second.first << " "; - int enum_val = *(static_cast(var)); - // try find display name for enum value - std::vector::const_iterator eit = (*iter).second.second.begin(); - bool found = false; - for(;eit<(*iter).second.second.end();eit++) - { - if(enum_val == eit->Value) - { - sstr << eit->Label; - found = true; - break; - } - } - if(!found) - { - sstr << "ERROR_ENUM_VALUE_NOT_DEFINED"; - } - }else - { - sstr << "ERROR_TYPE_NOT_SUPPORTED"; - } - break; - } - } - return sstr.str(); -} - -IGL_INLINE bool igl::anttweakbar::ReTwBar::load(const char *file_name) -{ - FILE * fp; - fp = fopen(file_name,"r"); - - if(fp == NULL) - { - printf("ERROR: not able to open %s for reading...\n",file_name); - return false; - } - - // go through file line by line - char line[REANTTWEAKBAR_MAX_LINE]; - bool still_comments; - char name[REANTTWEAKBAR_MAX_WORD]; - char type_str[REANTTWEAKBAR_MAX_WORD]; - char value_str[REANTTWEAKBAR_MAX_WORD]; - - - // line number - int j = 0; - bool finished = false; - while(true) - { - // Eat comments - still_comments = true; - while(still_comments) - { - if(fgets(line,REANTTWEAKBAR_MAX_LINE,fp) == NULL) - { - finished = true; - break; - } - // Blank lines and lines that begin with # are comments - still_comments = (line[0] == '#' || line[0] == '\n'); - j++; - } - if(finished) - { - break; - } - - sscanf(line,"%[^:]: %s %[^\n]",name,type_str,value_str); - //printf("%s: %s %s\n",name, type_str,value_str); - - TwType type; - if(!type_from_string(type_str,type)) - { - printf("ERROR: %s type not found... Skipping...\n",type_str); - continue; - } - set_value_from_string(name,type,value_str); - - } - - fclose(fp); - - // everything succeeded - return true; -} - -IGL_INLINE bool igl::anttweakbar::ReTwBar::type_from_string( - const char *type_str, TwType & type) -{ - // first check default types - for(int j = 0; j < RETW_NUM_DEFAULT_TYPE_STRINGS; j++) - { - if(strcmp(type_str,ReTwDefaultTypeStrings[j].type_str) == 0) - { - type = ReTwDefaultTypeStrings[j].type; - return true; - break; - } - } - - // then check custom types - std::map< - TwType,std::pair > - >::const_iterator iter = - ReTw_custom_types.begin(); - for(;iter != ReTw_custom_types.end(); iter++) - { - if(strcmp((*iter).second.first,type_str)==0) - { - type = (*iter).first; - return true; - } - } - return false; -} - -bool igl::anttweakbar::ReTwBar::set_value_from_string( - const char * name, - TwType type, - const char * value_str) -{ - void * value = NULL; - // possible value slots - int i; - float v; - double dv; - float f[4]; - double d[4]; - bool b; - unsigned int u; - unsigned char uc; - std::string s; - - // First try to get value from default types - switch(type) - { - case TW_TYPE_BOOLCPP: - { - int ib; - if(sscanf(value_str," %d",&ib) == 1) - { - b = ib!=0; - value = &b; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_QUAT4D: - //case TW_TYPE_COLOR4D: - { - if(sscanf(value_str," %lf %lf %lf %lf",&d[0],&d[1],&d[2],&d[3]) == 4) - { - value = &d; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_QUAT4F: - case TW_TYPE_COLOR4F: - { - if(sscanf(value_str," %f %f %f %f",&f[0],&f[1],&f[2],&f[3]) == 4) - { - value = &f; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - //case TW_TYPE_COLOR3D: - case TW_TYPE_DIR3D: - { - if(sscanf(value_str," %lf %lf %lf",&d[0],&d[1],&d[2]) == 3) - { - value = &d; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_COLOR3F: - case TW_TYPE_DIR3F: - { - if(sscanf(value_str," %f %f %f",&f[0],&f[1],&f[2]) == 3) - { - value = &f; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_UINT8: - { - if(sscanf(value_str," %d",&i) == 1) - { - // Cast to unsigned char - uc = (unsigned char) i; - value = &uc; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_BOOL32: - case TW_TYPE_INT32: - { - if(sscanf(value_str," %d",&i) == 1) - { - value = &i; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_UINT32: - { - if(sscanf(value_str," %u",&u) == 1) - { - value = &u; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_FLOAT: - { - if(sscanf(value_str," %f",&v) == 1) - { - value = &v; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_DOUBLE: - { - if(sscanf(value_str," %lf",&dv) == 1) - { - value = &dv; - }else - { - printf("ERROR: Bad value format...\n"); - return false; - } - break; - } - case TW_TYPE_STDSTRING: - { - s = value_str; - value = &s; - break; - } - default: - // Try to find type in custom enum types - std::map > >::const_iterator iter = - ReTw_custom_types.find(type); - if(iter != ReTw_custom_types.end()) - { - std::vector::const_iterator eit = (*iter).second.second.begin(); - bool found = false; - for(;eit<(*iter).second.second.end();eit++) - { - if(strcmp(value_str,eit->Label) == 0) - { - i = eit->Value; - value = &i; - found = true; - break; - } - } - if(!found) - { - printf("ERROR_ENUM_VALUE_NOT_DEFINED"); - } - }else - { - printf("ERROR_TYPE_NOT_SUPPORTED\n"); - } - - break; - } - - - // Find variable based on name - // First look in RW items - bool item_found = false; - for( - std::vector::iterator it = rw_items.begin(); - it != rw_items.end(); - it++) - { - if(it->name == name) - { - void * var = it->var; - switch(type) - { - case TW_TYPE_BOOLCPP: - { - bool * bvar = static_cast(var); - bool * bvalue = static_cast(value); - *bvar = *bvalue; - break; - } - case TW_TYPE_QUAT4D: - //case TW_TYPE_COLOR4D: - { - double * dvar = static_cast(var); - double * dvalue = static_cast(value); - dvar[0] = dvalue[0]; - dvar[1] = dvalue[1]; - dvar[2] = dvalue[2]; - dvar[3] = dvalue[3]; - break; - } - case TW_TYPE_QUAT4F: - case TW_TYPE_COLOR4F: - { - float * fvar = static_cast(var); - float * fvalue = static_cast(value); - fvar[0] = fvalue[0]; - fvar[1] = fvalue[1]; - fvar[2] = fvalue[2]; - fvar[3] = fvalue[3]; - break; - } - //case TW_TYPE_COLOR3D: - case TW_TYPE_DIR3D: - { - double * dvar = static_cast(var); - double * dvalue = static_cast(value); - dvar[0] = dvalue[0]; - dvar[1] = dvalue[1]; - dvar[2] = dvalue[2]; - break; - } - case TW_TYPE_COLOR3F: - case TW_TYPE_DIR3F: - { - float * fvar = static_cast(var); - float * fvalue = static_cast(value); - fvar[0] = fvalue[0]; - fvar[1] = fvalue[1]; - fvar[2] = fvalue[2]; - break; - } - case TW_TYPE_UINT8: - { - unsigned char * ucvar = static_cast(var); - unsigned char * ucvalue = static_cast(value); - *ucvar = *ucvalue; - break; - } - case TW_TYPE_BOOL32: - case TW_TYPE_INT32: - { - int * ivar = static_cast(var); - int * ivalue = static_cast(value); - *ivar = *ivalue; - break; - } - case TW_TYPE_UINT32: - { - unsigned int * uvar = static_cast(var); - unsigned int * uvalue = static_cast(value); - *uvar = *uvalue; - break; - } - case TW_TYPE_FLOAT: - { - float * fvar = static_cast(var); - float * fvalue = static_cast(value); - *fvar = *fvalue; - break; - } - case TW_TYPE_DOUBLE: - { - double * dvar = static_cast(var); - double * fvalue = static_cast(value); - *dvar = *fvalue; - break; - } - case TW_TYPE_STDSTRING: - { - std::string * svar = static_cast(var); - std::string * svalue = static_cast(value); - *svar = *svalue; - break; - } - default: - // Try to find type in custom enum types - std::map > >::iterator iter = - ReTw_custom_types.find(type); - if(iter != ReTw_custom_types.end()) - { - int * ivar = static_cast(var); - std::vector::iterator eit = (*iter).second.second.begin(); - bool found = false; - for(;eit<(*iter).second.second.end();eit++) - { - if(strcmp(value_str,eit->Label) == 0) - { - *ivar = eit->Value; - found = true; - break; - } - } - if(!found) - { - printf("ERROR_ENUM_VALUE_NOT_DEFINED"); - } - }else - { - printf("ERROR_TYPE_NOT_SUPPORTED\n"); - } - break; - } - item_found = true; - break; - } - } - - // Try looking in CB items - if(!item_found) - { - for( - std::vector::iterator it = cb_items.begin(); - it != cb_items.end(); - it++) - { - if(it->name==name) - { - it->setCallback(value,it->clientData); - item_found = true; - break; - } - } - } - - if(!item_found) - { - printf("ERROR: item '%s' not found\n",name); - } - return true; -} - -IGL_INLINE const std::vector & - igl::anttweakbar::ReTwBar::get_rw_items() -{ - return rw_items; -} - -IGL_INLINE const std::vector & - igl::anttweakbar::ReTwBar::get_cb_items() -{ - return cb_items; -} diff --git a/include/igl/anttweakbar/ReAntTweakBar.h b/include/igl/anttweakbar/ReAntTweakBar.h deleted file mode 100644 index d1dede927..000000000 --- a/include/igl/anttweakbar/ReAntTweakBar.h +++ /dev/null @@ -1,286 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_ANTTWEAKBAR_REANTTWEAKBAR_H -#define IGL_ANTTWEAKBAR_REANTTWEAKBAR_H -#include "../igl_inline.h" -// ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows -// "bars" to be saved and load from disk. Changing your existing app that uses -// AntTweakBar to use ReAntTweakBar is trivial. -// -// Many (but not all) variable types are supported. I'll try to keep track them -// here: -// TW_TYPE_BOOLCPP -// TW_TYPE_QUAT4F -// TW_TYPE_QUAT4D -// TW_TYPE_COLOR4F -// TW_TYPE_COLOR4D -// TW_TYPE_COLOR3F -// TW_TYPE_DIR3F -// TW_TYPE_DIR3D -// TW_TYPE_BOOL32 -// TW_TYPE_INT32 -// TW_TYPE_UINT32 -// TW_TYPE_FLOAT -// TW_TYPE_DOUBLE -// TW_TYPE_UINT8 -// and -// custom TwTypes made with TwDefineEnum -// -// I'm working on adding the rest on an as-needed basis. Adding a new type only -// requires changes in a few places... -// -// -// - -// This allows the user to have a non-global, static installation of -// AntTweakBar -#include -// Instead of including AntTweakBar.h, just define the necessary types -// Types used: -// - TwType -// - TwEnumVal -// - TwSetVarCallback -// - TwGetVarCallback -// - TwBar -// - TwButtonCallback - - -#include -#include - -#define REANTTWEAKBAR_MAX_CB_VAR_SIZE 1000 -// Max line size for reading files -#define REANTTWEAKBAR_MAX_LINE 1000 -#define REANTTWEAKBAR_MAX_WORD 100 - -namespace igl -{ - namespace anttweakbar - { - TwType ReTwDefineEnum( - const char *name, - const TwEnumVal *enumValues, - unsigned int nbValues); - TwType ReTwDefineEnumFromString(const char * name,const char * enumString); - - struct ReTwRWItem - { - //const char * name; - std::string name; - TwType type; - void * var; - // Default constructor - IGL_INLINE ReTwRWItem( - const std::string _name, - TwType _type, - void *_var): - name(_name), - type(_type), - var(_var) - { - } - // Shallow copy constructor - // I solemnly swear it's OK to copy var this way - // Q: Is it really? - IGL_INLINE ReTwRWItem(const ReTwRWItem & that): - name(that.name), - type(that.type), - var(that.var) - { - } - // Shallow assignment - // I solemnly swear it's OK to copy var this way - IGL_INLINE ReTwRWItem & operator=(const ReTwRWItem & that) - { - if(this != &that) - { - this->name = that.name; - this->type = that.type; - this->var = that.var; - } - return *this; - } - }; - - struct ReTwCBItem - { - //const char * name; - std::string name; - TwType type; - TwSetVarCallback setCallback; - TwGetVarCallback getCallback; - void * clientData; - // Default constructor - IGL_INLINE ReTwCBItem( - const std::string _name, - TwType _type, - TwSetVarCallback _setCallback, - TwGetVarCallback _getCallback, - void * _clientData): - name(_name), - type(_type), - setCallback(_setCallback), - getCallback(_getCallback), - clientData(_clientData) - { - } - // Shallow copy - // I solemnly swear it's OK to copy clientData this way - IGL_INLINE ReTwCBItem(const ReTwCBItem & that): - name(that.name), - type(that.type), - setCallback(that.setCallback), - getCallback(that.getCallback), - clientData(that.clientData) - { - } - // Shallow assignment - // I solemnly swear it's OK to copy clientData this way - IGL_INLINE ReTwCBItem & operator=(const ReTwCBItem & that) - { - if(this != &that) - { - name = that.name; - type = that.type; - setCallback = that.setCallback; - getCallback = that.getCallback; - clientData = that.clientData; - } - return *this; - } - - }; - - class ReTwBar - { - // VARIABLES - // Should be private, but seeing as I'm not going to implement all of the - // AntTweakBar public functions right away, I'll expose this so that at - // anytime AntTweakBar functions can be called directly on the bar - public: - TwBar * bar; - std::string name; - protected: - std::vector rw_items; - std::vector cb_items; - public: - // Default constructor with explicit initialization - IGL_INLINE ReTwBar(); - private: - // Copy constructor does shallow copy - IGL_INLINE ReTwBar(const ReTwBar & that); - // Assignment operator does shallow assignment - IGL_INLINE ReTwBar &operator=(const ReTwBar & that); - - // WRAPPERS FOR ANTTWEAKBAR FUNCTIONS - public: - IGL_INLINE void TwNewBar(const char *_name); - IGL_INLINE int TwAddVarRW( - const char *name, - TwType type, - void *var, - const char *def, - const bool record=true); - IGL_INLINE int TwAddVarCB( - const char *name, - TwType type, - TwSetVarCallback setCallback, - TwGetVarCallback getCallback, - void *clientData, - const char *def, - const bool record=true); - // Wrappers for convenience (not recorded, just passed on) - IGL_INLINE int TwAddVarRO(const char *name, TwType type, void *var, const char *def); - IGL_INLINE int TwAddButton( - const char *name, - TwButtonCallback buttonCallback, - void *clientData, - const char *def); - IGL_INLINE int TwSetParam( - const char *varName, - const char *paramName, - TwParamValueType paramValueType, - unsigned int inValueCount, - const void *inValues); - IGL_INLINE int TwGetParam( - const char *varName, - const char *paramName, - TwParamValueType paramValueType, - unsigned int outValueMaxCount, - void *outValues); - IGL_INLINE int TwRefreshBar(); - IGL_INLINE int TwTerminate(); - - - // IO FUNCTIONS - public: - // Save current items to file - // Input: - // file_name name of file to save data to, can be null which means print - // to stdout - // Return: - // true only if there were no (fatal) errors - IGL_INLINE bool save(const char *file_name); - std::string get_value_as_string( - void * var, - TwType type); - // Load into current items from file - // Input: - // file_name name of input file to load - // Return: - // true only if there were no (fatal) errors - IGL_INLINE bool load(const char *file_name); - // Get TwType from string - // Input - // type_str string of type - // Output - // type TwType converted from string - // Returns - // true only if string matched a valid type - IGL_INLINE bool type_from_string(const char *type_str, TwType & type); - // I realize that I mix std::string and const char * all over the place. - // What can you do... - IGL_INLINE bool set_value_from_string( - const char * name, - TwType type, - const char * value_str); - IGL_INLINE const std::vector & get_rw_items(); - IGL_INLINE const std::vector & get_cb_items(); - }; - } -} - -// List of TwBar functions -//TW_API TwBar * TW_CALL TwNewBar(const char *barName); -//TW_API int TW_CALL TwDeleteBar(TwBar *bar); -//TW_API int TW_CALL TwDeleteAllBars(); -//TW_API int TW_CALL TwSetTopBar(const TwBar *bar); -//TW_API TwBar * TW_CALL TwGetTopBar(); -//TW_API int TW_CALL TwSetBottomBar(const TwBar *bar); -//TW_API TwBar * TW_CALL TwGetBottomBar(); -//TW_API const char * TW_CALL TwGetBarName(TwBar *bar); -//TW_API int TW_CALL TwGetBarCount(); -//TW_API TwBar * TW_CALL TwGetBarByIndex(int barIndex); -//TW_API TwBar * TW_CALL TwGetBarByName(const char *barName); -//TW_API int TW_CALL TwRefreshBar(TwBar *bar); -//TW_API int TW_CALL TwTerminate(); -// -//TW_API int TW_CALL TwAddVarRW(TwBar *bar, const char *name, TwType type, void *var, const char *def); -//TW_API int TW_CALL TwAddVarRO(TwBar *bar, const char *name, TwType type, const void *var, const char *def); -//TW_API int TW_CALL TwAddVarCB(TwBar *bar, const char *name, TwType type, TwSetVarCallback setCallback, TwGetVarCallback getCallback, void *clientData, const char *def); -//TW_API int TW_CALL TwAddButton(TwBar *bar, const char *name, TwButtonCallback callback, void *clientData, const char *def); -//TW_API int TW_CALL TwAddSeparator(TwBar *bar, const char *name, const char *def); -//TW_API int TW_CALL TwRemoveVar(TwBar *bar, const char *name); -//TW_API int TW_CALL TwRemoveAllVars(TwBar *bar); - -// Until AntTweakBar dependency folder exists, this is header-only -#ifndef IGL_STATIC_LIBRARY -# include "ReAntTweakBar.cpp" -#endif - -#endif diff --git a/include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.cpp b/include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.cpp deleted file mode 100644 index bcd6e2be5..000000000 --- a/include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "cocoa_key_to_anttweakbar_key.h" - -#include - -IGL_INLINE int igl::anttweakbar::cocoa_key_to_anttweakbar_key(int key) -{ - // I've left commented the AntTweakBar key codes that correspond to keys I - // don't have on my keyboard. Please fill this in if you have those keys - switch(key) - { - case 127: - return TW_KEY_BACKSPACE; - case 9: - return TW_KEY_TAB; - //TW_KEY_CLEAR = 0x0c, - case 3://ENTER - case 13: - return TW_KEY_RETURN; - case 27: - return TW_KEY_ESCAPE; - case 32: - return TW_KEY_SPACE; - // IN A GLUT APP 40 is ( - //case 40: - case 63272: - return TW_KEY_DELETE; - case 63232: - return TW_KEY_UP; - case 63233: - return TW_KEY_DOWN; - case 63235: - return TW_KEY_RIGHT; - case 63234: - return TW_KEY_LEFT; - //TW_KEY_INSERT, - //TW_KEY_HOME, - //TW_KEY_END, - //TW_KEY_PAGE_UP, - //TW_KEY_PAGE_DOWN, - case 63236: - return TW_KEY_F1; - case 63237: - return TW_KEY_F2; - case 63238: - return TW_KEY_F3; - case 63239: - return TW_KEY_F4; - case 63240: - return TW_KEY_F5; - case 63241: - return TW_KEY_F6; - case 63242: - return TW_KEY_F7; - case 63243: - return TW_KEY_F8; - case 63244: - return TW_KEY_F9; - case 63245: - return TW_KEY_F10; - case 63246: - return TW_KEY_F11; - case 63247: - return TW_KEY_F12; - case 63248: - return TW_KEY_F13; - case 63249: - return TW_KEY_F14; - case 63250: - return TW_KEY_F15; - default: - break; - } - return key; -} diff --git a/include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.h b/include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.h deleted file mode 100644 index fdf3d3bea..000000000 --- a/include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.h +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_ANTTWEAKBAR_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H -#define IGL_ANTTWEAKBAR_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H -#include "../igl_inline.h" - - -namespace igl -{ - namespace anttweakbar - { - // Convert an unsigned char (like that from Cocoa apps) to AntTweakBar key - // code. - // See also: TranslateKey() in TwMgr.cpp in AntTweakBar source - // Inputs: - // key unsigned char key from keyboard - // Returns int of new key code - IGL_INLINE int cocoa_key_to_anttweakbar_key(int key); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "cocoa_key_to_anttweakbar_key.cpp" -#endif - -#endif diff --git a/include/igl/lim/lim.cpp b/include/igl/lim/lim.cpp deleted file mode 100644 index 1f4659062..000000000 --- a/include/igl/lim/lim.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 Christian Schüller -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "lim.h" -#include - - -IGL_INLINE igl::lim::State igl::lim::lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima) -{ - return (State)ComputeLIM( - vertices, - initialVertices, - elements, - constraintMatrix, - constraintTargets, - (EnergyType)energyType, - tolerance, - maxIteration, - findLocalMinima - ); -} - -IGL_INLINE igl::lim::State igl::lim::lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima, - bool enableOuput, - bool enableBarriers, - bool enableAlphaUpdate, - double beta, - double eps) -{ - return (State)ComputeLIM( - vertices, - initialVertices, - elements, - constraintMatrix, - constraintTargets, - (EnergyType)energyType, - tolerance, - maxIteration, - findLocalMinima, - enableOuput, - enableBarriers, - enableAlphaUpdate, - beta, - eps - ); -} - -IGL_INLINE igl::lim::State igl::lim::lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const std::vector& borderVertices, - const Eigen::Matrix& gradients, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima) -{ - return (State)ComputeLIM( - vertices, - initialVertices, - elements, - borderVertices, - gradients, - constraintMatrix, - constraintTargets, - (EnergyType)energyType, - tolerance, - maxIteration, - findLocalMinima - ); -} - -IGL_INLINE igl::lim::State igl::lim::lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const std::vector& borderVertices, - const Eigen::Matrix& gradients, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima, - bool enableOuput, - bool enableBarriers, - bool enableAlphaUpdate, - double beta, - double eps) -{ - return (State)ComputeLIM( - vertices, - initialVertices, - elements, - borderVertices, - gradients, - constraintMatrix, - constraintTargets, - (EnergyType)energyType, - tolerance, - maxIteration, - findLocalMinima, - enableOuput, - enableBarriers, - enableAlphaUpdate, - beta, - eps); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -#endif diff --git a/include/igl/lim/lim.h b/include/igl/lim/lim.h deleted file mode 100644 index c4d3f4ad4..000000000 --- a/include/igl/lim/lim.h +++ /dev/null @@ -1,133 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2014 Christian Schüller -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_LIM_LIM_H -#define IGL_LIM_LIM_H -#include -#include -#include - -namespace igl -{ - namespace lim - { - // Computes a locally injective mapping of a triangle or tet-mesh based on - // a deformation energy subject to some provided linear positional - // constraints Cv-d. - // - // Inputs: - // vertices vx3 matrix containing vertex position of the mesh - // initialVertices vx3 matrix containing vertex position of initial - // rest pose mesh - // elements exd matrix containing vertex indices of all elements - // borderVertices (only needed for 2D LSCM) vector containing indices - // of border vertices - // gradients (only needed for 2D Poisson) vector containing - // partial derivatives of target element gradients - // (structure is: [xx_0, xy_0, xx_1, xy_1, ..., xx_v, - // xy_v, yx_0, yy_0, yx_1, yy_1, ..., yx_v, yy_v]') - // constraintMatrix C: (c)x(v*(d-1)) sparse linear positional constraint - // matrix. X an Y-coordinates are alternatingly stacked - // per row (structure for triangles: [x_1, y_1, x_2, - // y_2, ..., x_v,y_v]) - // constraintTargets d: c vector target positions - // energyType type of used energy: - // Dirichlet, Laplacian, Green, ARAP, LSCM, Poisson (only 2D), UniformLaplacian, Identity - // tolerance max squared positional constraints error - // maxIteration max number of iterations - // findLocalMinima iterating until a local minima is found. If not - // enabled only tolerance must be fulfilled. - // enableOutput (optional) enables the output (#iteration / hessian correction / step size / positional constraints / barrier constraints / deformation energy) (default : true) - // enableBarriers (optional) enables the non-flip constraints (default = true) - // enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true) - // beta (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1) - // eps (optional) smallest valid triangle area (default: 1e-5 * smallest triangle) - // - // where: - // v : # vertices - // c : # linear constraints - // e : # elements of mesh - // d : # vertices per element (triangle = 3, tet = 4) - //-------------------------------------------------------------------------- - // Output: - // vertices vx3 matrix containing resulting vertex position of the - // mesh - //-------------------------------------------------------------------------- - // Return values: - // Succeeded : Successful optimization with fulfilled tolerance - // LocalMinima : Convergenged to a local minima / tolerance not fulfilled - // IterationLimit : Max iteration reached before tolerance was fulfilled - // Infeasible : not feasible -> has inverted elements (decrease eps?) - - enum Energy { Dirichlet = 0, Laplacian=1, Green=2, ARAP=3, LSCM=4, Poisson=5, UniformLaplacian=6, Identity=7 }; - enum State { Uninitialized = -4, Infeasible = -3, IterationLimit = -2, LocalMinima = -1, Running = 0, Succeeded = 1 }; - - State lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima); - - State lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima, - bool enableOuput, - bool enableBarriers, - bool enableAlphaUpdate, - double beta, - double eps); - - State lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const std::vector& borderVertices, - const Eigen::Matrix& gradients, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima); - - State lim( - Eigen::Matrix& vertices, - const Eigen::Matrix& initialVertices, - const Eigen::Matrix& elements, - const std::vector& borderVertices, - const Eigen::Matrix& gradients, - const Eigen::SparseMatrix& constraintMatrix, - const Eigen::Matrix& constraintTargets, - Energy energyType, - double tolerance, - int maxIteration, - bool findLocalMinima, - bool enableOuput, - bool enableBarriers, - bool enableAlphaUpdate, - double beta, - double eps); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "lim.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/MouseController.h b/include/igl/opengl2/MouseController.h deleted file mode 100644 index eb38802ad..000000000 --- a/include/igl/opengl2/MouseController.h +++ /dev/null @@ -1,691 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_MOUSECONTROLLER_H -#define IGL_OPENGL2_MOUSECONTROLLER_H -// Needs to be included before others -#include -#include "RotateWidget.h" -#include "TranslateWidget.h" -#include -#include -#include - -// Class for control a skeletal FK rig with the mouse. -namespace igl -{ - namespace opengl2 - { - class MouseController - { - public: - typedef Eigen::VectorXi VectorXb; - // Propagate selection to descendants so that selected bones and their - // subtrees are all selected. - // - // Input: - // S #S list of whether selected - // P #S list of bone parents - // Output: - // T #S list of whether selected - static inline void propogate_to_descendants_if( - const VectorXb & S, - const Eigen::VectorXi & P, - VectorXb & T); - // Create a matrix of colors for the selection and their descendants. - // - // Inputs: - // selection #S list of whether a bone is selected - // selected_color color for selected bones - // unselected_color color for unselected bones - // Outputs: - // C #P by 4 list of colors - static inline void color_if( - const VectorXb & S, - const Eigen::Vector4f & selected_color, - const Eigen::Vector4f & unselected_color, - Eigen::MatrixXf & C); - enum WidgetMode - { - WIDGET_MODE_ROTATE = 0, - WIDGET_MODE_TRANSLATE = 1, - NUM_WIDGET_MODES = 2, - }; - private: - // m_is_selecting whether currently selecting - // m_selection #m_rotations list of whether a bone is selected - // m_down_x x-coordinate of mouse location at down - // m_down_y y-coordinate 〃 - // m_drag_x x-coordinate of mouse location at drag - // m_drag_y y-coordinate 〃 - // m_widget rotation widget for selected bone - // m_width width of containing window - // m_height height 〃 - // m_rotations list of rotations for each bone - // m_rotations_at_selection list of rotations for each bone at time of - // selection - // m_translations list of translations for each bone - // m_fk_rotations_at_selection list of rotations for each bone at time of - // selection - // m_root_enabled Whether root is enabled - bool m_is_selecting; - VectorXb m_selection; - int m_down_x,m_down_y,m_drag_x,m_drag_y; - int m_width,m_height; - igl::opengl2::RotateWidget m_widget; - igl::opengl2::TranslateWidget m_trans_widget; - Eigen::Quaterniond m_widget_rot_at_selection; - //Eigen::Vector3d m_trans_widget_trans_at_selection; - typedef std::vector< - Eigen::Quaterniond, - Eigen::aligned_allocator > RotationList; - typedef std::vector< Eigen::Vector3d > TranslationList; - RotationList - m_rotations, - m_rotations_at_selection, - m_fk_rotations_at_selection, - m_parent_rotations_at_selection; - TranslationList - m_translations, - m_translations_at_selection, - m_fk_translations_at_selection; - bool m_root_enabled; - WidgetMode m_widget_mode; - public: - MouseController(); - // Returns const reference to m_selection - inline const VectorXb & selection() const{return m_selection;}; - // 〃 m_is_selecting - inline const bool & is_selecting() const{return m_is_selecting;} - inline bool is_widget_down() const{return m_widget.is_down();} - inline bool is_trans_widget_down() const{return m_trans_widget.is_down();} - // 〃 m_rotations - inline const RotationList & rotations() const{return m_rotations;} - inline const TranslationList & translations() const{return m_translations;} - // Returns non-const reference to m_root_enabled - inline bool & root_enabled(){ return m_root_enabled;} - inline void reshape(const int w, const int h); - // Process down, drag, up mouse events - // - // Inputs: - // x x-coordinate of mouse click with respect to container - // y y-coordinate 〃 - // Returns true if accepted (action taken). - inline bool down(const int x, const int y); - inline bool drag(const int x, const int y); - inline bool up(const int x, const int y); - // Draw selection box and widget - inline void draw() const; - // Set `m_selection` based on the last drag selection and initialize - // widget. - // - // Inputs: - // C #C by dim list of joint positions at rest - // BE #BE by 2 list of bone indices at rest - // P #P list of bone parents - inline void set_selection_from_last_drag( - const Eigen::MatrixXd & C, - const Eigen::MatrixXi & BE, - const Eigen::VectorXi & P, - const Eigen::VectorXi & RP); - // Set from explicit selection - inline void set_selection( - const Eigen::VectorXi & S, - const Eigen::MatrixXd & C, - const Eigen::MatrixXi & BE, - const Eigen::VectorXi & P, - const Eigen::VectorXi & RP); - // Set size of skeleton - // - // Inputs: - // n number of bones - inline void set_size(const int n); - // Resets m_rotation elements to identity - inline void reset(); - inline void reset_selected(); - inline void reset_rotations(); - inline void reset_selected_rotations(); - inline void reset_translations(); - inline void reset_selected_translations(); - inline bool set_rotations(const RotationList & vQ); - inline bool set_translations(const TranslationList & vT); - // Sets all entries in m_selection to false - inline void clear_selection(); - // Returns true iff some element in m_selection is true - inline bool any_selection() const; - inline void set_widget_mode(const WidgetMode & mode); - public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - }; - } -} - -// Implementation -#include "../line_segment_in_rectangle.h" -#include "draw_rectangular_marquee.h" -#include "project.h" -#include "../forward_kinematics.h" -#include -#include -#include - -inline void igl::opengl2::MouseController::propogate_to_descendants_if( - const VectorXb & S, - const Eigen::VectorXi & P, - VectorXb & T) -{ - using namespace std; - const int n = S.rows(); - assert(P.rows() == n); - // dynamic programming - T = S; - vector seen(n,false); - // Recursively look up chain and see if ancestor is selected - const function look_up = [&](int e) -> bool - { - if(e==-1) - { - return false; - } - if(!seen[e]) - { - seen[e] = true; - T(e) |= look_up(P(e)); - } - return T(e); - }; - for(int e = 0;e > vQ; - vector vT; - forward_kinematics(C,BE,P,m_rotations,m_translations,vQ,vT); - // Loop over deformed bones - for(int e = 0;e > & vQ = - m_fk_rotations_at_selection; - vector & vT = m_fk_translations_at_selection; - forward_kinematics(C,BE,P,m_rotations,m_translations,vQ,vT); - m_parent_rotations_at_selection.resize( - m_rotations.size(),Quaterniond::Identity()); - for(size_t r = 0;r=0) - { - m_parent_rotations_at_selection[r] = vQ[P(r)]; - } - } - - - if(&m_selection != &S) - { - m_selection = S; - } - assert(m_selection.rows() == BE.rows()); - assert(BE.rows() == P.rows()); - assert(BE.rows() == RP.rows()); - // Zero-out S up a path of ones from e - auto propagate = [&](const int e, const VectorXb & S, VectorXb & N) - { - if(S(e)) - { - int f = e; - while(true) - { - int p = P(f); - if(p==-1||!S(p)) - { - break; - } - N(f) = false; - f = p; - } - } - }; - VectorXb prev_selection = m_selection; - // Combine upward, group rigid parts, repeat - while(true) - { - // Spread selection across rigid pieces - VectorXb SRP(VectorXb::Zero(RP.maxCoeff()+1)); - for(int e = 0;e -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_ROTATE_WIDGET_H -#define IGL_OPENGL2_ROTATE_WIDGET_H -#include "../material_colors.h" -#include -#include -#include - -namespace igl -{ - namespace opengl2 - { - // 3D Rotate tool widget similar to Maya's. Works best if field of view angle - // is less than ~25. - class RotateWidget - { - // If a is true then use A else use desaturated A - static inline void glColor4fv(const bool a, const Eigen::Vector4f & A); - public: - inline static Eigen::Quaterniond axis_q(const int a); - inline static Eigen::Vector3d view_direction(const int x, const int y); - inline static Eigen::Vector3d view_direction(const Eigen::Vector3d & pos); - Eigen::Vector3d pos; - Eigen::Quaterniond rot,down_rot; - Eigen::Vector2d down_xy,drag_xy,down_dir; - Eigen::Vector3d udown,udrag; - double outer_radius_on_screen; - double outer_over_inner; - bool m_is_enabled; - enum DownType - { - DOWN_TYPE_X = 0, - DOWN_TYPE_Y = 1, - DOWN_TYPE_Z = 2, - DOWN_TYPE_OUTLINE = 3, - DOWN_TYPE_TRACKBALL = 4, - DOWN_TYPE_NONE = 5, - NUM_DOWN_TYPES = 6 - } down_type, selected_type; - inline RotateWidget(); - // Vector from origin to mouse click "Unprojected" onto plane with depth of - // origin and scale to so that outer radius is 1 - // - // Inputs: - // x mouse x position - // y mouse y position - // Returns vector - inline Eigen::Vector3d unproject_onto(const int x, const int y) const; - // Shoot ray from mouse click to sphere - // - // Inputs: - // x mouse x position - // y mouse y position - // Outputs: - // hit position of hit - // Returns true only if there was a hit - inline bool intersect( - const int x, - const int y, - Eigen::Vector3d & hit) const; - inline double unprojected_inner_radius() const; - inline bool down(const int x, const int y); - inline bool drag(const int x, const int y); - inline bool up(const int x, const int y); - inline bool is_down() const; - inline void draw() const; - inline void draw_guide() const; - public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - }; - } -} - -// Implementation -#include "../PI.h" -#include "../EPS.h" -#include "../ray_sphere_intersect.h" -#include "../mat_to_quat.h" -#include "../trackball.h" -#include "gl.h" -#include "project.h" -#include "unproject.h" -#include -#include - -inline void igl::opengl2::RotateWidget::glColor4fv( - const bool a, - const Eigen::Vector4f & A) -{ - if(a) - { - ::glColor4fv(A.data()); - }else - { - Eigen::Vector4f B; - const double f = 0.95; // desaturate by 95% - const double L = 0.3*A(0) + 0.6*A(1) + 0.1*A(2); - B.head(3) = A.head(3).array() + f*(L-A.head(3).array()); - B(3) = A(3); - ::glColor4fv(B.data()); - } -} - -inline Eigen::Quaterniond igl::opengl2::RotateWidget::axis_q(const int a) -{ - assert(a<3 && a>=0); - const Eigen::Quaterniond axes[3] = { - Eigen::Quaterniond(Eigen::AngleAxisd(igl::PI*0.5,Eigen::Vector3d(0,1,0))), - Eigen::Quaterniond(Eigen::AngleAxisd(igl::PI*0.5,Eigen::Vector3d(1,0,0))), - Eigen::Quaterniond::Identity()}; - return axes[a]; -} - -inline Eigen::Vector3d igl::opengl2::RotateWidget::view_direction(const int x, const int y) -{ - using namespace Eigen; - const Vector3d win_s(x,y,0), win_d(x,y,1); - const Vector3d s = unproject(win_s); - const Vector3d d = unproject(win_d); - return d-s; -} - -inline Eigen::Vector3d igl::opengl2::RotateWidget::view_direction(const Eigen::Vector3d & pos) -{ - using namespace Eigen; - const Vector3d ppos = project(pos); - return view_direction(ppos(0),ppos(1)); -} - -inline igl::opengl2::RotateWidget::RotateWidget(): - pos(0,0,0), - rot(Eigen::Quaterniond::Identity()), - down_rot(rot), - down_xy(-1,-1),drag_xy(-1,-1), - outer_radius_on_screen(91.), - outer_over_inner(1.13684210526), - m_is_enabled(true), - down_type(DOWN_TYPE_NONE), - selected_type(DOWN_TYPE_NONE) -{ -} - -inline Eigen::Vector3d igl::opengl2::RotateWidget::unproject_onto( - const int x, - const int y) const -{ - using namespace Eigen; - // KNOWN BUG: This projects to same depths as pos. I think what we actually - // want is The intersection with the plane perpendicular to the view - // direction at pos. If the field of view angle is small then this difference - // is negligible. - //const Vector3d ppos = project(pos); - //const Vector3d uxy = unproject( Vector3d(x,y,ppos(2))); - // http://en.wikipedia.org/wiki/Line-plane_intersection - // - // Hrrmmm. There's still something wrong here if the ball's in the corner of - // the screen. Am I somehow not accounting for perspective correctly? - // - // Q: What about just projecting the circle's equation and solving for the - // distance? - const Vector3d l0 = unproject(Vector3d(x,y,0)); - const Vector3d l = unproject(Vector3d(x,y,1))-l0; - const Vector3d n = view_direction(pos); - const double t = (pos-l0).dot(n)/l.dot(n); - const Vector3d uxy = l0+t*l; - return (uxy-pos)/unprojected_inner_radius()*outer_over_inner*outer_over_inner; -} - -inline bool igl::opengl2::RotateWidget::intersect( - const int x, - const int y, - Eigen::Vector3d & hit) const -{ - using namespace Eigen; - Vector3d view = view_direction(x,y); - const Vector3d ppos = project(pos); - Vector3d uxy = unproject(Vector3d(x,y,ppos(2))); - double t0,t1; - if(!ray_sphere_intersect(uxy,view,pos,unprojected_inner_radius(),t0,t1)) - { - return false; - } - hit = uxy+t0*view; - return true; -} - - -inline double igl::opengl2::RotateWidget::unprojected_inner_radius() const -{ - using namespace Eigen; - Vector3d off,ppos,ppos_off,pos_off; - project(pos,ppos); - ppos_off = ppos; - ppos_off(0) += outer_radius_on_screen/outer_over_inner; - unproject(ppos_off,pos_off); - return (pos-pos_off).norm(); -} -inline bool igl::opengl2::RotateWidget::down(const int x, const int y) -{ - using namespace Eigen; - using namespace std; - if(!m_is_enabled) - { - return false; - } - down_type = DOWN_TYPE_NONE; - selected_type = DOWN_TYPE_NONE; - down_xy = Vector2d(x,y); - drag_xy = down_xy; - down_rot = rot; - Vector3d ppos = project(pos); - const double r = (ppos.head(2) - down_xy).norm(); - const double thresh = 3; - if(fabs(r - outer_radius_on_screen) bool - { - // project onto rotate plane - pl_hit = hit-pos; - pl_hit = (m.conjugate()*rot.conjugate()*pl_hit).eval(); - pl_hit(2) = 0; - pl_hit = (rot*m*pl_hit).eval(); - pl_hit.normalize(); - pl_hit *= unprojected_inner_radius(); - pl_hit += pos; - return (project(pl_hit).head(2)-project(hit).head(2)).norm()<2*thresh; - }; - udown = (hit-pos).normalized()/outer_radius_on_screen; - udrag = udown; - for(int a = 0;a<3;a++) - { - Vector3d pl_hit; - if(on_meridian(hit,rot,Quaterniond(axis_q(a)),pl_hit)) - { - udown = (pl_hit-pos).normalized()/outer_radius_on_screen; - udrag = udown; - down_type = DownType(DOWN_TYPE_X+a); - selected_type = down_type; - { - Vector3d dir3 = axis_q(a).conjugate()*down_rot.conjugate()*(hit-pos); - dir3 = AngleAxisd(-PI*0.5,Vector3d(0,0,1))*dir3; - dir3 = (rot*axis_q(a)*dir3).eval(); - down_dir = (project((hit+dir3).eval())-project(hit)).head(2); - down_dir.normalize(); - //// flip y because y coordinate is going to be given backwards in - //// drag() - //down_dir(1) *= -1; - } - return true; - } - } - //assert(is_hit); - down_type = DOWN_TYPE_TRACKBALL; - selected_type = DOWN_TYPE_TRACKBALL; - return true; - }else - { - return false; - } -} - -inline bool igl::opengl2::RotateWidget::drag(const int x, const int y) -{ - using namespace std; - using namespace Eigen; - if(!m_is_enabled) - { - return false; - } - drag_xy = Vector2d(x,y); - switch(down_type) - { - case DOWN_TYPE_NONE: - return false; - default: - { - const Quaterniond & q = axis_q(down_type-DOWN_TYPE_X); - const double dtheta = -(drag_xy - down_xy).dot(down_dir)/ - outer_radius_on_screen/outer_over_inner*PI/2.; - Quaterniond dq(AngleAxisd(dtheta,down_rot*q*Vector3d(0,0,1))); - rot = dq * down_rot; - udrag = dq * udown; - return true; - } - case DOWN_TYPE_OUTLINE: - { - Vector3d ppos = project(pos); - // project mouse to same depth as pos - udrag = unproject_onto(x,y); - const Vector2d A = down_xy - ppos.head(2); - const Vector2d B = drag_xy - ppos.head(2); - const double dtheta = atan2(A(0)*B(1)-A(1)*B(0),A(0)*B(0)+A(1)*B(1)); - Vector3d n = view_direction(pos).normalized(); - Quaterniond dq(AngleAxisd(dtheta,-n)); - //Vector3d n = udrag.cross(udown).normalized(); - //Quaterniond dq(AngleAxisd(fabs(dtheta),-n)); - rot = dq * down_rot; - } - return true; - case DOWN_TYPE_TRACKBALL: - { - Vector3d ppos = project(pos); - const double r = (double)outer_radius_on_screen/outer_over_inner*2.0; - //const int h = w; - Vector4i vp; - glGetIntegerv(GL_VIEWPORT,vp.data()); - const int h = vp(3); - Quaterniond dq; - trackball( - r,r, - 1, - Quaterniond::Identity(), - double( down_xy(0)-ppos(0) )+r/2., - double((h-down_xy(1))-(h-ppos(1)))+r/2., - double( x-ppos(0) )+r/2., - double( (h-y)-(h-ppos(1)))+r/2., - dq); - // We've computed change in rotation according to this view: - // R = mv * r, R' = rot * (mv * r) - // But we only want new value for r: - // R' = mv * r' - // mv * r' = rot * (mv * r) - // r' = mv* * rot * mv * r - Matrix4d mv; - glGetDoublev(GL_MODELVIEW_MATRIX,mv.data()); - Quaterniond scene_rot; - // Convert modelview matrix to quaternion - mat4_to_quat(mv.data(),scene_rot.coeffs().data()); - scene_rot.normalize(); - rot = scene_rot.conjugate() * dq * scene_rot * down_rot; - } - return true; - } -} - -inline bool igl::opengl2::RotateWidget::up(const int /*x*/, const int /*y*/) -{ - // even if disabled process up - down_type = DOWN_TYPE_NONE; - return false; -} - -inline bool igl::opengl2::RotateWidget::is_down() const -{ - return down_type != DOWN_TYPE_NONE; -} - -inline void igl::opengl2::RotateWidget::draw() const -{ - using namespace Eigen; - using namespace std; - glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT | GL_LINE_BIT); - glDisable(GL_CLIP_PLANE0); - - glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); - glLineWidth(2.0); - - double r = unprojected_inner_radius(); - Vector3d view = view_direction(pos).normalized(); - - auto draw_circle = [&](const bool cull) - { - Vector3d view = view_direction(pos).normalized(); - glBegin(GL_LINES); - const double th_step = (2.0*igl::PI/100.0); - for(double th = 0;th<2.0*igl::PI+th_step;th+=th_step) - { - Vector3d a(cos(th),sin(th),0.0); - Vector3d b(cos(th+th_step),sin(th+th_step),0.0); - if(!cull || (0.5*(a+b)).dot(view) -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_TRANSLATE_WIDGET_H -#define IGL_OPENGL2_TRANSLATE_WIDGET_H -#include "../material_colors.h" -#include -#include -#include - -namespace igl -{ - namespace opengl2 - { - class TranslateWidget - { -public: - // m_pos position of center - // m_trans translation vector - // m_down_xy mouse position on down - // m_drag_xy mouse position on drag - // m_is_enabled whether enabled - Eigen::Vector3d m_pos,m_trans,m_down_trans; - Eigen::Vector2d m_down_xy, m_drag_xy; - bool m_is_enabled; - double m_len; - enum DownType - { - DOWN_TYPE_X = 0, - DOWN_TYPE_Y = 1, - DOWN_TYPE_Z = 2, - DOWN_TYPE_CENTER = 3, - DOWN_TYPE_NONE = 4, - NUM_DOWN_TYPES = 5 - } m_down_type, m_selected_type; - inline TranslateWidget(const Eigen::Vector3d & pos = Eigen::Vector3d(0,0,0)); - inline bool down(const int x, const int y); - inline bool drag(const int x, const int y); - inline bool up(const int x, const int y); - inline bool is_down() const; - inline void draw() const; -public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW; - }; - } -} - -// Implementation -#include "project.h" -#include "unproject.h" - -inline igl::opengl2::TranslateWidget::TranslateWidget( - const Eigen::Vector3d & pos): - m_pos(pos), - m_trans(0,0,0), - m_down_xy(-1,-1), - m_drag_xy(-1,-1), - m_is_enabled(true), - m_len(50), - m_down_type(DOWN_TYPE_NONE), - m_selected_type(DOWN_TYPE_NONE) -{ -} - -inline bool igl::opengl2::TranslateWidget::down(const int x, const int y) -{ - using namespace Eigen; - using namespace std; - if(!m_is_enabled) - { - return false; - } - m_down_trans = m_trans; - m_down_xy = Vector2d(x,y); - m_drag_xy = m_down_xy; - m_down_type = DOWN_TYPE_NONE; - m_selected_type = DOWN_TYPE_NONE; - Vector3d ppos = project((m_pos+m_trans).eval()); - const double r = (ppos.head(2) - m_down_xy).norm(); - const double center_thresh = 10; - if(r < center_thresh) - { - m_down_type = DOWN_TYPE_CENTER; - m_selected_type = m_down_type; - return true; - }else if(r < m_len) - { - // Might be hit on lines - } - return false; -} - -inline bool igl::opengl2::TranslateWidget::drag(const int x, const int y) -{ - using namespace std; - using namespace Eigen; - if(!m_is_enabled) - { - return false; - } - m_drag_xy = Vector2d(x,y); - switch(m_down_type) - { - case DOWN_TYPE_NONE: - return false; - default: - { - Vector3d ppos = project((m_pos+m_trans).eval()); - Vector3d drag3(m_drag_xy(0),m_drag_xy(1),ppos(2)); - Vector3d down3(m_down_xy(0),m_down_xy(1),ppos(2)); - m_trans = m_down_trans + unproject(drag3)-unproject(down3); - return true; - } - } -} - -inline bool igl::opengl2::TranslateWidget::up(const int /*x*/, const int /*y*/) -{ - // even if disabled process up - m_down_type = DOWN_TYPE_NONE; - return false; -} - -inline bool igl::opengl2::TranslateWidget::is_down() const -{ - return m_down_type != DOWN_TYPE_NONE; -} - -inline void igl::opengl2::TranslateWidget::draw() const -{ - using namespace Eigen; - using namespace std; - glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT | GL_LINE_BIT); - glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); - glLineWidth(2.0); - auto draw_axes = [&]() - { - glBegin(GL_LINES); - glColor3f(1,0,0); - glVertex3f(0,0,0); - glVertex3f(1,0,0); - glColor3f(0,1,0); - glVertex3f(0,0,0); - glVertex3f(0,1,0); - glColor3f(0,0,1); - glVertex3f(0,0,0); - glVertex3f(0,0,1); - glEnd(); - }; - auto draw_cube = [] - { - glBegin(GL_LINES); - glVertex3f(-1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, -1.0f, 1.0f); - glVertex3f(1.0f, -1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, 1.0f); - glVertex3f(-1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, -1.0f); - glVertex3f(1.0f, 1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, -1.0f); - glVertex3f(-1.0f, 1.0f, -1.0f); - glVertex3f(-1.0f, -1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, -1.0f); - glVertex3f(-1.0f, -1.0f, -1.0f); - glVertex3f(-1.0f, 1.0f, -1.0f); - glVertex3f(-1.0f, 1.0f, -1.0f); - glVertex3f(-1.0f, 1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, -1.0f); - glEnd(); - }; - glPushMatrix(); - glTranslated( m_pos(0)+m_trans(0), m_pos(1)+m_trans(1), m_pos(2)+m_trans(2)); - - { - Vector3d off,ppos,ppos_off,pos_off; - project((m_pos+m_trans).eval(),ppos); - ppos_off = ppos; - ppos_off(0) += m_len; - unproject(ppos_off,pos_off); - const double r = (m_pos+m_trans-pos_off).norm(); - glScaled(r,r,r); - } - - draw_axes(); - glScaled(0.05,0.05,0.05); - if(m_selected_type == DOWN_TYPE_CENTER) - { - glColor3fv(MAYA_YELLOW.data()); - }else - { - glColor3fv(MAYA_GREY.data()); - } - draw_cube(); - glPopMatrix(); - glPopAttrib(); -} - -#endif diff --git a/include/igl/opengl2/draw_beach_ball.cpp b/include/igl/opengl2/draw_beach_ball.cpp deleted file mode 100644 index a661ce4ae..000000000 --- a/include/igl/opengl2/draw_beach_ball.cpp +++ /dev/null @@ -1,283 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "draw_beach_ball.h" -#include "gl.h" - -// I'm not sure why windows would need it this way: -// http://lists.cairographics.org/archives/cairo/2008-January/012722.html -#ifdef _MSC_VER -#define SAFE_INLINE __inline -#else -#define SAFE_INLINE inline -#endif - -#include -#include -#include - -// Most of this implementation comes from the AntTweakBar source code: -// TwMgr.cpp, TwMgr.h, TwColor.h, TwColor.cpp, TwOpenGL.h and TwOpenGL.cpp - -//////////////////////////////////////////////////////////////////////////// -// Begin Copied Straight from AntTweakBar -//////////////////////////////////////////////////////////////////////////// -enum EArrowParts { ARROW_CONE, ARROW_CONE_CAP, ARROW_CYL, ARROW_CYL_CAP }; - -template SAFE_INLINE const T& TClamp(const T& X, const T& Limit1, const T& Limit2) -{ - if( Limit1=Limit2) ? Limit2 : X ); - else - return (X<=Limit2) ? Limit2 : ( (X>=Limit1) ? Limit1 : X ); -} - -typedef unsigned int color32; -static SAFE_INLINE color32 Color32FromARGBi(int A, int R, int G, int B) -{ - return (((color32)TClamp(A, 0, 255))<<24) | (((color32)TClamp(R, 0, 255))<<16) | (((color32)TClamp(G, 0, 255))<<8) | ((color32)TClamp(B, 0, 255)); -} - -static SAFE_INLINE color32 Color32FromARGBf(float A, float R, float G, float B) -{ - return (((color32)TClamp(A*256.0f, 0.0f, 255.0f))<<24) | (((color32)TClamp(R*256.0f, 0.0f, 255.0f))<<16) | (((color32)TClamp(G*256.0f, 0.0f, 255.0f))<<8) | ((color32)TClamp(B*256.0f, 0.0f, 255.0f)); -} - -static SAFE_INLINE void Color32ToARGBi(color32 Color, int *A, int *R, int *G, int *B) -{ - if(A) *A = (Color>>24)&0xff; - if(R) *R = (Color>>16)&0xff; - if(G) *G = (Color>>8)&0xff; - if(B) *B = Color&0xff; -} - -static SAFE_INLINE void Color32ToARGBf(color32 Color, float *A, float *R, float *G, float *B) -{ - if(A) *A = (1.0f/255.0f)*float((Color>>24)&0xff); - if(R) *R = (1.0f/255.0f)*float((Color>>16)&0xff); - if(G) *G = (1.0f/255.0f)*float((Color>>8)&0xff); - if(B) *B = (1.0f/255.0f)*float(Color&0xff); -} - -static color32 ColorBlend(color32 Color1, color32 Color2, float S) -{ - float a1, r1, g1, b1, a2, r2, g2, b2; - Color32ToARGBf(Color1, &a1, &r1, &g1, &b1); - Color32ToARGBf(Color2, &a2, &r2, &g2, &b2); - float t = 1.0f-S; - return Color32FromARGBf(t*a1+S*a2, t*r1+S*r2, t*g1+S*g2, t*b1+S*b2); -} - -static std::vector s_SphTri; -static std::vector s_SphCol; -static void CreateSphere() -{ - const int SUBDIV = 7; - s_SphTri.clear(); - s_SphCol.clear(); - - const float A[8*3] = { 1,0,0, 0,0,-1, -1,0,0, 0,0,1, 0,0,1, 1,0,0, 0,0,-1, -1,0,0 }; - const float B[8*3] = { 0,1,0, 0,1,0, 0,1,0, 0,1,0, 0,-1,0, 0,-1,0, 0,-1,0, 0,-1,0 }; - const float C[8*3] = { 0,0,1, 1,0,0, 0,0,-1, -1,0,0, 1,0,0, 0,0,-1, -1,0,0, 0,0,1 }; - //const color32 COL_A[8] = { 0xffff8080, 0xff000080, 0xff800000, 0xff8080ff, 0xff8080ff, 0xffff8080, 0xff000080, 0xff800000 }; - //const color32 COL_B[8] = { 0xff80ff80, 0xff80ff80, 0xff80ff80, 0xff80ff80, 0xff008000, 0xff008000, 0xff008000, 0xff008000 }; - //const color32 COL_C[8] = { 0xff8080ff, 0xffff8080, 0xff000080, 0xff800000, 0xffff8080, 0xff000080, 0xff800000, 0xff8080ff }; - const color32 COL_A[8] = { 0xffffffff, 0xffffff40, 0xff40ff40, 0xff40ffff, 0xffff40ff, 0xffff4040, 0xff404040, 0xff4040ff }; - const color32 COL_B[8] = { 0xffffffff, 0xffffff40, 0xff40ff40, 0xff40ffff, 0xffff40ff, 0xffff4040, 0xff404040, 0xff4040ff }; - const color32 COL_C[8] = { 0xffffffff, 0xffffff40, 0xff40ff40, 0xff40ffff, 0xffff40ff, 0xffff4040, 0xff404040, 0xff4040ff }; - - int i, j, k, l; - float xa, ya, za, xb, yb, zb, xc, yc, zc, x, y, z, norm, u[3], v[3]; - color32 col; - for( i=0; i<8; ++i ) - { - xa = A[3*i+0]; ya = A[3*i+1]; za = A[3*i+2]; - xb = B[3*i+0]; yb = B[3*i+1]; zb = B[3*i+2]; - xc = C[3*i+0]; yc = C[3*i+1]; zc = C[3*i+2]; - for( j=0; j<=SUBDIV; ++j ) - for( k=0; k<=2*(SUBDIV-j); ++k ) - { - if( k%2==0 ) - { - u[0] = ((float)j)/(SUBDIV+1); - v[0] = ((float)(k/2))/(SUBDIV+1); - u[1] = ((float)(j+1))/(SUBDIV+1); - v[1] = ((float)(k/2))/(SUBDIV+1); - u[2] = ((float)j)/(SUBDIV+1); - v[2] = ((float)(k/2+1))/(SUBDIV+1); - } - else - { - u[0] = ((float)j)/(SUBDIV+1); - v[0] = ((float)(k/2+1))/(SUBDIV+1); - u[1] = ((float)(j+1))/(SUBDIV+1); - v[1] = ((float)(k/2))/(SUBDIV+1); - u[2] = ((float)(j+1))/(SUBDIV+1); - v[2] = ((float)(k/2+1))/(SUBDIV+1); - } - - for( l=0; l<3; ++l ) - { - x = (1.0f-u[l]-v[l])*xa + u[l]*xb + v[l]*xc; - y = (1.0f-u[l]-v[l])*ya + u[l]*yb + v[l]*yc; - z = (1.0f-u[l]-v[l])*za + u[l]*zb + v[l]*zc; - norm = sqrtf(x*x+y*y+z*z); - x /= norm; y /= norm; z /= norm; - s_SphTri.push_back(x); s_SphTri.push_back(y); s_SphTri.push_back(z); -static const float FLOAT_EPS = 1.0e-7f; - if( u[l]+v[l]>FLOAT_EPS ) - col = ColorBlend(COL_A[i], ColorBlend(COL_B[i], COL_C[i], v[l]/(u[l]+v[l])), u[l]+v[l]); - else - col = COL_A[i]; - //if( (j==0 && k==0) || (j==0 && k==2*SUBDIV) || (j==SUBDIV && k==0) ) - // col = 0xffff0000; - s_SphCol.push_back(col); - } - } - } - //s_SphTriProj.clear(); - //s_SphTriProj.resize(2*s_SphCol.size(), 0); - //s_SphColLight.clear(); - //s_SphColLight.resize(s_SphCol.size(), 0); -} - -static std::vector s_ArrowTri[4]; -static std::vector s_ArrowNorm[4]; -static void CreateArrow() -{ - const int SUBDIV = 15; - const float CYL_RADIUS = 0.08f; - const float CONE_RADIUS = 0.16f; - const float CONE_LENGTH = 0.25f; - const float ARROW_BGN = -1.1f; - const float ARROW_END = 1.15f; - int i; - for(i=0; i<4; ++i) - { - s_ArrowTri[i].clear(); - s_ArrowNorm[i].clear(); - } - - float x0, x1, y0, y1, z0, z1, a0, a1, nx, nn; - for(i=0; i>16), GLubyte(s_SphCol[i]>>8), GLubyte(s_SphCol[i]), GLubyte(s_SphCol[i]>>24)); - glVertex3fv(&s_SphTri[i*3]); - } - glEnd(); - glPopMatrix(); - - CreateArrow(); - for(int k = 0;k<3;k++) - { - glPushMatrix(); - glColor3f(k==0,k==1,k==2); - glRotatef((k==2?-1.0:1.0)*90,k==0,k==2,k==1); - glBegin(GL_TRIANGLES); - for(int j = 0;j<4;j++) - { - for(int i = 0;i<(int)s_ArrowTri[j].size();i+=3) - { - glNormal3fv(&s_ArrowNorm[j][i]); - glVertex3fv(&s_ArrowTri[j][i]); - } - } - glEnd(); - glPopMatrix(); - } - - (cm ? glEnable(GL_COLOR_MATERIAL):glDisable(GL_COLOR_MATERIAL)); -} diff --git a/include/igl/opengl2/draw_beach_ball.h b/include/igl/opengl2/draw_beach_ball.h deleted file mode 100644 index d430dc5ed..000000000 --- a/include/igl/opengl2/draw_beach_ball.h +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_BEACH_BALL_H -#define IGL_OPENGL2_DRAW_BEACH_BALL_H -#include "../igl_inline.h" - -namespace igl -{ - namespace opengl2 - { - // Draw a beach ball icon/glyph (from AntTweakBar) at the current origin - // according to the current orientation: ball has radius 0.75 and axis have - // length 1.15 - IGL_INLINE void draw_beach_ball(); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "draw_beach_ball.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/draw_floor.cpp b/include/igl/opengl2/draw_floor.cpp deleted file mode 100644 index 61fa47491..000000000 --- a/include/igl/opengl2/draw_floor.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "draw_floor.h" -#include "gl.h" - -IGL_INLINE void igl::opengl2::draw_floor(const float * colorA, const float * colorB, - const int GridSizeX, - const int GridSizeY) -{ - const float SizeX = 0.5f*100./(double)GridSizeX; - const float SizeY = 0.5f*100./(double)GridSizeY; - // old settings - int old_lighting=0,old_color_material=0; - glGetIntegerv(GL_LIGHTING,&old_lighting); - glGetIntegerv(GL_COLOR_MATERIAL,&old_color_material); - glDisable(GL_LIGHTING); - glColorMaterial( GL_FRONT, GL_EMISSION); - glEnable(GL_COLOR_MATERIAL); - glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - // Set material - const float black[] = {0.,0.,0.,1.}; - glMaterialfv(GL_FRONT, GL_AMBIENT, black); - glMaterialfv(GL_FRONT, GL_DIFFUSE, black); - glMaterialfv(GL_FRONT, GL_SPECULAR, black); - glMaterialfv(GL_FRONT, GL_EMISSION, black); - glMaterialf(GL_FRONT, GL_SHININESS,0); - const bool use_lighting = false; - if(use_lighting) - { - glEnable(GL_LIGHTING); - }else - { - glDisable(GL_LIGHTING); - } - - - glBegin(GL_QUADS); - glNormal3f(0,1,0); - for (int x =-GridSizeX/2;x -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_FLOOR_H -#define IGL_OPENGL2_DRAW_FLOOR_H -#include "../igl_inline.h" -namespace igl -{ - namespace opengl2 - { - - // Draw a checkerboard floor aligned with current (X,Z) plane using ../opengl/OpenGL_ - // calls. side=50 centered at (0,0): - // (-25,-25)-->(-25,25)-->(25,25)-->(25,-25) - // - // Use glPushMatrix(), glScaled(), glTranslated() to arrange the floor. - // - // Inputs: - // colorA float4 color - // colorB float4 color - // - // Example: - // // Draw a nice floor - // glPushMatrix(); - // glCullFace(GL_BACK); - // glEnable(GL_CULL_FACE); - // glEnable(GL_LIGHTING); - // glTranslated(0,-1,0); - // if(project(Vector3d(0,0,0))(2) - project(Vector3d(0,1,0))(2) > -FLOAT_EPS) - // { - // draw_floor_outline(); - // } - // draw_floor(); - // glPopMatrix(); - // glDisable(GL_CULL_FACE); - // - IGL_INLINE void draw_floor( - const float * colorA, - const float * colorB, - const int GridSizeX=100, - const int GridSizeY=100); - // Wrapper with default colors - IGL_INLINE void draw_floor(); - IGL_INLINE void draw_floor_outline( - const float * colorA, - const float * colorB, - const int GridSizeX=100, - const int GridSizeY=100); - // Wrapper with default colors - IGL_INLINE void draw_floor_outline(); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "draw_floor.cpp" -#endif -#endif diff --git a/include/igl/opengl2/draw_mesh.cpp b/include/igl/opengl2/draw_mesh.cpp deleted file mode 100644 index aeaed12f0..000000000 --- a/include/igl/opengl2/draw_mesh.cpp +++ /dev/null @@ -1,278 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "draw_mesh.h" - -IGL_INLINE void igl::opengl2::draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N) -{ - using namespace Eigen; - MatrixXd _d; - MatrixXi _i; - return draw_mesh(V,F,N,_i,_d,_d,_i,_d,0,_i,0); -} - -IGL_INLINE void igl::opengl2::draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXd & C) -{ - using namespace Eigen; - MatrixXd _d; - MatrixXi _i; - return draw_mesh(V,F,N,_i,C,_d,_i,_d,0,_i,0); -} - -IGL_INLINE void igl::opengl2::draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXd & C, - const Eigen::MatrixXd & TC) -{ - using namespace Eigen; - MatrixXd _d; - MatrixXi _i; - return draw_mesh(V,F,N,_i,C,TC,_i,_d,0,_i,0); -} - -IGL_INLINE void igl::opengl2::draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXd & C, - const Eigen::MatrixXd & TC, - const Eigen::MatrixXd & W, - const GLuint W_index, - const Eigen::MatrixXi & WI, - const GLuint WI_index) -{ - using namespace Eigen; - return draw_mesh(V,F,N,MatrixXi(),C,TC,MatrixXi(),W,W_index,WI,WI_index); -} - -IGL_INLINE void igl::opengl2::draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXi & NF, - const Eigen::MatrixXd & C, - const Eigen::MatrixXd & TC, - const Eigen::MatrixXi & TF, - const Eigen::MatrixXd & W, - const GLuint W_index, - const Eigen::MatrixXi & WI, - const GLuint WI_index) -{ - using namespace std; - using namespace Eigen; - const int rF = F.rows(); - const int cF = F.cols(); - const int cC = C.cols(); - const int rC = C.rows(); - const int cW = W.cols(); - const int rW = W.rows(); - const int rV = V.rows(); - const int rTC = TC.rows(); - const int rTF = TF.rows(); - const int rNF = NF.rows(); - const int rN = N.rows(); - - if(F.size() > 0) - { - assert(F.maxCoeff() < V.rows()); - assert(V.cols() == 3); - assert(rC == rV || rC == rF || rC == rF*3 || rC==1 || C.size() == 0); - assert(C.cols() >= 3 || C.size() == 0); - assert(N.cols() == 3 || N.size() == 0); - assert(TC.cols() == 2 || TC.size() == 0); - assert(cF == 3 || cF == 4); - assert(TF.size() == 0 || TF.cols() == F.cols()); - assert(NF.size() == 0 || NF.cols() == NF.cols()); - } - if(W.size()>0) - { - assert(W.rows() == V.rows()); - assert(WI.rows() == V.rows()); - assert(W.cols() == WI.cols()); - } - - switch(F.cols()) - { - default: - case 3: - glBegin(GL_TRIANGLES); - break; - case 4: - glBegin(GL_QUADS); - break; - } - // loop over faces - for(int i = 0; i color; - if(rC == 1) - { - color = C.row(0); - }else if(rC == rV) - { - color = C.row(F(i,j)); - }else if(rC == rF*cF) - { - color = C.row(i*cF+j); - }else if(rC == rF) - { - color = C.row(i); - }else - { - assert(C.size() == 0); - } - - int n = -1; - if(rNF != 0) - { - n = NF(i,j); // indexed normals - } else if(rN == 1) - { - n = 0; // uniform normals - }else if(rN == rF) - { - n = i; // face normals - }else if(rN == rV) - { - n = F(i,j); // vertex normals - }else if(rN == rF*cF) - { - n = i*cF + j; // corner normals - }else - { - assert(N.size() == 0); - } - - { - if(rW>0 && W_index !=0 && WI_index != 0) - { - int weights_left = cW; - while(weights_left != 0) - { - int pass_size = std::min(4,weights_left); - int weights_already_passed = cW-weights_left; - // Get attribute location of next 4 weights - int pass_W_index = W_index + weights_already_passed/4; - int pass_WI_index = WI_index + weights_already_passed/4; - switch(pass_size) - { - case 1: - glVertexAttrib1d( - pass_W_index, - W(F(i,j),0+weights_already_passed)); - glVertexAttrib1d( - pass_WI_index, - WI(F(i,j),0+weights_already_passed)); - break; - case 2: - glVertexAttrib2d( - pass_W_index, - W(F(i,j),0+weights_already_passed), - W(F(i,j),1+weights_already_passed)); - glVertexAttrib2d( - pass_WI_index, - WI(F(i,j),0+weights_already_passed), - WI(F(i,j),1+weights_already_passed)); - break; - case 3: - glVertexAttrib3d( - pass_W_index, - W(F(i,j),0+weights_already_passed), - W(F(i,j),1+weights_already_passed), - W(F(i,j),2+weights_already_passed)); - glVertexAttrib3d( - pass_WI_index, - WI(F(i,j),0+weights_already_passed), - WI(F(i,j),1+weights_already_passed), - WI(F(i,j),2+weights_already_passed)); - break; - default: - glVertexAttrib4d( - pass_W_index, - W(F(i,j),0+weights_already_passed), - W(F(i,j),1+weights_already_passed), - W(F(i,j),2+weights_already_passed), - W(F(i,j),3+weights_already_passed)); - glVertexAttrib4d( - pass_WI_index, - WI(F(i,j),0+weights_already_passed), - WI(F(i,j),1+weights_already_passed), - WI(F(i,j),2+weights_already_passed), - WI(F(i,j),3+weights_already_passed)); - break; - } - weights_left -= pass_size; - } - } - if(tc != -1) - { - glTexCoord2d(TC(tc,0),TC(tc,1)); - } - if(rC>0) - { - switch(cC) - { - case 3: - glColor3dv(color.data()); - break; - case 4: - glColor4dv(color.data()); - break; - default: - break; - } - } - if(n != -1) - { - glNormal3d(N(n,0),N(n,1),N(n,2)); - } - glVertex3d(V(F(i,j),0),V(F(i,j),1),V(F(i,j),2)); - } - } - } - glEnd(); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -#endif - diff --git a/include/igl/opengl2/draw_mesh.h b/include/igl/opengl2/draw_mesh.h deleted file mode 100644 index ea1559c20..000000000 --- a/include/igl/opengl2/draw_mesh.h +++ /dev/null @@ -1,122 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_MESH_H -#define IGL_OPENGL2_DRAW_MESH_H -#include "../igl_inline.h" -#include "gl.h" -#include - - -namespace igl -{ - namespace opengl2 - { - - // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals - // - // Inputs: - // V #V by 3 eigen Matrix of mesh vertex 3D positions - // F #F by 3|4 eigen Matrix of face (triangle/quad) indices - // N #V|#F by 3 eigen Matrix of 3D normals - IGL_INLINE void draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N); - - // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals and per-vertex - // colors - // - // Inputs: - // V #V by 3 eigen Matrix of mesh vertex 3D positions - // F #F by 3|4 eigen Matrix of face (triangle/quad) indices - // N #V|#F by 3 eigen Matrix of 3D normals - // C #V|#F|1 by 3 eigen Matrix of RGB colors - IGL_INLINE void draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXd & C); - // Inputs: - // V #V by 3 eigen Matrix of mesh vertex 3D positions - // F #F by 3|4 eigen Matrix of face (triangle/quad) indices - // N #V|#F by 3 eigen Matrix of 3D normals - // C #V|#F|1 by 3 eigen Matrix of RGB colors - // TC #V|#F|1 by 3 eigen Matrix of Texture Coordinates - IGL_INLINE void draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXd & C, - const Eigen::MatrixXd & TC); - - // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals, per-vertex - // colors and LBS weights - // - // Inputs: - // V #V by 3 eigen Matrix of mesh vertex 3D positions - // F #F by 3|4 eigen Matrix of face (triangle/quad) indices - // N #V by 3 eigen Matrix of mesh vertex 3D normals - // C #V by 3 eigen Matrix of mesh vertex RGB colors - // TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1 - // W #V by #H eigen Matrix of per mesh vertex, per handle weights - // W_index Specifies the index of the "weight" vertex attribute: see - // glBindAttribLocation, if W_index is 0 then weights are ignored - // WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids - // WI_index Specifies the index of the "weight" vertex attribute: see - // glBindAttribLocation, if WI_index is 0 then weight indices are ignored - IGL_INLINE void draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXd & C, - const Eigen::MatrixXd & TC, - const Eigen::MatrixXd & W, - const GLuint W_index, - const Eigen::MatrixXi & WI, - const GLuint WI_index); - - // Draw ../opengl/OpenGL_ commands needed to display a mesh with normals, per-vertex - // colors and LBS weights - // - // Inputs: - // V #V by 3 eigen Matrix of mesh vertex 3D positions - // F #F by 3|4 eigen Matrix of face (triangle/quad) indices - // N #V by 3 eigen Matrix of mesh vertex 3D normals - // NF #F by 3 eigen Matrix of face (triangle/quad) normal indices, <0 - // means no normal - // C #V by 3 eigen Matrix of mesh vertex RGB colors - // TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1 - // TF #F by 3 eigen Matrix of face (triangle/quad) texture indices, <0 - // means no texture - // W #V by #H eigen Matrix of per mesh vertex, per handle weights - // W_index Specifies the index of the "weight" vertex attribute: see - // glBindAttribLocation, if W_index is 0 then weights are ignored - // WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids - // WI_index Specifies the index of the "weight" vertex attribute: see - // glBindAttribLocation, if WI_index is 0 then weight indices are ignored - IGL_INLINE void draw_mesh( - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & N, - const Eigen::MatrixXi & NF, - const Eigen::MatrixXd & C, - const Eigen::MatrixXd & TC, - const Eigen::MatrixXi & TF, - const Eigen::MatrixXd & W, - const GLuint W_index, - const Eigen::MatrixXi & WI, - const GLuint WI_index); - - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "draw_mesh.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/draw_point.cpp b/include/igl/opengl2/draw_point.cpp deleted file mode 100644 index 910fcc716..000000000 --- a/include/igl/opengl2/draw_point.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "draw_point.h" - -// Implementation -#include "gl.h" - -#include -#include - -IGL_INLINE void igl::opengl2::draw_point( - const double x, - const double y, - const double z, - const double requested_r, - const bool selected) -{ - // Push GL settings - glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT); - - float f; - glGetFloatv(GL_POINT_SIZE_MAX,&f); - // THIS IS OVERZEALOUS on Mac OS X: OpenGL reports a smaller point size than - // possible. - //assert(requested_r<=0.5*f); - double r = (requested_r<0.5*f?requested_r:0.5*f); - - //glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - - // get current color - float color[4]; - glGetFloatv(GL_CURRENT_COLOR,color); - - double outline_size = (r>7 ? sqrt(r/7.0) : 1.0); - - // White outline - glColor4f(1,1,1,color[3]); - glPointSize(2*r); - glBegin(GL_POINTS); - glVertex3d(x,y,z); - glEnd(); - // Black outline - glColor4f(0,0,0,color[3]); - glPointSize(2*r-2*outline_size); - glBegin(GL_POINTS); - glVertex3d(x,y,z); - glEnd(); - - // Foreground - glColor4fv(color); - glPointSize(2*r-4*outline_size); - glBegin(GL_POINTS); - glVertex3d(x,y,z); - glEnd(); - // Selection inner circle - if(selected) - { - glColor4f(0,0,0,color[3]); - double selected_size = 2*r-7*outline_size; - selected_size = (selected_size>3?selected_size:3); - glPointSize(selected_size); - glBegin(GL_POINTS); - glVertex3d(x,y,z); - glEnd(); - } - - // reset color - glColor4fv(color); - - // Pop GL settings - glPopAttrib(); -} - -template -IGL_INLINE void igl::opengl2::draw_point( - const Eigen::PlainObjectBase & P, - const double requested_r, - const bool selected) -{ - switch(P.size()) - { - case 2: - return draw_point(P(0),P(1),0,requested_r,selected); - default: - return draw_point(P(0),P(1),P(2),requested_r,selected); - } -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -template void igl::opengl2::draw_point >(Eigen::PlainObjectBase > const&, double, bool); -template void igl::opengl2::draw_point >(Eigen::PlainObjectBase > const&, double, bool); -#endif - diff --git a/include/igl/opengl2/draw_point.h b/include/igl/opengl2/draw_point.h deleted file mode 100644 index 2c7cc1c7d..000000000 --- a/include/igl/opengl2/draw_point.h +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_POINT_H -#define IGL_OPENGL2_DRAW_POINT_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace opengl2 - { - - //double POINT_COLOR[3] = {239./255.,213./255.,46./255.}; - // Draw a nice looking, colored dot at a given point in 3d. - // - // Note: expects that GL_CURRENT_COLOR is set with the desired foreground color - // - // Inputs: - // x x-coordinate of point, modelview coordinates - // y y-coordinate of point, modelview coordinates - // z z-coordinate of point, modelview coordinates - // requested_r outer-most radius of dot {7}, measured in screen space pixels - // selected fills inner circle with black {false} - // Asserts that requested_r does not exceed 0.5*GL_POINT_SIZE_MAX - IGL_INLINE void draw_point( - const double x, - const double y, - const double z, - const double requested_r = 7, - const bool selected = false); - template - IGL_INLINE void draw_point( - const Eigen::PlainObjectBase & P, - const double requested_r = 7, - const bool selected = false); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "draw_point.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/draw_rectangular_marquee.cpp b/include/igl/opengl2/draw_rectangular_marquee.cpp deleted file mode 100644 index 73f97c844..000000000 --- a/include/igl/opengl2/draw_rectangular_marquee.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. - - -#include "draw_rectangular_marquee.h" -#include "gl.h" -#include "glu.h" -#include "../material_colors.h" - -IGL_INLINE void igl::opengl2::draw_rectangular_marquee( - const int from_x, - const int from_y, - const int to_x, - const int to_y) -{ - using namespace std; - int l; - glGetIntegerv(GL_LIGHTING,&l); - int s; - glGetIntegerv(GL_LINE_STIPPLE,&s); - double lw; - glGetDoublev(GL_LINE_WIDTH,&lw); - glDisable(GL_LIGHTING); - // Screen space for this viewport - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT,viewport); - const int width = viewport[2]; - const int height = viewport[3]; - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluOrtho2D(0,width,0,height); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glEnable(GL_LINE_STIPPLE); - glLineStipple(3,0xAAAA); - glLineWidth(1); - glColor4f(0.2,0.2,0.2,1); - glBegin(GL_LINE_STRIP); - glVertex2d(from_x,from_y); - glVertex2d(to_x,from_y); - glVertex2d(to_x,to_y); - glVertex2d(from_x,to_y); - glVertex2d(from_x,from_y); - glEnd(); - - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glLineWidth(lw); - (s ? glEnable(GL_LINE_STIPPLE):glDisable(GL_LINE_STIPPLE)); - (l ? glEnable(GL_LIGHTING):glDisable(GL_LIGHTING)); -} - diff --git a/include/igl/opengl2/draw_rectangular_marquee.h b/include/igl/opengl2/draw_rectangular_marquee.h deleted file mode 100644 index bbb2e3f18..000000000 --- a/include/igl/opengl2/draw_rectangular_marquee.h +++ /dev/null @@ -1,35 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_RECTANGULAR_MARQUEE_H -#define IGL_OPENGL2_DRAW_RECTANGULAR_MARQUEE_H -#include "../igl_inline.h" -namespace igl -{ - namespace opengl2 - { - // Draw a rectangular marquee (selection box) in screen space. This sets up - // screen space using current viewport. - // - // Inputs: - // from_x x coordinate of from point - // from_y y coordinate of from point - // to_x x coordinate of to point - // to_y y coordinate of to point - IGL_INLINE void draw_rectangular_marquee( - const int from_x, - const int from_y, - const int to_x, - const int to_y); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "draw_rectangular_marquee.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/draw_skeleton_3d.cpp b/include/igl/opengl2/draw_skeleton_3d.cpp deleted file mode 100644 index a0ca6139a..000000000 --- a/include/igl/opengl2/draw_skeleton_3d.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. - -#include "draw_skeleton_3d.h" -#include "../PI.h" -#include "../material_colors.h" -#include "gl.h" -#include -#include - - -template < - typename DerivedC, - typename DerivedBE, - typename DerivedT, - typename Derivedcolor> -IGL_INLINE void igl::opengl2::draw_skeleton_3d( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T, - const Eigen::PlainObjectBase & color, - const double half_bbd) -{ - // Note: Maya's skeleton *does* scale with the mesh suggesting a scale - // parameter. Further, its joint balls are not rotated with the bones. - using namespace Eigen; - using namespace std; - if(color.size() == 0) - { - return draw_skeleton_3d(C,BE,T,MAYA_SEA_GREEN,half_bbd); - } - assert(color.cols() == 4 || color.size() == 4); - if(T.size() == 0) - { - typedef Eigen::Matrix Mat; - Mat I = Mat::Identity(C.cols()+1,C.cols()); - Mat T = I.replicate(BE.rows(),1); - // insane base case - if(T.size() == 0) - { - return; - } - return draw_skeleton_3d(C,BE,T,color,half_bbd); - } - assert(T.rows() == BE.rows()*(C.cols()+1)); - assert(T.cols() == C.cols()); - // push old settings - glPushAttrib(GL_LIGHTING_BIT); - glPushAttrib(GL_LINE_BIT); - glDisable(GL_LIGHTING); - glLineWidth(1.0); - - auto draw_sphere = [](const double r) - { - auto draw_circle = []() - { - glBegin(GL_LINE_STRIP); - for(double th = 0;th<2.0*igl::PI;th+=(2.0*igl::PI/30.0)) - { - glVertex3d(cos(th),sin(th),0.0); - } - glVertex3d(cos(0),sin(0),0.0); - glEnd(); - }; - glPushMatrix(); - glScaled(r,r,r); - draw_circle(); - glRotated(90.0,1.0,0.0,0.0); - draw_circle(); - glRotated(90.0,0.0,1.0,0.0); - draw_circle(); - glPopMatrix(); - }; - auto draw_pyramid = []() - { - glBegin(GL_LINE_STRIP); - glVertex3d(0, 1,-1); - glVertex3d(0,-1,-1); - glVertex3d(0,-1, 1); - glVertex3d(0, 1, 1); - glVertex3d(0, 1,-1); - glEnd(); - glBegin(GL_LINES); - glVertex3d(0, 1,-1); - glVertex3d(1,0,0); - glVertex3d(0,-1,-1); - glVertex3d(1,0,0); - glVertex3d(0,-1, 1); - glVertex3d(1,0,0); - glVertex3d(0, 1, 1); - glVertex3d(1,0,0); - glEnd(); - }; - - // Loop over bones - for(int e = 0;e < BE.rows();e++) - { - // Draw a sphere - auto s = C.row(BE(e,0)); - auto d = C.row(BE(e,1)); - auto b = (d-s).transpose().eval(); - double r = 0.02*half_bbd; - Matrix4d Te = Matrix4d::Identity(); - Te.block(0,0,3,4) = T.block(e*4,0,4,3).transpose(); - Quaterniond q; - q.setFromTwoVectors(Vector3d(1,0,0),b); - glPushMatrix(); - glMultMatrixd(Te.data()); - glTranslated(s(0),s(1),s(2)); - if(color.size() == 4) - { - glColor4d( color(0), color(1), color(2), color(3)); - }else - { - glColor4d( color(e,0), color(e,1), color(e,2), color(e,3)); - } - draw_sphere(r); - const double len = b.norm()-2.*r; - if(len>=0) - { - auto u = b.normalized()*r; - glPushMatrix(); - glTranslated(u(0),u(1),u(2)); - glMultMatrixd(Affine3d(q).matrix().data()); - glScaled(b.norm()-2.*r,r,r); - draw_pyramid(); - glPopMatrix(); - } - glTranslated(b(0),b(1),b(2)); - draw_sphere(r); - glPopMatrix(); - } - // Reset settings - glPopAttrib(); - glPopAttrib(); -} - -template -IGL_INLINE void igl::opengl2::draw_skeleton_3d( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T) -{ - return draw_skeleton_3d(C,BE,T,MAYA_SEA_GREEN); -} - -template -IGL_INLINE void igl::opengl2::draw_skeleton_3d( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE) -{ - return draw_skeleton_3d(C,BE,Eigen::MatrixXd(),MAYA_SEA_GREEN); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -template void igl::opengl2::draw_skeleton_3d, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); -template void igl::opengl2::draw_skeleton_3d, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); -template void igl::opengl2::draw_skeleton_3d, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, double); -template void igl::opengl2::draw_skeleton_3d, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, double); -#endif diff --git a/include/igl/opengl2/draw_skeleton_3d.h b/include/igl/opengl2/draw_skeleton_3d.h deleted file mode 100644 index 7bbb59717..000000000 --- a/include/igl/opengl2/draw_skeleton_3d.h +++ /dev/null @@ -1,53 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_SKELETON_3D_H -#define IGL_OPENGL2_DRAW_SKELETON_3D_H -#include "../igl_inline.h" -#include "../material_colors.h" -#include -namespace igl -{ - namespace opengl2 - { - - // Draw a skeleton - // - // Inputs: - // C #C by dim List of joint rest positions - // BE #BE by 2 list of bone edge indices into C - // T #BE*(dim+1) by dim matrix of stacked transposed bone transformations - // color #BE|1 by 4 list of color - // half_bbd half bounding box diagonal to determine scaling {1.0} - template < - typename DerivedC, - typename DerivedBE, - typename DerivedT, - typename Derivedcolor> - IGL_INLINE void draw_skeleton_3d( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T, - const Eigen::PlainObjectBase & color, - const double half_bbd=0.5); - // Default color - template - IGL_INLINE void draw_skeleton_3d( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T); - template - IGL_INLINE void draw_skeleton_3d( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "draw_skeleton_3d.cpp" -#endif -#endif diff --git a/include/igl/opengl2/draw_skeleton_vector_graphics.cpp b/include/igl/opengl2/draw_skeleton_vector_graphics.cpp deleted file mode 100644 index e45706120..000000000 --- a/include/igl/opengl2/draw_skeleton_vector_graphics.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "draw_skeleton_vector_graphics.h" -#include "draw_point.h" -#include "gl.h" -#include "../material_colors.h" - -IGL_INLINE void igl::opengl2::draw_skeleton_vector_graphics( - const Eigen::MatrixXd & C, - const Eigen::MatrixXi & BE) -{ - return draw_skeleton_vector_graphics(C,BE,BBW_POINT_COLOR,BBW_LINE_COLOR); -} - -IGL_INLINE void igl::opengl2::draw_skeleton_vector_graphics( - const Eigen::MatrixXd & C, - const Eigen::MatrixXi & BE, - const float * point_color, - const float * line_color) -{ - using namespace Eigen; - - int old_lighting=0; - double old_line_width=1; - glGetIntegerv(GL_LIGHTING,&old_lighting); - glGetDoublev(GL_LINE_WIDTH,&old_line_width); - int cm; - glGetIntegerv(GL_COLOR_MATERIAL,&cm); - glDisable(GL_LIGHTING); - glDisable(GL_LINE_STIPPLE); - //glEnable(GL_POLYGON_OFFSET_FILL); - glEnable(GL_COLOR_MATERIAL); - glLineWidth(10.0); - glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); - float mat_ambient[4] = {0.1,0.1,0.1,1.0}; - float mat_specular[4] = {0.0,0.0,0.0,1.0}; - float mat_shininess = 1; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); - glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); - - for(int i = 0;i<3;i++) - { - switch(i) - { - case 0: glColor3fv(WHITE); glLineWidth(10); break; - case 1: glColor3fv(BLACK); glLineWidth( 6); break; - case 2: glColor3fv(line_color); glLineWidth( 4); break; - } - // Loop over bone edges - glBegin(GL_LINES); - for(int e = 0;e -IGL_INLINE void igl::opengl2::draw_skeleton_vector_graphics( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T) -{ - return draw_skeleton_vector_graphics(C,BE,T,BBW_POINT_COLOR,BBW_LINE_COLOR); -} - -template -IGL_INLINE void igl::opengl2::draw_skeleton_vector_graphics( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T, - const float * point_color, - const float * line_color) -{ - DerivedC CT; - DerivedBE BET; - const int dim = T.cols(); - assert(dim == C.cols()); - CT.resize(2*BE.rows(),C.cols()); - BET.resize(BE.rows(),2); - for(int e = 0;e, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); -#endif diff --git a/include/igl/opengl2/draw_skeleton_vector_graphics.h b/include/igl/opengl2/draw_skeleton_vector_graphics.h deleted file mode 100644 index 8091cbb78..000000000 --- a/include/igl/opengl2/draw_skeleton_vector_graphics.h +++ /dev/null @@ -1,52 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_DRAW_SKELETON_VECTOR_GRAPHICS_H -#define IGL_OPENGL2_DRAW_SKELETON_VECTOR_GRAPHICS_H -#include "../igl_inline.h" -#include - -namespace igl -{ - namespace opengl2 - { - // Draw a skeleton with a 2D vector graphcis style à la BBW, STBS, Monotonic, - // FAST papers. - // - // Inputs: - // C #C by dim list of joint positions - // BE #BE by 2 list of bone edge indices into C - // point_color color of points - // line_color color of lines - IGL_INLINE void draw_skeleton_vector_graphics( - const Eigen::MatrixXd & C, - const Eigen::MatrixXi & BE, - const float * point_color, - const float * line_color); - // Use default colors (originally from BBW paper) - IGL_INLINE void draw_skeleton_vector_graphics( - const Eigen::MatrixXd & C, - const Eigen::MatrixXi & BE); - // T #BE*(dim+1) by dim matrix of stacked transposed bone transformations - template - IGL_INLINE void draw_skeleton_vector_graphics( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T, - const float * point_color, - const float * line_color); - template - IGL_INLINE void draw_skeleton_vector_graphics( - const Eigen::PlainObjectBase & C, - const Eigen::PlainObjectBase & BE, - const Eigen::PlainObjectBase & T); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "draw_skeleton_vector_graphics.cpp" -#endif -#endif diff --git a/include/igl/opengl2/flare_textures.h.REMOVED.git-id b/include/igl/opengl2/flare_textures.h.REMOVED.git-id deleted file mode 100644 index bf74c574e..000000000 --- a/include/igl/opengl2/flare_textures.h.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -0455195ebe076c34d28e9bfa34e2e0ec6b117571 \ No newline at end of file diff --git a/include/igl/opengl2/gl.h b/include/igl/opengl2/gl.h deleted file mode 100644 index 7147c9289..000000000 --- a/include/igl/opengl2/gl.h +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_GL_H -#define IGL_OPENGL2_GL_H - -#ifdef IGL_OPENGL_GL_H -# error "igl/opengl/gl.h already included" -#endif - -// Always use this: -// #include "gl.h" -// Instead of: -// #include -// or -// #include -// - -// For now this includes glu, glew and glext (perhaps these should be -// separated) -#ifdef _WIN32 -# define NOMINMAX -# include -# undef DrawText -# undef NOMINMAX -#endif - -#ifndef __APPLE__ -# define GLEW_STATIC -# include -#endif - -#ifdef __APPLE__ -# include -# define __gl_h_ /* Prevent inclusion of the old gl.h */ -#else -# include -#endif - -#endif diff --git a/include/igl/opengl2/glext.h b/include/igl/opengl2/glext.h deleted file mode 100644 index 78ff45fea..000000000 --- a/include/igl/opengl2/glext.h +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2017 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL_GLEXT_H -#define IGL_OPENGL_GLEXT_H - -#ifdef IGL_OPENGL2_GLEXT_H -# error "igl/opengl2/glext.h already included" -#endif - -// Always use this: -// #include "gl.h" -// Instead of: -// #include -// or -// #include -// - -#ifdef __APPLE__ -# include -#elif _WIN32 -// do nothing(?) -#else -# include -#endif - -#endif - diff --git a/include/igl/opengl2/glu.h b/include/igl/opengl2/glu.h deleted file mode 100644 index d4ab5e16c..000000000 --- a/include/igl/opengl2/glu.h +++ /dev/null @@ -1,30 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2017 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_GLU_H -#define IGL_OPENGL2_GLU_H - -#ifdef IGL_OPENGL_GLU_H -# error "igl/opengl/glu.h already included" -#endif - -// Always use this: -// #include "glu.h" -// Instead of: -// #include -// or -// #include -// - -#ifdef __APPLE__ -# include -#else -# include -#endif - -#endif - diff --git a/include/igl/opengl2/lens_flare.cpp b/include/igl/opengl2/lens_flare.cpp deleted file mode 100644 index c99f634c8..000000000 --- a/include/igl/opengl2/lens_flare.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "lens_flare.h" - -#include "../C_STR.h" -#include "unproject.h" -#include "project.h" -#include "shine_textures.h" -#include "flare_textures.h" - -#include -#include - -// http://www.opengl.org/archives/resources/features/KilgardTechniques/LensFlare/glflare.c - -IGL_INLINE void igl::opengl2::lens_flare_load_textures( - std::vector & shine_id, - std::vector & flare_id) -{ - - const auto setup_texture =[]( - const uint8_t * texture, - const int width, - const int height, - GLuint texobj, - GLenum minFilter, GLenum maxFilter) - { - glBindTexture(GL_TEXTURE_2D, texobj); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, maxFilter); - glTexImage2D(GL_TEXTURE_2D, 0, 1, width, height, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, texture); - }; - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - shine_id.resize(10); - glGenTextures(10,&shine_id[0]); - for (int i = 0; i < (int)shine_id.size(); i++) { - setup_texture( - SHINE_TEXTURES[i], - SHINE_TEXTURE_WIDTHS[i], - SHINE_TEXTURE_HEIGHTS[i], - shine_id[i], GL_LINEAR, GL_LINEAR); - } - flare_id.resize(6); - glGenTextures(6,&flare_id[0]); - for (int i = 0; i < (int)flare_id.size(); i++) { - setup_texture( - FLARE_TEXTURES[i], - FLARE_TEXTURE_WIDTHS[i], - FLARE_TEXTURE_HEIGHTS[i], - flare_id[i], GL_LINEAR, GL_LINEAR); - } -} - -IGL_INLINE void igl::opengl2::lens_flare_create( - const float * A, - const float * B, - const float * C, - std::vector & flares) -{ - using namespace std; - flares.resize(12); - /* Shines */ - flares[0] = Flare(-1, 1.0f, 0.1f, C, 1.0); - flares[1] = Flare(-1, 1.0f, 0.15f, B, 1.0); - flares[2] = Flare(-1, 1.0f, 0.35f, A, 1.0); - - /* Flares */ - flares[3] = Flare(2, 1.3f, 0.04f, A, 0.6); - flares[4] = Flare(3, 1.0f, 0.1f, A, 0.4); - flares[5] = Flare(1, 0.5f, 0.2f, A, 0.3); - flares[6] = Flare(3, 0.2f, 0.05f, A, 0.3); - flares[7] = Flare(0, 0.0f, 0.04f, A, 0.3); - flares[8] = Flare(5, -0.25f, 0.07f, A, 0.5); - flares[9] = Flare(5, -0.4f, 0.02f, A, 0.6); - flares[10] = Flare(5, -0.6f, 0.04f, A, 0.4); - flares[11] = Flare(5, -1.0f, 0.03f, A, 0.2); -} - -IGL_INLINE void igl::opengl2::lens_flare_draw( - const std::vector & flares, - const std::vector & shine_ids, - const std::vector & flare_ids, - const Eigen::Vector3f & light, - const float near_clip, - int & shine_tic) -{ - bool ot2 = glIsEnabled(GL_TEXTURE_2D); - bool ob = glIsEnabled(GL_BLEND); - bool odt = glIsEnabled(GL_DEPTH_TEST); - bool ocm = glIsEnabled(GL_COLOR_MATERIAL); - bool ol = glIsEnabled(GL_LIGHTING); - int obsa,obda,odf,odwm; - glGetIntegerv(GL_BLEND_SRC_ALPHA,&obsa); - glGetIntegerv(GL_BLEND_DST_ALPHA,&obda); - glGetIntegerv(GL_DEPTH_FUNC,&odf); - glGetIntegerv(GL_DEPTH_WRITEMASK,&odwm); - - glDisable(GL_COLOR_MATERIAL); - glEnable(GL_DEPTH_TEST); - //glDepthFunc(GL_LEQUAL); - glDepthMask(GL_FALSE); - glEnable(GL_TEXTURE_2D); - glDisable(GL_LIGHTING); - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); - - using namespace Eigen; - using namespace std; - - //// view_dir direction from eye to position it is looking at - //const Vector3f view_dir = (at - from).normalized(); - - //// near_clip distance from eye to near clipping plane along view_dir - //// center position on near clipping plane along viewdir from eye - //const Vector3f center = from + near_clip*view_dir; - - Vector3f plight = project(light); - // Orthogonal vectors to view direction at light - Vector3f psx = plight; - psx(0) += 1; - Vector3f psy = plight; - psy(1) += 1; - - // axis toward center - int vp[4]; - glGetIntegerv(GL_VIEWPORT,vp); - Vector3f center = unproject(Vector3f(0.5*vp[2],0.5*vp[3],plight[2]-1e-3)); - //Vector3f center(0,0,1); - Vector3f axis = light-center; - //glLineWidth(4.); - //glColor3f(1,0,0); - //glBegin(GL_LINES); - //glVertex3fv(center.data()); - //glVertex3fv(light.data()); - //glEnd(); - - const Vector3f SX = unproject(psx).normalized(); - const Vector3f SY = unproject(psy).normalized(); - - for(int i = 0; i < (int)flares.size(); i++) - { - const Vector3f sx = flares[i].scale * SX; - const Vector3f sy = flares[i].scale * SY; - glColor3fv(flares[i].color); - if (flares[i].type < 0) { - glBindTexture(GL_TEXTURE_2D, shine_ids[shine_tic]); - shine_tic = (shine_tic + 1) % shine_ids.size(); - } else - { - glBindTexture(GL_TEXTURE_2D, flare_ids[flares[i].type]); - } - - /* position = center + flare[i].loc * axis */ - const Vector3f position = center + flares[i].loc * axis; - Vector3f tmp; - - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); - tmp = position + sx; - tmp = tmp + sy; - glVertex3fv(tmp.data()); - - glTexCoord2f(1.0, 0.0); - tmp = position - sx; - tmp = tmp + sy; - glVertex3fv(tmp.data()); - - glTexCoord2f(1.0, 1.0); - tmp = position - sx; - tmp = tmp - sy; - glVertex3fv(tmp.data()); - - glTexCoord2f(0.0, 1.0); - tmp = position + sx; - tmp = tmp - sy; - glVertex3fv(tmp.data()); - glEnd(); - } - ot2?glEnable(GL_TEXTURE_2D):glDisable(GL_TEXTURE_2D); - ob?glEnable(GL_BLEND):glDisable(GL_BLEND); - odt?glEnable(GL_DEPTH_TEST):glDisable(GL_DEPTH_TEST); - ocm?glEnable(GL_COLOR_MATERIAL):glDisable(GL_COLOR_MATERIAL); - ol?glEnable(GL_LIGHTING):glDisable(GL_LIGHTING); - glBlendFunc(obsa,obda); - glDepthFunc(odf); - glDepthMask(odwm); -} diff --git a/include/igl/opengl2/lens_flare.h b/include/igl/opengl2/lens_flare.h deleted file mode 100644 index 280c27b69..000000000 --- a/include/igl/opengl2/lens_flare.h +++ /dev/null @@ -1,93 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_LENS_FLARE_H -#define IGL_OPENGL2_LENS_FLARE_H - -#include "../igl_inline.h" -#include "gl.h" -#include -#include - -namespace igl -{ - namespace opengl2 - { - - struct Flare{ - int type; /* flare texture index, 0..5 */ - float scale; - float loc; /* position on axis */ - float color[3]; - Flare(): - type(-1), - scale(0), - loc(0) - {} - Flare(int type, float location, float scale, const float color[3], float colorScale) : - type(type), - scale(scale), - loc(location) - { - this->color[0] = color[0] * colorScale; - this->color[1] = color[1] * colorScale; - this->color[2] = color[2] * colorScale; - } - }; - - - // Initialize shared data for lens flates - // - // Inputs: - // start_id starting texture id location (should have at least id:id+16 free) - // Outputs: - // shine list of texture ids for shines - // flare list of texture ids for flares - IGL_INLINE void lens_flare_load_textures( - std::vector & shine_ids, - std::vector & flare_ids); - - // Create a set of lens flares - // - // Inputs: - // A primary color - // B secondary color - // C secondary color - // Outputs: - // flares list of flare objects - IGL_INLINE void lens_flare_create( - const float * A, - const float * B, - const float * C, - std::vector & flares); - - // Draw lens flares - // - // Inputs: - // flares list of Flare objects - // shine_ids list of shine textures - // flare_ids list of flare texture ids - // light position of light - // near_clip near clipping plane - // shine_tic current "tic" in shine textures - // Outputs: - // shine_tic current "tic" in shine textures - IGL_INLINE void lens_flare_draw( - const std::vector & flares, - const std::vector & shine_ids, - const std::vector & flare_ids, - const Eigen::Vector3f & light, - const float near_clip, - int & shine_tic); - } -}; - -#ifndef IGL_STATIC_LIBRARY -# include "lens_flare.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/model_proj_viewport.cpp b/include/igl/opengl2/model_proj_viewport.cpp deleted file mode 100644 index 9fec32a49..000000000 --- a/include/igl/opengl2/model_proj_viewport.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "model_proj_viewport.h" -#include "gl.h" - -template -IGL_INLINE void igl::opengl2::model_proj_viewport( - Eigen::PlainObjectBase & model, - Eigen::PlainObjectBase & proj, - Eigen::PlainObjectBase & viewport) -{ - Eigen::Matrix4d MV,P; - Eigen::Vector4i VPi; - glGetDoublev(GL_MODELVIEW_MATRIX,MV.data()); - glGetDoublev(GL_PROJECTION_MATRIX,P.data()); - glGetIntegerv(GL_VIEWPORT,VPi.data()); - viewport = VPi.cast(); - model = MV.cast(); - proj = P.cast(); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -template void igl::opengl2::model_proj_viewport, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::opengl2::model_proj_viewport, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -#endif diff --git a/include/igl/opengl2/model_proj_viewport.h b/include/igl/opengl2/model_proj_viewport.h deleted file mode 100644 index 025247ae7..000000000 --- a/include/igl/opengl2/model_proj_viewport.h +++ /dev/null @@ -1,33 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_MODEL_PROJ_VIEW_H -#define IGL_OPENGL2_MODEL_PROJ_VIEW_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace opengl2 - { - // Collect the model-view, projection and viewport matrices - // - // Outputs: - // model 4x4 modelview matrix - // proj 4x4 projection matrix - // viewport 4x1 viewport vector - // - template - IGL_INLINE void model_proj_viewport( - Eigen::PlainObjectBase & model, - Eigen::PlainObjectBase & proj, - Eigen::PlainObjectBase & viewport); - } -} -#ifndef IGL_STATIC_LIBRARY -# include "model_proj_viewport.cpp" -#endif -#endif diff --git a/include/igl/opengl2/print_gl_get.cpp b/include/igl/opengl2/print_gl_get.cpp deleted file mode 100644 index 7182dc558..000000000 --- a/include/igl/opengl2/print_gl_get.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "print_gl_get.h" - -#include -IGL_INLINE void igl::opengl2::print_gl_get(GLenum pname) -{ - double dM[16]; - - int rows = 4; - int cols = 4; - switch(pname) - { - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - { - rows = 4; - cols = 4; - glGetDoublev(pname,dM); - for(int i = 0;i -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_PRINT_GL_GET_H -#define IGL_OPENGL2_PRINT_GL_GET_H -#include "gl.h" -#include "../igl_inline.h" - -namespace igl -{ - namespace opengl2 - { - // Prints the value of pname found by issuing glGet*(pname,*) - // Inputs: - // pname enum key to gl parameter - IGL_INLINE void print_gl_get(GLenum pname); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "print_gl_get.cpp" -#endif - -#endif diff --git a/include/igl/opengl2/project.cpp b/include/igl/opengl2/project.cpp deleted file mode 100644 index a953197b7..000000000 --- a/include/igl/opengl2/project.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "project.h" -#include "../project.h" -#include "gl.h" -#include "glu.h" -#include - -IGL_INLINE int igl::opengl2::project( - const double objX, - const double objY, - const double objZ, - double* winX, - double* winY, - double* winZ) -{ - using namespace std; - // Put model, projection, and viewport matrices into double arrays - double MV[16]; - double P[16]; - int VP[4]; - glGetDoublev(GL_MODELVIEW_MATRIX, MV); - glGetDoublev(GL_PROJECTION_MATRIX, P); - glGetIntegerv(GL_VIEWPORT, VP); - int ret = gluProject(objX,objY,objZ,MV,P,VP,winX,winY,winZ); - return ret; -} - -template -IGL_INLINE int igl::opengl2::project( - const Eigen::PlainObjectBase & obj, - Eigen::PlainObjectBase & win) -{ - assert(obj.size() >= 3); - Eigen::Vector3d dobj(obj(0),obj(1),obj(2)); - Eigen::Vector3d dwin; - int ret = igl::opengl2::project(dobj(0),dobj(1),dobj(2), - &dwin.data()[0], - &dwin.data()[1], - &dwin.data()[2]); - win(0) = dwin(0); - win(1) = dwin(1); - win(2) = dwin(2); - return ret; -} - -template -IGL_INLINE Derivedobj igl::opengl2::project( - const Eigen::PlainObjectBase & obj) -{ - Derivedobj win; - igl::opengl2::project(obj,win); - return win; -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -template int igl::opengl2::project, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template int igl::opengl2::project, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template int igl::opengl2::project, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); -template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); -template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); -template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); -template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); -template Eigen::Matrix igl::opengl2::project >(Eigen::PlainObjectBase > const&); -#endif - diff --git a/include/igl/opengl2/project.h b/include/igl/opengl2/project.h deleted file mode 100644 index befd09007..000000000 --- a/include/igl/opengl2/project.h +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_PROJECT_H -#define IGL_OPENGL2_PROJECT_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace opengl2 - { - // Wrapper for gluProject that uses the current GL_MODELVIEW_MATRIX, - // GL_PROJECTION_MATRIX, and GL_VIEWPORT - // Inputs: - // obj* 3D objects' x, y, and z coordinates respectively - // Outputs: - // win* pointers to screen space x, y, and z coordinates respectively - // Returns return value of gluProject call - IGL_INLINE int project( - const double objX, - const double objY, - const double objZ, - double* winX, - double* winY, - double* winZ); - // Eigen wrapper - template - IGL_INLINE int project( - const Eigen::PlainObjectBase & obj, - Eigen::PlainObjectBase & win); - // Eigen wrapper with return - template - IGL_INLINE Derivedobj project( - const Eigen::PlainObjectBase & obj); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "project.cpp" -#endif - -#endif - diff --git a/include/igl/opengl2/right_axis.cpp b/include/igl/opengl2/right_axis.cpp deleted file mode 100644 index a0b905176..000000000 --- a/include/igl/opengl2/right_axis.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "right_axis.h" -#include "gl.h" - -IGL_INLINE void igl::opengl2::right_axis(double * x, double * y, double * z) -{ - double mv[16]; - glGetDoublev(GL_MODELVIEW_MATRIX, mv); - igl::opengl2::right_axis(mv,x,y,z); -} - -IGL_INLINE void igl::opengl2::right_axis(const double * mv,double * x, double * y, double * z) -{ - *x = -mv[0*4+0]; - *y = -mv[1*4+0]; - *z = -mv[2*4+0]; -} - - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -#endif diff --git a/include/igl/opengl2/right_axis.h b/include/igl/opengl2/right_axis.h deleted file mode 100644 index 4e6787cdd..000000000 --- a/include/igl/opengl2/right_axis.h +++ /dev/null @@ -1,34 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_RIGHT_AXIS_H -#define IGL_OPENGL2_RIGHT_AXIS_H -#include "../igl_inline.h" -namespace igl -{ - namespace opengl2 - { - // Determines the right axis or depth axis of the current gl matrix - // Outputs: - // x pointer to x-coordinate in scene coordinates of the un-normalized - // right axis - // y pointer to y-coordinate in scene coordinates of the un-normalized - // right axis - // z pointer to z-coordinate in scene coordinates of the un-normalized - // right axis - // mv pointer to modelview matrix - // - // Note: Right axis is returned *UN-normalized* - IGL_INLINE void right_axis(double * x, double * y, double * z); - IGL_INLINE void right_axis(const double * mv, double * x, double * y, double * z); - } -}; - -#ifndef IGL_STATIC_LIBRARY -# include "right_axis.cpp" -#endif -#endif diff --git a/include/igl/opengl2/shine_textures.h.REMOVED.git-id b/include/igl/opengl2/shine_textures.h.REMOVED.git-id deleted file mode 100644 index 8da32d5b0..000000000 --- a/include/igl/opengl2/shine_textures.h.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -05001989d8ff527cd57823f435ec025540ebf18e \ No newline at end of file diff --git a/include/igl/opengl2/sort_triangles.cpp b/include/igl/opengl2/sort_triangles.cpp deleted file mode 100644 index ae9671099..000000000 --- a/include/igl/opengl2/sort_triangles.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "sort_triangles.h" -#include "project.h" -#include "../sort_triangles.h" -#include "gl.h" -#include "../sort.h" -#include "../slice.h" -#include "../barycenter.h" -#include -template < - typename DerivedV, - typename DerivedF, - typename DerivedFF, - typename DerivedI> -void igl::opengl2::sort_triangles( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & I) -{ - using namespace Eigen; - using namespace std; - // Put model, projection, and viewport matrices into double arrays - Matrix4d MV; - Matrix4d P; - glGetDoublev(GL_MODELVIEW_MATRIX, MV.data()); - glGetDoublev(GL_PROJECTION_MATRIX, P.data()); - if(V.cols() == 3) - { - Matrix hV; - hV.resize(V.rows(),4); - hV.block(0,0,V.rows(),V.cols()) = V; - hV.col(3).setConstant(1); - return igl::sort_triangles(hV,F,MV,P,FF,I); - }else - { - return igl::sort_triangles(V,F,MV,P,FF,I); - } -} - -template < - typename DerivedV, - typename DerivedF, - typename DerivedFF, - typename DerivedI> -void igl::opengl2::sort_triangles_slow( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & I) -{ - using namespace Eigen; - using namespace std; - // Barycenter, centroid - Eigen::Matrix D,sD; - Eigen::Matrix BC; - D.resize(F.rows(),3); - barycenter(V,F,BC); - for(int f = 0;f bc,pbc; - bc = BC.row(f); - project(bc,pbc); - D(f) = pbc(2); - } - sort(D,1,false,sD,I); - slice(F,I,1,FF); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -template void igl::opengl2::sort_triangles, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::opengl2::sort_triangles_slow, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -#endif diff --git a/include/igl/opengl2/sort_triangles.h b/include/igl/opengl2/sort_triangles.h deleted file mode 100644 index 53fd3e809..000000000 --- a/include/igl/opengl2/sort_triangles.h +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_SORT_TRIANGLES_H -#define IGL_OPENGL2_SORT_TRIANGLES_H - -#include "../igl_inline.h" -#include - -namespace igl -{ - namespace opengl2 - { - template < - typename DerivedV, - typename DerivedF, - typename DerivedFF, - typename DerivedI> - IGL_INLINE void sort_triangles( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & I); - template < - typename DerivedV, - typename DerivedF, - typename DerivedFF, - typename DerivedI> - IGL_INLINE void sort_triangles_slow( - const Eigen::PlainObjectBase & V, - const Eigen::PlainObjectBase & F, - Eigen::PlainObjectBase & FF, - Eigen::PlainObjectBase & I); - //template < - // typename DerivedV, - // typename DerivedF, - // typename DerivedMV, - // typename DerivedP, - // typename DerivedFF, - // typename DerivedI> - //IGL_INLINE void sort_triangles_robust( - // const Eigen::PlainObjectBase & V, - // const Eigen::PlainObjectBase & F, - // const Eigen::PlainObjectBase & MV, - // const Eigen::PlainObjectBase & P, - // Eigen::PlainObjectBase & FF, - // Eigen::PlainObjectBase & I); - //template < - // typename DerivedV, - // typename DerivedF, - // typename DerivedFF, - // typename DerivedI> - //IGL_INLINE void sort_triangles_robust( - // const Eigen::PlainObjectBase & V, - // const Eigen::PlainObjectBase & F, - // Eigen::PlainObjectBase & FF, - // Eigen::PlainObjectBase & I); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "sort_triangles.cpp" -#endif - -#endif - diff --git a/include/igl/opengl2/unproject.cpp b/include/igl/opengl2/unproject.cpp deleted file mode 100644 index f6b0013fe..000000000 --- a/include/igl/opengl2/unproject.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "unproject.h" -#include "model_proj_viewport.h" -#include "../unproject.h" -#include "gl.h" - -#include -#include - -IGL_INLINE void igl::opengl2::unproject( - const double winX, - const double winY, - const double winZ, - double* objX, - double* objY, - double* objZ) -{ - Eigen::Vector3d obj; - igl::opengl2::unproject(Eigen::Vector3d(winX,winY,winZ),obj); - *objX = obj(0); - *objY = obj(1); - *objZ = obj(2); -} - -template -IGL_INLINE void igl::opengl2::unproject( - const Eigen::PlainObjectBase & win, - Eigen::PlainObjectBase & obj) -{ - const auto ret = igl::opengl2::unproject(win); - obj = ret.template cast(); -} - - -template -IGL_INLINE Derivedwin igl::opengl2::unproject( - const Eigen::PlainObjectBase & win) -{ - using namespace Eigen; - typedef typename Derivedwin::Scalar Scalar; - Matrix4d MV,P; - Vector4d VPd; - model_proj_viewport(MV,P,VPd); - Vector3d wind = win.template cast(); - Vector3d objd = igl::unproject(wind,MV,P,VPd); - return objd.template cast(); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -// generated by autoexplicit.sh -template void igl::opengl2::unproject, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::opengl2::unproject, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template Eigen::Matrix igl::opengl2::unproject >(Eigen::PlainObjectBase > const&); -template Eigen::Matrix igl::opengl2::unproject >(Eigen::PlainObjectBase > const&); -template void igl::opengl2::unproject, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -#endif diff --git a/include/igl/opengl2/unproject.h b/include/igl/opengl2/unproject.h deleted file mode 100644 index 00de13077..000000000 --- a/include/igl/opengl2/unproject.h +++ /dev/null @@ -1,46 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_UNPROJECT_H -#define IGL_OPENGL2_UNPROJECT_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace opengl2 - { - // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX, - // GL_PROJECTION_MATRIX, and GL_VIEWPORT - // Inputs: - // win* screen space x, y, and z coordinates respectively - // Outputs: - // obj* pointers to 3D objects' x, y, and z coordinates respectively - // Returns return value of gluUnProject call - IGL_INLINE void unproject( - const double winX, - const double winY, - const double winZ, - double* objX, - double* objY, - double* objZ); - template - IGL_INLINE void unproject( - const Eigen::PlainObjectBase & win, - Eigen::PlainObjectBase & obj); - template - IGL_INLINE Derivedwin unproject( - const Eigen::PlainObjectBase & win); - } -} - - -#ifndef IGL_STATIC_LIBRARY -# include "unproject.cpp" -#endif - -#endif - diff --git a/include/igl/opengl2/unproject_to_zero_plane.cpp b/include/igl/opengl2/unproject_to_zero_plane.cpp deleted file mode 100644 index 1c2945886..000000000 --- a/include/igl/opengl2/unproject_to_zero_plane.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "unproject_to_zero_plane.h" - -#include "gl.h" - -#include "project.h" -#include "unproject.h" - -IGL_INLINE void igl::opengl2::unproject_to_zero_plane( - const double winX, - const double winY, - double* objX, - double* objY, - double* objZ) -{ - double winOrigin[3]; - igl::opengl2::project(0,0,0,&winOrigin[0],&winOrigin[1],&winOrigin[2]); - return igl::opengl2::unproject(winX, winY, winOrigin[2], objX, objY, objZ); -} - -template -IGL_INLINE void igl::opengl2::unproject_to_zero_plane( - const Eigen::PlainObjectBase & win, - Eigen::PlainObjectBase & obj) -{ - return unproject_to_zero_plane(win(0),win(1), - &obj.data()[0], - &obj.data()[1], - &obj.data()[2]); -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -// generated by autoexplicit.sh -template void igl::opengl2::unproject_to_zero_plane, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::opengl2::unproject_to_zero_plane, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -template void igl::opengl2::unproject_to_zero_plane, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); -#endif - diff --git a/include/igl/opengl2/unproject_to_zero_plane.h b/include/igl/opengl2/unproject_to_zero_plane.h deleted file mode 100644 index d76337e20..000000000 --- a/include/igl/opengl2/unproject_to_zero_plane.h +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_UNPROJECT_TO_ZERO_PLANE_H -#define IGL_OPENGL2_UNPROJECT_TO_ZERO_PLANE_H -#include "../igl_inline.h" -#include -namespace igl -{ - namespace opengl2 - { - // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX, - // GL_PROJECTION_MATRIX, and GL_VIEWPORT to unproject a screen position - // (winX,winY) to a 3d location at same depth as the current origin. - // Inputs: - // win* screen space x, y, and z coordinates respectively - // Outputs: - // obj* pointers to 3D objects' x, y, and z coordinates respectively - // Returns return value of gluUnProject call - IGL_INLINE void unproject_to_zero_plane( - const double winX, - const double winY, - double* objX, - double* objY, - double* objZ); - template - IGL_INLINE void unproject_to_zero_plane( - const Eigen::PlainObjectBase & win, - Eigen::PlainObjectBase & obj); - } -} - -#ifndef IGL_STATIC_LIBRARY -# include "unproject_to_zero_plane.cpp" -#endif - -#endif - diff --git a/include/igl/opengl2/up_axis.cpp b/include/igl/opengl2/up_axis.cpp deleted file mode 100644 index c6b3c02a0..000000000 --- a/include/igl/opengl2/up_axis.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "up_axis.h" -#include "gl.h" - -IGL_INLINE void igl::opengl2::up_axis(double * x, double * y, double * z) -{ - double mv[16]; - glGetDoublev(GL_MODELVIEW_MATRIX, mv); - igl::opengl2::up_axis(mv,x,y,z); -} - -IGL_INLINE void igl::opengl2::up_axis(const double *mv, double * x, double * y, double * z) -{ - *x = -mv[0*4+1]; - *y = -mv[1*4+1]; - *z = -mv[2*4+1]; -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -// generated by autoexplicit.sh -#endif diff --git a/include/igl/opengl2/up_axis.h b/include/igl/opengl2/up_axis.h deleted file mode 100644 index 2c042fb2c..000000000 --- a/include/igl/opengl2/up_axis.h +++ /dev/null @@ -1,36 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_UP_AXIS_H -#define IGL_OPENGL2_UP_AXIS_H -#include "../igl_inline.h" -namespace igl -{ - namespace opengl2 - { - // Determines the up axis or depth axis of the current gl matrix - // Outputs: - // x pointer to x-coordinate in scene coordinates of the un-normalized - // up axis - // y pointer to y-coordinate in scene coordinates of the un-normalized - // up axis - // z pointer to z-coordinate in scene coordinates of the un-normalized - // up axis - // mv pointer to modelview matrix - // - // Note: Up axis is returned *UN-normalized* - IGL_INLINE void up_axis(double * x, double * y, double * z); - IGL_INLINE void up_axis(const double * mv, double * x, double * y, double * z); - } -}; - -#ifndef IGL_STATIC_LIBRARY -# include "up_axis.cpp" -#endif -#endif - - diff --git a/include/igl/opengl2/view_axis.cpp b/include/igl/opengl2/view_axis.cpp deleted file mode 100644 index 5145cd207..000000000 --- a/include/igl/opengl2/view_axis.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#include "view_axis.h" -#include "gl.h" - -IGL_INLINE void igl::opengl2::view_axis(double * x, double * y, double * z) -{ - double mv[16]; - glGetDoublev(GL_MODELVIEW_MATRIX, mv); - igl::opengl2::view_axis(mv,x,y,z); -} - -IGL_INLINE void igl::opengl2::view_axis(const double * mv, double * x, double * y, double * z) -{ - *x = -mv[0*4+2]; - *y = -mv[1*4+2]; - *z = -mv[2*4+2]; -} - -template -IGL_INLINE void igl::opengl2::view_axis(Eigen::PlainObjectBase & V) -{ - double x,y,z; - view_axis(&x,&y,&z); - V(0) = x; - V(1) = y; - V(2) = z; -} - -#ifdef IGL_STATIC_LIBRARY -// Explicit template instantiation -// generated by autoexplicit.sh -template void igl::opengl2::view_axis >(Eigen::PlainObjectBase >&); -template void igl::opengl2::view_axis >(Eigen::PlainObjectBase >&); -#endif diff --git a/include/igl/opengl2/view_axis.h b/include/igl/opengl2/view_axis.h deleted file mode 100644 index ab324cbad..000000000 --- a/include/igl/opengl2/view_axis.h +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2013 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_OPENGL2_VIEW_AXIS_H -#define IGL_OPENGL2_VIEW_AXIS_H -#include "../igl_inline.h" -#include - -namespace igl -{ - namespace opengl2 - { - // Determines the view axis or depth axis of the current gl matrix - // Inputs: - // mv pointer to modelview matrix - // Outputs: - // x pointer to x-coordinate in scene coordinates of the un-normalized - // viewing axis - // y pointer to y-coordinate in scene coordinates of the un-normalized - // viewing axis - // z pointer to z-coordinate in scene coordinates of the un-normalized - // viewing axis - // - // Note: View axis is returned *UN-normalized* - IGL_INLINE void view_axis(const double * mv, double * x, double * y, double * z); - // Extract mv from current GL state. - IGL_INLINE void view_axis(double * x, double * y, double * z); - template - IGL_INLINE void view_axis(Eigen::PlainObjectBase & V); - } -}; - - -#ifndef IGL_STATIC_LIBRARY -# include "view_axis.cpp" -#endif - -#endif - diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6e92fe144..bf4dbb3cd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -23,10 +23,6 @@ if(UNIX) endif() endif() -## include pybind -set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/../external/pybind11 CACHE PATH "Path to pybind11") -add_subdirectory(${PYBIND11_DIR} pybind11) - ## include libigl option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" OFF) option(LIBIGL_WITH_OPENGL "Use viewer" ON) @@ -48,10 +44,14 @@ option(LIBIGL_WITH_COPYLEFT "Use Copyleft" ON) ## libigl if(NOT TARGET igl::core) - list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../shared/cmake") + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake") include(libigl) endif() +## include pybind +set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/../external/pybind11 CACHE PATH "Path to pybind11") +add_subdirectory(${PYBIND11_DIR} pybind11) + ## Prepare the python library pybind11_add_module(pyigl python_shared.cpp diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index b7b256c25..4a17adea4 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -4,7 +4,7 @@ message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") ### conditionally compile certain modules depending on libraries found on the system -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../shared/cmake) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) #find_package(CGAL QUIET COMPONENTS Core) find_package(MATLAB QUIET) find_package(MOSEK) @@ -123,9 +123,6 @@ if(TUTORIALS_CHAPTER6) if(LIBIGL_WITH_PNG) add_subdirectory("607_ScreenCapture") endif() - if(LIBIGL_WITH_LIM) - add_subdirectory("608_LIM") - endif() if(LIBIGL_WITH_CGAL) add_subdirectory("609_Boolean") add_subdirectory("610_CSGTree")