Пример #1
0
bool PointCloudRenderer::renderImpl(SoSeparator *ivRoot, Renderable &renderable)
{
    //Being here without a point cloud is a bug.
    assert(renderable.has_pointcloud() || renderable.has_pointcloud2());

    //Create the node subtree of the renderable if necessary.
    if(!ivRoot->getNumChildren())
    {
        createNodes(ivRoot, renderable);
    }
    setScale(ivRoot, renderable);
    //Get the nodes to insert the point data into.
    SoMaterial * mat = static_cast<SoMaterial *>(ivRoot->getChild(3));
    SoCoordinate3 * coord =
            static_cast<SoCoordinate3 *>(ivRoot->getChild(2));

    //Read the point data into Inventor structures.
    std::vector<SbVec3f> points;
    std::vector<SbColor> colors;
    int point_size = fillPointList(renderable, points,colors);
    //If points were parsed or the input meant to send no points,
    //set the new point cloud points and colors.
    if(points.size() || !point_size)
    {
        //Insert the inventor structures in to the
        coord->point.setValues(0,points.size(), &points[0]);
        mat->diffuseColor.setValues(0,colors.size(), &colors[0]);
    }
    return points.size() > 0;
}
Пример #2
0
void RenderableProtoDrawer::renderMessage(Renderable &renderable)
{
    if(renderable.has_pointcloud())
    {
        PointCloudRenderer renderer;
        QString ivRootName("PointCloudRoot");
        renderer.render(renderable,ivRootName);
    }
    if(renderable.has_pointcloud2())
    {
        PointCloud2Renderer renderer;
        QString ivRootName("PointCloudRoot2");
        renderer.render(renderable,ivRootName);
    }
    if(renderable.has_frame())
    {
        FrameRenderer renderer;
        QString emptyName = "";
        renderer.render(renderable, emptyName);
    }
}