[osg-users] "LOS" materail query

Mike Greene mgreene at hiwaay.net
Wed Aug 26 12:34:58 PDT 2015


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








More information about the osg-users mailing list