Face's material detection based on raycasting...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Alonguy
Posts: 9
Joined: Mon Feb 01, 2010 3:37 am

Face's material detection based on raycasting...

Post by Alonguy »

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.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Face's material detection based on raycasting...

Post by mongoose7 »

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).
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Re: Face's material detection based on raycasting...

Post by Adler1337 »

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?
multum in parvo
Alonguy
Posts: 9
Joined: Mon Feb 01, 2010 3:37 am

Re: Face's material detection based on raycasting...

Post by Alonguy »

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.
CuteAlien
Admin
Posts: 9720
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Face's material detection based on raycasting...

Post by CuteAlien »

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
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Face's material detection based on raycasting...

Post by hendu »

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.
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Re: Face's material detection based on raycasting...

Post by Klunk »

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.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: Face's material detection based on raycasting...

Post by RdR »

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
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: Face's material detection based on raycasting...

Post by Virion »

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)
Post Reply