Main Menu
Menu

Show posts

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

Messages - McJug

#1
Support / Re: Two questions.. Serialization/Lights
July 02, 2012, 08:48:00 PM
Aha! Thanks a lot! :)
#2
Support / Re: Two questions.. Serialization/Lights
July 02, 2012, 08:33:22 PM
Sorry, removed the includes and stuff. Line 62 is the bottom of the constructor


world.getCamera().lookAt(sonic[1].getTransformedCenter());
#3
Support / Re: Two questions.. Serialization/Lights
July 02, 2012, 08:06:09 PM
Full code listing:


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);
}
}
#4
Support / Re: Two questions.. Serialization/Lights
June 27, 2012, 03:18:53 PM
My application is package com.codeturkey.modelrenderer. This only happens when I add the two lines to merge the meshes and to add the merged model to the world, those are the only two lines I add.

"Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NullPointerException
        at com.codeturkey.modelrenderer.ModelRenderer.<init>(ModelRenderer.java:62)
        at com.codeturkey.modelrenderer.ModelRenderer.main(ModelRenderer.java:26
)
        ... 5 more"

EDIT: I'm using Windows and rarely use CmdLine, I dont know how to access those "... 5 more" messages.
#5
Support / Re: Two questions.. Serialization/Lights
June 27, 2012, 02:12:25 PM
Oh I was trying to load the serialized data on the desktop version. However the second error message is from trying a merge the meshes of a .OBJ file not a serialized file.
#6
Support / Re: Two questions.. Serialization/Lights
June 27, 2012, 12:27:37 AM
So.. I'm trying to load my serialized data and I'm getting:

"No octree found in serialized data!
java.lang.ArrayIndexOutOfBoundsException: 49787
    at com.threed.jpct.Object3D.recreateTextureCoords(Unknown Source)
    at com.threed.jpct.Object3D.build(Unknown Source)
    ...."

EDIT: I'm also getting exception's while trying to display an Object3D returned by mergeAll(Object3D[]).

"Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ...."
#7
Support / Re: Two questions.. Serialization/Lights
June 25, 2012, 10:06:28 PM
Brilliant! Just what I was after! Thanks a lot :)
#8
Support / Re: Two questions.. Serialization/Lights
June 25, 2012, 08:52:46 PM
Thanks, understanding the format helped a lot! I seem to have got my serialization working; but I see a large increase in file size when merging the meshes (ie. around normal file size), is this normal?
#9
Support / Two questions.. Serialization/Lights
June 25, 2012, 03:50:58 PM
Starting with the serialization issue:

I was making a quick GUI serialization tool last night, and realised I did not fully understand the LoadOBJ parameters. I read the Wiki but do not quite understand the language used. My interpretation is that Textures are referenced inside the .Obj file, and that the material file is something different entirely? Currently what I'm doing is, getting InputStreams for both files, using LoadOBJ, using build() and strip(), and serialising, is that correct?

The lighting issue:

Does the default setup/shader only support one light? I thought I had read that it supported more, but I cant seem to get any more working.

Thanks in Advance ;)

EDIT: Just discovered the shader only supports one light, but could still do with some help understanding the serialiser.