// applet size variables int xSize = 400; int ySize = 300; int xMid = xSize/2; int yMid = ySize/2; int frameRate = 30; int counter = 0; Camera camera; SpikeBall spikeBall; void setup(){ size(xSize, ySize); //lights(); //smooth(); framerate(frameRate); ellipseMode(CENTER_RADIUS); colorMode(HSB,255); // create camera (distance, lensAngle) camera = new Camera(100.0, 60.0); // create spikeBall (numSpikes, spikeLength, speed) spikeBall = new SpikeBall(25, 200, 5); } void loop(){ background(0); camera.exist(); spikeBall.exist(); counter ++; delay(10); } class Camera{ // camera variables float xPos, yPos; float x, y; float rotationVar; float elevation; float azimuth; float twist; float distance; float lensAngle; boolean autoRotate = false; Camera (float sentDistance, float sentLensAngle){ distance = sentDistance; lensAngle = sentLensAngle; } void exist(){ findRotation(); findPosition(); setCamera(); } void findRotation(){ if (autoRotate){ xPos -= (xPos - (cos(counter/80.0) * 65.0)) * .2; yPos -= (yPos - (sin(counter/135.0) * 86.0)) * .2; azimuth = cos(counter/100.0); } else { xPos -= (xPos - (xMid - mouseX)) * .2; yPos -= (yPos - (yMid - mouseY)) * .2; } } void findPosition(){ //x = cos(counter/100.0) * 3.0; //y = sin(counter/50.0) * 1.5; x = 0.0; y = 0.0; } void setCamera(){ beginCamera(); perspective(lensAngle, (float)xSize / (float)ySize, 1.0f, 200); translate(x, y, -distance); twist = radians(xPos); elevation = radians(yPos); rotateY(-twist); rotateX(elevation); rotateZ(-azimuth); endCamera(); } } class SpikeBall{ Spike[] spike; int numSpikes; int spikeLength; int speed; float bodyRadius; float xRot, yRot, zRot; SpikeBall(int sentNumSpikes, int sentSpikeLength, int sentSpeed){ numSpikes = sentNumSpikes; spikeLength = sentSpikeLength; speed = sentSpeed; spike = new Spike[numSpikes]; for (int i=0; i