Graphics

 View Only
  • 1.  Scripting Changes to a Gradient?

    Posted 12-09-2021 16:42
    I'm starting to get into scripting in XPression v10 (I love me some Visual Logic, but scripting is so much more flexible...:-) ) and I've run into a quick question...

    I'd like to build a graphic for our sports people to use in set monitors where they can select a team from one of the major sports leagues and have the logo pop up automatically; that bit is working, but I'd really like to change the background to match the team's primary and secondary colors as a gradient of some sort.  I've got all of the teams' colors stored in a DataLinq list as RGB values, and I'm pulling them into invisible text objects in the scene, so the values are all available to me in scripting.  But I'm hitting a wall when it comes to how to change the colors on the background.  Can I script changes to the colors in a gradient within a material?  If so, how?

    Any help or ideas or thoughts would be most appreciated!  Thanks!

    ------------------------------
    Ben Scripps
    ------------------------------


  • 2.  RE: Scripting Changes to a Gradient?

    MalThePal
    Posted 12-10-2021 10:46
    It might be better to build materials for each team and then just replace the material on the background based on your logo selection. Im not at my Xpression right now but in the SDK help I'm pretty sure there is a method that you can dig into to replace material. Let me know if you need a hand. This is the fun part of Xpression, scripting is great. Good Luck

    ------------------------------
    Malcolm Thorpe
    Free Lance Xpression Designer/Carbonite TD
    ------------------------------



  • 3.  RE: Scripting Changes to a Gradient?

    Posted 12-10-2021 15:39
    There's definitely a way to replace materials; I'm using
    primaryBackground.setMaterial(0,sportBkg)​
    to replace part of the background with a sport-specific material.

    I was really hoping to be able to actually change the gradient settings within a material through scripting rather than building a separate material for each team.  Pulling from all four major professional sports leagues plus a local minor league baseball league puts me at about 100 materials before I even think about colleges...

    I'm still in the honeymoon phase of scripting where everything is possible...until it isn't.  I'm just hoping there's some magic way of using the RGB values I stored in my DataLinq to just make it happen magically...

    Thanks!

    ------------------------------
    Ben Scripps
    ------------------------------



  • 4.  RE: Scripting Changes to a Gradient?

    MalThePal
    Posted 12-10-2021 16:29
    Yeah, I see your point. No promises but let me poke around for a bit.

    ------------------------------
    Malcolm Thorpe
    Free Lance Xpression Designer/Carbonite TD
    ------------------------------



  • 5.  RE: Scripting Changes to a Gradient?

    MalThePal
    Posted 12-10-2021 20:40
    I dug through the SDK help file and I can't find any way of setting gradient shader values using scripting. If you do find a way, make sure you share it here. Good Luck

    ------------------------------
    Malcolm Thorpe
    Free Lance Xpression Designer/Carbonite TD
    ------------------------------



  • 6.  RE: Scripting Changes to a Gradient?

    Posted 12-13-2021 15:02
      |   view attached
    I've been looking into it and I found a result that I think will get you a really good starting place. I was able to utilize the APITexture, Pens and Brushes via XPression scripting to produce a gradient. I am struggling to get any access to changing its color, but it will respond to the RGB values you have in the spreadsheet. Heres the code I used to access the previously mentioned tools.

    _____________________________________________________________
    Dim APITex as xpAPITextureShader
    Dim AutoGrad as xpMaterial
    Self.Project.GetMaterialByName("APIGradient",AutoGrad)
    Autograd.GetShaderByName("APITexture",APITex)
    APITex.Clear

    engine.DebugMessage("APITexure Defined",1)

    Dim GradBrush as xpGradientBrush
    Engine.CreateBrush(1,GradBrush)
    gradbrush.SetGradientRect(0,0,1920,1080)

    engine.DebugMessage("Gradient Brush Defined",1)

    dim GradientShape as xpPointList
    GradientShape = Engine.CreatePointList
    GradientShape.AddPoint(0,0)
    GradientShape.AddPoint(0,1080)
    GradientShape.AddPoint(1920,1080)
    GradientShape.AddPoint(1920,0)

    engine.DebugMessage("Shape Defined",1)

    APITex.FillPolygon(GradBrush,GradientShape)

    engine.DebugMessage("Shape Drawn",1)
    _____________________________________________________________

    Hope this helps you with your project! Feel free to hit me up with more questions, or progress on this. I had some fun looking into it.

    ------------------------------
    Riley Gibbs
    ------------------------------



  • 7.  RE: Scripting Changes to a Gradient?

    Posted 12-13-2021 17:07
    I got the colors to work... turns out my shader on the APITextures Diffuse was set to red...

    The only thing left for you to do is size it and make sure you bring in some invisible text objects to bring the data in from excel and make those text objects variables in the script.
    _________________________________________________________
    'Associate Scene Objects to Methods
    Dim APITex as xpAPITextureShader
    Dim AutoGrad as xpMaterial
    Self.Project.GetMaterialByName("APIGradient",AutoGrad)
    Autograd.GetShaderByName("APITexture",APITex)
    APITex.Clear

    engine.DebugMessage("APITexure Defined",1)

    'Define Brush and its properties
    Dim GradBrush as xpGradientBrush
    Engine.CreateBrush(1,GradBrush)
    gradbrush.SetColors(50,193,205,255,23,215,160,255)
    gradbrush.SetGradientRect(0,0,1920,1080)

    engine.DebugMessage("Gradient Brush Defined",1)

    'define shape for the API Texture
    dim GradientShape as xpPointList
    GradientShape = Engine.CreatePointList
    GradientShape.AddPoint(0,0)
    GradientShape.AddPoint(0,1080)
    GradientShape.AddPoint(1920,1080)
    GradientShape.AddPoint(1920,0)

    engine.DebugMessage("Shape Defined",1)

    APITex.FillPolygon(GradBrush,GradientShape)

    engine.DebugMessage("Shape Drawn",1)
    ______________________________________________________

    ------------------------------
    Riley Gibbs
    ------------------------------



  • 8.  RE: Scripting Changes to a Gradient?

    MalThePal
    Posted 12-13-2021 17:14
    Excellent Riley. Way to go.

    ------------------------------
    Malcolm Thorpe
    Free Lance Xpression Designer/Carbonite TD
    ------------------------------



  • 9.  RE: Scripting Changes to a Gradient?

    Posted 12-13-2021 19:39
    Fantastic work--thanks Mal and Riley for all your help!

    ------------------------------
    Ben Scripps
    Technical Director / XPression Designer
    WWTV Cadillac MI
    ------------------------------



  • 10.  RE: Scripting Changes to a Gradient?

    MalThePal
    Posted 12-13-2021 19:50
    This was all Riley. Way to keep digging.

    ------------------------------
    Malcolm Thorpe
    Free Lance Xpression Designer/Carbonite TD
    ------------------------------