Hello Stefan,

Stefan Rilling wrote:
> Hello,
> 
> I am trying to assign a semi transparent color to a Particle using 
> GeoColors4f. The relevant code is:
> 
> GeoColors4fPtr geoColor2 = GeoColors4f::create();
> beginEditCP(geoColor2, GeoColors4f::GeoPropDataFieldMask);
>       geoColor2->addValue(Color4f(1.0, 0.0, 0.0, 0.5)); //fails
>       //geoColor2->addValue(Color3f(1.0, 0.0, 0.0)); //works
> endEditCP(geoColor2, GeoColors4f::GeoPropDataFieldMask);
> 
> It fails to compile under VS 2005. The error is:
> 
> error C2664: 'osg::GeoProperty<GeoPropertyDesc>::addValue' : cannot 
> convert parameter 1 from 'osg::Color4f' to 'const osg::Color3<ValueTypeT> &'
> 
> It seems that the addValue function of GeoColors4fPtr only accepts RGB 
> colors, which suprises me a bit...
> So the question is: What am I doing wrong here?

the GeoProperties have basically two interfaces, a generic one that 
allows you to use them without knowing what exactly the stored datatype 
is (i.e. you can use GeoPositions and need not know if it is a 
GeoPosition3f or GeoPositions2s). That is the interface you are using 
(addValue) and it uses the "generic" (or better most common) type for 
that type of property. For GeoColor this is Color3f.
If you know the exact type of the property, want the most efficient code 
or need to set values that are not compatible with the generic type, you 
can use it like this:

GeoColor4fPtr pColors;
GeoColor4f::StoredFieldType *pC = pColors->getFieldPtr();

beginEditCP(pColors, GeoColor4f::GeoPropDataFieldMask);
   pC->push_back(Color4f(1.0, 0.0, 0.0, 0.5));
endEditCP(pColors, GeoColor4f::GeoPropDataFieldMask);

        Hope it helps,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to