Show ZOrderTest.java syntax highlighted
/*
* Copyright (C) 2001-2005 Pleasant nightmare studio
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package skunkworks;
import com.jme.app.SimpleGame;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.LightState;
import com.jme.scene.state.RenderState;
import com.jme.scene.state.ZBufferState;
/**
* @author: deus
* @since: May 24, 2007 10:51:57 AM
* @version: 1.0
*/
public class ZOrderTest extends SimpleGame {
protected void simpleInitGame() {
rootNode = new Node("hud");
rootNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
rootNode.setLightCombineMode(LightState.OFF);
rootNode.setRenderState(zBuffer());
rootNode.attachChild(blueQuad());
rootNode.attachChild(redQuad());
rootNode.updateRenderState();
}
private RenderState zBuffer() {
ZBufferState z = display.getRenderer().createZBufferState();
// All functions tried
z.setFunction(ZBufferState.CF_LEQUAL);
return z;
}
private Spatial redQuad() {
Quad q = new Quad("RED", 50, 50);
q.setDefaultColor(ColorRGBA.red);
q.setLocalTranslation(400, 300, 0);
// On each function, this was set to 1 or 100,
// different that on the blue quad
q.setZOrder(1);
return q;
}
private Spatial blueQuad() {
Quad q = new Quad("BLUE", 50, 50);
q.setDefaultColor(ColorRGBA.blue);
q.setLocalTranslation(430, 320, 0);
// Same as on the redQuad
q.setZOrder(5);
return q;
}
public static void main(String[] args) {
ZOrderTest test = new ZOrderTest();
test.setDialogBehaviour(FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG);
test.start();
}
}
See more files for this project here