multiple gl cameras ?


    Sep 23 2011 | 4:10 pm
    Hi!
    I couldn't find how to get multiple cameras in a gl context since it seems like jit.gl.render is also the camera. Is there something I overlooked?
    Thanks

    • Sep 24 2011 | 8:09 am
      i normally just end up with more than 1 render context and render everything a few times, including some javascript
      javascript to be saved as dynamicRender.js:
      //create a value to keep track of # of windows
      var valWindows=null;
      var divWindows=null;
      var windowArray=new Array();
      var renderArray=new Array();
      var videoplaneArray=new Array();
      var xyxy=new Array(4);
      var ctlArray=new Array();
      var nurbsArray=new Array();
      var sketchArray=new Array();
      var mainScreen=new Array(4);
      var secondScreen=new Array(4);
      var xtraScreen=0;
      var windowSize=new Array(320,240);
      var offsetY=50;
      var border =1;
      function setScreenSize(){
      var tempSize = arrayfromargs(arguments);
      mainScreen[0]=tempSize[0];
      mainScreen[1]=tempSize[1];
      mainScreen[2]=tempSize[2];
      mainScreen[3]=tempSize[3];
      secondScreen[0]=tempSize[4]-tempSize[0];
      secondScreen[1]=tempSize[5]-tempSize[1];
      secondScreen[2]=tempSize[6]-tempSize[2];
      secondScreen[3]=tempSize[7]-tempSize[3];
      if(secondScreen[0]==0 && secondScreen[1]==0 && secondScreen[2]==0 && secondScreen[3]==0){
      xtraScreen=0;
      }else{
      xtraScreen=1;
      }
      }
      function setWindowsize(x,y){
      windowSize[0]=x;
      windowSize[1]=y;
      }
      function calculateWindowsize(){
      }
      function setBorder(n){
      var i=0;
      for(i ==0; i windowArray[i].border=n;
      }
      }
      function setFSAA(n){
      var i=0;
      for(i ==0; i windowArray[i].fsaa=n;
      }
      }
      function setScreens(d,n){
      //d is how many columns of screens
      //n is total # of screens
      divWindows =d-1;
      valWindows=n;
      var i=0;
      for(i ==0; i windowArray[i] = new JitterObject("jit.window","screen"+i);
      windowArray[i].depthbuffer = 1;
      windowArray[i].fsaa = 1;
      var x1=i*windowSize[0];
      var y1=offsetY+divWindows*windowSize[1];
      var x2=i*windowSize[0]+windowSize[0];
      var y2=offsetY+divWindows*windowSize[1]+windowSize[1];
      windowArray[i].rect = [x1,y1,x2,y2];
      post("create render "+i+" n");
      renderArray[i] = new JitterObject("jit.gl.render","screen"+i);
      renderArray[i].ortho=2;
      // post("create videoplane "+i+" n");
      // videoplaneArray[i]=new JitterObject("jit.gl.videoplane","screen"+i);
      // videoplaneArray[i].automatic=1;
      // videoplaneArray[i].texture="TEX";
      post("create sketch "+i+" n");
      sketchArray[i] = new JitterObject("jit.gl.sketch","screen"+i);
      sketchArray[i].reset();
      sketchArray[i].lighting_enable = 1;
      sketchArray[i].smooth_shading = 1;
      // sketchArray[i].drawobject(videoplaneArray[i]);
      }
      }
      function drawObject(index,name){
      var i=0;
      if(index==0){
      for(i ==0; i sketchArray[i].drawobject(name);
      }
      }else{
      sketchArray[index].drawobject(name);
      }
      }
      function setPosition(){
      var l=arrayfromargs(arguments);
      if(l.length==3){
      windowArray[l[0]].rect = [l[1],l[2],l[1]+windowSize[0],l[2]+windowSize[1]];
      }else if(l.length==5){
      windowSize[0]=l[3];
      windowsize[1]=l[4];
      windowArray[l[0]].rect = [l[1],l[2],l[1]+windowSize[0],l[2]+windowSize[1]];
      }
      }
      //function drawNurbs(){
      // var i=0;
      // for(i ==0; i // nurbsArray[i]=new JitterObject("jit.gl.nurbs","screen"+i);
      // nurbsArray[i].dim=[2,2];
      // ctlArray[i]=[-1,1,1,-1];
      // nurbsArray[i].ctlarray=[-1,1,1,-1];
      // }
      //}
      //
      //function setCtlNurbs(x,y,x2,y2){
      // var i=0;
      // for(i ==0; i // ctlArray[i]=[x,y,x2,y2];
      // post(ctlArray[i]+"n");
      // nurbsArray[i].ctlarray=ctlArray[i];
      // }
      //}
      function setCamera(){
      var l=arrayfromargs(arguments);
      if(l.length==3){
      renderArray[l[0]].camera =[l[1],l[2],2];
      renderArray[l[0]].lookat =[l[1],l[2],0];
      }else if(l.length==7){
      renderArray[l[0]].camera =[l[1],l[2],l[3]];
      renderArray[l[0]].lookat =[l[4],l[5],l[6]];
      }
      }
      function bang()
      {
      if(windowArray.length!=0){
      var j=0;
      while(j renderArray[j].erase();
      renderArray[j].drawswap();
      renderArray[j].drawclients();
      renderArray[j].swap();
      j++;
      }
      }else{
      post("need to set at least 1 screen n")
      }
      }
      function setPosTorus(x,y,z)
      {
      var i=0;
      for(i ==0; i // randomize jit.gl.sketch's position, rotation, scale, and color
      sketchArray[i].position = [x,y,z];
      }
      }
    • Sep 26 2011 | 2:35 pm
      Thanks llumen!
      Great patch, really ingenious.
    • Sep 26 2011 | 4:29 pm
      that's nice 'n neat!
      remark: runs well with FSAA off but all windows flicker when i have FSAA on. any idea why?
    • Sep 27 2011 | 4:06 am
      no idea about the flickering, I've noticed it too when on a windows machine, but not on my mac-machine.
    • Sep 28 2011 | 12:12 am
      i'm on a MBP...
    • Oct 07 2011 | 12:33 pm
      another way :