[osg-users] How to grab color from a point on a model?
Robert Osfield
robert.osfield at gmail.com
Fri Oct 9 00:35:16 PDT 2015
Hi Dan,
It could be that UnRefImageDataAfterApply is being set to true in
preprocessing of the data. Are you loading the data from an OSG native
format (ive, osg, osgb, osgx,osgt) that you are previously converted from a
source format? This processing may have set the UnRefImageDataAfterApply
to true.
To reset the value back to false you can use the
osgUtil::Optimizer::TextureVisitor, note it's constructor where you can
pass in what settings you want to change and the value:
class OSGUTIL_EXPORT TextureVisitor : public BaseOptimizerVisitor
{
public:
TextureVisitor(bool changeAutoUnRef, bool valueAutoUnRef,
bool changeClientImageStorage, bool
valueClientImageStorage,
bool changeAnisotropy, float valueAnisotropy,
Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer,
OPTIMIZE_TEXTURE_SETTINGS),
_changeAutoUnRef(changeAutoUnRef),
_valueAutoUnRef(valueAutoUnRef),
_changeClientImageStorage(changeClientImageStorage),
_valueClientImageStorage(valueClientImageStorage),
_changeAnisotropy(changeAnisotropy),
_valueAnisotropy(valueAnisotropy) {}
You can simply create this visitor standalone with the settings you want
and apply to your scene graph.
No other parts of the OSG set the UnRefImageDataAfterApply - do a search of
the OSG to confirm this yourself. The other way is to simply put a
breakpoint into osg::Texture::setUnRefImageDataAfterApply() to spot when
and where it's being set.
Robert.
On 8 October 2015 at 21:40, Dan Flickinger <dmflickinger at gmail.com> wrote:
> Robert,
>
> Thank you very much for the swift reply. Good point on switching to
> PolytopeIntersector. Another part of the project is already using that for
> something else. LineSegmentIntersector is finding intersections, so at
> least it's assumed to work okay for now. I'll definitely switch over once I
> get this piece working.
>
> I did find an instance of osgUtil::Optimizer in the code, and I disabled
> it. The images are still dereferenced in the textures though. In checking
> each texture with osg::Texture::getUnRefImageDataAfterApply(), it's still
> set to true. Is there anything else that would enable this aside from
> running the optimizer?
>
> I found where each model has its osg::Node initialized, but I'm at a loss
> in pulling out references to the textures from that. (In order to call
> setUnRefImageDataAfterApply() there.) Do I need to dig through the
> attribute list to find a state attribute that is a texture? I'm concerned
> that if I call setUnRefImageDataAfterApply() at initialization, it will
> still get reset to true by something else.
>
> Thanks for all the help!
>
> Best regards,
>
> Dan
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65330#65330
>
>
>
>
>
> _______________________________________________
> 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/20151009/d55a7f56/attachment-0003.htm>
More information about the osg-users
mailing list