Re: [osg-users] pfObject::getNamedUserDataSlot

2015-11-24 Thread Robert Osfield
Hi Tony,

The name of the osg::Object is used as a key in UserDataContainerL  see the
methods:

   /** Get the index position of first user data object that matches
specified name.*/
virtual unsigned int getUserObjectIndex(const std::string& name,
unsigned int startPos=0) const = 0;

/** Get first user data object with specified name. */
virtual Object* getUserObject(const std::string& name, unsigned int
startPos=0);

/** Get first const user data object with specified name. */
virtual const Object* getUserObject(const std::string& name,
unsigned int startPos=0) const;

Robert.


On 23 November 2015 at 22:58, Tony Vasile  wrote:

> Hi Robert,
>We are trying to save classes which have more than simple types or the
> list specified in ValueObject. If we try and save an object which has
> osg::Object has its parent then you get a linker error about missing apply
> routines for SetValueVisitor and GetValueVisitor. I have worked around this
> by using addUserObject and setUserObject. I thought it would have been
> cleaner if we could use a string to token to identified the stored data
> rather than a magic number. The magic number approach is similar to
> Performer.
>
> 
> Tony V
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65755#65755
>
>
>
>
>
> ___
> 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] pfObject::getNamedUserDataSlot

2015-11-23 Thread Tony Vasile
Hi Robert,
  Unless I am going blind I couldn't see an explicit apply for  osg::Object in 
either GetValueVisitor or SetValueVisitor, hence the question.


Tony V

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





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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-11-23 Thread Robert Osfield
Hi Tony,

On 22 November 2015 at 23:16, Tony Vasile  wrote:

> I have looked at ValueObject and was wondering why there is no option to
> save an osg::Object or an osg::Referenced object. Is this an omission or
> intended?
>

I don't know where you got this impression. You can save custom
osg::Object's to .osgb/.osgx,.osgt as long as you provide the serializers -
see the OpenSceneGraph/src/osgWrappers/serializer/*/* for examples.

The serializers for ValueObject can be found in
src/osgWrappers/serializers/osg/ValueObject.cpp.

Classes subclassed from osg::Referenced rather than osg::Object don't
support serialization though as the serialization requires the RTT info
that osg::Object adds.

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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-11-23 Thread Robert Osfield
On 23 November 2015 at 11:38, Tony Vasile  wrote:

> Hi Robert,
>   Unless I am going blind I couldn't see an explicit apply for
> osg::Object in either GetValueVisitor or SetValueVisitor, hence the
> question.


This is different question to saving data, the serialization support uses
completely different mechanism.

Have a look at include/osg/ValueObject for the get/set methods for the
ValueObject/GetValueVisitor/SetValueVisitor.

Or... just use the template methods in osg::Object i.e.

 // set value
 int count;
 object->setUserValue("count", count);

  // get value
  object->getUserValue("count", count);

The later returns true of the object has a "count" value object of the same
type as the parameter passed in.  You need to take care here as:

  unsigned int value;
  object->getUserValue("count", value);

Will return false for the above setting using an int.

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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-11-23 Thread Tony Vasile
Hi Robert,
   We are trying to save classes which have more than simple types or the list 
specified in ValueObject. If we try and save an object which has osg::Object 
has its parent then you get a linker error about missing apply routines for 
SetValueVisitor and GetValueVisitor. I have worked around this by using 
addUserObject and setUserObject. I thought it would have been cleaner if we 
could use a string to token to identified the stored data rather than a magic 
number. The magic number approach is similar to Performer.


Tony V

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





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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-11-22 Thread Tony Vasile
I have looked at ValueObject and was wondering why there is no option to save 
an osg::Object or an osg::Referenced object. Is this an omission or intended?


Tony V

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





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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-09-10 Thread Robert Osfield
Hi Tony,

As Nick says there is the Node::setUserValue(..) template method and
Node::setUserData().  When you use UserValue it creates a UserDataContainer
to hold the values in a vector of osg::Object*, so this UserDataContainer
kinda has "slots".  The UserDataContainer is only created on demand and
when it is used it attached to the Node(or any osg::Object) via the
setUserData().

Another approach you could take it is create your own version of
UserDataContainer that uses a map rather than a vector and attach this as
UserData.

As a general note, the OSG is designed to be extensible and configurable,
while Performer is just configurable.  In Performer you have few options to
do things that aren't originally anticipated by the API, but with the OSG
the door is open to doing completely different things with it.

Robert.

On 10 September 2015 at 06:56, Tony Vasile  wrote:

> Is there an equivalent function to the Performer
> pfObject::getNamedUserDataSlot? Our code uses it a lot to store object
> data. I'm guessing we could just store the data in a map and uses the slot
> id returned as a key.
>
> 
> Tony V
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65084#65084
>
>
>
>
>
> ___
> 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] pfObject::getNamedUserDataSlot

2015-09-10 Thread Robert Osfield
Hi Tony,

On 10 September 2015 at 09:30, Tony Vasile  wrote:

> Unfortunately we have a tight schedule to do this port. The usual 6 months
> of work in 4 months type of affair. Thanks for the advice.
>

I can sympathise with impossible tight schedules, my point still stands
though.  The OSG isn't Performer, it's something FAR more flexible.

Once you get familiar with having this flexibility you can often short cut
problems and get right to a solution far quicker.  Things that took lots of
code before can be done much more easily, things that were impossible
before now become possible.

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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-09-10 Thread Tony Vasile
Hi Nick & Robert,
   That's not quite the same functionality as it appears that in Performer 
there is some sort of memory/map that is used to map a user defined name as a 
string to a slot number. You then add data to the node using this slot number. 
Performer does have a call to setUserData which takes the data as its argument 
but it installs the data in slot 0. There is another setUserData that takes two 
argument, with the first argument being a slot number. I assume that  
getNamedUserDataSlot is just an allocation scheme between the string name and 
and a magic number which represents the slot. 

That's cool this sort of functionality I could easily replicated with a couple 
of maps or a vector.

Thanks for your help.


Tony V

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





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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-09-10 Thread Robert Osfield
Hi Tony,

Spend some time with OSG code, you'll find it far more flexible than
anything that Performer had.  It's investing time into learning the OSG
rather than just working out how to do something equivalent to Performer
because your original design may well have been compromised by the
limitations of Perfomer, with the OSG it is extensible so you mold it to
how you want to work rather than moulding how you work to fit limitations
in front of you.

Robert.

On 10 September 2015 at 08:46, Tony Vasile  wrote:

> Hi Nick & Robert,
>That's not quite the same functionality as it appears that in Performer
> there is some sort of memory/map that is used to map a user defined name as
> a string to a slot number. You then add data to the node using this slot
> number. Performer does have a call to setUserData which takes the data as
> its argument but it installs the data in slot 0. There is another
> setUserData that takes two argument, with the first argument being a slot
> number. I assume that  getNamedUserDataSlot is just an allocation scheme
> between the string name and and a magic number which represents the slot.
>
> That's cool this sort of functionality I could easily replicated with a
> couple of maps or a vector.
>
> Thanks for your help.
>
> 
> Tony V
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65089#65089
>
>
>
>
>
> ___
> 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] pfObject::getNamedUserDataSlot

2015-09-10 Thread Trajce Nikolov NICK
Hi Tony,

you have two options:

- osg::Object:get/setUserData
- osg::Object:setUserValue (for this one you have to #include


Nick

On Thu, Sep 10, 2015 at 7:56 AM, Tony Vasile  wrote:

> Is there an equivalent function to the Performer
> pfObject::getNamedUserDataSlot? Our code uses it a lot to store object
> data. I'm guessing we could just store the data in a map and uses the slot
> id returned as a key.
>
> 
> Tony V
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65084#65084
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] pfObject::getNamedUserDataSlot

2015-09-10 Thread Tony Vasile
Unfortunately we have a tight schedule to do this port. The usual 6 months of 
work in 4 months type of affair. Thanks for the advice.


Tony V

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





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


[osg-users] pfObject::getNamedUserDataSlot

2015-09-09 Thread Tony Vasile
Is there an equivalent function to the Performer 
pfObject::getNamedUserDataSlot? Our code uses it a lot to store object data. 
I'm guessing we could just store the data in a map and uses the slot id 
returned as a key.


Tony V

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





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