Hi, I'm just wondering how to do this, I have my mouse picking working but I can't seem to get the movement working properly
runner = new Box("Runner", new Vector3f(), 3, 8, 3);
runner.setModelBound(new BoundingBox());
runner.updateModelBound();
runner.addController(new Controller() {
private static final long serialVersionUID = 1L;
public void update(float time) {
runner.getLocalRotation().mult(Vector3f.UNIT_Z, rDirection);
Vector3f dir = new Vector3f();
runner.getLocalTranslation().add(BufferUtils.getVector3Array(pointSelection.getVertexBuffer(0))[0], dir);
if (runner.getLocalTranslation().x >= BufferUtils.getVector3Array(pointSelection.getVertexBuffer(0))[0].x){
if (runner.getLocalTranslation().z >= BufferUtils.getVector3Array(pointSelection.getVertexBuffer(0))[0].z){
dir.set(0f, 0f, 0f);
}
return;
}
dir.normalizeLocal();
runner.getLocalTranslation().addLocal(dir.multLocal(rSpeed*time));
Vector3f pos = runner.getLocalTranslation();
float height = terrain.getHeight(pos);
runner.setLocalTranslation(pos.x, height+8, pos.z);
System.out.println("Direction : "+dir);
}
});
rootNode.attachChild(runner);
this only works if the runner is at (0,0,0), I just can't seem to figure out how to create a vector between runner.getLocalTranslation and BufferUtils.getVector3Array(pointSelection.getVertexBuffer(0))[0] which is the vector3f of my mousepick. I feel like I've hit a wall and it's probably something simple, thanks for any help.