Hi,
I’ve spent hours on this, but probably someone who knows what they’re doing can tell me what’s wrong in 1 minute or less. I am probably missing one line or property or something. :oops:
I started making a command menu with buttons (like in a typical RTS game for build units, upgrade units, etc). This is made of several buttons (Quads) in an ortho Node. My plan was to simply have each button be one Quad with 4 textures units: 0 = glow for rollover effect, 1 = button icon, 2 = disabled x-out, 3 = highlight glow. Each of these textures is a 64x64 png with transparency. I must have the wrong idea of how alphastate and multitexturing works – I just can’t get this even close to looking right.
Reduced to a simple case with just 2 textures, suppose texture 0 is
and texture 1 is . What I thought I could get was
but I can’t find the combination of properties that does it.
Here’s the short test case:
package ca.jotests;
import com.jme.app.SimpleGame;
import com.jme.image.Texture;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.AlphaState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.LoggingSystem;
import com.jme.util.TextureManager;
public class TestMultiTextureAlphaOrtho extends SimpleGame {
@Override
protected void simpleInitGame() {
LoggingSystem.getLogger().info(
"This video card has a total of " + TextureState.getNumberOfTotalUnits() + " texture units.");
LoggingSystem.getLogger().info(
"This video card has a total of " + TextureState.getNumberOfFixedUnits()
+ " fixed function pipeline texture units.");
DisplaySystem.getDisplaySystem().getRenderer().setBackgroundColor(ColorRGBA.white);
Node hud = new Node("Hud");
hud.setRenderQueueMode(Renderer.QUEUE_ORTHO);
hud.setLightCombineMode(LightState.OFF);
rootNode.attachChild(hud);
Texture tx0;
tx0 = TextureManager.loadTexture(TestMultiTextureAlphaOrtho.class.getClassLoader().getResource("ca/jotests/tx0.png"),
Texture.MM_LINEAR, Texture.FM_LINEAR);
tx0.setWrap(Texture.WM_ECLAMP_S_ECLAMP_T);
Texture tx1;
tx1 = TextureManager.loadTexture(TestMultiTextureAlphaOrtho.class.getClassLoader().getResource("ca/jotests/tx1.png"),
Texture.MM_LINEAR, Texture.FM_LINEAR);
tx1.setWrap(Texture.WM_ECLAMP_S_ECLAMP_T);
TextureState txs = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
txs.setEnabled(true);
txs.setTexture(tx0, 0);
txs.setTexture(tx1, 1);
AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
as.setEnabled(true);
as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
as.setBlendEnabled(true);
Quad q = new Quad("q", 64, 64);
hud.attachChild(q);
q.getLocalTranslation().set(160, 100, 0);
q.setRenderState(txs);
q.copyTextureCoords(0, 0, 1);
q.setRenderState(as);
}
public static void main(String[] args) {
TestMultiTextureAlphaOrtho app = new TestMultiTextureAlphaOrtho();
app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
app.start();
}
}
One texture looks like


Even if I got passed this and got the textures working, is it worth pursuing? I mean will it work to switch texture on and off within a texture state? For example, can I use textureState.removeTexture(0) to turn off a button's rollover effect, and set the texture again to turn it on?
The jME test TestMultitexture works fine for me. My gfx card has 6 texture units. I noticed TestMultitexture doesn't use an AlphaState at all in multitexturing so maybe that's where I'm confused.
Any input is appreciated. Thanks.