[osg-users] Using multiples texture for a geometry

Florian GOLESTIN florian.golestin at gmail.com
Wed May 4 14:03:15 PDT 2016


Hi Robert,

I tried without the SmoothingVisitor but it does not change anything.


However during my tests today I put a "Axes" object (the axes.osgt model from the OpenSceneGraph examples) and some part of the texture on the block below the object just appeared but really dark.
So it it make me think that it's not a texture problem but maybe a light problem.

I've tried then to use a full ambiant light:

Code:

osg::ref_ptr<osg::Node> createLightSource( unsigned int num,
			      const osg::Vec3& trans,
			      const osg::Vec4& color )
{
  osg::ref_ptr<osg::Light> light = new osg::Light;
  light->setLightNum( num );
  light->setDiffuse( color );

  /* full scene lightened: */
  light->setAmbient(osg::Vec4(1.0,1.0,1.0,1.0));
  light->setSpecular(osg::Vec4(1,1,1,1));  // some examples don't have this one

  
  light->setPosition( osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f) );
  osg::ref_ptr<osg::LightSource> lightSource = new
    osg::LightSource;
  lightSource->setLight( light );
  osg::ref_ptr<osg::MatrixTransform> sourceTrans = new osg::MatrixTransform;
  sourceTrans->setMatrix( osg::Matrix::translate(trans) );
  sourceTrans->addChild( lightSource.get() );
  return sourceTrans;
}

int	main(int argc, char **argv)
{
  osg::ArgumentParser arguments(&argc,argv);
  
  osg::ref_ptr<osg::Group> root = new osg::Group;

  root->addChild(createLightSource(0, osg::Vec3(0, -2.0, 0), osg::Vec4(1.0, 1.0, 1.0, 1.0)));
  root->addChild(createLightSource(1, osg::Vec3(0, -16.0, 10.0), osg::Vec4(1.0, 1.0, 1.0, 1.0)));

  root->getOrCreateStateSet()->setMode( GL_LIGHT0, osg::StateAttribute::ON );
  root->getOrCreateStateSet()->setMode( GL_LIGHT1, osg::StateAttribute::ON );





Now the texture appears but are really dark such as there is no light.

Is it something related to states and inheritance?

Thanks,
Florian

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








More information about the osg-users mailing list