Hello! Recently i tried to implement cockpit night lightning system in FG and came around a curious problem i can't solve: definition of new/additional light sources is ignored by FG. I went the classical OpenGL path and tried to incorporate additional "standard" light sources (OGL supports from 8 to 10 of them depending on the hardware). The code works so far, BUT only if the light source number is zero. Ergo none of the lights from 1 to 9 configured with the same code would work. Other light sources appear to be disabled somewhere in FG/SG, since OSG demonstrates in the example projects multiple light sources operated. Altering light 0 also affects the entire scene graph, but that's expected behavior as noted in OSG docs. Not even rough cut through with glEnable(...) helps.
Implementation details: Markup extension: <cockpit_light> <source>0</source> <name>cockpit_light</name> <colors> <ambient> <R>0.0</R><G>0.7</G><B>0.0</B><A>1.0</A> </ambient> <diffuse> <R>0.0</R><G>0.0</G><B>0.0</B><A>0.0</A> </diffuse> </colors> <direction> <X>0.3</X><Y>0.3</Y><Z>0.3</Z> </direction> <offsets> <x-m>-0.309142</x-m> <y-m>0.286432</y-m> <z-m>0.275279</z-m> <pitch-deg>0</pitch-deg> <heading-deg>180</heading-deg> <roll-deg>0</roll-deg> </offsets> <spot> <cutoff>0.002</cutoff> <exponent>0.002</exponent> </spot> <attenuation> <constant>5.0</constant> <linear>5.0</linear> <quadratic>10.0</quadratic> </attenuation> </cockpit_light> Method invocation in: static osg::Node * sgLoad3DModel_internal(const SGPath& path, const osgDB::ReaderWriter::Options* options_, SGPropertyNode *overlay) ... // process cockpit lights std::vector<SGPropertyNode_ptr> light_nodes; light_nodes = props->getChildren("cockpit_light"); for(unsigned i = 0; i < light_nodes.size(); i++) { group->addChild(Particles::appendLights(group, light_nodes[i], prop_root, options.get())); } ... Method implemented: osg::Group * Particles::appendLights(const osg::ref_ptr<osg::Group> parent, const SGPropertyNode* configNode, SGPropertyNode* modelRoot, const osgDB::ReaderWriter::Options* options) { int lightNum = configNode->getIntValue("source", 0); // create and configure light source osg::LightSource *interiorLightSource = new osg::LightSource(); interiorLightSource->setLocalStateSetModes(osg::StateAttribute::ON); interiorLightSource->getLight()->setDataVariance(Object::DYNAMIC); interiorLightSource->setLocalStateSetModes(osg::StateAttribute::ON); // acquire the light itself and do setup osg::Light *interiorLight = interiorLightSource->getLight(); interiorLight->setLightNum(lightNum); interiorLight->setPosition(osg::Vec4(configNode->getFloatValue("offsets/x-m", 0.0), configNode->getFloatValue("offsets/y-m", 0.0), configNode->getFloatValue("offsets/z-m", 0.0), 1.0f)); interiorLight->setAmbient(osg::Vec4(configNode->getFloatValue("colors/ambient/R", 0.0), configNode->getFloatValue("colors/ambient/G", 0.0), configNode->getFloatValue("colors/ambient/B", 0.0), configNode->getFloatValue("colors/ambient/A", 0.0))); interiorLight->setDiffuse(osg::Vec4(configNode->getFloatValue("colors/diffuse/R", 0.0), configNode->getFloatValue("colors/diffuse/G", 0.0), configNode->getFloatValue("colors/diffuse/B", 0.0), configNode->getFloatValue("colors/diffuse/A", 0.0))); interiorLight->setDirection(osg::Vec3(configNode->getFloatValue("direction/X", 0.0), configNode->getFloatValue("direction/Y", 0.0), configNode->getFloatValue("direction/Z", 0.0))); // exponent & cutoff interiorLight->setSpotCutoff(configNode->getFloatValue("spot/cutoff", 0.0)); interiorLight->setSpotExponent(configNode->getFloatValue("spot/exponent", 0.0)); // light attenuation interiorLight->setConstantAttenuation(configNode->getFloatValue("spot/attenuation", 0.0)); interiorLight->setLinearAttenuation(configNode->getFloatValue("spot/linear", 0.0)); interiorLight->setQuadraticAttenuation(configNode->getFloatValue("spot/quadratic", 0.0)); // state propagations osg::StateSet *parentState = parent->getOrCreateStateSet(); parentState->setMode(GL_LIGHTING, osg::StateAttribute::ON); parentState->setMode(GL_LIGHT0 + lightNum, osg::StateAttribute::ON); interiorLightSource->setStateSetModes(*parentState, osg::StateAttribute::ON); return interiorLightSource; } P.S. Best result sofar: http://www.flickr.com/photos/43342833@N04/6344963545/in/photostream ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel