You need to create a "Setup" or "Skinning" scene - a dummy/blank scene that plays out from all Tessera Nodes. That scene needs to do the material modifications, and that way the material will be modified in the project that is loaded on all nodes.
Original Message:
Sent: 03-31-2023 11:31
From: Garrett
Subject: Change Material Color through scripting
Thank you both for responses. Both of you kind of moved my thinking around a little bit. - I ended up being able to get what I wanted to get. Garner, I think that your script that you sent over is still having a lot to do with files that exist to create the colors and select which color.
While ideally with the partner colors, it would be nice to be able to affect the HEX Code to the material, that is okay as most everyone provides an RGB. So I switched from HSL to RGB to accomplish.
dim mat as xpMatieraldim r, g, b as xpTextObject'Get text boxes in the sceneself.GetObjectByName("Set R", r)self.GetObjectByName("Set G", g)self.GetObjectByName("Set B", b)'Get the Material in the Projectengine.GetMaterialByName("Change This Material", mat)'Set RGB Valuemat.ColorDiffuse.R = (cInt(r.Text))mat.ColorDiffuse.G = (cInt(g.Text))mat.ColorDiffuse.B = (cInt(b.Text))
So the weird step to most might be the cInt part. That is converting text to an integer so that you can use it as a number. Shout out Amber Barnett for giving me that little jewel years ago.
This works in Xpression, now I have to see if it works in Tessera or not. I have my doubts solely because we are blue boxes, and if you make a change to a material, in theory you need to republish your project for all of the boxes to see the change to that material. But I can dream can't I. - Plus like, make the material, publish, and then you are good to go, until you need to change it again.
------------------------------
Garrett Hall
Overtime Elite
------------------------------
Original Message:
Sent: 03-31-2023 02:13
From: Garner
Subject: Change Material Color through scripting
Here is a script I found that is labeled as "Setting Color Diffuse Materials Using RGB".
It is setting RGB and not HSL. I did not write this script or test it. Maybe this will help get you started..
dim team, path, pri, sec, lite, dark as xpTextObject
dim priColorMat, secColorMat, txtLiteMat, txtDarkMat, logoLiteMat, logoDarkMat, priBgrdMat, secBgrdMat as xpMaterial
dim priColorShad, secColorShad, txtLiteShad, txtDarkShad, logoLiteShad, logoDarkShad, priBgrdShad, secBgrdShad as xpBaseShader
dim priColor, secColor, liteColor, darkColor as xpColor
dim value as integer = 0
dim priStr(), secStr(), liteStr(), darkStr() as string
scene.GetObjectByName("TEAM", team)
scene.GetObjectByName("PATH", path)
scene.GetObjectByName("PRIMARY_COLOR", pri)
scene.GetObjectByName("SECONDARY_COLOR", sec)
scene.GetObjectByName("4LITE_COLOR", lite)
scene.GetObjectByName("4DARK_COLOR", dark)
priStr = split(pri.text, ",")
secStr = split(sec.text, ",")
liteStr = split(lite.text, ",")
darkStr = split(dark.text, ",")
engine.GetMaterialByName(ucase(team.text & "_COLOR_PRI"), priColorMat)
engine.GetMaterialByName(ucase(team.text & "_COLOR_SEC"), secColorMat)
engine.GetMaterialByName(ucase(team.text & "_COLOR_4LITE"), txtLiteMat)
engine.GetMaterialByName(ucase(team.text & "_COLOR_4DARK"), txtDarkMat)
engine.GetMaterialByName(ucase(team.text & "_LOGO_4LITE"), logoLiteMat)
engine.GetMaterialByName(ucase(team.text & "_LOGO_4DARK"), logoDarkMat)
engine.GetMaterialByName(ucase(team.text & "_BGRD_PRI"), priBgrdMat)
engine.GetMaterialByName(ucase(team.text & "_BGRD_SEC"), secBgrdMat)
'SET COLORS
priColor = priColorMat.ColorDiffuse
secColor = secColorMat.ColorDiffuse
liteColor = txtLiteMat.ColorDiffuse
darkColor = txtDarkMat.ColorDiffuse
priColor.R = priStr(0)
priColor.G = priStr(1)
priColor.B = priStr(2)
secColor.R = secStr(0)
secColor.G = secStr(1)
secColor.B = secStr(2)
liteColor.R = liteStr(0)
liteColor.G = liteStr(1)
liteColor.B = liteStr(2)
darkColor.R = darkStr(0)
darkColor.G = darkStr(1)
darkColor.B = darkStr(2)
'SET LOGOS
engine.debugMessage(logoLiteMat.ShaderCount, 0)
'LOGO FOR LIGHT BGRD
'DELETE EXISTING SHADERS
if logoLiteMat.ShaderCount > 0
for i as integer = 0 to (logoLiteMat.ShaderCount - 1)
logoLiteMat.DeleteShaderByIndex(i)
next
end if
logoLiteMat.AddShader("Texture2D", 0, logoLiteShad)
logoLiteShad.SetFileName(path.text & "\" & team.text & "_4LITE_LOGO.TGA")
'LOGO FOR DARK BGRD
if logoDarkMat.ShaderCount > 0
for i as integer = 0 to (logoDarkMat.ShaderCount - 1)
logoDarkMat.DeleteShaderByIndex(i)
next
end if
logoDarkMat.AddShader("Texture2D", 0, logoDarkShad)
logoDarkShad.SetFileName(path.text & "\" & team.text & "_4DARK_LOGO.TGA")
'PRIMARY PATTERNS
if priBgrdMat.ShaderCount > 0
for i as integer = 0 to (priBgrdMat.ShaderCount - 1)
priBgrdMat.DeleteShaderByIndex(i)
next
end if
priBgrdMat.AddShader("Texture2D", 0, priBgrdShad)
priBgrdShad.SetFileName(path.text & "\" & team.text & "_PRIMARY_PATTERN.TGA")
'SECONDARY PATTERNS
if secBgrdMat.ShaderCount > 0
for i as integer = 0 to (secBgrdMat.ShaderCount - 1)
secBgrdMat.DeleteShaderByIndex(i)
next
end if
secBgrdMat.AddShader("Texture2D", 0, secBgrdShad)
secBgrdShad.SetFileName(path.text & "\" & team.text & "_SECONDARY_PATTERN.TGA")