To use a osgFX::BumpMapping you only have to set your node as a child of a 
osgFX::BumpMapping group.

The normal map has to be the texture unit 0 and your colour texture as unit 1.

 

osg::Node *myNode = /*a node*/;

osg::Texture2D *MyBumpMap = /*a normal map*/;

osg::Texture2D *MyTexture = /*a texture*/;

 

// set the two textures, the second one is not required, but you have to set 
the bumpmap in the unit 0.

osg::StateSet *pStateSet = myNode ->getOrCreateStateSet();

pStateSet ->setTextureAttributeAndModes( 0, MyBumpMap, 
osg::StateAttribute::ON|osg::StateAttribute::PROTECTED );

pStateSet ->setTextureAttributeAndModes( 1, MyTexture , osg::StateAttribute::ON 
);

 

// create the BumpMapping group

osgFX::BumpMapping *pBump = new osgFX::BumpMapping;

// add our node as a child

pBump->addChild(myNode);

// I don't remember what this function do, sorry ;)

pBump->prepareChildren();

 

This piece of code should work. So, I still have problem with the bump mapping 
on my ATI FireGL card, but it work perfectly on my NVIDIA Quadro.

 

________________________________

De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Mael Blanchard
Envoyé : jeudi 3 mai 2007 17:10
À : osg users
Objet : [osg-users] [osgFX::BumpMapping]

 

Hello, 
does anyone know a short example of code to use the osgFX::BumpMapping node in 
a scene? I have some troubles, it could help me

thank you

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to