Problem to Drawing in OpenGL

May 21, 2013 at 10:58am

Problem to Drawing in OpenGL

I have a problem I can not fix. I have a one plane-matrix consists only of 0 and 1. They are practically matrices from images, and I want to recreate the same image in a 3D plane. So I could move the points in a three-dimensional plane or connecting the dots in different ways.

This is an example of what I would do (made with OpenFrameworks):

http://www.creativeapplications.net/openframeworks/pencil-drawing-openframeworks/

The problem is that I do not know how to create these points in OpenGL. Inserting the matrix jit.gl.mesh only comes out a strange shape.
Thank you :)

#250096
May 21, 2013 at 11:40am

First thing you wanna do is turn that 1-plane matrix in a 3-plane one so jit.gl.mesh etc can read the cells as 3D coordinates. I’d use jit.gen or jit.expr to turn each cell’s xy matrix coordinates into the first 2 planes’ values and take the original value as 3rd plane value (z). Feed that into jit.gl.mesh and start playing with drawmodes…

#250100
May 21, 2013 at 11:41am

Actually, I assumed you wanna use the 0/1 values for depth but I just realized that’s not necessarily the case. How do you wanna interpret that 1-plane matrix?

#250101
May 21, 2013 at 11:47am

I’m sorry but I use a 1-plane matrix for my choice, but I don’t know if is necessary. So, for example if you use jit.gl.gridshape, jit.gl.mesh creates the shape you select in gridshape. In fact I tried to use jit.op between the output of gridshape and the output of jit.qt.movie. The real problem is that I don’t understand what is the correlation between an RGB and XYZ matrix. :(

#250103
May 21, 2013 at 12:10pm

Well that’s easy :) Feed an RGB (3-plane) matrix into a jit object that expects XYZ (3-plane) data and it will just interpret the RGB colors as XYZ positions. Now in the case of jit.qt.movie there’s a hitch because it outputs 4-plane ARGB matrices (A = alpha). But the point is, jitter objects don’t care where data comes from. They will read and use it regardless of whether it’s sent form another jitter geometry object, movie/graphic object, or whatever. The trick is to format the data in such a way that the result will make sense.

I swear there’s a basic example floating around of a movie going into a mesh. Just can’t find it for ya. Process is very similar to what I described above. For X and Y planes are taken the X and Y matrix coordinates of each cell, for Z the luma value (= luminosity calculated from the RGB value). Result is a grid with the light ‘pixels’ sticking out to the front and the dark ones to the back.

#250110
May 21, 2013 at 12:20pm

Ohhhh so that is another problem. Many days ago I try to connect a gridshape (plane) with an image, using jit.op @op pass pass +. And the result was that I have the image in a 3D space but also changed in Z plane. When I tell you that I used a 1-plane matrix composed only by 0 and 1 is because I think that 1=point on, 0=point off, and connect only the points on. Fot the movemente I use a jit.sprinke before jit.gl.mesh. It’s strange because my idea is very simple, is like a monitor with only pixel on/off and connect them, color that like I want ecc.
If you understand what I mean, if you want, prepare a little patch. Because I use Max/MSP nice but not so better Jitter xD

#250114
May 22, 2013 at 3:37am

> When I tell you that I used a 1-plane matrix composed only by 0 and 1 is because I think that 1=point on, 0=point off, and connect only the points on.

It doesn’t work like that. All cells of an input matrix will be drawn (each cell represents a vertex). Not sure if there’s an easy way to skip certain cells. One clumsy way I can think of is iterating through all the cells and aggregate only the wanted cells in a new matrix, to be sent to jit.gl.mesh.

Anyway, I’d pass you such a patch if I had it but I’m not gonna make it for you. Sounds like you need to try things out and wrap your head around how jitter and GL objects use matrix data. Be sure to check the tutorials and docs on the subject.

#250228
May 22, 2013 at 3:44am

Mmmm ok, thank you so much. I think that I’ll try to use jit.gl.sketch, to draw only what I want. I’ll understand how it works and try to put a matrix in it. ;)

#250230
May 23, 2013 at 6:34am

Recently, I wanted to use a whole matrix of xyz data yet not draw all the points with jit.gl.mesh. I used a geometry shader to do the work.

However, I am curious if it could be done using the extra inlets on jit.gl.mesh of edgeflag_matrix or index_matrix. Anyone know? I wasn’t successful.

#250424

You must be logged in to reply to this topic.