Romanesco is an application to show the generative coding and mix them together and change them by differents settings, like : sounds, beat, graphic pen, weather API, controler midi and the differents sliders from the controler... and soon leapmotion, kinect or an other devices...
Hello. I post again my post about video mapping because I pust this one in the bad category.
I try to map a video in sphere. So I tried to transforme a code from jpg mapping to video mapping, but unfortunnately that don't work.
when I launch the sketch I receive this error
Sep 16 18:27:05 iMac-de-Stanislas.local java[2720] <Error>: CGContextGetCTM: invalid context 0x0
Sep 16 18:27:05 iMac-de-Stanislas.local java[2720] <Error>: CGContextSetBaseCTM: invalid context 0x0
Sep 16 18:27:05 iMac-de-Stanislas.local java[2720] <Error>: CGContextGetCTM: invalid context 0x0
Sep 16 18:27:05 iMac-de-Stanislas.local java[2720] <Error>: CGContextSetBaseCTM: invalid context 0x0
If anybody have an idea, I take it.
For information, I code for this sketch with Processing 151
my code
Copy code
boolean video = true ; import codeanticode.gsvideo.*; GSMovie texMovie;
//INIT SPHERE void initializeSphere(int res) { sinLUT = new float[SINCOS_LENGTH]; cosLUT = new float[SINCOS_LENGTH];
for (int i = 0; i < SINCOS_LENGTH; i++) { sinLUT[i] = (float) Math.sin(i * DEG_TO_RAD * SINCOS_PRECISION); cosLUT[i] = (float) Math.cos(i * DEG_TO_RAD * SINCOS_PRECISION); }
float delta = (float)SINCOS_LENGTH/res; float[] cx = new float[res]; float[] cz = new float[res];
// Calc unit circle in XZ plane for (int i = 0; i < res; i++) { cx[i] = -cosLUT[(int) (i*delta) % SINCOS_LENGTH]; cz[i] = sinLUT[(int) (i*delta) % SINCOS_LENGTH]; }
// Computing vertexlist vertexlist starts at south pole int vertCount = res * (res-1) + 2; int currVert = 0;
// Re-init arrays to store vertices sphereX = new float[vertCount]; sphereY = new float[vertCount]; sphereZ = new float[vertCount]; float angle_step = (SINCOS_LENGTH*0.5f)/res; float angle = angle_step;
// Generic routine to draw textured sphere void texturedSphereMov(float r, GSMovie toMap) { int v1,v11,v2; r = (r + 240 ) * 0.33; beginShape(TRIANGLE_STRIP); texture(toMap); float iu=(float)(toMap.getSourceWidth()-1)/(sDetail); float iv=(float)(toMap.getSourceHeight()-1)/(sDetail); float u=0,v=iv; for (int i = 0; i < sDetail; i++) { vertex(0, -r, 0,u,0); vertex(sphereX[i]*r, sphereY[i]*r, sphereZ[i]*r, u, v); u+=iu; } vertex(0, -r, 0,u,0); vertex(sphereX[0]*r, sphereY[0]*r, sphereZ[0]*r, u, v); endShape();
// Middle rings int voff = 0; for(int i = 2; i < sDetail; i++) { v1=v11=voff; voff += sDetail; v2=voff; u=0; beginShape(TRIANGLE_STRIP); texture(toMap); for (int j = 0; j < sDetail; j++) { vertex(sphereX[v1]*r, sphereY[v1]*r, sphereZ[v1++]*r, u, v); vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2++]*r, u, v+iv); u+=iu; }
// Close each ring v1=v11; v2=voff; vertex(sphereX[v1]*r, sphereY[v1]*r, sphereZ[v1]*r, u, v); vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2]*r, u, v+iv); endShape(); v+=iv; } u=0;
// Add the northern cap beginShape(TRIANGLE_STRIP); texture(toMap); for (int i = 0; i < sDetail; i++) { v2 = voff + i; vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2]*r, u, v); vertex(0, r, 0,u,v+iv); u+=iu; } vertex(sphereX[voff]*r, sphereY[voff]*r, sphereZ[voff]*r, u, v); endShape();
Hello,
I try to find the intersection point between bisector and the ellipse. In my sketch this point is the intersection of the red line start from the center of the ellipse pass by the red point C to the radius ellipse. I hope is clear.
I find no equation to calculate this point on internet. So if any body have an idea, thanks
I try to make my control mouse camera without peasycam, I'm close but the algorithm is not really ok, that make a zoom when I move. I don't find a solution on the forum.
So if any body have an idea. I'm glad
PVector pos = new PVector (eyePos(mouseInfo).x, eyePos(mouseInfo).y, eyePos(mouseInfo).z ) ; // the position of the scene is by default (width /2, height /2, 0 ) ; // so if you wan move to the left, you must minus x, and go to the right add sommesthing to the "x", // same idea for the top and the bottom, and the depth PVector scene = new PVector (0,0,0) ; // the direction of the cam is between (-1 to 1 ) , but I don't understand the concept PVector dirCam = new PVector (0.0, 1.0, 0.0) ; cameraP3Ddraw(pos, scene, dirCam) ;
println("distance between the scene and the camera " + pos.dist(scene)) ;
void cameraP3Dsetup() { // give the start distance between the camera and the scene if ( width > height ) distanceToFocus = width *3 ; else distanceToFocus = height *3 ; //give the starting position of the scene in the display centerScene = new PVector (width/2.0, height/2.0, 0) ; //camedra direction
When I use loadFont there is crash with setUndecorated
java.lang.NullPointerException
at processing.core.PApplet.handleDraw(PApplet.java:2301)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)
at processing.core.PApplet.run(PApplet.java:2141)
at java.lang.Thread.run(Thread.java:680)
I post this problem on Github but Ben Fry think is not a bug, so if any body have an idea to resolve the conflict between setUndecorated and loadFond. The comment of Ben Fry " (...) At the very minimum, this is causing init() to be called twice. But you're also using unsupported/undocumented things (i.e. setUndecorated) that are causing problems. "
So if any body ahave an idea.
Thx
PFont AmericanTypewriter ;
void setup() {
size(300,300) ;
// when I use this void without the setup with :
// public void removeBorder() that's ok,
// but inside the setup and is not public there is problem come too much often
removeBorder() ;
//PROBLEM WHEN THIS LINE IS ACTIVE
AmericanTypewriter=loadFont ("typo/AmericanTypewriter-96.vlw");
}
void removeBorder() {
frame.removeNotify();
frame.setUndecorated(false);
frame.addNotify();
super.init();
}
Hello, I want read the public void init() in the setup or after not before, because I wish change the boolean undecorated by loading an external String in the setup().
If anybody have an idea ?
Thx
boolean undecorated = false ;
public void init() { frame.removeNotify(); frame.setUndecorated(undecorated); frame.addNotify(); super.init(); }
Hello, I work around the sketchPath but I've a problem when I make an OS app, he don't find the path when it's an app, but find when I use the sketch. I check the path and it's ok.
If any body have an idea. Thx
String findPathScetch, findPathApp ;
void setup() { size(300,300 ) ;
//work with scetck findPathScetch = (sketchPath("") +"data/target.app") ;
//Doesn't work with the app findPathApp = (sketchPath("") +"application.macosx/OpenApp.app/Contents/Resources/Java/data/target.app") ; println(findPathScetch) ;
Hello, I try fo find the property fill, stroke and strokeWeight of children shape but I've problem with the index or something to acces at the information.
// The next line is needed if running in JavaScript Mode with Processing.js /* @pjs preload="usa-wikipedia.svg"; */
PShape original; PShape[] childrenShape ; // to create a shape children from SVG
void setup() { original = loadShape("illustrator.svg"); // println(original.getChildIndex(original)) ; // println(original.getChildren()) ; // println(original.getFamily()) ; int numChildren ; numChildren = original.getChildCount(); if ( numChildren > 0 ) { for ( int i = 0 ; i < numChildren ; i++) { // childrenShape = original.getChildren() ; // println(original.getFill(childrenShape[i])) ; println(original.getFill(i)) ; } }
Hello,
I want apply texture on Sphere in PShader mode, that's ok for the mapping but I lost the possibility to move, rotation... the sphere.
If any have an idea, I'll very happy.
// Implements mouse control (interaction will be inverse when sphere is upside down) if(mousePressed){ velocityX += (mouseY-pmouseY) * 0.01; velocityY -= (mouseX-pmouseX) * 0.01; }
}
Sphere
void initializeSphere(int res) { sinLUT = new float[SINCOS_LENGTH]; cosLUT = new float[SINCOS_LENGTH];
for (int i = 0; i < SINCOS_LENGTH; i++) { sinLUT[i] = (float) Math.sin(i * DEG_TO_RAD * SINCOS_PRECISION); cosLUT[i] = (float) Math.cos(i * DEG_TO_RAD * SINCOS_PRECISION); }
float delta = (float)SINCOS_LENGTH/res; float[] cx = new float[res]; float[] cz = new float[res];
// Calc unit circle in XZ plane for (int i = 0; i < res; i++) { cx[i] = -cosLUT[(int) (i*delta) % SINCOS_LENGTH]; cz[i] = sinLUT[(int) (i*delta) % SINCOS_LENGTH]; }
// Computing vertexlist vertexlist starts at south pole int vertCount = res * (res-1) + 2; int currVert = 0;
// Re-init arrays to store vertices sphereX = new float[vertCount]; sphereY = new float[vertCount]; sphereZ = new float[vertCount]; float angle_step = (SINCOS_LENGTH*0.5f)/res; float angle = angle_step;
// Generic routine to draw textured sphere void texturedSphere(float r, PImage t) { int v1,v11,v2; r = (r + 240 ) * 0.33; beginShape(TRIANGLE_STRIP); texture(t); float iu=(float)(t.width-1)/(sDetail); float iv=(float)(t.height-1)/(sDetail); float u=0,v=iv; for (int i = 0; i < sDetail; i++) { vertex(0, -r, 0,u,0); vertex(sphereX[i]*r, sphereY[i]*r, sphereZ[i]*r, u, v); u+=iu; } vertex(0, -r, 0,u,0); vertex(sphereX[0]*r, sphereY[0]*r, sphereZ[0]*r, u, v); endShape();
// Middle rings int voff = 0; for(int i = 2; i < sDetail; i++) { v1=v11=voff; voff += sDetail; v2=voff; u=0; beginShape(TRIANGLE_STRIP); texture(t); for (int j = 0; j < sDetail; j++) { vertex(sphereX[v1]*r, sphereY[v1]*r, sphereZ[v1++]*r, u, v); vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2++]*r, u, v+iv); u+=iu; }
// Close each ring v1=v11; v2=voff; vertex(sphereX[v1]*r, sphereY[v1]*r, sphereZ[v1]*r, u, v); vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2]*r, u, v+iv); endShape(); v+=iv; } u=0;
// Add the northern cap beginShape(TRIANGLE_STRIP); texture(t); for (int i = 0; i < sDetail; i++) { v2 = voff + i; vertex(sphereX[v2]*r, sphereY[v2]*r, sphereZ[v2]*r, u, v); vertex(0, r, 0,u,v+iv); u+=iu; } vertex(sphereX[voff]*r, sphereY[voff]*r, sphereZ[voff]*r, u, v); endShape();
Just a word to invite you to look the page of Romanesco Project. The idea it's made an app for the artist-coder to mix different code in the same "Scène" (display), in the same time with a lot thing to change the parameter of code, the most important paramter is a SOUND !!!
I think push this one in autumn 2013 on Github.
But to wait this time you can visit the page, send me your feed back.
//DISC void disc( PVector pos, int diam ) { for ( int i = 1 ; i < diam +1 ; i++) { circle(pos, i) ; } } //CIRCLE //classic void circle(PVector pos, int d) { int surface = d*d ; // surface is equale of square surface where is the circle.
I wish see my shape follow a specific path, this one is an ArrayList of points.
My problem is than my shape stop the move to differents coordinates points and I don't understand why, I search, but every time is very differents, depending of the coordinate. Some time just after the first point, some time after three round....
If any one have an idea, I take it now !
Thx
Stan
Follow fllw ;
float speed = 0.5 ; PVector position = new PVector(-1, -1 ) ; // to initialize the position
fllw.Path() ; // add point to the path example //fllw.readPointsToThePath() ; // add point from file.txt
}
void draw() { background(255) ;
fllw.path() ; // draw the path position = fllw.follow(position, speed) ; // feed back the position from the class Follow translate(position.x, position.y) ; // update the position of the Shape shape1() ;
class Follow { // list of the keypoint, use super_class Path ArrayList<Path> listP ; // distance between the keypoint and the position of the translation shape float distObjectFromStartKeyPoint = 0 ; float distBetweenTwoKeyPoints = 0 ; // a & b are points to calculate the direction and position of the translation to give at the shape PVector a, b ; // calcul the gap between a & b PVector c = new PVector (0,0,0) ; // speed ratio to adjust the speed xy according to position target PVector r = new PVector (0,0,0) ; //keypoint PVector pos ; //keypoint example PVector pos1, pos2, pos3, pos4, pos5, pos6 ; // find a good keypoint in the ArrayList int n = 0 ; int m = 1 ;
Follow() { listP = new ArrayList<Path>() ; }
PVector follow(PVector position, float speed) { if (listP.size() > 1 ) { // find a good keypoint in the list Path pthA = (Path) listP.get(n) ; Path pthB = (Path) listP.get(m) ; // update the position a & b from the list of keypoint a = pthA.pos ; b = pthB.pos ; // give a starting position of the path, must use the same xyz than initialize PVector, here it's -1, -1 if (position.x == -1 && position.y == -1 ) { position.x = a.x ; position.y = a.y ; } // distance between the keypoint a & b and the position of the translation shape distBetweenTwoKeyPoints = PVector.dist(a, b ) ; distObjectFromStartKeyPoint = PVector.dist(position, a) ;
new day, new problem !!!
I try to make a layer system and sort the layer from the top to the bottom.
But I've big problem to sort the objects from my ArrayList.
The idea it's to show the level of the layer and give the position, if it's the first, second,... or the last.
I try to extract the level of my layer list to copy in list of rank to sort this one, because I don't manage to sort directly my list of object... I try to make an example short, but don't manage too. So I give the big sketch.
I see few solution in the forum, but very complex for me...I just find the solutions with Collections.sort(arg).
I show the problem is in the part 3 between ///////////////////// and ///////////////
color BG = color(100,95,95) ;
ControlLayer cLayer ; PVector posLayer = new PVector (0,0) ; PVector sizeLayer = new PVector (0,0) ;
if (lyr.detection() || listLayer.size() > maxLayer-1) {; return ; }
} //Layer lyr = new Layer(p, s, rowHeight, Layer.ID1) ; // example to call the ID directly from the class Layer Layer lyr = new Layer(p, s, rowHeight, ID) ; listLayer.add(lyr) ; }
class Layer { private color c ; private color noir = color (0) ; private color blanc = color (255) ; private color rouge = color (215,30,30 ) ; private color orange = color (255,150,0 ) ; private color jaune = color (255,230,0 ) ; private color violet = color (150,90,200 ) ; private color vert = color (160,180,70 ) ; private color bleu = color (90,170,200 ) ; private color IDcolor1 = orange ; private color IDcolor2 = jaune ; private color IDcolor3 = rouge ; private color IDcolor4 = violet ; private color IDcolor5 = bleu ; private color IDcolor6 = vert ;
PVector p, s ; float newPosX, newPosY ; // we cannot use PVector for this relay, if we use PVector relay the object don't come back float rowHeight ;
// identity of layer int ID = 0 ; final static int ID1 = 1 ; final static int ID2 = 2 ; final static int ID3 = 3 ; final static int ID4 = 4 ; final static int ID5 = 5 ; final static int ID6 = 6 ;
// ranking of layer int rankLayer = 1 ; ArrayList listRanking ; // boolean to move the layer boolean inside, locked, contact ; boolean dropped = true ;
this.s = s ; this.rowHeight = rowHeight ; this.ID = ID ;
listRanking = new ArrayList() ; }
void update() { float posY = (floor(mouseY / rowHeight) * rowHeight) + rowHeight / 2.0 ; // move in the row grid if(locked) { // if the layer is locked he follow the mouse newPosX = mouseX ; newPosY = posY ; } else if (contact && !locked && !dropped) { c= blanc ; newPosX = p.x ; newPosY = p.y ; } else if (contact) { c= blanc ; } else { c = noir ; newPosX = newPosX ; newPosY = newPosY ; } }
void display() { if ( ID == 1 ) c = IDcolor1 ; else if ( ID == 2 ) c = IDcolor2 ; else if ( ID == 3 ) c = IDcolor3 ; else if ( ID == 4 ) c = IDcolor4 ; else if ( ID == 5 ) c = IDcolor5 ; else if ( ID == 6 ) c = IDcolor6 ; else c = noir ; fill(c) ;
noStroke() ; // rect (newPosX, newPosY, s.x, s.y ) ; // basic rect (width/2, newPosY, s.x, s.y ) ; } // DRAG void drag(ArrayList<Layer> listLayer) { // check if boolean inside is true and the mouse is pressed if (detection() ) inside = true; else inside = false;
if ( inside && mousePressed && !otherLocked(listLayer) ) { locked = true ; dropped = false ; } if ( !mousePressed ) { locked = false ; } if ( !mousePressed && !inside ) { dropped = true ; } } //COLLISION.CONTACT.NoCONTACT //::Collision void collision(ArrayList<Layer> listLayer ) { for (Layer target : listLayer) { if (target != this) { //check if two layers are in contact if (collide(target) ) { contact = true ; break ; // we must stop the loop at the first collide } else { contact = false ; } } } } //INFO //show info void info (ArrayList<Layer> listLayer) { fill (noir) ; rankingLayers(listLayer) ; text (rank() + " / " + rankLayer, 10, newPosY +5 ) ; // give the rank of layer from the top of board } ///////////////THE PROBLEM IS HERE//////////////////////// ///////////////////////////////////////////////////////// // ranking the layer from the top to the bottom void rankingLayers(ArrayList<Layer> listLayer ) { // clear the rank list to update the ranking listRanking.clear() ;
} //RETURN // return rank from the top of board ArrayList getRanking() { return listRanking ; } //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// int rank() { int r = floor(newPosY / rowHeight) +1 ; return r ; } // check if the cursor is on the layer or not boolean detection() { if( mouseX > newPosX - s.x /2.0 && mouseX < newPosX + s.x /2.0 && mouseY > newPosY - s.y /2.0 && mouseY < newPosY + s.y /2.0) { return true; } else { return false; } } // // Make sure no other buttons are active in the list of objects wished boolean otherLocked(ArrayList<Layer> listLayer) { for (Layer lyr : listLayer ) { // don't need to call the the ArrayList because we call this one in the Collision Void if (lyr.locked) { return true; } } return false; } // // see if there is collide between two things boolean collide(Layer target) { float distanceX = newPosX - target.newPosX ; float distanceY = newPosY - target.newPosY ; float treshX = s.x /2.0 + target.s.x /2.0 ; float treshY = s.y /2.0 + target.s.y /2.0 ; // println(abs(distanceY) + " / " + treshY) ; if (abs(distanceX) < treshX && abs(distanceY) < treshY) { // if the distance is less than the threshold, we are colliding! return true; } else { return false; } } /////////////// }
I search an idea to named class like an array, because I need a lot of classes, may be thirty, may be more with a same familly name. And i don't want write the name and add a number for calling the class, calling the void...etc. I don't find a topic about that, may be is not possible?
I make an example with three classes and classical system,
but I should make something like that
for ( int i = 0 ; i < n ; i++ ) {
String a = "Object" ;
String classObject = a + (i+1) ;
if ( i+1 == 1 ) obj1 = new Object1() ;
}
void draw() { background(0) ; obj.display() ; } // class Call class Object { int n ; // quantity of class must be open
Object1 obj1 ; Object2 obj2 ; Object3 obj3 ;
Object() { // read the .txt with the info with quantity of class must be open /* String call[] = loadStrings("/Users/stanislasmarcais/Desktop/ROMANESCO/Romanesco_Beta/TestInterface/importationProgShape/importationProgShape1a/data/ClassShape.txt"); for (int i = 0 ; i < call.length ; i++ ) { String [] cut = split(call[i], ':' ) ; String nObject = cut[1] ; n = int(nObject) ; } */ int call = 3 ; n = call ;
for ( int i = 1 ; i <= n ; i++ ) { if ( i == 1 ) obj1 = new Object1() ; if ( i == 2 ) obj2 = new Object2() ; if ( i == 3 ) obj3 = new Object3() ; } }
void display() { text ("Total class Objects: " + n, 20, 20 ) ; for ( int i = 1 ; i <= n ; i++ ) { if ( i == 1 ) obj1.display() ; if ( i == 2 ) obj2.display() ; if ( i == 3 ) obj3.display() ; } } } // class called class Object1 { Object1 () {} void display() { text("First class object", 20 , 40) ; } } class Object2 { Object2 () {} void display() { text("Second class object", 20 , 60) ; } } class Object3 { Object3 () {} void display() { text("Third class object", 20 , 80) ; } }
Hello Everybody,
I try to make a system to show the collision between particles, not the effect ; for that it's ok.
So in my example I want see particles white and add the number between them when there is collision. It's ok when there is two particles, but with more the last particle make law for the number, and for the color all particles must be together to became white. I walk around my code since few days but I don't find the other way of code.
So if anybody have an idea, i take it, i don't find track of my purpose in the forum.
Hello,
I have problem with my lock particle...I want forbiden the creation of particle when this one is lock for the drag.
I white a note on the Sketch where the problem is.
color inAtom = color (255, 255, 255, 255) ; // noir
Atome (float aX, float aY, float aZ ) { x = aX ; y = aY ; z = aZ ; }
// Detection the cursor is on the atom boolean detection2D (int d) { float disX = x - mouseX ; float disY = y - mouseY ; if (sqrt(sq(disX) + sq(disY)) < d / 2 ) { return true ; } else { return false ; } } // return if Atom is lock or not boolean lock_() { if (lock) { return true ; } else { return false ; } }