checking for space/complex raycasts

pra

09-11-2007 12:10:57

is there a way to check is there are bodies inside/intersectiong with a specified AABB, something like a "box raycast"?

and, I want to align a body with the floor. i could raycast down, but what if there is a hole just on the ray's way? can i do something like raycasting with the AABB's bottom plane, or raycast for AABBs only?

Vectrex

09-11-2007 15:27:25

I was just trying to do that yesterday :) I actually ended up doing 5 raycasts from the corners and have the exact same problem. I originally tried using newtons manual collision function which looks like it's just what we want but it crashed on me. Plus I can't figure out a good way to test if 'this object has collided with ANY object' since it require a specific A and B collision shapes to test. So I'm doing an initial raycast to figure out which shape I should test against (rayInfo in my code)
Here's my (crashing) code. It dies on the newton call
I think I'm not supposed to be getting the info back like I'm doing. You have to use and array of vectors or something. I haven't looked at it enough to test.

// Collision test
OgreNewt::Collision* col = NULL;
col = new OgreNewt::CollisionPrimitives::TreeCollision(PhysicsManager::getSingletonPtr()->mWorld, ghostObjectSN, false);

Vector3 tempPos;
Quaternion tempOrient;
Ogre::Vector3* retContactPts = new Vector3(0,0,0);
Ogre::Vector3* retNormals = new Vector3(0,0,0);
Ogre::Real* retPenetrations = 0;
rayInfo.mBody->getPositionOrientation(tempPos, tempOrient);

int numOfContacts = OgreNewt::CollisionTools::CollisionCollide(PhysicsManager::getSingletonPtr()->mWorld, 10, col, spawnOrient, spawnPos, rayInfo.mBody->getCollision(), tempOrient, tempPos, retContactPts, retNormals, retPenetrations);

pra

09-11-2007 19:23:22

i think i know where the problem in your code is: try using regular vector variables, not pointers, and then in the function call, say "retNormals[0]"

pra

12-11-2007 10:53:37

does it work?

Vectrex

17-11-2007 14:06:43

no :D
I've never seen any actual code which uses this either. Has anyone tried this function?

walaber

19-11-2007 04:59:52

the easy way to do this would be to make a box-shaped rigid body, and set a specific material on it. then in the collision callback return 0 (to ignore the collision physically), and trigger the logic there. actually with this you can create very complex "trigger volume" shapes...

pra

19-11-2007 11:03:29

that sounds like quite a workaround solution, but well, i'll try it