Hello,

it's me again ;). So now I have another problem where I could need your help. I think you could perhaps answer it easily. Attached are two images, the one with the red ground is the picutere "before" and the other one "after". The Scene exists of an osg::group with two childs, the ground geometry and the avatar. Now I just wanted to put a texture on the avatar, what is working as you see, but why is the ground now black??? The code I used for puting the texture image on the avatar is:

   osg::ref_ptr< osg::Group > model = new osg::Group();
osg::ref_ptr< osg::Node > avatar = osgDB::readNodeFile( "wholeAvatar.obj" ); osg::ref_ptr< osg::Node > avatarPlane = osgDB::readNodeFile( "planeAvatar.obj" );

   osg::StateSet *stateTexture = avatar->getOrCreateStateSet();
   osg::Image *imgTexture = osgDB::readImageFile( "wholeAvatar.jpg" );
if ( imgTexture ) {
       // create a new two-dimensional texture object
       osg::Texture2D *texAvatar = new osg::Texture2D;

       // set the texture to the loaded image
       texAvatar->setImage( imgTexture );

       // set the texture to the state
stateTexture->setTextureAttributeAndModes( 0, texAvatar, osg::StateAttribute::ON );

       // set the state of the current geode
       avatar->setStateSet( stateTexture );

   }

   model->addChild( avatarPos.get() );
   model->addChild( avatarPlane.get() );

Thanks for your help, you are doing a good job ;)
Marcus

--
----------------------------------------------------------------
Marcus Fritzen                  E-mail: [EMAIL PROTECTED]
University Koblenz              
Triererstr. 105, 56072 Koblenz, 
HIWI FB4 Herr Jackel
----------------------------------------------------------------

<<inline: before.jpg>>

<<inline: after.jpg>>

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

Reply via email to