当前位置: 首页>>代码示例>>C++>>正文


C++ Camera3D类代码示例

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


在下文中一共展示了Camera3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

// Qt Streams
QDebug operator<<(QDebug dbg, const Camera3D &transform)
{
    dbg << "Camera3D\n{\n";
    dbg << "Position: <" << transform.translation().x() << ", " << transform.translation().y() << ", " << transform.translation().z() << ">\n";
    dbg << "Rotation: <" << transform.rotation().x() << ", " << transform.rotation().y() << ", " << transform.rotation().z() << " | " << transform.rotation().scalar() << ">\n}";
    return dbg;
}
开发者ID:DimitarBabov,项目名称:QT_tests,代码行数:8,代码来源:camera3d.cpp

示例2: mouse_move_func

// This function called by both OpenGL (GLUT) and DirectX
void mouse_move_func ( int x, int y )
{
    mSelectID = (((x-window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10;
    if ( mSelectID < 0 ) mSelectID = 0;
    if ( mSelectID > mEvents.size()-1 ) mSelectID = mEvents.size() -1;

    mSelectBin = ((y-window_height/2.0) - cam.getToPos().y) / 25;
    if ( mSelectBin < 0 ) mSelectBin = 0;
    if ( mSelectBin >= NUM_BIN ) mSelectBin = NUM_BIN-1;
}
开发者ID:lalalaring,项目名称:stateviewer,代码行数:11,代码来源:main.cpp

示例3: renderCamSetupGL

void renderCamSetupGL ( Scene& scene, int prog )
{
    // Set model, view, projection matrices
    Camera3D* cam = scene.getCamera ();	
    Matrix4F ident;
    ident.Identity();	
    glProgramUniformMatrix4fv( prog, scene.getParam(prog, UMODEL), 1, GL_FALSE, ident.GetDataF() );
    glProgramUniformMatrix4fv( prog, scene.getParam(prog, UVIEW), 1, GL_FALSE, cam->getViewMatrix().GetDataF() ); 
    glProgramUniformMatrix4fv( prog, scene.getParam(prog, UPROJ), 1, GL_FALSE, cam->getProjMatrix().GetDataF() );
}
开发者ID:amitprakash07,项目名称:gl_optix_composite,代码行数:10,代码来源:render_opengl.cpp

示例4: mouse

void AppWindow::mouse ( NVPWindow::MouseButton button, ButtonAction action, int mods, int x, int y )
{
    Vector3DF cangs, ctp;
    float cdist;
    Camera3D* cam = scene.getCamera ();
    cangs = cam->getAng();
    ctp = cam->getToPos();
    cdist = cam->getOrbitDist();

    if ( action==NVPWindow::BUTTON_PRESS && guiMouseDown ( x, y ) ) return;

    if( action==NVPWindow::BUTTON_PRESS ) {		
        dragging = (int) button;		
        last_x = x;
        last_y = y;	
    } else if ( action==NVPWindow::BUTTON_RELEASE ) {
        dragging = -1;
    }
}
开发者ID:hmalm,项目名称:gl_optix_composite,代码行数:19,代码来源:main.cpp

示例5: paintGL

void BaseEntity::paintGL( Camera3D& camera, QMatrix4x4& projection )
{
    m_program->bind();

    m_program->setUniformValue( m_worldEye, camera.toMatrix() );
    m_program->setUniformValue( m_eyeClip, projection );

    m_vao->bind();
    m_texture->bind();

    m_program->setUniformValue( m_modelWorld, Transform.toMatrix() );

    glDrawArrays( GL_TRIANGLES, 0, m_numVertices );

    m_texture->release();
    m_vao->release();
    m_program->release();
}
开发者ID:Zarol,项目名称:QtOpenGL-ComputerGraphics,代码行数:18,代码来源:baseEntity.cpp

示例6: paintGL

void Skybox::paintGL( Camera3D& camera, QMatrix4x4& projection )
{
    glEnable( GL_DEPTH_TEST );
    glDepthFunc( GL_LEQUAL );
    glDepthMask( GL_TRUE );
    glDisable( GL_CULL_FACE );

    program->bind();

    program->setUniformValue( worldEye, camera.toMatrix() );
    program->setUniformValue( eyeClip, projection );

    vao->bind();
    texture->bind();

    program->setUniformValue( modelWorld, transform.toMatrix() );

    glDrawArrays( GL_TRIANGLES, 0, numVertices );

    texture->release();
    vao->release();
    program->release();
}
开发者ID:Zarol,项目名称:QtOpenGL-ComputerGraphics,代码行数:23,代码来源:skybox.cpp

示例7: RunUniverse

void RunUniverse(const char *file)
{
    ifstream in;
    in.open(file);
    int cameras, i, j, maxiterations;
    double initstep, maxdistance, errscale;
    double position[4];
    double cameralook[16];
    string error;
    string output;
    int skip = 0;
    int coordinate;
    double M, a;
    Camera3D *cam;
    RungeKuttaForm *solver;
    BlackHole *bh;

    int pixh, pixv;
    double fovh, fovv, zoomh1, zoomh2, zoomv1, zoomv2;

    solver = RungeKutta::DormandPrince;
    /*solver = RungeKutta::Midpoint;
    solver = RungeKutta::Kutta;
    solver = RungeKutta::BogackiSchampine;
    solver = RungeKutta::CashKarp;
    solver = RungeKutta::Fehlberg;/**/

    in >> error;
    in >> output;

    in >> cameras;
    in >> initstep;
    in >> errscale;
    errscale *= 100;
    cout << "cameras: " << cameras << ". error: " << error << ". output: " << output << "." << endl;

    in >> M;
    in >> a;

    bh = new BlackHole(M, a);

    for(i = 0; i < cameras; i++)
    {
        in >> maxiterations;
        in >> maxdistance;

        in >> pixh;
        in >> pixv;
        in >> fovh;
        in >> fovv;
        in >> zoomh1;
        in >> zoomh2;
        in >> zoomv1;
        in >> zoomv2;
        in >> coordinate;

        for(j = 0; j < 4; j++) in >> position[j];

        for(j = 0; j < 16; j++) in >> cameralook[j];

        cam = new Camera3D(bh, position, cameralook, coordinate, CAMERA_FLAT, pixh, pixv, fovh, fovv, zoomh1, zoomh2, zoomv1, zoomv2);

        if(skip<1) {
            cam->Snapshot(solver, ((string)"c:\\dosgames\\kerr schild\\" + output +  stringify(i) + ".txt").c_str(), maxiterations>MAXSTEPS?MAXSTEPS:maxiterations, maxdistance, initstep, errscale, coordinate, CoordinateTest);
            cout << "snapshot complete!" << endl << flush;
        } else {skip--;}

        cout << "Image " << i << " complete!" << endl << flush;
        delete cam;
    }

    in.close();
}
开发者ID:DanielKrawisz,项目名称:KerrSchild,代码行数:73,代码来源:main.cpp

示例8: main

int main (int argc, char **argv)
{
  //Initialize GLUT
  initGlut( argc, argv );
  
  Kernel kernel;
  kernel.enableVerticalSync( false );
  renderer = kernel.getRenderer();
  printf( "Kernel loaded\n" );

  StandardMaterial matRedLogo;
  matRedLogo.setSpecularity( 0.5 );
  matRedLogo.setDiffuseColor( Vector3(1,0,0) );
  matRedLogo.setAmbientColor( matRedLogo.getDiffuseColor() * .8f );

  StandardMaterial matWhiteLogo;
  matWhiteLogo.setSpecularity( 0.5 );
  matWhiteLogo.setAmbientColor( matWhiteLogo.getDiffuseColor() * .8f );

  StandardMaterial matWhite;
  matWhite.setSpecularity( 0.5 );

  StandardMaterial matBlue;
  matBlue.setSpecularity( 0.5 );
  matBlue.setDiffuseColor( Vector3(0,0.5,1) );

  StandardMaterial matGreen;
  matGreen.setSpecularity( 0.5 );
  matGreen.setDiffuseColor( Vector3(0,0.6,0) );

  StandardMaterial matYellow;
  matYellow.setSpecularity( 0.5 );
  matYellow.setDiffuseColor( Vector3(1,1,0.7) );

  StandardMaterial matBlack;
  matBlack.setSpecularity( 0.5 );
  matBlack.setDiffuseColor( Vector3(0.2,0.2,0.2) );

  MultiMaterial mm;
  mm.setNumSubMaterials( 5 );
  mm.setSubMaterial( 0, &matBlue );
  mm.setSubMaterial( 1, &matYellow );
  mm.setSubMaterial( 2, &matWhite );
  mm.setSubMaterial( 3, &matBlack );
  mm.setSubMaterial( 4, &matBlue );

  MultiMaterial mm2;
  mm2.setNumSubMaterials( 5 );
  mm2.setSubMaterial( 0, &matGreen );
  mm2.setSubMaterial( 1, &matYellow );
  mm2.setSubMaterial( 2, &matWhite );
  mm2.setSubMaterial( 3, &matBlack );
  mm2.setSubMaterial( 4, &matGreen );

  MultiMaterial mmLogo;
  mmLogo.setNumSubMaterials( 2 );
  mmLogo.setSubMaterial( 0, &matWhiteLogo );
  mmLogo.setSubMaterial( 1, &matRedLogo );

  //Setup Logo scene

  sceneLogo = new Scene;

  loadLogo( "logo.pak" );
  actLogo = new TriMeshActor;
  actLogo->setMesh( mshLogo );
  actLogo->translate( 200, 0, 0 );
  actLogo->setMaterial( &mmLogo );
  sceneLogo->addChild( actLogo );

  camLogo = new Camera3D;
  camLogo->translate( 0,0,-600 );
  camLogo->setNearClipPlane( 1.0f );
  camLogo->setFarClipPlane( 3000.0f );

  lightLogo = new SpotLight( Vector3(0,0,-500), Vector3(0,0,1), 60, 50 );
  lightLogo->setCastShadows( true );
  sceneLogo->addChild( lightLogo );

  //Setup Bub scene

  loadPackage( "bub.pak" );
  scene = new Scene;
  
  skinActor = new SkinMeshActor;
  skinActor->setMaterial( &mm );
  skinActor->setMesh( character );
  skinActor->translate( 60, 0, 0 );
  scene->addChild( skinActor );

  skinActor2 = new SkinMeshActor;
  skinActor2->setMaterial( &mm2 );
  skinActor2->setMesh( character );
  skinActor2->translate( -60, 0, 0 );
  scene->addChild( skinActor2 );

  TriMesh *cubeMesh = new CubeMesh;
  TriMeshActor *cube = new TriMeshActor;
  cube->setMaterial( &matWhiteLogo );
  cube->setMesh( cubeMesh );
//.........这里部分代码省略.........
开发者ID:ileben,项目名称:GameEngine,代码行数:101,代码来源:TestSkin.cpp

示例9: mouse_drag_func

// This function called by both OpenGL (GLUT) and DirectX
void mouse_drag_func ( int x, int y )
{
    if ( guiMouseDrag ( x, y ) ) return;	// event handling for nv2D GUIs

    int dx = x - last_x;
    int dy = y - last_y;

    float deltx = window_width / cam.getToPos().z;
    float delty = window_height / cam.getToPos().z;
    
    // Camera interaction
    int mode = 0;
    switch ( mode ) {
    case 0:
        if ( dragging == DRAG_LEFT ) {
            glide += Vector3DF( dx / cam.getToPos().z, 0, 0);		
            cam.moveToPos ( 0, dy, 0 );
        } else if ( dragging == DRAG_RIGHT ) {	
            cam.moveToPos ( 0, 0, -dy*0.001 );
            if ( cam.to_pos.z < 0.001 ) cam.to_pos.z = 0.001;
        }
        break;	
    }
    last_x = x;
    last_y = y;
}
开发者ID:lalalaring,项目名称:stateviewer,代码行数:27,代码来源:main.cpp

示例10: initialize

char* initialize ( char* cmdline )
{
    // Get comnmand line
    std::string str = cmdline;
    std::vector<std::string>	args;
    while ( str.length() > 0) {
        args.push_back ( strSplit ( str, " " ) );		
    }
    fileName = "";
    for (int n=0; n < args.size(); n++ ) {
        if ( args[n].compare ( "-f" ) == 0 ) {
            startFrame = strToI ( args[n+1] );
        }
        if ( args[n].compare ( "-d" ) == 0 ) {		// max_draw
            maxDraw = strToI ( args[n+1] );
        }
        if ( args[n].find_first_of ( "." ) != std::string::npos ) {
            fileName = args[n];
        }
    }
    if ( fileName.length()== 0 || args.size()==0 ) {
        app_printf ( "USAGE:  state_view [-f #] [-d #] filename.raw\n\n" );
        app_printf ( "  -f #   Start at frame \n" );
        app_printf ( "  -d #   Maximum number of draw calls to read \n" );
        _getch();
        exit(-1);
    }

    for (int n=0; n < 10; n++ ) bShow[n] = true;

    // Initialize camera
    cam.setPos ( 0, 0, 1 );
    cam.setToPos ( -window_width*3/8, -window_height*3/8, 1 );
    cam.updateMatricies ();

    // Initialize bin and call names
    setup_bins ();

    // Load trace file	
    char fname[256];
    strcpy ( fname, fileName.c_str() );
    load_trace_raw ( fname );	

    // required init functions
    init2D ( "arial_12" );		// specify font file (.bin/tga)
    setText ( 1.0, -0.5 );		// scale by 0.5, kerning adjust -0.5 pixels
    setview2D ( window_width, window_height );

    // draw visualization layer
    drawMatrix ();
    
    PERF_INIT ( false );						// Enable CPU perf (do not require nv-perfmarker DLL)
    PERF_SET ( false, 2, false, "" );		// Perf CPU?, CPU level, NV Perfmarkers, Log filename

    return "NVIDIA State Viewer, by Rama Hoetzlein";	// Return Window title
}
开发者ID:lalalaring,项目名称:stateviewer,代码行数:56,代码来源:main.cpp

示例11: display

// Main display loop
void display () 
{
    cam.moveToPos ( glide.x, 0, 0  );
    glide.x *= 0.8;	
        
    PERF_PUSH ( "frame" );

    // Clear framebuffers. OpenGL
    glClearColor( 0.1, 0.1, 0.1, 0.0 );
    glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    drawOverlay ();

    drawGui ();

    draw2D ();

    #ifdef USE_DX
        // DirectX - Swap buffers		
        checkHR ( g_pSwapChain->Present ( 0, 0 ) );
    #else
        // OpenGL - Swap buffers
        SwapBuffers ( g_hDC );  		
    #endif

    PERF_POP ();

    frame++;
}
开发者ID:lalalaring,项目名称:stateviewer,代码行数:30,代码来源:main.cpp

示例12: mouse_click_func

// This function called by both OpenGL (GLUT) and DirectX
void mouse_click_func ( int button, int state, int x, int y )
{
  cangs = cam.getAng();
  ctp = cam.getToPos();
  cdist = cam.getOrbitDist();

  if ( state==GLUT_DOWN && guiMouseDown ( x, y ) ) return;		// event handling for nv2D GUIs

  if( state == GLUT_DOWN ) {
    if ( button == GLUT_LEFT_BUTTON )		dragging = DRAG_LEFT;
    else if ( button == GLUT_RIGHT_BUTTON ) dragging = DRAG_RIGHT;	
    last_x = x;
    last_y = y;	
  } else if ( state==GLUT_UP ) {
    dragging = DRAG_OFF;
  }
}
开发者ID:lalalaring,项目名称:stateviewer,代码行数:18,代码来源:main.cpp

示例13: glut_program

void glut_program(void)
{
    //update camera
    float elapsedTime = timeCounter.getElapsedTimef();
    timeCounter.reset();
    cam.update(elapsedTime, -(300.0f-lastMY), 400.0f-lastMX);
    lastMX=400.0f;
    lastMY=300.0f;
    glutWarpPointer(400,300);
}
开发者ID:ArturSoczek,项目名称:OpenGLInsightsCode,代码行数:10,代码来源:glut_callback.cpp

示例14: mouse

void mouse(double x, double y){
    if(rotating){
        vec3 beg = screenToSphere(start.x, start.y);
        vec3 end = screenToSphere(x,HEIGHT-y);
        glm::vec3 axis = glm::normalize(glm::cross(beg,end));
        float phi = glm::distance(beg, end)/4;
        glm::vec3 newAxis = glm::normalize(glm::mat3(glm::inverse(glm::toMat4(trans.r))*glm::inverse(camera.getView()))*axis);
        trans.r = glm::rotate(trans.r, glm::degrees(phi)*0.3f, newAxis);
        start = gd->getMousePos();
    }
    if(translating){
        glm::vec2 delta = gd->getMousePos() - panStart;
        delta.x /= WIDTH; delta.y /= HEIGHT;
        glm::vec3 newDelta = glm::mat3(glm::inverse(glm::toMat4(trans.r))*glm::inverse(camera.getView()))*glm::vec3(delta.x,delta.y,0.0);
        trans.t = trans.t + newDelta*3.0f;
        panStart = gd->getMousePos();
    }
    camera.apply(trans);
}
开发者ID:filipecn,项目名称:CGProjects,代码行数:19,代码来源:testgrid.cpp

示例15: glut_keyboardUp

void glut_keyboardUp(unsigned char key,int x,int y)
{
    switch(key)
    {
    case 'q':
    case 'a':
        cam.setLeft(false);
        break;
    case 'd':
        cam.setRight(false);
        break;
    case 'w':
    case 'z':
        cam.setForward(false);
        break;
    case 's':
        cam.setBackward(false);
        break;
    case ' ':
        cam.setUp(false);
        break;
    case 'c':
        cam.setDown(false);
        break;

    default:
        break;
    }
}
开发者ID:ArturSoczek,项目名称:OpenGLInsightsCode,代码行数:29,代码来源:glut_callback.cpp


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