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

Reply via email to