Changeset 890
- Timestamp:
- 03/11/08 13:48:27
- Files:
-
- trunk/include/vpb/BuildOptions (modified) (2 diffs)
- trunk/src/vpb/BuildOptions.cpp (modified) (2 diffs)
- trunk/src/vpb/BuildOptionsIO.cpp (modified) (1 diff)
- trunk/src/vpb/Destination.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/vpb/BuildOptions
r859 r890 250 250 void setBuildOptionsString(const std::string& str) { _buildOptionsString = str; } 251 251 const std::string& getBuildOptionsString() const { return _buildOptionsString; } 252 253 enum LayerInheritance 254 { 255 INHERIT_LOWEST_AVAILABLE, 256 INHERIT_NEAREST_AVAILABLE, 257 NO_INHERITANCE 258 }; 259 260 void setLayerInheritance(LayerInheritance inheritance) { _layerInheritance = inheritance; } 261 LayerInheritance getLayerInheritance() const { return _layerInheritance; } 262 252 263 253 264 protected: … … 310 321 311 322 std::string _buildOptionsString; 323 324 LayerInheritance _layerInheritance; 312 325 }; 313 326 trunk/src/vpb/BuildOptions.cpp
r874 r890 72 72 _numReadThreadsToCoresRatio = 0.0f; 73 73 _numWriteThreadsToCoresRatio = 0.0f; 74 75 _layerInheritance = INHERIT_NEAREST_AVAILABLE; 74 76 } 75 77 … … 144 146 145 147 _buildOptionsString = rhs._buildOptionsString; 148 149 _layerInheritance = rhs._layerInheritance; 146 150 } 147 151 trunk/src/vpb/BuildOptionsIO.cpp
r859 r890 218 218 219 219 ADD_STRING_PROPERTY(BuildOptionsString); 220 221 { AEP(LayerInheritance); AEV(INHERIT_LOWEST_AVAILABLE); AEV(INHERIT_NEAREST_AVAILABLE); AEV(NO_INHERITANCE); } 222 220 223 } 221 224 trunk/src/vpb/Destination.cpp
r888 r890 1054 1054 _stateset = new osg::StateSet; 1055 1055 1056 bool updateBaseTextureToCurrentValidImage = true;1057 osg::Texture* baseTexture = 0;1058 1056 for(layerNum=0; 1059 1057 layerNum<_imagery.size(); … … 1078 1076 1079 1077 osg::Texture2D* texture = new osg::Texture2D; 1080 1081 if (updateBaseTextureToCurrentValidImage || baseTexture==0) baseTexture=texture;1082 1078 1083 1079 texture->setImage(image); … … 1179 1175 } 1180 1176 1181 // now fill in any blank texture units. 1182 bool fillInAllTextureUnits = true; 1183 if (fillInAllTextureUnits) 1184 { 1185 for(layerNum=0; 1186 layerNum<_dataSet->getNumOfTextureLevels(); 1187 ++layerNum) 1188 { 1189 bool applyBaseTexture = false; 1190 if (layerNum>=_imagery.size()) applyBaseTexture=true; 1191 else 1192 { 1193 ImageData& imageData = _imagery[layerNum]; 1194 if (!imageData._imagery.valid() || !imageData._imagery->_image.valid()) 1177 switch(_dataSet->getLayerInheritance()) 1178 { 1179 case(BuildOptions::INHERIT_LOWEST_AVAILABLE): 1180 { 1181 osg::StateAttribute* texture = 0; 1182 // first look for an available texture 1183 for(layerNum=0; 1184 layerNum<_dataSet->getNumOfTextureLevels() && texture==0; 1185 ++layerNum) 1186 { 1187 texture = _stateset->getTextureAttribute(layerNum,osg::StateAttribute::TEXTURE); 1188 } 1189 1190 if (texture) 1191 { 1192 // now fill in any blanks 1193 for(layerNum=0; 1194 layerNum<_dataSet->getNumOfTextureLevels(); 1195 ++layerNum) 1195 1196 { 1196 applyBaseTexture=true; 1197 if (!_stateset->getTextureAttribute(layerNum,osg::StateAttribute::TEXTURE)) 1198 { 1199 _stateset->setTextureAttributeAndModes(layerNum,texture,osg::StateAttribute::ON); 1200 } 1197 1201 } 1198 1202 } 1199 if (applyBaseTexture) 1200 _stateset->setTextureAttributeAndModes(layerNum,baseTexture,osg::StateAttribute::ON); 1201 } 1202 } 1203 break; 1204 } 1205 case(BuildOptions::INHERIT_NEAREST_AVAILABLE): 1206 { 1207 osg::StateAttribute* texture = 0; 1208 unsigned int noBlanks = 0; 1209 for(int layerNum=0; 1210 layerNum<_dataSet->getNumOfTextureLevels(); 1211 ++layerNum) 1212 { 1213 osg::StateAttribute* localTexture = _stateset->getTextureAttribute(layerNum,osg::StateAttribute::TEXTURE); 1214 if (localTexture) texture = localTexture; 1215 else if (texture) _stateset->setTextureAttributeAndModes(layerNum,texture,osg::StateAttribute::ON); 1216 else ++noBlanks; 1217 } 1203 1218 1219 if (noBlanks>0 && noBlanks != _dataSet->getNumOfTextureLevels()) 1220 { 1221 // inherit downards to fill in any blanks 1222 for(int layerNum=_dataSet->getNumOfTextureLevels()-1; 1223 layerNum>=0; 1224 --layerNum) 1225 { 1226 osg::StateAttribute* localTexture = _stateset->getTextureAttribute(layerNum,osg::StateAttribute::TEXTURE); 1227 if (localTexture) texture = localTexture; 1228 else if (texture) _stateset->setTextureAttributeAndModes(layerNum,texture,osg::StateAttribute::ON); 1229 } 1230 } 1231 break; 1232 } 1233 case(BuildOptions::NO_INHERITANCE): 1234 { 1235 // do nothing.. 1236 break; 1237 } 1238 } 1204 1239 return _stateset.get(); 1205 1240 } … … 1430 1465 1431 1466 1432 osgTerrain::ImageLayer* baseLayer = 0;1433 bool updateLayerTextureToCurrentValidLayer = true;1434 1435 1467 // assign the imagery 1436 1468 for(unsigned int layerNum=0; … … 1448 1480 1449 1481 terrain->setColorLayer(layerNum, imageLayer); 1450 1451 if (updateLayerTextureToCurrentValidLayer || baseLayer==0) 1452 { 1453 baseLayer = imageLayer; 1454 } 1455 } 1456 } 1457 1458 // copy layer into any blanks 1459 if (baseLayer) 1460 { 1461 for(unsigned int layerNum=0; 1462 layerNum<_dataSet->getNumOfTextureLevels(); 1463 ++layerNum) 1464 { 1465 if (terrain->getColorLayer(layerNum)==0) 1466 { 1467 terrain->setColorLayer(layerNum, baseLayer); 1468 } 1469 } 1470 } 1482 } 1483 } 1484 1485 switch(_dataSet->getLayerInheritance()) 1486 { 1487 case(BuildOptions::INHERIT_LOWEST_AVAILABLE): 1488 { 1489 osgTerrain::Layer* layer = 0; 1490 // first look for an available Layer 1491 for(unsigned int layerNum=0; 1492 layerNum<_dataSet->getNumOfTextureLevels() && layer==0; 1493 ++layerNum) 1494 { 1495 layer = terrain->getColorLayer(layerNum); 1496 } 1497 1498 if (layer) 1499 { 1500 // now fill in any blanks 1501 for(unsigned int layerNum=0; 1502 layerNum<_dataSet->getNumOfTextureLevels(); 1503 ++layerNum) 1504 { 1505 if (!terrain->getColorLayer(layerNum)) 1506 { 1507 terrain->setColorLayer(layerNum,layer); 1508 } 1509 } 1510 } 1511 break; 1512 } 1513 case(BuildOptions::INHERIT_NEAREST_AVAILABLE): 1514 { 1515 osgTerrain::Layer* layer = 0; 1516 unsigned int noBlanks = 0; 1517 for(int layerNum=0; 1518 layerNum<_dataSet->getNumOfTextureLevels(); 1519 ++layerNum) 1520 { 1521 osgTerrain::Layer* localLayer = terrain->getColorLayer(layerNum); 1522 if (localLayer) layer = localLayer; 1523 else if (layer) terrain->setColorLayer(layerNum, layer); 1524 else ++noBlanks; 1525 } 1526 1527 if (noBlanks>0 && noBlanks != _dataSet->getNumOfTextureLevels()) 1528 { 1529 // inherit downards to fill in any blanks 1530 for(int layerNum=_dataSet->getNumOfTextureLevels()-1; 1531 layerNum>=0; 1532 --layerNum) 1533 { 1534 osgTerrain::Layer* localLayer = terrain->getColorLayer(layerNum); 1535 if (localLayer) layer = localLayer; 1536 else if (layer) terrain->setColorLayer(layerNum, layer); 1537 } 1538 } 1539 break; 1540 } 1541 case(BuildOptions::NO_INHERITANCE): 1542 { 1543 // do nothing.. 1544 break; 1545 } 1546 } 1547 1471 1548 1472 1549 // assign the terrain technique that will be used to render the terrain tile. … … 2162 2239 { 2163 2240 unsigned int layerNum = source->getLayer(); 2164 2165 if (layerNum==0) 2241 switch(_dataSet->getLayerInheritance()) 2166 2242 { 2167 // copy the base layer 0 into layer 0 and all subsequent layers to provide a backdrop. 2168 for(unsigned int i=0;i<_imagery.size();++i) 2243 case(BuildOptions::INHERIT_LOWEST_AVAILABLE): 2169 2244 { 2170 if ( _imagery[i]._imagery.valid())2245 if (layerNum==0) 2171 2246 { 2172 data->read(*(_imagery[i]._imagery)); 2247 // copy the base layer 0 into layer 0 and all subsequent layers to provide a backdrop. 2248 for(unsigned int i=0;i<_imagery.size();++i) 2249 { 2250 if (_imagery[i]._imagery.valid()) 2251 { 2252 data->read(*(_imagery[i]._imagery)); 2253 } 2254 } 2173 2255 } 2256 else 2257 { 2258 // copy specific layer. 2259 if (layerNum<_imagery.size() && _imagery[layerNum]._imagery.valid()) 2260 { 2261 data->read(*(_imagery[layerNum]._imagery)); 2262 } 2263 } 2264 break; 2174 2265 } 2175 } 2176 else 2177 { 2178 // copy specific layer. 2179 if (layerNum<_imagery.size() && _imagery[layerNum]._imagery.valid()) 2266 case(BuildOptions::INHERIT_NEAREST_AVAILABLE): 2180 2267 { 2181 data->read(*(_imagery[layerNum]._imagery)); 2268 // copy the current layer into this and all subsequent layers to provide a backdrop. 2269 for(unsigned int i=layerNum;i<_imagery.size();++i) 2270 { 2271 if (_imagery[i]._imagery.valid()) 2272 { 2273 data->read(*(_imagery[i]._imagery)); 2274 } 2275 } 2276 break; 2182 2277 } 2183 } 2278 case(BuildOptions::NO_INHERITANCE): 2279 { 2280 if (layerNum<_imagery.size() && _imagery[layerNum]._imagery.valid()) 2281 { 2282 data->read(*(_imagery[layerNum]._imagery)); 2283 } 2284 break; 2285 } 2286 } 2184 2287 break; 2185 2288 }
