Forums > Jitter

Inputting single coordinates into GL objects

November 21, 2007 | 10:33 am

Hi there,

I was wondering whether anyone could tell me if there is a convenient way of inputting single parameters (that are usually part of a list) into GL objects, such as gridshape.

I’m interpolating between different values for a single, user-selected param (such as x-coord or y-rotation). The other values are, of course, stored inside the GL object, and while i could keep them somewhere else as well, this is extra work and double data storage.

In the example below I built what is necessary to update the X and Y-coord. It works, but it gets a lot bigger when i also want to add rotation, scale, color, blend_mode…

I suppose there is no magical ‘position 1.23 $ $’ or similar message to just input one? And there are no functions like positionx() in the gl group? Has anyone done something like this before and what would be the best way to do this?
Thanks, Bas.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 150 201 104 196617 pack position 0. 0. 0.;
#P newex 150 175 84 196617 unpack s 0. 0. 0.;
#P newex 141 112 81 196617 t b f getposition;
#P message 173 62 87 196617 position 4. $ $;
#P newex 32 220 83 196617 prepend position;
#P newex 32 56 60 196617 route x y z;
#P newex 32 200 66 196617 pack 0. 0. 0.;
#P newex 53 175 84 196617 unpack s 0. 0. 0.;
#P newex 32 112 73 196617 t f getposition;
#P newex 53 149 93 196617 jit.gl.gridshape foo;
#B color 5;
#P comment 262 62 72 196617 i’d love this! :);
#P connect 7 0 1 0;
#P connect 10 0 1 0;
#P connect 1 1 3 0;
#P connect 1 1 9 0;
#P connect 8 0 10 0;
#P connect 9 1 10 1;
#P connect 9 3 10 3;
#P connect 8 1 10 2;
#P connect 8 2 1 0;
#P connect 5 1 8 0;
#P connect 5 0 2 0;
#P connect 6 0 1 0;
#P connect 4 0 6 0;
#P connect 2 0 4 0;
#P connect 3 2 4 1;
#P connect 3 3 4 2;
#P connect 2 1 1 0;
#P window clipboard copycount 11;


November 22, 2007 | 6:45 am

I don’t know of any way to update, say, the x position value without including y and z values. It’s hard to give solutions without more knowledge of what you’re after, but here’s something (slightly simpler than what you posted).

max v2;
#N vpatcher 15 55 503 323;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 151 47 62 9109513 then adjust x;
#P newex 208 153 207 9109513 route position rotatexyz blend_mode scale color;
#P flonum 162 68 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 236 68 34 9109513 set $1;
#P message 199 68 34 9109513 set $1;
#P newex 125 90 123 9109513 pak position 0. 0. 0.;
#P message 81 90 42 9109513 getstate;
#P newex 208 182 71 9109513 unpack 0. 0. 0.;
#P newex 125 123 93 9109513 jit.gl.gridshape foo;
#B color 5;
#P comment 15 91 65 9109513 click this first;
#P connect 4 0 1 0;
#P fasten 3 0 1 0 86 115 130 115;
#P connect 7 0 4 1;
#P connect 2 1 5 0;
#P connect 5 0 4 2;
#P connect 1 1 8 0;
#P connect 8 0 2 0;
#P connect 2 2 6 0;
#P connect 6 0 4 3;
#P pop;

Zachary


November 22, 2007 | 1:25 pm

Well, explaining the whole thing is a bit pointless, but I want the user to select a single object, then a single parameter, and then control that single parameter (of a gridshape) by mouse or any other input, doesn’t really matter.

The example you posted is fine, although i don’t think it differs much from my one. It works fine, but when I want to allow the user to select the param, the whole thing gets quite big. It’s not even that it’s too difficult to make, just that I don’t like using too many objects. Since there may be quite a number of gridshapes to select from, this makes for quite a number of max objects, affecting load times etc.

In the mean time, ill stick with keeping all the parameter data somewhere else, it much easier to e.g. grab it from a coll than getting everything from the gridshape itself and routing it. Thanks for your post anyway,

It is illogical to implement separate input functions for each parameter? I know it’s done by something like glMoveTo3f() internally, but separate inputs could come in handy in some situations (especially since keeping variables and pointers is so much harder in Max than in a conventional language).


November 22, 2007 | 5:35 pm

i’m not sure i understand the problem.
"pak position 0 0 0" does store the x, y, and z positions for you, with one object, no?

and you can just send a single parameter to this and have it sent to the gridshape. why would you need positionX?


November 26, 2007 | 10:14 am

That’s correct, It’s not a problem. But I’m using up to a 100 gridshapes, and take into account that I want to be able to input rotation, color, scale and blend_mode as well.

This would add up to 500 paks to my patch, which wouldn’t be a problem in itself, but I want to update everything from saved data as well, which would mean I’d have to make sure not every single pak outputs multiple times (or also add a pack), etc.

It’s all very possible, I was just wondering what the best method is. And if those positionX() methods would have existed, i’d be instadone. From a programmers pov, pak is effectively storing data while this is already being done within a gridshape. But thanks for your replies, i already got it working…somewhat.


November 26, 2007 | 2:50 pm

pattr.

On Nov 26, 2007, at 5:14 AM, Bas van der Graaff wrote:

>
> That’s correct, It’s not a problem. But I’m using up to a 100
> gridshapes, and take into account that I want to be able to input
> rotation, color, scale and blend_mode as well.
>
> This would add up to 500 paks to my patch, which wouldn’t be a
> problem in itself, but I want to update everything from saved data
> as well, which would mean I’d have to make sure not every single pak
> outputs multiple times (or also add a pack), etc.
>
> It’s all very possible, I was just wondering what the best method
> is. And if those positionX() methods would have existed, i’d be
> instadone. From a programmers pov, pak is effectively storing data
> while this is already being done within a gridshape. But thanks for
> your replies, i already got it working…somewhat.
> –
> SmadSteck – http://www.smadsteck.nl
> Hard- and software for interactive audiovisual sampling
>


November 26, 2007 | 3:49 pm

Quote: joshua goldberg wrote on Mon, 26 November 2007 15:50
—————————————————-
> pattr.
>

Ah, I didn’t know binding to jitter attributes works with pattr, nice feature :)

So I assume Bas would ideally like to have:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 274 243 159 196617 pattr @bindto gridshape::rotatex;
#X prestore 1 0 0;
#P objectname u378004689;
#P newex 274 263 159 196617 pattr @bindto gridshape::rotatey;
#X prestore 1 0 0;
#P objectname u687004690;
#P newex 274 283 158 196617 pattr @bindto gridshape::rotatez;
#X prestore 1 0 0;
#P objectname u626004691;
#P newex 274 312 78 196617 jit.gl.gridshape;
#P objectname gridshape;
#P window clipboard copycount 4;

Mattijs


November 27, 2007 | 2:29 am

no. something like this:

#P window setfont "Sans Serif" 9.;
#P number 331 365 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 330 309 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 337 245 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 189 467 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname rotatez;
#P number 149 467 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname rotatey;
#P number 109 467 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname rotatex;
#P window linecount 1;
#P newex 92 503 100 196617 pak rotatexyz 0 0 0;
#P newex 337 270 108 196617 pattr @bindto rotatex;
#X prestore 1 0 99;
#P objectname u510000976;
#P newex 330 334 108 196617 pattr @bindto rotatey;
#X prestore 1 0 38;
#P objectname u316000977;
#P newex 332 389 107 196617 pattr @bindto rotatez;
#X prestore 1 0 112;
#P objectname u874000978;
#P newex 87 555 399 196617 jit.gl.gridshape bork @shape cube @color 1.
0. 0. 1. @scale 0.5 0.5 0.5 @lighting_enable 1;
#P objectname gridshape;
#P message 134 50 34 196617 reset;
#P newex 134 74 188 196617 jit.gl.handle bork @inherit_transform 1;
#P message 375 135 70 196617 fullscreen $1;
#P toggle 375 115 15 0;
#P newex 375 92 38 196617 sel 27;
#P newex 375 70 40 196617 key;
#P number 91 41 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user jit.fpsgui 31 178 60 196617 0;
#P toggle 31 47 15 0;
#P newex 31 153 201 196617 jit.gl.render bork @erase_color 0. 0. 0. 1.;
#P newex 31 98 58 196617 t b b erase;
#P newex 31 73 57 196617 qmetro 33;
#P newex 375 156 207 196617 jit.window bork @floating 1 @depthbuffer 1;
#P connect 23 0 14 0;
#P connect 22 0 15 0;
#P connect 21 0 16 0;
#P connect 20 0 17 3;
#P connect 19 0 17 2;
#P connect 18 0 17 1;
#P connect 17 0 13 0;
#P connect 10 0 0 0;
#P connect 9 0 10 0;
#P connect 8 0 9 0;
#P connect 7 0 8 0;
#P connect 12 0 11 0;
#P connect 6 0 1 1;
#P connect 3 0 5 0;
#P connect 2 2 3 0;
#P connect 2 0 3 0;
#P connect 11 0 3 0;
#P connect 1 0 2 0;
#P connect 4 0 1 0;
#P window clipboard copycount 24;

On Nov 26, 2007, at 10:49 AM, Mattijs Kneppers wrote:

>
> Quote: joshua goldberg wrote on Mon, 26 November 2007 15:50
> —————————————————-
>> pattr.
>>
>
> Ah, I didn’t know binding to jitter attributes works with pattr,
> nice feature :)
>
> So I assume Bas would ideally like to have:
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 274 243 159 196617 pattr @bindto gridshape::rotatex;
> #X prestore 1 0 0;
> #P objectname u378004689;
> #P newex 274 263 159 196617 pattr @bindto gridshape::rotatey;
> #X prestore 1 0 0;
> #P objectname u687004690;
> #P newex 274 283 158 196617 pattr @bindto gridshape::rotatez;
> #X prestore 1 0 0;
> #P objectname u626004691;
> #P newex 274 312 78 196617 jit.gl.gridshape;
> #P objectname gridshape;
> #P window clipboard copycount 4;
>
> Mattijs
>
> –
> SmadSteck – http://www.smadsteck.nl
> Hard- and software for interactive audiovisual sampling
>


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