Added s/getLightingMode and s/getLight to osg::View to allow control of the viewers

global light source.
This commit is contained in:
Robert Osfield
2007-05-07 22:07:23 +00:00
parent 6716f0d845
commit 963cd837e3
8 changed files with 123 additions and 6 deletions

View File

@@ -20,6 +20,8 @@ View::View()
{
// osg::notify(osg::NOTICE)<<"Constructing osg::View"<<std::endl;
setLightingMode(HEADLIGHT);
setCamera(new osg::Camera);
_camera->setProjectionMatrixAsFrustum(-0.325, 0.325, -0.26, 0.26, 1.0f,10000.0f);
@@ -31,6 +33,8 @@ View::View()
View::View(const osg::View& view, const osg::CopyOp& copyop):
Object(view,copyop),
_lightingMode(view._lightingMode),
_light(view._light),
_camera(view._camera),
_slaves(view._slaves)
{
@@ -60,6 +64,19 @@ View::~View()
osg::notify(osg::INFO)<<"Done destructing osg::View"<<std::endl;
}
void View::setLightingMode(LightingMode lightingMode)
{
_lightingMode = lightingMode;
if (_lightingMode != NO_LIGHT && !_light)
{
_light = new osg::Light;
_light->setLightNum(0);
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
_light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f));
_light->setSpecular(Vec4(1.0f,1.0f,1.0f,1.0f));
}
}
void View::setCamera(osg::Camera* camera)
{