Hi,
I’m learning about SimpleGame and I tried to create a GameState using scene from “JME 2.X - Material Tutorial 3 - Object transparency”.
The problem is that the same code from this tutorial is rendered differently when used in a SimpleGame vs in a GameState (to make it more readable I render only 2 teapots):
SimpleGame
GameState
Here’s the code for the GameState:
public class TransparentScene extends GameState
{
Node rootNode; //A root node for our GameState, just like SimpleGame has.
LightState lightState; //A light to shine on our box.
DirectionalLight myLight; //The light that plugs into the LightState
/**
* A node to rotate two teapots at a time.
*/
private Node teapots;
/**
* Initialization code of the tutorial
*/
protected TransparentScene()
{
rootNode = new Node("t3h n0d3zk");
// hide the mouse cursor
MouseInput.get().setCursorVisible(false);
lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState(); //Set up a lightState
// our light
final PointLight light = new PointLight();
light.setDiffuse(ColorRGBA.white);
light.setSpecular(ColorRGBA.white);
light.setLocation(new Vector3f(100.0f, 100.0f, 100.0f));
light.setEnabled(true);
// attach the light to a lightState
lightState.attach(light);
teapots = new Node("teapots");
// first teapot
final Teapot teapot = new Teapot("teapot");
teapot.setLocalTranslation(0.0f, -2.0f, 6.0f);
teapots.attachChild(teapot);
// second teapot
final Teapot farTeapot = new Teapot("farTeapot");
farTeapot.setLocalTranslation(0.0f, -2.0f, -6.0f);
teapots.attachChild(farTeapot);
// attach it to the root node
rootNode.attachChild(teapots);
rootNode.updateRenderState();
}
@Override
public void render(float tpf)
{
DisplaySystem.getDisplaySystem().getRenderer().clearBuffers(); //Standard render cycle, clear buffers then render
rootNode.draw(DisplaySystem.getDisplaySystem().getRenderer());
}
@Override
public void cleanup()
{
//Do nothing
}
@Override
public void update(float tpf)
{
rootNode.updateGeometricState(tpf, true); //Stanard update cycle for geometry and rendering
rootNode.updateRenderState();
}
}
What to do to get same results using GameState?