We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Help with Perlin Noise
Page Index Toggle Pages: 1
Help with Perlin Noise (Read 423 times)
Help with Perlin Noise
Apr 11th, 2010, 6:54pm
 
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!  Smiley
Re: Help with Perlin Noise
Reply #1 - Apr 11th, 2010, 7:19pm
 
try multiplying n by 3000!  It is such a small number that the shapes that have a dimension of n are going to display at 1px.  You can get it to modulate other shapes, like triangle, by writing your own triangle function that uses n in some way.  For example: by writing a function that uses n to travel a certain distance and angle from a center point, and defining the triangle as a set of 3 vertices between beginShape and endShape.
Re: Help with Perlin Noise
Reply #2 - Apr 11th, 2010, 9:30pm
 
Thanks! I was looking really closely, I didn't even think a pixel would escape my eyes. But I suppose it did  Tongue
Page Index Toggle Pages: 1