Graphics

 View Only
  • 1.  Newbie Question: Headshot Image define and load

    Posted 10-01-2013 18:38
    I am building "headshots" of NBA Refs. Head shots are saved under last name of Ref. I want the operator to be able to input their last name for each of the three heads and get the following results: replace default image on all three quads holding default ref pics, replace text place holder with name that was typed by operator. I will continue digging, but I don't really know enough to know what I don't yet know. Thanks in advance.


  • 2.  RE: Newbie Question: Headshot Image define and load

    Posted 10-04-2013 15:49
    Hi Malcolm,

    In order to do this, you're gonna need to use some scripting.

    However it's not very clear where you expect your operators to input the last name of the Ref. Are you using the Sequencer to take your scenes online or what are you using?

    Anyway, I'll just assume you're doing it through the Sequencer.

    So let's assume your scene has three textobjects which are called "txtRefName1", "txtRefName2" and "txtRefName3".

    For the headshots you've used three quads with the names "picRef1", "picRef2" and "picRef3".

    You also need to make sure that you have 3 different materials for these quads. So for example "matPictureRef1", "matPictureRef2" and "matPictureRef3"

    If you right-click on the scene and you select Edit Script Events, you'll get a popup. Select the OnOnline-event and copy-paste the below code in it:

    dim obj as xpBaseObject

    dim txtObj as xpTextObject

    dim matRef as xpMaterial

    dim shader as xpBaseShader

    dim refName as string

    for i=1 to 3

    ' GET THE NAME OF THE REFEREE

    Self.getObjectByName("txtRefName" & i, txtObj)

    refName = txtObj.Text

    ' GET THE MATERIAL WHICH HAS THE PICTURE OF THE REF

    engine.getMaterialByName("matPictureRef" & i, matRef)

    ' LOAD THE PICTURE OF THE REFEREE IN THE MATERIAL

    matRef.getShaderByName("Texture", shader)

    shader.setFileName("D:\Projects\NBA\Images\Refs" & refName & ".jpg")

    next

    When you've got this in the window, click on the little Lightning-button to compile the script.

    Now when you use the sequencer you can fill in the names of the refs in the Template-tab for that scene.

    When you take it online, the pictures should be loaded on the quads.

    Note that the filepath which is in the code here above is purely fictional, you'll need to provide the path for your pictures in there. Also the extension doesn't have to be .jpg. It could also be .png, .gif, .psd, etc...

    Let us know if this works for you.

    Cheers,

    Kenneth

    #XPression


  • 3.  RE: Newbie Question: Headshot Image define and load

    Posted 10-04-2013 19:41
    Hi Ken, i'm also trying to achieve something similiar to your script. Forgive me I'm at day 3 of learning xpression. But a have a graphic that is liveupdates on channel 2 through datalinq. It's basically 3 tweets.

    My producer wants me to have a certain icon appear when a certain username shows up. So i was thinking maybe a script could do this. Select the layer user1 get the "Name" then compare that name to a static list of Usernames 1-6 if any of the names match then select icon layer make visible and change material to specified icon 1-6...

    This script of course would have to occur everytime the graphic live updates... I'm trying to rework the script you posted... not with much luck! lol any thoughts? Thanks

    #XPression


  • 4.  RE: Newbie Question: Headshot Image define and load

    Posted 10-04-2013 20:16
    Kenneth, thank you. It looks as if this should work for me. I appreciate you going the extra length to actually script it for me. Hopefully I can tweak it and customize it to my needs.

    Malcolm

    #XPression


  • 5.  RE: Newbie Question: Headshot Image define and load

    Posted 10-04-2013 20:57
    Hi Steve,

    What you're asking for is indeed a small adjustment to the previous posted script.

    In this case if you have a textfield which is called "txtUserName" you can use that one.

    dim obj as xpBaseObject

    dim txtObj as xpTextObject

    dim matRef as xpMaterial

    dim shader as xpBaseShader

    dim userName as string

    ' GET THE NAME OF THE REFEREE

    Self.getObjectByName("txtUserName", txtObj)

    userName = txtObj.Text

    ' GET THE MATERIAL WHICH HAS THE PICTURE OF THE REF

    engine.getMaterialByName("matPicture", matRef)

    ' LOAD THE PICTURE OF THE REFEREE IN THE MATERIAL

    matRef.getShaderByName("Texture", shader)

    select case userName

    case "Username1"

    shader.setFileName("D:\Projects\NBA\Images\username1.jpg")

    case "Username2"

    shader.setFileName("D:\Projects\NBA\Images\username2.jpg")

    case "Username3"

    shader.setFileName("D:\Projects\NBA\Images\username3.jpg")

    case "Username4"

    shader.setFileName("D:\Projects\NBA\Images\username4.jpg")

    case "Username5"

    shader.setFileName("D:\Projects\NBA\Images\username5.jpg")

    case "Username6"

    shader.setFileName("D:\Projects\NBA\Images\username6.jpg")

    ' IF NONE OF THE USERNAMES IS PRESENT, THEN USE A DEFAULT IMAGE

    case else

    shader.setFileName("D:\Projects\NBA\Images\default.jpg")

    end select

    You just have to replace the "Username" with the Name that you want to use.

    You could also create an array but that might be not ideal inside the XPression scripting engine.

    Good luck,

    Kenneth

    #XPression


  • 6.  RE: Newbie Question: Headshot Image define and load

    Posted 10-05-2013 14:41
    Kenneth,

    What is a good resource for diving into scripting. I did some years and years ago, but it was a proprietary language for the old Dubner system. Thanks again.

    #XPression


  • 7.  RE: Newbie Question: Headshot Image define and load

    Posted 10-05-2013 18:12
    Hi Malcolm,

    The scripting engine of XPression uses VB.Net as scripting language, so you're probably best to dig into that language.

    Some websites which have helped me a lot with programming issues I encountered are bytes.com or stackoverflow.com.

    Keep in mind that XPression also has an API that you can connect to, which you can use to create external software applications that can control the XPression engine. For gameshows for example. For the record I do need to add that you need the AE-version of XPression to be able to use the API.

    Best regards,

    Kenneth

    #XPression