if (building_texture.empty()) {
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \"" << bt);
+ }
+
+ bt = props->getStringValue("building-lightmap", "Textures/buildings-lightmap.png");
+ building_lightmap = SGModelLib::findDataFile(bt, options);
+
+ if (building_lightmap.empty()) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Cannot find texture \"" << bt);
}
-
+
building_small_ratio = props->getDoubleValue("building-small-ratio", 0.8);
building_medium_ratio = props->getDoubleValue("building-medium-ratio", 0.15);
building_large_ratio = props->getDoubleValue("building-large-ratio", 0.05);
* @return The texture for auto-generated buildings.
*/
inline std::string get_building_texture () const { return building_texture; }
+
+ /**
+ * Get the building lightmap.
+ *
+ * This is the lightmap used for auto-generated buildings.
+ *
+ * @return The lightmap for auto-generated buildings.
+ */
+ inline std::string get_building_lightmap () const { return building_lightmap; }
// Ratio of the 3 random building sizes
inline double get_building_small_fraction () const { return building_small_ratio / (building_small_ratio + building_medium_ratio + building_large_ratio); }
// building spacing
double building_spacing;
- // building texture
+ // building texture & lightmap
std::string building_texture;
+ std::string building_lightmap;
// Ratio of the 3 random building sizes
double building_small_ratio;
SGPropertyNode_ptr effectProp = new SGPropertyNode;
makeChild(effectProp, "inherits-from")->setStringValue("Effects/building");
SGPropertyNode* params = makeChild(effectProp, "parameters");
- // emphasize n = 0
+ // Main texture - n=0
params->getChild("texture", 0, true)->getChild("image", 0, true)
->setStringValue(bin->texture);
+
+ // Light map - n=1
+ params->getChild("texture", 1, true)->getChild("image", 0, true)
+ ->setStringValue(bin->lightMap);
+
effect = makeEffect(effectProp, true, options);
if (iter == buildingEffectMap.end())
buildingEffectMap.insert(EffectMap::value_type(bin->texture, effect));
ref_ptr<Group> group = quadbuilding.getRoot();
- /*
- // Set up the stateset for this building bin and the texture to use.
- osg::StateSet* stateSet = group->getOrCreateStateSet();
- const std::string texturename = bin->texture;
- osg::Texture2D* texture = SGLoadTexture2D(texturename);
- texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP_TO_EDGE);
- texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP_TO_EDGE);
- stateSet->setTextureAttributeAndModes(0, texture);
-
- osg::ShadeModel* shadeModel = new osg::ShadeModel;
- shadeModel->setMode(osg::ShadeModel::FLAT);
- stateSet->setAttributeAndModes(shadeModel);
- stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
- stateSet->setMode(GL_FOG, osg::StateAttribute::ON);
- stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
- stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
- stateSet->setMode(GL_BLEND, osg::StateAttribute::OFF);
- stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
- stateSet->setAttribute(new osg::CullFace(osg::CullFace::BACK));
-
- osg::Material* material = new osg::Material;
- material->setAmbient(osg::Material::FRONT, osg::Vec4(0.3,0.3,0.3,1.0));
- material->setDiffuse(osg::Material::FRONT, osg::Vec4(1.0,1.0,1.0,1.0));
- material->setSpecular(osg::Material::FRONT, osg::Vec4(0,0,0,1.0));
- material->setShininess(osg::Material::FRONT, 0.0);
- material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
- stateSet->setAttribute(material);
- */
mt->addChild(group);
}