This tutorial demonstrates the low-level support in Jitter to specify geometry data as matrices and render them with the jit.gl.render object. Since the data is contained in an ordinary Jitter matrix, this opens up a world of possibilities where arbitrary matrix operators may be used to generate and/or process the geometry matrices. The tutorial will cover the attribute of the GL group, the organization of data in geometry matrices, an example of how geometry matrices can be processed using matrix operators, and introduce various drawing primitives supported by the jit.gl.render object.
Wait a minute—the sphere that was just there a moment ago has disappeared. What's going on?
Some of the objects in the GL group support the jit.gl.gridshape is one such object. This attribute determines whether or not the object's geometry is rendered directly in the object's associated drawing context or if the object sends a matrix containing geometry data out its left outlet. The geometry is not visible because it is being sent to a gate, which is closed.attribute, and
In the max window you should see a series of messages like "print: jit_matrix u26300000007 quad_grid". This is similar to what you've seen in previous tutorials as the output of objects, which pass matrix data, with the exception, that there is an extra element. Rather than sending the message jit.gl.gridshape object sends message . In this case the drawing primitive is , which means interpret the matrix as a grid of quadrilaterals., as you should be familiar with, the
There is still no excitement in our window, but this is easily remedied.
The sphere is now visible again, because the message jit.gl.render object. In response to this message, the jit.gl.render object draws the supplied matrix using the specified drawing primitive. If no drawing primitive is specified, the jit.gl.render object's current drawing primitive will be used. Valid drawing primitives are: , , , , , , , , , , , and .is being sent to the
In the same fashion that you can change the dimensions of video data, you can change the dimensions of the matrix output by sending the jit.gl.gridshape object the message. By default the dimensions of the matrix output by the jit.gl.gridshape object is 20 by 20.
Geometry Matrix Details
Video in Jitter is typically represented by 4-planedata, but how is the geometry data being represented?
Each vertex in the geometry is typically represented asdata with 3, 5, 8, 12, or 13 planes. Planes 0-2 specify the x, y and z position of the vertex. Planes 3 and 4 specify the texture co-ordinates s and t. Planes 5-7 specify the normal vector nx, ny and nz used to calculate the effects of lighting on the geometry. Planes 8-11 specify the red, green, blue, and alpha vertex color. Plane 12 specifies the edge flag e.
The output matrix of the jit.gl.gridshape object has 12 planes, but since we are not applying a texture to the geometry, and lighting is not enabled, the texture coordinates and normal vectors are ignored.
Processing the Geometry Matrix
Instead of simply rendering the geometry unaltered, as you've done so far, it is possible to process this geometry with matrix operators.
Now the matrix is being sent through the jit.xfade object to cross fade the geometry matrix with a matrix of noise. Just as the jit.xfade object may be used to crossfade between video matrices, it may be used to crossfade between geometry matrices.
This will subtly deform the sphere with noise, as well as introduce random colors. The texture coordinates and normal vectors are also being affected, but this is not visible since there is no texture being applied, and lighting is not enabled.
Now the geometry being drawn is pure noise.
You will notice that despite the fact that jit.gl.gridshape is outputting the message , we are appending the output of jit.xfade with . This is because most matrix operators will ignore the drawing primitive argument and simply output the message . Hence we need to append the name of the drawing primitive to the message. This provides a good opportunity to experiment with various drawing primitives.
In addition to drawing directly to their associated drawing contexts, some objects in the GL group support theattribute. When enabled, the geometry matrix is sent out the object's left output with the message .
Geometry matrices are typicallydata with a plane count of 3, 5, 8, 12, or 13 planes, and may be processed using arbitrary matrix operators in a similar fashion to processing video matrices.
The jit.gl.render object supports various drawing primitives to render these geometry matrices: , , , , , , , , , , , and .
|Working with OpenGL||Working with OpenGL|
|Video and Graphics Tutorial 7: Generating Geometry|
|GL Contexts||GL Contexts|
|jit.gl.gridshape||Generate simple geometric shapes as a grid|
|jit.gl.handle||Use mouse movement to control position/rotation|
|jit.gl.render||Render Jitter OpenGL objects|
|jit.xfade||Crossfade between 2 matrices|