void Input::MouseClick (int button, int state, int x, int y) { y = Params::WindowHeight - y-1; if( state == GLUT_DOWN ) { Draw::draw_selectable(); unsigned char pRGBA[4]; glReadBuffer( GL_BACK ); glReadPixels( x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pRGBA ); selected_face_color = //MeshObj::color_to_i(ColorVec4(pRGBA[0], pRGBA[1], pRGBA[2], pRGBA[3])); MeshObj::color_to_i(pRGBA); cout << "color: " << (int)pRGBA[0] << "," << (int)pRGBA[1] << "," << (int)pRGBA[2] << "," << (int)pRGBA[3] << ","<< endl; //------------------------------------------------------------------------- Vec3f psphere; if(SpherePoint(View::SphereCenter, View::SphereRadius, ScreenToWorld(Params::MainWindow, x, y), psphere)) { CurrentPsphere = psphere; NewPsphere = psphere; } glutPostRedisplay(); } if(state == GLUT_UP) { CurrentPsphere = NewPsphere; } }
void MouseMotion(int x, int y) { y = WindowParams::WindowHeight - y-1; Vec3f psphere; if(SpherePoint(SphereCenter,SphereRadius,ScreenToWorld(WindowParams::MainWindow,x,y),psphere)) { ExaminerRotAxis = cross(CurrentPsphere-SphereCenter, psphere-SphereCenter); ExaminerRotAngle = acos((CurrentPsphere-SphereCenter).dot(psphere-SphereCenter)/SphereRadius/SphereRadius); ExaminerRotation = Maflo::Rotation(ExaminerRotAngle,ExaminerRotAxis)*ExaminerRotation; CurrentPsphere = psphere; } glutPostRedisplay(); }
void MouseClick (int button, int state, int x, int y) { y = WindowParams::WindowHeight - y - 1; if(state == GLUT_DOWN) { Vec3f psphere; if(SpherePoint(SphereCenter,SphereRadius,ScreenToWorld(WindowParams::MainWindow,x,y),psphere)) { CurrentPsphere = psphere; NewPsphere = psphere; } glutPostRedisplay(); //selection pickercalculator(x, y); } if(state == GLUT_UP) { CurrentPsphere = NewPsphere; } }
void Input::MouseMotion(int x, int y) { y = Params::WindowHeight - y-1; Vec3f psphere; if(SpherePoint(View::SphereCenter, View::SphereRadius, ScreenToWorld(Params::MainWindow, x, y), psphere)) { Vec3f tmpRotAxis = cross(CurrentPsphere-View::SphereCenter, psphere-View::SphereCenter); View::ExaminerRotAxis = tmpRotAxis; View::ExaminerRotAngle = acos((CurrentPsphere-View::SphereCenter) .dot(psphere-View::SphereCenter) / View::SphereRadius / View::SphereRadius); if( !(tmpRotAxis.x() == 0 && tmpRotAxis.y() == 0 && tmpRotAxis.z() == 0) ) View::ExaminerRotation = HMatrix<float>::Rotation(View::ExaminerRotAngle, View::ExaminerRotAxis) * View::ExaminerRotation; CurrentPsphere = psphere; } glutPostRedisplay(); }