Jme collision detection - triangle inside boundingbox?

is there a way to find all nodes which contain triangles which intersect the bounding box of another node?

i think findCollision() only looks for bounds<-> sbound collisions or triangle<->triangle, but not triangle<->bounds?

what i want to do is to check if a volume is completely free of any obstacles

i assume nobody knows and ever needed this. is it possible to implement my own collisionresult to achieve the wanted result?

Maybe you still use the collision Event handler for that. Just check if there is a collision event for a object.

If no collision event with this object happend, the object is 'free'.

What i mean is add all nodes which get reported by the collision event into a hash map or something, then at the end of the cycle, or at the begin of the new cycle you know, all the objects who are not in this map, do not intersect currently.

i never heard of a thing called "collision event". my solution is:

import com.jme.bounding.BoundingVolume;
import com.jme.intersection.CollisionData;
import com.jme.intersection.CollisionResults;
import com.jme.math.Ray;
import com.jme.math.Triangle;
import com.jme.math.Vector3f;
import com.jme.math.Plane;
import com.jme.scene.Geometry;
import com.jme.scene.SceneElement;
import com.jme.scene.TriMesh;
import com.jme.scene.batch.TriangleBatch;
import hstar.hhexen.engine.Utils;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;

public class TriangleInBoundsCollisionResults extends CollisionResults {
  @NotNull private final Vector3f[] m_triVerts;
  @NotNull private final Triangle m_tmpTri;
  @NotNull private final ArrayList<Integer> m_emptyList;
  private final boolean m_collectSourceTris;
  @NotNull private final Ray m_ray = new Ray();
  @NotNull private final Plane m_plane = new FixedPlane();
  @NotNull private final Vector3f m_tmp = new Vector3f();

  /** @param p_collectSourceTris Whether to collect the source or target tris */
  public TriangleInBoundsCollisionResults(final boolean p_collectSourceTris) {
    m_collectSourceTris = p_collectSourceTris;
    m_tmpTri = new Triangle(new Vector3f(), new Vector3f(), new Vector3f());
    m_triVerts = new Vector3f[3];
    m_emptyList = new ArrayList<Integer>();
    for (int i = 0; i < m_triVerts.length; i++) {
      m_triVerts[i] = new Vector3f();

  public void addCollision(final Geometry p_src, final Geometry p_target) {
    if ((p_src.getType() & SceneElement.TRIMESH) == 0 || (p_target.getType() & SceneElement.TRIMESH) == 0) {
      final CollisionData data = new CollisionData(p_src, p_target);
    } else {

      if (m_collectSourceTris) {
        collect(p_target, p_src, m_collectSourceTris);
      } else {
        collect(p_src, p_target, m_collectSourceTris);

  private void collect(final Geometry p_src, final Geometry p_target, final boolean p_collectSourceTris) {
    final BoundingVolume l_worldBound = p_src.getWorldBound();
    for (int l_batchIndex = 0; l_batchIndex < p_target.getBatchCount(); l_batchIndex++) {
      final ArrayList<Integer> l_triIndices = new ArrayList<Integer>();
      final TriMesh l_targetMesh = (TriMesh) p_target;
      final TriangleBatch l_batch = l_targetMesh.getBatch(l_batchIndex);
      final int l_triangleCount = l_batch.getTriangleCount();
      for (int l_triIndex = 0; l_triIndex < l_triangleCount; l_triIndex++) {
        l_batch.getTriangle(l_triIndex, m_triVerts);
        final Triangle l_triangle = Utils.getTriangle(l_batch, m_tmpTri, m_triVerts);
        if (l_worldBound.contains(l_triangle.get(0)) ||
           l_worldBound.contains(l_triangle.get(1)) ||
           l_worldBound.contains(l_triangle.get(2))) {
        } else {
          m_ray.intersectsWherePlane(m_plane, m_tmp);
            if (l_triangle.equals()) {

      final CollisionData l_ret = new CollisionData(p_src, p_target, p_collectSourceTris ? l_batchIndex : -1,
         p_collectSourceTris ? -1 : l_batchIndex, p_collectSourceTris?l_triIndices : m_emptyList, p_collectSourceTris?m_emptyList : l_triIndices);

  public void processCollisions() {



you might wonder what

if (l_triangle.equals()) {


is supposed to do. i modified the trianglecollisionresult so that it collects all triangles of target contained in the bounding volume of source (or the other way round). i just need a way to actually find out if the triangle is inside a bounding volume (in my case, an AABD). any idea how to do that?
HamsterofDeath said:

i never heard of a thing called "collision event"

I was referring to PhysicsSpace.getCollisionEventHandler().
Every collision is reported with an event, so you can find all Nodes who do collide in the physics space.

i only use the standard hme collision detection (findpick, findcollision)