This exception persists despite the fact that the different spatials have got their own classes from where they receive their materials. Perhaps someone could help me solve this issue?
How do you create Materials in those classes?Do you pass it by arguments?
It’s not easy to help you without having any code.
The first screenshot reveals the classes within the project and the subsequent reveal how materials (usually referred to as “mat”) are assigned to the meshes (referred to as “mesh”).
Well i have examined your code in-depth but this should work,are you sure you have no more animated models with materials?
Basically, nothing more of that kind. Either way, I don’t see how any meshes of shown classes get to use the same instances of materials.
I wish these were actual code blocks so that I could quote them…
But every time you call node.setMaterial() you are potentially transferring that ONE material instance to every Geometry child. Nodes don’t have materials. Node.setMaterial() is just a convenience method that sets that material on every Geometry child in that Node’s subtree.
That’s right,models are probably split into different geometries and that’s the issue.
I turned the meshes into nodes so I could attach particle emitters to them.
They were already nodes… if you load something and can cast it to a node then it’s a node. If it has more than one Geometry child then calling setMaterial() on the node will set the same instance for both children.
The interesting thing is that JME is supposed to handle this for you automatically if you didn’t set any materials as materials only get cloned if there is no hardware skinning detected.
Edit: else they are deep cloned if hardware skinning is detected. So try not setting your own materials at all and just use what was loaded.
So try not setting your own materials at all and just use what was loaded.
In other words, I should make it so my models are imported with textures automatically, without specifically writing that in the code?
This conversation is very frustrating. That’s not what I said at all.
“You should not do this bad thing.” “Oh, so you are saying I should let all the babies die?”
Good luck with your game.
So could please explain what you meant by this?
I can post the code blocks if it’s necessary.
From you screenshot, you no longer load your model from .xbuf or .j3o. is it right ?
I guessed you had this error with the xbuf Model viewer, because you originaly posted the bug in its topic (sorry for late reply) ?
I’m currius, because this is a bug the xbuf loader had, and I fixed it with some kind of clone + material replicator. But since the loader was refactored, so it’s possible the bug was come back under some condition.
For now, I’m simply using models exported using blender2ogre.
In the previous thread my problem was inability to import models into the Spatial Explorer from Blender but now that works. (HUGE THANKS TO YOU!!!)
To help you debug, you could write a SceneGraphVisitor, that dump material (name + hashCode) of every geometry
This appears to be very complicated. Isn’t there a simple solution I could use to resolve this whole issue?
nothing complex (something like pseudo java, I’m not on my dev desktop):
root.depthFirstTraversal(new SceneGraphVisitorAdapter(){
@Override
public void visit(Geometry geom){
System.out.println("material of " + geom.getName() + " => " + geom.getMaterial().name() + " .. " + geom.getMaterial().hashCode());
}
});
Ok, but is there something I can do to avoid this in the future?