[osg-users] Absolutely dark scene

Fernan osgforum at tevs.eu
Tue Mar 17 04:27:24 PDT 2009


Hi Robert,

thanks for reply.

I initialize my system as follows:

--------------

    // construct the viewer.
    osgViewer::Viewer viewer;
    viewer.setLightingMode (osg::View::HEADLIGHT);

    // Configura el visor para aparecer en una ventana
    viewer.setUpViewInWindow (100, 100, 800, 600, 0);

    // Pone el manejador de eventos de ratón (se hace por defecto dentro del run() del viewer, pero 
    // aquí es necesario crearlo antes para poder ponerle la posición por defecto de la cámara
    viewer.setCameraManipulator(new osgGA::TrackballManipulator());

    // Pone la posición por defecto de la cámara
    osgGA::MatrixManipulator* pCameraManip = viewer.getCameraManipulator();
    if (pCameraManip != NULL)
    {
      pCameraManip->setHomePosition (osg::Vec3 (0.0, -600.0, 8.0), osg::Vec3 (0.0, 0.0, 8.0), osg::Vec3 (0.0, 0.0, 1.0));
    }

    // create a model from the images.
    osg::Group* pRoot = new osg::Group();

    // Create a new light, and set the light number according to our parameter.
    osg::Light* pLight = new osg::Light();
    pLight->setLightNum (0);
    pLight->setAmbient (osg::Vec4d (0.0, 0.0, 0.0, 1.0));
    pLight->setDiffuse (osg::Vec4d (0.0, 0.0, 0.0, 1.0)); 
    pLight->setSpecular (osg::Vec4d (0.0, 0.0, 0.0, 1.0)); 
    osg::LightSource* pLightsource = new osg::LightSource();
    pLightsource->setLight (pLight);
    pLightsource->setStateSetModes (*pRoot->getOrCreateStateSet(), osg::StateAttribute::ON);
    pRoot->addChild (pLightsource);

----------------


With this, the scene get a little dark, but it is not totally black.
There is always a little light, so objects that I add to the scene can be seen.

These objects are ships and what I want is to see their lights and not ships due to it is night.

Would that be possible?

Thanks.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=8605#8605








More information about the osg-users mailing list