With the situation you describe, in which the Geometry is shared, the
best way to change color would be with a unique BlendColor on the
MatrixTransform's StateSet. You'll need to enable blending for this, and
set the blend function to reference the blend color and zero the dest
color, like (GL_CONSTANT_COLOR, GL_ZERO) or something like that.
(I question your use of the word "static". You seem to use it as if to
mean it is shared by multiple parents. This is confusing, as one of the
DataVariance enums is STATIC, which means the data will not be modified.)
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466
Andrius Kausinis wrote:
Hi,
i am OSG newbie. and i'm working with Java project which uses JavaOSG binding
by NoodleGlue.
about the problem:
1. I have static Geode with one drawable (geometry to draw Icosahedron). These geodes represents some specific points (lets name it diamonds) in scene (may be more than 100). Geometry has it's own StateSet:
Code:
Material material = new Material();
material.setColorMode(MATERIALColorMode.AMBIENT_AND_DIFFUSE);
LightModel lightModel = new LightModel();
lightModel.setTwoSided(false);
StateSet stateset = new StateSet();
stateset.setMode(GL.GL_LIGHTING, STATEATTRIBUTEValues.ON_Val);
stateset.setMode(GL.GL_NORMALIZE, STATEATTRIBUTEValues.ON_Val);
stateset.setAttributeAndModes(material);
stateset.setAttributeAndModes(lightModel);
and color of it is set like this:
Code:
setColorArray(colors);
setColorBinding(GEOMETRYAttributeBinding.BIND_PER_PRIMITIVE_SET);
2. In OSG scene i have as many Switches as visible diamonds are available. So OSG tree would look like this:
Code:
some ROOT switch
|
+--- MatrixTransform node for diamond (resizing diamond when mouse is over
it)
| |
| +--- Switch for diamond (i would like to change diamond
color there, when it is clicked by mouse)
| |
| +--- Geode representing the diamond
+--- MatrixTransform node for diamond (resizing diamond when mouse is over
it)
| |
| +--- Switch for diamond (i would like to change diamond
color there, when it is clicked by mouse)
| |
| +--- Geode representing the diamond
+--- MatrixTransform node for diamond (resizing diamond when mouse is over
it)
| |
| +--- Switch for diamond (i would like to change diamond
color there, when it is clicked by mouse)
| |
| +--- Geode representing the diamond
...
3. So all i want is to change diamond color when it is clicked by mouse. If
i change color directly on Geometry, then all visible diamonds changes color
after one single diamond click, because it is static. I think Switch and
StateSet of it is the best place to change color. I have wrote one StateSet,
but it doesn't work:
Code:
Material material = new Material ();
material.setColorMode (MATERIALColorMode.DIFFUSE);
material.setDiffuse (MATERIALFace.FRONT_AND_BACK, highlightColor);
highlightStateSet.setAttributeAndModes(material,
STATEATTRIBUTEValues.OVERRIDE_Val | STATEATTRIBUTEValues.ON_Val);
i assume because color of Geometry is set using colors array. What i need to
change to make it work?
Thank you!
Cheers,
Andrius
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=23987#23987
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org