Graphics

 View Only
  • 1.  Scripting question: How to update an object's material from sequencer take item?

    Posted 06-11-2014 18:27
    Hello,

    I write a VB application which can get the current take item from Sequencer, preview it and update the material and text directly. I've done all most every features, but I failed to update the material from take item.

    I've checked the new material has been created in Xpression, but the Texture 2D image seems not setup properly. Could any one help to look into my code and give me some advice for creating a material and update it back to Take item?

    The following is the process the following code does:

    a. Get the take item reference from take ID.

    b. Create a new material.

    c. Create a new Shader and

    d. Get the published image object from take item.

    e. Set Property of published image object.

    If engine.Sequencer.GetTakeItemByID(SmallWindowTakeID(SmallWindowListBox.SelectedIndex), takeItem) Then

    Dim newMat As xpMaterial

    Dim shader As xpBaseShader

    Dim tmpPublishedObjImage As New xpPublishedObject

    newMat = engine.CreateMaterial()

    newMat.Name = tmpFileName + "_Image"

    newMat.AddShader("Texture2D", 0, shader)

    shader.SetFileName(tmpFilePath)

    If takeItem.GetPublishedObject(1, tmpPublishedObjImage) Then

    If tmpPublishedObjImage.SetPropertyString(0, newMat.Name) Then

    Debug.Print("Set Image Material " + newMat.Name.ToString() + " successfully")

    Else

    Debug.Print("Set Image Material " + newMat.Name.ToString() + " failed")

    End If

    End If

    Thank you!!


  • 2.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-11-2014 18:30
    You don't need to create a new material. Just pass the File Path to the SetPropertyString function and XPression will automatically create a temporary material that holds that file when the take item goes on air.

    e.g. tmpPublishedObjImage.SetPropertyString(0, tmpFilePath)

    #XPression


  • 3.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-11-2014 19:51
    Hi Brian,

    Thanks for your reply. The reason I need to create Materials is because I don't want operator to use Xpression GUI but using my application instead. Therefore, before updating the material of takeitems, the application will pop up file dialog to let operator import images (basically the image will be pushed to Xpression as a new material, it's what I thought)..

    I observe that even if I SetProperty to that publishedObj successfully, the object cannot be displayed correctly when the take item goes online. For example, the new material I created named "Accident_Image", and the original material the takeitem used was "WatchChina_Image". After updating the material with the application, the object's property did show the change, it changes from "" to "Accident_Image" from object inspector. Nevertheless, the new updated image is all black. I need to set the object inspector to select the "Accident_Image" material from object window manually. Afterward I saw the property of the take item changes from "Accident_Image" to "" and looks ok when it's online.

    Have you ever use APIs to create a new material and update it to one of take items?

    #XPression


  • 4.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-11-2014 19:54
    You do not need to create a material to do what you describe. Everything you just described can be done by passing a File Path to the SetPropertyString function. You do not need to use the XPression GUI for this.

    #XPression


  • 5.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-11-2014 21:13
    Brian, thank you so much for your advice! It works!

    #XPression


  • 6.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-12-2014 16:54
    Hello Brian,

    I have one more quick question about the temporary material. Is it possible to access that temporary material created by Xpression from Scene?

    My application use the virtual output as its preview monitor. Every time the operator moves the mouse cursor into the control area and preview the take item from it's original scene which is copied from GetSceneTemplate method. And I need to current the current material of the takeitem and use it for that copied scene. Could you give me some advice for how to get that temporary created material?

    #XPression


  • 7.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-12-2014 22:57
    I am not aware of any way to get access to the temporary material.. The material only exists when the take item is Online.

    Instead, once you have the Template Scene copy you could simply assign the image file to the quad object in your scene copy.. Take a look at xpBaseObject.SetVolatileTextureFile.. You can use this to assign an image directly to a quad. Then when you assign the Scene to the preview it should have the image in it.

    #XPression


  • 8.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-13-2014 13:24
    Hi Brian,

    I'm very appreciated for your help. This morning I tried to use the method you mentioned but seems like it's not inside the xpression com library? My xpression version is 5.11 build 2550. Does this SetVolatitleTextureFile method come with newer xpression version?

    #XPression


  • 9.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-13-2014 15:15
    You require version 5.5 for SetVolatileTextureFile.

    #XPression


  • 10.  RE: Scripting question: How to update an object's material from sequencer take item?

    Posted 06-13-2014 19:40
    oh oh... I see...

    #XPression