As it works (for our needs at least) I've done and attached a tar.gz file for the VRML2 plugin with a new part to write a VRML2 file from an osg one.
The read part is the same as in osg 2.9.9.
The write part code is in convertToVRML.cpp and .h files. It works for some osg nodes (group, geode, matrixTransform, positionAttitudeTransform and geometry). Textures are converted to jpeg (if not translucent) or png (if translucent).
There are some options that could be given to the writer (with -O switch) :
convertTextures=0 to copy textures without converting them to jpeg or png
convertTextures=-1 do not copy textures, keep them in their original format and location
convertTextures=-2 do not use textures, parse only geometry
convertTextures=-3 (default) convert textures to jpeg or png ones.
textureUnit=X in case of multiple textures, X= texture unit to use (default value=0)
directoryTexture=aPath when texture will be copied, it will be in this directory, not in the current one."
consider these initial cpack support scripts. It is hidden behind a
BUILD_PACKAGES option so won't affect the normal user. The submission
1) set the COMPONENT attribute on all cmake install commands.
COMPONENT names are according to
http://www.openscenegraph.org/projects/osg/wiki/Community/Packaging
2) provide cmake script and a template for creating CPack
configuration files. It will generate target for creating packages
with everything that gets "installed" (make package on unx, project
PACKAGE in MSVC) plus targets for generating one package per COMPONENT
(i.e. libopenscenegraph-core etc.).
I have temporariliy uploaded some examples to
http://www.openscenegraph.org/projects/osg/wiki/Community/People/MattiasHelsing
If this submission makes it into svn we can develop it to generate
rpms, installers for windows and mac (I know at least J-S don't like
these but there may be others who do ;) and even DEBs (not sure if we
can make them "ubuntu-ready" but they eventually may - at least we
could put a deb on the website)"
osg::ref_ptr<osg::Node> ReaderWriterVRML2::convertFromVRML(openvrml::node *obj)
The fixes are:
* Added the source's parent directory as search directory for image files.
* The material properties are now set in the stateset of the Geode rather than the Geometry. This will allow geometries to be reused with different material properties in future updates.
NB: I planned for a caching scheme in which multiple occurences of the same primitive (e.g., Cylinders with radius 0.8 and height 1.2), would use the same Geometry object. Unfortunately, my planning moved me to other areas, but I might still finish the caching scheme in a quiet hour. For the time being I decided it would be a good thing to already submit my current changes.
"