I have a terrain and the user can place items like rocks and fences in that terrain. Now I want to check for each placed item if it collides with another item in the same node.
I have a node named itemsNode and all items which are placed are attached to this node.
If an user places an item, I want to check if this item collides with another item to determine the item can be set at that location.
I am using another node for my terrain.
You can get the BoundingVolume of a node using node.getWorldBound() and check if two bounding volumes collides with BoundingVolume.intersects(BoundingVolume).
See the example below:
boolean can_be_placed=true;
BoundingVolume new_item_boundingvolume=new_item.getWorldBound();
for(Spatial s:itemsNode.getChildren()){
boolean result=s.getWorldBound().intersects(new_item_boundingvolume);
if(result){
can_be_placed=false;
break;
}
}