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 › Camera movement Help
Page Index Toggle Pages: 1
Camera movement Help (Read 233 times)
Camera movement Help
Dec 3rd, 2008, 4:31pm
 
Hi, I have this code for processing where I am trying to create a 3D visualizer for music. I have a standard wave bars going with a cube rotating.

I want to know how would I be able to do a camera movement where I can circle around the wavebars and cube. Anyone know how I can do this?

Here is my code:

import ddf.minim.*;

Minim minim;
AudioPlayer groove;
WaveformRenderer waveform;


void setup()
{
 size(512, 400, P3D);

 minim = new Minim(this);
 groove = minim.loadFile("John_Legend.mp3", 2048);
 groove.loop();
 
 waveform = new WaveformRenderer();
 // see the example Recordable >> addListener for more about this
 groove.addListener(waveform);

}


void draw()
{
 background(0);
 // see waveform.pde for an explanation of how this works
 waveform.draw();
 // Change height of the camera with mouseY

 
 translate(width / 2, height / 2);
 
 // Orange point light on the right
 pointLight(150, 100, 0, // Color
            200, -150, 0); // Position

 // Blue directional light from the left
 directionalLight(0, 102, 255, // Color
                  1, 0, 0); // The x-, y-, z-axis direction

 // Yellow spotlight from the front
 spotLight(255, 255, 109, // Color
           0, 40, 300, // Position
           0, -0.5, -0.5, // Direction
           PI / 2, 2); // Angle, concentration
 
 
 rotateY(frameCount*PI/250);
 rotateX(map(100, 0, height, 0, PI));
 box(100);




}


void stop()
{
 // always close Minim audio classes when you are done with them
 groove.close();
 // always stop Minim before exiting.
 minim.stop();
 
 super.stop();
}




class WaveformRenderer implements AudioListener
{
 private float[] left;
 private float[] right;
 
 WaveformRenderer()
 {
   left = null;
   right = null;
 }
 
 synchronized void samples(float[] samp)
 {
   left = samp;
 }
 
 synchronized void samples(float[] sampL, float[] sampR)
 {
   left = sampL;
   right = sampR;
 }
 
 synchronized void draw()
 {
   // we've got a stereo signal if right is not null
   if ( left != null && right != null )
   {
     noFill();
     stroke(0,255,255);
     beginShape();
     for ( int i = 0; i < left.length; i++ )
     {
       vertex(i, height/2 + left[i]*50);
     }
     endShape();
   
     noFill();
     stroke(255,255,0);
     beginShape();
     for ( int i = 0; i < left.length; i++ )
     {
       vertex(i, height/3.25 + left[i]*50);
     }
     endShape();
     
     noFill();
     stroke(255,0,255);
     beginShape();
     for ( int i = 0; i < right.length; i++ )
     {
       vertex(i, 3*(height/4) + right[i]*50);
     }
     endShape();
   }
   
   else if ( left != null )
 
     endShape();
 
   }
   }

Re: Camera movement Help
Reply #1 - Dec 3rd, 2008, 6:08pm
 
I reckon you want to use the OCD camera library:

http://www.cise.ufl.edu/~kdamkjer/processing/libraries/ocd/

Circling is then one simple command.
Page Index Toggle Pages: 1