Home > Uncategorized > Small lesson on setters, setcell!

Small lesson on setters, setcell!

Another way to think setcell messages to a matrix using java. So something like this:

setcell 1 1 plane 1 val 233

can be turned into the next, a small tiny thingie to play around:

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class SetcellBasic extends MaxObject{
JitterMatrix sc1 = new JitterMatrix(3,”char”,3,3);
int[] cells = new int[2];
int value;
int plane;

public SetcellBasic(){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});

value = 0;
plane = 0;

public void setCells(int _x, int _y){
cells[0] = _x;
cells[1] = _y;

post(“the position of the cell is “+ cells[0] + ” ” + cells[1]);

public void setValue(int _value){
value = _value;

public void setPlane(int _plane){
plane = _plane;

public void bang(){
//remember that setcell(int[], int, int)
//also floats can be used as values
sc1.setcell(cells, plane, value);

outlet(0,”jit_matrix”, sc1.getName());

Now, if we want to port this into gl vectors we can do something like this:

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class Gldraw extends MaxObject{

JitterMatrix l2= new JitterMatrix(3,”float32″,2);
int[] cells = new int[2];
float x, y;

public Gldraw(){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});
x = 0; y = 0;
cells[0]=0; cells[1] = 0;

public void setX(float _x){
x = _x;

public void setY(float _y){
y = _y;

public void resetValues(){
x = 0;
y = 0;

public void bang(){
int plane = 0;
l2.setcell(cells, plane, x);

plane = 1;
l2.setcell(cells, plane, y);

plane = 2;
l2.setcell(cells, plane, 0.0f);

outlet(0,”jit_matrix”, l2.getName());


Notice how each plane represents the x, y and z values. Remember that setters are our friends here!
Once in maxland we can provide the next command to our sketch object:

reset, drawmatrix [matrix name] [primitive]

A proper example very soon!

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: