Blender Object Loading But with Multiple Materials

Started by blenderman, March 31, 2011, 07:29:04 AM

Previous topic - Next topic

blenderman

I'm exporting an object file from Blender into my JPCT app. The object has two materials and two objects. However, only one of the materials is applied to the object. The other material is not. I manually edited the .obj file to remove the object that was correctly having the texture applied, and the texture correctly appeared for the other material.

I'm using the  jpctCollision.java example and I changed lines 98 and added the following:


               TextureManager.getInstance().addTexture("harl.jpg", new Texture("harl.jpg"));
TextureManager.getInstance().addTexture("asphalt.jpg", new Texture("asphalt.jpg"));
Object3D testing = Object3D.mergeAll(Loader.loadOBJ("untitled.obj", "untitled.mtl", 10));
testing.translate(0, -40, -60);
world.addObject(testing);


Here are the links to the files described above:
http://dl.dropbox.com/u/9609567/untitled.obj
http://dl.dropbox.com/u/9609567/untitled.mtl
http://dl.dropbox.com/u/9609567/harl.jpg
http://dl.dropbox.com/u/9609567/asphalt.jpg

I'm hoping i'm just making some dumb error here.

Thanks.

EgonOlsen

Can you post the log output? I'll look into it next week...i'm limited to the smart phone for the next few days.

blenderman

Yes, here is the output from running it for a few seconds.

Java version is: 1.6.0_24
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
Loading Texture...harl.jpg
Software renderer disposed
[ Thu Mar 31 10:52:21 PDT 2011 ] - WARNING: Unsupported Texture height (768)...resizing to a height of 256 pixels!
Loading Texture...asphalt.jpg
[ Thu Mar 31 10:52:21 PDT 2011 ] - WARNING: Unsupported Texture width (640)...resizing to a width of 256 pixels!
Loading file untitled.mtl
Text file untitled.mtl loaded...311 bytes
Processing new material None_harl.jpg!
Processing new material None_asphalt.jpg!
Loading file untitled.obj
Text file untitled.obj loaded...1775 bytes
Processing object from OBJ-file: Cube.001
Object 'Cube.001_jPCT5' created using 12 polygons and 8 vertices.
Processing object from OBJ-file: Cube
Object 'Cube_jPCT6' created using 12 polygons and 8 vertices.
Adding Lightsource: 0
Worker created using 7 queues!
93
Worker thread stopped!
Worker thread stopped!
Worker thread stopped!
Worker thread stopped!
Worker thread stopped!
Worker thread stopped!
Worker thread stopped!
Software renderer disposed


I suspect this problem exists on JPCT-AE. I'm going to port my game from PC to android, so I am more interested in JPCT-AE's behavior. I'll try it out on my phone later tonight when I have time to write the code and let you know if I still have the problem.

Thanks.

EgonOlsen

Loader code is almost the same for both versions, so i would expect the same problem. Have you tried what happens if you don't merge the objects?

blenderman

#4
Just tried changing the code to eliminate the merges. It still has the same problem.


TextureManager.getInstance().addTexture("harl.jpg", new Texture("harl.jpg"));
TextureManager.getInstance().addTexture("asphalt.jpg", new Texture("asphalt.jpg"));
for(Object3D testing : Loader.loadOBJ("untitled.obj", "untitled.mtl", 10)){
testing.translate(0, -40, -60);
world.addObject(testing);
}


I also tried adding this on the Hello World android example (I had to resize the textures and change the material name to get it going), it has the same issues.

Thanks.

EgonOlsen

Try this jar: http://www.jpct.net/download/beta/jpct.jar. It hopefully fixes the problem without introducing a new one. There was some code in the loader that nulled the materials for the former object if the parser starts to work on the next one...no idea if this was by accident or served a purpose. I can't think of one, so i've moved the code to a later position.
For AE, a fixed version can be found here: http://www.jpct.net/jpct-ae/download/alpha/jpct_ae.jar

blenderman

You rock man! Works like a charm now. Thanks for the fix. JPCT is awesome too btw.  ;D