Tap Collision Grab Object

Mike_Hoff

18-03-2015 17:13:17

Hello everyone,
I'm currently working on an iOS Game using OgreBullet (I simply copied the source code of bullet and ogrebullet into my Xcode project).
I ported the controls from a third person mouse and keyboard control to a 'Diablo like' touch based character control.
However I was wondering what the best approach would be if I wanted the collision detection for selecting an enemy to be greater than the actual collision body.
For example I have an enemy walking around in the scene and I want to select him with a tap. But My finger is bigger than the enemy and the raycast goes slightly below/above/right/left of the enemy.
Is it a valid approach to use 4 different ray casts and check if one hits the enemy, or should I use the Ogre Raycast to check for the Bounding Box of the enemy?
I also read about Ghost Objects but haven't found much about the integration into Ogrebullet.
Or is there anything related already implemented into bullet?
If anybody would have any suggestions on this topic I would really appreciate it!

The code I use for collision looks like this:


Ogre::Ray ray = m_pCamera->getCameraToViewportRay(x, y);
OgreBulletCollisions::CollisionClosestRayResultCallback callBackObject(ray, mWorld, 40.0f);

mWorld->launchRay(callBackObject, POSITION_MARKER_COLLIDES_WITH);


short version:
I want to grab/tap on an object in the scene but I want it to be selected even if I touched just 'near' it.
What would be the best (or at least good) approach?

Thanks for your time!

Greetings
Mike

AlexeyKnyshev

20-03-2015 07:42:15

As I know, there is an convex-cast example in bullet samples. Take a look at it.
(GJKConvexCast)

Regards, Alexey Knyshev