Hi,
On Tue, 2004-05-18 at 23:39, Andreas Zieringer wrote:
> Hi,
>
> oliver is working on a new really nice tutorial
> http://www.oliver-abert.de/index.php?target=work
>
> Andreas
>
>
> GeoTexCoords3fPtr txcrd = GeoTexCoords3f::create();
> beginEditCP (txcrd, GeoTexCoords3f::GeoPropDataFieldMask);
> txcrd->getFieldPtr()->push_back((Vec3f(0, 0, 1));
> beginEditCP (txcrd, GeoTexCoords3f::GeoPropDataFieldMask);
>
> > hello,
> >
> > i am trying to feed opensg the tex coords for the cube map all by
> > myself. This means using 3 dimensional coordinates. On, no problem, I
> > think i should use GeoTexCoords3f.
> > I've copied a snippet of code from an example reading:
> >
> > GeoTexCoords2fPtr txcrd = GeoTexCoords2f::create();
> > beginEditCP (txcrd, GeoTexCoords2f::GeoPropDataFieldMask);
> > {
> > txcrd->addValue(Vec2f(0, 1));
> > txcrd->addValue(Vec2f(0, 0));
> > txcrd->addValue(Vec2f(1, 0));
> > txcrd->addValue(Vec2f(1, 1));
> > }
> > endEditCP (txcrd, GeoTexCoords2f::GeoPropDataFieldMask);
> >
> > so i told myself: great, just swap all 2s with 3s and you are done.
> > Wrong: all i get is a compilation error saying:
> >
> > 10loading.cpp:632: no matching function for call to `
> > osg::GeoProperty<osg::GeoTexCoords3fPropertyDesc>::addValue(osg::Vec3f)'
> > /usr/local/include/OpenSG/OSGGeoPropTexCoords.inl:138: candidates are:
> > void
> > osg::GeoProperty<GeoPropertyDesc>::addValue(GeoPropertyDesc::GenericType&)
> > [with GeoPropertyDesc = osg::GeoTexCoords3fPropertyDesc]
> >
> > now what type of data should i use in the place of Vec3f?
> >
> > finally my last question: since it is better to teach the hungry man to
> > fish, rather than giving him one fish, how can I guess myself what kind
> > of data is GeoTexCoords3fPropertyDesc? I've read the doxigen stuff and
> > gave a look at the src code, but didn't get very far...
to make the answer a little bit more complete, what happened is that
GeoProperties have two interface the specific one and a generic one.
The generic one takes the most common data type for this property as
an argument (in case of texture coordinates this is Vec2f). As you
might guess addValue is part of the generic interface so even after
you switched to GeoTexCoords3f addValue still expects Vec2f arguments.
To get the specific interface you have to access the stored mfield
directly (property->getFieldPtr()) using the normal mfield functions,
as they will expect the specific type (Vec3f in your case).
To figure out the stored and generic type you can look at the Desc
structs, for GeoTexCoords3f this is snip :
struct GeoTexCoords3fPropertyDesc : public GeoTexCoordsPropertyDesc
{
static FieldDescription *_desc[];
.
.
.
.
.
typedef GeoTexCoords Inherited;
typedef GeoTexCoords::PtrType InheritedPtr;
typedef GeoTexCoordsPropertyDesc InheritedDesc;
typedef MFVec3f StoredFieldType;
typedef InheritedDesc::GenericType GenericType;
#ifndef OSG_SUPPORT_NO_GEO_INTERFACE
typedef GeoPropertyInterface<GeoTexCoordsPropertyDesc> Interface;
#endif
};
StoredFieldType means the return type of property->getFieldPtr() is an
MFVec3f *. The generic type is a little bit harder to find. You have
to go to OSGGeoPropertyInterfaces.h to find snip :
struct GeoTexCoordsPropertyDesc : public GeoPropertyDesc
{
.
.
.
typedef Attachment Inherited;
typedef AttachmentPtr InheritedPtr;
typedef AttachmentPropertyDesc InheritedDesc;
typedef Vec2f GenericType;
#ifndef OSG_SUPPORT_NO_GEO_INTERFACE
typedef GeoPropertyInterface<GeoTexCoordsPropertyDesc> Interface;
#endif
};
and there you find that the generic type for texture coordinates is
Vec2f.
hope it helps a little bit for the future ;-)
gerrit
-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users