firestruck
YaBB Newbies
Offline
Posts: 3
Re: Processing & Flash
Reply #9 - Jul 1st , 2008, 2:10am
Hi, i have a problem to make a caroussel menu icons spin with processing,processing conect and sent data,but i dont know the changes to make the camera act as a mouse,to spin the around the carousel,heres´s the code <--------------PROCESSING-------------------------> import processing.net.*; int port = 9001; Server myServer; byte zero = 0; int total = 7; int total2 = 2; import JMyron.*; JMyron m;//a camera object void setup(){ size(320,240); m = new JMyron();//make a new instance of the object m.start(width,height);//start a capture at 320x240 m.trackColor(0,0,200,200);//R, G, B, and range of similarity m.minDensity(100); //minimum pixels in the glob required to result in a box println("Myron " + m.version()); noFill(); myServer = new Server(this,port); } void draw(){ m.update();//update the camera view drawCamera();//draw the camera to the screen int[][] b = m.globBoxes();//get the center points int xi=1000, yi=1000, xf=0, yf=0; int xc, yc; //draw the boxes stroke(255,0,0); for(int i=0;i<b.length;i++){ if(b[i][0]<xi) xi = b[i][0]; if(b[i][1]<yi) yi = b[i][1]; if(b[i][0]+b[i][2]>xf) xf = b[i][0]+b[i][2]; if(b[i][1]+b[i][3]>yf) yf = b[i][1]+b[i][3]; // rect( b[i][0] , b[i][1] , b[i][2] , b[i][3]); } if(b.length > 0) { rect( xi , yi , xf-xi , yf-yi); xc = xi + ( xf-xi)/2; yc = yi + ( yf-yi)/2; myServer.write( xc +","+ yc); myServer.write(zero); } } void drawCamera(){ int[] img = m.image(); //get the normal image of the camera loadPixels(); for(int i=0;i<width*height;i++){ //loop through all the pixels pixels[i] = img[i]; //draw each pixel to the screen } updatePixels(); } void mousePressed(){ m.settings();//click the window to get the settings } public void stop(){ m.stop();//stop the object super.stop(); } <-----------------------FLASH CODE----------------------> <code> function mover() { //(WHERE I GIVE THE ATTRIBUTES FOR PROCESSING??) this._x = Math.cos(this.angle) * radiusX + centerX; this._y = Math.sin(this.angle) * radiusY + centerY; var s = (this._y - perspective) /(centerY+radiusY-perspective); this._xscale = this._yscale = s*100; this.angle += this._parent.speed; this.swapDepths(Math.round(this._xscale) + 100); } this.onMouseMove = function() { speed = (this._xmouse-centerX)/2500; } </code> I hope somebody give me a hand,i have read all sections and topics and didn´t find(or not see) a solution...just need to know how to give the attributes ( processins vars)to a camera be my mouse! Thank you Regards