Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Vincent Bourdier
Thanks a lot !

I did some changes to have the same osg file, and it work very good now !!!

It seems to be a mix of different settings.

thanks for your help.

Regards,
   Vincent.

2008/7/15 dimi christop <[EMAIL PROTECTED]>:

> Ok,
> I fixed your osg file so that it displays varrying tranparency (top
> transparent, bottom opaque).
> I assume this is what you wanted.
> Do an diff on the files and see what you did wrong You set the colors
> per primitive and not per vertex.
>
>
>
> - Original Message 
> From: Vincent Bourdier <[EMAIL PROTECTED]>
> To: OpenSceneGraph Users 
> Sent: Tuesday, July 15, 2008 1:19:23 PM
> Subject: Re: [osg-users] Transparency on a drawable
>
> Hi Dimi,
>
> this is my code :
>
> osg::StateSet* state = g->getOrCreateStateSet();
>
> state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
> osg::Material* mat = new osg::Material;
> mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
> mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
> state->setAttributeAndModes(mat,osg::StateAttribute::ON |
> osg::StateAttribute::OVERRIDE);
>
> osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
> osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
> state->setAttributeAndModes(bf);
>
> state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
>
> g->setStateSet(state);
>
> there is no difference at all...
>
> thanks for help.
>
> Vincent.
>
>
> 2008/7/15 dimi christop <[EMAIL PROTECTED]>:
>
>> This is because when you set alpha to the vertices and attach also an
>> material
>> and a blending function you have to setColorMode (AMBIENT_DIFFUSE) on the
>> material.
>>
>> Dimi
>>
>> - Original Message 
>> From: Vincent Bourdier <[EMAIL PROTECTED]>
>> To: OpenSceneGraph Users 
>> Sent: Tuesday, July 15, 2008 11:09:23 AM
>> Subject: Re: [osg-users] Transparency on a drawable
>>
>>
>> Hi Paul.
>>
>> Nothing changes with color's alpha changed...
>>
>>
>> 2008/7/15 Paul Speed <[EMAIL PROTECTED]>:
>>
>>>
>>>
>>> Vincent Bourdier wrote:
>>>
>>>> Hi
>>>>
>>>> Yes, no solutions seems to work on my problem.
>>>> Because all the propositions concern nodes, I permit to remember that I
>>>> am looking at a way to set alpha level on a osg::Geometry ...
>>>>
>>>> On node I already have a method using material : set alpha channel, and
>>>> it works good...  But on my geometry nothing look to work good...
>>>>
>>>> This is all my geometry creator code :
>>>>
>>>>osg::ref_ptr builtGeometry(){
>>>>
>>>>double alpha = 0.1;
>>>>osg::Vec4 grey(0.4,0.4,0.4,1.0);
>>>>osg::Vec4 yellow(1.0,1.0,0.0,1.0);
>>>>
>>>
>>> What happens if you put alpha for the fourth value in your color?
>>> -Paul
>>>
>>>
>>>>osg::Geometry* g = new osg::Geometry;
>>>>osg::Vec3Array* vertices= new osg::Vec3Array();
>>>>osg::Vec3Array* normals= new osg::Vec3Array();
>>>>osg::Vec4Array* colors= new osg::Vec4Array();
>>>>
>>>>normals->push_back(osg::Vec3(0,0,1));
>>>>colors->push_back(grey);
>>>>
>>>>//
>>>>//QUAD
>>>>vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
>>>>_offset));
>>>>vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
>>>>_offset));
>>>>vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
>>>>_offset));
>>>>vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
>>>>_offset));
>>>>
>>>>if(!_empty)
>>>>g->addPrimitiveSet(new
>>>>osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
>>>>else
>>>>g->addPrimitiveSet(new
>>>>osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,4));
>>>>
>>>>
>>>>//-
>>>>//LINE
>>>>
>>>>vertices->push_back(osg::Vec3(0.0, 1.0, _offset));
>>>>vertices->push_back(osg::Vec3(0.0, _dist, _offset)

Re: [osg-users] Transparency on a drawable

2008-07-15 Thread dimi christop
Ok,
I fixed your osg file so that it displays varrying tranparency (top 
transparent, bottom opaque).
I assume this is what you wanted.
Do an diff on the files and see what you did wrong You set the colors per 
primitive and not per vertex.





- Original Message 
From: Vincent Bourdier <[EMAIL PROTECTED]>
To: OpenSceneGraph Users 
Sent: Tuesday, July 15, 2008 1:19:23 PM
Subject: Re: [osg-users] Transparency on a drawable


Hi Dimi,

this is my code : 


osg::StateSet* state = g->getOrCreateStateSet();

state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
osg::Material* mat = new osg::Material;
mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
state->setAttributeAndModes(mat,osg::StateAttribute::ON | 
osg::StateAttribute::OVERRIDE);

osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, 
osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
state->setAttributeAndModes(bf);

state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

g->setStateSet(state);
there is no difference at all...

thanks for help.

Vincent.



2008/7/15 dimi christop <[EMAIL PROTECTED]>:

This is because when you set alpha to the vertices and attach also an material 
and a blending function you have to setColorMode (AMBIENT_DIFFUSE) on the 
material.

Dimi



- Original Message 
From: Vincent Bourdier <[EMAIL PROTECTED]>

To: OpenSceneGraph Users 
Sent: Tuesday, July 15, 2008 11:09:23 AM
Subject: Re: [osg-users] Transparency on a drawable



Hi Paul.

Nothing changes with color's alpha changed...



2008/7/15 Paul Speed <[EMAIL PROTECTED]>:



Vincent Bourdier wrote:

Hi

Yes, no solutions seems to work on my problem.
Because all the propositions concern nodes, I permit to remember that I am 
looking at a way to set alpha level on a osg::Geometry ...

On node I already have a method using material : set alpha channel, and it 
works good...  But on my geometry nothing look to work good...

This is all my geometry creator code :

   osg::ref_ptr builtGeometry(){

   double alpha = 0.1;
   osg::Vec4 grey(0.4,0.4,0.4,1.0);
   osg::Vec4 yellow(1.0,1.0,0.0,1.0);


What happens if you put alpha for the fourth value in your color?
-Paul



   osg::Geometry* g = new osg::Geometry;
   osg::Vec3Array* vertices= new osg::Vec3Array();
   osg::Vec3Array* normals= new osg::Vec3Array();
   osg::Vec4Array* colors= new osg::Vec4Array();

   normals->push_back(osg::Vec3(0,0,1));
   colors->push_back(grey);

   //
   //QUAD
   vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
   _offset));
   vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
   _offset));
   vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
   _offset));
   vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
   _offset));

   if(!_empty)
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
   else
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,4));


   //-
   //LINE

   vertices->push_back(osg::Vec3(0.0, 1.0, _offset));
   vertices->push_back(osg::Vec3(0.0, _dist, _offset));
   colors->push_back(grey);
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::LINES,4,2));


   //
   //LINE_LOOP

   vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
   _offset/2.0));
   vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
   _offset/2.0));
   vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
   _offset/2.0));
   vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
   _offset/2.0));

   colors->push_back(yellow);
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,6,4));

   g->setNormalArray(normals);
   g->setVertexArray(vertices);
   g->setColorArray(colors);

   g->setNormalBinding(osg::Geometry::BIND_OVERALL);
   g->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
   g->setDataVariance(osg::Object::DYNAMIC);


   //TRANSPARENCY

   osg::StateSet* state = g->getOrCreateStateSet();
  
state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
   osg::Material* mat = new osg::Material;   
mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
   state->setAttributeAndModes(mat,osg::StateAttribute::ON |
   osg::StateAttribute::OVERRIDE);

   osg::BlendFunc* bf = new
   osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
   osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
   state->setAttributeAndModes(bf);

   state->setRenderingHint(osg::StateSe

Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Vincent Bourdier
Hi Dimi,

this is my code :

osg::StateSet* state = g->getOrCreateStateSet();

state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
osg::Material* mat = new osg::Material;
mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
mat->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
state->setAttributeAndModes(mat,osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE);

osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
state->setAttributeAndModes(bf);

state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

g->setStateSet(state);

there is no difference at all...

thanks for help.

Vincent.


2008/7/15 dimi christop <[EMAIL PROTECTED]>:

> This is because when you set alpha to the vertices and attach also an
> material
> and a blending function you have to setColorMode (AMBIENT_DIFFUSE) on the
> material.
>
> Dimi
>
> - Original Message 
> From: Vincent Bourdier <[EMAIL PROTECTED]>
> To: OpenSceneGraph Users 
> Sent: Tuesday, July 15, 2008 11:09:23 AM
> Subject: Re: [osg-users] Transparency on a drawable
>
>
> Hi Paul.
>
> Nothing changes with color's alpha changed...
>
>
> 2008/7/15 Paul Speed <[EMAIL PROTECTED]>:
>
>>
>>
>> Vincent Bourdier wrote:
>>
>>> Hi
>>>
>>> Yes, no solutions seems to work on my problem.
>>> Because all the propositions concern nodes, I permit to remember that I
>>> am looking at a way to set alpha level on a osg::Geometry ...
>>>
>>> On node I already have a method using material : set alpha channel, and
>>> it works good...  But on my geometry nothing look to work good...
>>>
>>> This is all my geometry creator code :
>>>
>>>osg::ref_ptr builtGeometry(){
>>>
>>>double alpha = 0.1;
>>>osg::Vec4 grey(0.4,0.4,0.4,1.0);
>>>osg::Vec4 yellow(1.0,1.0,0.0,1.0);
>>>
>>
>> What happens if you put alpha for the fourth value in your color?
>> -Paul
>>
>>
>>>osg::Geometry* g = new osg::Geometry;
>>>osg::Vec3Array* vertices= new osg::Vec3Array();
>>>osg::Vec3Array* normals= new osg::Vec3Array();
>>>osg::Vec4Array* colors= new osg::Vec4Array();
>>>
>>>normals->push_back(osg::Vec3(0,0,1));
>>>colors->push_back(grey);
>>>
>>>//
>>>//QUAD
>>>vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
>>>_offset));
>>>vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
>>>_offset));
>>>vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
>>>_offset));
>>>vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
>>>_offset));
>>>
>>>if(!_empty)
>>>g->addPrimitiveSet(new
>>>osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
>>>else
>>>g->addPrimitiveSet(new
>>>osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,4));
>>>
>>>
>>>//-
>>>//LINE
>>>
>>>vertices->push_back(osg::Vec3(0.0, 1.0, _offset));
>>>vertices->push_back(osg::Vec3(0.0, _dist, _offset));
>>>colors->push_back(grey);
>>>g->addPrimitiveSet(new
>>>osg::DrawArrays(osg::PrimitiveSet::LINES,4,2));
>>>
>>>
>>>//
>>>//LINE_LOOP
>>>
>>>vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
>>>_offset/2.0));
>>>vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
>>>_offset/2.0));
>>>vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
>>>_offset/2.0));
>>>vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
>>>_offset/2.0));
>>>
>>>colors->push_back(yellow);
>>>g->addPrimitiveSet(new
>>>osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,6,4));
>>>
>>>g->setNormalArray(normals);
>>>g->setVertexArray(vertices);
>>>g->setColorArray(colors);
>>>
>>>g->setNormalBinding(osg::Geometry::BIND_OVERALL);
>>>g->setColorBinding(osg::Geometry::B

Re: [osg-users] Transparency on a drawable

2008-07-15 Thread dimi christop
This is because when you set alpha to the vertices and attach also an material 
and a blending function you have to setColorMode (AMBIENT_DIFFUSE) on the 
material.

Dimi



- Original Message 
From: Vincent Bourdier <[EMAIL PROTECTED]>
To: OpenSceneGraph Users 
Sent: Tuesday, July 15, 2008 11:09:23 AM
Subject: Re: [osg-users] Transparency on a drawable



Hi Paul.

Nothing changes with color's alpha changed...



2008/7/15 Paul Speed <[EMAIL PROTECTED]>:



Vincent Bourdier wrote:

Hi

Yes, no solutions seems to work on my problem.
Because all the propositions concern nodes, I permit to remember that I am 
looking at a way to set alpha level on a osg::Geometry ...

On node I already have a method using material : set alpha channel, and it 
works good...  But on my geometry nothing look to work good...

This is all my geometry creator code :

   osg::ref_ptr builtGeometry(){

   double alpha = 0.1;
   osg::Vec4 grey(0.4,0.4,0.4,1.0);
   osg::Vec4 yellow(1.0,1.0,0.0,1.0);


What happens if you put alpha for the fourth value in your color?
-Paul



   osg::Geometry* g = new osg::Geometry;
   osg::Vec3Array* vertices= new osg::Vec3Array();
   osg::Vec3Array* normals= new osg::Vec3Array();
   osg::Vec4Array* colors= new osg::Vec4Array();

   normals->push_back(osg::Vec3(0,0,1));
   colors->push_back(grey);

   //
   //QUAD
   vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
   _offset));
   vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
   _offset));
   vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
   _offset));
   vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
   _offset));

   if(!_empty)
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
   else
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,4));


   //-
   //LINE

   vertices->push_back(osg::Vec3(0.0, 1.0, _offset));
   vertices->push_back(osg::Vec3(0.0, _dist, _offset));
   colors->push_back(grey);
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::LINES,4,2));


   //
   //LINE_LOOP

   vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
   _offset/2.0));
   vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
   _offset/2.0));
   vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
   _offset/2.0));
   vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
   _offset/2.0));

   colors->push_back(yellow);
   g->addPrimitiveSet(new
   osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,6,4));

   g->setNormalArray(normals);
   g->setVertexArray(vertices);
   g->setColorArray(colors);

   g->setNormalBinding(osg::Geometry::BIND_OVERALL);
   g->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
   g->setDataVariance(osg::Object::DYNAMIC);


   //TRANSPARENCY

   osg::StateSet* state = g->getOrCreateStateSet();
  
state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
   osg::Material* mat = new osg::Material;   
mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
   state->setAttributeAndModes(mat,osg::StateAttribute::ON |
   osg::StateAttribute::OVERRIDE);

   osg::BlendFunc* bf = new
   osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
   osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
   state->setAttributeAndModes(bf);

   state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
   state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

   g->setStateSet(state);

   return g;
   }


Thanks for your help.

Regards,

Vincent.


2008/7/15 dimi christop <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:


   Hi Vincent,
   I see you still havent found a solution. So here I send you a
   complete example of transpareny.
   Its a modification of the Viewer example from the Qucik start guide.
   It loads up a cow and overrides the alpha to 0.1.
   Hope you can start from there.

   Dimi

   // Viewer Example, A minimal OSG viewer
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 
int
   main( int, char ** )
   {
   // Create a Viewer.
   osgViewer::Viewer viewer;
// Load a model and add it to the Viewer.
   osg::ref_ptr nde = osgDB::readNodeFile( "cow.osg" );
// Create StateSet and Material
   osg::StateSet* state2 = nde->getOrCreateStateSet();
   osg::ref_ptr mat2 = new osg::Material;
  // Set alpha to 0.1
   mat2->setAlpha(osg::Material::FRONT_AND_BACK, 0.1);
   state2-&

Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Vincent Bourdier
Sure

This is my Billboard node which won't set its geometry to transparent.

thanks for help.

Regards,
Vincent


2008/7/15 Ulrich Hertlein <[EMAIL PROTECTED]>:

> Hi Vincent,
>
> odd... could you save the scene and post it?
> /ulrich
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


node_debug.osg
Description: Binary data
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Ulrich Hertlein

Hi Vincent,

odd... could you save the scene and post it?
/ulrich
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Vincent Bourdier
G viewer
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>#include 
>>int
>>main( int, char ** )
>>{
>>// Create a Viewer.
>>osgViewer::Viewer viewer;
>>// Load a model and add it to the Viewer.
>>osg::ref_ptr nde = osgDB::readNodeFile( "cow.osg" );
>>// Create StateSet and Material
>>osg::StateSet* state2 = nde->getOrCreateStateSet();
>>    osg::ref_ptr mat2 = new osg::Material;
>>  // Set alpha to 0.1
>>mat2->setAlpha(osg::Material::FRONT_AND_BACK, 0.1);
>>state2->setAttributeAndModes( mat2.get() ,
>>osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
>>   // Turn on blending
>>osg::BlendFunc* bf = new
>>osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
>>osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
>>state2->setAttributeAndModes(bf);
>>viewer.setSceneData(nde.get());
>>if (!viewer.getSceneData())
>>{
>>osg::notify( osg::FATAL ) << "Unable to load data file.
>>Exiting." << std::endl;
>>return 1;
>>}
>>
>>// Display, and main loop.
>>return viewer.run();
>>}
>>
>>- Original Message 
>>From: Vincent Bourdier <[EMAIL PROTECTED]
>><mailto:[EMAIL PROTECTED]>>
>>To: OpenSceneGraph Users ><mailto:osg-users@lists.openscenegraph.org>>
>>Sent: Tuesday, July 15, 2008 9:04:23 AM
>>Subject: Re: [osg-users] Transparency on a drawable
>>
>>Hi Ulrich
>>
>>thanks for help.
>>
>>I use/try this code for the moment :
>>
>>osg::StateSet* state = g->getOrCreateStateSet();
>>
>>  
>> state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
>>osg::Material* mat =
>>(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
>>if(!mat) {
>>mat = new osg::Material;  }
>>mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
>>state->setAttributeAndModes(mat,osg::StateAttribute::ON);
>>state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>>state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
>>
>>But nothing appear transparent...
>>
>>Regards,
>>   Vincent
>>
>>2008/7/12 Ulrich Hertlein <[EMAIL PROTECTED]
>><mailto:[EMAIL PROTECTED]>>:
>>
>>Vincent Bourdier wrote:
>>
>>I do exactly the same things, on Nodes...
>>
>>stateset->setMode(GL_BLEND,
>>  osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON );
>>
>>stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>>
>>
>>Are you sure you're doing this last line?  It's not in the code
>>snippet you posted initially...
>>
>>Cheers,
>>/ulrich
>>
>>
>>   double opacity = 0.1;
>>
>>  osg::StateSet* state = mygometry->getOrCreateStateSet();
>>  state->setMode(GL_BLEND,osg::StateAttribute::ON|
>>  osg::StateAttribute::OVERRIDE);
>>  osg::Material* mat = (osg::Material*)state->getAttribute
>>  (osg::StateAttribute::MATERIAL);
>>  if(!mat) {
>>  mat = new osg::Material;
>>  mat->setAlpha(osg::Material::FRONT_AND_BACK,
>> opacity);
>>
>>  state->setAttributeAndModes(mat,osg::StateAttribute::ON);
>>  }
>>
>>
>>___
>>osg-users mailing list
>>osg-users@lists.openscenegraph.org
>><mailto:osg-users@lists.openscenegraph.org>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>
>>
>>___
>>osg-users mailing list
>>osg-users@lists.openscenegraph.org
>><mailto:osg-users@lists.openscenegraph.org>
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>>
>> 
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Paul Speed
(!viewer.getSceneData())

{
osg::notify( osg::FATAL ) << "Unable to load data file.
Exiting." << std::endl;
return 1;
}

// Display, and main loop.
return viewer.run();
}

- Original Message 
From: Vincent Bourdier <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
To: OpenSceneGraph Users mailto:osg-users@lists.openscenegraph.org>>
Sent: Tuesday, July 15, 2008 9:04:23 AM
Subject: Re: [osg-users] Transparency on a drawable

Hi Ulrich

thanks for help.

I use/try this code for the moment :

osg::StateSet* state = g->getOrCreateStateSet();
   
state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);

osg::Material* mat =
(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
if(!mat) {
mat = new osg::Material;   
}

mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
state->setAttributeAndModes(mat,osg::StateAttribute::ON);
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

But nothing appear transparent...

Regards,
   Vincent

2008/7/12 Ulrich Hertlein <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>:

Vincent Bourdier wrote:

I do exactly the same things, on Nodes...

stateset->setMode(GL_BLEND,  
osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON );


stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);


Are you sure you're doing this last line?  It's not in the code
snippet you posted initially...

Cheers,
/ulrich


   double opacity = 0.1;

  osg::StateSet* state = mygometry->getOrCreateStateSet();
  state->setMode(GL_BLEND,osg::StateAttribute::ON|
  osg::StateAttribute::OVERRIDE);
  osg::Material* mat = (osg::Material*)state->getAttribute
  (osg::StateAttribute::MATERIAL);
  if(!mat) {
  mat = new osg::Material;
  mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
 
state->setAttributeAndModes(mat,osg::StateAttribute::ON);

  }


___
osg-users mailing list
osg-users@lists.openscenegraph.org
<mailto:osg-users@lists.openscenegraph.org>

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




___
osg-users mailing list
osg-users@lists.openscenegraph.org
<mailto:osg-users@lists.openscenegraph.org>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-15 Thread Vincent Bourdier
Hi

Yes, no solutions seems to work on my problem.
Because all the propositions concern nodes, I permit to remember that I am
looking at a way to set alpha level on a osg::Geometry ...

On node I already have a method using material : set alpha channel, and it
works good...  But on my geometry nothing look to work good...

This is all my geometry creator code :

osg::ref_ptr builtGeometry(){
>
> double alpha = 0.1;
> osg::Vec4 grey(0.4,0.4,0.4,1.0);
> osg::Vec4 yellow(1.0,1.0,0.0,1.0);
>
> osg::Geometry* g = new osg::Geometry;
> osg::Vec3Array* vertices= new osg::Vec3Array();
> osg::Vec3Array* normals= new osg::Vec3Array();
> osg::Vec4Array* colors= new osg::Vec4Array();
>
> normals->push_back(osg::Vec3(0,0,1));
> colors->push_back(grey);
>
> //
> //QUAD
> vertices->push_back(osg::Vec3( _width/2.0, _height + _dist, _offset));
> vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist, _offset));
> vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
> _offset));
> vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
> _offset));
>
> if(!_empty)
> g->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
> else
> g->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,4));
>
>
> //-
> //LINE
>
> vertices->push_back(osg::Vec3(0.0, 1.0, _offset));
> vertices->push_back(osg::Vec3(0.0, _dist, _offset));
> colors->push_back(grey);
> g->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,4,2));
>
>
> //
> //LINE_LOOP
>
> vertices->push_back(osg::Vec3( _width/2.0, _height + _dist,
> _offset/2.0));
> vertices->push_back(osg::Vec3(-_width/2.0, _height + _dist,
> _offset/2.0));
> vertices->push_back(osg::Vec3(-_width/2.0, 0.0   + _dist,
> _offset/2.0));
> vertices->push_back(osg::Vec3( _width/2.0, 0.0   + _dist,
> _offset/2.0));
>
> colors->push_back(yellow);
> g->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,6,4));
>
> g->setNormalArray(normals);
> g->setVertexArray(vertices);
> g->setColorArray(colors);
>
> g->setNormalBinding(osg::Geometry::BIND_OVERALL);
> g->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
> g->setDataVariance(osg::Object::DYNAMIC);
>
>
> //TRANSPARENCY
>
> osg::StateSet* state = g->getOrCreateStateSet();
>
> state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
> osg::Material* mat = new osg::Material;
> mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
> state->setAttributeAndModes(mat,osg::StateAttribute::ON |
> osg::StateAttribute::OVERRIDE);
>
> osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
> osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
> state->setAttributeAndModes(bf);
>
> state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
>
> g->setStateSet(state);
>
> return g;
> }


Thanks for your help.

Regards,

Vincent.

2008/7/15 dimi christop <[EMAIL PROTECTED]>:

> Hi Vincent,
> I see you still havent found a solution. So here I send you a complete
> example of transpareny.
> Its a modification of the Viewer example from the Qucik start guide.
> It loads up a cow and overrides the alpha to 0.1.
> Hope you can start from there.
>
> Dimi
>
> // Viewer Example, A minimal OSG viewer
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
>
> int
> main( int, char ** )
> {
> // Create a Viewer.
> osgViewer::Viewer viewer;
>
> // Load a model and add it to the Viewer.
> osg::ref_ptr nde = osgDB::readNodeFile( "cow.osg" );
>
> // Create StateSet and Material
> osg::StateSet* state2 = nde->getOrCreateStateSet();
> osg::ref_ptr mat2 = new osg::Material;
>
> // Set alpha to 0.1
> mat2->setAlpha(osg::Material::FRONT_AND_BACK, 0.1);
> state2->setAttributeAndModes( mat2.get() , osg::StateAttribute::ON |
> osg::StateAttribute::OVERRIDE);
>
>  // Turn on blending
> osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
> osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
> state2->setAttributeAndModes(bf);
>
> viewer.setSceneData(nde.get());

Re: [osg-users] Transparency on a drawable

2008-07-15 Thread dimi christop
Hi Vincent,
I see you still havent found a solution. So here I send you a complete example 
of transpareny.
Its a modification of the Viewer example from the Qucik start guide.
It loads up a cow and overrides the alpha to 0.1. 
Hope you can start from there.

Dimi

// Viewer Example, A minimal OSG viewer 
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
 
int 
main( int, char ** ) 
{ 
// Create a Viewer. 
osgViewer::Viewer viewer; 
 
// Load a model and add it to the Viewer.
osg::ref_ptr nde = osgDB::readNodeFile( "cow.osg" );
 
// Create StateSet and Material
osg::StateSet* state2 = nde->getOrCreateStateSet(); 
osg::ref_ptr mat2 = new osg::Material; 

// Set alpha to 0.1
mat2->setAlpha(osg::Material::FRONT_AND_BACK, 0.1); 
state2->setAttributeAndModes( mat2.get() , osg::StateAttribute::ON | 
osg::StateAttribute::OVERRIDE);

 // Turn on blending 
osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, 
osg::BlendFunc::ONE_MINUS_SRC_ALPHA ); 
state2->setAttributeAndModes(bf);
 
viewer.setSceneData(nde.get());
 
if (!viewer.getSceneData()) 
{ 
osg::notify( osg::FATAL ) << "Unable to load data file. Exiting." << 
std::endl; 
return 1; 
}

// Display, and main loop. 
return viewer.run(); 
}



- Original Message 
From: Vincent Bourdier <[EMAIL PROTECTED]>
To: OpenSceneGraph Users 
Sent: Tuesday, July 15, 2008 9:04:23 AM
Subject: Re: [osg-users] Transparency on a drawable


Hi Ulrich

thanks for help.

I use/try this code for the moment :


osg::StateSet* state = g->getOrCreateStateSet();

state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
osg::Material* mat = 
(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
if(!mat) {
mat = new osg::Material;
}
mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
state->setAttributeAndModes(mat,osg::StateAttribute::ON);
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
But nothing appear transparent...

Regards,
   Vincent


2008/7/12 Ulrich Hertlein <[EMAIL PROTECTED]>:

Vincent Bourdier wrote:

I do exactly the same things, on Nodes...

stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON );

stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

Are you sure you're doing this last line?  It's not in the code snippet you 
posted initially...

Cheers,
/ulrich



   double opacity = 0.1;

  osg::StateSet* state = mygometry->getOrCreateStateSet();
  state->setMode(GL_BLEND,osg::StateAttribute::ON|
  osg::StateAttribute::OVERRIDE);
  osg::Material* mat = (osg::Material*)state->getAttribute
  (osg::StateAttribute::MATERIAL);
  if(!mat) {
  mat = new osg::Material;
  mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
  state->setAttributeAndModes(mat,osg::StateAttribute::ON);
  }


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


  ___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-14 Thread Vincent Bourdier
Hi Ulrich

thanks for help.

I use/try this code for the moment :

osg::StateSet* state = g->getOrCreateStateSet();

state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
osg::Material* mat =
(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
if(!mat) {
mat = new osg::Material;
}
mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
state->setAttributeAndModes(mat,osg::StateAttribute::ON);
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

But nothing appear transparent...

Regards,
   Vincent

2008/7/12 Ulrich Hertlein <[EMAIL PROTECTED]>:

> Vincent Bourdier wrote:
>
>> I do exactly the same things, on Nodes...
>>
>>> stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE |
>>> osg::StateAttribute::ON );
>>> stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>>>
>>
> Are you sure you're doing this last line?  It's not in the code snippet you
> posted initially...
>
> Cheers,
> /ulrich
>
> double opacity = 0.1;
>>
>>   osg::StateSet* state = mygometry->getOrCreateStateSet();
>>   state->setMode(GL_BLEND,osg::StateAttribute::ON|
>>   osg::StateAttribute::OVERRIDE);
>>   osg::Material* mat = (osg::Material*)state->getAttribute
>>   (osg::StateAttribute::MATERIAL);
>>   if(!mat) {
>>   mat = new osg::Material;
>>   mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
>>   state->setAttributeAndModes(mat,osg::StateAttribute::ON);
>>   }
>>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Ulrich Hertlein

Vincent Bourdier wrote:

I do exactly the same things, on Nodes...

stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON );
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);


Are you sure you're doing this last line?  It's not in the code snippet you 
posted initially...


Cheers,
/ulrich


double opacity = 0.1;

   osg::StateSet* state = mygometry->getOrCreateStateSet();
   state->setMode(GL_BLEND,osg::StateAttribute::ON|
   osg::StateAttribute::OVERRIDE);
   osg::Material* mat = (osg::Material*)state->getAttribute
   (osg::StateAttribute::MATERIAL);
   if(!mat) {
   mat = new osg::Material;
   mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
   state->setAttributeAndModes(mat,osg::StateAttribute::ON);
   }


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Will Dicharry

Hi Vincent,

A Drawable (which Geometry inherits from) has an associated StateSet 
object the same way that Geodes (and other classes inheriting Node) do, 
so the same method should work for your geometry as well. See 
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01139.html 
for more information.


--Will

Vincent Bourdier wrote:

Thanks for help.

I do exactly the same things, on Nodes...

but this time I am looking on a way to do this only on a geometry (So 
under a Geode)...


If you have any suggestion..

Regards,

Vincent


2008/7/11 Brian R Hill <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:

This is what I do:

osg::StateSet * stateset = node->getOrCreateStateSet();
osg::Material * mm =
dynamic_cast(stateset->getAttribute
(osg::StateAttribute::MATERIAL));
if (!mm)
{
 mm = new osg::Material;
}
mm->setAlpha(osg::Material::FRONT, transparency);
stateset->setAttributeAndModes( mm, osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON);
stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON );
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON );
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

Brian
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> wrote: -


To: "'OpenSceneGraph Users'" mailto:osg-users@lists.openscenegraph.org>>
From: "Gordon Tomlinson" <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
Sent by: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
Date: 07/11/2008 09:59AM
Subject: Re: [osg-users] Transparency on a drawable


Vincent
You post your initial question at a little over 2 hours ago.. you
need to
give people time to possibly respond maybe 1-2 days
http://www.catb.org/~esr/faqs/smart-questions.html
<http://www.catb.org/%7Eesr/faqs/smart-questions.html>
also a search of the mailing list archive will throw up quite a few
discussions and solutions on this very subject




From: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
[mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>] On Behalf Of
Vincent
    Bourdier
Sent: Friday, July 11, 2008 8:54 AM
To: osg
Subject: Re: [osg-users] Transparency on a drawable


No one have any idea of how to set an alpha transparency level on a
geometry ?
It has no texture, juste one color...

Thanks,

Regards,

Vincent.


2008/7/11 Vincent Bourdier < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >:

Hi All,

Just a simple question on how to set a transparency effect on a
drawable.

My geode contains 2 drawables, and I need only one to be
transparent...

I've tried :


double opacity = 0.1;

   osg::StateSet* state = mygometry->getOrCreateStateSet();
   state->setMode(GL_BLEND,osg::StateAttribute::ON|
   osg::StateAttribute::OVERRIDE);
   osg::Material* mat = (osg::Material*)state->getAttribute
   (osg::StateAttribute::MATERIAL);
   if(!mat) {
   mat = new osg::Material;
   mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
   state->setAttributeAndModes(mat,osg::StateAttribute::ON);
   }


Lightning is already set to ON...

But nothing appear transparent...

Thanks,

Regards
   Vincent.


___
osg-users mailing list
osg-users@lists.openscenegraph.org
<mailto:osg-users@lists.openscenegraph.org>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
<mailto:osg-users@lists.openscenegraph.org>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
  


--
Will Dicharry
Stellar Science Ltd Co



smime.p7s
Description: S/MIME Cryptographic Signature
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Vincent Bourdier
Thanks for help.

I do exactly the same things, on Nodes...

but this time I am looking on a way to do this only on a geometry (So under
a Geode)...

If you have any suggestion..

Regards,

Vincent


2008/7/11 Brian R Hill <[EMAIL PROTECTED]>:

> This is what I do:
>
> osg::StateSet * stateset = node->getOrCreateStateSet();
> osg::Material * mm = dynamic_cast(stateset->getAttribute
> (osg::StateAttribute::MATERIAL));
> if (!mm)
> {
>  mm = new osg::Material;
> }
> mm->setAlpha(osg::Material::FRONT, transparency);
> stateset->setAttributeAndModes( mm, osg::StateAttribute::OVERRIDE |
> osg::StateAttribute::ON);
> stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE |
> osg::StateAttribute::ON );
> stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
> osg::StateAttribute::ON );
> stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>
> Brian
> [EMAIL PROTECTED] wrote: -
>
>
> To: "'OpenSceneGraph Users'" 
> From: "Gordon Tomlinson" <[EMAIL PROTECTED]>
> Sent by: [EMAIL PROTECTED]
> Date: 07/11/2008 09:59AM
> Subject: Re: [osg-users] Transparency on a drawable
>
>
> Vincent
> You post your initial question at a little over 2 hours ago.. you need to
> give people time to possibly respond maybe 1-2 days
> http://www.catb.org/~esr/faqs/smart-questions.html<http://www.catb.org/%7Eesr/faqs/smart-questions.html>
> also a search of the mailing list archive will throw up quite a few
> discussions and solutions on this very subject
>
>
>
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Vincent
> Bourdier
> Sent: Friday, July 11, 2008 8:54 AM
> To: osg
> Subject: Re: [osg-users] Transparency on a drawable
>
>
> No one have any idea of how to set an alpha transparency level on a
> geometry ?
> It has no texture, juste one color...
>
> Thanks,
>
> Regards,
>
> Vincent.
>
>
> 2008/7/11 Vincent Bourdier < [EMAIL PROTECTED] >:
>
> Hi All,
>
> Just a simple question on how to set a transparency effect on a drawable.
>
> My geode contains 2 drawables, and I need only one to be transparent...
>
> I've tried :
>
>
> double opacity = 0.1;
>
>osg::StateSet* state = mygometry->getOrCreateStateSet();
>state->setMode(GL_BLEND,osg::StateAttribute::ON|
>osg::StateAttribute::OVERRIDE);
>osg::Material* mat = (osg::Material*)state->getAttribute
>(osg::StateAttribute::MATERIAL);
>if(!mat) {
>mat = new osg::Material;
>mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
>state->setAttributeAndModes(mat,osg::StateAttribute::ON);
>}
>
>
> Lightning is already set to ON...
>
> But nothing appear transparent...
>
> Thanks,
>
> Regards
>Vincent.
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Brian R Hill
This is what I do:

osg::StateSet * stateset = node->getOrCreateStateSet();
osg::Material * mm = dynamic_cast(stateset->getAttribute
(osg::StateAttribute::MATERIAL));
if (!mm)
{
 mm = new osg::Material;
}
mm->setAlpha(osg::Material::FRONT, transparency);
stateset->setAttributeAndModes( mm, osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON);
stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON );
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
osg::StateAttribute::ON );
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

Brian
[EMAIL PROTECTED] wrote: -


To: "'OpenSceneGraph Users'" 
From: "Gordon Tomlinson" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
Date: 07/11/2008 09:59AM
Subject: Re: [osg-users] Transparency on a drawable


Vincent
You post your initial question at a little over 2 hours ago.. you need to
give people time to possibly respond maybe 1-2 days
http://www.catb.org/~esr/faqs/smart-questions.html
also a search of the mailing list archive will throw up quite a few
discussions and solutions on this very subject




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vincent
Bourdier
Sent: Friday, July 11, 2008 8:54 AM
To: osg
Subject: Re: [osg-users] Transparency on a drawable


No one have any idea of how to set an alpha transparency level on a
geometry ?
It has no texture, juste one color...

Thanks,

Regards,

Vincent.


2008/7/11 Vincent Bourdier < [EMAIL PROTECTED] >:

Hi All,

Just a simple question on how to set a transparency effect on a drawable.

My geode contains 2 drawables, and I need only one to be transparent...

I've tried :


double opacity = 0.1;

osg::StateSet* state = mygometry->getOrCreateStateSet();
state->setMode(GL_BLEND,osg::StateAttribute::ON|
osg::StateAttribute::OVERRIDE);
osg::Material* mat = (osg::Material*)state->getAttribute
(osg::StateAttribute::MATERIAL);
if(!mat) {
mat = new osg::Material;
mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
state->setAttributeAndModes(mat,osg::StateAttribute::ON);
}


Lightning is already set to ON...

But nothing appear transparent...

Thanks,

Regards
Vincent.


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Gordon Tomlinson
Vincent
 
You post your initial question at a little over 2 hours ago.. you need to
give people time to possibly respond maybe 1-2 days
 
http://www.catb.org/~esr/faqs/smart-questions.html
 
 
also a search of the mailing list archive will throw up quite a few
discussions and solutions on this very subject

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vincent
Bourdier
Sent: Friday, July 11, 2008 8:54 AM
To: osg
Subject: Re: [osg-users] Transparency on a drawable


No one have any idea of how to set an alpha transparency level on a geometry
? 
It has no texture, juste one color...

Thanks,

Regards,

Vincent.


2008/7/11 Vincent Bourdier <[EMAIL PROTECTED]>:


Hi All,

Just a simple question on how to set a transparency effect on a drawable.

My geode contains 2 drawables, and I need only one to be transparent... 

I've tried : 



double opacity = 0.1;

osg::StateSet* state = mygometry->getOrCreateStateSet();
 
state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRID
E);
osg::Material* mat =
(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
if(!mat) {
mat = new osg::Material;
mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
state->setAttributeAndModes(mat,osg::StateAttribute::ON);
}



Lightning is already set to ON...

But nothing appear transparent...

Thanks,

Regards
Vincent.



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Paul Martz
This has been discussed multiple times, have you tried searching the
archives for "transparent" or "blend"? There are also several examples that
show how to do this. Try doing a recursive, case-insensitive grep on your
OSG source tree for "transparent".
 
The rules for transparency in OSG are not different from those of OpenGL. Do
it just like you would in OpenGL, except use the StateSet setRenderingHint
to control render order.
   -Paul
 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vincent
Bourdier
Sent: Friday, July 11, 2008 6:54 AM
To: osg
Subject: Re: [osg-users] Transparency on a drawable


No one have any idea of how to set an alpha transparency level on a geometry
? 
It has no texture, juste one color...

Thanks,

Regards,

Vincent.


2008/7/11 Vincent Bourdier <[EMAIL PROTECTED]>:


Hi All,

Just a simple question on how to set a transparency effect on a drawable.

My geode contains 2 drawables, and I need only one to be transparent... 

I've tried : 



double opacity = 0.1;

osg::StateSet* state = mygometry->getOrCreateStateSet();
 
state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRID
E);
osg::Material* mat =
(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
if(!mat) {
mat = new osg::Material;
mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
state->setAttributeAndModes(mat,osg::StateAttribute::ON);
}



Lightning is already set to ON...

But nothing appear transparent...

Thanks,

Regards
Vincent.



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Vincent Bourdier
Hi Stephan

Yes GL_BLEND is on :

osg::StateSet* state = g->getOrCreateStateSet();
>
> state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
> osg::Material* mat =
> (osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
> if(!mat) {
> mat = new osg::Material;
> }
> mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
> state->setAttributeAndModes(mat,osg::StateAttribute::ON);
> state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
>



2008/7/11 Stephan Maximilian Huber <[EMAIL PROTECTED]>:

> Hi,
>
> Vincent Bourdier schrieb:
>
>> Lightning is already set to ON...
>>
>> But nothing appear transparent...
>>
> is GL_BLEND enabled? a.ka. state->setMode(GL_BLEND,
> osg::StatetAttribute::ON);
>
> cheers
> Stephan
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Stephan Maximilian Huber

Hi,

Vincent Bourdier schrieb:

Lightning is already set to ON...

But nothing appear transparent...
is GL_BLEND enabled? a.ka. state->setMode(GL_BLEND, 
osg::StatetAttribute::ON);


cheers
Stephan
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Transparency on a drawable

2008-07-11 Thread Vincent Bourdier
No one have any idea of how to set an alpha transparency level on a geometry
?
It has no texture, juste one color...

Thanks,

Regards,

Vincent.

2008/7/11 Vincent Bourdier <[EMAIL PROTECTED]>:

> Hi All,
>
> Just a simple question on how to set a transparency effect on a drawable.
>
> My geode contains 2 drawables, and I need only one to be transparent...
>
> I've tried :
>
> double opacity = 0.1;
>>
>> osg::StateSet* state = mygometry->getOrCreateStateSet();
>>
>> state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
>> osg::Material* mat =
>> (osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
>> if(!mat) {
>> mat = new osg::Material;
>> mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
>> state->setAttributeAndModes(mat,osg::StateAttribute::ON);
>> }
>>
>
> Lightning is already set to ON...
>
> But nothing appear transparent...
>
> Thanks,
>
> Regards
> Vincent.
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Transparency on a drawable

2008-07-11 Thread Vincent Bourdier
Hi All,

Just a simple question on how to set a transparency effect on a drawable.

My geode contains 2 drawables, and I need only one to be transparent...

I've tried :

double opacity = 0.1;
>
> osg::StateSet* state = mygometry->getOrCreateStateSet();
>
> state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
> osg::Material* mat =
> (osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
> if(!mat) {
> mat = new osg::Material;
> mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
> state->setAttributeAndModes(mat,osg::StateAttribute::ON);
> }
>

Lightning is already set to ON...

But nothing appear transparent...

Thanks,

Regards
Vincent.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org