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 & HelpSyntax Questions › sphereDetail into loop
Page Index Toggle Pages: 1
sphereDetail into loop (Read 700 times)
sphereDetail into loop
Mar 10th, 2010, 8:19pm
 
hi,

Not a very advanced scripter here Smiley

i've read the information of sphereDetail, but i don't understand why it still keeps the same size when i render. I Want to visualize the Fibonnaci string with the amount of segments:

Code:

for(int y = 1; y <20; y++){
rotateY((PI*2)/fibs[y]);
pushMatrix();
fill(random(255), random(255), random(255),30);
sphereDetail(3+((int)fibs[y]/(int)fibs[20]/4));
translate(width/2,height/2, fibs[16]);
sphere(fibs[20]/fibs[y]);
println(y);

//println(num);

popMatrix();
}


Code:
void generate(int count){
for(int i = 1; i < count; i++){
fibs=append(fibs,number);
last=last2;
last2=number;
number+=last;
}
}


I don't understand why it still keeps the same resolution when it loops. I've read everything now, but still.. tried allot of combinations.

who can help me with this.. i'm out of options Sad

Re: sphereDetail into loop
Reply #1 - Mar 10th, 2010, 11:28pm
 
I don't understand what you're trying to do. sphereDetail() doesn't change the size of the spheres rendered, just how many times the sphere surface is divided up to make the rendering smoother. What is generate() for? You don't call it from the first part of your code.

Are you using setup() and draw(), or is this the entirety of your code (to draw a single image)? (Edit: can't possibly be the entirety of your code, since fibs[] is not defined, for example).

Suspicion: integer division (int / int -> int) could possibly be rounding things to a single value instead of (expected) multiple values.

Other: the rotateY() is 'outside' of the pushMatrix() / popMatrix() nest; this means the rotation each time will be relative to the previous rotation.

-spxl
Re: sphereDetail into loop
Reply #2 - Mar 11th, 2010, 12:04am
 
Anyone?? please?
Re: sphereDetail into loop
Reply #3 - Mar 11th, 2010, 1:13am
 
Anyone what?

Post the rest of your code and try to explain your problem better.

-spxl
Re: sphereDetail into loop
Reply #4 - Mar 11th, 2010, 1:55am
 
subpixel wrote on Mar 11th, 2010, 1:13am:
Anyone what

Post the rest of your code and try to explain your problem better.

-spxl


sorry, i didn't see your reaction

Code:
float number = 1;
float last,last2;
float[] fibs= new float [1];


import processing.opengl.*;

aTileSaver tiler;

void setup() {
 size(1000,1000, P3D);
 noStroke();
 tiler=new aTileSaver(this);
 generate(40);
 noLoop();
}

public void draw() {
 if(tiler==null) return; // Not initialized


 tiler.pre();

 smooth();
 background(255);

 float ang=PI;

 smooth();

   noStroke();
 
 
  for(int y = 1; y <20; y++){
    rotateY((PI*2)/fibs[y]);
pushMatrix();
  fill(random(255/fibs[y]),2);
   
  for(int x = 1; x <5; x++){
    sphereDetail(3+((int)fibs[y]/(int)fibs[20]));
 translate(width/2,height/2,  fibs[20]/1);
   sphere(fibs[20]/fibs[y]);
   saveFrame("line-####.tif");
  }  
println(y);


popMatrix();
    }
   






   tiler.post();
 

}

// Saves tiled imaged when 't' is pressed
public void keyPressed() {
 if(key=='t') tiler.init("Simple"+nf(frameCount,5),5);
}

void generate(int count){
 for(int i = 1; i < count; i++){
   fibs=append(fibs,number);
   last=last2;
   last2=number;
   number+=last;
 }
}





and how can i make it viewable fullscreen. I want to visualize every step.
Re: sphereDetail into loop
Reply #5 - Mar 11th, 2010, 6:20am
 
Problem:
  • sphereDetail(3+((int)fibs[y]/(int)fibs[20]));
Reason:
  • fibs[20] is a large number (6765).
  • fibs[y] (where y < 20) is a not-so-large number (less than 6765)
  • small number / large number = a fraction less than 1
  • integer division (int / int) results in an integer answer; the fraction is discarded
  • Therefore ((int)fibs[y]/(int)fibs[20]) == 0 for all values of y < 20
  • It follows that sphereDetail() is always called with the value "3".


Full-screen display:
menu: Sketch > Present
or Ctrl+Shift+R keyboard shortcut (or similar but maybe using Apple/Command/some-crappy-key on a Mac)

You can use size(screen.width, screen.height) to set the sketch size to the screen size.

-spxl

PS: You must be using a library for which you did not include the import statement in the code you posted (what is "aTileSaver"?). Not helpful.
Page Index Toggle Pages: 1