Getting material from raycast hit?

recon

28-09-2009 20:09:56

Hi

I'm trying to figure out how to determine which type of material was hit on a raycast. I see that there's a member variable called mMaterialIndex of NxOgre::RaycastHit, but I'm not sure how to use it since materials are bound to names in 3d modelers. Have anyone else come up with a fast simple solution to this problem, or does a function for getting material name from a index already exist?

Thanks
/recon

betajaen

28-09-2009 20:16:39

A material index is just a id number of the physics material (not the Ogre graphics kind). The material index in RaycastHit would correspond to the physics material of the hit shape, or if it's a triangle mesh or height field then the material index of that face.

Anyway; you can get the actual material pointer from scene->getMaterial(material_index);

recon

28-09-2009 20:35:42

Ok, thanks a lot for clarifying :)

recon

02-10-2009 02:56:53

I've got a related question (sort of) so I thought I might as well reuse this thread.

I'm in bit of a jam, I've been trying to filter out which Actors that should be excluded from a ray cast.
But without any luck, since I'm having a hard time understanding how I am supposed to use all the parameters in the raycastClosestShape() method.
I'm guessing that what I'm supposed to use the "unsigned int groups" parameter for this but I must be doing it wrong then because it gives me the opposite result of what I was expecting.
So how am I supposed to perform a ray cast on all shapes and, for example, exclude all actor/shapes of group id 2 and 3 or exclude one particular actor, or a list of actors?

Hope I'm not being to vague =P

recon

02-10-2009 17:18:55

Is what I'm trying to accomplish even possible? Do I have to use some kind of callback?
Any thoughts on this would be much appreciated