Thanks Vincent for your answer.
I tried to follow your suggestion, but the problem persists. If you look at the code, I have : |_root ---|_modelGraph ---|transform ---------|lightsource ---------|geode Any suggestions ? What are my mistakes? My goal is to have a model moving with the camera and a light represented by a sphere that does not move (fixed coord). Just one precision: when I place the light in the scene, the light coordinates depends of the model: ((0,0,0) puts the light inside the model) Could this explain the problem? How can I prevent this? Thanks again. { //_modelGraph group represents the current scene //_root group will contains _modelGraph plus the light //create the light osg::ref_ptr<osg::Light> light = new osg::Light; //make the light a point light by setting w to 1.0 light->setPosition(osg::Vec4(-10.0f, -10.0f, 0.0f, 10.0f)); //create a lightsource for the light osg::ref_ptr<osg::LightSource> lightSource = new osg::LightSource; //create a transformation node that will move the node in the scene osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform; transform->addChild(lightSource.get()); //Position the light osg::Vec3 pos(-5.0f, 10.0f, 0.0f); transform->setMatrix(osg::Matrix::translate(pos)); //create a small sphere to represent the lights position osg::ref_ptr<osg::Geode> geode = new osg::Geode; osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints; hints->setDetailRatio(0.3); osg::ref_ptr<osg::ShapeDrawable> shape = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 0.6f), hints.get()); shape->setColor(lightColor); geode->addDrawable(shape.get()); transform->addChild(geode.get()); _root->addChild(transform.get()); //add the model to the light's root group _root->addChild(_modelGraph.get()); }
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org