Can i use a point light as a simulated sonar?

Hey guys,



i am creating an evolutionary system which will evolve flocking behaviours in underwater vehicles (twin thruster submersibles) which need to be fitted with three sonar units.







Basically, because sonar is essentially impossible to accurately simulate a probability based method will be used.  All i need to know is whether an object is in the vehicles sonar range and the distance away it is.  Based on how far away the object is in the field the sonar using vehicle will be told about it to a certain accuracy, for example, the further the object is the more noise needs to be added which will reduce the accuracy of the distance etc…



Essentially a sonar uniit is a 3d cone which can be of a fixed length (again an aproximation).



I noticed in the HelloAnimation example that a point light was being used illuminate a sphere object, i am wondering if i could use these as my sonar units.



What i need them to do is as follows:



  • Give me information about when they have illuminated something - i.e another object, including the objects position.

  • Be completely invisible unless they illuminate something

  • Follow a strict dimension



Perhaps if they could not tell me the objects distance but tell me the amount of light that has reflected back off the object that would be ok too,  since i presume that the light intensity diminishes to a scale??  In fact some more information on that would be useful since it would be good if i could get the scale to act in the same way as sonars accuracy does in water over distance.

thanks,

edd

Lights are purely visual. You won't get any feedback on when something is "hit" by a light or not. That's all done on the videocard… (I guess you could use some shader tricks on the latest videocards but that's not a very good solution).



For that matter, pointlights are not directional, their "light" goes right through obstacles, and anything outside of the viewport is not even calculated.



So no, not really.

bugger!



Anyone have any thoughts on things that i could use???  perhaps creating an invisible cone object and looking for collisions???



if that is the case could i get the distance information from these collisions??



edd

Yes, collision should work I think. And you can calculate the distance from that.

I'd recommend using a bounding sphere for performance reasons. After receiving all objects in that radius, compute the distance and filter occluded objects or those that are not within a defined angle.

irrisor said:

I'd recommend using a bounding sphere for performance reasons. After receiving all objects in that radius, compute the distance and filter occluded objects or those that are not within a defined angle.


Do you mean like this???



where there is a complete sphere object with the point of the sonar unit as the centre?

edd

yes :slight_smile:

Attach one or more smaller BoundingSphere in some distance to the ship.

Right.  Having your sonar cone contain several spheres in a line and simply using what they collide with would be a cheap (and probably perfectly acceptable) means to give you a tiered sonar collision result.