Uploaded a new version that corrects a small bug with texture uploading. Here's an example of how to use multi texturing:
import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import javax.swing.*;
import java.awt.*;
public class MTAWT {
public static void main(String[] args) throws Exception {
MTAWT mt = new MTAWT();
mt.doIt();
}
private void doIt() throws Exception {
JFrame frame=new JFrame();
frame.setSize(320,240);
frame.show();
FrameBuffer fb=new FrameBuffer(320, 240, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
Canvas canvas=fb.enableGLCanvasRenderer(IRenderer.MODE_OPENGL);
frame.getContentPane().add(canvas);
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);
int bid=tm.getTextureID("base");
int did=tm.getTextureID("decal");
Object3D plane=new Object3D(9);
plane.setCulling(Object3D.CULLING_DISABLED);
// Base texture only
TextureInfo tInf1=new TextureInfo(bid,0,0,1,0,0,1);
TextureInfo tInf2=new TextureInfo(bid,1,0,1,1,0,1);
plane.addTriangle(new SimpleVector(-10,-10,30), new SimpleVector(-10,0,30), new SimpleVector(0,-10,30), tInf1);
plane.addTriangle(new SimpleVector(-10,0,30), new SimpleVector(0,0,30), new SimpleVector(0,-10,30), tInf2);
// 2nd stage used, modulate
tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_MODULATE);
tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_MODULATE);
plane.addTriangle(new SimpleVector( 0, -10, 30), new SimpleVector( 0, 0, 30), new SimpleVector(10, -10, 30), tInf1);
plane.addTriangle(new SimpleVector( 0, 0, 30), new SimpleVector(10, 0, 30), new SimpleVector(10, -10, 30), tInf2);
// 2nd stage used, add
tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_ADD);
tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_ADD);
plane.addTriangle(new SimpleVector(-10,0,30), new SimpleVector(-10,10,30), new SimpleVector(0,0,30), tInf1);
plane.addTriangle(new SimpleVector(-10,10,30), new SimpleVector(0,10,30), new SimpleVector(0,0,30), tInf2);
// 2nd stage used, blend
tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_BLEND);
tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_BLEND);
plane.addTriangle(new SimpleVector( 0, 0, 30), new SimpleVector( 0, 10, 30), new SimpleVector(10, 0, 30), tInf1);
plane.addTriangle(new SimpleVector( 0, 10, 30), new SimpleVector(10, 10, 30), new SimpleVector(10, 0, 30), tInf2);
w.addObject(plane);
w.buildAllObjects();
while (frame.isActive()) {
fb.clear();
w.renderScene(fb);
w.draw(fb);
fb.displayGLOnly();
plane.rotateY(0.01f);
canvas.repaint();
Thread.sleep(10);
}
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
System.exit(0);
}
}