FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   Newbie Problem with Rotation
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Newbie Problem with Rotation  (Read 387 times)
The Public


Newbie Problem with Rotation
« on: Dec 6th, 2004, 6:35am »

I'm new to P5, and I'm doing some experiments to pick up on some things.  In this example, I'm trying to get rotate around a set of points plotted in 3D.  The points are generated randomly by downloading random bytes from http://www.random.org/form.html to a .dat file in data.   The precedent that I'm trying to work from is Casey Reas' 3D plotting of 2D image pixel data here:  http://processing.org/learning/examples/extrusion.html.
 
Thanks in advance for any help.
 
This is the error I get:
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
 
 
 
This is the code I'm trying to run:
 
 
// Random Points 3D
 
boolean onetime = true;
int i=0,j=0,str=255;
// open a file and read its binary data  
byte byt[] = loadBytes("RandomNumbers.dat");  
int[][] bezPoints = new int[byt.length/3][3];
float angle;
 
 
 
void setup(){
 
     size(305, 305);
     framerate(24);
     noFill();
 
 
     for(i=0;i<byt.length/3;i++){
    for(j=0;j<3;j++){
  bezPoints[i][j] = (byt[(i*3)+j]&0xff) + 0x19;
    }//end for
     }//end for  
}//end setup
 
 
 
void loop(){
 
    background(0);  
    // Update and constrain the angle  
    angle += 0.01;  
    if(angle > TWO_PI) { angle = 0; }  
 
 
    //Rotate around center axis
    translate(width/2, 0, 128 ) ;  
    rotateY(angle);  
    translate(-width/2, 0, 128 ) ;
   
 
     //display points
     for(i=0;i<byt.length/3;i++){
   j=0;
   str-=20;
     
   if(str < 5){
  str=255;
    }//end if
     
   stroke(str);  
   
   point(bezPoints[i][j], bezPoints[i][j+1], bezPoints[i][j+2]);
     }//end for
 
}//end loop
 
 
toxi

WWW
Re: Newbie Problem with Rotation
« Reply #1 on: Dec 6th, 2004, 7:36pm »

off the top of my head it looks like your error has more to do with a scoping issue than anything else. your call to loadBytes() would be executed before actually setup() had a chance to run. this is what causes errors internally. as a rule of thumb function calls should only be made within code blocks (other functions). so a correct version of your code would start like this:
 
Code:
byte byt[];
// plus declaration of your other variables...
 
void setup() {
  byt=loadBytes("RandomNumbers.dat");
  ...
}

 

http://toxi.co.uk/
The Public


Re: Newbie Problem with Rotation
« Reply #2 on: Dec 9th, 2004, 11:53pm »

Works.  Awesome.  Thanks.
 
Pages: 1 

« Previous topic | Next topic »