from Mike Weiblen, added wrap mode to planet texture to avoid black seam, and
add option of specifying the texture to use in osgshape.
This commit is contained in:
@@ -455,7 +455,10 @@ osg::Geode* SolarSystem::createPlanet( double radius, const std::string& name, c
|
||||
osg::Image* image = osgDB::readImageFile( textureName );
|
||||
if ( image )
|
||||
{
|
||||
geodePlanet->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D( image ), osg::StateAttribute::ON );
|
||||
osg::Texture2D* tex2d = new osg::Texture2D( image );
|
||||
tex2d->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
|
||||
tex2d->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );
|
||||
geodePlanet->getOrCreateStateSet()->setTextureAttributeAndModes( 0, tex2d, osg::StateAttribute::ON );
|
||||
|
||||
// reset the object color to white to allow the texture to set the colour.
|
||||
//sPlanetSphere->setColor( osg::Vec4(1.0f,1.0f,1.0f,1.0f) );
|
||||
@@ -491,7 +494,10 @@ osg::Geode* SolarSystem::createPlanet( double radius, const std::string& name, c
|
||||
texenv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
|
||||
|
||||
stateset->setTextureAttribute( 1, texenv );
|
||||
stateset->setTextureAttributeAndModes( 1, new osg::Texture2D( image ), osg::StateAttribute::ON );
|
||||
osg::Texture2D* tex2d = new osg::Texture2D( image );
|
||||
tex2d->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
|
||||
tex2d->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );
|
||||
stateset->setTextureAttributeAndModes( 1, tex2d, osg::StateAttribute::ON );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// for the grid data..
|
||||
#include "../osghangglide/terrain_coords.h"
|
||||
|
||||
osg::Geode* createShapes()
|
||||
osg::Geode* createShapes( char* img_filename )
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
@@ -21,7 +21,9 @@ osg::Geode* createShapes()
|
||||
// ---------------------------------------
|
||||
osg::StateSet* stateset = new osg::StateSet();
|
||||
|
||||
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
|
||||
if( ! img_filename ) img_filename = "Images/lz.rgb";
|
||||
osg::Image* image = osgDB::readImageFile( img_filename );
|
||||
|
||||
if (image)
|
||||
{
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
@@ -91,7 +93,7 @@ int main( int argc, char **argv )
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates the osg::Shape classes.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] [image_filename]");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
|
||||
// construct the viewer.
|
||||
@@ -119,8 +121,18 @@ int main( int argc, char **argv )
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* img_filename = 0;
|
||||
for( int pos = 1; pos < arguments.argc(); ++pos )
|
||||
{
|
||||
if( arguments.isString(pos) )
|
||||
{
|
||||
img_filename = arguments[pos];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
osg::Node* node = createShapes();
|
||||
osg::Node* node = createShapes( img_filename );
|
||||
|
||||
// add model to viewer.
|
||||
viewer.setSceneData( node );
|
||||
|
||||
Reference in New Issue
Block a user