sending jit.movie to videoplane using output_texture in js


    Jan 08 2019 | 2:51 am
    Hello, I'm trying to figure out how to use the (somewhat)new output_texture feature of jit.movie to draw directly to a videoplane in js, and I'm missing something.
    The attached patcher contains a js which creates two videoplanes, and one jit.movie. it has one function, which is to read a movie, which in theory should play on the videoplane with the corresponding texture name. In the Max patch, I have a regular jit.movie which has a texture name corresponding with the second videoplane.
    If I load a movie into the jit.movie object, it happily plays on the js-instantiated videoplane. However, if I do the same with the js-instantiated movie, the movie is playing (you can hear it), but it is not drawing to the videoplane.
    I feel like I must be missing something, doesn anyone know? JS and patch below. Thanks!
    \M
    //one-plane.js
    autowatch = 1;
    // create a videoplane for the js-instantiated movie
    var vp = new JitterObject("jit.gl.videoplane", "bob"); vp.blend_enable = 1; vp.color = [1.,1.,1.,1.]; vp.scale = [.5,.5,.5]; vp.position = [0.6,0.,0.]; vp.enable = 1; vp.automatic = 1; vp.texture = ("tex_1");
    // create a videoplane for the external movie
    var vp2 = new JitterObject("jit.gl.videoplane", "bob"); vp2.blend_enable = 1; vp2.color = [1.,1.,1.,1.]; vp2.scale = [.5,.5,.5]; vp2.position = [-.6,0.,0.]; vp2.enable = 1; vp2.automatic = 1; vp2.texture = ("tex_2");
    //create a movie
    var vm = new JitterObject("jit.movie"); vm.drawto = "bob"; vm.output_texture = 1; vm.automatic = 1; vm.texture_name = ("tex_1");
    function play_movie(name){
    vm.read(name);
    }
    Patch:

    • Jan 08 2019 | 5:38 pm
      unfortunately jit.movie automatic mode only works outside of JS, so you have to add a few more lines of code to get this to work.
      first you must create a JitterListener for your jit.world context, and a dummy JitterMatrix for the jit.movie matrix_calc method: var l = new JitterListener("bob", callbackfun); var dummymatrix = new JitterMatrix(4,"char",320,240);
      Then you must create a callback function to trigger matrix_calc each draw (if the JitterListener is attached to the root gl.render context instead of a jit.gl.node or jit.world, then you should listen for the "swap" event instead of the "draw" event):
      function callbackfun(e) { //post(e.eventname+"\n"); if (e.eventname == "draw") { vm.matrixcalc(dummymatrix,dummymatrix); } }
    • Jan 08 2019 | 5:59 pm
      Ah, I was worried I was going to have to use the dreaded matrixcalc. But the matrix is just a dummy, and the texture output of the jit.movie is still rendering directly to the videoplane? I. e., the movie is never going through the matrix, yes?
      And just out of curiosity, isn't automatic working for the videoplanes? why is the external movie showing if the videoplane isn't automatically rendering?
      Thanks!
      \M
    • Jan 08 2019 | 6:06 pm
      yes and yes
      jit.gl.* automatic is a different mechanism from jit.movie automatic. I know it's confusing that that's what it is.
    • Jan 08 2019 | 6:11 pm
      It's often confusing, but I'm used to it after all these years. Thanks a lot, Rob, you've been a big help!
      \M
    • Jan 16 2019 | 5:50 pm
      Hey Rob, does the callback function work in a standalone? I'm seeing these errors on loading an app: method setcbdata called on invalid object method setcallback called on invalid object
      And, if I try to post() the eventname, nothing comes out.
      I rewrote the listener using the bang() function, but I was curious as to whether a jitterListener can run in a standalone... \M
    • Jan 16 2019 | 5:52 pm
      hmm, can't see why it wouldn't but I'll take a look
    • Jan 16 2019 | 6:22 pm
      And the crazy thing is that using bang() to draw to my videoplanes has disabled the Task scheduler! (I'm banging movies in an array vm, and vx is the dummy matrix array)
      function bang(){
      for (var i = 0; i < movie_count; i++) { vm[i].matrixcalc(vx[i],vx[i]); } }
    • Jan 17 2019 | 5:42 pm
      i just tested a standalone made from the js.gl.matrixoutput example file using Max 8.0.3, and I had no problems. So we'll need more info on what you're doing to create your standalone, platform, max version, etc, and a full patch.
    • Jan 17 2019 | 7:28 pm
      Hey Rob, I did get it working, in a kind of weird & kludgey way, but I'll send it along to you privately. As far as my last issue went, I found that the scheduler works if and only if I define my Tasks in global code. Originally, I was declaring them in a function, which worked fine with the JitterListener, but didn't when I was rendering with a bang. I'll get it to you in a day or two...
      \M