public void showLight(final LightNode lightNode, final String name) {
if (rootNode != null) {
dispose();
}
DirectionalLight directionalLight = (DirectionalLight)lightNode.getLight();
rootNode = new Node("Light Viewer Node");
RenderManager rm = ClientContextJME.getWorldManager().getRenderManager();
RenderComponent rc = rm.createRenderComponent(rootNode);
this.addComponent(RenderComponent.class, rc);
// Set the Z-buffer state on the root node
ZBufferState zbuf = (ZBufferState)rm.createRendererState(StateType.ZBuffer);
zbuf.setEnabled(true);
zbuf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
rootNode.setRenderState(zbuf);
// Set the wireframe state on the root node
// WireframeState wf = (WireframeState)rm.createRendererState(StateType.Wireframe);
// wf.setEnabled(true);
// rootNode.setRenderState(wf);
MaterialState ms = (MaterialState)rm.createRendererState(StateType.Material);
ms.setAmbient(new ColorRGBA(0.25f, 0, 0.5f, 0.40f));
ms.setDiffuse(new ColorRGBA(0.25f, 0, 0.5f, 0.40f));
ms.setMaterialFace(MaterialState.MaterialFace.FrontAndBack);;
//ms.setSpecular(new ColorRGBA(1f, 1, 1f, 1f));
ms.setEnabled(true);
rootNode.setRenderState(ms);
BlendState bs = (BlendState)rm.createRendererState(StateType.Blend);
bs.setEnabled(true);
bs.setBlendEnabled(true);
bs.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
bs.setTestEnabled(true);
bs.setTestFunction(BlendState.TestFunction.GreaterThan);
rootNode.setRenderState(bs);
CellTransform transform = cell.getWorldTransform();
// Draw an arrow that mimics the light position --direction still under
//construction.
TextLabel2D label = new TextLabel2D(name,
Color.black, Color.white, 1.0f, true, Font.getFont("SANS_SERIF"));
Vector3f direction = directionalLight.getDirection();
Vector3f position = lightNode.getLocalTranslation();
Vector3f labelPosition = new Vector3f(position.x, position.y + 3, position.z);
Arrow arrow = new Arrow("Arrow", 3, 0.5f);
Node rotatedOnX = new Node("Rotated For Arrow");