[osg-users] How to grab color from a point on a model?

Robert Osfield robert.osfield at gmail.com
Wed Oct 7 07:53:54 PDT 2015


Hi Dan,

LineSegmentIntersector won't work with point clouds.  You potentially could
use the PolytopeIntersector instead or write a custom Intersector class
that can handle point data by testing against against cylinder.

As for the NULL Image data this may well be down to the OSG automatically
unref'ing osg::Image once they have been download to OpenGL - this
optimization isn't on by default but if you run the osgUtil::Optimizer on
the scene graph this optimization will be enabled.  The feature which
controls this automatic unref'ing is
osg::Texture::setUnRefImageDataAfterApply(bool), from include/osg/Texture
the docs are:

        /** Sets whether or not the apply() function will unreference the
image
          * data. If enabled, and the image data is only referenced by this
          * Texture, apply() will delete the image data. */
        inline void setUnRefImageDataAfterApply(bool flag) {
_unrefImageDataAfterApply = flag; }

Try not calling osgUtil::Optimizer or reset the UnRefImageDataAfterApply
back to false before any rendering is done on the scene graph.

Robert.


On 7 October 2015 at 15:31, Dan Flickinger <dmflickinger at gmail.com> wrote:

> Hi all,
>
> I recently took over maintaining a system utilizing osg, which simulates
> sensors on an autonomous vehicle. One of the features in the works is to
> model a new LIDAR sensor. The system grabs intersections of line segments
> approximating laser pulses, pulling points into
> osgUtil::LineSegmentIntersector::Intersection objects. Now these
> intersections are used to generate simulated point clouds, and I am
> attempting to model intensity in these points by approximating the color of
> the model at the intersection point. So this is where I run into a wall.
>
> I get an osg::Texture pointer from
> osg::Util::LineSegmentIntersector::Intersection.getTextureLookUp(osg::Vec3),
> which is an osg::Texture2D. This pulls the texture as expected. From there,
> I attempt to pull out an osg::Image* out of osg::Texture2D.getImage(0). All
> I'm getting from that is a bunch of NULLs; on multiple models.
>
> My working theory is that _image is never getting set in the Texture2D
> object, or is that set right before getting handed over to OpenGL, and then
> unset as the images are deleted in order to not drag around a bunch of
> cruft? So is there a way to retain the images after loading the models? Or
> is there a better way to go about grabbing the color of a point on a model?
> Does texture compression play a part in this? I assume that compressed
> textures would just return garbage, not have _image set as NULL.
>
> Best regards,
>
> Dan
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65318#65318
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151007/796ca230/attachment-0003.htm>


More information about the osg-users mailing list