Hi all,
In danger of exposing ignorance, I need to ask this question: It should
be possible to texture a SphereSegment, right?
In the example code snipplet below, the sphere segment displays
correctly above the terrain, but for some reason it is not textured. I
hope someone on the list can point out the obvious mistake:)
Best regards,
John Larring
PS: I have checked that the image load succeeds;)
...
// Load the terrain
// load the nodes from the commandline arguments.
osg::ref_ptr<osg::Node> terrainRoot = osgDB::readNodeFiles(arguments);
osg::CoordinateSystemNode* csn =
findTopMostNodeOfType<osg::CoordinateSystemNode>(terrainRoot.get());
double radius = csn->getEllipsoidModel()->getRadiusEquator() +
500000.0f;
osgSim::SphereSegment * ss = new
osgSim::SphereSegment(osg::Vec3d(0.0,0.0,0.0), // center
radius, // radius
osg::DegreesToRadians(-15.0f),
osg::DegreesToRadians(15.0f),
osg::DegreesToRadians(30.0f),
osg::DegreesToRadians(50.0f),
60);
ss->setAllColors(osg::Vec4(1.0f,1.0f,1.0f,0.5f));
ss->setSideColor(osg::Vec4(0.5f,1.0f,1.0f,0.1f));
osg::Image* image = osgDB::readImageFile("~/images/test.jpg");
if (image)
{
osg::Texture2D* texture = new osg::Texture2D;
texture->setImage(image);
texture->setMaxAnisotropy(8);
osg::StateSet* ssss = ss->getOrCreateStateSet();
ssss->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
}
else
std::cerr<< "Failed to load: " <<imageFile<<std::endl;
rootNode->addChild(terrainRoot.get());
rootNode->addChild(ss);
// register our custom handler for adjust Terrain settings
viewer.addEventHandler(new CustomHandler(rootNode.get(), &viewer));
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData( rootNode.get() );
// create the windows and run the threads.
viewer.realize();
return viewer.run();
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org