Graphics

 View Only
Expand all | Collapse all

Populating Team Colors based on a single datalinq value

  • 1.  Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 15:35

    With the League data provided I am trying to change visiting team color schemes based on the TeamCode. 

     

    I would use 4 text objects. One text object would be a datalinq to pull the team code. The a Red, Blue and Green. 

    Where I get hung up is on the scripting. See Below. 

    dim TeamID as xpTextObject
    dim Red as xpTextObject
    dim R as string

    'Red"
    self.GetTextObjectByname ("TeamID", TeamID)
    R = Red.text
    if TeamID = "23" then

    r ="225"

    end if

    The RGB text objects would then populate an INT Color block in Visual logic and then the value of the Int Color Block would populate the material. In theory I think this would work, however my scripting is a little shaky, any help is appreciated!

     



  • 2.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 17:09

    I would so this with a folder of team color swatches and a volatile texture script tied to your datalinq keys.  

    Here's an example from my most recent project, in this case we are pulling from a folder of player image mattes, but the approach is the same:

     

    'IMG SET SCRIPTS

    dim Keys as xpDatalinqKeys
    Dim Key as xpDatalinqKey
    Dim NumKey as xpDatalinqKey
    dim TEAM as xptextObject

    'NEW VOLATILE TEXTURE SCRIPT

    Dim HeadMattePath as string

    HeadMattePath = "D:\2019 TV\Images\_HeadshotsMATTE\BLT\"

    'Engine.DebugMessage("test", 1)

    Self.GetDatalinqKeys(Keys)

    Keys.GetKeyByName("H or A", Key)
    Keys.getKeyByName("Jersey", Numkey)
    Self.GetObjectByName("Home or Away?", TEAM)
    TEAM.text = Key.AsString


    dim PlayerImg, PlayerMask as xpBaseObject
    dim PlayerImgMat, PlayerMaskMat as xpMaterial
    dim PlayerImgSha, PlayerMaskSha as xpBaseShader
    dim MatFilePath as String


    'set file to mask head shot 1--------------------------------

    Keys.getKeyByName("Jersey", NumKey)
    Self.GetObjectByName("P-MATTE Head-1", PlayerMask)
    PlayerMask.SetVolatileTextureFile(0, HeadMattePath & NumKey.asString & ".png")

     

    You should be able to switch out the key bits above with the things that relate specifically to your setup, like file path, object name, and the specific DL key.  But this works extremely well over here for a very similar purpose.

     

    Hope this helps


    #XPression


  • 3.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 17:11

    And full disclosure, my scripting skills are not all that strong, this was built with the help of one of Ross' own.


    #XPression


  • 4.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 17:51

    I use setviotaletexture for the a similar thing so I am familiar with how it works.

     

    The other issue I am finding is that the way I am trying above is a string not a integer so I will have to go with your method.  


    #XPression


  • 5.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 20:01

    You can use the CInt() method to convert string to integer values provided they can.

    In the script you have above (though it looks like aren't Getting the text object), try swapping these codes:

    dim R as string -> dim R as Integer

    R = Red.text -> R = CInt(Red.Text)

    That should return R's text contents as an integer. Though your next line of code hardcodes R to 255, so I'm not sure what's going on there.

     

     

     

     

     


    #XPression


  • 6.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 20:39

    The idea behind is that when the a specific value of team code appears (For this case 8-24) it would change the text to correct Red value for that teams color.

    I would then repeat this script for Green and Blue. By being able to change that Text Object from a string to an integer would allow me to use a Int Color Block in Visual Logic to get a final color to use for the material in which I need to change the color to.


    #XPression


  • 7.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 21:02

    Yes so in that case I think using CInt() to convert your text objects should work. Are you using a datalinq that is housing these team colors? Is there a reason it starts at 8? What about teamcodes 1-7?

    If you are hardcoding everything from the looks of your script, you may want to consider using an array to store all of the values. You could avoid a bunch of If statements by just matching the teamcode to an index value of an array.


    #XPression


  • 8.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 22:11

    Ill have to do some researching on array. I am guessing I would identify my Team ID text object along with my quad that contains the material. Then have an If statement that if The text equals 23 to apply the following values to xpcolor or that quad? I just have no idea how that script would look or even write.  I have only tinkered with scripting since becoming an Xpression user. I am guessing this would also be applied to the scene? This I know does not work, but I am curious if I am going in the right direction. 

    Also Our stats provider assigned every team a unique ID. For whatever reason they started at 8 and it ends at 24.  

    dim ID as xpTextObject

    dim PP as xpBaseObject

    self.getTextObjectByName ("TeamID", ID)

    self.getBaseObjectByName ("AwayPP", PP)

    if ID = "11" then

    PP.xpColor = Cint = ("223", "71", "15")

    end if

     

     


    #XPression


  • 9.  RE: Populating Team Colors based on a single datalinq value

    Posted 08-30-2019 23:47

    I really think you're over complicating it.  You have 16 teams... make 10x10 little swatches of each team's primary color, put them in a folder within your images folder and use the method I laid out earlier today. You could even make swatches of the secondary colors and have a little conditional VL to use the primary color or the secondary color depending on a specific criteria of your choosing... not required, but flexibility is a good thing.


    #XPression


  • 10.  RE: Populating Team Colors based on a single datalinq value

    Posted 09-01-2019 17:07

    Hello Jeff,

    to populate a text object from another, you can use Datalinq and @TextObject@ macro feature.

    In your case , define a new datalinq that contains R,G,B values for each of team ID . Make the rows match the team IDs.
    for example :

    ID_TEAM;R;G;B;TEAM_NAME
    1;0;0;0;not-used
    2;0;0;0;not-used
    3;0;0;0;not-used
    4;0;0;0;not-used
    5;0;0;0;not-used
    6;0;0;0;not-used
    7;0;0;0;not-used
    8;255;0;0;red team
    9;0;255;0;green team
    10;0;0;255;blue team
    11;255;255;255;white team
    ...
    23;128;128;128;grey team

    bind your "Red" "Green" and "Blue" text objects to this new datalinq , set the row info to @TeamID@ (assuming "TeamID" is text object containing the team id from 8 to 23

    keep your first idea with visual logic to set the color :

     


    There is another solution with pure Visual Logic where colors are "hard coded" in VL and use Input Selector :

    (sample image only show for team 8 to 11 , you'll have to make it up to team 23)

    Hope it helps,

    Regards,
    Antoine.


    #XPression


  • 11.  RE: Populating Team Colors based on a single datalinq value

    Posted 09-03-2019 20:17

    One thing I missed is that the Material is actually rounded. 

    Is there a way I can do a VolatileTexture to a specific layer of an existing material?

    Something like this? 

    dim Mat as xpMaterial

    dim Shader as xpBaseShader

    dim FilePath1 as String

    dim TeamId as xpTextObject

    Engine.getMaterialByName ("Away_PP", Mat)

    Mat.getShaderByName ("TeamColor", Shader)

    self.getObjectByName("TeamID", TeamID)

    FilePath1 = TeamID.Text

    Shader.setFileName ("FilePath1")

    shader.reloadfile

    Granted it just does not work. 


    #XPression