Aha! Thanks a lot!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
public class ModelRenderer {
private World world;
private FrameBuffer buffer;
private Object3D box;
private Object3D[] sonic;
private Object3D merged;
private JFrame frame;
public static void main(String[] args) throws Exception {
new ModelRenderer().loop();
}
public ModelRenderer() throws Exception {
frame = new JFrame("Model Renderer");
frame.setSize(800, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
world = new World();
world.setAmbientLight(0, 255, 0);
TextureManager.getInstance().addTexture("sonic", new Texture("Sonic.JPG"));
File snc = new File("Sonic.obj");
InputStream objIn = new FileInputStream(snc);
File sncMtl = new File("Sonic.mtl");
InputStream mtlIn = new FileInputStream(sncMtl);
sonic = Loader.loadOBJ(objIn, mtlIn, 1);
merged = Object3D.mergeAll(sonic);
world.addObject(merged);
world.getCamera().setPosition(0, 0, -100);
world.getCamera().lookAt(sonic[1].getTransformedCenter());
}
private void loop() throws Exception {
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
while (frame.isShowing()) {
box.rotateY(0.01f);
buffer.clear(java.awt.Color.BLUE);
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);
}
}
Page created in 0.053 seconds with 12 queries.