Hi, isnt there missing a *setMode*( GL_LIGHT1, osg::StateAttribute::ON );
for your terrain group? (or did I miss something?) Peter 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::StateAttribute::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