Game Development Community

material property map and projectiles

by Paolo Oliverio · in Torque Game Engine · 06/05/2003 (5:31 pm) · 10 replies

i have added fields to my material property maps now when a projectile collide one of the returned info is u32 material i whont to know if this material have a material property map and get this map.
how can i do?
i'm tryng to implement different decals for different materials like in crime force.

i have also some c question

1)
i have an enum like this
enum MaterialType {
Default,
Wood,
Metal
};
a variable of type MaterialType and a string readed from a file (es. "Wood")how i can translate the string to MaterialType?for now i'm using unsignedshort instead of enum,this avoid the problem but don't resolve it.

2)how to get in c++ a pointer pointing at a script datablock having a string with its name.es PlayerData* datablock = datafromstring(string);

thanks.

#1
06/06/2003 (3:01 am)
i have discovered that material in rayinfo is always 0.
this because in Interior::castRay_r i have found an interesting comment.

if (isBSPSolidLeaf(node)) {
// DMM: Set material info here.. material info? hahaha

now at thye end of the function we can found the index of the face that is hit.

for returning also info->material is needed a function that return material index from face index but i didn't find it.
now i'm studying interiors to make if myself.
someone have just make it?

with the material index we can after find the mapping property and see the MaterialType.
#2
06/06/2003 (4:57 am)
If you look in renderARB_FC() you'll see something like
pMaterials->getMaterial(rSurface.textureIndex).getGLName();

I think that is basically what you are looking for or at least a starting place.
#3
06/07/2003 (3:13 am)
i have add this in interior collision
under
info->face = surfaceIndex;

add

MaterialPropertyMap* pMatMap = static_cast(Sim::findObject("MaterialPropertyMap"));
const char* pName = mMaterialList->getMaterialName(rSurface.textureIndex);
const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntry(pName);

if (pEntry != NULL)
{
info->material = pEntry->matType;
}else
info->material = 0;

this work.
In projectile oncollision i have added code for add decals for every material.
#4
06/24/2005 (9:55 pm)
Old thread I know, but I just had to do the same sorts of things and this info isn't valid.

I'm loading some physical info for materials on interiors, also need sounds per material type on interiors.

the above code will not work, at least in the TGE 1.3 source I'm using.

it's using pEntry->matType which doesn't correspond to a material index, perhaps Paolo added that, or it's just changed over the years. You want to store the material index in the info struct.

so in the exact same place as before, add this code instead of the above.

MaterialPropertyMap* pMatMap = static_cast<MaterialPropertyMap*>(Sim::findObject("MaterialPropertyMap"));
			const char* pName = mMaterialList->getMaterialName(rSurface.textureIndex);
			//const MaterialPropertyMap::MapEntry* pEntry = pMatMap->getMapEntry(pName);
			info->material = pMatMap->getIndexFromName(pName);
			if(info->material == -1)
				info->material = 0; //no entry, use material 0

UnEarthed Games At Your Service.
#5
06/24/2005 (10:59 pm)
Sounds per material type for interiors (for footsteps) should already be working.
#6
06/25/2005 (1:02 am)
"should already be working" or are already working? :)

The code I'm using looks like it just always plays the 'hard' sound when you are on an interior.
where does it do it in the code?
#7
05/26/2006 (8:38 pm)
Any further progress with this one?
#8
05/26/2006 (8:43 pm)
Further progress on which part? Its working fine for me now.
#9
05/27/2006 (4:37 pm)
Really could our would you be willing to share an example of what you did? I am really interested in using this particular method and exand upon it for different debris and decals due to damage and ammo fire.
#10
09/18/2006 (10:39 pm)
Did any of you get this to work for dts objects?