Hi,
Gerrit Voss schrieb:
> Hi,
>
> On Sun, 2008-12-14 at 18:40 +0100, Christoph Schäfer wrote:
>
>> Hi!
>>
>> Has anybody yet designed something like an observer for OSG::Node (or
>> others) to send a notification to another object on e.g. setting a new
>> transformation matrix, adding children,…?
>>
>> I’m thinking about sub classing OSG::Node to be able to implement an
>> observer pattern. But since I’m using two aspects in my project I don’t know
>> how this will work out with ...MTRecPtr e.g.
>>
>> Probably OpenSG has some similar concept to observers already implemented
>> but I just don’t see it?
>>
>> Any suggestions/thoughts about this topics are very much appreciated ☺
>>
>
> Kind of, you can attach changed callbacks to any container. These are
> boost functions which take the changed container and the mask which
> field did change as an argument. A simple example can be found in
>
> Source/System/FieldContainer/Base/testChangedCallback.cpp
>
Following this example I now try to access the changed field (I suppose
it's the one identified by whichfield). I tried the following code
hoping whichfield contains the typ id of the changed field:
void DefaultNodeObserver::processEvent( OSG::FieldContainer *pObj,
OSG::BitVector whichField )
{
OSG::GetFieldHandlePtr _fieldHandleP;
for (int i = 0; i < pObj->getNumFields(); i++)
{
_fieldHandleP = pObj->getField(i); // Strange - does not seem to
work for all fields!
if (_fieldHandleP)
{
std::stringstream ss;
ss << "Field " << i << ": " <<
_fieldHandleP->getType().getName() << "(" <<
_fieldHandleP->getType().getId() << ") - " <<
_fieldHandleP->getName();
LOG( LOG_DEBUG,"[DefaultNodeObserver::processEvent] " +
ss.str() );
if ( _fieldHandleP->getType().getId() == whichField )
{
OVRP_LOG(
ovrp::LOG_DEBUG,"[DefaultNodeObserver::processEvent] Bingo!");
}
}
}
}
Now there are two strange things - 1) I never get a handle to field ß
and 1, 2) There never is a field with the type id given by whichfield.
What am I doing wrong here?
> Based on these there are FieldConnectors which give you route like
> functionality. The ComplexSceneManager uses them to do the
> animation parts (The vrml/osg loader can create those).
>
>
> kind regards,
> gerrit
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
Cheers,
Christoph
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users