Sebastian Knödel wrote:
> Andreas Zieringer wrote:
>> you can use the reflective interface just search for the "GLId" field
>> and read the value.
yes, this is probably better than the inheritance trickery. Sorry, I
just did not think of this earlier.
> If I understand you right I just read out the GLIdFieldId value of my
> geometry like
>
> int DLid = anyGeo->GLIdFieldId;
>
> but this gives me only the "Field value" which is 21 all the time,
> because its the 21. field in the set.
with this you can get a pointer to the actual field, by calling:
Field *pField = geo->getField(Geometry::GLIdFieldId);
now, in this case the type of the field is actually known, it is
SFInt32, so you can cast that Field* to the correct type and read the value:
SFInt32 *pIdField = static_cast<SFInt32 *>(pField);
Int32 glId = win->getGLObjectId(pIdField->getValue());
If the type of the field would not be known, you would have to use the
"generic interface", which basically is a fancy name for accessing the
fields value as a string (see the functions {M|S}Field::getValueByStr etc)
> I also tried to cast the GeometryPtr to my own Type myGeometry, which
> doesn't work out right know.
> The compiler tells me that I cannot convert from 'osg::GeometryPtr' to
> 'myGeometry *'.
> The code looks like that
>
> -----
> class myGeometry : public Geometry
> {
> public:
> myGeometry(){};
>
> inline int getDListID(PassiveWindowPtr win) {return
> win->getGLObjectId(getGLId());}
> };
>
> myGeometry* myGeo;
> .
> .
> .
> myGeo = static_cast<myGeometry*>( anyOSGGeo);
> int DLid = myGeo->getDListID(win);
no, this can not work. SomethingPtr is not just a typedef for
Something*, but a class type of its own, it just behaves like a pointer.
And even if this was not the case the above would need a
reinterpret_cast, because you are attempting to forcefully circumvent
the access control by casting the pointer to something it does not
really point to.
Hope it helps,
Carsten
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users