Again TriangleCollisionResults problem


anyway I don't get it. I want to check if my bullet hits a tree -model (uses a bounding box) and if yes, i want to play a particle effect at the exact position where the bullet hits the tree. The problem is to get the exact world location of the trimesh of the tree where the bullet hits the tree and where the explosion should took place…

I searched the forum, but i didn't get it working :frowning:

this here doesn't work right…


Why are you fiddling with tris here? The exact position where the tree is hit, is the location of the bullet (which is reasonable small, I think).  :wink:

For a particle effect you should not need any tris of the tree, do you?

well, then i need the exact location of the bullet where the bullet hits the tree (and not its bounds)…and i don't know how to get this location

If you have no tris in your result the bullet has not hit the tree yet. When you get the first tris then the location of your bullet is the 'exact' location where it hits the tree.

Hmm, ok, but that's what you tried, right? Besides the fact, that you don't have to call findTriangleCollision yourself (already happens inside jME), I can't see why it should not work. Triangle collision is not that reliable (don't know why) - perhaps you should live with bounds and improve them a bit to get close…  :expressionless:

thx irissor,

but I don't understand why I get results here

            bullet.findCollisions(p, results2);
            if (results2.getNumber() > 0)

when the bullet hits the bounding box of the tree, although I use TriangleCollisionResults and not BoundingCollisionResults...
If that wouldn't happen, all would be fine ;)

You still get CollisionData instances when only bounds collide. But the sourceTris and targetTris lists have size 0.

As soon as you get source- or targetTris in one of the CollisionData instances the bullet hits the mesh (you just don't need to compute them yourself).

For a code example see TestOBBTree.


i already played a bit with TestOBBTree but

the arraylists are always size 0… i don't understand why