Added s/getLightingMode and s/getLight to osg::View to allow control of the viewers
global light source.
This commit is contained in:
@@ -86,10 +86,10 @@ class OSG_EXPORT CullSettings
|
||||
void setCullSettings(const CullSettings& settings) { inheritCullSettings(settings, ALL_VARIABLES); }
|
||||
|
||||
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
|
||||
void inheritCullSettings(const CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }
|
||||
virtual void inheritCullSettings(const CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }
|
||||
|
||||
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
|
||||
void inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask);
|
||||
virtual void inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask);
|
||||
|
||||
/** read the environmental variables.*/
|
||||
void readEnvironmentalVariables();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define OSG_VIEW 1
|
||||
|
||||
#include <osg/Camera>
|
||||
#include <osg/Light>
|
||||
|
||||
#include <OpenThreads/Mutex>
|
||||
|
||||
@@ -43,6 +44,29 @@ class OSG_EXPORT View : public osg::Object
|
||||
/** Get the const Stats object.*/
|
||||
const osg::Stats* getStats() const { return _stats.get(); }
|
||||
|
||||
/** Options for controlling the global lighting used for the view.*/
|
||||
enum LightingMode
|
||||
{
|
||||
NO_LIGHT,
|
||||
HEADLIGHT,
|
||||
SKY_LIGHT
|
||||
};
|
||||
|
||||
/** Set the global lighting to use for this view.
|
||||
* Defaults to headlight. */
|
||||
void setLightingMode(LightingMode lightingMode);
|
||||
|
||||
/** Get the global lighting used for this view.*/
|
||||
LightingMode getLightingMode() const { return _lightingMode; }
|
||||
|
||||
/** Get the global light.*/
|
||||
void setLight(osg::Light* light) { _light = light; }
|
||||
|
||||
/** Get the global lighting if assigned.*/
|
||||
osg::Light* getLight() { return _light.get(); }
|
||||
|
||||
/** Get the const global lighting if assigned.*/
|
||||
const osg::Light* getLight() const { return _light.get(); }
|
||||
|
||||
/** Set the master camera of the view. */
|
||||
void setCamera(osg::Camera* camera);
|
||||
@@ -109,10 +133,13 @@ class OSG_EXPORT View : public osg::Object
|
||||
|
||||
osg::ref_ptr<osg::Stats> _stats;
|
||||
|
||||
LightingMode _lightingMode;
|
||||
osg::ref_ptr<osg::Light> _light;
|
||||
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
|
||||
typedef std::vector<Slave> Slaves;
|
||||
Slaves _slaves;
|
||||
typedef std::vector<Slave> Slaves;
|
||||
Slaves _slaves;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -422,6 +422,12 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
|
||||
virtual osg::Matrixd computeRightEyeProjectionImplementation(const osg::Matrixd& projection) const;
|
||||
virtual osg::Matrixd computeRightEyeViewImplementation(const osg::Matrixd& view) const;
|
||||
|
||||
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
|
||||
void inheritCullSettings(const CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }
|
||||
|
||||
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
|
||||
virtual void inheritCullSettings(const osg::CullSettings& settings, unsigned int inheritanceMask);
|
||||
|
||||
|
||||
/** Do init traversal of attached scene graph using Init NodeVisitor.
|
||||
* The init traversal is called once for each SceneView, and should
|
||||
|
||||
@@ -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