Most efficient vehicle collision detection method?

Hi guys!

First thing on my first activity i want to congrats you for your community.

I am a final year student and I am trying for my bachelor degree to create a complex control system for traffic congestions with a 3D graphical background. For all the documentation available I have chosen JMonkey.

By running all example projects I have been able so far to create and manually control a vehicle from the keyboard. I do not want anything fancy.

My question for you is what method for collision detection, or presence detection of an object on the map should I use? I have tried so far to use BoundingSphere object but the problem is that I want to sense presence of an object just in the vehicle lane, not all radius of it.

I need just to sense an object just in my lane. I have tried even the Ray object but problem is the same.

So, please, if you can only suggest some solution I am open to try it.

You don’t want a bounding sphere, because as you have discovered a round shape is not good for locating something that is approximately rectangular, like a car (a bounding box is a much better fit). That being said, you don’t really need bounding shapes here at all. A simple ray cast (see the picking tutorials) will give you presence and distance to something in your lane.

I mean, given the data specified, there are endless possibilities. Are these cars driven by real people? Following paths with random intersection decisions? Complex AI? How many cars are we talking here? 10? 10,000? 8 rays around the car would be fine for a few hundred cars but i mean binary bitshifting the locations will be much quicker until you get somewhere near a collision distance.

There isnt enough information to go on at this point.

I am sorry for the lack of input informations, as I said, I am not trying to do anything graphical complex. I am looking for about 10-20 cars to go straight forward and steer in some point… intersection/merge, and to check in a predefined distance in front of them the presence of an object. I have tried initially to run an object instance of AutonomousVehicleControl class, but the problem is that the wichSide method is always switching flags of the anglemult and therefore the behaviour of the vehicle is steer right and immediatly steer left at pi/2 angle.
public void CarMoveAt(Vector3f targetLocation) { vehicle.getPhysicsLocation(vector1); vector2.set(targetLocation); vector2.subtractLocal(vector1); float distance = vector2.length(); float checkRadius = 4; if (distance <= checkRadius) { //moving = false; vehicle.accelerate(0); vehicle.brake(10); } else { vector2.normalizeLocal(); vehicle.getForwardVector(vector3).normalizeLocal(); vector4.set(vector3); ROTATE_RIGHT.multLocal(vector4); plane.setOriginNormal(map.getWorldTranslation(), vector4);
float dot = 1 - vector3.dot(vector2); float angle = vector3.angleBetween(vector2);
float anglemult = 1;//FastMath.PI / 4.0f; float speedmult = 0.3f;//0.3f;
if (angle > FastMath.QUARTER_PI) { angle = FastMath.QUARTER_PI; } //left or right if (plane.whichSide(targetLocation) == Plane.Side.Negative) { anglemult *= -1; } //backwards if (dot > 1) { speedmult *= -1; anglemult *= -1; } vehicle.steer(angle * anglemult); vehicle.accelerate(speed * speedmult); vehicle.brake(0); } }
this is my move method. I am running it on an instance Vehicle object from the FancyCar class.
Can you help me with this, or please get me in touch with Normen? I am desperatelly looking for a fast simple solution…
btw, idk why, the hub is not working, smth like Bad Gateway…

Have you tried a Hullcollision Shape? It is the most precise shape you can use that still runs fast, a ful gimpact mesh is slow as hell. Oh wait are you using bullet or run without any physic engine? Also what is the target platform? Desktop pc? Mobile?