Ejemplo n.º 1
0
void createSubBox(Eigen::Affine3f &target, int parent_w, int parent_h, int child_w, int child_h, int off_x, int off_y) {
	target = Eigen::Affine3f::Identity();
	#define FDIV(a,b) (((float)a)/((float)b))
	float rw_scale = FDIV(child_w,parent_w);
	float rh_scale = FDIV(child_h,parent_h);
	float mw = ((FDIV(1.0,child_w))*((float)off_x));
	float mh = (FDIV(1.0,child_h)*((float)off_y));
	target.scale(Eigen::Vector3f(rw_scale,rh_scale,0.0f));
	target.translate(Eigen::Vector3f(mw,mh,0.0f));
	#undef FDIV
}
Ejemplo n.º 2
0
void GLWidget::paintGL()
{
    makeCurrent();

    glClearColor(0.7, 0.7, 0.7, 1.0);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);

    if(Interface::showBackgroundImage)
    {
//        renderTexture.imageAlpha = Interface::alphaBackgroundImage;
//        renderTexture.renderTexture(*mTextManagerObj.getBaseTexture(), Eigen::Vector2i(this->width(), this->height()));
    }


//    phong.render(*mTextManagerObj.getMesh(), *currentCamera, light_trackball);

//      multi.render(mTextManagerObj, *currentCamera, light_trackball);
      multiMask.useWeights = Interface::useWeights;
      multiMask.render(mTextManagerObj, *currentCamera, light_trackball);
//    depthMap.render(*mTextManagerObj.getMesh(), calibrationCamera, light_trackball);

    if(Interface::camera == Interface::CAMERA_TYPES::FREE)
    {
//        camera.render();
        if(Interface::ShowCameras){
            for(int i =0 ; i < mTextManagerObj.getNumPhotos(); i++)
            {
                mTextManagerObj.changePhotoReferenceTo(i);
                camRep.resetModelMatrix();
                Eigen::Affine3f m = (*(mTextManagerObj.getViewMatrix())).inverse();
                m.translation() -= mTextManagerObj.getMesh()->getCentroid();
                m.translation() *= mTextManagerObj.getMesh()->getScale();
                m.scale (0.08);
                camRep.setModelMatrix(m);
                camRep.render(*currentCamera, light_trackball);
            }
            mTextManagerObj.changePhotoReferenceTo(0);
        }
    }
}
bool normalizeSize(std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > &points, std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > &normals, Eigen::Affine3f &invTransform)
{
    // Assumes normalized rotation/translation
    Eigen::AlignedBox3f aabb;
    for (size_t i = 0; i < points.size(); ++i) {
        aabb.extend(points[i]);
    }

    // Calculate isotropic scaling to that the longest side becomes unit length
    const float s = 1.f / aabb.diagonal().maxCoeff();

    for (size_t i = 0; i < points.size(); ++i) {
        points[i] *= s;
    }

    // Assemble inverse transform.
    invTransform = Eigen::Affine3f::Identity();
    invTransform = invTransform.scale(s);
    invTransform = invTransform.inverse();

    return true;
}
Ejemplo n.º 4
0
template <typename PointInT, typename PointOutT> void
pcl::ESFEstimation<PointInT, PointOutT>::scale_points_unit_sphere (
    const pcl::PointCloud<PointInT> &pc, float scalefactor, Eigen::Vector4f& centroid)
{
  pcl::compute3DCentroid (pc, centroid);
  pcl::demeanPointCloud (pc, centroid, local_cloud_);

  float max_distance = 0, d;
  pcl::PointXYZ cog (0, 0, 0);

  for (size_t i = 0; i < local_cloud_.points.size (); ++i)
  {
    d = pcl::euclideanDistance(cog,local_cloud_.points[i]);
    if (d > max_distance)
      max_distance = d;
  }

  float scale_factor = 1.0f / max_distance * scalefactor;

  Eigen::Affine3f matrix = Eigen::Affine3f::Identity();
  matrix.scale (scale_factor);
  pcl::transformPointCloud (local_cloud_, local_cloud_, matrix);
}
Ejemplo n.º 5
0
 /**
  * @brief Scales the view matrix by given factor in all axis.
  * @param scale_factor Scale factors in all axis.
  */
 void scale (float scale_factor)
 {
     view_matrix.scale(scale_factor);
 }
Ejemplo n.º 6
0
 /**
  * @brief Scales the view matrix by given factors.
  * @param scale_factors Scale factors in x, y, and z axis.
  */
 void scale (const Eigen::Vector3f& scale_factors)
 {
     view_matrix.scale(scale_factors);
 }
Ejemplo n.º 7
0
 /**
  * @brief Normalize model matrix to center and scale model.
  * The model matrix will include a translation to place model's centroid
  * at the origin, and scale the model to fit inside a unit sphere.
  */
 void normalizeModelMatrix (void)
 {
     model_matrix.scale(scale);
     model_matrix.translate(-centroid);
 }