i have a quad and i need to do the following things:
- multitexture the quad with (1) a background texture that wraps and (2) a foreground decal that doesn't wrap
- my foreground decal need to be able to move to any x,y position within the quad
- adjust the length of the quad at will, while avoiding stretching (setVertexBuffer and getTextureBuffer work great for that)
and yes i've looked at TestMultitexture… here's what i have so far. problems: it wraps both textures, not just t0; i don't know how to move t1 to an arbitrary x,y position
any help will be greatly appreciated! this forum hasn't failed me yet
//INIT THE QUAD W/ TEXTURE ETC.
private void init(Quaternion rotation) {
quadBackground = new Quad("quadBackground", 0, 0);
quadBackground.setModelBound(new BoundingBox());
quadBackground.updateModelBound();
quadBackground.setLightCombineMode(LightState.OFF);
TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
ts.setEnabled(true);
Texture t0 = getTexture(KSJMETexture.DIR_TEXTURES + "/" + textureFile);
t0.setWrap(Texture.WM_WRAP_S_WRAP_T); //wrap mode
ts.setTexture(t0, 0);
Texture t1 = getTexture(KSJMETexture.DIR_TEXTURES + "/" + "loc_move3.png");
t1.setWrap(Texture.WM_ECLAMP_S_ECLAMP_T); //wrap mode
t1.setApply(Texture.AM_DECAL);
ts.setTexture(t1, 1);
quadBackground.copyTextureCoords(0, 0, 1); //copyTextureCoords(int batchIndex, int fromIndex, int toIndex)
quadBackground.setRenderState(ts);
quadBackground.updateRenderState();
this.attachChild(quadBackground);
this.setLocalRotation(rotation);
}
//CHANGE THE LENGTH OF THE LINE
public void setLength(float length) {
// System.out.println("t[Line] setLength(" + length + ")");
//changing VertexBuffer changes size of the quad
float[] f = { -length / 2, h / 2, 0,
-length / 2, -h / 2, 0,
length / 2, -h / 2, 0,
length / 2, h / 2, 0 };
quadBackground.setVertexBuffer(0, BufferUtils.createFloatBuffer(f));
quadBackground.setLocalTranslation(length / 2, 0, 5); //re-justify the quad to its anchor point
//number of times the texture wraps
FloatBuffer tBuf0 = quadBackground.getTextureBuffer(0, 0); //getTextureBuffer(int batchIndex, int textureUnit)
tBuf0.clear();
tBuf0.put(0).put(h/h); //i.e. 1 wrap
tBuf0.put(0).put(0);
tBuf0.put(length/h).put(0); //wrap to scale
tBuf0.put(length/h).put(h/h);
}