コード例 #1
0
ファイル: model_renderer.cpp プロジェクト: ashuang/sceneview
void ModelRenderer::LoadModelGL() {
  Scene::Ptr scene = GetScene();

  // Clear out any previously loaded model.
  ClearModel();

  // Load the model as a scene graph resource.
  Scene::Ptr model = AssetImporter::ImportFile(GetResources(), model_fname_);

  if (!model) {
    return;
  }

  // Create a node in the main scene graph.
  node_ = scene->MakeGroup(GetBaseNode());

  // Instantiate the model as a child of the newly created node.
  scene->MakeGroupFromScene(node_, model);

  // Scale and translate the model so that it fits inside a unit cube
  // centered at the origin.
  const AxisAlignedBox& box = model->Root()->WorldBoundingBox();
  const QVector3D span = box.Max() - box.Min();
  const float max_span = std::max(std::max(span.x(), span.y()), span.z());
  const double scale_factor = 1.0 / max_span;
  node_->SetScale(QVector3D(scale_factor, scale_factor, scale_factor));
  node_->SetTranslation(-0.5 * scale_factor * (box.Max() + box.Min()));

  GetViewport()->ScheduleRedraw();
}
コード例 #2
0
    void ObjectDetectionViewer::onPointCloudReceived(PointCloud<Point>::ConstPtr cloud) {
        posix_time::ptime startTime = posix_time::microsec_clock::local_time();

        Scene::Ptr scene = Scene::fromPointCloud(cloud, config);
        Table::Collection detectedTables = tableDetector.detectTables(scene);
        Object::Collection detectedObjects = objectDetector.detectObjects(scene, detectedTables);

        {
            mutex::scoped_lock(resultMutex);
            this->detectedTables = detectedTables;
            this->detectedObjects = detectedObjects;
        }

        posix_time::time_duration diff = posix_time::microsec_clock::local_time() - startTime;
        processingTime = diff.total_milliseconds();

        showPointCloud(scene->getFullPointCloud());
    }
コード例 #3
0
void StockShapeRenderer::InitializeGL() {
  Scene::Ptr scene = GetScene();
  ResourceManager::Ptr resources = GetResources();
  GroupNode* base_node = GetBaseNode();

  // Create a material to share among several shapes
  StockResources stock(resources);
  material_ = stock.NewMaterial(StockResources::kUniformColorLighting);
  material_->SetParam(sv::kDiffuse, 1.0, 0.5, 0.5, 1.0);
  material_->SetParam(sv::kSpecular, 1.0, 0.5, 0.5, 1.0);
  material_->SetParam(sv::kShininess, 10.0f);

  // Create a material to use for the selected shape
  select_material_ = stock.NewMaterial(StockResources::kUniformColorLighting);
  select_material_->SetParam(sv::kDiffuse, 1.0, 0.0, 1.0, 1.0);
  select_material_->SetParam(sv::kSpecular, 1.0, 0.0, 0.1, 1.0);
  select_material_->SetParam(sv::kShininess, 16.0f);

  // Create a bunch of shapes
  shapes_.push_back(scene->MakeDrawNode(base_node, stock.Cone(), material_));
  shapes_.push_back(scene->MakeDrawNode(base_node, stock.Cube(), material_));
  shapes_.push_back(scene->MakeDrawNode(base_node, stock.Cylinder(), material_));
  shapes_.push_back(scene->MakeDrawNode(base_node, stock.Sphere(), material_));

  DrawNode* axes = scene->MakeDrawNode(base_node);
  axes->Add(stock.UnitAxes());
  shapes_.push_back(axes);

  // Move the shapes so they're not all on top of each other.
  //
  // Also set the selection mask for each node so that they can be selected by
  // StockShapeSelector
  const double spacing = 2.0;
  const double x_start = - spacing * shapes_.size() / 2;
  for (size_t i = 0; i < shapes_.size(); ++i) {
    shapes_[i]->SetTranslation(x_start + i * spacing, 0, 0);
    shapes_[i]->SetSelectionMask(1);
  }
}
コード例 #4
0
ファイル: UpdateFrequency.cpp プロジェクト: altseed/Altseed
	void AddHastedLayerTo(Scene::Ptr scene, float frequency, Vector2DF position)
	{
		auto layer = make_shared<Layer2D>();
		auto object = make_shared<MovingObject>();

		layer->SetUpdateFrequency(frequency);
		object->SetTexture(asd::Engine::GetGraphics()->CreateTexture2D(ToAString("Data/Texture/Cloud1.png").c_str()));
		object->SetScale(Vector2DF(0.5f, 0.5f));
		object->SetPosition(position);

		scene->AddLayer(layer);
		layer->AddObject(object);
	}
コード例 #5
0
// Read in a 3D model
void
loadPolygonMeshModel (char* polygon_file)
{
  pcl::PolygonMesh mesh;
  pcl::io::loadPolygonFile (polygon_file, mesh);
  pcl::PolygonMesh::Ptr cloud (new pcl::PolygonMesh (mesh));
  
  TriangleMeshModel::Ptr model = TriangleMeshModel::Ptr (new TriangleMeshModel (cloud));
  scene_->add (model);
  
  std::cout << "Just read " << polygon_file << std::endl;
  std::cout << mesh.polygons.size () << " polygons and "
	    << mesh.cloud.data.size () << " triangles\n";
}
コード例 #6
0
ファイル: range_test.cpp プロジェクト: nttputus/PCL
void load_model(const std::vector<std::string> & files)
{
    for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file)
    {
        std::cout << "Load model: " << *file << std::endl;

        pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
        if (pcl::io::loadPCDFile<pcl::PointXYZRGB> (*file, *cloud) == -1) //* load the file
        {
            PCL_ERROR ("Couldn't read file %s \n", file->c_str()) ;
            exit (-1);
        }

        PointCloudModel::Ptr model = PointCloudModel::Ptr(new PointCloudModel(GL_POLYGON, cloud));
        scene_->add(model);
    }
}
コード例 #7
0
// Read in a 3D model
void load_PolygonMesh_model (char* polygon_file)
{
  pcl::PolygonMesh mesh;	// (new pcl::PolygonMesh);
  //pcl::io::loadPolygonFile("/home/mfallon/data/models/dalet/Darlek_modified_works.obj",mesh);
  pcl::io::loadPolygonFile (polygon_file, mesh);
  pcl::PolygonMesh::Ptr cloud (new pcl::PolygonMesh (mesh));
  
  // Not sure if PolygonMesh assumes triangles if to
  // TODO: Ask a developer
  PolygonMeshModel::Ptr model = PolygonMeshModel::Ptr (new PolygonMeshModel (GL_POLYGON, cloud));
  scene_->add (model);
  
  std::cout << "Just read " << polygon_file << std::endl;
  std::cout << mesh.polygons.size () << " polygons and "
	    << mesh.cloud.data.size () << " triangles\n";
  
}
コード例 #8
0
ファイル: kinfu_app_sim.cpp プロジェクト: AlexSchwank/pcl
// Read in a 3D model
void
load_PolygonMesh_model (std::string polygon_file)
{
  pcl::PolygonMesh mesh;	// (new pcl::PolygonMesh);
  //pcl::io::loadPolygonFile("/home/mfallon/data/models/dalet/Darlek_modified_works.obj",mesh);
  if (!pcl::io::loadPolygonFile (polygon_file, mesh)){
    std::cout << "No ply file found, exiting" << std::endl;
   exit(-1); 
  }
  pcl::PolygonMesh::Ptr cloud (new pcl::PolygonMesh (mesh));
  
  TriangleMeshModel::Ptr model = TriangleMeshModel::Ptr (new TriangleMeshModel (cloud));
  scene_->add (model);
  
  std::cout << "Just read " << polygon_file << std::endl;
  std::cout << mesh.polygons.size () << " polygons and "
	    << mesh.cloud.data.size () << " triangles\n";
}