Graphics

 View Only
Expand all | Collapse all

Scripting, how to choose the right event to script, and setVolatileTexture.

  • 1.  Scripting, how to choose the right event to script, and setVolatileTexture.

    Posted 04-14-2017 18:15

    I've been given a fairly simple scene to play with, it's got two "banners" that have team logos on them. The banners are not primitives (not quads), but imported obj files. They have only one face for materials.

    In order to set the two materials, there are published text fields. The first question is when do the scripts get called? Given an item in the sequencer, I know focusing that item will trigger the script event "OnSetText," as will changing it's value in the template data. However, while I can tell the script is running - and getting the correct values, neither the preview nor the online output change the material.

    The "OnSetText" script looks like this:


    dim banner as xpBaseObject
    dim filepath as string = engine.projectPath & "Images\characters"
    dim file as string = filepath & text & ".png"
    dim screen as string = "ScreenLeft"

    if scene.getObjectbyname(screen, banner) then
    if banner.setVolatileTextureFile(0, file) then
    engine.debugMessage("Set " & screen & " to " & file, 0)
    else
    engine.debugMessage("Unable to set " & screen & " textures to " & file, 0)
    end if
    else
    engine.debugMessage("Unable to get object """ & screen & """", 0)
    end if



    When I run this, I see the debug message "Set ScreenLeft to .png" (and I can verify the file in the path exists).

    However, the texture doesn't actually change, it remains what it was set to while building the scene.

    The other questions are what the other events do.... when is OnAddText or OnSetLine called, and where should my script go?



  • 2.  RE: Scripting, how to choose the right event to script, and setVolatileTexture.

    Posted 04-14-2017 18:32
    So I tried on a quad and it worked; I'm guessing setVolatileTextureFile doesn't work on an imported .obj? My solution was to create materials for all teams and then assign the material.

    #XPression