We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys, I'm pretty new at processing and need your help. I already have the triangle grid but now I need to clinche some lines and also remove some lines. It shoud look like the picture, but changing by mouseClicked. Thats what I already have:
float elementBr, elementH, anzahlX, anzahlY, rand1, rand2, rand3,a,b;
float[][] Dreiecke;
int Breite=70;
float[] KnotenX;
float[] KnotenY;
int nrX, nrY,nrKnoten;
float atr;
void setup() {
size(800, 570);
background(0);
//smooth();
strokeWeight(0.5);
elementBr = 20;
elementH = (sqrt(3)/2)*elementBr;
}
void draw() {
background(0);
stroke(255);
noFill();
nrX=width/Breite;
nrY=height/Breite;
nrKnoten=nrX*nrY;
KnotenX= new float[nrKnoten];
KnotenY= new float[nrKnoten];
anzahlX=width/elementH;
anzahlY=height/elementBr;
//int x=0;
for(int j = 0; j < anzahlX+(elementH*2); j++) {
beginShape(TRIANGLE_STRIP);
for(int i = 0; i < anzahlY +(elementBr*2); i++) {
float shift = (j % 2) == 0 ? (elementH/2)+3 : 0;
vertex(-elementBr+i*elementBr+shift, j*elementH);
vertex(-elementBr+i*elementBr+(elementBr/2)+shift, j*elementH+elementH);
}
endShape();
}
//for(int j=0;j<pos.length;j++){
// float dist=atr.dist(pos[j]);
// if (dist<2*Breite){
// PVector dir=new PVector(atr.x,atr.y);
// dir.sub(pos[j]);
// float faktor=map(dist,0,2*Breite,0.8,0.2);
// dir.mult(faktor);
// pos[j].add(dir);
// fill(255,0,0);
// beginShape(TRIANGLE_STRIP);
// float shift = (j % 2) == 0 ? (elementH/2)+3 : 0;
// vertex(pos[j].x,pos[j].y);
// vertex((pos[j].x)+shift, pos[j].y);
// } else{
// fill(255);
// vertex(pos[j].x,pos[j].y);
// }
//}
fill(0);
noStroke();
rect(0,0,40,height);
rect(0,0,width,30);
rect(width,0,-120,height);
rect(0,height,width,-30);
noLoop();
}
void mouseClicked(){
loop();
}
`
Answers
What does "clinche some lines" mean? Did you mean clinch (grip, gather, knot), and can you be more specific?
It means, like you can see in the picture, that the grid isnt regularly anymore. Looking like folds of fabric. :)
What you see there is a height map
That’s why it looks like a fabric or landscape
There might be tutorials/ examples for height field
When you had a data set boolean [] vertexIsOn to store if a vertex is there (initial all true) you could set a position to false when the mouse is clicked in the area (use dist())
If the pictures you want to imitate are generated by triangle strip height maps (3D terrain) then here is a discussion of related techniques:
Note that this approach would require using the P3D renderer in
size()
rather than the default 2D.The tutorial was pretty helpful. Thanks to the two of you. But I don't get how to connect boolean with mouseClicked. Could you help me again? Thats how far I am:
@LiP -- re:
Can you describe what you are trying to do in more detail?
if()
expects a statement that evaluates to True or False.dist()
returns a number -- not true or false.You might want something like "if the distance is greater than x" ....?
This means: you are trying to put in a number where you should be putting in something that is true/false. For example, use
>
to return true/false.I tried to turn the colour of the lines that are near to the mouse into black. So it is looking like something is missing in the grid. Like if the distance between mouse and line ist smaller than 4*width of the triangle the stroke is changing into black. But any way that could turn some lines in black would be good for me..
If this array
Bewegung
holds the lines / points:make a parallel grid of
boolean isThere
as I described (beforesetup()
)Before 72 place an
if(isThere[...][...]......
which can suppress vertices (using the data of
isThere
)in mouseClicked or mousePressed
for
loop overBewegung
and check thedist()
for all and set themisThere[][]
to false accordingly (storing data intoisThere
)@Chrisir Do you have an example for the using of boolean []? I never used it before and find nothing, thats helpful.
look at reference boolean please
boolean[][] isThere = new boolean [111][111];
some works needs to be done
since we have ONE huge shape it looks dumb when we remove vertices
Thank you so much! I already have an other code without vertex and 3D. But stucking again.. I try to connect ellipses with lines. But in this code there are only lines in the left corner.
And in this Code there is the grid missing:
Could you please help me,`` again?
based on the first code of the last two codes you posted is this example.
Based on this first code I think you don't have a clue what's going on, eh?
I am not willing to look at your second code (of the two you posted last).
But please get rid of noLoop and loop.....
Thank you so much!
;-)