Hello Robert, "osgconv --formats" is a useful option. No more needs to use the source.
I've attached ReaderWriterVRML2.h. It is the same as the previous one, I've just add supportsOption() calls. I hope explanations are less cryptic. Johan. On 09/11/2010 16:05, Robert Osfield wrote:
Hi Johan, You can simply run osgconv --formats to list all the details of the plugins including options supported. osgconv --format vrml would list just the details on the vrml plugin. Robert. On Tue, Nov 9, 2010 at 2:43 PM, Johan Nouvel <[email protected]> wrote:Hello Robert, I will add supportsOption() calls. But I'd like to see the result of these calls, so is there an example to print on console options, extensions and protocol supported by a plugin ? An osgplugin(s)infos for example ? If not, how to do that ? By using osgDB::PluginQuery class ? Cheers, Johan. On 08/11/2010 16:52, Robert Osfield wrote: Hi Johan, I've merged and checked-in your changes. The options are a bit cryptic though. In the latest version of the OSG there is support for reporting the options and a description string, so perhaps this would be something that would be good for the new writer options that you've added. For instance the following can now be found in src/osgPlugins/osg/ReaderWriterOSG.cpp's ReaderWriterOSG constructor: supportsOption("precision","Set the floating point precision when writing out files"); supportsOption("OutputTextureFiles","Write out the texture images to file"); supportsOption("includeExternalReferences","Export option"); supportsOption("writeExternalReferenceFiles","Export option"); Could you do something similar for the options you've added to the VRML plugin? Thanks, Robert. On Wed, Nov 3, 2010 at 4:47 PM, Johan Nouvel <[email protected]> wrote: Hello, Some times ago, I have coded an osg to vrml2 writer. Today, I have updated our writer to osg 2.9.9. 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. Cheers, Johan. -- Johan Nouvel, research engineer http://www.archivideo.com tel : +33 (0)2 99 86 30 20 ARCHIVIDEO, 40 rue des Veyettes, 35000 RENNES, FRANCE _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org -- Johan Nouvel, research engineer http://www.archivideo.com tel : +33 (0)2 99 86 30 20 ARCHIVIDEO, 40 rue des Veyettes, 35000 RENNES, FRANCE _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
-- Johan Nouvel, research engineer http://www.archivideo.com tel : +33 (0)2 99 86 30 20 ARCHIVIDEO, 40 rue des Veyettes, 35000 RENNES, FRANCE
// -*-c++-*- /* * * VRML2 file converter for OpenSceneGraph. * * authors : * Johan Nouvel ([email protected]) for the writeNode function. * * Jan Ciger ([email protected]), * Tolga Abaci ([email protected]), * Bruno Herbelin ([email protected]) * * (c) VRlab EPFL, Switzerland, 2004-2006 * * Gino van den Bergen, DTECTA ([email protected]) * Xiangxian Wang ([email protected]) * */ #include <string> #include <map> #include <osg/Node> #include <osg/Geometry> #include <osgDB/Registry> #include <osgDB/ReadFile> #include <osgDB/FileNameUtils> #include <osgDB/FileUtils> namespace openvrml { class node; } class QuadricKey { public: QuadricKey(float height, float radius, unsigned bottom, unsigned side, unsigned top) : m_height(height) , m_radius(radius) , m_flags(bottom | (side << 1) | (top << 2)) {} bool operator<(const QuadricKey& rhs) const { return m_height < rhs.m_height || (m_height == rhs.m_height && (m_radius < rhs.m_radius || (m_radius == rhs.m_radius && m_flags < rhs.m_flags))); } private: float m_height; float m_radius; unsigned m_flags; }; /** * OpenSceneGraph plugin wrapper/converter. */ class ReaderWriterVRML2 : public osgDB::ReaderWriter { public: ReaderWriterVRML2():osgDB::ReaderWriter() { supportsExtension("wrl","VRML format"); supportsOption("directoryTexture=<aDirectory>","Export option. If a texture needs to be copied, it will be into directory <aDirectory> instead of the working one"); supportsOption("convertTextures=0","Export option. Keep textures in their original format but copy them into <directoryTexture> directory"); supportsOption("convertTextures=-1","Export option. Use textures but do not convert them, keep them in their original format and location."); supportsOption("convertTextures=-2","Export option. Do not use textures, export only geometry"); supportsOption("convertTextures=-3","Export option. Default value.Convert textures to jpeg or png format, according to alpha values, and copy them into <directoryTexture> directory "); supportsOption("textureUnit=<X>","Export option. Use parameters of texture unit X instead of unit 0 in case of multitexture input file"); } virtual const char* className() const { return "VRML2 Reader/Writer"; } virtual ReadResult readNode(const std::string&, const osgDB::Options *options) const; // virtual ReadResult readNode(std::istream& fin, const osgDB::Options* options) const; virtual WriteResult writeNode(const osg::Node&,const std::string& filename,const osgDB::ReaderWriter::Options *options) const; private: typedef std::map<float, osg::ref_ptr<osg::Geometry> > SphereLibrary; typedef std::map<osg::Vec3, osg::ref_ptr<osg::Geometry> > BoxLibrary; typedef std::map<QuadricKey, osg::ref_ptr<osg::Geometry> > ConeLibrary; typedef std::map<QuadricKey, osg::ref_ptr<osg::Geometry> > CylinderLibrary; osg::ref_ptr<osg::Node> convertFromVRML(openvrml::node *obj) const; osg::ref_ptr<osg::Geometry> convertVRML97IndexedFaceSet(openvrml::node *vrml_ifs) const; osg::ref_ptr<osg::Geometry> convertVRML97IndexedLineSet(openvrml::node *vrml_ifs) const; osg::ref_ptr<osg::Geometry> convertVRML97Box(openvrml::node* vrml_box) const; osg::ref_ptr<osg::Geometry> convertVRML97Sphere(openvrml::node* vrml_sphere) const; osg::ref_ptr<osg::Geometry> convertVRML97Cone(openvrml::node* vrml_cone) const; osg::ref_ptr<osg::Geometry> convertVRML97Cylinder(openvrml::node* vrml_cylinder) const; mutable BoxLibrary m_boxLibrary; mutable SphereLibrary m_sphereLibrary; mutable ConeLibrary m_coneLibrary; mutable CylinderLibrary m_cylinderLibrary; };
_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
