jit.gl.model and jit.anim.node in javascript

    Dec 04 2011 | 3:38 am
    hi, i can't understand how to write the jit.gl.model and jit.anim.node relationship in javascript.
    if i create a jit.gl.model, and then read a model (.DAE with skeleton , seymour for example), i get the nodenames easily but i can't understand how to create the nodes corresponding.
    do i need only this?? (in short version...)
    var mymodel = new JitterObject("jit.gl.model") ---read procedure and so on...--- var mynodenames = mymodel.getnodenames;
    for (n in mynodenames){ var node = new JitterObject("jit.anim.node"); node.name = mynodenames[n]; myJitAnimNodes.push (node); }
    I i do this type of code, Seymour in transformed in a compact box ! like if the nodes created get only the name but not bind the positions and quats...
    thank you for all

    • Dec 05 2011 | 12:36 am
      hi pierre. thanks for diving into this stuff!
      currently, the process for binding model nodes to anim.node objects for manipulation involves using the jit.gl.model "nodebind" message. the message takes two args, the name of the gl.model node (as returned by the "getnodenames" message) and the name of an anim.node to bind.
      so something like this might work for you in your javascript:
      var mynodenames = mymodel.getnodenames();
      for (var n in mynodenames) {
      	var node = new JitterObject("jit.anim.node");
      	var bindargs = new Array();
      	node.name = mynodenames[n]+"anode";
      	myjitanimnodes.push (node);
      the anim.node to gl.model node communication has been updated to make this process easier and more robust, so check for the next update to see these changes.
      please let me know if you have any further questions or comments on this, as we are still working out the implementation details based on user feedback. thanks!
    • Dec 05 2011 | 9:41 am
      Thank you very much, it works now. I am building a physics model for skeleton so perhaps i will ask you more, later...
      thank you
    • Dec 05 2011 | 10:33 am
      I believe i found some bug but not sure : * the worldpos message sent to jit.anim.node (the outside binded to internal model's nodes) retrieve local position, is it normal? * to load the model and get the joints. I must : - read a file and put into the gl.model - trig my initModel() function -> retrieve no nodes found. - trig a second time my initModel() function -> retrieves nodes OK, found nn nodes. is it because the context must render the model and we must wait one frame before retrieving nodes?
      here is the js code :
      var mynodenames; var mroot = new JitterObject("jit.anim.node"); var mymodel = new JitterObject("jit.gl.model"); var myjitanimnodes = new Array();
      function read (filename){ mymodel.read(filename); }
      function initModel(){ mymodel.drawto = "doll-ctx"; mymodel.smooth_shading = 1; mymodel.lighting_enable = 1; mymodel.position = [0.,-1.,-0.5]; mymodel.scale = [0.01,0.01,0.01]; mymodel.nodesaxes = 1; mymodel.axes = 1; mymodel.poly_mode = [1,1]; mymodel.drawskeleton = 1; mymodel.normalize = 0;
      mynodenames = mymodel.getnodenames(); post ("Model length : " + mynodenames.length);
      for (var n in mynodenames) { var node = new JitterObject("jit.anim.node"); var bindargs = new Array(); node.name = mynodenames[n]+"bind"; node.anim = mroot.name;
      bindargs.push(mynodenames[n]); bindargs.push(node.name);
      mymodel.nodebind(bindargs); myjitanimnodes.push(node); } }
      function getModelInfo(){ for (n in myjitanimnodes){ myjitanimnodes[n].update_node(); post("node name and local position (worldpos seems to not work) : " + myjitanimnodes[n].name + " "+ myjitanimnodes[n].worldpos + "n"); // this post() retrieve local position, not global, is it normal? } }
    • Dec 05 2011 | 7:45 pm
      hi pierre. please send me an email off list. ramirez@cycling74.com