Hi,
I read 123.osgb file to a node, and then write it to 456.osgb ,however,the
456.osgb has a 10 times bigger size than 123.osgb. My code is here:
osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(123.osgb);
osg::ref_ptr<osgDB::ReaderWriter::Options> options = new
osgDB::ReaderWriter::Options;
options->setOptionString("WriteImageHint=IncludeData");
osgDB::ReaderWriter::WriteResult result =
osgDB::Registry::instance()->writeNode(*node, “456.osgb”,options);
I than use a texure compress method cited from osgconv.cpp, the result is
still 2 times bigger size than the original file.
void MyNodeVisitor::compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE) << "Error: Unable to create graphis
context, problem with running osgViewer-" << osgViewerGetVersion() << ", cannot
run compression." << std::endl;
return;
}
osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();
for (TextureSet::iterator itr = _textureSet.begin();
itr != _textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());
osg::Texture2D* texture2D =
dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D =
dynamic_cast<osg::Texture3D*>(texture);
osg::ref_ptr<osg::Image> image = texture2D ?
texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat() == GL_RGB ||
image->getPixelFormat() == GL_RGBA) &&
(image->s() >= 32 && image->t() >= 32))
{
texture->setInternalFormatMode(_internalFormatMode);
// need to disable the unref after apply, otherwise the
image could go out of scope.
bool unrefImageDataAfterApply =
texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);
// get OpenGL driver to create texture from image.
texture->apply(*state);
// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);
image->readImageFromCurrentTexture(0, true);
texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}
my question is ,how can i make the 456.osgb has the same size with 123.osgb
Thank you!
Cheers,
tangrijing
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72745#72745
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org