Mercurial > hg > ccmieditor
view native/PhantomOmni/utils.cpp @ 8:ea7885bd9bff tip
fixed bug : render solid line as dotted/dashed when moving the stylus from dotted/dashed to solid
author | ccmi-guest |
---|---|
date | Thu, 03 Jul 2014 16:12:20 +0100 |
parents | 9e67171477bc |
children |
line wrap: on
line source
#include "utils.h" void checkExceptions(JNIEnv *env, char* what){ if(env->ExceptionOccurred()){ std::cout << "Exception occurred!!!" << std::endl; std::cout << what << std::endl; env->ExceptionDescribe(); exit(-1); } } void stopExecution(char* msg){ std::cerr << msg << std::endl; exit(-1); } bool fromScreen(const hduVector3Dd &win, hduVector3Dd &obj) { hduMatrix m_worldTview; hduMatrix m_viewTclip; int m_viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, m_worldTview); glGetDoublev(GL_PROJECTION_MATRIX, m_viewTclip); glGetIntegerv(GL_VIEWPORT, m_viewport); int nResult = gluUnProject( win[0], win[1], win[2], m_worldTview, m_viewTclip, m_viewport, &obj[0], &obj[1], &obj[2]); return nResult == GL_TRUE; } bool toScreen(const hduVector3Dd &obj, hduVector3Dd &win) { hduMatrix m_worldTview; hduMatrix m_viewTclip; int m_viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, m_worldTview); glGetDoublev(GL_PROJECTION_MATRIX, m_viewTclip); glGetIntegerv(GL_VIEWPORT, m_viewport); int nResult = gluProject( obj[0], obj[1], obj[2], m_worldTview, m_viewTclip, m_viewport, &win[0], &win[1], &win[2]); return nResult == GL_TRUE; } HDdouble norm(HDdouble v[3]){ return sqrt( (v[0]*v[0])+(v[1]*v[1])+(v[2]*v[2])); } void print(char* str){ std::cout << str << std::endl; } void print(int str){ std::cout << str << std::endl; } float rotate(){ static float rot = 0.0f; rot += 0.5f; if(rot > 360) rot = 0; return rot; }