I have exported the obj from blender. The model contains many objects with all unique names. The obj file looks like this:
o Lower_Leg_L_Lower_Leg_1
v 0.592870 -3.073410 0.034250
v 0.611490 -3.074640 -0.095880
v 0.433000 -3.074250 -0.043560
v 0.480600 -3.072670 0.118800
v 0.340450 -3.072860 0.108250
I can convert to j3o file format without any errors. I can also load the model into the scene without any problems. However, I want to change the color of different parts of the model. RIght now, I can only change the entire model's color. If I try this
[java]Geometry submesh = (Geometry) newBody.getChild("Lower_Leg_L_Lower_Leg_1");[/java]
I get null returned.
Any ideas of what I need to do in order for JME to recognize separate objects loaded from a model?
Thanks
normen said:
The objects are divided by material so creating different materials per mesh part should result in multiple geometries.
When I export with a material; the material is set in the mtl file. When I try to convert from obj+mtl to .j3o, I get a null pointer exception. Any ideas of why this might be? Note, the obj file contains usemtl (null) throughout. In order to get jme to convert to j3o without mtl, I have to delete the lines with usemtl (null).
The material-library-file must have the name it has in the first few lines of the obj-file.
mtllib yourfile.mtl
The problem why your code doesn’t work is following:
according to obj-specification, you can separate your model into sub-models by using the “o” tag.
reading OBJLoader.java you will see there is no separation by the “o” tag. jme3 only separates the model by the various materials used and it names the sub-spatials after the materials.
This “feature” isn’t implemented in jme3 (yet, I hope).
Thanks doe300. I have found that I needed to apply a material to all objects in Blender then export. Its working now! The naming of the submesh seems to be something like this