Re: [osg-users] Add a color node in the scenegraph?

2010-04-14 Thread Benjamin GODIN
Hello, I tried what you said, but it doesn't work.
Do you see an error in my code ?


Code:
osg::ref_ptr sphere = new osg::Sphere(osg::Vec3f(0.0, 0.0, 0.0), 
.5f);

osg::ref_ptr sphereDrawable = new 
osg::ShapeDrawable(sphere.get());
sphereDrawable->getOrCreateStateSet()->setMode(osg::StateAttribute::BLENDCOLOR, 
osg::StateAttribute::ON);

osg::ref_ptr sphereGeode = new osg::Geode();
sphereGeode->addDrawable(sphereDrawable.get());


osg::Matrix I = osg::Matrix::identity();
osg::ref_ptr mtI = new osg::MatrixTransform(I);

mtI->addChild(sphereGeode.get());

double x = 0.0;
for (int k = 0; k < 10; k++) {
osg::ref_ptr patSphere = new 
osg::PositionAttitudeTransform();

patSphere->setPosition(osg::Vec3f(x, 0.0, 0.0));

if (k == 5) {
osg::BlendColor* bc = new osg::BlendColor(osg::Vec4(1.0, 0.0, 
0.0, 1.0));
patSphere->getOrCreateStateSet()->setAttributeAndModes(bc, 
osg::StateAttribute::ON);

patSphere->getOrCreateStateSet()->setMode(osg::StateAttribute::BLENDCOLOR, 
osg::StateAttribute::ON);
}

patSphere->addChild(mtI.get());

root->addChild(patSphere.get());
}



Thanks. :)

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26754#26754





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


Re: [osg-users] Add a color node in the scenegraph?

2010-04-07 Thread Paul Martz

Vincent Bourdier wrote:

Hello,

You should try just adding a material on each PAT.
If I'm right, material will overpass the color of the geode... If anyone 
can confirm :-[


That will work if lighting is on. If lighting is off, set a BlendColor at each 
PAT and then configure blending on the Drawable to reference the blend color.



Le 07/04/2010 11:33, Benjamin GODIN a écrit :

Hello,

I have a scene with one object but represented many times.
My graph is something like that :
[Image: http://img576.imageshack.us/img576/1522/osg.png ]

I want to give different colors to the different objects. The method 
I've found is setColor on a ShapeDrawable but that means I need to 
create many instances of this object.


Is there any way I can add the color in the scene graph (as a node)?

Thanks. :)[/img]



--
  -Paul Martz  Skew Matrix Software
   http://www.skew-matrix.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Add a color node in the scenegraph?

2010-04-07 Thread Vincent Bourdier

Hello,

You should try just adding a material on each PAT.
If I'm right, material will overpass the color of the geode... If anyone 
can confirm :-[


Regard,
Vincent

Le 07/04/2010 11:33, Benjamin GODIN a écrit :

Hello,

I have a scene with one object but represented many times.
My graph is something like that :
[Image: http://img576.imageshack.us/img576/1522/osg.png ]

I want to give different colors to the different objects. The method I've found 
is setColor on a ShapeDrawable but that means I need to create many instances 
of this object.

Is there any way I can add the color in the scene graph (as a node)?

Thanks. :)[/img]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26507#26507





___
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] Add a color node in the scenegraph?

2010-04-07 Thread Benjamin GODIN
Hello,

I have a scene with one object but represented many times.
My graph is something like that :
[Image: http://img576.imageshack.us/img576/1522/osg.png ]

I want to give different colors to the different objects. The method I've found 
is setColor on a ShapeDrawable but that means I need to create many instances 
of this object.

Is there any way I can add the color in the scene graph (as a node)?

Thanks. :)[/img]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26507#26507





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