On Fri, Aug 7, 2009 at 7:44 AM, Jie Liu <[email protected]> wrote:

> Hi,
>
> I know this should not be an issue, but I did not find direct examples to
> demonstrate the right way to do blending
>
> OK, here is the thing. I have a quad geometry, my background is solid, say,
> green.
> The color of each vertex of the quad is a Color4f variable, they have the
> same values, like Color4f(1.0, 0.0, 0.0, 0.5)
>
> However, when displaying the scene, the quad is pure red. What could be the
> problem? Will OpenSG blend the scene and the background?
> Or there are additional options to enable blending?


Yes there are.  By default blending is disabled in OpenGL.  You will need to
attach a BlendChunk to the material that you are attaching to the Geometry
core.

Example (OpenSG 1.8):
    BlendChunkPtr PSBlendChunk = BlendChunk::create();
    beginEditCP(PSBlendChunk);
        PSBlendChunk->setSrcFactor(GL_SRC_ALPHA);
        PSBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
    endEditCP(PSBlendChunk);

    ChunkMaterialPtr PSMaterial = ChunkMaterial::create();
    beginEditCP(PSMaterial, ChunkMaterial::ChunksFieldMask);
        PSMaterial->addChunk(PSBlendChunk);
    endEditCP(PSMaterial, ChunkMaterial::ChunksFieldMask);



>
>
> =====================
> BTW, what is the right way to change the values of a GeoColors4f object.
> I checked some tutorial code, the manners to change the value of Nodecore
> objects are very confusing. Below are some examples.


All of the GeoProperties (Pos,Norm,Color,etc) inherit off of a base class
that defines a generic type for each.  For example

GeoColors3f,GeoColors3ub,GeoColors4f, and GeoColors4ub inherit off of
GeoColors.  They all have a generic defined as a Color3f, but their internal
storage is different.

The push_back method takes a parameter of the same type as the generic type,
Color3f, in this case.  If you do this on a GeoColor4f this will add a
Color4f to the object with an alpha of 1.0.

But you want to be able to add a Color4f to GeoColor4f, so you can have an
alpha != 1.0.  To do this in OpenSG 1.8, AFAIK, you have to get access to
the stored field type.  For a GeoColor4f this stored field type is
MFColor4f, a multi-field of Color4fs.  That is why,AFAIK , the examples call
the getField()/getFieldPtr() methods on the GeoXXXX objects.  You can use
either method, one returns a reference, the other returns a pointer to the
stored field type.

In short you will need to use the
getField().push_back()/getFieldPtr()->push_back() on GeoColors4f to add a
Color4f.


>
> For a GeoTexCoords2f object, we can change its values in this way:
> tex->push_back(tex_value);        // this seems the most common way, quite
> intuitive
>
> however, for a GeoTexCoords1fPtr object, in this way:
> tex->*getField().*push_back(tex_value);  // we have to get field before we
> push back values, why?
>
> As a constrast, for a GeoColors4f object, We have to do like this
> color->*getFieldPtr()->*push_back(color_value);      // this time, we have
> to get the *pointer* of its field before we add values...
>
> So how can I know what is right way to change values of a Nodecore object?

There may be some confusion.  GeoColors4f/GeoTexCoord1f/etc are not
NodeCores they are GeoProperties.

Hope this helps,
David Kabala

>
>
> Thanks~~
>
> --
> Jie Liu
> Visualization Research Group
> Center for Information Science, School of EECS,
> Room 2104, Science Building No.2,
> Peking University, Beijing 100871, China
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to