Graphics

 View Only
Expand all | Collapse all

Logo selection script assistance

  • 1.  Logo selection script assistance

    Posted 03-06-2015 15:15
    We have some new graphics that utilize a primary logo, a secondary logo and a color swatch. I'm trying to figure out the best way to simplify the selection process - so the end user doesn't have to select 3 elements each time they put in a logo.

    I don't think Visual Logic supports anything like this yet, so to script this, how would you select a logo material (file-based) and have it automatically bring in the other two elements? The filenames would most likely be the same, but they would be in different paths. (ie: D:PrimaryLogoALABAMA.PNG, D:SecondaryLogoALABAMA.PNG)

    The other gotcha - some scenes have multiple logos...I think once I have one working I can make the others work though.

    I have some ideas how this should work, but I'm hoping somebody else with more scripting knowledge has the better answer!

    Thanks!

    Brian


  • 2.  RE: Logo selection script assistance

    Posted 03-06-2015 18:26
    I would do this by creating a text field the change rather than multiple objects, then letting a script control those objects based on the text input.

    So lets assume that your two logos are ABC and XYZ, and the color background is red for ABC and blue for XYZ. Create a text object titled "Logo." The end user will only type in either ABC or XYZ into this field. They won't touch the rest.

    The script then will use the `InStr` function to determine which logo is being input, and change accordingly. You could design it to default to one, then change to the other, or have it all set as blank until there is text input.

    Here's the script, with the best comments I can do quickly:

    dim logo as xpTextObject

    dim logoquad as xpBaseObject

    dim logobkg as xpBaseObject

    dim ABC as xpMaterial

    dim XYZ as xpMaterial

    dim ABCbkg as xpMaterial

    dim XYZbkg as xpMaterial

    Self.GetObjectByName("Logo", logo)

    Self.GetObjectByName("Logo Quad", logoquad)

    Self.GetObjectByName("Logo BKG", logobkg)

    Engine.GetMaterialByName("ABC's Logo", ABC)

    Engine.GetMaterialByName("XYZ's Logo", XYZ)

    Engine.GetMaterialByName("ABC's Swatch", ABCbkg)

    Engine.GetMaterialByName("XYZ's Swatch", XYZbkg)

    'the InStr function looks within the first string of text for the second string, then returns a character number of where that string was first found

    'for example, if logo.Text="abcdefg" then InStr(logo.Text, b)=2 or InStr(logo.Text, f)=6

    If InStr(UCase(logo.Text), "ABC") = 1 then 'I always add the UCase() so it will catch it if they enter it in upper or lower case

    logoquad.SetMaterial=ABC

    logobkg.SetMaterial=ABCbkg

    elseif InStr(UCase(logo.Text), "XYZ") = 1 then

    logoquad.SetMaterial=XYZ

    logobkg.SetMaterial=XYZbkg

    'This else statement makes it so if something other than "ABC" or "XYZ" is entered, the logo and bkg will just be turned off, saving you from mistakes

    else

    logoquad.Visible=False

    logobkg.Visible=False

    end if


    #XPression


  • 3.  RE: Logo selection script assistance

    Posted 03-06-2015 20:42
    Thanks Dan, I'll try this. If I took this one step further, can we strip the name of the texture being applied? For example - I set the logo texture to ABC.png. Can I extract the ABC part and apply it to the background texture?

    The text entry method will probably work, but selecting a base logo would be much easier - in theory anyway. I'm trying to handle all the ncaa team logos for this example.

    #XPression


  • 4.  RE: Logo selection script assistance

    Posted 03-06-2015 20:54
    If I remember correctly, `OBJ.GetMaterial` returns boolean, so you could do something like

    dim logoquad as xpBaseObject

    dim logobkg as xpBaseObject

    dim ABC as xpMaterial

    dim XYZ as xpMaterial

    dim ABCbkg as xpMaterial

    dim XYZbkg as xpMaterial

    Self.GetObjectByName("Logo Quad", logoquad)

    Self.GetObjectByName("Logo BKG", logobkg)

    Engine.GetMaterialByName("ABC's Logo", ABC)

    Engine.GetMaterialByName("XYZ's Logo", XYZ)

    Engine.GetMaterialByName("ABC's Swatch", ABCbkg)

    Engine.GetMaterialByName("XYZ's Swatch", XYZbkg)

    if logoquad.GetMaterial=ABC then

    logobkg.SetMaterial=ABCbkg

    elseif logoquad.GetMaterial=XYZ then

    logobkg.SetMaterial=XYZbkg

    else

    logoquad.Visible=False

    logobkg.Visible=False

    end if


    #XPression


  • 5.  RE: Logo selection script assistance

    Posted 03-06-2015 21:04
    I was actually thinking about starting with that method, but we always use text-based input at my TV station, so I went there first.

    #XPression


  • 6.  RE: Logo selection script assistance

    Posted 03-06-2015 21:06
    I need to correct that last script. I used the `GetMaterial` function wrong.

    dim logoquad as xpBaseObject

    dim logobkg as xpBaseObject

    dim ABC as xpMaterial

    dim XYZ as xpMaterial

    dim ABCbkg as xpMaterial

    dim XYZbkg as xpMaterial

    Self.GetObjectByName("Logo Quad", logoquad)

    Self.GetObjectByName("Logo BKG", logobkg)

    Engine.GetMaterialByName("ABC's Logo", ABC)

    Engine.GetMaterialByName("XYZ's Logo", XYZ)

    Engine.GetMaterialByName("ABC's Swatch", ABCbkg)

    Engine.GetMaterialByName("XYZ's Swatch", XYZbkg)

    if logoquad.GetMaterial(0, ABC)=true then

    logobkg.SetMaterial=ABCbkg

    elseif logoquad.GetMaterial(0, XYZ)=true then

    logobkg.SetMaterial=XYZbkg

    else

    logoquad.Visible=False

    logobkg.Visible=False

    end if


    #XPression


  • 7.  RE: Logo selection script assistance

    Posted 03-06-2015 21:25
    I'll mess with it and see what happens. Thanks again. If anybody else had a different solution, please post! thanks!

    #XPression


  • 8.  RE: Logo selection script assistance

    Posted 03-06-2015 21:25
    Nice to know about the boolean return for the .GetMaterial, and are you adding all the NCAA logos to your project? Other wise I thought you had to have something like this added to it:

    dim ABCbkgShader as xpBaseShader

    ABCbkg.getShaderByName("Texture", ABCbkgShader)

    ABCbkgShader.setFileName("D:PrimaryLogoABC.PNG")

    #XPression


  • 9.  RE: Logo selection script assistance

    Posted 03-06-2015 21:27
    And no - the logos would be on a local drive, not in my project. At the moment, I may have to make say 10 logo and material instances for things to change.

    Mark - your option may be more along the lines of what I was thinking...

    #XPression


  • 10.  RE: Logo selection script assistance

    Posted 03-06-2015 21:36
    You can do it with just placeholder materials and change the shader with the script, as well. It'll take me some work to come up with how to do it for your instance, but I have some examples I've used before I can share immediately. You'd have to adapt it from there.

    dim pictag as xpTextObject

    dim pic as xpBaseObject

    dim picmat as xpMaterial

    dim picshad as xpBaseShader

    dim filepath as String

    'find and set candidate pics

    for i = 1 to 2

    Self.GetObjectByName("Pic_ID " & i, pictag)

    filepath="X:/!CURRENT/MAR2014ELECTIONS/" & pictag.Text ".png"

    Self.GetObjectByName("Pic " & i, pic)

    pic.GetMaterial(0, picmat)

    picmat.GetShader(0, picshad)

    picshad.SetFileName(filepath)

    next i


    As earlier, this is text driven (by the `pictag` text object), but could be modified to be driven by material instead.

    #XPression


  • 11.  RE: Logo selection script assistance

    Posted 03-06-2015 21:49
    Let assume you have files abc.png, def.png, ghi.png, and etc out as far as you need to, and they're the background shaders. Extrapolate as needed.

    dim pic as xpBaseObject

    dim picbkg as xpBaseMaterial

    dim picmat as xpMaterial

    dim picshad as xpBaseShader

    dim filepath as String

    dim abc as xpMaterial

    dim def as xpMaterial

    dim ghi as xpMaterial

    Self.GetObjectByName("pic", pic)

    filepath='local filepath & pic.GetMaterial(0)

    picbkg.GetMaterial(0, picmat)

    picmat.GetShader(0, picshad)

    picshad.SetFileName(filepath)


    Not tested or really scoured for accuracy, but might work.

    #XPression


  • 12.  RE: Logo selection script assistance

    Posted 03-09-2015 15:45
    Just so everyone following this thread knows, Brian contacted me directly to help finish the project. I'll post some results here so we can get some closure on the forum, but this thread may be a little dead if you're looking for advice on the topic.

    #XPression


  • 13.  RE: Logo selection script assistance

    Posted 03-10-2015 02:51
    I just wanted to pass along a solution I found out about tonight - thanks to Andrew from Ross. This solution uses volatile textures - which means they are temporary, and won't directly affect the materials in the scene - and doesn't require a bunch of extra materials in the project. It still uses a text entry method - and the script snippet below is placed in "On Set Text"

    dim logo, swatch as xpBaseObject

    dim logopath as string

    scene.GetObjectByName("Logo1", logo)

    scene.GetObjectByName("Logo1 swatch", swatch)

    logopath = "Your Image Path"

    if scene.iscopy then

    logo.SetVolatileTextureFile(0, logopath & "Logos_Keyable" & ucase(Replace(text," ","_")) & ".tga")

    swatch.SetVolatileTextureFile(0, logopath & "Swatches" & ucase(Replace(text," ","_")) & "_swatch.tga")

    end if



    You can code the image paths directly, I chose to put part of the path into a string.

    Just a FYI - you need at least version 5.4 build 2627 for this to work, and the scene.iscopy line only works in the newer 5.9 builds. You can leave that if statement out if you're running an older build.

    #XPression


  • 14.  RE: Logo selection script assistance

    Posted 03-11-2015 14:19
    Could you loop this, too? For example:

    dim logo, swatch as xpBaseObject

    dim logopath as string

    dim i as Integer

    for i = 1 to 10

    scene.GetObjectByName("Logo" & i, logo)

    scene.GetObjectByName("Logo" & i & " swatch", swatch)

    logopath = "Your Image Path"

    if scene.iscopy then

    logo.SetVolatileTextureFile(0, logopath & "Logos_Keyable" & ucase(Replace(text," ","_")) & ".tga")

    swatch.SetVolatileTextureFile(0, logopath & "Swatches" & ucase(Replace(text," ","_")) & "_swatch.tga")

    end if

    next i


    #XPression