Raycasting?

Elspin

04-11-2009 16:41:58

So I've looked through the documentation for PhysX, and I got a raycast working. I'm really not sure how to get useful information out of the raycast though.

This is the raycast I have set up in my framelistener that's controlling buffered input

NxOgre::Vec3 StartPos( mCamNode->getPosition() );
Camera *mCam = static_cast<Camera*>(mCamNode->getAttachedObject("Camera"));
NxOgre::Vec3 Direction( mCam->getDirection() );
NxOgre::Ray CubeRay( StartPos, Direction );

NxOgre::RaycastHit mRayResult = mScene->raycastClosestShape( CubeRay, NxOgre::Enums::ShapesType_All );


what I'm trying to do is find a cube I've spawned, which is an OGRE3DBody*. I'm not sure how I could find this using a raycast, aside from possibly making a container to hold all the 3D bodies and then matching the rigid body returned to one of the 3D bodies... Is there a better way, or a different way I should be going about doing this?

betajaen

04-11-2009 17:02:22

Try:

hit.mRigidBody->getClassType();

It should respond with "_OGRE3DBody" for OGRE3DBody or "NxOgre::Classes::_Actor" for Actors, but in Detritus there is a slightly better system. But comparing ints is faster than than a look up map.

spacegaier

04-11-2009 21:31:40

There is a post right next to yours with almost the same question and here the answer (as an addition to betajaen's):
viewtopic.php?p=65518#p65518

Elspin

05-11-2009 00:46:28

Thanks for the responses from both of you, I should be able to get this working now :). Sorry about missing the other topic, I'd been looking around for a few days just reading various topics and that topic popped up on the same day.

betajaen

05-11-2009 01:01:24

It's alright. I sometimes miss posts too. ;)