OK, so I was wondering if anyone has a good method for this. I have a player, 3rd-person view. Now, when they walk, I want different sounds to play for footsteps based on the surface they're walking on. I once tried a method where I made every different kind of surface into a separate mesh and detected what node the player is on through raycasting. But this way is pretty hard to work with. Basically, I want to be able to cast a ray below the player, and determine what material the face below them is. Does anyone know any good way to do this?
Any help is appreciated.
Face's material detection based on raycasting...
Re: Face's material detection based on raycasting...
Looks straightforward to me. The terrain is generated from a heightfield. The player is at the point (x, y, z). (x, y) is the base point on the ground plane. Choose your sounds based on (x, y).
Re: Face's material detection based on raycasting...
Good question. I have yet to find a good solution to this problem. I'm looking forward to hearing some ideas.
@mongoose7: That solution would only work for basic games/tech demos. What if you are not using a heightfield at all? Or multi-story buildings?
@mongoose7: That solution would only work for basic games/tech demos. What if you are not using a heightfield at all? Or multi-story buildings?
multum in parvo
Re: Face's material detection based on raycasting...
Hmm... I suppose I COULD go back to the old way of setting up nodes for different materials. And since I'm now using XEffects for lighting, I don't think the normals should matter, so they don't NEED to be connected... and I'm using Newton for physics and I have separate collision maps for my levels... And I'm actually doing an action-RPG type deal. Determining materials would also make it easy to do things like make ladder/vine materials climbable. (once I figure how to do a climbing system).
But if it requires a ton of Irrlicht hackery, I don't think I wanna do it. XD
But if anyone does know a good method, I would really, really appreciate it.
But if it requires a ton of Irrlicht hackery, I don't think I wanna do it. XD
But if anyone does know a good method, I would really, really appreciate it.
Re: Face's material detection based on raycasting...
I worked with separate invisible polygons for that in the past (trigger areas). I don't think there's an easy way to get to the material.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Face's material detection based on raycasting...
Q3 does that with the materials; can't remember right now how exactly, but you have the code.
edit: It uses a short raycast, and then tests the material's parameters.
edit: It uses a short raycast, and then tests the material's parameters.
Re: Face's material detection based on raycasting...
Don't know anything about Newton, but I would have thought encoding this kind of data in the collision, and getting the physics to access it. In my own simpleton homebrew physics I encode a matid for every face in collision mesh. this matid maps to the materials on the visible geometry which has info on the dynamic surface properties, cr, friction etc. Its then very simple process for the physics to access the face , and therefore the material, where a collision occurs.
Re: Face's material detection based on raycasting...
An other idea might be to create some sort of material color map.
An external image with defines the material / sound 'type' by different colors in a image.
Each color represents an material or sound.
Convert the world coordinates to the image x,y coordinates and get the color to check which sound to play
An external image with defines the material / sound 'type' by different colors in a image.
Each color represents an material or sound.
Convert the world coordinates to the image x,y coordinates and get the color to check which sound to play
Re: Face's material detection based on raycasting...
in Unreal Engine for example it uses the physical material http://wiki.beyondunreal.com/UE3:PhysicalMaterial_(UDK) basically detecting the collided object and get the sound from its physical material based on the action (fracture, impact, sliding)
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info