Added support for placing a base in the scene to shadow against

This commit is contained in:
Robert Osfield
2006-12-01 15:19:21 +00:00
parent 8d85636b50
commit 6778bfca44

View File

@@ -149,6 +149,9 @@ int main(int argc, char** argv)
bool updateLightPosition = true;
while (arguments.read("--noUpdate")) updateLightPosition = false;
bool createBase = false;
while (arguments.read("--base")) createBase = true;
bool doShadow = true;
while (arguments.read("--noShadow")) doShadow = false;
@@ -174,6 +177,29 @@ int main(int argc, char** argv)
ComputeBoundingBoxVisitor cbbv;
model->accept(cbbv);
osg::BoundingBox bb = cbbv.getBoundingBox();
if (createBase)
{
osg::ref_ptr<osg::Group> newGroup = new osg::Group;
newGroup->addChild(model.get());
osg::Geode* geode = new osg::Geode;
osg::Vec3 widthVec(bb.radius(), 0.0f, 0.0f);
osg::Vec3 depthVec(0.0f, bb.radius(), 0.0f);
osg::Vec3 centerBase( (bb.xMin()+bb.xMax())*0.5f, (bb.yMin()+bb.yMax())*0.5f, bb.zMin()-bb.radius()*0.1f );
geode->addDrawable( createTexturedQuadGeometry( centerBase-widthVec*1.5f-depthVec*1.5f,
widthVec*3.0f, depthVec*3.0f) );
newGroup->addChild(geode);
model = newGroup.get();
}
// get the bounds of the model.
cbbv.reset();
model->accept(cbbv);
bb = cbbv.getBoundingBox();
osg::ref_ptr<osg::Group> group = new osg::Group;
@@ -205,6 +231,7 @@ int main(int argc, char** argv)
}
osg::ref_ptr<osg::Light> light = new osg::Light;
if (!doShadow)