Graphics

 View Only
  • 1.  Scripted Line graph materials back to back

    Posted 05-23-2023 19:12

    Hi there, currently have a script which is providing output of line graphs for AFL player stats, using Xpression Graphite v8.5 4567 (64bit)
    (script below).

    'create a new XPression engine instance
    'dim Engine as new xpEngine
    'dim a material variable
    dim Mat as xpMaterial
    'dim an APITexture shader variable
    dim Texture as xpAPITextureShader
    'dim and create a Pen object instance
    dim Pen as xpPen
     Pen = Engine.CreatePen
    'dim and create an xpPointList object instance
    dim Points as xpPointList
     Points = Engine.CreatePointList

    dim y1 as xptextobject
    dim y2 as xptextobject
    dim y3 as xptextobject
    dim y4 as xptextobject
    dim y5 as xptextobject
    dim y6 as xptextobject

    dim n1 as xpBaseobject
    dim n2 as xpBaseobject
    dim n3 as xpBaseobject
    dim n4 as xpBaseobject
    dim n5 as xpBaseobject
    dim n6 as xpBaseobject

    self.getobjectbyname ("Value 1", y1)
    self.getobjectbyname ("Value 2", y2)
    self.getobjectbyname ("Value 3", y3)
    self.getobjectbyname ("Value 4", y4)
    self.getobjectbyname ("Value 5", y5)
    self.getobjectbyname ("Value 6", y6)

    self.getobjectbyname ("node 1", n1)
    self.getobjectbyname ("node 2", n2)
    self.getobjectbyname ("node 3", n3)
    self.getobjectbyname ("node 4", n4)
    self.getobjectbyname ("node 5", n5)
    self.getobjectbyname ("node 6", n6)


      'retrieve "material1" from the project (see assumptions above)
      Engine.GetMaterialByName("line 3", Mat)

      'retrieve the APITexture shader from the material
      Mat.GetShaderByName("APITexture", Texture)  'set the Pen's size to 20
      Pen.Size = 5  'set the Pen's color to red and alpha to full
      Pen.SetColor(255, 255, 255, 255)    'now using (disconnected) line mode we draw a number of lines representing a graph
      'note: to prevent redrawing on each line instruction we call Begin/EndUpdate to improve performance    APITexture.BeginUpdate()   APITexture.MoveTo(100, 100)   APITexture.LineTo(Pen, 200, 150)   APITexture.LineTo(Pen, 300, 100)   APITexture.LineTo(Pen, 400, 200)   APITexture.LineTo(Pen, 500, 400)   APITexture.LineTo(Pen, 600, 100)  APITexture.EndUpdate()
      ' Dim points As New xpPointList

    dim factor as double
    factor = "21"

     texture.clear

     Points.AddPoint(0, cdbl(y1.text)*factor)
     Points.AddPoint(160, cdbl(y2.text)*factor)
     Points.AddPoint(320, cdbl(y3.text)*factor)
     Points.AddPoint(480, cdbl(y4.text)*factor)
     Points.AddPoint(640, cdbl(y5.text)*factor)
     Points.AddPoint(800, cdbl(y6.text)*factor)

    n1.posY = (cdbl(y1.text)*12.7)
    n2.posY = (cdbl(y2.text)*12.7)
    n3.posY = (cdbl(y3.text)*12.7)
    n4.posY = (cdbl(y4.text)*12.7)
    n5.posY = (cdbl(y5.text)*12.7)
    n6.posY = (cdbl(y6.text)*12.7)

     'now draw the lines using the PointList  APITexture.DrawLines(Pen, Points)
      Texture.DrawLines(Pen, Points)

    So the use case is the operator wants to be able to see the resulting output before taking the scene to line, but in having this option present, when these graphics play back to back, the line material changes live in output when the next scene in sequence is previewed, which is not desired.

    I suppose I am asking how to add to this script, a modifier to the material that outputs the line graph, to reference another material as the desired output instead of only referencing one material.

    The operator currently duplicates the scene and creates a new material and changes the script to that material, but this is creating a lot of additional templates (20 unique and now 20 duplicated) and slowing workflow.

    What would be a better alternative?
    Cheers
    T



    ------------------------------
    Tai Newman
    Xpression operator/designer
    Melbourne Australia
    ------------------------------


  • 2.  RE: Scripted Line graph materials back to back

    Posted 05-24-2023 03:54

    Hi Tai.
    In this case you will need to create two materials with API texture. One of the materials is for preview, second is for programm/online. Also you need to create two quads. One of the quads is for preview and assign the preiview material, second is for programm/online and assign the program material and disable this qaud. Then create 'Layer Object' and enable on it 'Render layer in preview only' and put into it the preview quad.
    In the scene edit scrip event in the tab 'OnPreviewRender' put your script  wtih assign the preview material in the sctring 'Engine.GetMaterialByName("line prw", Mat)'. In 
    the tab 'OnOnline' put your script wtih assign the programm material in the sctring 'Engine.GetMaterialByName("line pgm", Mat)' and add string which enable the programm quad 'quad.visible=true'



    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------



  • 3.  RE: Scripted Line graph materials back to back

    Posted 05-24-2023 17:33

    Thanks Roman!

    I will give this a go, honestly never thought of having just a preview material and one for working online, brilliant.

    Cheers



    ------------------------------
    Tai Newman
    Xpression operator/designer
    Melbourne Australia
    ------------------------------



  • 4.  RE: Scripted Line graph materials back to back

    Posted 05-24-2023 18:53

    Tested and works like a charm. Much appreciated!



    ------------------------------
    Tai Newman
    Xpression operator/designer
    Melbourne Australia
    ------------------------------