Switch off or remove decals from staticShape object when hit
by Jules · in Torque 3D Professional · 09/24/2012 (7:27 am) · 4 replies
On a TSStatic shape you can switch off the collision decals when firing a weapon, how do you do this for staticShape? I've set the datablock;
but on firing a weapon they still show up, so I presume this does not apply like TSStatic as I couldn't find it in the docs and the online docs are off for this at the moment.
Usage: Firing on a window for example to break the window leaves the weapon damage decal there.
edit: I don't think having decals on staticShapes is a good idea by default as you can animate with static shapes, add damage states or add decals in script to them. So having the option to turn them off would be a nice feature. Leave the decals for TSStatics. Personal preference.
For now I've just reduced the timeout on the decals until I can get around to writing a fix for it in the DecalManager. But if anyone has a quick fix/hack , please share - thanks!
decalType = "None";
but on firing a weapon they still show up, so I presume this does not apply like TSStatic as I couldn't find it in the docs and the online docs are off for this at the moment.
Usage: Firing on a window for example to break the window leaves the weapon damage decal there.
edit: I don't think having decals on staticShapes is a good idea by default as you can animate with static shapes, add damage states or add decals in script to them. So having the option to turn them off would be a nice feature. Leave the decals for TSStatics. Personal preference.
For now I've just reduced the timeout on the decals until I can get around to writing a fix for it in the DecalManager. But if anyone has a quick fix/hack , please share - thanks!
#2
And - you can extend the script interface for DecalManager from the engine, make a new engine function to remove all decals within x units of your window (WARNING - Untested code follows):
04/07/2016 (5:42 pm)
Try http://torque3d.org/And - you can extend the script interface for DecalManager from the engine, make a new engine function to remove all decals within x units of your window (WARNING - Untested code follows):
// in engine/T3D/decal/decalManager.cpp add this to the end
DefineEngineFunction(decalManagerRemoveDecalRadius, bool, (F32 radius, Point3F pos), ,
"Remove all decals within radius units of pos from the scene.n"
"@param radius Search radius.n"
"@param pos Center of search radius.n"
"@return Returns true if successful, false if no decals found.n"
"@tsexamplen"
"// Tell the decal manager to remove all decals within 5 units of 0 0 0.n"
"decalManagerRemoveDecal( 5.0, \"0.0 0.0 0.0\" )n"
"@endtsexamplen"
"@ingroup Decals")
{
DecalInstance *inst = gDecalManager->getClosestDecal((Point3F&)pos);
if (!inst)
return false;
while (inst != NULL)
{
VectorF v = pos - inst->mPosition;
F32 dist = v.len();
if (dist > radius)
gDecalManager->removeDecal(inst);
}
return true;
}Then from script:// this should remove all decals within 5 units of the window position decalManagerRemoveDecalRadius(5.0, %theWindow.Position);
#3
For your solution it is a not so good approach to just remove all decals within a radius, the decals need to be removed based on object instance like it is done with TSStatic shapes.
04/08/2016 (5:28 am)
His post is from 2012, but I found it as I have the same problem, no idea if he will ever read that.For your solution it is a not so good approach to just remove all decals within a radius, the decals need to be removed based on object instance like it is done with TSStatic shapes.
#4
04/08/2016 (5:41 am)
Then knock yourself out. Just look at TSStatic and copy the appropriate code into StaticShape. Looks like you're in for a lot of fun.
Duion