[osg-users] Extract an embedded texture from an .ive

2008-07-09 Thread Doug

Hi,

I have a model in .ive format with an embedded texture. I need to bring 
the model into 3dsMax to work on it. I can use osgconv to convert it to 
one of several different formats that Max can import (obj, dae, etc.), 
but I also need the texture that is embedded. Can anyone point me in the 
right direction as to how to extract a texture that is embedded in an 
.ive file?


Thanks,

Doug
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Extract an embedded texture from an .ive

2008-07-09 Thread Luigi Calori

Doug wrote:


Hi,

I have a model in .ive format with an embedded texture. I need to 
bring the model into 3dsMax to work on it. I can use osgconv to 
convert it to one of several different formats that Max can import 
(obj, dae, etc.), but I also need the texture that is embedded. Can 
anyone point me in the right direction as to how to extract a texture 
that is embedded in an .ive file?


try osgconv -O OutputTextureFiles file.ive file.osg
it should save texture embedded in file.ive

Luigi


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Extract an embedded texture from an .ive

2008-07-09 Thread 冯晨
 
 
 Hi,
I've also been doing the same thing lately. I've writen some code to 
achieve that, maybe help, :)

class TextureVisitor : public osg::NodeVisitor
{
public:
TextureVisitor(int sizelimit, int levelnum):_sizelimit(sizelimit), 
_levelnum(levelnum),
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{}

virtual void apply(osg::Group node)
{
osg::StateSet* ss = node.getStateSet();
if(ss!=NULL)
traverseTexture(ss);
traverse(node);
}

virtual void apply(osg::Node node)
{
osg::StateSet* ss = node.getStateSet();
if(ss!=NULL)
traverseTexture(ss);
traverse(node);
}

virtual void apply(osg::Geode node)
{
osg::StateSet* ss = node.getStateSet();
if(ss!=NULL)
traverseTexture(ss);

int numdrawables = node.getNumDrawables();
for(int i=0; inumdrawables; ++i)
{
ss = node.getDrawable(i)-getStateSet();
if(ss!=NULL)
traverseTexture(ss);
}
traverse(node);
}

void traverseTexture(osg::StateSet* ss)
{
osg::StateSet::TextureAttributeList texAbl =
ss-getTextureAttributeList();
int i=0;
for(osg::StateAttribute* sa = ss-getTextureAttribute(i, 
osg::StateAttribute::TEXTURE);
itexAbl.size(); ++i)
{
osg::Texture2D* tex2d = dynamic_castosg::Texture2D*(sa);
if(tex2d==NULL)
continue;
//对于每一个image
int numImg = tex2d-getNumImages();
for(int j=0; jnumImg; ++j)
{
osg::Image* img = tex2d-getImage(j);
SaveTexture(img);
}
}
}
string getName(const string filename)
{
string::size_type pos = filename.find_last_of(\\);
string::size_type pointpos = filename.find_last_of(.);
string name;
for(string::size_type i = pos+1; ipointpos; ++i)
{
name += filename[i];
}
return name;
}
void SaveTexture(osg::Image* img)
{
osgDB::writeImageFile(img, img-getFileName());
}
private:
int _sizelimit;
int _levelnum;
};

 


在2008-07-09 21:32:46,Doug [EMAIL PROTECTED] 写道:
Hi,

I have a model in .ive format with an embedded texture. I need to bring 
the model into 3dsMax to work on it. I can use osgconv to convert it to 
one of several different formats that Max can import (obj, dae, etc.), 
but I also need the texture that is embedded. Can anyone point me in the 
right direction as to how to extract a texture that is embedded in an 
.ive file?

Thanks,

Doug
___
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] Extract an embedded texture from an .ive

2008-07-09 Thread Doug

Fantastic! That worked like a charm.

Thank you very much for your help!

Doug

Luigi Calori wrote:


Doug wrote:


Hi,

I have a model in .ive format with an embedded texture. I need to 
bring the model into 3dsMax to work on it. I can use osgconv to 
convert it to one of several different formats that Max can import 
(obj, dae, etc.), but I also need the texture that is embedded. Can 
anyone point me in the right direction as to how to extract a texture 
that is embedded in an .ive file?



try osgconv -O OutputTextureFiles file.ive file.osg
it should save texture embedded in file.ive

Luigi


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

__ NOD32 3256 (20080710) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org