Radar with cone-like collision detection

Guys,



In my project (tankbattles.sourceforge.net) I'm implementing a rotating tank radar. Right now I've been using a rotating cone over the tank as the radar. Looks really nice with alpha.



The thing is: For being usefull the radar has to detect the other tanks nearby as they get inside the cone. I'm doing this by detecting a collision with the enemy tanks and the cone, but two things are really annoing me:

1 - With triangle accuracy, which is precise, the performance sucks.

2 - No bounding collision mecanism is good for this, since it detects outside the cone and that's not nice.



I've been thinking in using ray collision, but that's not like a cone radar (It'd be really nice if I could do Parabolic, but cone is OK). What do you all think?



This is my cone:


      radarCone = new Cone("radarCone",3,10,RADAR_REACH/4,RADAR_REACH);
      radarCone.setLocalRotation(new Matrix3f(1,0,0,0,1,0,0,0,1));
      radarCone.setLocalTranslation(new Vector3f(0,0,RADAR_REACH/2));
      radarCone.setDefaultColor(new ColorRGBA(0.4f,0.25f,0.25f,0.5f));
      radarCone.setRenderState(RenderStateHelper.createAlphaState());
      radarCone.updateRenderState();
      radarCone.setModelBound(new BoundingBox());
      radarCone.updateModelBound();



and this is my collision detector method (triangle accuracy true, bounding collision, I've tried other combinations as well):

public boolean isInsideRadarCone(TankNode tankNode, CollisionResults results){
      this.radarCone.calculateCollisions(tankNode.getChassi(), results);
      return this.radarCone.hasCollision(tankNode.getChassi(), false);
   }



My best regards.

What I think would be REALLY nice was to detect the collision between the triangle-accurate Cone against the BoundingBox of the oher tank. Is there a way I can do this? Is it better in terms of performance?

It may be faster to iterate through a list of possible contacts and just do the distance and trig calculations to determine if its in your radar cone rather than doing collision detection in the scene.



In the simulation I worked on, this is how we did it, because it wasn't originally using any rendering system. When they wanted to visualize it then I made the radar scene object point in the direction of the logical radar. The cone was just a visualization of what was happening, not actually affecting anything.

Well…



I manually created a small Box and I'm testing the collisions between the cone (with very low polycount) with this Box and the performance is OK. I'll test with more tanks…

Yes, using a low poly version of your cone should speed up things up a lot.



Maybe jME should have a mechanism for letting the user provide an alternative mesh for building the collision tree.

It didn't scalled well… I'm trying jMEPhysics2 collision events now… I'm using it for physics, so I'll give it a try.

Make sure you only check for triangle collision after you get a collision between the boundings.

llama said:

Maybe jME should have a mechanism for letting the user provide an alternative mesh for building the collision tree.


Yes please!! :)
Make sure you only check for triangle collision after you get a collision between the boundings.


I'm using jMEPhysics2 collision events callbacks... I think ODE already does that.