Does your terrain does have Normals ? Also you have a scale on your terrain (and a non-uniform scale at that) so you WILL have to re-normalize your normals See http://www.vis-sim.com/osg/osg_faq_1.htm#f19
_____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ümit Uzun Sent: Saturday, July 19, 2008 6:11 AM To: OpenSceneGraph Users Subject: Re: [osg-users] osg::Light Simple Question ? Thanks for reply, I have converted terrain model to osg and opened it with text editor. osg file format like below; ---------------------------------------------------------------------------- -------------------------- Group { name "db" nodeMask 0xffffffff cullingActive TRUE num_children 1 Geode { DataVariance STATIC name "p1_437" nodeMask 0xffffffff cullingActive TRUE StateSet { UniqueID StateSet_0 DataVariance STATIC rendering_hint DEFAULT_BIN renderBinMode INHERIT GL_CULL_FACE ON GL_LIGHTING OFF Material { ColorMode OFF ambientColor 0.722 0.722 0.729 1 diffuseColor 0.918 0.918 0.918 1 specularColor 0.137 0.137 0.137 1 emissionColor 0 0 0 1 shininess 10 } CullFace { UniqueID CullFace_1 mode BACK } textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file "Cell 23.rgb" wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE } TexEnv { mode MODULATE } } } num_drawables 1 Geometry { DataVariance STATIC useDisplayList TRUE useVertexBufferObjects FALSE PrimitiveSets 1 { DrawArrays QUADS 0 1600 } ...... ..... ...... etc. ---------------------------------------------------------------------------- -------------------------- The TexEnv configuration have MODULATE mode. And I have changed it to GL_MODULATE and GL_LIGHTING OFF to ON but there is no light effect on terrain too. Then I deleted the TexEnv code block from the osg file format then lighting not effect too. Peter, I added "lightSS->setMode(GL_LIGHTING,osg::StateAttribute::ON);" pattern to my code but there is no change on the state of terrain too. Jean, if I write a node visitor for TexEnv, I thing there won't be any change too, because of I have removed the TexEnv pattern from osg file format but there wasn't any change on terrain. Any idea for lightiing the terrain like other components. Thanks for all advices. Best Regards. Ümit UZUN 2008/7/19 Peter Wraae Marino <[EMAIL PROTECTED]>: Hi, isnt there missing a setMode( GL_LIGHT1, osg::StateAttribute::ON ); for your terrain group? (or did I miss something?) Peter http://osghelp.com <http://osghelp.com/> On Sat, Jul 19, 2008 at 12:39 AM, Ümit Uzun <[EMAIL PROTECTED]> wrote: Hi All, I have an simple question about light the terrain model problem. I have added two sphere(osg::Sphere) and one terrain(JoeDirt.flt) to the scene. I am trying to effect the components of scene with green light. Although green light could effected two of sphere, couldn't get success on the terrain model. What can I do to effect the terrain with green light? I have tried this code block; ---------------------------------------------------------------------------- ---------------------------------------------------------------------- int main() { osgViewer::Viewer viewer; osg::ref_ptr<osg::Group> root (new osg::Group); osg::ref_ptr<osg::MatrixTransform> terrainScaleMAT (new osg::MatrixTransform); osg::Matrix terrainScaleMatrix; terrainScaleMatrix.makeScale(0.05f,0.05f,0.03f); //Lighting code osg::ref_ptr<osg::Group> lightGroup (new osg::Group); osg::ref_ptr<osg::StateSet> lightSS (root->getOrCreateStateSet()); osg::ref_ptr<osg::LightSource> lightSource1 = new osg::LightSource; // create a local light. osg::Vec4f lightPosition (osg::Vec4f(0.0,0.0,3.0,1.0f)); osg::ref_ptr<osg::Light> myLight = new osg::Light; myLight->setLightNum(1); myLight->setPosition(lightPosition); myLight->setAmbient(osg::Vec4(0.2f,0.2f,0.2f,1.0f)); myLight->setDiffuse(osg::Vec4(0.1f,0.4f,0.1f,1.0f)); myLight->setConstantAttenuation(1.0f); lightSource1->setLight(myLight.get()); lightSource1->setLocalStateSetModes(osg::StateAttribute::ON); lightSource1->setStateSetModes(*lightSS,osg::StateAttribute::ON); lightGroup->addChild(lightSource1.get()); //Light markers: small spheres osg::ref_ptr<osg::Geode> lightMarkerGeode (new osg::Geode); lightMarkerGeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3f(-5.0f,-2.0f,3.0f),0.5f))); //lightMarkerGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAtt ribute::OFF); //Second light marker lightMarkerGeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3f(2.0f,-1.0f,3.0f),0.5f))); //Loading the terrain node osg::ref_ptr<osg::Node> terrainnode (osgDB::readNodeFile("JoeDirt.flt")); terrainScaleMAT->addChild(terrainnode.get()); terrainScaleMAT->setMatrix(terrainScaleMatrix); //adding the terrain node to the root node root->addChild(terrainScaleMAT.get()); //lighting code root->addChild(lightGroup.get()); //Adding the light marker geode root->addChild(lightMarkerGeode.get()); // add the state manipulator viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); viewer.setSceneData( root.get() ); return (viewer.run()); } ---------------------------------------------------------------------------- ---------------------------------------------------------------------- _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Regards, Peter Wraae Marino www.osghelp.com - OpenSceneGraph support site _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org