Forums > Jitter

# geometry controled by expression

November 24, 2006 | 1:21 am

hmm…
is it possible, using jit.expr with 3 expressions inside wich are using 2 variables(input 0 and input 1) to generate a geometry?
each expression would generate a coordinate(first expression X, second Y, third Z, wich would then come out as a 3 plane float32 matrix.
This matrix would then generate a surface wich i could manipulate(using the GL commands) and then render such surface to a jitter window.

So is it possible to achieve such goal?

Bruno Gustavo Costa

PS

i’m using Jitter 1.5.2 at school, so please take this into account… not yet capable of using jitter 1.6 funcionalities

November 24, 2006 | 2:17 am

Sure. This is basically doing f(x, y) = z for each plane. An example
of making a sphere would be jit.expr @expr
"cos(snorm[0]*PI)*sin(norm[1]*PI)" "sin(snorm[0]*PI)*sin(norm[1]*PI)"
"cos(norm[1]*PI)". Heed the result into jit.gl.mesh or a nurbs object
and you’ll have you form.

wes

On 11/23/06, Bgustavo wrote:
>
> hmm…
> is it possible, using jit.expr with 3 expressions inside wich are using 2 variables(input 0 and input 1) to generate a geometry?
> each expression would generate a coordinate(first expression X, second Y, third Z, wich would then come out as a 3 plane float32 matrix.
> This matrix would then generate a surface wich i could manipulate(using the GL commands) and then render such surface to a jitter window.
>
> So is it possible to achieve such goal?
>
>
> Bruno Gustavo Costa
>

November 24, 2006 | 11:32 am

first i’d like to say thanks wes, but one thing i dont understand though is what do i connect to the jit.expr object…

i’ve got the jit.expr connected to a prepend ctlmatrix in order to connect it to the nurbs object, and i think i need the snorm[0] and norm[1] to be driven by some numbers… in order to get the values to the matrix of vertexes.

i’ve tried 2 floats(one each inlet) and also 2 jit.noise matrixes.
the error i get is :

.error: jit.gl.nurbs:requres order < = number of control points

i don’t really know this means… i understand the error, yet i dont understand how to make it right.

November 24, 2006 | 3:55 pm

you do this
[jit.matrix 3 float32 40 40]
|
[jit.expr @expr "......" "....." "....."]
|
[prepend ctlmatrix]
|
[jit.gl.nurbs]

I’d post a patch, but my max computer can’t get internet here.

wes

On 11/24/06, Bgustavo wrote:
>
> first i’d like to say thanks wes, but one thing i dont understand though is what do i connect to the jit.expr object…
>
> i’ve got the jit.expr connected to a prepend ctlmatrix in order to connect it to the nurbs object, and i think i need the snorm[0] and norm[1] to be driven by some numbers… in order to get the values to the matrix of vertexes.
>
> i’ve tried 2 floats(one each inlet) and also 2 jit.noise matrixes.
> the error i get is :
>
> .error: jit.gl.nurbs:requres order < = number of control points
>
> i don’t really know this means… i understand the error, yet i dont understand how to make it right.
>
> –
> Many thanks,
>
> Bruno Gustavo Costa
>

November 24, 2006 | 4:41 pm

once again thanks wes, the sphere did show up, yet my problem is when i change the expression to these:

x = 2 sin(3 u) / (2 + cos(v))

y = 2 (sin(u) + 2 sin(2 u)) / (2 + cos(v + 2 pi / 3))

z = (cos(u) – 2 cos(2 u)) (2 + cos(v)) (2 + cos(v + 2 pi / 3)) / 4

where
-pi < = u <= pi
-pi < = v <= pi

i’ve included the file below if it can be of any help.

the expressions are taken from

http://local.wasp.uwa.edu.au/~pbourke/surfaces/

i’d like to see jitter do some of these surfaces… yet no luck whatsoever,

Many thanks wes for showing some light on the subject.

////////////

max v2;
#N vpatcher 181 265 1193 717;
#P window setfont "Sans Serif" 9.;
#P number 92 70 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 92 98 54 196617 dim \$1 \$1;
#P number 17 79 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 17 104 63 196617 order \$1 \$1;
#P toggle 134 180 15 0;
#P message 123 201 58 196617 ctlshow \$1;
#P newex 25 237 77 196617 jit.gl.nurbs foo;
#P newex 25 197 89 196617 prepend ctlmatrix;
#P newex 359 309 75 196617 jit.window foo;
#P newex 184 251 50 196617 t b erase;
#P newex 174 372 82 196617 jit.gl.render foo;
#P number 232 184 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 192 184 15 0;
#P newex 184 215 57 196617 qmetro 20;
#P button 222 54 15 0;
#P newex 226 80 122 196617 jit.noise 3 float32 40 40;
#P window linecount 3;
#P newex 326 347 378 196617 jit.expr @expr "2sin(3*snorm[0]) / (2 + cos(norm[1]))" "2(sin(snorm[0]) + 2 sin(2*snorm[0])) / (2 + cos(norm[1] + 2*PI / 3))" "(cos(snorm[0]) – 2*cos(2*snorm[0])) (2 + cos(norm[1])) (2 + cos(norm[0] + 2*PI/3))/4" @cache 0;
#P connect 14 0 13 0;
#P connect 0 0 9 0;
#P connect 15 0 10 0;
#P connect 13 0 10 0;
#P connect 11 0 10 0;
#P connect 9 0 10 0;
#P connect 16 0 15 0;
#P connect 12 0 11 0;
#P connect 7 0 6 0;
#P connect 7 1 6 0;
#P connect 4 0 3 0;
#P connect 3 0 7 0;
#P connect 2 0 1 0;
#P connect 5 0 3 1;
#P connect 1 0 0 0;
#P pop;

November 24, 2006 | 5:17 pm

I recommend searching for "supershape" in the forum. There was recently
a whole thread about it, and (I believe) some working patches that do
the job.

Cheers,
Andrew B.

November 24, 2006 | 9:02 pm

that’s exactly what i was searching for…
you hit the spot.

thanks, and wesley’s help was great too.

November 25, 2006 | 3:34 am

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