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


C++ camera类代码示例

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


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

示例1:

void
camera_uniform_block::update(const render_context_ptr& context,
                             const camera&             cam)
{
    _uniform_block.begin_manipulation(context); {
        _uniform_block->_ws_position                 = cam.position();
        _uniform_block->_ws_near_plane               = cam.view_frustum().get_plane(frustum::near_plane).vector();
        _uniform_block->_p_matrix                    = cam.projection_matrix();
        _uniform_block->_p_matrix_inverse            = cam.projection_matrix_inverse();
        _uniform_block->_v_matrix                    = cam.view_matrix();
        _uniform_block->_v_matrix_inverse            = cam.view_matrix_inverse();
        _uniform_block->_v_matrix_inverse_transpose  = cam.view_matrix_inverse_transpose();
        _uniform_block->_vp_matrix                   = cam.view_projection_matrix();
        _uniform_block->_vp_matrix_inverse           = cam.view_projection_matrix_inverse();
    } _uniform_block.end_manipulation();
}
开发者ID:4og,项目名称:schism,代码行数:16,代码来源:camera_uniform_block.cpp

示例2: generateImage

void image::generateImage(object mxdObject, camera m3dCamera, pose m34dPose)
{
  this->mxdImage = m3dCamera.getIntrinsic() * m34dPose.getPoseMatrix() * mxdObject.getObjectPoints();

  for (unsigned i = 0; i < this->mxdImage.cols(); i++)
  {
    this->mxdImage(0,i) = round(this->mxdImage(0,i)/this->mxdImage(2,i));
    this->mxdImage(1,i) = round(this->mxdImage(1,i)/this->mxdImage(2,i));
    this->mxdImage(2,i) = round(this->mxdImage(2,i)/this->mxdImage(2,i));
  }
}
开发者ID:mdqyy,项目名称:Pose-Estimation,代码行数:11,代码来源:Image.cpp

示例3: if

void rasterized_color_triangle_app::on_key_down(SDL_Keysym const key)
{
	app::on_key_down(key);

	float const moving_speed{0.01f};
	float const rotation_speed{0.05f};

	if (key.sym == SDLK_a)
	{
		m_camera.move_left(moving_speed);
	}
	else if (key.sym == SDLK_d)
	{
		m_camera.move_right(moving_speed);
	}
	else if (key.sym == SDLK_w)
	{
		m_camera.move_forward(moving_speed);
	}
	else if (key.sym == SDLK_s)
	{
		m_camera.move_backward(moving_speed);
	}
	else if (key.sym == SDLK_r)
	{
		m_camera.move_up(moving_speed);
	}
	else if (key.sym == SDLK_f)
	{
		m_camera.move_down(moving_speed);
	}
	else if (key.sym == SDLK_q)
	{
		m_camera.yaw(-rotation_speed);
	}
	else if (key.sym == SDLK_e)
	{
		m_camera.yaw(rotation_speed);
	}
	else if (key.sym == SDLK_1)
	{
		m_shader_option = shader_option::color;
	}
	else if (key.sym == SDLK_2)
	{
		m_shader_option = shader_option::texture;
	}

	// Update model-view-projection according to camera changes
	update_shader_mvp();
}
开发者ID:dubrousky,项目名称:lantern,代码行数:51,代码来源:main.cpp

示例4: mouseMove

/**
 * Updates the camera based on the mouse movement.
 */
void mouseMove(int x, int y) {
   dx = mouse_sensitivity * (p2wx(x) - lastx);
   dy = mouse_sensitivity * (p2wy(g2py(y)) - lasty);
   //dy = mouse_sensitivity * (p2wy(y) - lasty);
   
   cam.update(cam.cam_spin_flag ? 0 : dx, dy);

   //lastx = p2wx(x);
   lasty = p2wy(g2py(y));
   lasty = p2wy(y);
   glutPostRedisplay();
}
开发者ID:Guinto,项目名称:Particle-System,代码行数:15,代码来源:main.cpp

示例5: detect

void blob_finder::detect(const camera &cam, const cv::Mat &mask, blobs_t &blobs)
{
	detector.detect(mask, blobs);

	for (auto &b : blobs)
	{
		b.cam = cam.i;
		b.rel = cam.cam2rel(b.center);
		auto pol = rect2pol(b.rel);
		b.dist = pol.x;
		b.angle = pol.y;
	}
}
开发者ID:sim642,项目名称:Cryptex,代码行数:13,代码来源:blob_finder.cpp

示例6: generateImage

image generateImage(const camera& cam, const sceneGraphNode& sceneGraph, const lightsource_base& ls)
{
  image result(cam.width(), cam.height());
  result.clear();

  // for every pixel
  for(image::size_type y=0; y < result.height(); y++)
    for(image::size_type x=0; x < result.width(); x++)
  {
      // create view ray
      ray r = cam.generateViewRay(x, y);

      // intersect
      intersectionPoint ip = sceneGraph.intersect(r);

      // if hit
      if(ip.isHit())
	result(x,y)  = ip.evaluate(ls);
    }

  // Done.
  return result;
}
开发者ID:Anaisabel95,项目名称:GraphicsClass,代码行数:23,代码来源:hw4.cpp

示例7: glGetIntegerv

void water::update(const float4x4& view_projection, const camera& camera, const point_light& light) {
	// count normals
	GLint old_viewport[4];
  glGetIntegerv(GL_VIEWPORT, old_viewport);

  glViewport(0, 0, grid_size_x_, grid_size_z_);
  glDisable(GL_DEPTH_TEST);

	norm_tex_->BeginRenderingToThisTexture();
	glUseProgram(normal_prog_.program);
	setUniform(normal_prog_.program, "objectMatrix", object_matrix_);
	setUniform(normal_prog_.program, "inversedObjectMatrix", inversed_object_matrix_);
	setUniform(normal_prog_.program, "gridSizeX",    grid_size_x_);
  setUniform(normal_prog_.program, "gridSizeZ",   grid_size_z_);
  bindTexture(normal_prog_.program, WATER_POSITIONS, "inPositions", pos_tex_[c_]->GetColorTexId());
	full_screen_quad_->Draw();
	norm_tex_->EndRenderingToThisTexture();
	glEnable(GL_DEPTH_TEST);
  glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]);


	// draw water
	glUseProgram(render_prog_.program);
  setUniform(render_prog_.program, "cameraPosition", camera.get_pos());
	setUniform(render_prog_.program, "viewProjectionMatrix", view_projection);
  setUniform(render_prog_.program, "objectMatrix", object_matrix_);

	light.setup_shader(render_prog_.program);
	material_.setup_shader(render_prog_.program); 
	setUniform(render_prog_.program, "gridSizeX", grid_size_x_);
  setUniform(render_prog_.program, "gridSizeZ", grid_size_z_);
  bindTexture(render_prog_.program, WATER_POSITIONS, "inPositions", pos_tex_[c_]->GetColorTexId());
	bindTexture(render_prog_.program, WATER_NORMALS, "inNormals", norm_tex_->GetColorTexId());

	//glEnable(GL_DEPTH_TEST);
  glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	

	water_mesh_->Draw(GL_TRIANGLES);

	glDisable(GL_BLEND); 
}
开发者ID:tanyatik,项目名称:pool-caustics,代码行数:42,代码来源:water.cpp

示例8: main

int main(int argc, char** argv) {
  int rc;
  Shader s;

  // set the camera to an initial position
  cam.setCamera(Vector3f(0,-10,100), Vector3f(0,0,0), Vector3f(0,1,0));

  glutInit(&argc, argv);
  // glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH|GLUT_3_2_CORE_PROFILE);
  glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
  glutInitWindowSize(600,600);
  glutInitWindowPosition(10, 10);

  glutCreateWindow("skybox");
  glutDisplayFunc(renderFun);
  glutIdleFunc(idleFun);
  // setCallbackFun();

  // initialize GLEW
  // GLenum err = glewInit();
  // if ( err != GLEW_OK)  printf(" Error initializing GLEW! \n");

  loadTextures();
  skybox.init();
  // skybox2.init();

  Init_Geometry();
  InitVBO();

  rc = loadShaders(s);
  if (rc != 0) {
    printf("error after createing shaders rc = %d \n", rc);
    getchar();
  }

  glutMainLoop();
}
开发者ID:ryanseys,项目名称:comp4002-assigns,代码行数:37,代码来源:main.cpp

示例9: renderScene

void renderScene(void){
    //update the modelview matrix based on the camera's position
    glMatrixMode(GL_MODELVIEW);             //make sure we aren't changing the projection matrix!
    glLoadIdentity();

    glDrawBuffer( GL_BACK );
    glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glViewport( 0, 0, windowWidth, windowHeight);
    glPushMatrix();

        myCam.set_atx(porsche.getX());
        myCam.set_aty(porsche.getY());
        myCam.set_atz(porsche.getZ());
        myCam.set_eyex(porsche.getX());
        myCam.set_eyez(porsche.getZ());
        myCam.update_pos_arcball();

        glPushMatrix(); {
            sky->drawSkybox(200, 200, 200);               // draw our axes so we know how we are oriented
        }; glPopMatrix();

        // draw ground
        glPushMatrix(); {
            drawGround();
        }; glPopMatrix();

        for (unsigned int i=0; i<cash.size(); i++){
            glPushMatrix(); {
                cash.at(i)->drawCrate();
            };glPopMatrix();
        }

        // draw the car based on the world object coordinates controlled by user interaction
    	glPushMatrix(); {
      		glTranslatef(porsche.getX(), porsche.getY(), porsche.getZ());
      		glRotatef(porsche.getTheta(), 0.0, 1.0, 0.0);       //Rotate about the y-axis
      		glTranslatef(-porsche.getX(), -porsche.getY(), -porsche.getZ());
      		porsche.drawCar();	// draw our dodecahedron...or torus...teapot...or whatever
        }; glPopMatrix();

        // draw the car based on the world object coordinates controlled by user interaction
        for (unsigned int i=0; i<fuzz.size(); i++){
            glPushMatrix(); {
              glTranslatef(fuzz.at(i)->getX(), fuzz.at(i)->getY(), fuzz.at(i)->getZ());
              glRotatef(fuzz.at(i)->getTheta(), 0.0, 1.0, 0.0);
              glTranslatef(-fuzz.at(i)->getX(), -fuzz.at(i)->getY(), -fuzz.at(i)->getZ());
              fuzz.at(i)->drawCar();
            }; glPopMatrix();
        }
    glPopMatrix();

    glClear(GL_FRAMEBUFFER | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);

    glDisable(GL_LIGHTING);
    glPushMatrix();
      glOrtho(-1,1,-1,1,-1,1);
        int locationX,locationY;
        if (!gameOver){
            locationX=-15;
            locationY=windowHeight-windowHeight/12;
        }else{
            locationX=windowWidth/2;
            locationY=windowHeight-windowHeight/2;
        }
        glViewport(locationX, locationY, windowWidth/12, windowHeight/12);
        glLoadIdentity();
      glColor3f(1,1,1);
        char c[15];
        sprintf(c, "%d", score);
        string temp=string(c);
      glRasterPos3i(0,0,0);
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'S');
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'C');
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'O');
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'R');
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'E');
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, ':');
      glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, ' ');
    for (unsigned int i=0; i<temp.size(); i++){
        glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, temp[i] );
    } 
    glMatrixMode(GL_PROJECTION);
  glPopMatrix();

  glPushMatrix();
      glOrtho(-1,1,-1,1,-1,1);
        if (!gameOver){
            locationX=150;
            locationY=windowHeight-windowHeight/12;
        }else{
            locationX=windowWidth/2;
            locationY=windowHeight-windowHeight/2+windowWidth/12;
        }
        glViewport(locationX, locationY, windowWidth/12, windowHeight/12);
        glLoadIdentity();
      glColor3f(healthR,healthG,0);
        char h[15];
        sprintf(h, "%d", health);
//.........这里部分代码省略.........
开发者ID:tseale,项目名称:GTA-CarpetCity,代码行数:101,代码来源:main.cpp

示例10: UIMethodsInit

	void UIMethodsInit()
	{
		PosesInit();
		nameHandler = new NameHandler();
		fp = new vector< FixedPoint* >();
		//hl = new HumanLeg( point( 0.0f, 50.0f, 0.0f ), point( 0.0f, 0.0f, 0.0f ), point( 1.0f, 1.0f, 1.0f ) );
		//hlc = new HumanLegController( hl );
		pl = new Player( point( ((float)width)/2.0f, ((float)height)/2.0f, 0 ), point( 0.0f, 0.0f, 0.0f ) );
		selectedRect = new Rect( point( 0,0,0 ), point( 2000, 100, 0 ) );
		float pos[WAMS_PLAYER_DOF];
		pl->getPose( pos );
		//hlc->getPose( pos );
		keyframes.push_back( new Keyframe( pos, -1.0f ) );
		count = 0;
		cam.setLoc( 0, 0, -50 );
		cam.setLookAt( 0, 0, 50 );
		//cam2.setLoc( 0.0f, 300.0f, 0.0f );
		//cam.setLookAt( 0, 100, 0 );
	}
开发者ID:dtracers,项目名称:PumpAndJump,代码行数:19,代码来源:uimethods.cpp

示例11: overhead

void overhead(){
  glMatrixMode(GL_MODELVIEW);             
  glLoadIdentity(); 
  glDrawBuffer( GL_BACK );
  glViewport(windowHeight-windowHeight/3,windowWidth-windowWidth/3,windowWidth/3,windowHeight/3);
  glScissor(windowHeight-windowHeight/3,windowWidth-windowWidth/3,windowWidth/3,windowHeight/3);
  glEnable(GL_SCISSOR_TEST);
  glClearDepth(1.0);
  glClearColor(0,0,0,1);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glDisable(GL_SCISSOR_TEST);
      glPushMatrix();
        overheadCam.update_pos_arcball();
        glPushMatrix(); {
            sky->drawSkybox(200, 200, 200);               // draw our axes so we know how we are oriented
        }; glPopMatrix();
        // draw ground
        glPushMatrix(); {
            drawGround();
        }; glPopMatrix();

        // draw the car based on the world object coordinates controlled by user interaction
        glPushMatrix(); {
            glTranslatef(porsche.getX(), porsche.getY(), porsche.getZ());
            glColor3f(1,1,1);
            glutSolidSphere(3, 10, 10);
        };glPopMatrix();

        for (unsigned int i=0; i<cash.size(); i++){
            glPushMatrix(); {
                glTranslatef(cash.at(i)->getX(),cash.at(i)->getY(),cash.at(i)->getZ());
                glColor3f(0.6,0.4,0.2);
                glutSolidCube(targsize);
            };glPopMatrix();
        }

        for (unsigned int i=0; i<fuzz.size(); i++){
            if (fuzz.at(i)->getY()>-10){
                glPushMatrix(); {
                  glTranslatef(fuzz.at(i)->getX(), fuzz.at(i)->getY(), fuzz.at(i)->getZ());
                  if (fuzz.at(i)->inPursuit){
                    glColor3f(fuzz.at(i)->r,0,fuzz.at(i)->b);
                  }else{
                    glColor3f(0,0,0);
                  }
                  glutSolidSphere(3, 10, 10);
                }; glPopMatrix();
            }
        }

      glPopMatrix();
  glMatrixMode(GL_PROJECTION);
}
开发者ID:tseale,项目名称:GTA-CarpetCity,代码行数:53,代码来源:main.cpp

示例12: drawScene

/**
 * Draws the scene (used in display).
 */
void drawScene() {
   glMatrixMode(GL_MODELVIEW);
   glEnable(GL_DEPTH_TEST);

   glPushMatrix(); {
      cam.updateLookat();
      for (unsigned int i = 0; i < objs.size(); i++) {
         objs[i]->draw();
         if (draw_arrows) {
            glDisable(GL_DEPTH_TEST);
            objs[i]->drawArrows();
            glEnable(GL_DEPTH_TEST);
         }
         if (draw_bounding_box) {
            objs[i]->drawBoundingBox();
         }
         if (follow && objs[i]->classId == PART_ID) {
            particleSystem *temp = (particleSystem*)objs[i];
            cam.setFocus(temp->pos);
         }
      }
   } glPopMatrix();
}
开发者ID:Guinto,项目名称:Particle-System,代码行数:26,代码来源:main.cpp

示例13: drawScene

// Draws the scene
void drawScene()
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	// Camera
	cam.look();
	// Lights
	light01.draw(); // Diffuse
	light02.draw(false); // Ambient
	// Object
	ball01.draw();
	glutSwapBuffers();
}
开发者ID:mohsend,项目名称:Magnificent-University-Projects,代码行数:15,代码来源:main.cpp

示例14: render

void render()
{
	fr.SetCameraPos(Camera.getPos());
	glm::mat4 view = Camera.getView();
	glm::mat4 projection = Camera.getProjection();
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	glClearColor( 0.f, 0.f, 0.5f, 0.f );
	fr.render(view, projection);

	GBuffer::BindForWriting();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glDepthMask(GL_TRUE);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	glEnable(GL_CULL_FACE);
	glCullFace(GL_FRONT);
	glClearColor( 0.f, 0.f, 0.5f, 0.f );
	Terrain.render(view, projection);
	GBuffer::DefaultBuffer();
	//glDisable(GL_CULL_FACE);
	//glDisable(GL_DEPTH_TEST);
	return;
}
开发者ID:doctorwk007,项目名称:OpenGL-and-GDAL-Tutorials,代码行数:24,代码来源:main.cpp

示例15: paintGL

void GLWidget::paintGL(){

    glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
    glClearDepth(1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();
    gluLookAt(Camera.mPos.x,  Camera.mPos.y,  Camera.mPos.z,
              Camera.mView.x, Camera.mView.y, Camera.mView.z,
              Camera.mUp.x,   Camera.mUp.y,   Camera.mUp.z);


     Camera.Mouse_Move();

     Keyboard_Operations();

     terra();
    glEnable(GL_LIGHTING);
     drawCube();
    glDisable(GL_LIGHTING);

     // Draw The Car
             glColor3f(1,1,1);
             glEnable(GL_LIGHTING);
             glPushMatrix();
             glTranslatef(20.0f,-3.0f,10.0f);
             Auto->draw();
             glPopMatrix();
             glDisable(GL_LIGHTING);


     rot+=1;
       // Framerate control
        int delay = time.msecsTo(QTime::currentTime());
        if (delay == 0)
           delay = 1;
        time = QTime::currentTime();
        timer->start(qMax(0, 30 - delay));

}
开发者ID:ismaelbonato,项目名称:OpenGLGame,代码行数:40,代码来源:glwidget.cpp


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