Question about using getChild() with .OBJ files

Hello, I have a problem with accessing parts of the geometry for an .OBJ asset I am loading. In 3DS, I have named the different objects, and when exporting to .OBJ, I get a structure looking like this;


object MyObject


followed by lots of what I assume to be vertex definitions (v -36.3748 -4.5192 -5.0073 and so on). After that you get a section starting like this:

[java]g MyObject
usemtl MetalSemi

followed by I-don’t-even. Then, the next named object starts.

I am trying to extract these specific geometries for individual manipulation in jme, but I don’t understand what getChild() actually references. It seems to reference by material, not by object. For example, if I do this:

[java] model= (Node)assetManager.loadModel(“model.obj”);
Geometry test = (Geometry)model.getChild(“MyObject”);

the Geometry will be instanced to null. If I do this:

[java] System.out.println("Num children: " + model.getChildren().size());

it returns 12, which is exactly the number of different materials defined in my .MTL file. If I do this:

[java] model= (Node)assetManager.loadModel(“model.obj”);
Geometry test = (Geometry)model.getChild(3);

I get every part of the full model geometry that has the third material defined in the .MTL file.

Is there something off with how my geometry is defined in my model? How do I reference individually named objects from a .OBJ? When working with Blender, I’m just to simply going getChild(“MyObject”) and it works fine.

Thanks in advance for any help.

Well, I’ve been able to confirm that this is how it works. The object seems to need to have a material defined that is unique to that object (in other words its own section in the .MTL file, even if the material parameters are identical to some other object).

By ensuring that each object I want to access has a material definition set up for just that object, I can now get the objects I want to using getChild(int index). However, I apparently still can’t use getChild(String name).

EDIT: Okay, the individual geometries get named modelfilename-geom-n for the 0…n different geometries. It’s jme doing this naming, it’s not in the model. The original question still stands; is getChild(String name) supported in .OBJ models?