Notifications
Clear all

[Closed] Flocking alignment to surface

Hi guys,

I am writing a flocking sytem (attempting) using a rayintersect function to find the flock members (boids) position on the ground (a surface mesh). This is working fine, but I am using vehicles, so the boids need to align (local x-rotation) to the surface that they are on. This angle is easy to calulate if I can identify the exact face that the boid is sitting on (so I can take the face normal).

At this stage I am not worried about sampling over nearby faces. All I am trying to is write a function that returns the face number of the surface mesh that an object (boid) is sitting on, using the boids world space coordinates. Just that one face.

I know the “mouseTrack” function can return the exact face that the mouse hovers over, but I cannot use this function in this case, but it must be possible.

I have tried searching for the nearest face centre (using meshop.getFaceCenter), but this is not always the exact face that the boid is sitting on (normally if the boid is sitting near a face edge.

Any ideas guys? Help would earn my eternal gratitude, since I am at that stage where a small little problem is blocking me from potential flocking bliss!

Thanks all

Everzen

2 Replies

Have you tried using intersectRayEx() ?

It may well appear that Mr Moosley is the dubiously blessed with my aforementioned undying gratitude. I dont know how I managed to miss that function as I was looking through help, but it is absolutely what I need! Infact that whole section includes some really nice little functions!

Thanks so much, especially for the speedy reply

Take care,

Everzen