Hi I'm a newbie, and I'm trying to convert this code for bouncing balls from 2D to 3D to use it in another sketch, but I'm having issues getting the balls to stay in the frame.....any help would be greatly appreciated! (I'm sure its something really simple)
int numBalls = 12;
float spring = 0.05;
float gravity = 0.03;
float friction = -0.9;
import processing.opengl.*;
Ball[] balls = new Ball[numBalls];
void setup()
{
size(1000, 700,OPENGL); //640
noStroke();
smooth();
for (int i = 0; i < numBalls; i++) {
balls[i] = new Ball(random(width), random(height), 0, random(20, 40), i, balls);
}
}
void draw()
{
lights();
background(0);
for (int i = 0; i < numBalls; i++) {
balls[i].collide();
balls[i].move();
balls[i].display();
}
}
class Ball {
float x, y,z;
float diameter;
float vx = 0;
float vy = 0;
float vz = 0;
int id;
Ball[] others;
Ball(float xin, float yin, float zin, float din, int idin, Ball[] oin) {
x = xin;
y = yin;
z = zin;
diameter = din;
id = idin;
others = oin;
}