Forums > Jitter

jit.expr – creating expr dynamically


Jan 22 2009 | 1:26 am

I’m playing around with the excellent shatter examples that generate quads for jit.gl.mesh with jit.expr.
I’d like to make it variable dim, but creating the expr on the fly, according to desired dims is sort of a headache.

By headache, I mean, creating varables for the floats in

jit.expr @expr "(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.051282" "(cell[0]%4>1)*0.051282" "0." "(cell[0]%4.>0.)*(cell[0]%4.<3.)*0.025" "(cell[0]%4>1)*0.025"

eludes me.

Is there a nice way of doing this without a bunch of "pack" and "tosymbol" objects?

P

Jan 22 2009 | 2:06 am

On Jan 21, 2009, at 5:26 PM, pnyboer wrote:

>
> Is there a nice way of doing this without a bunch of "pack" and
> "tosymbol" objects?

Note that you can use multiple inputs and use in[N] with incoming
float values.

-Joshua

Jan 22 2009 | 7:54 am

Jan 22 2009 | 5:38 pm

That works. I was hoping that there was a less busy method, but your patch makes sense and does what it’s supposed to! Many thanks.

Jan 22 2009 | 6:34 pm

> a less busy method

Yes, of course, that’s just a start .

Jan 22 2009 | 6:49 pm

> a less busy method
sorry, didn’t mean that to sound critical of your patch – I just wish a less busy method was POSSIBLE, but, due to the way jit.expr takes it’s expressions, it seems required to build a lot of structure just to change a few numbers!

Attached is a dynamic version of shatter such that you can set the shatter dimensions.

Pboer

Jan 22 2009 | 7:14 pm

On Jan 22, 2009, at 10:49 AM, pnyboer wrote:

>> I just wish a less busy method was POSSIBLE, but, due to the way
>> jit.expr takes it’s expressions, it seems required to build a lot
>> of structure just to change a few numbers!

Hey. Did you even try to make an expression using multiple inputs like
I suggested?

For example the following would be your expression with second and
third inputs taking a value for width and height respectively–i.e. 1./
xdim and 1./ydim. I’ve formatted it to make it more readable:

jit.expr
@inputs 3
@expr
"(cell[0]%4.>0.)*(cell[0]%4.<3.)*in[1]"
"(cell[0]%4>1)*in[1]"
"0."
"(cell[0]%4.>0.)*(cell[0]%4.<3.)*in[2]"
"(cell[0]%4>1)*in[2]"

Am I missing something about the nature of your request or commentary
on dynamic jit.expr objects?

You can also use jit.gl.multiple for this sort of thing instead of
jit.gl.mesh if you want something easier to program (but potentially
less efficient).

-Joshua

Jan 22 2009 | 7:20 pm

On Jan 22, 2009, at 10:49 AM, pnyboer wrote:

>> a less busy method
> sorry, didn’t mean that to sound critical of your patch – I just
> wish a less busy method was POSSIBLE, but, due to the way jit.expr
> takes it’s expressions, it seems required to build a lot of
> structure just to change a few numbers!

Also check out viz_expr_octaves.js, in the audio_viz examples. It
shows a pretty clean way of doing this using Javascript.

-Randy

Jan 22 2009 | 7:28 pm

>Hey. Did you even try to make an expression
>using multiple inputs like I suggested?

No! I totally missed that reply! The "inputs" in the html doc (I’m in 4.6 for this :( ) are easy to miss. I had tried using named matrices (1 plane, 1×1), but I didn’t have much success with that (though that could have been for other reasons in the chain!)

Sorry for whining :)

Pboer

Jan 22 2009 | 7:38 pm

On Jan 22, 2009, at 11:28 AM, pnyboer wrote:
>
> No! I totally missed that reply! The "inputs" in the html doc (I’m
> in 4.6 for this :( ) are easy to miss. I had tried using named
> matrices (1 plane, 1×1), but I didn’t have much success with that
> (though that could have been for other reasons in the chain!)

p.s. you can just connect a floating point number box (or send a float
message by other means) to those inputs in case that’s not obvious.

-Joshua

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

Forums > Jitter