Real-time drawing of incomplete planes.

Aug 16, 2010 at 3:17am

Real-time drawing of incomplete planes.

Hello,

I’m looking for a way to draw incomplete plane shapes with gl.sketch (or other object, if it suits). Specifically, I’m working with a grid (be it jit.matrix or matrixctrl) in order to have control of which parts can be added or removed, depending on coordinates.

It works fine, except that I can’t figure the way to draw the result as a single shape, that can receive a texture in its entirety. What I mean with this is that regardless of the final plane’s shape, it should receive the texture as if it was a normal plane, or rectangle (as if it had a mask). Instead, every grid space is rendered its unique texture.

I’m also sure my method is very resource-wasteful. Please, if you could provide me any pointers in order to achieve my goal, I know this must be a complex thing…

– Pasted Max Patch, click to expand. –
#51797
Aug 20, 2010 at 9:34pm

I’m bumping this thread because as of yet I haven’t found any solution on my own. Sketch drawing functions are too low-level for me to understand completely without some free time. Of course, I’m just asking for some pointers or some exemplary messages.

I devised another solution that involves slabs and videoplane masking. It works alright, but it demands much maintenance and power. I’m thinking sketch might be more economical to me.

Thanks in advance,

#185892
Aug 21, 2010 at 1:51am

Try the tex_map and tex_plane messages. I was able to get it closer to what you wanted, but not quite. There’s four variables and two planes to mess with, the third in the list never did anything. But with tex_map set to 3 you can stretch and offset the texture, and it’ll be one big texture over the whole image… couldn’t get it to stretch/position itself correctly though.

I like the mouse cell-draw function you have in there, for adding and removing the tiles in the 9×9 matrix. If you wanted, you could just merge that matrix with the main one, treat them both as movies/images rather than using sketch, which would give you what you were looking for… though with sketch you could get away from rectangles too.

This one just has a mini-module added to mess with the tex_map and tex_planes, and an All Off/All On for the tiles:

– Pasted Max Patch, click to expand. –
#185893
Aug 23, 2010 at 2:52am

seejayjames,

Thanks for your dedicated patch. I tweaked and tweaked but couldn’t get to properly set my textures. Now I’m not so sure this may be the way to go forward; I say this because I expect to have 9 tile-planes of that sort and that means +300 independent planes.

Maybe a very dedicated drawing routine for one single shape? That is out of my league, however.

I have been investigating and perhaps gl.mesh might be IT (or maybe gl.multiple). Is it possible to feed it a matrix with vertex coordinates to produce the tile/grid effect I’m looking for? If it is, could you please provide me with the basic stuff for translating my 9×9 char matrix into a float32 matrix with vertex coordinates? (I did went through the jit.expr tutorial but this seems quite a specific need)

Thanks for your time, again,

#185894
Aug 23, 2010 at 4:31am

BTW,

With working with jit.expr I’m meaning a way to procedurally position only those pixels that are at 255 in the original char matrix: some tiles on and some off, but using the texture coordinates of a complete plane.

#185895
Aug 23, 2010 at 4:28pm

maybe instead of working with the tex_plane attributes directly, use this handy abstraction:

– Pasted Max Patch, click to expand. –
#185896
Aug 23, 2010 at 4:41pm

rob,

It works like magic with my texture so thanks. Now I’ll see if this same principle can be applied to a grid made up with jit.gl.multiple, which might come easier for my GPU.

#185897
Aug 23, 2010 at 6:03pm

There are a couple of things that strike me here as possible venues for exploration. If you are looking to essentially turn on and off rectangular sections of a larger textured plane, why not just generate an alpha channel and turn on blend_enable? You can use jit.gl.slab @file cc.alphaglue.jxs to apply an arbitrary alpha texture. If you want to break up a single texture to be used on an array of textured quads, you might try using a combination of jit.expr and jit.gl.mesh to generate the geometry. For some examples, check out Jitter Recipes 36-38 http://cycling74.com/2008/10/28/jitter-recipes-book-3/

Let us know what you come up with.

#185898
Aug 23, 2010 at 6:19pm

I did explore the slabs alternative; the problem is that I’m already pushing too many slabs already and I need to work with 9 different plane-grids.

I am now exploring for the first time the possibilities of gl.multiple and jit.expr. Below is what I have done so far: the part where I translate positions to a float32 matrix is particularly painful to see. Also, I’m aware my jit.expressions are pretty bad.

If you think gl.mesh is better suited for this task, or if you could offer the expression I should be using for positioning the tiles in gl.multiple I would appreciate it, as my head is about to explode.

– Pasted Max Patch, click to expand. –
#185899
Aug 24, 2010 at 5:45am

I managed to work out something more decent than my last patch. At least I’m outputting the tiles in (mostly) the correct positions with mesh. If I manage to correct the weird vertex problem I’m having with textures and certain positions, plus realigning my quads as if they were one single plane, I’d consider myself happy.

Of course, this is way over my head for now (never really messed with expr or meshes before), so if you can lend me a hand or give me some pointers. I’m not asking for the complete homework, just some meaningful tips please.

Thanks everybody,

Rehash of nº 36, this time readable and respectful to the viewer:

– Pasted Max Patch, click to expand. –
#185900
Aug 24, 2010 at 11:57pm

And here is a much improved version of what I’m trying to accomplish. Now it’s only fault is placement, scale (preferably 1.333, 1.) and vertex for the individual textures.

Any ideas?

This is a composite hack from nº 36 and 38 of mesh tutorials.

– Pasted Max Patch, click to expand. –
#185901
Aug 25, 2010 at 5:50pm

can’t you just scale and position the gl.mesh using attributes?

#185902

You must be logged in to reply to this topic.