hello
iam a bit new to bullet, and using it with SIO2 on the iphone
how can i detect a point mesh collision (meaning that the point is inside the mesh)
so how do i determine if a point is inside a mesh, is there some function for this?
like checkPointInsideMesh(...)
thank you
Point inside a mesh
-
- Posts: 47
- Joined: Mon Aug 16, 2010 10:43 am
Re: Point inside a mesh
If you've created btBvhTriangleMeshShape, you could raycast from that point, into any direction. If it hits triangle, which is backfaced (from rays perspective), then it's inside. But this assumes your models are properly made.
-
- Posts: 3
- Joined: Mon Feb 07, 2011 12:08 pm
Re: Point inside a mesh
the problem is, that the returned normal, is always facing towards the ray origin, so if the point is inside a mesh and hits a face, which normal points outside, the callback returns a normal which is sadly pointing inside
, so the dot of the returned normal and the ray is always negative
here is some code

here is some code
Code: Select all
SIO2object * sio2ObjectLocationInsideMesh( SIO2physic *_SIO2physic, SIO2object * _sio2Obejct, SIO2object * p )
{
vec3 & loc = _sio2Obejct->_SIO2transform.localspace.loc;
btVector3 rayOrigin(loc.x, loc.y, loc.z);
btVector3 rayTarget(0, 0, 0);
btCollisionWorld::ClosestRayResultCallback collision_ray( rayOrigin, rayTarget );
_SIO2physic->_btSoftRigidDynamicsWorld->rayTest( rayOrigin, rayTarget, collision_ray );
if( collision_ray.hasHit() ) {
vec3 n;
n.x = collision_ray.m_hitNormalWorld.x();
n.y = collision_ray.m_hitNormalWorld.y();
n.z = collision_ray.m_hitNormalWorld.z();
vec3 rayDir;
//if rayTarget is [0,0,0], we practicly dont need this, as rayDir = -loc
sio2Vec3Diff(&v, &loc, &rayDir);
//sio2Normalize(&rayDir, &rayDir);
float dot = sio2DotProduct(&rayDir, &n);
INFO_ARG("dot %f", dot);
return ( SIO2object * )( ( btRigidBody * )collision_ray.m_collisionObject )->getUserPointer();
}
return NULL;
}
-
- Posts: 3
- Joined: Mon Feb 07, 2011 12:08 pm
Re: Point inside a mesh
ok, i can overload the
and get the collision shape
but how do i get the normal of the face which is hit?
thank you
Code: Select all
virtual btScalar addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace)
Code: Select all
rayResult.m_collisionObject->getCollisionShape();
thank you
-
- Posts: 47
- Joined: Mon Aug 16, 2010 10:43 am
Re: Point inside a mesh
I can't help on this one, sorry 
I'm pretty new too.

I'm pretty new too.