Is there any API for query area in the world with a shape ?

User avatar
sjinny
Posts: 11
Joined: Tue Apr 24, 2007 6:20 am

Is there any API for query area in the world with a shape ?

Post by sjinny »

Is there any API for query area in the world with a shape ?
for example, i use bullet in the server and use bullet's collision detection the find which objects would be seen by a client and i use an sphere to stand for a client's view.
how can i achieve this ?
thanks~
madMAx4
Posts: 27
Joined: Fri Apr 20, 2007 7:29 pm
Location: Germany

Post by madMAx4 »

therefor some engines have a volume sensor.
but there arent any sensors implemented in bullet yet as far as i know.

but you can send a few ray test around your sphere. this should work as long as your objects are not too small ;)
User avatar
sjinny
Posts: 11
Joined: Tue Apr 24, 2007 6:20 am

Post by sjinny »

well....there would be too many rays in that way.... :)
madMAx4
Posts: 27
Joined: Fri Apr 20, 2007 7:29 pm
Location: Germany

Post by madMAx4 »

well i never tried this :)
you can take a look in OPAL's source code, there is a volume sensor implemented ;)
link: http://ox.slug.louisville.edu/~o0lozi01 ... /Main_Page
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

There are several ways to do this within Bullet. The Blender game engine allows to do such 'collision sensors'.

Two ways:
- Add a rigidbody/collision object with collision shape and disable the collision response:

Code: Select all

rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
Then check for contact points with this rigidbody (see CollisionInterfaceDemo how to find contacts) or add a collision callback for this object.

- Do a convex cast, this lets you find the first time of impact when moving an object along a path. This is similar to a raycast, but instead of a ray you can use a convex object (like sphere, box, cylinder etc). There is not a good interface in the btCollisionWorld at the moment, but it would be a small change to turn the raycast into an 'object cast'.

A good demo how to do this is lacking indeed, it would be useful to add this.
Thanks,
Erwin
Last edited by Erwin Coumans on Sat Jun 02, 2007 2:33 pm, edited 1 time in total.
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post by Dragonlord »

I didn't know this works in Bullet ( maybe the version I have is too old :O ). So far I did my own collision detection to do AI testing. So this convex casting gives you all the informations I need for my AI routines?
- Time To Impact
- Impact Normal
- Collision Response Callback ( to check if something can collide with each other )
- Hit Face ( so what triangle I hit in a mesh if a mesh is hit )
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

I didn't know this works in Bullet ( maybe the version I have is too old :O ). So far I did my own collision detection to do AI testing. So this convex casting gives you all the informations I need for my AI routines?
Yes, this is all available in Bullet, but there is no easy interface for that. So for next version, I'll try to add a user-friendly interface for AI queries, with the following properties:
- Time To Impact
Yes
- Impact Normal
Yes
- Collision Response Callback ( to check if something can collide with each other )
Yes

- Hit Face ( so what triangle I hit in a mesh if a mesh is hit )
Yes

Hope this helps,
Erwin
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post by Dragonlord »

Sounds good as my current AI testing code is more quick hack then optimized and doing this through Bullet should be speedier and making some lengthy code unneeded.