fiore@3: #include "utils.h" fiore@3: fiore@3: void checkExceptions(JNIEnv *env, char* what){ fiore@3: if(env->ExceptionOccurred()){ fiore@3: std::cout << "Exception occurred!!!" << std::endl; fiore@3: std::cout << what << std::endl; fiore@3: env->ExceptionDescribe(); fiore@3: exit(-1); fiore@3: } fiore@3: } fiore@3: fiore@3: void stopExecution(char* msg){ fiore@3: std::cerr << msg << std::endl; fiore@3: exit(-1); fiore@3: } fiore@3: fiore@3: fiore@3: bool fromScreen(const hduVector3Dd &win, hduVector3Dd &obj) { fiore@3: fiore@3: hduMatrix m_worldTview; fiore@3: hduMatrix m_viewTclip; fiore@3: int m_viewport[4]; fiore@3: glGetDoublev(GL_MODELVIEW_MATRIX, m_worldTview); fiore@3: glGetDoublev(GL_PROJECTION_MATRIX, m_viewTclip); fiore@3: glGetIntegerv(GL_VIEWPORT, m_viewport); fiore@3: int nResult = gluUnProject( fiore@3: win[0], win[1], win[2], fiore@3: m_worldTview, fiore@3: m_viewTclip, fiore@3: m_viewport, fiore@3: &obj[0], &obj[1], &obj[2]); fiore@3: fiore@3: return nResult == GL_TRUE; fiore@3: } fiore@3: fiore@3: bool toScreen(const hduVector3Dd &obj, hduVector3Dd &win) { fiore@3: fiore@3: hduMatrix m_worldTview; fiore@3: hduMatrix m_viewTclip; fiore@3: int m_viewport[4]; fiore@3: glGetDoublev(GL_MODELVIEW_MATRIX, m_worldTview); fiore@3: glGetDoublev(GL_PROJECTION_MATRIX, m_viewTclip); fiore@3: glGetIntegerv(GL_VIEWPORT, m_viewport); fiore@3: int nResult = gluProject( fiore@3: obj[0], obj[1], obj[2], fiore@3: m_worldTview, fiore@3: m_viewTclip, fiore@3: m_viewport, fiore@3: &win[0], &win[1], &win[2]); fiore@3: fiore@3: return nResult == GL_TRUE; fiore@3: } fiore@3: fiore@3: fiore@3: HDdouble norm(HDdouble v[3]){ fiore@3: return sqrt( (v[0]*v[0])+(v[1]*v[1])+(v[2]*v[2])); fiore@3: } fiore@3: fiore@3: void print(char* str){ fiore@3: std::cout << str << std::endl; fiore@3: } fiore@3: fiore@3: void print(int str){ fiore@3: std::cout << str << std::endl; fiore@3: } fiore@3: fiore@3: float rotate(){ fiore@3: static float rot = 0.0f; fiore@3: rot += 0.5f; fiore@3: if(rot > 360) fiore@3: rot = 0; fiore@3: return rot; fiore@3: }