Added s/getLightingMode and s/getLight to osg::View to allow control of the viewers
global light source.
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -496,6 +496,24 @@ osg::Matrixd SceneView::computeRightEyeViewImplementation(const osg::Matrixd& vi
|
||||
-es,0.0,0.0,1.0);
|
||||
}
|
||||
|
||||
void SceneView::inheritCullSettings(const osg::CullSettings& settings, unsigned int inheritanceMask)
|
||||
{
|
||||
if (_camera.valid() && _camera->getView())
|
||||
{
|
||||
switch(_camera->getView()->getLightingMode())
|
||||
{
|
||||
case(osg::View::NO_LIGHT): setLightingMode(NO_SCENEVIEW_LIGHT); break;
|
||||
case(osg::View::HEADLIGHT): setLightingMode(HEADLIGHT); break;
|
||||
case(osg::View::SKY_LIGHT): setLightingMode(SKY_LIGHT); break;
|
||||
}
|
||||
|
||||
setLight(_camera->getView()->getLight());
|
||||
}
|
||||
|
||||
osg::CullSettings::inheritCullSettings(settings, inheritanceMask);
|
||||
}
|
||||
|
||||
|
||||
void SceneView::cull()
|
||||
{
|
||||
_dynamicObjectCount = 0;
|
||||
|
||||
@@ -99,12 +99,12 @@ BEGIN_VALUE_REFLECTOR(osg::CullSettings)
|
||||
"Set the local cull settings values from specified CullSettings object. ",
|
||||
"");
|
||||
I_Method1(void, inheritCullSettings, IN, const osg::CullSettings &, settings,
|
||||
Properties::NON_VIRTUAL,
|
||||
Properties::VIRTUAL,
|
||||
__void__inheritCullSettings__C5_CullSettings_R1,
|
||||
"Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask. ",
|
||||
"");
|
||||
I_Method2(void, inheritCullSettings, IN, const osg::CullSettings &, settings, IN, unsigned int, inheritanceMask,
|
||||
Properties::NON_VIRTUAL,
|
||||
Properties::VIRTUAL,
|
||||
__void__inheritCullSettings__C5_CullSettings_R1__unsigned_int,
|
||||
"Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask. ",
|
||||
"");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <osg/Camera>
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/Light>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Matrixd>
|
||||
#include <osg/Object>
|
||||
@@ -26,6 +27,12 @@
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
BEGIN_ENUM_REFLECTOR(osg::View::LightingMode)
|
||||
I_EnumLabel(osg::View::NO_LIGHT);
|
||||
I_EnumLabel(osg::View::HEADLIGHT);
|
||||
I_EnumLabel(osg::View::SKY_LIGHT);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osg::View)
|
||||
I_BaseType(osg::Object);
|
||||
I_Constructor0(____View,
|
||||
@@ -75,6 +82,31 @@ BEGIN_OBJECT_REFLECTOR(osg::View)
|
||||
__C5_osg_Stats_P1__getStats,
|
||||
"Get the const Stats object. ",
|
||||
"");
|
||||
I_Method1(void, setLightingMode, IN, osg::View::LightingMode, lightingMode,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__setLightingMode__LightingMode,
|
||||
"Set the global lighting to use for this view. ",
|
||||
"Defaults to headlight. ");
|
||||
I_Method0(osg::View::LightingMode, getLightingMode,
|
||||
Properties::NON_VIRTUAL,
|
||||
__LightingMode__getLightingMode,
|
||||
"Get the global lighting used for this view. ",
|
||||
"");
|
||||
I_Method1(void, setLight, IN, osg::Light *, light,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__setLight__osg_Light_P1,
|
||||
"Get the global light. ",
|
||||
"");
|
||||
I_Method0(osg::Light *, getLight,
|
||||
Properties::NON_VIRTUAL,
|
||||
__osg_Light_P1__getLight,
|
||||
"Get the global lighting if assigned. ",
|
||||
"");
|
||||
I_Method0(const osg::Light *, getLight,
|
||||
Properties::NON_VIRTUAL,
|
||||
__C5_osg_Light_P1__getLight,
|
||||
"Get the const global lighting if assigned. ",
|
||||
"");
|
||||
I_Method1(void, setCamera, IN, osg::Camera *, camera,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__setCamera__osg_Camera_P1,
|
||||
@@ -138,6 +170,12 @@ BEGIN_OBJECT_REFLECTOR(osg::View)
|
||||
I_SimpleProperty(osg::Camera *, Camera,
|
||||
__osg_Camera_P1__getCamera,
|
||||
__void__setCamera__osg_Camera_P1);
|
||||
I_SimpleProperty(osg::Light *, Light,
|
||||
__osg_Light_P1__getLight,
|
||||
__void__setLight__osg_Light_P1);
|
||||
I_SimpleProperty(osg::View::LightingMode, LightingMode,
|
||||
__LightingMode__getLightingMode,
|
||||
__void__setLightingMode__LightingMode);
|
||||
I_ArrayProperty(osg::View::Slave &, Slave,
|
||||
__Slave_R1__getSlave__unsigned_int,
|
||||
0,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <osg/Camera>
|
||||
#include <osg/CollectOccludersVisitor>
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/CullSettings>
|
||||
#include <osg/DisplaySettings>
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/Light>
|
||||
@@ -696,6 +697,16 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::SceneView)
|
||||
__osg_Matrixd__computeRightEyeViewImplementation__C5_osg_Matrixd_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, inheritCullSettings, IN, const osg::CullSettings &, settings,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__inheritCullSettings__C5_CullSettings_R1,
|
||||
"Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask. ",
|
||||
"");
|
||||
I_Method2(void, inheritCullSettings, IN, const osg::CullSettings &, settings, IN, unsigned int, inheritanceMask,
|
||||
Properties::VIRTUAL,
|
||||
__void__inheritCullSettings__C5_osg_CullSettings_R1__unsigned_int,
|
||||
"Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask. ",
|
||||
"");
|
||||
I_Method0(void, init,
|
||||
Properties::VIRTUAL,
|
||||
__void__init,
|
||||
|
||||
Reference in New Issue
Block a user