Hi!
I have model of earth and 2 maps as texture on it - daylight and night texture.
I need to load one more texture - for example more detailed map of some region
or city.
How can I do it?
This is my code , which realizes 2 textures:
Code:
sPlanetSphere->setVertexArray(coords);
osg::Vec3Array* normals = new osg::Vec3Array(numVertices);
sPlanetSphere->setNormalArray(normals);
sPlanetSphere->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
osg::Vec2Array* texcoords = new osg::Vec2Array(numVertices);
sPlanetSphere->setTexCoordArray(0,texcoords);
sPlanetSphere->setTexCoordArray(1,texcoords);
.....
//NEW TEXTURE
// DAY
osg::Image* image =
osgDB::readImageFile(QString(QApplication::applicationDirPath()).toStdString()+"/img/earth2048.jpg");
// osg::Image* image = osgDB::readImageFile("img/EarthMap_2500x1250.jpg");
// osg::Image* image = osgDB::readImageFile("img/polit.jpg");
if ( image ){
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 );
sPlanetSphere->getOrCreateStateSet()->setTextureAttributeAndModes( 0,
tex2d, osg::StateAttribute::ON );
}
//NIGHT
osg::Image* image1 =
osgDB::readImageFile(QString(QApplication::applicationDirPath()).toStdString()+"/img/land_ocean_ice_lights_2048.jpg");
if ( image1 )
{
osg::StateSet* stateset = sPlanetSphere->getOrCreateStateSet();
osg::TexEnvCombine* texenv = new osg::TexEnvCombine;
texenv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);//
texenv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
texenv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
texenv->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
texenv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
texenv->setSource2_RGB(osg::TexEnvCombine::PRIMARY_COLOR);
texenv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
stateset->setTextureAttribute( 1, texenv );
osg::Texture2D* tex2d1 = new osg::Texture2D( image1 );
tex2d1->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
tex2d1->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );
stateset->setTextureAttributeAndModes( 1, tex2d1,
osg::StateAttribute::ON );
}
//END OF TEXTURE
Thank you!
Cheers,
Sergey
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36448#36448
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org