Game Development Community

MAterial Mapping

by Ronald J Nelson · in Torque Game Engine · 06/07/2006 (4:57 pm) · 4 replies

Can someone tell me how to access the material mapping functions from script so I can get material specific information upon collision?

#1
06/08/2006 (12:07 am)
There's no built-in support for that, but it's very easy to add in the C++ source if you have the need. Look at dgl/materialPropertyMap.cc.
#2
06/08/2006 (12:19 am)
Oh yeah been working with it just wondering if anyone had gotten further along on this.
#3
06/09/2006 (10:45 am)
Well I am almost totally successful in my code except for one very big problem. Shoot a bullet at anything but the terrain and it does exactly what it should. Shoot at the terrain and the game crashes. I now where the problem stems from but I am not sure why. In projectile.cc in the proccesstick function I added this right before the oncollision and explode call:

MaterialPropertyMap* pMatMap = static_cast(Sim::findObject("MaterialPropertyMap"));

const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntryFromIndex(rInfo.material);

pMatType = pEntry->matType;

I know this has been used before in other places but I dont under stand why the use of either a static_cast or dynamic_cast towards a terrain object crashes my system. As I said before it works perfectly with every other object type.
#4
06/09/2006 (12:16 pm)
Well I got past that point. I will likely look at releasing this after I knock out some more bugs.