Setting translucent renderstate

Hi all, I would like to ask how to make a simple box in jme translucent… I have a plan that when I choose my selection from all the objects in the scene via a JComboBox I've made… all other objects in the scene shall remain translucent

Set a blend state on your box and a material state that has a transparency set on it:



Box shape = new Box(....);

MaterialState material = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
material.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));

shape.setRenderState(material);
shape.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);

BlendState bs = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
bs.setBlendEnabled(true);
bs.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
bs.setTestEnabled(false);
bs.setTestFunction(BlendState.TestFunction.GreaterThanOrEqualTo);
bs.setEnabled(true);
      
shape.setRenderState(bs);

shape.updateRenderState();



You might have to to turn off two-pass-transparency as that pass will not cull the back of your box, causing half of it to still appear. Renderer.getQueue().setTwoPassTransparency()
Give it a try without that though and see how it looks.

Hi all



I'd like to revive this thread again… So I was able to make my objects in a transparent renderstate so I could mousepick the translator inside even if the object gets scaled… now what I'd like to do is to bring back the renderstates of those other objects that aren't selected in my scenegraph… I saw this clearRenderState(int RenderType) function but I can't quite get the hang of using it… any suggestions on how I can clear the other object's renderstates?