[osg-users] "LOS" materail query

Robert Osfield robert.osfield at gmail.com
Thu Aug 27 00:56:54 PDT 2015


Hi Mike,

OK, the next complication is probably that the osg::Texture has the
probably unref'd the Image assigned to it after it's download to GL, the
method that control it is in include/osg/Texture:

        /** 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; }

This is memory optimization, but... if you want to look at the image data
after it's been rendered you obviously don't want to use this feature.  By
default this feature is OFF, but if you run the osgUtil::Optimizer on the
scene graph it can switch it on as a memory optimization.

You can switch it back on using the osgUtil::Optimizer::TextureVisitor see
the include/osgUtil/Optimizer header for the TextureVisitor.

Robert.





On 26 August 2015 at 20:34, Mike Greene <mgreene at hiwaay.net> wrote:

> OK, fixed that - loaded an .ive file and was able to get correct looking
> texture coordinates. In a .ive file with embedded textures, is there a
> textureName? Probably not - not really important.
>
> But the code does say that there is one image in the texture. But doing
> the getImage(0) does not return a valid image and thus no color from the
> texture is returned.
>
>
> Code:
>
>  osgUtil::LineSegmentIntersector::Intersections intersections;
>                 if (viewer->computeIntersections(ea, intersections))
>                 {
>                         const
> osgUtil::LineSegmentIntersector::Intersection& hit = *intersections.begin();
>
>                         //MGREENE
>                         std::cout << "hit = " <<
> hit.getLocalIntersectPoint().x() << "," << hit.getLocalIntersectPoint().y()
> << "," << hit.getLocalIntersectPoint().z() << std::endl;
>
>                         osg::Vec3 tc(0, 0, 0);
>                         osg::Texture* myTexture = hit.getTextureLookUp(tc);
>                         std::cout << "tc = " << tc.x() << "," << tc.y() <<
> "," << tc.z() << std::endl;
>
>
>                         if (myTexture){
>                                 std::string myString =
> myTexture->getName();
>                                 std::cout << "texturename = " << myString
> << std::endl;
>
>                                 int numImages = myTexture->getNumImages();
>                                 std::cout << "numImages = " << numImages
> << std::endl;
>
>                                 osg::Image *myImage =
> myTexture->getImage(0);
>                                 if (myImage) {
>                                         osg::Vec4 textureColor =
> myImage->getColor(tc);
>                                         std::cout << "textureColor = " <<
> textureColor.r() << "," << textureColor.b() << "," << textureColor.g() <<
> "," << textureColor.a() << std::endl;
>                                 }
>                     }
>                         //END MGREENE
>
>
>
> ...
>
> Thank you!
>
> Cheers,
> Mike
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64908#64908
>
>
>
>
>
> _______________________________________________
> 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/20150827/ecafe0fc/attachment-0003.htm>


More information about the osg-users mailing list