Here you go: *edit: download removed!*
It includes both changes, i.e. an extended setPolygonTexture(...) in the PolygonManager and the possibility to set a texture to clamping mode. In OpenGL, this is bound to the texture, so i had to add the method to Texture too, albeit i'm not really happy with that. Anyway...i hope i haven't broken anything else as i haven't tested this version very much. Here's some example code, that moves a decal over a plane using multi texturing only:
import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import java.awt.event.*;
import com.threed.jpct.util.*;
public class MTMove {
public static void main(String[] args) throws Exception {
MTMove mt = new MTMove();
mt.doIt();
}
private void doIt() throws Exception {
FrameBuffer fb=new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
fb.enableRenderer(IRenderer.RENDERER_OPENGL);
World w=new World();
w.setAmbientLight(255,255,255);
TextureManager tm=TextureManager.getInstance();
Texture base=new Texture("base.jpg");
Texture decal=new Texture("decal.jpg");
tm.addTexture("base", base);
tm.addTexture("decal", decal);
decal.enableGLClamping();
int bid=tm.getTextureID("base");
int did=tm.getTextureID("decal");
Object3D plane=new Object3D(9);
plane.setCulling(Object3D.CULLING_DISABLED);
TextureInfo tInf1 = new TextureInfo(bid, -1, -1, 2, -1, -1, 2);
tInf1.add(did, -1, -1, 2, -1, -1, 2, TextureInfo.MODE_ADD);
TextureInfo tInf2 = new TextureInfo(bid, 2, -1, 2, 2, -1, 2);
tInf2.add(did, 2, -1, 2, 2, -1, 2, TextureInfo.MODE_ADD);
plane.addTriangle(new SimpleVector( -10, -10, 30), new SimpleVector( -10, 10, 30), new SimpleVector(10, -10, 30), tInf1);
plane.addTriangle(new SimpleVector( -10, 10, 30), new SimpleVector(10, 10, 30), new SimpleVector(10, -10, 30), tInf2);
w.addObject(plane);
w.buildAllObjects();
KeyMapper km=new KeyMapper();
PolygonManager pm = plane.getPolygonManager();
float u=-1;
float v=-1;
int bs=0;
while (!Display.isCloseRequested()) {
fb.clear();
w.renderScene(fb);
w.draw(fb);
fb.displayGLOnly();
KeyState key=null;
while(key!=KeyState.NONE) {
key = km.poll();
int keyc=key.getKeyCode();
if (keyc == KeyEvent.VK_W) {
bs ^= 4;
}
if (keyc == KeyEvent.VK_S) {
bs ^= 8;
}
if (keyc == KeyEvent.VK_A) {
bs ^= 2;
}
if (keyc == KeyEvent.VK_D) {
bs ^= 1;
}
}
if ((bs & 4) == 4) {
u += 0.01f;
}
if ((bs & 8) == 8) {
u -= 0.01f;
}
if ((bs & 2) == 2) {
v += 0.01f;
}
if ((bs & 1) == 1) {
v -= 0.01f;
}
if (bs!=0) {
tInf1 = new TextureInfo(bid, -1, -1, 2, -1, -1, 2);
tInf1.add(did, u, v, u + 3, v, u, v + 3, TextureInfo.MODE_ADD);
tInf2 = new TextureInfo(bid, 2, -1, 2, 2, -1, 2);
tInf2.add(did, u + 3, v, u + 3, v + 3, u, v + 3, TextureInfo.MODE_ADD);
pm.setPolygonTexture(0, tInf1);
pm.setPolygonTexture(1, tInf2);
}
Thread.sleep(10);
}
km.destroy();
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
System.exit(0);
}
}