lua gencoord


    Oct 24 2007 | 2:40 am
    Hi lua maxers,
    I started doing some work with jit.gl.lua and thought I would post
    what I found out.
    I noticed if I use an instance of jit.expr in lua I had to bracket
    the input and output with an instance of jit.matrix (vpoint, vgen) to
    be able to perform the matrixcalc and use the data within lua code or
    output it. Is there a simpler way to calculate matrix messages in
    jit.gl.lua? This is the only way I could get it to work so far...
    (())_n
    -- lua code
    render_context = this.drawto
    autogarbage = 1
    autowatch = 1
    gc = 1
    points = 50
    -- called on every gl.draw unless @automatic 0
    function draw()
    makepoints()
    end
    -- generate points
    function makepoints()
    local vpoint = jit.matrix(2, "float32", points, points)
    local vgen = jit.matrix(2, "float32", points, points)
    local vexpr = jit.new("jit.expr")
    vexpr.expr = {"norm[0]", "norm[1]"}
    vexpr.inputs = 1
    vexpr.type = "float32"
    vexpr:matrixcalc(vpoint.name, vgen.name)
    outlet(0, "jit_matrix", vgen.name)
    end
    -- set the dimensions of the matrix
    function dim(x)
    points = x
    end

    • Oct 24 2007 | 2:58 am
      The following should work. Note that even in a patcher jit.expr
      requires an input jit.matrix object so that being also the case in
      jit.gl.lua is consistent. All I did below was make the calculations
      happen in-place.
      wes
      render_context = this.drawto
      autogarbage = 1
      autowatch = 1
      gc = 1
      points = 50
      -- called on every gl.draw unless @automatic 0
      function draw()
      makepoints()
      end
      -- generate points
      function makepoints()
      local vpoint = jit.matrix(2, "float32", points, points)
      local vexpr = jit.new("jit.expr")
      vexpr.expr = {"norm[0]", "norm[1]"}
      vexpr.inputs = 1
      vexpr.type = "float32"
      vexpr:matrixcalc(vpoint.name, vpoint.name)
      outlet(0, "jit_matrix", vpoint.name)
      end
      -- set the dimensions of the matrix
      function dim(x)
      points = x
      end
    • Oct 24 2007 | 4:52 am
      hi wes,
      sweet. thanks that gives me a new view of things. so I only need to
      create an instance of one matrix and pass it along.
      super.
      another question which I haven't quite found an answer to: If I
      create an instance of jit.qt.movie how do I reference the output
      matrix when it plays? In jitter I would just send it a bang, but in
      lua I am having trouble getting a matrix. the read message I seem to
      have working... but it seems some messages work and others don't. Am
      I right to assume that messages take the : and atributes the .
      between the instance and message?
      function load(a)
      vmovie = jit.new("jit.qt.movie")
      vmovie.colormode = "uyvy"
      vmovie.adapt = 1
      vmovie:read(a)
      local vframe = jit.matrix(2, "char", 320, 240)
      -- I get an error: "jit.qt.movie: could not create gworld" if I
      call the following but no film has been read
      vmovie:matrixcalc(vframe.name, vframe.name)
      outlet(0, "jit_matrix", vframe.name)
      end
      (())_n
      On Oct 23, 2007, at 10:58 PM, Wesley Smith wrote:
      > The following should work. Note that even in a patcher jit.expr
      > requires an input jit.matrix object so that being also the case in
      > jit.gl.lua is consistent. All I did below was make the calculations
      > happen in-place.
      >
      > wes
      >
      > render_context = this.drawto
      > autogarbage = 1
      > autowatch = 1
      > gc = 1
      > points = 50
      >
      > -- called on every gl.draw unless @automatic 0
      > function draw()
      > makepoints()
      > end
      >
      > -- generate points
      > function makepoints()
      > local vpoint = jit.matrix(2, "float32", points, points)
      > local vexpr = jit.new("jit.expr")
      > vexpr.expr = {"norm[0]", "norm[1]"}
      > vexpr.inputs = 1
      > vexpr.type = "float32"
      > vexpr:matrixcalc(vpoint.name, vpoint.name)
      > outlet(0, "jit_matrix", vpoint.name)
      > end
      >
      > -- set the dimensions of the matrix
      > function dim(x)
      > points = x
      > end
    • Oct 24 2007 | 5:23 am
      works for me. BTW, you might want to make your matrix 4 plane. Are
      you in windows or OSX? What version of jit.gl.lua do you have?
      wes
      On 10/23/07, (())_n wrote:
      > hi wes,
      >
      > sweet. thanks that gives me a new view of things. so I only need to
      > create an instance of one matrix and pass it along.
      >
      > super.
      >
      > another question which I haven't quite found an answer to: If I
      > create an instance of jit.qt.movie how do I reference the output
      > matrix when it plays? In jitter I would just send it a bang, but in
      > lua I am having trouble getting a matrix. the read message I seem to
      > have working... but it seems some messages work and others don't. Am
      > I right to assume that messages take the : and atributes the .
      > between the instance and message?
      >
      > function load(a)
      > vmovie = jit.new("jit.qt.movie")
      > vmovie.colormode = "uyvy"
      > vmovie.adapt = 1
      > vmovie:read(a)
      > local vframe = jit.matrix(2, "char", 320, 240)
      > -- I get an error: "jit.qt.movie: could not create gworld" if I
      > call the following but no film has been read
      > vmovie:matrixcalc(vframe.name, vframe.name)
      > outlet(0, "jit_matrix", vframe.name)
      > end
      >
      > (())_n
      >
      > On Oct 23, 2007, at 10:58 PM, Wesley Smith wrote:
      >
      > > The following should work. Note that even in a patcher jit.expr
      > > requires an input jit.matrix object so that being also the case in
      > > jit.gl.lua is consistent. All I did below was make the calculations
      > > happen in-place.
      > >
      > > wes
      > >
      > > render_context = this.drawto
      > > autogarbage = 1
      > > autowatch = 1
      > > gc = 1
      > > points = 50
      > >
      > > -- called on every gl.draw unless @automatic 0
      > > function draw()
      > > makepoints()
      > > end
      > >
      > > -- generate points
      > > function makepoints()
      > > local vpoint = jit.matrix(2, "float32", points, points)
      > > local vexpr = jit.new("jit.expr")
      > > vexpr.expr = {"norm[0]", "norm[1]"}
      > > vexpr.inputs = 1
      > > vexpr.type = "float32"
      > > vexpr:matrixcalc(vpoint.name, vpoint.name)
      > > outlet(0, "jit_matrix", vpoint.name)
      > > end
      > >
      > > -- set the dimensions of the matrix
      > > function dim(x)
      > > points = x
      > > end
      >
      >
    • Oct 24 2007 | 4:45 pm
      On Oct 24, 2007, at 1:23 AM, Wesley Smith wrote:
      > works for me. BTW, you might want to make your matrix 4 plane. Are
      > you in windows or OSX? What version of jit.gl.lua do you have?
      >
      > wes
      Hi Wes,
      Thanks. I overlooked the 4 planes. Yes it works but not until I have
      read a file into jit.qt.movie. if I haven't read a file I get the
      error: "jit.qt.movie: could not create gworld." So matrixcalc is the
      only way for an instance of jit.qt.movie to output a matrix in
      jit.gl.lua?
      I am on 12" pwrbk g4 GeForce FX Go5200 osx 10.4.10 max 4.6.3 jitter
      1.6.3 jit.gl.lua is b4
      Note: I updated to the Jitter "1.6.4-x1 :: Experimental Jitter
      framework" and still get the same error.
      (())_n
      here is the code that illustrates this behavior:
      render_context = this.drawto
      autogarbage = 1
      autowatch = 1
      gc = 1
      function script_load()
      vmovie = jit.new("jit.qt.movie")
      vmovie.colormode = "uyvy"
      vmovie.adapt = 1
      end
      function read(a)
      vmovie:read(a)
      local vframe = jit.matrix(4, "char", 320, 240)
      vmovie:matrixcalc(vframe.name, vframe.name)
      outlet(0, "jit_matrix", vframe.name)
      end
      -- I get an error: "jit.qt.movie: could not create gworld"
      -- if I call the following but no film has been read
      function play()
      local vframe = jit.matrix(4, "char", 320, 240)
      vmovie:matrixcalc(vframe.name, vframe.name)
      outlet(0, "jit_matrix", vframe.name)
      end
    • Oct 24 2007 | 5:20 pm
      I am confused by the play function. Don't you want to do something
      more like this? Also fixes the gworld error:
      -- movieplayer.lua
      render_context = this.drawto
      autogarbage = 1
      autowatch = 1
      gc = 1
      function script_load()
      vmovie = jit.new("jit.qt.movie")
      vmovie.colormode = "uyvy"
      vmovie.adapt = 1
      end
      function read(a)
      vmovie:read(a)
      end
      -- I get an error: "jit.qt.movie: could not create gworld"
      -- if I call the following but no film has been read
      function draw()
      if (vmovie.framecount > 0) then
      local vframe = jit.matrix(4, "char", 320, 240)
      vmovie:matrixcalc(vframe.name, vframe.name)
      outlet(0, "jit_matrix", vframe.name)
      end
      end
      here is my patcher:
      max v2;
      On Oct 24, 2007, at 9:45 AM, (())_n wrote:
      > On Oct 24, 2007, at 1:23 AM, Wesley Smith wrote:
      >
      >> works for me. BTW, you might want to make your matrix 4 plane. Are
      >> you in windows or OSX? What version of jit.gl.lua do you have?
      >>
      >> wes
      >
      >
      > Hi Wes,
      >
      > Thanks. I overlooked the 4 planes. Yes it works but not until I
      > have read a file into jit.qt.movie. if I haven't read a file I get
      > the error: "jit.qt.movie: could not create gworld." So matrixcalc
      > is the only way for an instance of jit.qt.movie to output a matrix
      > in jit.gl.lua?
      >
      > I am on 12" pwrbk g4 GeForce FX Go5200 osx 10.4.10 max 4.6.3 jitter
      > 1.6.3 jit.gl.lua is b4
      > Note: I updated to the Jitter "1.6.4-x1 :: Experimental Jitter
      > framework" and still get the same error.
      >
      > (())_n
      >
      > here is the code that illustrates this behavior:
      >
      > render_context = this.drawto
      > autogarbage = 1
      > autowatch = 1
      > gc = 1
      >
      > function script_load()
      > vmovie = jit.new("jit.qt.movie")
      > vmovie.colormode = "uyvy"
      > vmovie.adapt = 1
      > end
      >
      > function read(a)
      > vmovie:read(a)
      > local vframe = jit.matrix(4, "char", 320, 240)
      > vmovie:matrixcalc(vframe.name, vframe.name)
      > outlet(0, "jit_matrix", vframe.name)
      > end
      >
      > -- I get an error: "jit.qt.movie: could not create gworld"
      > -- if I call the following but no film has been read
      > function play()
      > local vframe = jit.matrix(4, "char", 320, 240)
      > vmovie:matrixcalc(vframe.name, vframe.name)
      > outlet(0, "jit_matrix", vframe.name)
      > end
      >
      >
    • Oct 24 2007 | 6:23 pm
      Hi mark,
      this is great. I guess I should be calling it on the draw and check
      for frames to see if a movie has been loaded.
      thanks
      (())_n
      On Oct 24, 2007, at 1:20 PM, MarkDavid Hosale wrote:
      > I am confused by the play function. Don't you want to do something
      > more like this? Also fixes the gworld error:
      >
      > -- movieplayer.lua
      >
      > render_context = this.drawto
      > autogarbage = 1
      > autowatch = 1
      > gc = 1
      >
      > function script_load()
      > vmovie = jit.new("jit.qt.movie")
      > vmovie.colormode = "uyvy"
      > vmovie.adapt = 1
      > end
      >
      > function read(a)
      > vmovie:read(a)
      > end
      >
      > -- I get an error: "jit.qt.movie: could not create gworld"
      > -- if I call the following but no film has been read
      > function draw()
      > if (vmovie.framecount > 0) then
      > local vframe = jit.matrix(4, "char", 320, 240)
      > vmovie:matrixcalc(vframe.name, vframe.name)
      > outlet(0, "jit_matrix", vframe.name)
      > end
      > end
      >
      >
      > here is my patcher:
      >
      > max v2;
      >
    • Oct 24 2007 | 7:02 pm
      You don't have to call it on the draw but it can be convenient. If
      you're not using opengl, you can just send a message to output a frame
      whenever you want.
      wes
      On 10/24/07, (())_n wrote:
      > Hi mark,
      >
      > this is great. I guess I should be calling it on the draw and check
      > for frames to see if a movie has been loaded.
      >
      > thanks
      >
      > (())_n
      >
      >
      > On Oct 24, 2007, at 1:20 PM, MarkDavid Hosale wrote:
      >
      > > I am confused by the play function. Don't you want to do something
      > > more like this? Also fixes the gworld error:
      > >
      > > -- movieplayer.lua
      > >
      > > render_context = this.drawto
      > > autogarbage = 1
      > > autowatch = 1
      > > gc = 1
      > >
      > > function script_load()
      > > vmovie = jit.new("jit.qt.movie")
      > > vmovie.colormode = "uyvy"
      > > vmovie.adapt = 1
      > > end
      > >
      > > function read(a)
      > > vmovie:read(a)
      > > end
      > >
      > > -- I get an error: "jit.qt.movie: could not create gworld"
      > > -- if I call the following but no film has been read
      > > function draw()
      > > if (vmovie.framecount > 0) then
      > > local vframe = jit.matrix(4, "char", 320, 240)
      > > vmovie:matrixcalc(vframe.name, vframe.name)
      > > outlet(0, "jit_matrix", vframe.name)
      > > end
      > > end
      > >
      > >
      > > here is my patcher:
      > >
      > > max v2;
      > > #N vpatcher 501 427 1101 827;
      > > #P window setfont "Sans Serif" 9.;
      > > #P window linecount 1;
      > > #P message 368 138 80 196617 read dozer.mov;
      > > #P message 303 140 58 196617 read dozer;
      > > #P newex 300 164 64 196617 prepend call;
      > > #P user jit.pwindow 303 216 82 62 0 1 0 0 1 0;
      > > #P newex 277 289 75 196617 jit.window foo;
      > > #P newex 147 160 50 196617 t b erase;
      > > #P toggle 147 106 15 0;
      > > #P newex 147 135 57 196617 qmetro 33;
      > > #P newex 147 236 82 196617 jit.gl.render foo;
      > > #P newex 304 192 166 196617 jit.gl.lua foo @file movieplayer.lua;
      > > #P connect 3 0 2 0;
      > > #P connect 2 0 4 0;
      > > #P connect 4 1 1 0;
      > > #P connect 4 0 1 0;
      > > #P connect 9 0 7 0;
      > > #P connect 8 0 7 0;
      > > #P connect 7 0 0 0;
      > > #P connect 0 0 6 0;
      > > #P pop;
      >
    • Oct 24 2007 | 11:15 pm
      On Oct 24, 2007, at 3:02 PM, Wesley Smith wrote:
      > You don't have to call it on the draw but it can be convenient. If
      > you're not using opengl, you can just send a message to output a frame
      > whenever you want.
      >
      > wes
      Hi Wes, Mark,
      Yes I was just trying to think to keep the CPU and GPU processes
      separate.
      Will see what is more effective in the long run.
      So I now made a player based on your input. I noticed that if I call
      a local matrix on every draw() or play() for the matrixcalc it slowed
      down and crashed after a while. So now I create the processing matrix
      in the setup. With this code I noticed that dozer.mov and other short
      movies play fine, but that the frame rate drops proportionately on
      longer movie files with the same photo-jpeg 320x240 compression
      settings. The longer files play fast in jit.qt.movie in a patch. I
      went back to jitter 1.6.3 but it didn't change anything.
      The patch and code here (and below):
      (())_n
      -- code es.play.lua
      render_context = this.drawto
      autogarbage = 1
      autowatch = 1
      gc = 1
      function script_load()
      vmovie = jit.new("jit.qt.movie")
      vmovie.colormode = "uyvy"
      vmovie.adapt = 1
      vplane = jit.new("jit.gl.videoplane", render_context)
      vplane.colormode = "uyvy"
      vplane.scale = {1.333, 1., 1.}
      vframe = jit.matrix(4, "char", 320, 240)
      end
      function read(a)
      vmovie:read(a)
      end
      function play()
      if (vmovie.framecount > 0) then
      vmovie:matrixcalc(vframe.name, vframe.name)
      outlet(0, "jit_matrix", vframe.name)
      end
      end
      function draw()
      if (vmovie.framecount > 0) then
      vmovie:matrixcalc(vframe.name, vframe.name)
      vplane:jit_matrix(vframe.name)
      end
      end
      -- play patch:
    • Oct 24 2007 | 11:28 pm
      On Oct 24, 2007, at 4:15 PM, (())_n wrote:
      > vmovie = jit.new("jit.qt.movie")
      > vmovie.colormode = "uyvy"
      > vframe = jit.matrix(4, "char", 320, 240)
      Very important: in UYVY mode you should use *half* resolution for the
      x-axis. If you connect jit.fpsgui in dim mode you should see that the
      output matrix for a "320x240" file uses "160x120" in UYVY mode due to
      the chroma reduced "macro-pixel". See the "colorspaces" tutorial for
      more info if this doesn't make sense to you.
      -Joshua
    • Oct 25 2007 | 12:55 am
      Wes is probably better able to address the issue you are describing
      here as it relates to the code you posted. But, I was wondering, what
      is your end goal? do you want to do some video processing on a slab?
      Do some matrix processing with video? or do you want to just texture
      some video planes?
      Depending on what you're trying to do I have some sample patches that
      could help you and are definitely not suffering from this slow down
      problem.
      A couple of little notes about this patch:
      - you should erase your renderer after each bang i.e. [t b erase]
      - it's really not important, but I would change the name of play() to
      bang(), this way you can just run the metro directly to the [prepend
      call] without the play message. It's more intuitive to me since this
      is the way max objects work. Almost not worth mentioning however...
      -markdavid
      On Oct 24, 2007, at 4:15 PM, (())_n wrote:
      > On Oct 24, 2007, at 3:02 PM, Wesley Smith wrote:
      >
      >> You don't have to call it on the draw but it can be convenient. If
      >> you're not using opengl, you can just send a message to output a
      >> frame
      >> whenever you want.
      >>
      >> wes
      >
      > Hi Wes, Mark,
      >
      > Yes I was just trying to think to keep the CPU and GPU processes
      > separate.
      > Will see what is more effective in the long run.
      >
      > So I now made a player based on your input. I noticed that if I
      > call a local matrix on every draw() or play() for the matrixcalc it
      > slowed down and crashed after a while. So now I create the
      > processing matrix in the setup. With this code I noticed that
      > dozer.mov and other short movies play fine, but that the frame rate
      > drops proportionately on longer movie files with the same photo-
      > jpeg 320x240 compression settings. The longer files play fast in
      > jit.qt.movie in a patch. I went back to jitter 1.6.3 but it didn't
      > change anything.
      >
      > The patch and code here (and below):
      > http://home.earthlink.net/~posit/lua/
      >
      > (())_n
      >
      > -- code es.play.lua
      >
      > render_context = this.drawto
      > autogarbage = 1
      > autowatch = 1
      > gc = 1
      >
      > function script_load()
      > vmovie = jit.new("jit.qt.movie")
      > vmovie.colormode = "uyvy"
      > vmovie.adapt = 1
      > vplane = jit.new("jit.gl.videoplane", render_context)
      > vplane.colormode = "uyvy"
      > vplane.scale = {1.333, 1., 1.}
      > vframe = jit.matrix(4, "char", 320, 240)
      > end
      >
      > function read(a)
      > vmovie:read(a)
      > end
      >
      > function play()
      > if (vmovie.framecount > 0) then
      > vmovie:matrixcalc(vframe.name, vframe.name)
      > outlet(0, "jit_matrix", vframe.name)
      > end
      > end
      >
      > function draw()
      > if (vmovie.framecount > 0) then
      > vmovie:matrixcalc(vframe.name, vframe.name)
      > vplane:jit_matrix(vframe.name)
      > end
      > end
      >
      >
      > -- play patch:
      >
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P newex 314 243 48 196617 loadbang;
      > #P message 314 269 82 196617 colormode uyvy;
      > #P user jit.pwindow 135 303 322 242 0 1 0 0 1 0;
      > #P newex 292 150 183 196617 jit.gl.handle bar @inherit_transform 1;
      > #P newex 292 192 127 196617 jit.gl.render bar @ortho 2;
      > #P newex 300 218 76 196617 jit.window bar;
      > #P message 208 192 80 196617 read dozer.mov;
      > #P message 171 193 30 196617 read;
      > #P message 136 193 29 196617 play;
      > #P user jit.fpsgui 66 141 60 196617 0;
      > #P newex 145 110 30 196617 t b b;
      > #P user gswitch2 136 140 39 32 0 0;
      > #P newex 136 237 64 196617 prepend call;
      > #P toggle 145 53 15 0;
      > #P newex 145 79 57 196617 qmetro 20;
      > #P newex 136 268 143 196617 jit.gl.lua bar @file es.play.lua;
      > #P comment 416 270 38 196617 (())_n;
      > #P connect 16 0 15 0;
      > #P connect 13 0 12 0;
      > #P fasten 5 1 12 0 170 178 297 178;
      > #P connect 6 1 5 1;
      > #P connect 2 0 6 0;
      > #P connect 3 0 2 0;
      > #P connect 1 0 14 0;
      > #P fasten 15 0 14 0 319 294 141 294;
      > #P connect 4 0 1 0;
      > #P connect 9 0 4 0;
      > #P connect 10 0 4 0;
      > #P connect 8 0 4 0;
      > #P connect 5 0 8 0;
      > #P fasten 6 0 7 0 150 134 71 134;
      > #P window clipboard copycount 17;
      >
      >
      >
    • Oct 25 2007 | 2:51 am
      On Oct 24, 2007, at 8:55 PM, MarkDavid Hosale wrote:
      > Wes is probably better able to address the issue you are describing
      > here as it relates to the code you posted. But, I was wondering,
      > what is your end goal? do you want to do some video processing on a
      > slab? Do some matrix processing with video? or do you want to just
      > texture some video planes?
      >
      > Depending on what you're trying to do I have some sample patches
      > that could help you and are definitely not suffering from this slow
      > down problem.
      >
      > A couple of little notes about this patch:
      > - you should erase your renderer after each bang i.e. [t b erase]
      > - it's really not important, but I would change the name of play()
      > to bang(), this way you can just run the metro directly to the
      > [prepend call] without the play message. It's more intuitive to me
      > since this is the way max objects work. Almost not worth mentioning
      > however...
      >
      > -markdavid
      Thanks for the tips markdavid,
      I made the changes. I am in the learning curve with lua. I am
      building some shapes with lua so I can have multiple shapes drawn
      with instances of jit.gl.mesh. That part is working. Although I am
      still trying to figure out drawraw in some respects because Joshua
      said it would be faster.
      Now I am trying to texture those shapes and thought I would create as
      many instances of jit.qt.movie to load onto my instances of
      jit.gl.texture. But I will not only be working with short movies.
      Some might be longer. So because of this limitation I will probably
      either go with the example I found in the archive of uploading frames
      of the videos to textures outside of lua and then binding them with
      the example of quads which wes posted a while ago or copy the output
      of the jit.qt.movie objects outside of jit.gl.lua to instances of
      jit.gl.matrix that are copied to instances of jit.gl.texture within
      lua. Then jit.gl.lua would just be for the opengl stuff and possibly
      uploading the textures.
      Beyond that I am posting what I am figuring out using matrices in
      jit.gl.lua because it might be useful to others using lua.
      Sorry to tear up the bandwidth with this.
      (())_n
    • Oct 25 2007 | 6:03 am
      here's a simple lua slab patch that seems to have better results than
      your previous example in terms of the long movie frame rate thing. I
      am not sure if there is any advantage to creating the jit.qt.movie
      object in lua over max other than for clarity in your script. I'm not
      doing it here. I tried to make this patch real simple so you could
      build up from it and test as you go. You could bypass slab, use the
      uyvy colormode, etc. for example.
      I found the glvideotrail.lua example real useful when learning the
      video texturing.
      BTW, I am by far no expert, and maybe you know this already, but you
      mentioned separating the cpu and gpu. As I understand it all the
      quicktime stuff and most matrix stuff is cpu unless you move it to
      the gpu via slab. OpenGL and shaders are gpu. I did notice some new
      graphics cards that are handling quicktime calls, but I think that is
      a separate issue.
      > Sorry to tear up the bandwidth with this.
      seems to me that's what this list is for...
      Anyway, I hope this patch helps. shoot more questions, and post more
      examples, I find this discussion really useful-
      -MarkDavid
      -- textureDemo.lua
      render_context = this.drawto
      autogarbage = 1
      autowatch = 1
      the_slab = jit.new("jit.gl.slab", render_context)
      the_slab.file = "cf.emboss.jxs"
      vplane = jit.new("jit.gl.videoplane", render_context)
      vplane.automatic = 0
      vplane.texture = the_slab.out_name
      function jit_matrix(name)
      the_slab:jit_matrix(name)
      the_slab:draw()
      end
      function draw()
      vplane:draw()
      end
      ------------
      max v2;
      On Oct 24, 2007, at 7:51 PM, (())_n wrote:
      > On Oct 24, 2007, at 8:55 PM, MarkDavid Hosale wrote:
      >
      >> Wes is probably better able to address the issue you are
      >> describing here as it relates to the code you posted. But, I was
      >> wondering, what is your end goal? do you want to do some video
      >> processing on a slab? Do some matrix processing with video? or do
      >> you want to just texture some video planes?
      >>
      >> Depending on what you're trying to do I have some sample patches
      >> that could help you and are definitely not suffering from this
      >> slow down problem.
      >>
      >> A couple of little notes about this patch:
      >> - you should erase your renderer after each bang i.e. [t b erase]
      >> - it's really not important, but I would change the name of play()
      >> to bang(), this way you can just run the metro directly to the
      >> [prepend call] without the play message. It's more intuitive to me
      >> since this is the way max objects work. Almost not worth
      >> mentioning however...
      >>
      >> -markdavid
      >
      > Thanks for the tips markdavid,
      >
      > I made the changes. I am in the learning curve with lua. I am
      > building some shapes with lua so I can have multiple shapes drawn
      > with instances of jit.gl.mesh. That part is working. Although I am
      > still trying to figure out drawraw in some respects because Joshua
      > said it would be faster.
      >
      > Now I am trying to texture those shapes and thought I would create
      > as many instances of jit.qt.movie to load onto my instances of
      > jit.gl.texture. But I will not only be working with short movies.
      > Some might be longer. So because of this limitation I will probably
      > either go with the example I found in the archive of uploading
      > frames of the videos to textures outside of lua and then binding
      > them with the example of quads which wes posted a while ago or copy
      > the output of the jit.qt.movie objects outside of jit.gl.lua to
      > instances of jit.gl.matrix that are copied to instances of
      > jit.gl.texture within lua. Then jit.gl.lua would just be for the
      > opengl stuff and possibly uploading the textures.
      >
      > http://www.cycling74.com/pipermail/jitter/2007-July/009926.html
      >
      > Beyond that I am posting what I am figuring out using matrices in
      > jit.gl.lua because it might be useful to others using lua.
      >
      > Sorry to tear up the bandwidth with this.
      >
      > (())_n
      >
      >
    • Oct 25 2007 | 7:20 am
      On Oct 25, 2007, at 2:03 AM, MarkDavid Hosale wrote
      :
      > here's a simple lua slab patch that seems to have better results
      > than your previous example in terms of the long movie frame rate
      > thing. I am not sure if there is any advantage to creating the
      > jit.qt.movie object in lua over max other than for clarity in your
      > script. I'm not doing it here. I tried to make this patch real
      > simple so you could build up from it and test as you go. You could
      > bypass slab, use the uyvy colormode, etc. for example.
      >
      > I found the glvideotrail.lua example real useful when learning the
      > video texturing.
      >
      > BTW, I am by far no expert, and maybe you know this already, but
      > you mentioned separating the cpu and gpu. As I understand it all
      > the quicktime stuff and most matrix stuff is cpu unless you move it
      > to the gpu via slab. OpenGL and shaders are gpu. I did notice some
      > new graphics cards that are handling quicktime calls, but I think
      > that is a separate issue.
      >
      >> Sorry to tear up the bandwidth with this.
      >
      > seems to me that's what this list is for...
      >
      > Anyway, I hope this patch helps. shoot more questions, and post
      > more examples, I find this discussion really useful-
      > -MarkDavid
      cool. I feel now (tomorrow) I am ready to start to deal simply with
      GPU issues in jit.gl.lua. I will look at the glvideotrail.lua again
      tomorrow.
      I made one more attempt using jit.matrix instances within jit.gl.lua
      and then using the importmovie message to load still pictures.
      Problem with reading them directly into the jit.matrix is I cannot
      specify colormode uvyv. This is why I didn't bring them to a
      videoplane yet. It seems to work though, but I only tested with 20
      images. I haven't gotten into the memsize attribute. Also I was
      having a bit of trouble outputting an int in another outlet than the
      first. It came out as lists with just one float element.
      Find it below or on the site:
      cheers,
      (())_n
      -- lua code es.matrix.lua
      autogarbage = 1
      autowatch = 1
      gc = 1
      vmatrix = {}
      vmatrixnum = 0
      current = 0
      function bang()
      current = current + 1
      if (current > vmatrixnum) then
      current = 1
      end
      if (vmatrixnum > 0) then
      outlet(0, "jit_matrix", vmatrix[current].name)
      end
      end
      function play(i)
      if (i outlet(0, "jit_matrix", vmatrix[i].name)
      end
      end
      function read(a)
      local temp = vmatrixnum + 1
      vmatrix[temp] = jit.matrix(4, "char", 320, 240)
      vmatrix[temp].adapt = 1
      vmatrix[temp]:importmovie(a)
      vmatrixnum = temp
      end
      function path(b)
      vmatrixnum = 0
      current = 0
      vmatrix = {}
      vpath = b
      end
      function readfolder(c)
      local temp = vmatrixnum + 1
      vmatrix[temp] = jit.matrix(4, "char", 320, 240)
      vmatrix[temp].adapt = 1
      vmatrix[temp]:importmovie(vpath..c)
      vmatrixnum = temp
      end
      function clear()
      vmatrixnum = 0
      current = 0
      vmatrix = {}
      end
      Max patch: