Using the code below, I attach certain quasi-static objects into a batchNode:
[java]
else if (type.equals(rainbow)) {
Material mateo = new Material(myApp.getAssetManager(),“Common/MatDefs/Misc/Unshaded.j3md”);
Geometry boxGeom = (Geometry) mySpatial;
//boxGeom.setMaterial(myApp.getAssetManager().loadMaterial("/Models/myOwnMaterial.j3m"));
boxGeom.setMaterial(mateo);
batch.attachChild(boxGeom);
}
[/java]
this works great except there is no material on my object. So I created my own material (myOwnMaterial.j3m):
[java]
Material shiny bumpy rock : Common/MatDefs/Misc/ShowNormals.j3md {
MaterialParameters {
Shininess: 8.0
NormalMap: Textures/bump_rock_normal.png
UseMaterialColors : true
Ambient : 0.0 0.0 0.0 1.0
Diffuse : 0.0 0.117 0.8 1.0
Specular : 1.0 1.0 1.0 1.0
}
}
[/java]
and un-commented the code to set the material of these objects to myOwnMaterial.j3m
now I literally have triple the number of objects by changing the material. I don’t understand what’s the relation and why this is happening??? As silly as it may sound: Is Material related to object quantity???
Batch node can only batch together objects with the same material. I read somewhere recently that there are limitations in detecting what materials are actually “the same” although I don’t remember the specifics. Try setting the material on your batch node after batching the geometries together?
I don’t think you can set material on something already batched. All my objects do have the same material.