- // FIXME: this stuff can be handled
- // in the XML wrapper as well (at least,
- // the billboarding should be handled
- // there).
- float ranges[] = {0, _range_m};
- ssgRangeSelector * lod = new ssgRangeSelector;
- lod->ref();
- lod->setRanges(ranges, 2);
- if (_heading_type == HEADING_BILLBOARD) {
- ssgCutout * cutout = new ssgCutout(false);
- cutout->addKid(entity);
- lod->addKid(cutout);
- } else {
- lod->addKid(entity);
- }
- _models.push_back(lod);
+ // FIXME: this stuff can be handled
+ // in the XML wrapper as well (at least,
+ // the billboarding should be handled
+ // there).
+
+ if (_heading_type == HEADING_BILLBOARD) {
+ // if the model is a billboard, it is likely :
+ // 1. a branch with only leaves,
+ // 2. a tree or a non rectangular shape faked by transparency
+ // We add alpha clamp then
+ osg::StateSet* stateSet = entity->getOrCreateStateSet();
+ osg::AlphaFunc* alphaFunc =
+ new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.01f);
+ stateSet->setAttributeAndModes(alphaFunc,
+ osg::StateAttribute::OVERRIDE);
+ stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
+ }
+
+ _models.push_back(entity);
+