本文整理汇总了C++中Trackball类的典型用法代码示例。如果您正苦于以下问题:C++ Trackball类的具体用法?C++ Trackball怎么用?C++ Trackball使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Trackball类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyboardEvent
void keyboardEvent(unsigned char key, int x, int y) {
switch (key) {
case 'x':
case 27 : {
exit(0);
break;
}
case 'w': {
// move forward //
trackball.updateOffset(Trackball::MOVE_FORWARD);
break;
}
case 's': {
// move backward //
trackball.updateOffset(Trackball::MOVE_BACKWARD);
break;
}
case 'a': {
// move left //
trackball.updateOffset(Trackball::MOVE_LEFT);
break;
}
case 'd': {
// move right //
trackball.updateOffset(Trackball::MOVE_RIGHT);
break;
}
default : {
break;
}
}
glutPostRedisplay();
}
示例2: display
void
display(void)
{
Matrix m1, m2, m3;
Quaternion q1;
#ifdef PAR_SCHEDULER
if(pVSCThread == NULL)
{
pVSCThread = ExternalThread::find("VSCScheduler");
}
VSC::VSCScheduler::the()->enterSyncBarrier(2);
pVSCThread->getChangeList()->applyToCurrent();
pVSCThread->getChangeList()->clearAll();
// VSC::vsc_sleep(100);
VSC::VSCScheduler::the()->enterSyncBarrier(2);
#endif
// tball.getRotation().getValue(m3);
// q1.setValue(m3);
// m1.setRotate(q1);
// cout << "TBROT" << endl << tball.getRotation() << endl;
// cout << "M3" << endl << m3 << endl;
// cout << "Q1" << endl << q1 << endl;
// cout << "M1" << endl << m1 << endl;
// m1.setRotate( tball.getRotation() );
// m2.setTranslate( tball.getPosition() );
//cout << "Pos: " << tball.getPosition() << ", Rot: " << tball.getRotation() << endl;
// cout << tball.getRotation() << endl;
// m1.mult( m2 );
cam_trans->getSFMatrix()->setValue(tball.getFullTrackballMatrix());
/*
fprintf(stderr, "%d %d %d %d | %d | %d\r",
glutGet(GLUT_WINDOW_RED_SIZE),
glutGet(GLUT_WINDOW_GREEN_SIZE),
glutGet(GLUT_WINDOW_BLUE_SIZE),
glutGet(GLUT_WINDOW_ALPHA_SIZE),
glutGet(GLUT_WINDOW_DEPTH_SIZE),
glutGet(GLUT_WINDOW_STENCIL_SIZE));
*/
win->draw( ract );
}
示例3: mouse
void mouse(int button, int state, int x, int y)
{
long s=0x00000000;
s |= (button == GLUT_LEFT_BUTTON) ? ((state == GLUT_DOWN) ? Trackball::LBUTTON_DOWN : Trackball::LBUTTON_UP) : 0;
s |= (button == GLUT_MIDDLE_BUTTON) ? ((state == GLUT_DOWN) ? Trackball::MBUTTON_DOWN : Trackball::MBUTTON_UP) : 0;
s |= (button == GLUT_RIGHT_BUTTON) ? ((state == GLUT_DOWN) ? Trackball::RBUTTON_DOWN : Trackball::RBUTTON_UP) : 0;
int key_state = glutGetModifiers();
s |= (key_state & GLUT_ACTIVE_CTRL) ? Trackball::CTRL_DOWN : 0;
s |= (key_state & GLUT_ACTIVE_ALT) ? Trackball::ALT_DOWN : 0;
s |= (key_state & GLUT_ACTIVE_SHIFT) ? Trackball::SHIFT_DOWN : 0;
if (s & Trackball::BUTTON_DOWN){
trackball.mouseDown(s, x, y);
}
if (s & Trackball::BUTTON_UP){
trackball.mouseUp(s, x, y);
}
}
示例4: trackball_handler
/* Trackball Handler */
void trackball_handler(int event,int xx,int yy) {
float matrix[4][4];
if ( event == FL_PUSH ) {
x_ang = xx ;
y_ang = yy ;
trackball.rotate( 0,0,0,0 ) ;
}
else if (( event == FL_DRAG ) ) {
trackball.rotate((2.0 * x_ang - screen_width) / float(screen_width),
(screen_height - 2.0 * y_ang) / float(screen_height),
(2.0 * xx - screen_width) / float(screen_width),
(screen_height - 2.0 * yy) / float(screen_height));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
trackball.rotationMatrix(matrix);
glMultMatrixf((float *)matrix);
x_ang = xx ;
y_ang = yy ;
glutPostRedisplay() ;
}
}
示例5: mouseMoveEvent
void MyOSGQGLWidget::mouseMoveEvent ( QMouseEvent *me )
{
Real32 w = _osgWin->getWidth(); // force the calc to Real32
Real32 h = _osgWin->getHeight();
Real32 a = -2. * ( _lastx / w - .5 );
Real32 b = -2. * ( .5 - _lasty / h );
Real32 c = -2. * ( me->pos().x() / w - .5 );
Real32 d = -2. * ( .5 - me->pos().y() / h );
if ( _mouseb & LeftButton )
{
tball.updateRotation( a, b, c, d );
}
else if ( _mouseb & MidButton )
{
tball.updatePosition( a, b, c, d );
}
else if ( _mouseb & RightButton )
{
tball.updatePositionNeg( a, b, c, d );
}
_lastx = me->pos().x();
_lasty = me->pos().y();
doCamTrans();
paintGL();
}
示例6:
void
display(void)
{
Matrix m1, m2, m3;
Quaternion q1;
tball.getRotation().getValue(m3);
q1.setValue(m3);
m1.setRotate(q1);
// std::cout << "TBROT" << std::endl << tball.getRotation() << std::endl;
// std::cout << "M3" << std::endl << m3 << std::endl;
// std::cout << "Q1" << std::endl << q1 << std::endl;
// std::cout << "M1" << std::endl << m1 << std::endl;
// m1.setRotate( tball.getRotation() );
m2.setTranslate( tball.getPosition() );
//std::cout << "Pos: " << tball.getPosition() << ", Rot: " << tball.getRotation() << std::endl;
// std::cout << tball.getRotation() << std::endl;
m1.mult( m2 );
cam_trans->editSFMatrix()->setValue( m1 );
win->draw( ract );
}
示例7: glutGet
void
display(void)
{
Matrix m1, m2;
m1.setRotate( tball.getRotation() );
m2.setTranslate( tball.getPosition() );
m1.mult( m2 );
cam_trans->editSFMatrix()->setValue( m1 );
// move the object
float t = glutGet(GLUT_ELAPSED_TIME);
Quaternion q;
q.setValueAsAxisDeg(0, 1, 0, t / 5000);
m1.setTransform(Vec3f(osgsin(t / 500.), 0, osgcos(t / 500)), q);
tr->setMatrix(m1);
if ( doRender )
win->render( ract );
else
win->draw( dact );
}
示例8: if
void
mouse(int button, int state, int x, int y)
{
if ( state == 0 )
{
switch ( button )
{
case GLUT_LEFT_BUTTON: break;
case GLUT_MIDDLE_BUTTON:tball.setAutoPosition(true);
break;
case GLUT_RIGHT_BUTTON: tball.setAutoPositionNeg(true);
break;
}
mouseb |= 1 << button;
}
else if ( state == 1 )
{
switch ( button )
{
case GLUT_LEFT_BUTTON: break;
case GLUT_MIDDLE_BUTTON:tball.setAutoPosition(false);
break;
case GLUT_RIGHT_BUTTON: tball.setAutoPositionNeg(false);
break;
}
mouseb &= ~(1 << button);
}
lastx = x;
lasty = y;
}
示例9: if
void
motion(int x, int y)
{
Real32 w = win->getWidth(), h = win->getHeight();
Real32 a = -2. * ( lastx / w - .5 ),
b = -2. * ( .5 - lasty / h ),
c = -2. * ( x / w - .5 ),
d = -2. * ( .5 - y / h );
if ( mouseb & ( 1 << GLUT_LEFT_BUTTON ) )
{
tball.updateRotation( a, b, c, d );
}
else if ( mouseb & ( 1 << GLUT_MIDDLE_BUTTON ) )
{
tball.updatePosition( a, b, c, d );
}
else if ( mouseb & ( 1 << GLUT_RIGHT_BUTTON ) )
{
tball.updatePositionNeg( a, b, c, d );
}
lastx = x;
lasty = y;
}
示例10: cursorPos_callback
/** This method is automatically called by GLFW everytime the mouse moves */
static void cursorPos_callback(GLFWwindow* window, double x, double y)
{
if(mButton == GLFW_MOUSE_BUTTON_LEFT)
{
mCamera.dragRotate(Vector2f(x,y));
}
else if(mButton == GLFW_MOUSE_BUTTON_MIDDLE)
{
mCamera.dragTranslate(Vector2f(x,y));
}
mLastMousePos = Vector2f(x,y);
}
示例11: doCamTrans
void doCamTrans ( void )
{
Matrix m1, m2, m3;
Quaternion q1;
tball.getRotation().getValue(m3);
q1.setValue(m3);
m1.setRotate(q1);
m2.setTranslate( tball.getPosition() );
m1.mult( m2 );
cam_trans->getSFMatrix()->setValue( m1 );
}
示例12: display
void display(void)
{
Matrix m1, m2, m3;
Quaternion q1;
tball.getRotation().getValue(m3);
q1.setValue(m3);
m1.setRotate(q1);
m2.setTranslate( tball.getPosition() );
m1.mult( m2 );
cam_trans->editSFMatrix()->setValue( m1 );
window->draw( drAct );
}
示例13: display
void display(void)
{
Matrix m1, m2;
m1.setRotate(tball.getRotation());
m2.setTranslate(tball.getPosition());
m1.mult(m2);
cam_trans->editSFMatrix()->setValue(m1);
if(doRender)
win->render(ract);
else
win->draw(dact);
}
示例14:
void
mouse ( int button, int state, int x, int y )
{
if ( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) {
trackball.startMouse ( x, y );
}
}
示例15: display
void display()
{
static GLdouble m[4][4];
if ( white_background )
glClearColor(1.0, 1.0, 1.0, 1.0);
else
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
tb.writeOpenGLTransfMatrix(m);
glPushMatrix();
glMultMatrixd( &m[0][0] );
// Draw display lists
if ( white_background )
glColor3f(0.0, 0.0, 0.0);
else
glColor3f(1.0, 1.0, 1.0);
if ( show_ball )
glutWireSphere(1.0, 10, 10);
if ( show_axes )
glCallList(axes_list);
glPopMatrix();
glutSwapBuffers();
glFlush();
}