i have a mesh and want to project several photo on the mesh .   code is here:

osg::Switch *layer = new osg::Switch;
osg::Geode* leaf = 0;
if (!hasTexture){
leaf = createLeaf(points, numOfVert, tris,header.np);
layer->addChild(leaf); 
}else{ 
osg::Group *group = new osg::Group; 
for (unsigned int gr = 0; gr < header.ngr; gr++){ 
/*for every group , load the different texture*/
osg::Texture2D* texture = 0L;
osg::ref_ptr<osg::Image> image;
if(osgDB::isAbsolutePath(groups[gr].texmap)){
image = osgDB::readImageFile(std::string(groups[gr].texmap));
}else{
std::string absoluteFile = osgDB::getFilePath(fileName) 
+ std::string("/") 
+ std::string(groups[gr].texmap);
image = osgDB::readImageFile(absoluteFile);
} 
texture = new osg::Texture2D;
texture->setImage( image.get() );
if (texture->getImage()!=0L){
group->getOrCreateStateSet()->setTextureAttributeAndModes(gr,texture );    
//set texture units
group->getOrCreateStateSet()->setTextureAttribute(gr, new 
osg::TexEnv(osg::TexEnv::DECAL));
} 
/*create group leaf*/
leaf = createLeaf(points, tris_t, groups[gr].poly_begin, groups[gr].poly_end, 
gr);
group->addChild(leaf);
}
layer->addChild(group); 
}

the problem is that just one texture unit works .       
in case :
         for (unsigned int gr = 0; gr < header.ngr; gr++){      unit 0 works 
         for (unsigned int gr = 1; gr < 2; gr++){                       unit 1 
works


then , how can i show the whole mesh with texture?


thanks in advance



Shawl
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to