Game Development Community

Read terrain texture

by Vilain Design · in Torque Game Engine · 10/28/2005 (2:28 pm) · 5 replies

Hello,

I am using the WheeledVehicule object and I am trying to detect the material/texture that the wheel is touching on the terrain. I can see that in the updateWheelParticles function, it is trying to do similar detection to change the color of the dust particules emitted by the wheels. It doesn't seem to be implemented. In fact, I want to know if I am on the grass, dirt or gravel/rock.

Can anyone point me to the location of where I can get this information in the engin? That would really help me out.

Thanks.

#1
10/28/2005 (3:59 pm)
Figure contact point with terrain, then call getMaterialMapIndex (iirc) on the TerrainBlock passing that point to get the primary material on that part of the terrain. Then you can use that index to look up the material, get the material map, etc.
#2
10/28/2005 (5:04 pm)
I've done this myself. I had to add a special flag to the material mapping that labels the texture with a terrain "type". IIRC, I had these types: grass, dry grass, dirt, dry dirt, sand, and snow. In the wheeled vehicle's update particle function, I just grabbed the current terrain texture and get it's terrain type, then used the right dirt emitter for that terrain type.

Note: I added extra particle emitter datablocks to the WheeledVehicleData class.
#3
10/30/2005 (11:40 am)
Thanks for the replies! I was doing pretty much what you guys are telling me to do so I am glad you are confirming the way I was doing it.

Thanks again.
#4
10/31/2005 (8:15 am)
Is there a reason why in void WheeledVehicle::updateWheelParticles(F32 dt) the map index always return -1? Both S32 mapIndex = tBlock->mMPMIndex[0]; and tBlock->getTerrainMapIndex(wheel->surface.pos); are returning -1 and my contact point seems to be correct...
#5
10/31/2005 (11:33 am)
Crap, the script data/terrains/highplains/propertyMap.cs wasn't loaded... Now it works fine!