if (mat)
eg->setEffect(mat->get_effect());
eg->addDrawable(geometry);
+ eg->runGenerators(geometry); // Generate extra data needed by effect
if (group)
group->addChild(eg);
}
if (!mat)
continue;
- float coverage = mat->get_tree_coverage();
- if (coverage <= 0)
+ float wood_coverage = mat->get_wood_coverage();
+ if (wood_coverage <= 0)
continue;
// Attributes that don't vary by tree
randomForest.texture_varieties = mat->get_tree_varieties();
std::vector<SGVec3f> randomPoints;
- i->second.addRandomSurfacePoints(coverage, 0, randomPoints);
+ i->second.addRandomTreePoints(wood_coverage,
+ mat->get_tree_density(),
+ mat->get_wood_size(),
+ randomPoints);
+
std::vector<SGVec3f>::iterator j;
for (j = randomPoints.begin(); j != randomPoints.end(); ++j) {
-
- // Apply a random scaling factor and texture index.
- float scale = (mt_rand(&seed) + mt_rand(&seed)) / 2.0f + 0.5f;
- int v = (int) (mt_rand(&seed) * mat->get_tree_varieties());
- if (v == mat->get_tree_varieties()) v--;
- randomForest.insert(*j, v, scale);
+ randomForest.insert(*j);
}
}
}
i < tileGeometryBin.randomModels.getNumModels(); i++) {
SGMatModelBin::MatModel obj
= tileGeometryBin.randomModels.getMatModel(i);
- osg::Node* node = sgGetRandomModel(obj.model);
+ osg::Node* node = sgGetRandomModel(obj.model, seed);
// Create a matrix to place the object in the correct
// location, and then apply the rotation matrix created
// above, with an additional random heading rotation if appropriate.
osg::Matrix transformMat;
- transformMat = osg::Matrix::translate(obj.position.osg());
+ transformMat = osg::Matrix::translate(toOsg(obj.position));
if (obj.model->get_heading_type() == SGMatModel::HEADING_RANDOM) {
// Rotate the object around the z axis.
double hdg = mt_rand(&seed) * M_PI * 2;
}
if (!tileGeometryBin.vasiLights.empty()) {
- osg::Geode* vasiGeode = new osg::Geode;
+ EffectGeode* vasiGeode = new EffectGeode;
+ Effect* vasiEffect
+ = getLightEffect(6, osg::Vec3(1, 0.0001, 0.000001), 1, 6, true);
+ vasiGeode->setEffect(vasiEffect);
SGVec4f red(1, 0, 0, 1);
SGMaterial* mat = 0;
if (matlib)
mat = matlib->find("RWY_WHITE_LIGHTS");
if (mat)
white = mat->get_light_color();
-
SGDirectionalLightListBin::const_iterator i;
for (i = tileGeometryBin.vasiLights.begin();
i != tileGeometryBin.vasiLights.end(); ++i) {
vasiGeode->addDrawable(SGLightFactory::getVasi(up, *i, red, white));
}
- vasiGeode->setCullCallback(new SGPointSpriteLightCullCallback(osg::Vec3(1, 0.0001, 0.000001), 6));
vasiGeode->setStateSet(lightManager->getRunwayLightStateSet());
lightGroup->addChild(vasiGeode);
}
-
+ Effect* runwayEffect = 0;
+ if (tileGeometryBin.runwayLights.getNumLights() > 0
+ || !tileGeometryBin.rabitLights.empty()
+ || !tileGeometryBin.reilLights.empty()
+ || !tileGeometryBin.odalLights.empty()
+ || tileGeometryBin.taxiLights.getNumLights() > 0)
+ runwayEffect = getLightEffect(4, osg::Vec3(1, 0.001, 0.0002), 1, 4, true);
if (tileGeometryBin.runwayLights.getNumLights() > 0
|| !tileGeometryBin.rabitLights.empty()
|| !tileGeometryBin.reilLights.empty()
|| !tileGeometryBin.odalLights.empty()) {
osg::Group* rwyLights = new osg::Group;
- rwyLights->setCullCallback(new SGPointSpriteLightCullCallback);
rwyLights->setStateSet(lightManager->getRunwayLightStateSet());
rwyLights->setNodeMask(RUNWAYLIGHTS_BIT);
if (tileGeometryBin.runwayLights.getNumLights() != 0) {
- osg::Geode* geode = new osg::Geode;
+ EffectGeode* geode = new EffectGeode;
+ geode->setEffect(runwayEffect);
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin
.runwayLights));
rwyLights->addChild(geode);
if (tileGeometryBin.taxiLights.getNumLights() > 0) {
osg::Group* taxiLights = new osg::Group;
- taxiLights->setCullCallback(new SGPointSpriteLightCullCallback);
taxiLights->setStateSet(lightManager->getTaxiLightStateSet());
taxiLights->setNodeMask(RUNWAYLIGHTS_BIT);
- osg::Geode* geode = new osg::Geode;
+ EffectGeode* geode = new EffectGeode;
+ geode->setEffect(runwayEffect);
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.taxiLights));
taxiLights->addChild(geode);
lightGroup->addChild(taxiLights);
// The toplevel transform for that tile.
osg::MatrixTransform* transform = new osg::MatrixTransform;
transform->setName(path);
- transform->setMatrix(osg::Matrix::rotate(hlOr.osg())*
- osg::Matrix::translate(center.osg()));
+ transform->setMatrix(osg::Matrix::rotate(toOsg(hlOr))*
+ osg::Matrix::translate(toOsg(center)));
transform->addChild(terrainGroup);
if (lightGroup->getNumChildren() > 0) {
osg::LOD* lightLOD = new osg::LOD;