diff --git a/src/osgPlugins/fbx/ReaderWriterFBX.cpp b/src/osgPlugins/fbx/ReaderWriterFBX.cpp index 2d2b7c727..4adb2619e 100644 --- a/src/osgPlugins/fbx/ReaderWriterFBX.cpp +++ b/src/osgPlugins/fbx/ReaderWriterFBX.cpp @@ -344,6 +344,9 @@ ReaderWriterFBX::readNode(const std::string& filenameInit, resolveBindMatrices(*res.getNode(), reader.boneBindMatrices, reader.nodeMap); osg::Node* osgNode = res.getNode(); + for (int light = 0; light < nLightCount; ++light) + osgNode->getOrCreateStateSet()->setMode(GL_LIGHT0 + light, osg::StateAttribute::ON); + osgNode->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL,osg::StateAttribute::ON); osgNode->getOrCreateStateSet()->setMode(GL_NORMALIZE,osg::StateAttribute::ON); diff --git a/src/osgPlugins/fbx/fbxRLight.cpp b/src/osgPlugins/fbx/fbxRLight.cpp index 594e3e31f..8acbf8f8c 100644 --- a/src/osgPlugins/fbx/fbxRLight.cpp +++ b/src/osgPlugins/fbx/fbxRLight.cpp @@ -22,8 +22,8 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int& osg::Light* osgLight = new osg::Light; osg::LightSource* osgLightSource = new osg::LightSource; - osgLightSource->setLight(osgLight); osgLight->setLightNum(nLightCount++); + osgLightSource->setLight(osgLight); KFbxLight::ELightType fbxLightType = fbxLight->LightType.IsValid() ? fbxLight->LightType.Get() : KFbxLight::ePOINT; @@ -39,11 +39,11 @@ osgDB::ReaderWriter::ReadResult OsgFbxReader::readFbxLight(KFbxNode* pNode, int& osgLight->setSpotCutoff(static_cast(coneAngle)); //Approximate the hotspot using the GL light exponent. - //This formula maps a hotspot of 180° to exponent 0 (uniform light - // distribution) and a hotspot of 45° to exponent 1 (effective light + //This formula maps a hotspot of 180 to exponent 0 (uniform light + // distribution) and a hotspot of 45 to exponent 1 (effective light // intensity is attenuated by the cosine of the angle between the // direction of the light and the direction from the light to the vertex - // being lighted). A hotspot close to 0° maps to exponent 128 (maximum). + // being lighted). A hotspot close to 0 maps to exponent 128 (maximum). float exponent = (180.0f / (std::max)(static_cast(hotSpot), MIN_HOTSPOT) - 1.0f) / 3.0f; osgLight->setSpotExponent(exponent);