Forums > Jitter

lua gencoord

October 24, 2007 | 2:40 am

Hi lua maxers,

I started doing some work with jit.gl.lua and thought I would post
what I found out.
I noticed if I use an instance of jit.expr in lua I had to bracket
the input and output with an instance of jit.matrix (vpoint, vgen) to
be able to perform the matrixcalc and use the data within lua code or
output it. Is there a simpler way to calculate matrix messages in
jit.gl.lua? This is the only way I could get it to work so far…

(())_n

http://home.earthlink.net/~posit/lua

– lua code

render_context = this.drawto
autogarbage = 1
autowatch = 1
gc = 1
points = 50

– called on every gl.draw unless @automatic 0
function draw()
makepoints()
end

– generate points
function makepoints()
local vpoint = jit.matrix(2, "float32", points, points)
local vgen = jit.matrix(2, "float32", points, points)
local vexpr = jit.new("jit.expr")
vexpr.expr = {"norm[0]", "norm[1]"}
vexpr.inputs = 1
vexpr.type = "float32"
vexpr:matrixcalc(vpoint.name, vgen.name)
outlet(0, "jit_matrix", vgen.name)
end

– set the dimensions of the matrix
function dim(x)
points = x
end


October 24, 2007 | 2:58 am

The following should work. Note that even in a patcher jit.expr
requires an input jit.matrix object so that being also the case in
jit.gl.lua is consistent. All I did below was make the calculations
happen in-place.

wes

render_context = this.drawto
autogarbage = 1
autowatch = 1
gc = 1
points = 50

– called on every gl.draw unless @automatic 0
function draw()
makepoints()
end

– generate points
function makepoints()
local vpoint = jit.matrix(2, "float32", points, points)
local vexpr = jit.new("jit.expr")
vexpr.expr = {"norm[0]", "norm[1]"}
vexpr.inputs = 1
vexpr.type = "float32"
vexpr:matrixcalc(vpoint.name, vpoint.name)
outlet(0, "jit_matrix", vpoint.name)
end

– set the dimensions of the matrix
function dim(x)
points = x
end


October 24, 2007 | 4:52 am

hi wes,

sweet. thanks that gives me a new view of things. so I only need to
create an instance of one matrix and pass it along.

super.

another question which I haven’t quite found an answer to: If I
create an instance of jit.qt.movie how do I reference the output
matrix when it plays? In jitter I would just send it a bang, but in
lua I am having trouble getting a matrix. the read message I seem to
have working… but it seems some messages work and others don’t. Am
I right to assume that messages take the : and atributes the .
between the instance and message?

function load(a)
vmovie = jit.new("jit.qt.movie")
vmovie.colormode = "uyvy"
vmovie.adapt = 1
vmovie:read(a)
local vframe = jit.matrix(2, "char", 320, 240)
– I get an error: "jit.qt.movie: could not create gworld" if I
call the following but no film has been read
vmovie:matrixcalc(vframe.name, vframe.name)
outlet(0, "jit_matrix", vframe.name)
end

(())_n

On Oct 23, 2007, at 10:58 PM, Wesley Smith wrote:

> The following should work. Note that even in a patcher jit.expr
> requires an input jit.matrix object so that being also the case in
> jit.gl.lua is consistent. All I did below was make the calculations
> happen in-place.
>
> wes
>
> render_context = this.drawto
> autogarbage = 1
> autowatch = 1
> gc = 1
> points = 50
>
> — called on every gl.draw unless @automatic 0
> function draw()
> makepoints()
> end
>
> — generate points
> function makepoints()
> local vpoint = jit.matrix(2, "float32", points, points)
> local vexpr = jit.new("jit.expr")
> vexpr.expr = {"norm[0]", "norm[1]"}
> vexpr.inputs = 1
> vexpr.type = "float32"
> vexpr:matrixcalc(vpoint.name, vpoint.name)
> outlet(0, "jit_matrix", vpoint.name)
> end
>
> — set the dimensions of the matrix
> function dim(x)
> points = x
> end


October 24, 2007 | 5:23 am

works for me. BTW, you might want to make your matrix 4 plane. Are
you in windows or OSX? What version of jit.gl.lua do you have?

wes

On 10/23/07, (())_n wrote:
> hi wes,
>
> sweet. thanks that gives me a new view of things. so I only need to
> create an instance of one matrix and pass it along.
>
> super.
>
> another question which I haven’t quite found an answer to: If I
> create an instance of jit.qt.movie how do I reference the output
> matrix when it plays? In jitter I would just send it a bang, but in
> lua I am having trouble getting a matrix. the read message I seem to
> have working… but it seems some messages work and others don’t. Am
> I right to assume that messages take the : and atributes the .
> between the instance and message?
>
> function load(a)
> vmovie = jit.new("jit.qt.movie")
> vmovie.colormode = "uyvy"
> vmovie.adapt = 1
> vmovie:read(a)
> local vframe = jit.matrix(2, "char", 320, 240)
> — I get an error: "jit.qt.movie: could not create gworld" if I
> call the following but no film has been read
> vmovie:matrixcalc(vframe.name, vframe.name)
> outlet(0, "jit_matrix", vframe.name)
> end
>
> (())_n
>
> On Oct 23, 2007, at 10:58 PM, Wesley Smith wrote:
>
> > The following should work. Note that even in a patcher jit.expr
> > requires an input jit.matrix object so that being also the case in
> > jit.gl.lua is consistent. All I did below was make the calculations
> > happen in-place.
> >
> > wes
> >
> > render_context = this.drawto
> > autogarbage = 1
> > autowatch = 1
> > gc = 1
> > points = 50
> >
> > — called on every gl.draw unless @automatic 0
> > function draw()
> > makepoints()
> > end
> >
> > — generate points
> > function makepoints()
> > local vpoint = jit.matrix(2, "float32", points, points)
> > local vexpr = jit.new("jit.expr")
> > vexpr.expr = {"norm[0]", "norm[1]"}
> > vexpr.inputs = 1
> > vexpr.type = "float32"
> > vexpr:matrixcalc(vpoint.name, vpoint.name)
> > outlet(0, "jit_matrix", vpoint.name)
> > end
> >
> > — set the dimensions of the matrix
> > function dim(x)
> > points = x
> > end
>
>


October 24, 2007 | 4:45 pm

On Oct 24, 2007, at 1:23 AM, Wesley Smith wrote:

> works for me. BTW, you might want to make your matrix 4 plane. Are
> you in windows or OSX? What version of jit.gl.lua do you have?
>
> wes

Hi Wes,

Thanks. I overlooked the 4 planes. Yes it works but not until I have
read a file into jit.qt.movie. if I haven’t read a file I get the
error: "jit.qt.movie: could not create gworld." So matrixcalc is the
only way for an instance of jit.qt.movie to output a matrix in
jit.gl.lua?

I am on 12" pwrbk g4 GeForce FX Go5200 osx 10.4.10 max 4.6.3 jitter
1.6.3 jit.gl.lua is b4
Note: I updated to the Jitter "1.6.4-x1 :: Experimental Jitter
framework" and still get the same error.

(())_n

here is the code that illustrates this behavior:

render_context = this.drawto
autogarbage = 1
autowatch = 1
gc = 1

function script_load()
vmovie = jit.new("jit.qt.movie")
vmovie.colormode = "uyvy"
vmovie.adapt = 1
end

function read(a)
vmovie:read(a)
local vframe = jit.matrix(4, "char", 320, 240)
vmovie:matrixcalc(vframe.name, vframe.name)
outlet(0, "jit_matrix", vframe.name)
end

– I get an error: "jit.qt.movie: could not create gworld"
– if I call the following but no film has been read
function play()
local vframe = jit.matrix(4, "char", 320, 240)
vmovie:matrixcalc(vframe.name, vframe.name)
outlet(0, "jit_matrix", vframe.name)
end


October 24, 2007 | 5:20 pm

I am confused by the play function. Don’t you want to do something
more like this? Also fixes the gworld error:

– movieplayer.lua

render_context = this.drawto
autogarbage = 1
autowatch = 1
gc = 1

function script_load()
vmovie = jit.new("jit.qt.movie")
vmovie.colormode = "uyvy"
vmovie.adapt = 1
end

function read(a)
vmovie:read(a)
end

– I get an error: "jit.qt.movie: could not create gworld"
– if I call the following but no film has been read
function draw()
if (vmovie.framecount > 0) then
local vframe = jit.matrix(4, "char", 320, 240)
vmovie:matrixcalc(vframe.name, vframe.name)
outlet(0, "jit_matrix", vframe.name)
end
end

here is my patcher:

max v2;
#N vpatcher 501 427 1101 827;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 368 138 80 196617 read dozer.mov;
#P message 303 140 58 196617 read dozer;
#P newex 300 164 64 196617 prepend call;
#P user jit.pwindow 303 216 82 62 0 1 0 0 1 0;
#P newex 277 289 75 196617 jit.window foo;
#P newex 147 160 50 196617 t b erase;
#P toggle 147 106 15 0;
#P newex 147 135 57 196617 qmetro 33;
#P newex 147 236 82 196617 jit.gl.render foo;
#P newex 304 192 166 196617 jit.gl.lua foo @file movieplayer.lua;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 1 1 0;
#P connect 4 0 1 0;
#P connect 9 0 7 0;
#P connect 8 0 7 0;
#P connect 7 0 0 0;
#P connect 0 0 6 0;
#P pop;

On Oct 24, 2007, at 9:45 AM, (())_n wrote:

> On Oct 24, 2007, at 1:23 AM, Wesley Smith wrote:
>
>> works for me. BTW, you might want to make your matrix 4 plane. Are
>> you in windows or OSX? What version of jit.gl.lua do you have?
>>
>> wes
>
>
> Hi Wes,
>
> Thanks. I overlooked the 4 planes. Yes it works but not until I
> have read a file into jit.qt.movie. if I haven’t read a file I get
> the error: "jit.qt.movie: could not create gworld." So matrixcalc
> is the only way for an instance of jit.qt.movie to output a matrix
> in jit.gl.lua?
>
> I am on 12" pwrbk g4 GeForce FX Go5200 osx 10.4.10 max 4.6.3 jitter
> 1.6.3 jit.gl.lua is b4
> Note: I updated to the Jitter "1.6.4-x1 :: Experimental Jitter
> framework" and still get the same error.
>
> (())_n
>
> here is the code that illustrates this behavior:
>
> render_context = this.drawto
> autogarbage = 1
> autowatch = 1
> gc = 1
>
> function script_load()
> vmovie = jit.new("jit.qt.movie")
> vmovie.colormode = "uyvy"
> vmovie.adapt = 1
> end
>
> function read(a)
> vmovie:read(a)
> local vframe = jit.matrix(4, "char", 320, 240)
> vmovie:matrixcalc(vframe.name, vframe.name)
> outlet(0, "jit_matrix", vframe.name)
> end
>
> — I get an error: "jit.qt.movie: could not create gworld"
> — if I call the following but no film has been read
> function play()
> local vframe = jit.matrix(4, "char", 320, 240)
> vmovie:matrixcalc(vframe.name, vframe.name)
> outlet(0, "jit_matrix", vframe.name)
> end
>
>


October 24, 2007 | 6:23 pm

Hi mark,

this is great. I guess I should be calling it on the draw and check
for frames to see if a movie has been loaded.

thanks

(())_n

On Oct 24, 2007, at 1:20 PM, MarkDavid Hosale wrote:

> I am confused by the play function. Don’t you want to do something
> more like this? Also fixes the gworld error:
>
> — movieplayer.lua
>
> render_context = this.drawto
> autogarbage = 1
> autowatch = 1
> gc = 1
>
> function script_load()
> vmovie = jit.new("jit.qt.movie")
> vmovie.colormode = "uyvy"
> vmovie.adapt = 1
> end
>
> function read(a)
> vmovie:read(a)
> end
>
> — I get an error: "jit.qt.movie: could not create gworld"
> — if I call the following but no film has been read
> function draw()
> if (vmovie.framecount > 0) then
> local vframe = jit.matrix(4, "char", 320, 240)
> vmovie:matrixcalc(vframe.name, vframe.name)
> outlet(0, "jit_matrix", vframe.name)
> end
> end
>
>
> here is my patcher:
>
> max v2;
> #N vpatcher 501 427 1101 827;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 368 138 80 196617 read dozer.mov;
> #P message 303 140 58 196617 read dozer;
> #P newex 300 164 64 196617 prepend call;
> #P user jit.pwindow 303 216 82 62 0 1 0 0 1 0;
> #P newex 277 289 75 196617 jit.window foo;
> #P newex 147 160 50 196617 t b erase;
> #P toggle 147 106 15 0;
> #P newex 147 135 57 196617 qmetro 33;
> #P newex 147 236 82 196617 jit.gl.render foo;
> #P newex 304 192 166 196617 jit.gl.lua foo @file movieplayer.lua;
> #P connect 3 0 2 0;
> #P connect 2 0 4 0;
> #P connect 4 1 1 0;
> #P connect 4 0 1 0;
> #P connect 9 0 7 0;
> #P connect 8 0 7 0;
> #P connect 7 0 0 0;
> #P connect 0 0 6 0;
> #P pop;


October 24, 2007 | 7:02 pm

You don’t have to call it on the draw but it can be convenient. If
you’re not using opengl, you can just send a message to output a frame
whenever you want.

wes

On 10/24/07, (())_n wrote:
> Hi mark,
>
> this is great. I guess I should be calling it on the draw and check
> for frames to see if a movie has been loaded.
>
> thanks
>
> (())_n
>
>
> On Oct 24, 2007, at 1:20 PM, MarkDavid Hosale wrote:
>
> > I am confused by the play function. Don’t you want to do something
> > more like this? Also fixes the gworld error:
> >
> > — movieplayer.lua
> >
> > render_context = this.drawto
> > autogarbage = 1
> > autowatch = 1
> > gc = 1
> >
> > function script_load()
> > vmovie = jit.new("jit.qt.movie")
> > vmovie.colormode = "uyvy"
> > vmovie.adapt = 1
> > end
> >
> > function read(a)
> > vmovie:read(a)
> > end
> >
> > — I get an error: "jit.qt.movie: could not create gworld"
> > — if I call the following but no film has been read
> > function draw()
> > if (vmovie.framecount > 0) then
> > local vframe = jit.matrix(4, "char", 320, 240)
> > vmovie:matrixcalc(vframe.name, vframe.name)
> > outlet(0, "jit_matrix", vframe.name)
> > end
> > end
> >
> >
> > here is my patcher:
> >
> > max v2;
> > #N vpatcher 501 427 1101 827;
> > #P window setfont "Sans Serif" 9.;
> > #P window linecount 1;
> > #P message 368 138 80 196617 read dozer.mov;
> > #P message 303 140 58 196617 read dozer;
> > #P newex 300 164 64 196617 prepend call;
> > #P user jit.pwindow 303 216 82 62 0 1 0 0 1 0;
> > #P newex 277 289 75 196617 jit.window foo;
> > #P newex 147 160 50 196617 t b erase;
> > #P toggle 147 106 15 0;
> > #P newex 147 135 57 196617 qmetro 33;
> > #P newex 147 236 82 196617 jit.gl.render foo;
> > #P newex 304 192 166 196617 jit.gl.lua foo @file movieplayer.lua;
> > #P connect 3 0 2 0;
> > #P connect 2 0 4 0;
> > #P connect 4 1 1 0;
> > #P connect 4 0 1 0;
> > #P connect 9 0 7 0;
> > #P connect 8 0 7 0;
> > #P connect 7 0 0 0;
> > #P connect 0 0 6 0;
> > #P pop;
>


October 24, 2007 | 11:15 pm

On Oct 24, 2007, at 3:02 PM, Wesley Smith wrote:

> You don’t have to call it on the draw but it can be convenient. If
> you’re not using opengl, you can just send a message to output a frame
> whenever you want.
>
> wes

Hi Wes, Mark,

Yes I was just trying to think to keep the CPU and GPU processes
separate.
Will see what is more effective in the long run.

So I now made a player based on your input. I noticed that if I call
a local matrix on every draw() or play() for the matrixcalc it slowed
down and crashed after a while. So now I create the processing matrix
in the setup. With this code I noticed that dozer.mov and other short
movies play fine, but that the frame rate drops proportionately on
longer movie files with the same photo-jpeg 320×240 compression
settings. The longer files play fast in jit.qt.movie in a patch. I
went back to jitter 1.6.3 but it didn’t change anything.

The patch and code here (and below):

http://home.earthlink.net/~posit/lua/

(())_n

– code es.play.lua

render_context = this.drawto
autogarbage = 1
autowatch = 1
gc = 1

function script_load()
vmovie = jit.new("jit.qt.movie")
vmovie.colormode = "uyvy"
vmovie.adapt = 1
vplane = jit.new("jit.gl.videoplane", render_context)
vplane.colormode = "uyvy"
vplane.scale = {1.333, 1., 1.}
vframe = jit.matrix(4, "char", 320, 240)
end

function read(a)
vmovie:read(a)
end

function play()
if (vmovie.framecount > 0) then
vmovie:matrixcalc(vframe.name, vframe.name)
outlet(0, "jit_matrix", vframe.name)
end
end

function draw()
if (vmovie.framecount > 0) then
vmovie:matrixcalc(vframe.name, vframe.name)
vplane:jit_matrix(vframe.name)
end
end

– play patch:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 314 243 48 196617 loadbang;
#P message 314 269 82 196617 colormode uyvy;
#P user jit.pwindow 135 303 322 242 0 1 0 0 1 0;
#P newex 292 150 183 196617 jit.gl.handle bar @inherit_transform 1;
#P newex 292 192 127 196617 jit.gl.render bar @ortho 2;
#P newex 300 218 76 196617 jit.window bar;
#P message 208 192 80 196617 read dozer.mov;
#P message 171 193 30 196617 read;
#P message 136 193 29 196617 play;
#P user jit.fpsgui 66 141 60 196617 0;
#P newex 145 110 30 196617 t b b;
#P user gswitch2 136 140 39 32 0 0;
#P newex 136 237 64 196617 prepend call;
#P toggle 145 53 15 0;
#P newex 145 79 57 196617 qmetro 20;
#P newex 136 268 143 196617 jit.gl.lua bar @file es.play.lua;
#P comment 416 270 38 196617 (())_n;
#P connect 16 0 15 0;
#P connect 13 0 12 0;
#P fasten 5 1 12 0 170 178 297 178;
#P connect 6 1 5 1;
#P connect 2 0 6 0;
#P connect 3 0 2 0;
#P connect 1 0 14 0;
#P fasten 15 0 14 0 319 294 141 294;
#P connect 4 0 1 0;
#P connect 9 0 4 0;
#P connect 10 0 4 0;
#P connect 8 0 4 0;
#P connect 5 0 8 0;
#P fasten 6 0 7 0 150 134 71 134;
#P window clipboard copycount 17;


October 24, 2007 | 11:28 pm

On Oct 24, 2007, at 4:15 PM, (())_n wrote:

> vmovie = jit.new("jit.qt.movie")
> vmovie.colormode = "uyvy"
> vframe = jit.matrix(4, "char", 320, 240)

Very important: in UYVY mode you should use *half* resolution for the
x-axis. If you connect jit.fpsgui in dim mode you should see that the
output matrix for a "320×240" file uses "160×120" in UYVY mode due to
the chroma reduced "macro-pixel". See the "colorspaces" tutorial for
more info if this doesn’t make sense to you.

-Joshua


October 25, 2007 | 12:55 am

Wes is probably better able to address the issue you are describing
here as it relates to the code you posted. But, I was wondering, what
is your end goal? do you want to do some video processing on a slab?
Do some matrix processing with video? or do you want to just texture
some video planes?

Depending on what you’re trying to do I have some sample patches that
could help you and are definitely not suffering from this slow down
problem.

A couple of little notes about this patch:
- you should erase your renderer after each bang i.e. [t b erase]
- it’s really not important, but I would change the name of play() to
bang(), this way you can just run the metro directly to the [prepend
call] without the play message. It’s more intuitive to me since this
is the way max objects work. Almost not worth mentioning however…

-markdavid

On Oct 24, 2007, at 4:15 PM, (())_n wrote:

> On Oct 24, 2007, at 3:02 PM, Wesley Smith wrote:
>
>> You don’t have to call it on the draw but it can be convenient. If
>> you’re not using opengl, you can just send a message to output a
>> frame
>> whenever you want.
>>
>> wes
>
> Hi Wes, Mark,
>
> Yes I was just trying to think to keep the CPU and GPU processes
> separate.
> Will see what is more effective in the long run.
>
> So I now made a player based on your input. I noticed that if I
> call a local matrix on every draw() or play() for the matrixcalc it
> slowed down and crashed after a while. So now I create the
> processing matrix in the setup. With this code I noticed that
> dozer.mov and other short movies play fine, but that the frame rate
> drops proportionately on longer movie files with the same photo-
> jpeg 320×240 compression settings. The longer files play fast in
> jit.qt.movie in a patch. I went back to jitter 1.6.3 but it didn’t
> change anything.
>
> The patch and code here (and below):
> http://home.earthlink.net/~posit/lua/
>
> (())_n
>
> — code es.play.lua
>
> render_context = this.drawto
> autogarbage = 1
> autowatch = 1
> gc = 1
>
> function script_load()
> vmovie = jit.new("jit.qt.movie")
> vmovie.colormode = "uyvy"
> vmovie.adapt = 1
> vplane = jit.new("jit.gl.videoplane", render_context)
> vplane.colormode = "uyvy"
> vplane.scale = {1.333, 1., 1.}
> vframe = jit.matrix(4, "char", 320, 240)
> end
>
> function read(a)
> vmovie:read(a)
> end
>
> function play()
> if (vmovie.framecount > 0) then
> vmovie:matrixcalc(vframe.name, vframe.name)
> outlet(0, "jit_matrix", vframe.name)
> end
> end
>
> function draw()
> if (vmovie.framecount > 0) then
> vmovie:matrixcalc(vframe.name, vframe.name)
> vplane:jit_matrix(vframe.name)
> end
> end
>
>
> — play patch:
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 314 243 48 196617 loadbang;
> #P message 314 269 82 196617 colormode uyvy;
> #P user jit.pwindow 135 303 322 242 0 1 0 0 1 0;
> #P newex 292 150 183 196617 jit.gl.handle bar @inherit_transform 1;
> #P newex 292 192 127 196617 jit.gl.render bar @ortho 2;
> #P newex 300 218 76 196617 jit.window bar;
> #P message 208 192 80 196617 read dozer.mov;
> #P message 171 193 30 196617 read;
> #P message 136 193 29 196617 play;
> #P user jit.fpsgui 66 141 60 196617 0;
> #P newex 145 110 30 196617 t b b;
> #P user gswitch2 136 140 39 32 0 0;
> #P newex 136 237 64 196617 prepend call;
> #P toggle 145 53 15 0;
> #P newex 145 79 57 196617 qmetro 20;
> #P newex 136 268 143 196617 jit.gl.lua bar @file es.play.lua;
> #P comment 416 270 38 196617 (())_n;
> #P connect 16 0 15 0;
> #P connect 13 0 12 0;
> #P fasten 5 1 12 0 170 178 297 178;
> #P connect 6 1 5 1;
> #P connect 2 0 6 0;
> #P connect 3 0 2 0;
> #P connect 1 0 14 0;
> #P fasten 15 0 14 0 319 294 141 294;
> #P connect 4 0 1 0;
> #P connect 9 0 4 0;
> #P connect 10 0 4 0;
> #P connect 8 0 4 0;
> #P connect 5 0 8 0;
> #P fasten 6 0 7 0 150 134 71 134;
> #P window clipboard copycount 17;
>
>
>


October 25, 2007 | 2:51 am

On Oct 24, 2007, at 8:55 PM, MarkDavid Hosale wrote:

> Wes is probably better able to address the issue you are describing
> here as it relates to the code you posted. But, I was wondering,
> what is your end goal? do you want to do some video processing on a
> slab? Do some matrix processing with video? or do you want to just
> texture some video planes?
>
> Depending on what you’re trying to do I have some sample patches
> that could help you and are definitely not suffering from this slow
> down problem.
>
> A couple of little notes about this patch:
> – you should erase your renderer after each bang i.e. [t b erase]
> – it’s really not important, but I would change the name of play()
> to bang(), this way you can just run the metro directly to the
> [prepend call] without the play message. It’s more intuitive to me
> since this is the way max objects work. Almost not worth mentioning
> however…
>
> -markdavid

Thanks for the tips markdavid,

I made the changes. I am in the learning curve with lua. I am
building some shapes with lua so I can have multiple shapes drawn
with instances of jit.gl.mesh. That part is working. Although I am
still trying to figure out drawraw in some respects because Joshua
said it would be faster.

Now I am trying to texture those shapes and thought I would create as
many instances of jit.qt.movie to load onto my instances of
jit.gl.texture. But I will not only be working with short movies.
Some might be longer. So because of this limitation I will probably
either go with the example I found in the archive of uploading frames
of the videos to textures outside of lua and then binding them with
the example of quads which wes posted a while ago or copy the output
of the jit.qt.movie objects outside of jit.gl.lua to instances of
jit.gl.matrix that are copied to instances of jit.gl.texture within
lua. Then jit.gl.lua would just be for the opengl stuff and possibly
uploading the textures.

http://www.cycling74.com/pipermail/jitter/2007-July/009926.html

Beyond that I am posting what I am figuring out using matrices in
jit.gl.lua because it might be useful to others using lua.

Sorry to tear up the bandwidth with this.

(())_n


October 25, 2007 | 6:03 am

here’s a simple lua slab patch that seems to have better results than
your previous example in terms of the long movie frame rate thing. I
am not sure if there is any advantage to creating the jit.qt.movie
object in lua over max other than for clarity in your script. I’m not
doing it here. I tried to make this patch real simple so you could
build up from it and test as you go. You could bypass slab, use the
uyvy colormode, etc. for example.

I found the glvideotrail.lua example real useful when learning the
video texturing.

BTW, I am by far no expert, and maybe you know this already, but you
mentioned separating the cpu and gpu. As I understand it all the
quicktime stuff and most matrix stuff is cpu unless you move it to
the gpu via slab. OpenGL and shaders are gpu. I did notice some new
graphics cards that are handling quicktime calls, but I think that is
a separate issue.

> Sorry to tear up the bandwidth with this.

seems to me that’s what this list is for…

Anyway, I hope this patch helps. shoot more questions, and post more
examples, I find this discussion really useful-
-MarkDavid

– textureDemo.lua
render_context = this.drawto
autogarbage = 1
autowatch = 1

the_slab = jit.new("jit.gl.slab", render_context)
the_slab.file = "cf.emboss.jxs"

vplane = jit.new("jit.gl.videoplane", render_context)
vplane.automatic = 0
vplane.texture = the_slab.out_name

function jit_matrix(name)
the_slab:jit_matrix(name)

the_slab:draw()
end

function draw()
vplane:draw()
end

————
max v2;
#N vpatcher 211 525 811 925;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 379 80 30 196617 read;
#P user jit.fpsgui 40 115 60 196617 0;
#P newex 304 109 63 196617 jit.qt.movie;
#P message 368 34 80 196617 read dozer.mov;
#P newex 304 137 64 196617 prepend call;
#P newex 277 289 75 196617 jit.window foo;
#P newex 143 72 58 196617 t b b erase;
#P toggle 143 18 15 0;
#P newex 143 47 51 196617 qmetro 2;
#P newex 143 148 82 196617 jit.gl.render foo;
#P newex 304 162 168 196617 jit.gl.lua foo @file textureDemo.lua;
#P connect 4 0 9 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 1 0;
#P connect 4 2 1 0;
#P connect 10 0 8 0;
#P connect 4 1 8 0;
#P connect 7 0 8 0;
#P connect 8 0 6 0;
#P connect 6 0 0 0;
#P pop;

On Oct 24, 2007, at 7:51 PM, (())_n wrote:

> On Oct 24, 2007, at 8:55 PM, MarkDavid Hosale wrote:
>
>> Wes is probably better able to address the issue you are
>> describing here as it relates to the code you posted. But, I was
>> wondering, what is your end goal? do you want to do some video
>> processing on a slab? Do some matrix processing with video? or do
>> you want to just texture some video planes?
>>
>> Depending on what you’re trying to do I have some sample patches
>> that could help you and are definitely not suffering from this
>> slow down problem.
>>
>> A couple of little notes about this patch:
>> – you should erase your renderer after each bang i.e. [t b erase]
>> – it’s really not important, but I would change the name of play()
>> to bang(), this way you can just run the metro directly to the
>> [prepend call] without the play message. It’s more intuitive to me
>> since this is the way max objects work. Almost not worth
>> mentioning however…
>>
>> -markdavid
>
> Thanks for the tips markdavid,
>
> I made the changes. I am in the learning curve with lua. I am
> building some shapes with lua so I can have multiple shapes drawn
> with instances of jit.gl.mesh. That part is working. Although I am
> still trying to figure out drawraw in some respects because Joshua
> said it would be faster.
>
> Now I am trying to texture those shapes and thought I would create
> as many instances of jit.qt.movie to load onto my instances of
> jit.gl.texture. But I will not only be working with short movies.
> Some might be longer. So because of this limitation I will probably
> either go with the example I found in the archive of uploading
> frames of the videos to textures outside of lua and then binding
> them with the example of quads which wes posted a while ago or copy
> the output of the jit.qt.movie objects outside of jit.gl.lua to
> instances of jit.gl.matrix that are copied to instances of
> jit.gl.texture within lua. Then jit.gl.lua would just be for the
> opengl stuff and possibly uploading the textures.
>
> http://www.cycling74.com/pipermail/jitter/2007-July/009926.html
>
> Beyond that I am posting what I am figuring out using matrices in
> jit.gl.lua because it might be useful to others using lua.
>
> Sorry to tear up the bandwidth with this.
>
> (())_n
>
>


October 25, 2007 | 7:20 am

On Oct 25, 2007, at 2:03 AM, MarkDavid Hosale wrote
:
> here’s a simple lua slab patch that seems to have better results
> than your previous example in terms of the long movie frame rate
> thing. I am not sure if there is any advantage to creating the
> jit.qt.movie object in lua over max other than for clarity in your
> script. I’m not doing it here. I tried to make this patch real
> simple so you could build up from it and test as you go. You could
> bypass slab, use the uyvy colormode, etc. for example.
>
> I found the glvideotrail.lua example real useful when learning the
> video texturing.
>
> BTW, I am by far no expert, and maybe you know this already, but
> you mentioned separating the cpu and gpu. As I understand it all
> the quicktime stuff and most matrix stuff is cpu unless you move it
> to the gpu via slab. OpenGL and shaders are gpu. I did notice some
> new graphics cards that are handling quicktime calls, but I think
> that is a separate issue.
>
>> Sorry to tear up the bandwidth with this.
>
> seems to me that’s what this list is for…
>
> Anyway, I hope this patch helps. shoot more questions, and post
> more examples, I find this discussion really useful-
> -MarkDavid

cool. I feel now (tomorrow) I am ready to start to deal simply with
GPU issues in jit.gl.lua. I will look at the glvideotrail.lua again
tomorrow.

I made one more attempt using jit.matrix instances within jit.gl.lua
and then using the importmovie message to load still pictures.
Problem with reading them directly into the jit.matrix is I cannot
specify colormode uvyv. This is why I didn’t bring them to a
videoplane yet. It seems to work though, but I only tested with 20
images. I haven’t gotten into the memsize attribute. Also I was
having a bit of trouble outputting an int in another outlet than the
first. It came out as lists with just one float element.

Find it below or on the site:

http://home.earthlink.net/~posit/lua/

cheers,

(())_n

– lua code es.matrix.lua

autogarbage = 1
autowatch = 1
gc = 1
vmatrix = {}
vmatrixnum = 0
current = 0

function bang()
current = current + 1
if (current > vmatrixnum) then
current = 1
end
if (vmatrixnum > 0) then
outlet(0, "jit_matrix", vmatrix[current].name)
end
end

function play(i)
if (i < = vmatrixnum) then
outlet(0, "jit_matrix", vmatrix[i].name)
end
end

function read(a)
local temp = vmatrixnum + 1
vmatrix[temp] = jit.matrix(4, "char", 320, 240)
vmatrix[temp].adapt = 1
vmatrix[temp]:importmovie(a)
vmatrixnum = temp
end

function path(b)
vmatrixnum = 0
current = 0
vmatrix = {}
vpath = b
end

function readfolder(c)
local temp = vmatrixnum + 1
vmatrix[temp] = jit.matrix(4, "char", 320, 240)
vmatrix[temp].adapt = 1
vmatrix[temp]:importmovie(vpath..c)
vmatrixnum = temp
end

function clear()
vmatrixnum = 0
current = 0
vmatrix = {}
end

Max patch:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 90 140 33 196617 clear;
#P newex 310 93 39 196617 r slide;
#N vpatcher 457 209 884 558;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 75 233 51 196617 tosymbol;
#P hidden newex 318 245 39 196617 s slide;
#P hidden message 318 221 83 196617 setminmax 1 $1;
#P newex 209 115 48 196617 loadbang;
#P window linecount 1;
#P newex 75 268 68 196617 prepend read;
#P window linecount 0;
#P newex 75 121 38 196617 gate 2;
#P window linecount 1;
#P newex 180 84 21 196617 t 2;
#P window linecount 0;
#P newex 151 84 21 196617 t 1;
#P newex 151 54 69 196617 sel JPEG fold;
#P inlet 151 28 15 0;
#P window linecount 1;
#P newex 257 242 51 196617 tosymbol;
#P newex 257 269 67 196617 prepend path;
#P newex 152 241 51 196617 tosymbol;
#P newex 152 180 37 196617 folder;
#P newex 152 151 27 196617 t l l;
#P newex 152 211 67 196617 route append;
#P message 209 148 61 196617 types JPEG;
#P newex 152 268 95 196617 prepend readfolder;
#P inlet 103 27 15 0;
#P outlet 152 299 15 0;
#P connect 12 0 14 0;
#P connect 13 0 14 0;
#P connect 14 0 19 0;
#P connect 19 0 15 0;
#P connect 1 0 14 1;
#P connect 10 0 11 0;
#P connect 11 0 12 0;
#P connect 14 1 5 0;
#P connect 3 0 6 0;
#P connect 5 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 7 0;
#P connect 7 0 2 0;
#P fasten 8 0 0 0 262 291 157 291;
#P connect 2 0 0 0;
#P connect 15 0 0 0;
#P connect 11 1 13 0;
#P connect 16 0 3 0;
#P connect 5 1 9 0;
#P connect 9 0 8 0;
#P connect 6 1 17 0;
#P hidden connect 17 0 18 0;
#P pop;
#P newobj 34 139 43 196617 p parse;
#P comment 328 126 92 196617 3. – shuffle manual;
#P user multiSlider 199 118 125 28 1. 20. 1 2664 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P message 199 152 44 196617 play $1;
#P comment 155 94 132 196617 2 – turn on metro to shuffle;
#P user jit.pwindow 104 266 322 242 0 1 0 0 1 0;
#P user jit.fpsgui 34 250 60 196617 0;
#P newex 34 180 64 196617 prepend call;
#P toggle 136 92 15 0;
#P newex 136 122 57 196617 qmetro 20;
#P newex 34 205 167 196617 jit.gl.lua movie @file es.matrix.lua;
#P comment 122 66 174 196617 1. – drop folder or jpeg images here;
#P comment 297 206 37 196617 (())_n;
#P user dropfile 34 52 113 118 1;
#P connect 3 0 7 0;
#P fasten 3 0 8 0 39 233 110 233;
#P connect 11 0 10 0;
#P fasten 14 0 11 0 315 114 204 114;
#P connect 5 0 4 0;
#P fasten 0 1 13 1 108 128 72 128;
#P connect 6 0 3 0;
#P connect 13 0 6 0;
#P fasten 10 0 6 0 204 169 39 169;
#P fasten 4 0 6 0 141 169 39 169;
#P fasten 15 0 6 0 95 169 39 169;
#P connect 0 0 13 0;
#P window clipboard copycount 16;


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