Hi guys....I'm trying to have the numer of links changing accordingly to the X mouse movement....basically I want mouseX to assume the value of _maxLevels....any ideia on how to do that? I know the code is not ready for that but I'm stuck here....thanks!
[code]
//import processing.serial.*;
//Serial port;
int _numChildren = 1;
int _maxLevels = 20;
Branch _trunk;
void setup() {
size(750, 500);
smooth();
newTree();
//port = new Serial(this, Serial.list()[1], 9600); // MOUSE
}
void newTree() {
_trunk = new Branch(2, 0, width/2, height/2);
_trunk.drawMe();
}
void draw() {
background(255);
_trunk.updateMe(width/2, height/2);
_trunk.drawMe();
//port.write(mouseX); // MOUSE
print("X = ");
println(mouseX);
print("Y = ");
println(mouseY);
}
class Branch {
float level, index;
float x, y;
float endx, endy;
float alph;
float len, lenChange;
float rot, rotChange;
Branch[] children = new Branch[0];
Branch(float lev, float ind, float ex, float why) {
level = lev;
alph = 300 / level; // transparency
lenChange = random(10) - 5; // amplitude
rotChange = random(10) - 5; // rotation
if (level < _maxLevels) {
children = new Branch[_numChildren];
for (int x=0; x < _numChildren; x++) {
children[x] = new Branch(level+1, x, endx, endy); }
Hi everyone....I'm trying to make a really simple game but I'm having some problem with the collisions....any idea why? I believe the coordinates are correct but still no luck......the code is quite long so case anyone is willing to take a look, the entire folder sketch can be downloaded in:
Last night I was trying to play around with NI Lab and open vision to try and track a bright object and use with as my mouse cursor but I was wondering if it's possible to use it in processing throughr BrightnessTracking or ColorTracking examples...
Hi guys, I was wondering if anyone could give me some help....I'm doing a project where i have servos that i want to be triggered through movement, so far I have the below codes...the problem is that the servo just keeps runing on it's own, doesn't stop at states...
Arduino:
#include <Servo.h>
Servo myservo1;
int pos = 0;
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
myservo1.attach(3);//servo
//myservo2.attach(9);//servo
//myservo1.write(pos);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H'){
digitalWrite(ledPin, HIGH); // turn LED OFF
for(pos = 0; pos < 180; pos += 6) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
Serial.println("AAoff");
Serial.println("Servooff");
}
if (incomingByte == 'L'){
digitalWrite(ledPin, LOW); // turn LED OFF
for(pos = 180; pos>=1; pos-=6) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
Serial.println("AAoff");
Serial.println("Servooff");
}
}
}
WORKS WITH KEYBOARD....If i type L and H in the serial monitor it goes to the positions I want....
Or something similar that can trigger when the camera detects movement....another example is the Frame Differencing but i can't use regular video library with serial...
Hi guys.....today i was trying to adapt musiccam (it was developed for the shake sensor (mustick), but i used the webcam version, and i was trying to control the music according to the brightest point but the music just keeps playing....any ideas why? Thanks!!!
Hi guys, I'm having some problems with an interactive instalation...the idea is to have a kiosk where a tree will be (pics here:
http://antoniopdgomes.wordpress.com/) and by sensors, I want to trigger some animations....my problem is, as it is right now, my code is very slow so I created gif files but I have no idea on how to adapt this....anyone can help me? for "B" i made a mix_CaseB.gif, better than loading 600png's like i'm doing now i guess...thanks in advance for any help u can give me
(I had the topic previously but i hit trash by mistake --')
Hi everyone, i was wondering if anyone can help me....i developed this code where i intend to have a plant following my mouse movement but i only succeeded if the plant is separated from the stem.....is there anyway to attach them? Thank you so much
hey guys, i wonder if anyone can help me. I'm trying to help my girlfriend with a project but i'm not a programmer (never studied much nor had classes on the subject). Basically she was trying to record a portion of video from someone standing in front of a webcam (while mousepressed, and masked with a circle, and afterwards, load it to the right side of the screen where the balls are...is it possible to do in processing? There's an image of what i accomplished so far:
import processing.video.*;
Capture cam;
MovieMaker writer;
char w = 'w';
int v = 0;
int counter = 0;
int circleSize = 100;
int shrinkOrGrow = 1;
int mode = 0;
int numBalls = 7;
float spring = 0.05;
float gravity = 0.8;
float friction = -0.02;
Ball[] balls = new Ball[numBalls];
void setup()
{
size(1300, 500);
frameRate(50);
background(255);
noStroke();
cam = new Capture(this, 640, 480);//for cam image position
writer = new MovieMaker( this, width, height, "data/" + w + v + ".mov", 30,
MovieMaker.H263, MovieMaker.WORST );
for (int i = 0; i < numBalls; i++) {
balls[i] = new Ball(random(width), random(height), random(100, 20), i, balls);
I managed to record video, but from the moment when I start the application until i close it...not until i keep pressing the mouse....i also need to prevent overlapping from the balls...i have no idea how :X