• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Trackball类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Trackball的典型用法代码示例。如果您正苦于以下问题:C++ Trackball类的具体用法?C++ Trackball怎么用?C++ Trackball使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Trackball类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:Valodim,项目名称:cg2,代码行数:33,代码来源:Ex10.cpp


示例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 );
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:56,代码来源:testVRMLView.cpp


示例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);
        }
}
开发者ID:,项目名称:,代码行数:20,代码来源:


示例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() ;
    }
}
开发者ID:garodimb,项目名称:graphics,代码行数:22,代码来源:main.cpp


示例5: start

	void start(){
		//resource
		String rspath = Application::instance()->appResourcesDirectory();
		//init renders
		Vec4 viewport(0, 0, 1280, 720);
		getRender().setViewportState(viewport);
        getRender().setClearColorState({64,64,64,255});
		getRender().setZBufferState(true);
		getRender().setBlendState(BlendState(BLEND::ONE, BLEND::ZERO));
		getRender().setCullFaceState(CullFace::DISABLE);
		//materials
		matTrackball.init();
		matPoints.init();
		matGeometry.init();
		matGeometry.setColor({1.0,1.0,1.0,1.0});
		//init trackball
		trackball.init(&matTrackball);
        //init track area
        //left
        trackAreaLeft.init(&matGeometry, &matPoints);
        trackAreaLeft.setTrackball(trackball);
        //right
        trackAreaRight.init(&matGeometry, &matPoints);
        trackAreaRight.setTrackball(trackball);
        //init ui
        ui.setSizeLeft(UI_SIZE);
        ui.setCallBackLoad([this](const String& path)
                           {
                               loadModel(path);
                           });
        ui.setCallBackSave([this](const String& path)
                           {
                               saveModels(path);
                           });
        ui.setCallBackSVD([this]()
                         {
                             mergeMesh();
                         });
		#if 0
		Mesh m1;
		m1.addMeshOFF(modelRight, {
			1, 0, 0, 0,
			0, 0.5, 0, 0,
			0, 0, 1, 0,
			0, 0, 0, 1
		});
		m1.saveOFF(rspath + "/meshs/faccia045.off");
		#endif
		
	}
开发者ID:Gabriele91,项目名称:Merging-Meshs,代码行数:50,代码来源:main.cpp


示例6: display

void display(void)
{
    m1c = tball.getFullTrackballMatrix();

    if(move_obj == true)
    {
        scene_trans->editSFMatrix()->setValue( m1c );
    }
    else
    {
        cam_trans->editSFMatrix()->setValue( m1c );
    }

    commitChanges();

    win->render(rentravact);
}
开发者ID:whztt07,项目名称:OSGAddOnsGV,代码行数:17,代码来源:testMiniTerrainLoad.cpp


示例7: mouseEvent

void mouseEvent(int button, int state, int x, int y) {
 Trackball::MouseState mouseState;
  if (state == GLUT_DOWN) {
    switch (button) {
      case GLUT_LEFT_BUTTON : {
        mouseState = Trackball::LEFT_BTN;
        break;
      }
      case GLUT_RIGHT_BUTTON : {
        mouseState = Trackball::RIGHT_BTN;
        break;
      }
      default : break;
    }
  } else {
    mouseState = Trackball::NO_BTN;
  }
  trackball.updateMouseBtn(mouseState, x, y);
}
开发者ID:Valodim,项目名称:cg2,代码行数:19,代码来源:Ex10.cpp


示例8: 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();
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:28,代码来源:testWindowMTQT_qt.cpp


示例9:

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 );
}
开发者ID:,项目名称:,代码行数:29,代码来源:


示例10: 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 );
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:28,代码来源:testBillboardRender.cpp


示例11: 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;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:30,代码来源:testWindowGLUTGF.cpp


示例12: 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;
}
开发者ID:,项目名称:,代码行数:26,代码来源:


示例13: 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);
}
开发者ID:Patagouin,项目名称:Mod,代码行数:13,代码来源:main.cpp


示例14: 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 );
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:12,代码来源:testWindowMTQT_qt.cpp


示例15: 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 );
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:13,代码来源:testCalcFaceNormals.cpp


示例16: 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);
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:15,代码来源:testBINLoader.cpp


示例17:

void 
mouse ( int button, int state, int x, int y )
{
  if ( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) {
    trackball.startMouse ( x, y );
  }
}
开发者ID:wthibault,项目名称:ssg,代码行数:7,代码来源:example5.cpp


示例18: 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();
}
开发者ID:davidbourguignon,项目名称:move,代码行数:32,代码来源:tbViewer_test.C


示例19: mouseReleaseEvent

void MyOSGQGLWidget::mouseReleaseEvent ( QMouseEvent *me )
{
    switch ( me->button() )
    {
        case MidButton:
            tball.setAutoPosition(false);
            break;
        case RightButton:
            tball.setAutoPositionNeg(false);
            break;
        default:
            break;
    }
    _mouseb &= me->button();
    _lastx = me->x();
    _lasty = me->y();   
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:17,代码来源:testWindowMTQT_qt.cpp


示例20: reshape_callback

/** This method is automatically called by GLFW everytime the OpenGL windows is resized.
      * \param width the new width of the windows (in pixels)
      * \param height the new height of the windows (in pixels)
      */
static void reshape_callback(GLFWwindow* window, int width, int height)
{
    // configure the rendering target size (viewport)
    WIDTH = width;
    HEIGHT = height;
    glViewport(0, 0, width, height);
    mCamera.setScreenViewport(AlignedBox2f(Vector2f(0.0,0.0), Vector2f(width,height)));
    render(window);
}
开发者ID:Patagouin,项目名称:Mod,代码行数:13,代码来源:main.cpp



注:本文中的Trackball类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TrackedButtonInteractionEvent类代码示例发布时间:2022-05-31
下一篇:
C++ TrackPointer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap