Re: [osg-users] Change Texture in a given 3D model
Hi, Andrea If you know which texture unit used by this texture(if its only one texture applied to geode, this probably will be 0), you can load your own texture and set on your geode stateset on same texture unit with override flag node-getOrCreateStateSet()-setTextureAttribute(unit, moonTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE) texture can be created from image, image can be loaded with osgDB::readImageFile call Cheers 23.01.2012, 19:13, Andrea Martini martini.and...@gmail.com: Hi, is it possibile change texture image of a given 3D model? I have a 3D model coming from lightwave. I know the node* where i can find the texture (i.e Sun.tga). I'm wondering if is it possibile to change the SUN texture with another one (i.e MOON.tga) that has the same resolution. Moreover that texture would be applied in the same way of the previous one. PS: The only information i have is the name of the surface (geode) that contains the texture (created with uv map). Thank you! Cheers, Andrea -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44974#44974 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Change Texture in a given 3D model
Hi, thank you for your answer. I solved using : osg::Geode* mGeodeWhoHasTexture; // Geode with texture osg::ref_ptrosg::Texture2D mGeodeTexture; osg::ref_ptrosg::Image mOriginalImage; // original image osg::ref_ptrosg::Image mImageOne; // new image // After image load ... mGeodeTexture=dynamic_castosg::Texture2D* (mGeodeWhoHasTexture-getDrawable(0)-getStateSet()-getTextureAttribute(Channel,osg::StateAttribute::TEXTURE)); if (mGeodeTexture.get()) { mOriginalImage = mGeodeTexture-getImage(); mGeodeTexture-setImage(mImageOne.get()); } Is there a way to load all the images during start application to avoid waiting time during image switching? Beccouse each time i load a new image, i see a rescaling process. (i don't want to rescale image) that could take some seconds. Thank you! Cheers, Andrea -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44985#44985 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Change Texture in a given 3D model
You can disable image rescaling with texture-setResizeNonPowerOfTwoHint(false) Cheers 24.01.2012, 15:13, Andrea Martini martini.and...@gmail.com: Hi, thank you for your answer. I solved using : osg::Geode* mGeodeWhoHasTexture; // Geode with texture osg::ref_ptrosg::Texture2D mGeodeTexture; osg::ref_ptrosg::Image mOriginalImage; // original image osg::ref_ptrosg::Image mImageOne; // new image // After image load ... mGeodeTexture=dynamic_castosg::Texture2D* (mGeodeWhoHasTexture-getDrawable(0)-getStateSet()-getTextureAttribute(Channel,osg::StateAttribute::TEXTURE)); if (mGeodeTexture.get()) { mOriginalImage = mGeodeTexture-getImage(); mGeodeTexture-setImage(mImageOne.get()); } Is there a way to load all the images during start application to avoid waiting time during image switching? Beccouse each time i load a new image, i see a rescaling process. (i don't want to rescale image) that could take some seconds. Thank you! Cheers, Andrea -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44985#44985 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Change Texture in a given 3D model
Hi, is it possibile change texture image of a given 3D model? I have a 3D model coming from lightwave. I know the node* where i can find the texture (i.e Sun.tga). I'm wondering if is it possibile to change the SUN texture with another one (i.e MOON.tga) that has the same resolution. Moreover that texture would be applied in the same way of the previous one. PS: The only information i have is the name of the surface (geode) that contains the texture (created with uv map). Thank you! Cheers, Andrea -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=44974#44974 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] change texture
and here is image when i run my program : http://blog.360.yahoo.com/blog-Rs6nWTU5cqM642o5YzZ2Mf_I0w--?cq=1 - Original Message From: Tran Thanh Hiep [EMAIL PROTECTED] To: osg-users@lists.openscenegraph.org Sent: Monday, October 29, 2007 5:17:35 PM Subject: [osg-users] change texture hi all, in my program i want change a new texture for my model but when i apply a new texture it don't display correct follow here my code virtual void apply(osg::Geode node) { int count=node.getNumDrawables(); for(int i=0;icount;i++) { osg::Drawable *pDrawable=node.getDrawable(i); osg::Geometry *pGeo=dynamic_castosg::Geometry*(pDrawable); osg::StateSet *pStateSet=pGeo-getStateSet(); if(pStateSet!=NULL) { //pStateSet-getAttributeList(); osg::Texture2D *txtOldTexture=static_castosg::Texture2D*(pStateSet-getTextureAttribute(0,osg::StateAttribute::Type::TEXTURE)); //osg::StateAttribute *pStateAttribute=pStateSet-getTextureAttribute(0,osg::StateAttribute::Type::TEXTURE); //if(pStateAttribute!=NULL) if(txtOldTexture!=NULL) { // txtOldTexture-flushDeletedTextureObjects(0,0,0.0); // txtOldTexture-setUnRefImageDataAfterApply(false); txtOldTexture-dirtyTextureObject(); txtOldTexture-flushAllDeletedTextureObjects(0); // osg::Texture2D *txtOld=dynamic_castosg::Texture2D*(pStateAttribute); osg::Image *imgTexture=osgDB::readImageFile(strNameImageFile); //txtOldTexture-areAllTextureObjectsLoaded(); txtOldTexture-setImage(0,imgTexture); //txtOld-setImage(imgTexture); bolIsState=true; } } } please help me thanks! __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] change texture
hi all, in my program i want change a new texture for my model but when i apply a new texture it don't display correct follow here my code virtual void apply(osg::Geode node) { int count=node.getNumDrawables(); for(int i=0;icount;i++) { osg::Drawable *pDrawable=node.getDrawable(i); osg::Geometry *pGeo=dynamic_castosg::Geometry*(pDrawable); osg::StateSet *pStateSet=pGeo-getStateSet(); if(pStateSet!=NULL) { //pStateSet-getAttributeList(); osg::Texture2D *txtOldTexture=static_castosg::Texture2D*(pStateSet-getTextureAttribute(0,osg::StateAttribute::Type::TEXTURE)); //osg::StateAttribute *pStateAttribute=pStateSet-getTextureAttribute(0,osg::StateAttribute::Type::TEXTURE); //if(pStateAttribute!=NULL) if(txtOldTexture!=NULL) { // txtOldTexture-flushDeletedTextureObjects(0,0,0.0); // txtOldTexture-setUnRefImageDataAfterApply(false); txtOldTexture-dirtyTextureObject(); txtOldTexture-flushAllDeletedTextureObjects(0); // osg::Texture2D *txtOld=dynamic_castosg::Texture2D*(pStateAttribute); osg::Image *imgTexture=osgDB::readImageFile(strNameImageFile); //txtOldTexture-areAllTextureObjectsLoaded(); txtOldTexture-setImage(0,imgTexture); //txtOld-setImage(imgTexture); bolIsState=true; } } } please help me thanks! __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org