Looking up Terrain material
by Martin Andersson · in Torque Game Engine · 04/07/2006 (1:06 pm) · 6 replies
I'm trying to get the material from the terrain.
I have the propertyMap.cs working, so colors of the wheel particles are read from the file etc.
Problem is I always end up with S32 mapIndex = 0 wherever I drive with the car. I have painted different textures on the map and the racing demo track gives the same result.
It's like the entire terrain has the same material.
I don't really care about colors and stuff from the propertyMap.cs, I just want to know what kind of material you are on to take care of different particle emitters, friction etc.
I found a thread about this topic (can't find it any longer), but it still can't solve my problem.
All help is very welcome.
I have the propertyMap.cs working, so colors of the wheel particles are read from the file etc.
Problem is I always end up with S32 mapIndex = 0 wherever I drive with the car. I have painted different textures on the map and the racing demo track gives the same result.
It's like the entire terrain has the same material.
I don't really care about colors and stuff from the propertyMap.cs, I just want to know what kind of material you are on to take care of different particle emitters, friction etc.
I found a thread about this topic (can't find it any longer), but it still can't solve my problem.
All help is very welcome.
#2
Can I do like this or do I have to use the rInfo?
I found a part in wheeledVehicle.cc, the part under RayInfo rInfo; which I logged and it also returns the same
value wherever I go: (rInfo.material = 3.43597e+0C)
Actually, the stock code seems to support what I am looking for by looking at the comments, but it always finds the default value.
This is found im wheeledVehicle.cc:
Also, I checked the code in player.cc which tries to set the color for footpuffs, but the puffs are always the same color because useEmitterColors = false in the player.cs. If set to true, particles gets white and totally opaque.
In my last attempt I at least managed to read the color values from the propertyMap.cs.
I suspect there is something else to be done to be able to read/update the materials.
This tread seems to very interesting, but didn't give me an exact answer to my problem.
www.garagegames.com/mg/forums/result.thread.php?qt=36089
Any ideas? Anything script-related maybe?
04/10/2006 (1:43 am)
Ok, I tried to incorporate the code to fit my need, but the pEntry->matType and pEntry->matFlags are always the same.TerrainBlock* tBlock = static_cast<TerrainBlock*>(wheel->surface.object);
S32 mapIndex = tBlock->getTerrainMapIndex(wheel->data->pos);
if (mapIndex != -1)
{
MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap"));
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(mapIndex);
if(pEntry)
{
mMaterialHitType = pEntry->matType;
mMaterialHitFlags = pEntry->matFlags;
}
}Can I do like this or do I have to use the rInfo?
I found a part in wheeledVehicle.cc, the part under RayInfo rInfo; which I logged and it also returns the same
value wherever I go: (rInfo.material = 3.43597e+0C)
Actually, the stock code seems to support what I am looking for by looking at the comments, but it always finds the default value.
This is found im wheeledVehicle.cc:
TerrainBlock* tBlock = static_cast<TerrainBlock*>(wheel->surface.object);
S32 mapIndex = tBlock->mMPMIndex[0];
// Override the dust color with the material property
const MaterialPropertyMap::MapEntry* pEntry;
if (matMap && mapIndex != -1 &&
(pEntry = matMap->getMapEntryFromIndex(mapIndex)) != 0)Also, I checked the code in player.cc which tries to set the color for footpuffs, but the puffs are always the same color because useEmitterColors = false in the player.cs. If set to true, particles gets white and totally opaque.
In my last attempt I at least managed to read the color values from the propertyMap.cs.
I suspect there is something else to be done to be able to read/update the materials.
This tread seems to very interesting, but didn't give me an exact answer to my problem.
www.garagegames.com/mg/forums/result.thread.php?qt=36089
Any ideas? Anything script-related maybe?
#3
04/11/2006 (7:05 am)
There is fixes for both vehicles and the player search the forum a little more !
#4
Have I had better C++ skills I wouldn't have to dig around GG forums this much.
Gues I'll have to do some more diggin'.
Keyword suggestions anyone?
Tried these: particles, material, texture, terrain, color, emitter, index
This thread sounds like the way to go:
www.garagegames.com/mg/forums/result.thread.php?qt=7351
I'ts a bit more work than I expected, but it would be good to have it working. The implementation of the original code seems be non-working and there doesn't seem to be a quick fix to repair it...
I was kind of hoping for "change this line in xx.cc and then this line in yy.cc and you're set".
@Bill L
Where the threads you saw the "quick fix"-type or more an explanation of what to look for?
04/11/2006 (1:43 pm)
Yes, this "fix" sounds like the remedy to me. Not sure why it should be a fix, it's in the engine and should work right off... Have I had better C++ skills I wouldn't have to dig around GG forums this much.
Gues I'll have to do some more diggin'.
Keyword suggestions anyone?
Tried these: particles, material, texture, terrain, color, emitter, index
This thread sounds like the way to go:
www.garagegames.com/mg/forums/result.thread.php?qt=7351
I'ts a bit more work than I expected, but it would be good to have it working. The implementation of the original code seems be non-working and there doesn't seem to be a quick fix to repair it...
I was kind of hoping for "change this line in xx.cc and then this line in yy.cc and you're set".
@Bill L
Where the threads you saw the "quick fix"-type or more an explanation of what to look for?
#6
Seems like I will get my hinds dirty tonight!
Thanks Billy L!
04/13/2006 (10:59 am)
Now THIS looks promising!Seems like I will get my hinds dirty tonight!
Thanks Billy L!
Torque Owner David Barr
Viola Interactive Ltd
TerrainBlock* tBlock = static_cast<TerrainBlock*>(rInfo.object); S32 mapIndex = tBlock->getTerrainMapIndex(rInfo.point); if (mapIndex != -1) { MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap")); const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(mapIndex); if(pEntry) { mMaterialHitType = pEntry->matType; mMaterialHitFlags = pEntry->matFlags; } }mMaterialHitType and mMaterialHitFlags are my own additions but the method to get the information should be apparent