screentoworld with depth

    Apr 13 2006 | 4:44 am
    Does anyone know a simple solution to map the screen to world when depth is involved. The following is an axample which needs modification, because the coordinates are off when depth is not zero. Thanks. Charles.
    // create our listener object for our window var mylistener = new JitterListener("listentestwindow",callbackfun); var x1, y1, z1; z1 = 0; var zscalar = 1; function callbackfun(event) { var x,y,button; if (event.eventname=="mouse") { // arguments are (x,y,button,cmd,shift,capslock,option,ctrl) x = (event.args[0]-z1); y = (event.args[1]-z1); var world = render.screentoworld(x,y); post("x,", x, "y", y);post(); if (event.args[6] == 0){ x1 = (world[0]); y1 = (world[1]); } if (event.args[6] == 1){ x1 = world[0]; z1 = world[1] * zscalar; } jsketch.position = [x1, y1, z1]
    } } callbackfun.local = 1;

    • Apr 13 2006 | 9:23 am
    • Apr 13 2006 | 9:20 pm
      Hi Charles,
      Could you better formulate your question and provide a clear example and description of what you're expecting and what's being returned. Sorry but we're too busy to make these sorts of guesses. If you provide a z argument (as distance from the *camera*, 0-1 where 0 is the near clipping plane and 1 is the far clipping plane), screen to world will give you the world position at that distance from the camera.
      In the following situation, perhaps you want to manipulate an existing object. If so, I might suggest you call worldtoscreen to determine the screen depth coordinate of the existing object first and make use of it in your calculation. Though this is complete speculation as I'm not sure what you're trying to accomplish with the following.
    • Apr 13 2006 | 9:37 pm
      On Apr 13, 2006, at 2:23 AM, Vincent Goudard wrote:
      > I am also interested by the world2screen ferature, which > unfortunately doesn't appear in the render object, when > used outside a javascript.
      This will be present in Jitter 1.5.3, however for the time being, you can make a very simple wrapper in JS to accomplish this feature. For an example of dispatching arbitrary messages (for methods and attributes) to a JS instantiated Jitter object, you might want to check out the jsmoviebank.js example. For example:
      var myjitobj = new JitterObject("jit.whatever");
      function anything() { //pass off all other messages to the wrapped Jitter Object var a = arrayfromargs(arguments);
      // detect if method or attribute and call method or set property accordingly // methods are instances of the function class, detected with the isPrototypeOf method if (Function.prototype.isPrototypeOf(myjitobj[messagename])) { myjitobj[messagename](a); } else { myjitobj[messagename] = a; } }
      > It seems yours is using a render and window outside a jsui, is it?
      Looks like it's a JS instantiated instance of