Yes, midnight...but that's not a problem. I'm only sleeping around 5-6 hours during the week anyway... :wink:
To your problem: I can't spot anything wrong in the code you've posted (that doesn't mean that there isn't, of course). So i did a quick and dirty modification of another example to mimic this behaviour and it works fine for me. Here is the code (maybe it's helpful to find out what's wrong with your code):
import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import java.awt.event.*;
import com.threed.jpct.util.*;
public class MoveTest {
public static void main(String[] args) throws Exception {
MoveTest mt = new MoveTest();
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);
int bid = tm.getTextureID("base");
int did = tm.getTextureID("decal");
Object3D plane = new Object3D(9);
plane.setCulling(Object3D.CULLING_DISABLED);
int bs = 0;
// Base texture only
TextureInfo tInf1 = new TextureInfo(bid, -1, -1, 2, -1, -1, 2);
TextureInfo tInf2 = new TextureInfo(bid, 2, -1, 2, 2, -1, 2);
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, 25),
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, 25),
new SimpleVector(10, -10, 30), tInf1);
plane.addTriangle(new SimpleVector(0, 0, 25), 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, 25),
tInf1);
plane.addTriangle(new SimpleVector( -10, 10, 30),
new SimpleVector(0, 10, 30), new SimpleVector(0, 0, 25),
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, 25), 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);
plane.rotateX( (float) Math.PI / 2f);
plane.rotateMesh();
plane.setRotationMatrix(new Matrix());
w.addObject(plane);
plane.build();
Object3D o2 = Primitives.getCone(0.25f);
o2.rotateX( (float) Math.PI / 2f);
o2.rotateMesh();
o2.setRotationMatrix(new Matrix());
w.addObject(o2);
o2.setOrigin(plane.getTransformedCenter());
o2.translate(0, -10, 0);
o2.build();
plane.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
o2.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
w.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 10);
w.getCamera().moveCamera(Camera.CAMERA_MOVEDOWN, 10);
w.getCamera().lookAt(o2.getOrigin());
KeyMapper km = new KeyMapper();
float yRot = 0;
SimpleVector elr = new SimpleVector(0.25f, 0.25f, 0.25f);
while (!Display.isCloseRequested()) {
int key = 0;
KeyState keys = null;
// place
SimpleVector dd = new SimpleVector(0, 1, 0);
float dist = plane.calcMinDistance(o2.getTransformedCenter(), dd, 40);
if (dist != Object3D.COLLISION_NONE) {
dd.scalarMul(dist - 0.5f);
o2.translate(dd);
}
// rotateY
o2.getRotationMatrix().setIdentity();
o2.rotateY(yRot);
if ( (bs & 1) == 1) {
yRot += 0.1f;
}
if ( (bs & 2) == 2) {
yRot -= 0.1f;
}
//move
if ( (bs & 4) == 4) {
SimpleVector a = o2.getZAxis();
a.scalarMul(0.25f);
a = o2.checkForCollisionEllipsoid(a, elr, 5);
o2.translate(a);
}
if ( (bs & 8) == 8) {
SimpleVector a = o2.getZAxis();
a.scalarMul( -0.25f);
a = o2.checkForCollisionEllipsoid(a, elr, 5);
o2.translate(a);
}
do {
keys = km.poll();
if (keys != KeyState.NONE) {
key = keys.getKeyCode();
if (key == KeyEvent.VK_W) {
bs ^= 4;
}
if (key == KeyEvent.VK_S) {
bs ^= 8;
}
if (key == KeyEvent.VK_A) {
bs ^= 2;
}
if (key == KeyEvent.VK_D) {
bs ^= 1;
}
}
}
while (keys != KeyState.NONE);
fb.clear();
w.renderScene(fb);
w.draw(fb);
fb.displayGLOnly();
Thread.sleep(10);
}
km.destroy();
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
System.exit(0);
}
}