When using GameStates, I am able to render a texture on an object (with TextureState), but when I scrap that and try to use MaterialState or RenderState instead, I don't get any results (my object just appears white). Why is this? Must I add a LightState or something?
if u r using custom game states which extend basic game states, yes u need to setup ur own light state.
if u can post some code, it might be easier for me to find out exactly where the problem is.
I am making a "window" for kicks which has a JMEDesktop on the front, another JMEDesktop on the back, and a border inbetween as a rounded box. The idea is that you can rotate the window and have other real estate on the back to put swing stuff. I create JMEDesktopStates for each of the JMEDesktops (so that I can deactivate the one on the back while it is not in use) and BasicGameState for the border.
public void makeWindow() {
// Instantiate and add the front of our window
front = new JMEDesktopState(true);
GameStateManager.getInstance().attachChild(front);
front.setActive(true);
// Instantiate and add the border of our window
border = new BasicGameState("border");
GameStateManager.getInstance().attachChild(border);
border.setActive(true);
// Instantiate and add the back of our window
back = new JMEDesktopState(true);
GameStateManager.getInstance().attachChild(back);
back.setActive(true);
width = front.getDesktop().getJDesktop().getWidth();
frontGUINode = front.getGUINode();
frontGUINode.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
frontGUINode.setLocalTranslation(0, 0, 1f);
frontGUINode.setLocalScale(new Vector3f((aspect * 24f) / width,
(aspect * 24f) / width, 1f));
frontGUINode.updateGeometricState(0, true);
frontGUINode.updateRenderState();
front.getDesktop().getJDesktop().setBackground(
new Color(255, 255, 255, 100));
borderRootNode = border.getRootNode();
borderRootNode.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
borderRootNode.setLocalTranslation(0, 0, 0f);
Vector3f extent = new Vector3f(12*aspect + 0.5f, 12 + 0.5f, 1);
RoundedBox rb = new RoundedBox("border", extent, new Vector3f(24f/200f, 24f/200f, 24f/200f), new Vector3f(24f/200f, 24f/200f, 24f/200f));
final MaterialState materialState = game.getDisplay().getRenderer().createMaterialState();
materialState.setDiffuse( new ColorRGBA( 0.5f, 0.5f, 0.9f, 0.6f ) );
final AlphaState alphaState = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
alphaState.setEnabled( true );
alphaState.setBlendEnabled( true );
alphaState.setSrcFunction( AlphaState.SB_SRC_ALPHA );
alphaState.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );
rb.setRenderState( alphaState );
rb.setRenderState( materialState );
System.out.println(rb.getRenderState(0).toString());
// LightState l = new LightState();
rb.updateRenderState();
rb.setModelBound(new BoundingSphere());
rb.updateModelBound();
borderRootNode.attachChild(rb);
borderRootNode.updateGeometricState(0, true);
borderRootNode.updateRenderState();
backGUINode = back.getGUINode();
backGUINode.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
backGUINode.setLocalTranslation(0, 0, -1f);
backGUINode.setLocalScale(new Vector3f((aspect * 24f) / width,
(aspect * 24f) / width, 1f));
backGUINode.updateGeometricState(0, true);
backGUINode.updateRenderState();
back.getDesktop().getJDesktop().setBackground(
new Color(255, 255, 255, 100));
// rotate 180 degrees to write on the back
backGUINode.getLocalRotation().fromAngleNormalAxis(FastMath.PI, new Vector3f(0, 1, 0));
}
i dont think material state would work on jmedesk top. but again i dont use jmedesktop at all. i use fenggui for gui stuff.
I'm not using materialstate on JMEDesktop, I'm using it on a roundedbox. My window consists of two JMEDesktops with a rounded box in the middle to form the border.
sry my bad.
have u tried adding a light state with a directional light into ur game state?
LightState ls = DisplaySystem.getDisplaySystem().getRenderer().createLightState();
ls.setGlobalAmbient(ColorRGBA.white);
DirectionalLight light = new DirectionalLight();
light.setDirection(new Vector3f(0,-1,0));
light.setDiffuese(ColorRGBA.white);
ls.attchLight(light);
rootNode.setRenderState(ls);
rootNode.updateRenderState();