I export a model from Blender to the jme xml format and then I load it with the binaryreader. I put SharedNodes from this original into my scene.
When I change the RenderState of one of these nodes or a parent node, nothing happens. I can only change something if I go down in the hierarchy of the node until I reach the mesh and call RenderState functions from the mesh.
But shouldn't I be able to change the Renderstate from the parent down to every mesh?
Hope someone can help me…
After you change the RenderState of a node do you call updateRenderState on that node?
yes, I update the renderstate
this is the code where I want to change the renderstate. This way it works ( if I go down the hierarchy in the while loop, and change there the state). The part with the comments alone doesent work.
Node pickedNode = this.pr.getPickData(i).getTargetMesh().getParent().getParent().getParent();
System.out.println("resultN: " + pickedNode);
MaterialState ms = this.display.getRenderer().createMaterialState();
ms.setEmissive(new ColorRGBA(0, 1, 0, 1));
Spatial spatial = pickedNode;
while (spatial.getType() == Spatial.NODE)
spatial = ((Node)spatial).getChild(0);
Maybe it didn't work setting it on the Node because the spatial childeren already had a MaterialState?
this doesent change anything, too:
but does it matter if the node already has a renderstate? In this case doesn't jme replace the old one?
In the xml file of my model I can see that there is already a MaterialState:
<?xml version="1.0" encoding="UTF-8" ?>
I'm not talking about the Node (where it will be replaced, and no need to call clearRenderState() before that either). I'm talking about the Spatial attachted to the Node.
A parent Node's RenderState does not override that of it's Spatial (or Node) childeren. It's merely used if no such state is set. (Though for some type of states, RenderStates can be combined, eg. LightState)
As you can see in the XML the material state is inside <mesh/> so it belongs to the Spatial (the <mesh/>), not the Node (<node/>).
With your old code you set the RenderState of the Node, which only changes the RenderState of all childeren of that Node that do not have their own RenderState. With your new code, you replace the RenderState of the Spatial itself, which as you see, does work. So alternativly, you could set it for Node, and clear the MaterialState of all the childeren.
I understand. :lol:
Thank you for your help!!