Fixed the osg::Light so that it requires the user to explicitly define which
OpenGL light is being operated on, and also now relies upong the standard osg::State handling of OpenGL modes to switch on the appropriate lights. The previous static counter mechansim for the light number was causing a redundent light to be created when the osg plugin created the first osg::Light to use a prototype for other osg::Light's to be cloned from in the .osg plugin execution. The static count mechanism also prevent the lights modes being controlled independantly from the setting of the light paramters themselves. This meant that a light once created was global, and couldn't be turned off locally via the OSG's support for OpenGL mode enabling/disabling. This has been overcome with the new implementation, the user has complete flexiblity of when and where to use the different lights at their disposal.
This commit is contained in:
@@ -32,6 +32,16 @@ bool Light_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
Light& light = static_cast<Light&>(obj);
|
||||
|
||||
if (fr[0].matchWord("light_num"))
|
||||
{
|
||||
int lightnum=0;
|
||||
if (fr[1].getInt(lightnum))
|
||||
{
|
||||
light.setLightNum(lightnum);
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
#define ReadVec4(A,B) { \
|
||||
if (fr[0].matchWord(B) && \
|
||||
@@ -96,6 +106,8 @@ bool Light_writeLocalData(const Object& obj,Output& fw)
|
||||
{
|
||||
const Light& light = static_cast<const Light&>(obj);
|
||||
|
||||
fw.indent() << "light_num " << light.getLightNum() << std::endl;
|
||||
|
||||
// Vec4's
|
||||
fw.indent() << "ambient " << light.getAmbient() << std::endl;
|
||||
fw.indent() << "diffuse " << light.getDiffuse() << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user