本文整理汇总了C++中GpuVoxelsSharedPtr::addPrimitives方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuVoxelsSharedPtr::addPrimitives方法的具体用法?C++ GpuVoxelsSharedPtr::addPrimitives怎么用?C++ GpuVoxelsSharedPtr::addPrimitives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GpuVoxelsSharedPtr
的用法示例。
在下文中一共展示了GpuVoxelsSharedPtr::addPrimitives方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
signal(SIGINT, ctrlchandler);
signal(SIGTERM, killhandler);
icl_core::logging::initialize(argc, argv);
gvl = GpuVoxels::getInstance();
gvl->initialize(200, 200, 100, 3.0);
gvl->addMap(MT_BITVECTOR_VOXELLIST, "voxellist");
// This should result in two lines of points with equal spacing inbetween the points of each line.
// The Primitives hover a bit above the pointcloud points.
std::vector<Vector3f> listPoints;
listPoints.push_back(Vector3f(30.0f, 9.0f, 12.0f));
listPoints.push_back(Vector3f(30.0f,15.0f, 12.0f));
listPoints.push_back(Vector3f(30.0f,21.0f, 12.0f));
listPoints.push_back(Vector3f(30.0f,27.0f, 12.0f));
std::vector<Vector3f> metric3Point;
metric3Point.push_back(Vector3f(30.0f,9.0f,9.0f));
std::vector<Vector4f> metric4Point;
metric4Point.push_back(Vector4f(30.0f,15.0f,9.0f,3.0f));
std::vector<Vector3i> voxel3Point;
voxel3Point.push_back(Vector3i(10,7,3));
std::vector<Vector4i> voxel4Point;
voxel4Point.push_back(Vector4i(10,9,3,1));
gvl->insertPointCloudIntoMap(listPoints, "voxellist", BitVoxelMeaning(1));
gvl->addPrimitives(primitive_array::ePRIM_SPHERE, "metric3Sphere");
bool prim = gvl->modifyPrimitives("metric3Sphere", metric3Point, 3.0f);
gvl->addPrimitives(primitive_array::ePRIM_SPHERE, "metric4Sphere");
prim = gvl->modifyPrimitives("metric4Sphere", metric4Point);
gvl->addPrimitives(primitive_array::ePRIM_SPHERE, "voxel3Sphere");
prim = gvl->modifyPrimitives("voxel3Sphere", voxel3Point, 1);
gvl->addPrimitives(primitive_array::ePRIM_SPHERE, "voxel4Sphere");
prim = gvl->modifyPrimitives("voxel4Sphere", voxel4Point);
std::cout << "Entering Draw Loop : " << prim << std::endl;
while(true)
{
gvl->visualizeMap("voxellist");
gvl->visualizePrimitivesArray("metric3Sphere");
gvl->visualizePrimitivesArray("metric4Sphere");
gvl->visualizePrimitivesArray("voxel3Sphere");
gvl->visualizePrimitivesArray("voxel4Sphere");
}
}
示例2: main
int main(int argc, char* argv[])
{
signal(SIGINT, ctrlchandler);
signal(SIGTERM, killhandler);
icl_core::logging::initialize(argc, argv);
/*
* First, we generate an API class, which defines the
* volume of our space and the resolution.
* Be careful here! The size is limited by the memory
* of your GPU. Even if an empty Octree is small, a
* Voxelmap will always require the full memory.
*/
gvl = GpuVoxels::getInstance();
gvl->initialize(200, 200, 200, 0.01);
// Now we add some maps
gvl->addMap(MT_PROBAB_VOXELMAP, "myProbabVoxmap");
gvl->addMap(MT_BITVECTOR_VOXELMAP, "myBitmapVoxmap");
gvl->addMap(MT_BITVECTOR_OCTREE, "myOctree");
gvl->addMap(MT_PROBAB_VOXELMAP, "myCoordinateSystemMap");
// And two different primitive types
gvl->addPrimitives(primitive_array::ePRIM_SPHERE, "myPrims");
gvl->addPrimitives(primitive_array::ePRIM_CUBOID, "mySecondPrims");
std::vector<Vector4f> prim_positions(1000);
std::vector<Vector4i> prim_positions2(1000);
// These coordinates are used for three boxes that are inserted into the maps
Vector3f center1_min(0.5,0.5,0.5);
Vector3f center1_max(0.6,0.6,0.6);
Vector3f center2_min(0.5,0.5,0.5);
Vector3f center2_max(0.6,0.6,0.6);
Vector3f center3_min(0.5,0.5,0.5);
Vector3f center3_max(0.6,0.6,0.6);
Vector3f corner1_min;
Vector3f corner2_min;
Vector3f corner3_min;
Vector3f corner1_max;
Vector3f corner2_max;
Vector3f corner3_max;
// We load the model of a coordinate system.
if (!gvl->insertPointCloudFromFile("myCoordinateSystemMap", "coordinate_system_100.binvox", true,
eBVM_OCCUPIED, true, Vector3f(0, 0, 0),0.5))
{
LOGGING_WARNING(Gpu_voxels, "Could not insert the PCD file..." << endl);
}
/*
* Now we start the main loop, that will animate the scene.
*/
float t = 0.0;
int j = 0;
while(true)
{
// Calculate new positions for the boxes
float x = sin(t);
float y = cos(t);
t += 0.03;
corner1_min = center1_min + Vector3f(0.2 * x, 0.2 * y, 0);
corner1_max = center1_max + Vector3f(0.2 * x, 0.2 * y, 0);
gvl->insertBoxIntoMap(corner1_min, corner1_max, "myProbabVoxmap", eBVM_OCCUPIED, 2);
corner2_min = center2_min + Vector3f(0.0, 0.2 * x, 0.2 * y);
corner2_max = center2_max + Vector3f(0.0, 0.2 * x, 0.2 * y);
gvl->insertBoxIntoMap(corner3_min, corner3_max, "myBitmapVoxmap", eBVM_OCCUPIED, 2);
corner3_min = center3_min + Vector3f(0.2 * x, 0.0, 0.2 * y);
corner3_max = center3_max + Vector3f(0.2 * x, 0.0, 0.2 * y);
gvl->insertBoxIntoMap(corner2_min, corner2_max, "myOctree", eBVM_OCCUPIED, 2);
// generate info on the occuring collisions:
LOGGING_INFO(
Gpu_voxels, "Collsions myProbabVoxmap + myBitmapVoxmap: " << gvl->getMap("myProbabVoxmap")->as<voxelmap::ProbVoxelMap>()->collideWith(gvl->getMap("myBitmapVoxmap")->as<voxelmap::BitVectorVoxelMap>()) << endl <<
"Collsions myOctree + myBitmapVoxmap: " << gvl->getMap("myOctree")->as<NTree::GvlNTreeDet>()->collideWith(gvl->getMap("myBitmapVoxmap")->as<voxelmap::BitVectorVoxelMap>()) << endl <<
"Collsions myOctree + myProbabVoxmap: " << gvl->getMap("myOctree")->as<NTree::GvlNTreeDet>()->collideWith(gvl->getMap("myProbabVoxmap")->as<voxelmap::ProbVoxelMap>()) << endl);
// tell the visualier that the maps have changed
gvl->visualizeMap("myProbabVoxmap");
gvl->visualizeMap("myBitmapVoxmap");
gvl->visualizeMap("myOctree");
gvl->visualizeMap("myCoordinateSystemMap");
// update the primitves:
for(size_t i = 0; i < prim_positions.size(); i++)
{
// x, y, z, size
prim_positions[i] = Vector4f(0.2 + (i / 250.0), 0.2 + (sin(i/5.0)/50.0), (sin(j/5.0) / 50.0), 0.01);
prim_positions2[i] = Vector4i(20 + (sin(i/5.0)/0.5), 20 + (sin(j/5.0) / 0.5), i / 2.5, 1);
j++;
}
gvl->modifyPrimitives("myPrims", prim_positions);
gvl->modifyPrimitives("mySecondPrims", prim_positions2);
// tell the visualizier that the data has changed:
gvl->visualizePrimitivesArray("myPrims");
gvl->visualizePrimitivesArray("mySecondPrims");
usleep(30000);
//.........这里部分代码省略.........