void VoxelGridGPU::setUniformCellSizeFromResolutionAndMapping(float width,
		float height, int resX, int resY, int resZ) {

	if ( ( width / resX )  != ( height / resY) )
	{
		DEBUGLOG->log( "Resolution and dimensions are in an unequal ratio. Cannot compute uniform cell size");
		return;
	}

	this->width = width;
	this->height = height;
	this->resX = resX;
	this->resY = resY;
	this->resZ = resZ;

	this->cellSize = ( width / resX );

	this->depth = this->cellSize * resZ;

	computeProjectionMatrix();

	computeWorldToVoxel();

	printInfo();
}
Ejemplo n.º 2
0
void display(void) {
	double time;
	char name[128];

	timer1.startTimer();

	/* first set up the matrices */
	computeModelViewMatrix();
	computeProjectionMatrix();

	if (opengl_test) {
		/* draw the scene with opengl */
		scene.renderSceneOpenGL();
	}
	else {
		/* draw the scene with software */
		scene.renderSceneSoftware();
		g_fb.dumpToScreen();
	}

	glFinish();

	timer1.stopTimer();
	time = timer1.getTime();
	sprintf(name, "%s: %.4lf s, %.2lf fps", opengl_test ? "GL" : "Soft", time, 1.0/time);
	glutSetWindowTitle(name);

	checkGLErrors("Errors in display()!\n");

	glutSwapBuffers();
}
Ejemplo n.º 3
0
	void Camera::setOrthogonal(int width, int height, float nearP, float farP)
	{
		this->setWidth(width);
		this->setHeight(height);
		this->setZNearPlane(nearP);
		this->setZFarPlane(farP);
		this->setType(CameraType::ORTHOGRAPHIC);
		computeProjectionMatrix();
	}
Ejemplo n.º 4
0
void GLRender::loadProjectionMatrix(bool reset)
{
	glMatrixMode(GL_PROJECTION);

	if (reset)
		glLoadIdentity();

	computeProjectionMatrix();
	glMultMatrixf(m_projectionMatrix);
}
Ejemplo n.º 5
0
	void Camera::setPerspective(int width, int height, float nearP, float farP, float fieldOfView)
	{
		this->setWidth(width);
		this->setHeight(height);
		this->setZNearPlane(nearP);
		this->setZFarPlane(farP);
		this->setFieldOfView(fieldOfView);
		this->setType(CameraType::PERSPECTIVE);
		computeProjectionMatrix();
	}
Ejemplo n.º 6
0
  void MeshRenderer :: renderToImage(cv::Mat4b& image, const Pose3D& pose, int flags)
  {     
    m_pbuffer->makeCurrent();

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    if (flags & LIGHTING)
    {
      GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
      GLfloat mat_shininess[] = { 10.0 };
      GLfloat light_position[] = { 1, 1, 1.0, 0.0 };
      glEnable(GL_LIGHTING);
      glShadeModel (GL_SMOOTH);
      glEnable(GL_COLOR_MATERIAL);
      glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
      glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
      glLightfv(GL_LIGHT0, GL_POSITION, light_position);
      glEnable(GL_LIGHT0);
    }

    computeProjectionMatrix(image, pose);

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

    if (flags & WIREFRAME)
      glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

    // draw the display list
    glCallList(m_list_index);
    glFlush();

    computeDepthBuffer();
    QImage qimage = m_pbuffer->toImage();
    for (int r = 0; r < qimage.height(); ++r)
    for (int c = 0; c < qimage.width(); ++c)
    {
      QRgb pixel = qimage.pixel(c,r);
      Vec4b color (qBlue(pixel), qGreen(pixel), qRed(pixel), qAlpha(pixel));
      m_color_buffer(r,c) = color;
      float a = qAlpha(pixel)/255.f;
      if (a > 0)
      {
        Vec4b old_color = image(r,c);
        image(r,c) = Vec4b(old_color[0]*(1-a) + color[0]*a,
                           old_color[1]*(1-a) + color[1]*a,
                           old_color[2]*(1-a) + color[2]*a,
                           255);
      }
    }
  }
void VoxelGridGPU::setDimensionFromMapping(float cellSize, float resX,
		float resY, float resZ) {

	if ( cellSize <= 0.0f )
	{
		DEBUGLOG->log( "Invalid cell size : ", cellSize);
		return;
	}

	this->cellSize = cellSize;
	this->resX = resX;
	this->resY = resY;
	this->resZ = resZ;

	this->width = resX * cellSize;
	this->height = resY * cellSize;
	this->depth = resZ * cellSize;

	computeProjectionMatrix();

	computeWorldToVoxel();

	printInfo();
}
Ejemplo n.º 8
0
void PerspectiveCamera::update()
{
	computeProjectionMatrix();
	computeVisualizationMatrix();
}
Ejemplo n.º 9
0
void PerspectiveCamera::update(){
	glViewport(0, 0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
	computeProjectionMatrix();
    computeVisualizationMatrix();
}
Ejemplo n.º 10
0
void OrthogonalCamera::update() {
    computeProjectionMatrix();
    computeVisualizationMatrix();
}