Hi. I put a Quad as background of my application using QUEUE_ORTHO, and put a normal cube with transparency.
I want that my cube show the quad texture in the transparency, but I don't know how.
protected void simpleInitGame() {
// CONFIGURE WALLPAPER
int border = 20;
Quad wallpaper = new Quad("Background", display.getWidth()-border, display.getHeight()-border);
wallpaper.setLocalTranslation(new Vector3f(display.getWidth() / 2, display.getHeight() / 2, -1.0f));
wallpaper.setRenderQueueMode(Renderer.QUEUE_ORTHO);
wallpaper.setLightCombineMode(LightCombineMode.Off);
URL url_wallpaper = BlendStateTest.class.getClassLoader().getResource("jmetest/data/texture/north.jpg");
Texture tex = TextureManager.loadTexture(url_wallpaper,
Texture.MinificationFilter.Trilinear,
Texture.MagnificationFilter.Bilinear);
TextureState ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
ts.setTexture(tex);
wallpaper.setRenderState(ts);
wallpaper.updateRenderState();
wallpaper.setModelBound(new BoundingBox());
wallpaper.updateModelBound();
rootNode.attachChild(wallpaper);
// CONFIGURE SAMPLE BOX
Vector3f min = new Vector3f(-4, -3, -2);
Vector3f max = new Vector3f(4, 3, 2);
Box box = new Box("box1", min, max);
MaterialState boxMS = display.getRenderer().createMaterialState();
boxMS.setDiffuse(new ColorRGBA(0, 0, 100, 0.5f));
boxMS.setAmbient(new ColorRGBA(0, 50, 100, 0.5f));
box.setRenderState(boxMS);
BlendState blend = display.getRenderer().createBlendState();
blend.setSourceFunctionAlpha(SourceFunction.SourceAlpha);
blend.setDestinationFunctionAlpha(DestinationFunction.One);
blend.setEnabled(true);
blend.setBlendEnabled(true);
blend.setTestEnabled(true);
blend.setTestFunction(BlendState.TestFunction.GreaterThan);
box.setRenderState(blend);
box.updateRenderState();
rootNode.attachChild(box);
}
I don't know if this is possible, or how can I get this effect.
Some ideas??
I'm a bit newbie with jME, :|