Forums > Jitter

screen to world by hand ?

June 7, 2006 | 11:17 am

Has anyone figured out a way to map screen to 3d world without using javascript?

I am trying to make an interface for a pluggo plugin. Jitter JS doesn’t seem to draw to a screen in the pluggo environment, and JSUI is out of the question for other reasons. Also I don’t want to use jit.gl.handle because (a) I want the default transform to be position not rotation (b) the mod key is overridden by a pluggo menu

I don’t mind coding some matrix math, but I need a step in the direction; is it possible?

thanks,
Charles


June 7, 2006 | 11:54 am

Have you looked at the JitterHitTest example in the jitter/javascript folder?

wes



VG
June 7, 2006 | 6:36 pm


June 7, 2006 | 6:57 pm

On Jun 7, 2006, at 4:54 AM, Wesley Smith wrote:

> Have you looked at the JitterHitTest example in the jitter/
> javascript folder?

This uses javascript’s screentoworld method, fwiw. In Jitter
1.5.3/1.6, screentoworld and worldtoscreen will be exposed to the
patcher via jit.gl.render, however for the meantime, you can just
make a simple Javascript which wraps jit.gl.render. You can of course
perform all the matrix math necessary to accomplish this, and I know
at least one person whose done this with jit.la.*, but your math
chops will need to be up to snuff.

I’ve taken 15 minutes to build a js wrapper workalike for
jit.gl.render and an example patch which uses it (at bottom). Similar
can be done for any Jitter object.

Hope this helps.

-Joshua

/**************************
begin jsrender.js
***************************/

outlets = 2;
var contextname = "";

if (jsarguments.length>1)
contextname = jsarguments[1];

var render;

if (render)
render.freepeer(); // when editing JS file, explicitly free c peer
before allocating another one

render = new JitterObject("jit.gl.render",contextname);

function screentoworld()
{
var a = arrayfromargs(arguments);
var w = render.screentoworld(a);
outlet(1,"screentoworld",w);
}

function worldtoscreen()
{
var a = arrayfromargs(arguments);
var s = render.worldtoscreen(a);
outlet(1,"worldtoscreen",s);
}

function bang()
{
render.drawswap();
outlet(0,"bang");
}

function anything()
{
//pass off all other messages to the movie object
var a = arrayfromargs(arguments);
if (Function.prototype.isPrototypeOf(render[messagename])) {
render[messagename](a);
if (messagename=="swap"||messagename=="drawswap")
outlet(0,"bang");
} else {
if (messagename.length>3&&messagename[0]==’g'&&messagename[1]
==’e'&&messagename[2]==’t')
{
var attrname = messagename.slice(3);
var rv = render[attrname];
outlet(1,attrname,rv);
} else {
render[messagename] = a;
}
}
}

/**************************
end jsrender.js
***************************/

example patch below:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 163 537 57 196617 getcamera;
#P flonum 339 513 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 339 537 120 196617 worldtoscreen $1 $1 $1;
#P flonum 224 513 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 224 537 105 196617 screentoworld $1 $1;
#P flonum 76 513 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 76 537 82 196617 camera 0 $1 $1;
#P user jit.fpsgui 15 618 60 196617 0;
#P newex 95 619 58 196617 print dump;
#P window linecount 3;
#P comment 723 300 81 196617 turn OFF auto_material to use shininess.;
#P toggle 592 320 15 0;
#P window linecount 1;
#P message 592 343 88 196617 auto_material $1;
#P message 685 343 64 196617 shininess $1;
#P flonum 685 320 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 340 419 15 0;
#P message 340 437 55 196617 floating $1;
#P toggle 250 287 15 0;
#P comment 271 287 100 196617 draw as mesh;
#P hidden message 48 413 68 196617 camera 0 0 4;
#P flonum 669 222 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 631 222 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 591 222 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 566 249 85 196617 pak scale 1. 1. 1.;
#P newex 323 170 158 196617 jit.gl.handle foo @depth_enable 1;
#P toggle 267 419 15 0;
#P newex 228 418 35 196617 sel 27;
#P message 267 437 68 196617 fullscreen $1;
#P newex 185 461 145 196617 jit.window foo @depthbuffer 1;
#P newex 183 418 40 196617 key;
#P newex 213 186 43 196617 r grimy;
#P newex 188 367 43 196617 s grimy;
#P flonum 688 270 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 650 270 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 610 270 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 377 320 15 0;
#P message 377 343 94 196617 smooth_shading $1;
#P message 103 346 79 196617 color 0. 1. 0. 1.;
#P toggle 476 320 15 0;
#P message 476 343 90 196617 lighting_enable $1;
#P toggle 54 325 15 0;
#P message 54 346 44 196617 axes $1;
#P toggle 270 324 15 0;
#P toggle 229 323 15 0;
#P newex 188 344 92 196617 pak poly_mode 0 0;
#P hidden newex 416 277 50 196617 loadbang;
#P number 60 105 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 289 320 15 0;
#P message 289 343 81 196617 depth_enable $1;
#P toggle 15 105 15 0;
#P newex 15 131 57 196617 qmetro 20;
#P newex 15 185 50 196617 t b erase;
#P newex 196 246 158 196617 jit.gl.gridshape foo @shape torus;
#B color 5;
#P newex 15 585 90 196617 js jsrender.js foo;
#P hidden message 417 299 14 196617 1;
#P newex 582 294 95 196617 pak position 0. 0. 0.;
#P toggle 493 166 15 0;
#P message 493 195 82 196617 matrixoutput $1;
#P connect 8 0 7 0;
#P connect 7 0 6 0;
#P fasten 56 0 4 0 168 568 20 568;
#P fasten 54 0 4 0 344 568 20 568;
#P fasten 52 0 4 0 229 568 20 568;
#P fasten 50 0 4 0 81 568 20 568;
#P fasten 5 0 4 0 201 297 20 297;
#P hidden fasten 38 0 4 0 53 506 20 506;
#P fasten 6 1 4 0 42 213 20 213;
#P connect 6 0 4 0;
#P connect 4 0 49 0;
#P hidden connect 12 0 38 0;
#P connect 17 0 16 0;
#P connect 11 0 7 1;
#P connect 51 0 50 0;
#P connect 4 1 48 0;
#P fasten 41 0 29 0 345 456 190 456;
#P fasten 30 0 29 0 272 456 190 456;
#P fasten 44 0 26 0 690 362 193 362;
#P fasten 45 0 26 0 597 362 193 362;
#P fasten 2 0 26 0 587 362 193 362;
#P fasten 16 0 26 0 59 364 193 364;
#P fasten 18 0 26 0 481 362 193 362;
#P fasten 21 0 26 0 382 362 193 362;
#P fasten 20 0 26 0 108 364 193 364;
#P fasten 13 0 26 0 193 364 193 364;
#P fasten 9 0 26 0 294 362 193 362;
#P fasten 34 0 26 0 571 362 193 362;
#P fasten 33 0 5 0 328 230 201 230;
#P fasten 27 0 5 0 218 224 201 224;
#P fasten 0 0 5 0 498 218 201 218;
#P connect 53 0 52 0;
#P fasten 28 0 31 0 188 437 225 437 225 416 233 416;
#P fasten 40 0 14 0 255 312 234 312;
#P connect 14 0 13 1;
#P fasten 31 0 32 0 233 436 264 436 264 416 272 416;
#P connect 32 0 30 0;
#P fasten 40 0 15 0 255 313 275 313;
#P connect 15 0 13 2;
#P hidden fasten 3 0 10 0 422 317 294 317;
#P connect 10 0 9 0;
#P connect 55 0 54 0;
#P connect 42 0 41 0;
#P hidden fasten 3 0 22 0 422 317 382 317;
#P connect 22 0 21 0;
#P hidden connect 12 0 3 0;
#P hidden fasten 3 0 19 0 422 317 481 317;
#P connect 19 0 18 0;
#P connect 1 0 0 0;
#P connect 35 0 34 1;
#P hidden fasten 3 0 46 0 422 317 597 317;
#P connect 46 0 45 0;
#P connect 23 0 2 1;
#P fasten 36 0 34 2 636 243 621 243;
#P fasten 24 0 2 2 655 289 643 289;
#P fasten 37 0 34 3 674 243 646 243;
#P fasten 25 0 2 3 693 289 671 289;
#P connect 43 0 44 0;
#P window clipboard copycount 57;


June 8, 2006 | 1:22 am

I appreciate the effort, but it doesn’t work when compiled to a plugin and loaded into an external vst host (Nunendo 3 in this case).

Error: render has no properties.

Further test suggest to me that the jitter js object constructor isn’t working in external vst hosts.

I tried making a plugin with nothing but a js object and the following text:

var mult = new JitterObject("jit.la.mult");

and the window within the plugin stated:

"Javascript reference error: JitterObject is not defined, line 0"

I included the external in the build script, and jitlib file. Have you known anyone to get Jitter JS loaded in an external VST host?

thanks
charles


June 8, 2006 | 1:48 am

You need to *not* include jitlib in the build script. This is not
supported for libraries which are not externs.

You *do* need to place jitlib in CFM support.

You *do* need to place jsjitter in the jsextensions folder for
Pluggo, which depending on which version of pluggo will be /Library/
Application Support/Cycling 74/ or the Pluggo Support folder
(wherever that is…I don’t know off the top of my head).

You *do* need to place any additional exerns used (such as
jit.gl.render in this case) in either the build-script (and the
"nostrip" file so that this file remains when building your plugin;
for more info please consult pluggo developer docs), or simply in the
Pluggo Support folder which is one of the two places mentioned above.

If you wish to use other necessary Jitter items such as Cg.framework,
Java support, or shader files, please follow the instructions in
Appendix D of the Jitter 1.5.2 Manual, but place in the appropriate
Pluggo support folder rather than the Standalone bundle.

Hope this helps.

-Joshua


June 8, 2006 | 3:16 am

jsjitter is in the cycling ’74/jsextensions folder, but not in the pluggo support folder, so i’ll try that. Everything else you mentioned is in place. Except I have not tried the "nostrip" file, which from reading the docs appears to be for older versions of pluggo anyway.

The reason I could never find Appendix D is the following:

The link on the website:
Jitter 1.5 documentation only (Mac version)

on both the the downloads and documention menu delivers possibly an older version without Appendix D.
Thanks again.


June 8, 2006 | 3:39 am

On Jun 7, 2006, at 8:16 PM, veaseyc wrote:

>
> jsjitter is in the cycling ’74/jsextensions folder, but not in the
> pluggo support folder, so i’ll try that. Everything else you
> mentioned is in place. Except I have not tried the "nostrip" file,
> which from reading the docs appears to be for older versions of
> pluggo anyway.

Okey doke. Been years since I’ve made a pluggo.

> The reason I could never find Appendix D is the following:
>
> The link on the website:
> Jitter 1.5 documentation only (Mac version)

Sorry but you need to download the 1.5.2 installer to get the current
version with Appendix D.

-Joshua


June 9, 2006 | 11:49 am

Placing jsjitter in the folder:

..Library: Application Support: C74 Plug-in Support: jsextensions

did the trick, js jitter working in an external plugin host.

thanks.

Now I can use the screentoworld, but I am a bit unsure if it can help me.

I am making 3D audio panning plugins, and want them to have a central graphical hub. The idea is whenever someone loads a panning plugin, a little sphere will be added to the graphic plugin, which in turn allows one to either position the audio visually with the mouse/keyboard or with the panning plugin cartesian/polar coordintates.

I have everything working, except that when the object is not at z=0 or the world is rotated, the mouse (I use simple 2d mapping based on the window size) of course is not lined up correctly in relation to the graphic. I see the JitterHitTest example on how to get the position of the torus, but then it uses jit.handle to position them. I can’t use jit.handle because the the Z enabling modifier key is being overtaken by pluggo. Also I would like position to be the default mouse activity not rotation. Can this be modified so that jit.handle is not being used?

Currently the way I am working this plugin system out is that I have placed a jit.gl.gridhape object inside each panning plugin. The name of the render destination is the same as render and window in graphic plugin so it works out. I know there are other ways to go about it, but this seems to give me good results. Does doing it this way still allow me get it’s position through the screentoworld function?

thanks again,
Charles


Viewing 9 posts - 1 through 9 (of 9 total)