Is BatchNode or SimpleBatchNode supposed to reduce # of objects sent to the GPU?

@.Ben. said: I meant SPATIAL, I'm sorry.

See… at best this completely missed the point. At worst, you were yelling at me that I should have known what you meant. I interpreted it as the former. I think Normen was trying to point out that it could be interpreted as the latter.

Just to get sure…

Do you reuse one material, or do you create a new one each time?

Because the comparison in the batchutil is based on the std hashCode() and not the Material.contentHashCode()/.contentEquals…

@pspeed Yeah OK I got you, but in my object creation process, I’ve been applying materials to SPATIALS (not geometries) for months and it works perfectly, except for BatchNode, stating (like I wrote earlier) something like “You have to set the material before batching.” or something close to this, I could dig the exception if it’s needed, but the only way I could make the BatchNode shut up about it is to apply the material directly on the GEOMETRY instead of the SPATIAL.

Here’s how EVERY SINGLE other object gets their material on my scene (except for the BatchNode, which throws an exception at this point):

[java]
if(node.getChild(“Grass Layer”) != null){
node.getChild(“Grass Layer”).setMaterial(grassMaterial);
}
if(node.getChild(“Grass2 Layer”) != null){
node.getChild(“Grass2 Layer”).setMaterial(grass2Material);
}
if(node.getChild(“Flower Layer”) != null){
node.getChild(“Flower Layer”).setMaterial(flowerMaterial);
}
if(node.getChild(“Flower2 Layer”) != null){
node.getChild(“Flower2 Layer”).setMaterial(flower2Material);
}
if(node.getChild(“Rock Layer”) != null){
node.getChild(“Rock Layer”).setMaterial(rockMaterial);
}
[/java]

I got mixed between the SPATIAL and the NODE, I’m sorry about this, but I don’t think it’s relevant in this issue, or is it…?

@ghoust I reuse materials for hundreds of objects. My class creates 1 new material at the beginning (like “grassMaterial” or “flowerMaterial”) and then assigns them after creating all the geometries.

EDIT: …but in the case of the BatchNode we’re talking about, instead of assigning the material to the parent spatial, I had to assign the material to individual geometries BEFORE batching of course, else it would crash.

RTZ for a sec…

Writing a simple test case is only partially about helping us help you. 90% of it is that most of the time the test case will work just fine. Then you can work on either tweaking your code to be more like the test case (or probably in this instance) tweaking the test code until it breaks like your app does. Once that happens then you will have either learned what the issue is or you can then post some complete code here for us to look at.

Otherwise, we seem to be circling the drain here.

Hmm, ok, reading you first post again… you have a problem with using BatchNode, not theGeometryBatchFactory.

The codebase in BatchNode is different, so I’m outa here… haven’t used that one so far… And that one uses Material.contentEquals()

@.Ben. said: @pspeed Yeah OK I got you, but in my object creation process, I've been applying materials to SPATIALS (not geometries) for months and it works perfectly, except for BatchNode, stating (like I wrote earlier) something like "You have to set the material before batching." or something close to this, I could dig the exception if it's needed, but the only way I could make the BatchNode shut up about it is to apply the material directly on the GEOMETRY instead of the SPATIAL.

Here’s how EVERY SINGLE other object gets their material on my scene (except for the BatchNode, which throws an exception at this point):

[java]
if(node.getChild(“Grass Layer”) != null){
node.getChild(“Grass Layer”).setMaterial(grassMaterial);
}
if(node.getChild(“Grass2 Layer”) != null){
node.getChild(“Grass2 Layer”).setMaterial(grass2Material);
}
if(node.getChild(“Flower Layer”) != null){
node.getChild(“Flower Layer”).setMaterial(flowerMaterial);
}
if(node.getChild(“Flower2 Layer”) != null){
node.getChild(“Flower2 Layer”).setMaterial(flower2Material);
}
if(node.getChild(“Rock Layer”) != null){
node.getChild(“Rock Layer”).setMaterial(rockMaterial);
}
[/java]

I got mixed between the SPATIAL and the NODE, I’m sorry about this, but I don’t think it’s relevant in this issue, or is it…?

It must be. If you set a material on a spatial then it internally traverses the entire scene graph under that spatial and sets the material on the geometries. That may be relevant. At any rate, there is no such thing as a “node with a null material” and thinking like that will only confuse you. The fact that you can set a material on a spatial is just a convenient (and confusing) utility method.

…thus this conversation.