Hi guys, I'm new here and new to processing. Apologies if I've posted this in the wrong forum, I'm looking for some help and I'm inexperienced!
Alright, so I’ve got a project in which I’m trying to create a light-painting experience in outer space using Processing and reacTIVision (with it’s supplied fiducial markers). I’m using the TUIO Processing sketch they supply at the reacTIVision website, and I’ve been making progress with it.
I’ve changed the output of the fiducial marker to show a small radial gradient that I created using image(); (this is instead of the default square created when you move it in front of the camera), but I want that same image to repeat itself as I move the marker around to create a drawing/painting effect.
The background is a .mov file, and the gradientPNG only appears when the fiducial is in front of the webcam. It disappears again once it’s off-screen.
Can anybody suggest how I can get the gradient to draw itself? I apologise in advance if I’ve posted this in the wrong place or if I’m not following the right protocols here. I AM a beginner, and I have very little experience, so thank you VERY much in advance for any help that comes my way. Here’s the sketch:
Quote://Gradient image
PImage gradientPNG;
//Import Movie
import processing.video.*;
Movie theMov;
// we need to import the TUIO library
// and declare a TuioProcessing client variable
import TUIO.*;
TuioProcessing tuioClient;
// these are some helper variables which are used
// to create scalable graphical feedback
float cursor_size = 15;
float object_size = 60;
float table_size = 760;
float scale_factor = 1;
PFont font;
void setup()
{
//size(screen.width,screen.height);
size(640,480);
noStroke();
fill(0);
//Gradient image
gradientPNG = loadImage("gradient.png");
//Movie Setup
theMov = new Movie(this, “stars2.mov");
/* only use 1 of the following options */
theMov.loop(); //plays the movie once
loop();
frameRate(30);
//noLoop();
hint(ENABLE_NATIVE_FONTS);
font = createFont("Arial", 18);
scale_factor = height/table_size;
// we create an instance of the TuioProcessing client
// since we add “this” class as an argument the TuioProcessing class expects
// an implementation of the TUIO callback methods (see below)
tuioClient = new TuioProcessing(this);
}
// within the draw method we retrieve a Vector (List) of TuioObject and TuioCursor (polling)
// from the TuioProcessing client and then loop over both lists to draw the graphical feedback.
void draw()
{
image(theMov, 0, 0);
textFont(font,18*scale_factor);
float obj_size = object_size*scale_factor;
float cur_size = cursor_size*scale_factor;
//This is the area that I’m concerned with drawing the repeating line
Vector tuioObjectList = tuioClient.getTuioObjects();
for (int i=0;i
TuioObject tobj = (TuioObject)tuioObjectList.elementAt(i);
stroke(0);
pushMatrix();
translate(tobj.getScreenX(width),tobj.getScreenY(height));
rotate(tobj.getAngle());
image(gradientPNG,15,15);
popMatrix();
}
//ends here
Vector tuioCursorList = tuioClient.getTuioCursors();
for (int i=0;i
TuioCursor tcur = (TuioCursor)tuioCursorList.elementAt(i);
Vector pointList = tcur.getPath();
if (pointList.size()>0) {
stroke(0,0,255);
TuioPoint start_point = (TuioPoint)pointList.firstElement();;
for (int j=0;j
TuioPoint end_point = (TuioPoint)pointList.elementAt(j);
line(start_point.getScreenX(width),start_point.getScreenY(height),end_point.getS
creenX(width),end_point.getScreenY(height));
start_point = end_point;
}
stroke(192,192,192);
fill(192,192,192);
ellipse( tcur.getScreenX(width), tcur.getScreenY(height),cur_size,cur_size);
fill(0);
text(""+ tcur.getCursorID(), tcur.getScreenX(width)-5, tcur.getScreenY(height)+5);
}
}
}
//movie event
void movieEvent(Movie m) {
m.read();
}
// these callback methods are called whenever a TUIO event occurs
// called when an object is added to the scene
void addTuioObject(TuioObject tobj) {
println("add object “+tobj.getSymbolID()+” ("+tobj.getSessionID()+") “+tobj.getX()+” “+tobj.getY()+” “+tobj.getAngle());
}
// called when an object is removed from the scene
void removeTuioObject(TuioObject tobj) {
println("remove object “+tobj.getSymbolID()+” ("+tobj.getSessionID()+")");
}
// called when an object is moved
void updateTuioObject (TuioObject tobj) {
println("update object “+tobj.getSymbolID()+” ("+tobj.getSessionID()+") “+tobj.getX()+” “+tobj.getY()+” “+tobj.getAngle()
+” “+tobj.getMotionSpeed()+” “+tobj.getRotationSpeed()+” “+tobj.getMotionAccel()+” “+tobj.getRotationAccel());
}
// called when a cursor is added to the scene
void addTuioCursor(TuioCursor tcur) {
println("add cursor “+tcur.getCursorID()+” ("+tcur.getSessionID()+ “) “ +tcur.getX()+” “+tcur.getY());
}
// called when a cursor is moved
void updateTuioCursor (TuioCursor tcur) {
println("update cursor “+tcur.getCursorID()+” ("+tcur.getSessionID()+ “) “ +tcur.getX()+” “+tcur.getY()
+” “+tcur.getMotionSpeed()+” “+tcur.getMotionAccel());
}
// called when a cursor is removed from the scene
void removeTuioCursor(TuioCursor tcur) {
println("remove cursor “+tcur.getCursorID()+” ("+tcur.getSessionID()+")");
}
// called after each message bundle
// representing the end of an image frame
void refresh(TuioTime bundleTime) {
redraw();
}
Again, thank you VERY much in advance if you can help me out. Cheers.