I made a uv wrapper image for My model in blender. The image seems to wrap ok in blender, but when I use the following code, the image doesn't wrap right.
Any ideas what I am missing?
import com.threed.jpct.*;
import javax.swing.*;
public class HelloWorldSoftware {
private String[] textures = {"ng"};
private String thingName = "untitled";
private int thingScale = 1;//end
private World world;
private FrameBuffer buffer;
private Object3D thing;
private JFrame frame;
public static void main(String[] args) throws Exception {
new HelloWorldSoftware().loop();
}
public HelloWorldSoftware() throws Exception {
frame = new JFrame("Blender Model Loading");
frame.setSize(700, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
world = new World();
world.setFogging(World.FOGGING_DISABLED);
world.setFoggingMode(World.FOGGING_PER_PIXEL);
world.setAmbientLight(255,255,255);
for (int i = 0; i < textures.length; ++i) {
TextureManager.getInstance().addTexture(textures[i] + ".jpg", new Texture("res/" + textures[i] + ".jpg"));
}
thing = loadModel("res/" + thingName + ".3ds", thingScale);
thing.build();
//thing.calcTextureWrapSpherical();
thing.setTexture("ng.jpg");
world.addObject(thing);
world.getCamera().setPosition(0, 0, 0);
world.getCamera().lookAt(thing.getTransformedCenter());
}
private void loop() throws Exception {
buffer = new FrameBuffer(700, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
while (frame.isShowing()) {
SimpleVector place = new SimpleVector();
thing.rotateY(0.03f);
thing.rotateX(0.02f);
buffer.clear(java.awt.Color.BLACK);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.display(frame.getGraphics());
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
frame.dispose();
System.exit(0);
}
private Object3D loadModel(String filename, float scale) {
Object3D[] model = Loader.load3DS(filename, scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;
for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float)( -.5*Math.PI));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.build();
}
return o3d;
}
}