Finding all instances of a decal in Torquescript
by Netwyrm · in Torque 3D Professional · 03/28/2011 (9:40 pm) · 5 replies
How does one locate all instances of DecalA in a level, with the purpose being to change the material DecalA is drawing from?
I have found decals to be incredibly great tools for adding windows to buildings and would now like to change their state based on day and night.
Does anyone know how to do this via Torquescript? I can't seem to figure out how to access all the decals in the mission, although I can see all the datablocks for them are conobjects which have a material property which I can, in theory, change.
I have found decals to be incredibly great tools for adding windows to buildings and would now like to change their state based on day and night.
Does anyone know how to do this via Torquescript? I can't seem to figure out how to access all the decals in the mission, although I can see all the datablocks for them are conobjects which have a material property which I can, in theory, change.
About the author
My adventures in T3D are chronicled at http://www.worldofantra.com. Please be aware the subject is sword-and-sorcery, and the occasional bloody or bare body part may be in scope.
#2
I reread the Decal Editor documentation again and again until I fixated on the Retarget button. Then I dug around in the editor and found this:
So it has to be possible--I think the trick is to swap datablocks, like it is for turning particle effects on and off. Then all the instances using that datablock swap out at once. One doesn't look for each instance, one looks for the decal by name and wonks with it--the instances inherit any change.
That doesn't mean I've figured out how to do it yet, or if retarget works as laid out, but it's time to split for work so it will have to wait (grrrr).
03/29/2011 (8:18 am)
Great rant, Caylo!I reread the Decal Editor documentation again and again until I fixated on the Retarget button. Then I dug around in the editor and found this:
function RetargetDecalButton::onClick( %this )
{
%id = DecalDataList.getSelectedItem();
%datablock = DecalDataList.getItemText(%id );
if( !isObject(%datablock) )
{
MessageBoxOK("Error", "A valid Decal Template must be selected.");
return;
}
// This is the first place IODropdown is used. The # in the function passed replaced with the output
// of the preset menu.
IODropdown("Retarget Decal Instances",
"Retarget DecalInstances from " @ %datablock.getName() @ " over to....",
"decalDataSet",
"DecalEditorGui.retargetDecalDatablock(" @ %datablock.getName() @ ", #);",
"");
DecalEditorGui.rebuildInstanceTree();
}So it has to be possible--I think the trick is to swap datablocks, like it is for turning particle effects on and off. Then all the instances using that datablock swap out at once. One doesn't look for each instance, one looks for the decal by name and wonks with it--the instances inherit any change.
That doesn't mean I've figured out how to do it yet, or if retarget works as laid out, but it's time to split for work so it will have to wait (grrrr).
#3
03/29/2011 (9:57 am)
try this for changing decals from script in realtimedatablock DecalData(theDecal)
{
sizeX = 0.5;
sizeY = 0.5;
textureName = "art/decals/theDecalTex.png";
textureCoordCount = "0";
Material = "theDecalMat";
};
singleton Material(theDecalMat)
{
mapTo = "theDecalTex";
diffuseMap[0] = "art/decals/theDecalTex.png";
normalMap[0] = "art/decals/theDecalBumpTex.png";
specularPower[0] = "1";
pixelSpecular[0] = "1";
cubemap = "theCubemap";
detailMap[0] = "art/decals/theDecalDetailTex.png";
detailScale[0] = "1 1";
detailNormalMap[0] = "art/decals/theDecalDetailBumpTex.png";
detailNormalMapStrength[0] = "5";
useAnisotropic[0] = "1";
subSurface[0] = "1";
showDust = "1";
glow[0] = false;
emissive[0] = false;
Enabled = "0";
};
function ToggleDecal(%obj, %lightState)
{
theDecalMat.glow[0] = true;
theDecalMat.emissive[0] = true;
theDecalMat.diffuseMap[0] = "art/decals/theDecalTex_2.png";
theDecalMat.cubemap = "theOtherCubemap";
theDecalMat.detailMap[0] = "art/decals/theDecalDetailTex_2.png";
theDecalMat.detailScale[0] = "2.5 2.5";
theDecalMat.detailNormalMapStrength[0] = "17";
theDecalMat.showDust = "0";
theDecalMat.reload();
}as an example of what you can do in script to these things
#4
03/29/2011 (7:00 pm)
With just a little tweaking to fit it into my other lighting routines, that worked beautifully! Thank you for providing so clear an example, deepscratch! That was really nice of you!
#5
The motivation to the simplicity of the current T3D decal system, I may have ignorantly judged. I did not consider the possibility that removal of functionality was in fact removal of confusing redundancy! Of course, the consistency of this to be a truth, is still in question...
03/30/2011 (6:40 pm)
Thanks deepscratch, not only an exceptionally illuminating solution, but a truly revealing example of a perfectly functioning complex system by way of "Emergence". The value of knowledge about a subjects (T3D in this case) unrelated systems to function together in optimal harmony, is first measured by dedication, and finally comprehended as self expression. The dichotomy of; One would never know it, if they did not already know it. The motivation to the simplicity of the current T3D decal system, I may have ignorantly judged. I did not consider the possibility that removal of functionality was in fact removal of confusing redundancy! Of course, the consistency of this to be a truth, is still in question...
Torque 3D Owner Caylo Gypsyblood
I am becoming aware of the growing possibility that my concept of "DECAL" is unique to expect dynamic flexibility to be a self defining necessity of this mostly failed T3D feature.
Some conversation have been repeatedly expressed to the grand possibility that 'the next version' will have the original design improvements what were accidentally busted, then ripped clean and sorta-fixed, then optimized while still busted, then working but totally unoptimized, to be finally replaced by a totally new system what spawned particle FX of creepy smiley faced clowns, in the place of decals. I may be a slight bit inaccurate to details because I stopped truly caring a long time ago with the observation that more time and effort was being put into the "TradeShowVersion" of T3D back at the time.
Truth in this regard is the over exaggerations to the fact, DECALS fully lost any original focuses and we should shut up and be happy that they at least work. I have 'pre-alpha-whatnot-bedazzled' older version of T3D what have a busted but fully more fascinating implementation of decals.
Does anyone know how to do this via Torquescript?
No, I found it impossible to hack any functionality into the decals C'code, even after endless hours of scrutiny from my team of 1000 monkeys banging on keyboards(they make much noise and mess, but far less lip about my unrealistic expectations then other options).
Sorry i am endlessly capable of being in a condition of not being exactly very helpful at all.