Hi Paul,

I intended to use osgIntrospection to provide scripting functionality to my 
software. As I dived in deeper into osgIntrospection, I recognized that this 
framework is quite complicated. After lots of reading forum posts and 
discussions, I learned that this part of osg was once contributed to osg by a 
third party. This person is any longer active in the osg community, so Robert 
is thinking about removing osgIntrospection from the core project, as soon as 
any other technique is available.
As far as I know, the wrapper definitions of osgIntrospection are created semi 
automatically. This seem to cause lots of trouble. Robert assumed that manual 
wrapper definition and maintenance would be easier.

Now osgDB::Serializer enters the game: Wang wrote it to allow file formats 
which can grow with the project. The old .osg and .ive format was hard coded, 
so later added node classes could not be saved to file/stream.
In the new format, all classes have the usual class definition with members and 
attributes.  For the serializer, all classes provide now additionally  set/get 
functions for all members with a well defined signature AND they contain a 
macro call which connects all members and there set/get functions.

To serialize nodes is now easy: Using predefined osg nodes you can serialize in 
one step, because all get/set functions and the MACRO call is implemented 
already. (you have to use at least 2.9.7)
If you use one transportcontainsers, you have to define you transport 
container, the getters/setter and the serializer macro.

Please note that my transport container node holds other customs nodes, so they 
are build in that serializer compatible way too. (not listed below)

Regarding namespace: osgDB::serializer requires namespace usage! My application 
did not use namespace before, but I added it for the serializer and it works ) 

In detail, why do you want to use osgIntrospection? For serializing nodes or 
for scripting abilities? I would recommend you to try solving your issue with 
the “new” technique, because this will give your software a guaranteed future 
(at least more the using osgIntrospection, I assume)

I myself would be happy if the serializer functionality would get a 
corresponding wrapper functionality.
Maybe this could be realized by specifying the function signatures via calling 
them with a Macro. (only a fiorst simple approach of myself to that topic)

Well , I hope I could help you, don’t hesitate to ask.

I will post this email additionally in our thread in the forum to participate 
other persons in that discussion.

Best regards from Salzburg,

Torben



My example dataIO_transportContainer.cpp:

#include "dataIO_transportContainer.h"
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>

REGISTER_OBJECT_WRAPPER( dataIO_transportContainer,                      // The 
unique wrapper name
                         new osgVisual::dataIO_transportContainer,             
// The proto
                         osgVisual::dataIO_transportContainer,                 
// The class typename
                                    "osg::Object 
osgVisual::dataIO_transportContainer" )  // The inheritance relations
{
      ADD_INT_SERIALIZER( FrameID, 0 );
      ADD_MATRIXD_SERIALIZER( ViewMatrix, osg::Matrixd() );
      ADD_LIST_SERIALIZER( Executer, 
osgVisual::dataIO_transportContainer::executerList );
      ADD_LIST_SERIALIZER( IOSlots, 
osgVisual::dataIO_transportContainer::slotList );
}

My example dataIO_transportContainer.h:
#pragma once
/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
 *
 * This library is based on OpenSceneGraph, open source and may be 
redistributed and/or modified under 
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * osgVisual requires for some proprietary modules a license from the 
correspondig manufacturer.
 * You have to aquire licenses for all used proprietary modules.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#include <osg/Object>
#include <osg/Matrixd>

#include <dataIO_executer.h>
#include <dataIO_slot.h>

#include <vector>

namespace osgVisual {

class dataIO_transportContainer : public osg::Object
{
public:
      META_Object(osgVisual,dataIO_transportContainer);    // Required for 
serializer
      dataIO_transportContainer(const osgVisual::dataIO_transportContainer& 
tC_, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):      // Required for 
serializer
                  Object(tC_,copyop),
                  frameID(tC_.frameID),
                  viewMatrix(tC_.viewMatrix),
                  executer(tC_.executer),
                  ioSlots(tC_.ioSlots){}
      dataIO_transportContainer(){}
      virtual ~dataIO_transportContainer(){}




      typedef std::vector<osg::ref_ptr<dataIO_executer> > executerList;
      typedef std::vector<osg::ref_ptr<dataIO_slot> > slotList;

private:
      int frameID;
      osg::Matrixd viewMatrix;
      executerList executer;
      slotList ioSlots;

// Access functions for Serializer
public:
      int getFrameID() const {return frameID;}
      void setFrameID(int frameID_ ){frameID=frameID_;}

      void setViewMatrix(const osg::Matrixd& 
viewMatrix_){viewMatrix=viewMatrix_;}
      const osg::Matrixd& getViewMatrix() const {return viewMatrix;}

      void setExecuter(const executerList& executer_) {executer=executer_;}
      const executerList& getExecuter() const {return executer;}

      void setIOSlots(const slotList& ioSlots_) {ioSlots=ioSlots_;}
      const slotList& getIOSlots() const {return ioSlots;}



      // Usage functions
      void addExecuter( osg::ref_ptr<dataIO_executer> executerToAdd_ ) 
{executer.push_back(executerToAdd_);}
      void removeAllExecuter() { executer.clear();}

      void addSlot( osg::ref_ptr<dataIO_slot> slotToAdd_ ) 
{ioSlots.push_back(slotToAdd_);}
      void removeAllSlots() {ioSlots.clear();}

};

} // END NAMESPACE

Von: Paul Gotzel [mailto:] 
Gesendet: Dienstag, 13. April 2010 14:56
An: Torben Dannhauer
Betreff: osgIntrospection

Hello Torben,

Thanks for you response.  What do you know about the osgIntrospection 
namespace?  From the example, I couldn't determine how I would use the 
namespace to serialize an instanced scene graph.  Perhaps you could provide a 
small example?  Robert Osfield (the author?) seems to think that the new 
approach in the in osgDB 2.9 branch would be better.  Thoughts?

Thanks,
-- 
Paul Gotzel

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26727#26727





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to