Improvements to MultiTextureControl and texture layer handling in osgTerrain::DataSet.
This commit is contained in:
@@ -46,12 +46,31 @@ void MultiTextureControl::updateStateSet()
|
||||
|
||||
stateset->clear();
|
||||
|
||||
if (_textureWeightList.size()==1)
|
||||
unsigned int numTextureUnitsOn = 0;
|
||||
unsigned int unit;
|
||||
for(unit=0;unit<_textureWeightList.size();++unit)
|
||||
{
|
||||
osg::TexEnv* texenv = new osg::TexEnv(osg::TexEnv::MODULATE);
|
||||
stateset->setTextureAttribute(0, texenv);
|
||||
if (_textureWeightList[unit]>0.0f) ++numTextureUnitsOn;
|
||||
}
|
||||
if (_textureWeightList.size()==2)
|
||||
|
||||
if (numTextureUnitsOn<=1)
|
||||
{
|
||||
for(unit=0;unit<_textureWeightList.size();++unit)
|
||||
{
|
||||
if (_textureWeightList[unit]>0.0f)
|
||||
{
|
||||
osg::TexEnv* texenv = new osg::TexEnv(osg::TexEnv::MODULATE);
|
||||
stateset->setTextureAttribute(unit, texenv);
|
||||
stateset->setTextureMode(unit, GL_TEXTURE_2D, osg::StateAttribute::ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
stateset->setTextureMode(unit, GL_TEXTURE_2D, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (_textureWeightList.size()==2)
|
||||
{
|
||||
{
|
||||
osg::TexEnvCombine* texenv = new osg::TexEnvCombine;
|
||||
@@ -80,7 +99,7 @@ void MultiTextureControl::updateStateSet()
|
||||
stateset->setTextureAttribute(1, texenv);
|
||||
}
|
||||
}
|
||||
if (_textureWeightList.size()==3)
|
||||
else if (_textureWeightList.size()==3)
|
||||
{
|
||||
float b = (_textureWeightList[0]+_textureWeightList[1])/(_textureWeightList[0]+_textureWeightList[1]+_textureWeightList[2]);
|
||||
float a = _textureWeightList[0]/(_textureWeightList[0]+_textureWeightList[1]);
|
||||
|
||||
@@ -2833,19 +2833,40 @@ void DataSet::DestinationTile::readFrom(CompositeSource* sourceGraph)
|
||||
{
|
||||
|
||||
Source* source = itr->get();
|
||||
if (source && _level>=source->getMinLevel() && _level<=source->getMaxLevel())
|
||||
if (source &&
|
||||
_level>=source->getMinLevel() && _level<=source->getMaxLevel() &&
|
||||
(*itr)->getSourceData())
|
||||
{
|
||||
unsigned int layerNum = source->getLayer();
|
||||
my_notify(osg::INFO)<<"DataSet::DestinationTile::readFrom -> SourceData::read() "<<std::endl;
|
||||
my_notify(osg::INFO)<<" destination._level="<<_level<<"\t"<<source->getMinLevel()<<"\t"<<source->getMaxLevel()<<std::endl;
|
||||
|
||||
SourceData* data = (*itr)->getSourceData();
|
||||
if (data)
|
||||
if (source->getType()==DataSet::Source::IMAGE)
|
||||
{
|
||||
my_notify(osg::INFO)<<"DataSet::DestinationTile::readFrom -> SourceData::read() "<<std::endl;
|
||||
my_notify(osg::INFO)<<" destination._level="<<_level<<"\t"<<source->getMinLevel()<<"\t"<<source->getMaxLevel()<<std::endl;
|
||||
if (layerNum<_imagery.size() &&
|
||||
_imagery[layerNum]._imagery.valid())
|
||||
unsigned int layerNum = source->getLayer();
|
||||
|
||||
if (layerNum==0)
|
||||
{
|
||||
data->read(*(_imagery[layerNum]._imagery));
|
||||
// copy the base layer 0 into layer 0 and all subsequent layers to provide a backdrop.
|
||||
for(unsigned int i=0;i<_imagery.size();++i)
|
||||
{
|
||||
if (_imagery[i]._imagery.valid())
|
||||
{
|
||||
data->read(*(_imagery[i]._imagery));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy specific layer.
|
||||
if (layerNum<_imagery.size() && _imagery[layerNum]._imagery.valid())
|
||||
{
|
||||
data->read(*(_imagery[layerNum]._imagery));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_terrain.valid()) data->read(*_terrain);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user