3DS Model - Setting MaterialState


i've created a box using SketchUp, exported it as a 3ds model and loaded it into jme. Now i'm triying to change the color of one of it's groups.

I didn't use obj files because of the lack of 'group' support. When i request the node's children from an obj file i just receive groups with names like tempX and not the originally assigned ones. The only advantage was that i managed to color the box lid.

Load a 3ds model file:

    URL model=HelloModelLoading.class.getClassLoader().getResource("Box.3ds");
    FormatConverter converter = new MaxToJme();
    ByteArrayOutputStream BO=new ByteArrayOutputStream();
    converter.convert(model.openStream(), BO);
    Node box=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
    box.setModelBound(new BoundingSphere());

Retrieve lid-child:

    Spatial lid =  box.getChild("lid");

Until this point everything works fine. When i try to remove the lid by 's.removeFromParent()' it works perfectly.

Setting MaterialState:

    MaterialState ms = display.getRenderer().createMaterialState();
    ms.setEmissive(new ColorRGBA(0f, .2f, 0f, 1));

But at this point nothing happens. When i used the obj file in a similiar way, my lid would now be green.

I found this similiar thread but it didn't help me very much:

Any ideas? I just started working with 3d models and the jme ...so be gentle ;)

I've also tryed to call lid.updateRenderState() or box.updateRenderState() at various points but it didn't do the trick.

After hours of searching for a solution i finally found it.


chirstius wrote:
Created a greatly simplified test case and through trial and error found a "hidden" (to me) node which is where I needed to be clearing and setting the texture and material states.

I must say, some kind of scenegraph dumper/browser would have been very helpful here.  Once I found the node I was able to verify texture coords were indeed set correctly and the rest was butter.  Sorry for the idiocy.

...and that was exactly my problem.

SketchUp exported a model which when loaded into JME had the following scenegraph:

'box' (chosen name in sketchup)
'case'    'lid'
|             |
v            v
various subgroups

So when i tried to color the whole model by getting all children by calling getChildren i only got 'box'. Same problem wenn i tried to color 'lid'. I didn't retrieve the leaf by calling getChild("lid") which is called something like 'lid##0'.
And when i change the MaterialState of any node which is not a leaf, nothing happens...which explains it.


there is a very good scenegraph viewer:


(@erlend: Scenemonitor is missing at Overview: Current Projects)