[osg-users] applying textures

Enrico Villani enri.villa at gmail.com
Tue Sep 25 03:13:04 PDT 2007


Hi to all!
   i'm a newbie of osg and i would share my problem with the
community.......
    i'm developing a VR application which should load various kind of 3D
models (mainly flt and osg/ive), insert them into an appropriate
environement and allow to modify all the scenegraph at runtime. in fact it
shows the scenegraph and the user can decide to change positions of nodes,
their visibility, etc. When the user chooses to modify the texture of these
models, he searches the disk for a good looking image (bmp, jpg, etc), but
the texture is not mapped correctly (the node selected by the user changes
only its color, texture too big???? ). otherwise when he applies these
textures onto the environement sphere or the terrain, all look more or less
correct. I use an extended nodevisitor to traverse the scenegraph from the
node choosed by the user in search of geodes. Every time the visitor finds a
geode it does:

        int Num = geode.getNumDrawables();
        for(int j = 0; j < Num; j++) {
            osg::StateSet* stateset = geode.getDrawable
(j)->getOrCreateStateSet();
            osg::Texture2D* myTexture=new osg::Texture2D;
            myTexture->setDataVariance(osg::Object::DYNAMIC);
            myTexture->setImage(myImage);
            stateset->setTextureAttributeAndModes(0, myTexture,
osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
            geode.getDrawable(j)->setStateSet(stateset);
        }

I'm in trouble understanding texture mapping. I looked at BumpMapping to get
useful hints about texcoordgenerator... but i don't know how to use it.
Having multiple geometries, how to map them correctly or even
approssimatively?

Can anyone help me??

Sorry for my maybe silly question but I'm new to to the computer graphics
world!

I'd be very grateful..
Many thanks in advance..

Enrico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070925/e970bf72/attachment-0002.htm>


More information about the osg-users mailing list