Hello all. I'm trying to create an owl, and I'm wanting him to change size according to the Perlin noise function. Below is my code:
Code:
Owl owl;
Owl owl2;
Owl owl3;
float timeowl=0;
float incrementowl=.01;
void setup() {
size(800,600,P3D);
smooth();
owl = new Owl(100);
owl2 = new Owl(500);
owl3 = new Owl(700);
}
void draw() {
background(255);
owl.display();
owl2.display();
owl3.display();
}
Class:
Code:class Owl {
float xpos;
Owl(float xpos_) {
xpos=xpos_;
}
void display() {
fill(125);
float n = noise(timeowl)*incrementowl;
timeowl+=incrementowl;
ellipse(xpos,250,60,60); //Owl head
beginShape(TRIANGLES); //Owl ear
vertex(xpos-15,230,0);
vertex(xpos-5,230,0);
vertex(xpos-10,200,0);
endShape();
beginShape(TRIANGLES); //Other owl ear
vertex(xpos+15,230,0);
vertex(xpos+5,230,0);
vertex(xpos+10,200,0);
endShape();
fill(255,255,0); //Owl eyes
ellipse(xpos-5,240,n,n);
ellipse(xpos+5,240,n,n);
fill(0); //Owl mouth
ellipse(xpos,260,n,n);
}
}
For some reason, my owl's eyes and mouth are staying the same shape, instead of changing based on the value of noise. I used Shiffman's idea of putting a println in there - I put println(n); and was getting values below 1 back, so I'm assuming there's nothing wrong there.
Also, how do I go about applying my Perlin noise to my owl's ears?
Thanks!