Hello I am new Jmonkey. I’m trying to create a scene for a 2D game turrets.
I am using TestOrtho as an example. The problem I have is that when I add the background to the scene, the model disappears
Here is the code:
[java]// Import the model
Spatial pezGlobo = assetManager.loadModel(“Models/PezGlobo/PezGlobo.j3o”);
pezGlobo.scale(0.5f, 0.5f, 0.5f);
pezGlobo.setLocalTranslation(0f, 0f, 1f);
guiNode.attachChild(pezGlobo);
// Add a light to make the model visible
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
guiNode.addLight(sun);
// Create background image
Picture imagenFondo = new Picture(“Fondo”);
imagenFondo.move(0, 0, -1); // make it appear behind stats view
imagenFondo.setPosition(0, 0);
imagenFondo.setWidth(settings.getWidth());
imagenFondo.setHeight(settings.getHeight());
imagenFondo.setImage(assetManager, “Scenes/ImagenFondo.png”, false);
// attach geometry to orthoNode
guiNode.attachChild(imagenFondo);[/java]
Obviously the gui isn’t in the background… Why would it be? oO
→ http://hub.jmonkeyengine.org/groups/graphics/forum/topic/setting-a-stationary-background-image-in-jme3/
@normen said:
Obviously the gui isn't in the background.. Why would it be? oO
I thought the location was enough.
[java]
pezGlobo.setLocalTranslation(0f, 0f, 1f);
imagenFondo.move(0, 0, -1); // make it appear behind stats view
[/java]
anyway I will try your suggestion
@hickaru said:
I thought the location was enough.
Its still in the gui node then.. And the gui is in front as I said.
@hickaru said:
anyway I will try your suggestion
thanks xD
still I have problems with the background image, try the solution you gave me but I get this error.
Uploaded with ImageShack.us
The Source Code:
[java]
public void simpleInitApp() {
// Instantiated the object image
Picture p = new Picture(“Background”);
// Set te image for the Object
p.setImage(assetManager, “Scenes/ImagenFondo.png”, false);
// Set the size of the image
p.setWidth(settings.getWidth());
p.setHeight(settings.getHeight());
// Set the position of the image on the origin
p.setPosition(0,0);
p.updateGeometricState();
// Create the “pre viewport”
ViewPort pv = renderManager.createPreView(“Background”, cam);
pv.setClearFlags(true, true, true);
pv.attachScene§;
viewPort.setClearFlags(false, true, true);
}
[/java]