Hi Josan12,
using PeasyCam library (a simple 3Dcam) and OpenGl, I came out with that. Sun is like a central planet with no orbit duration... You have to download PeasyCam first and install it in your Sketch\libraries folder.
import processing.opengl.*;
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
//DECLARE VARS
planetoid myplanetoid;
planetoid myplanetoid2;
planetoid myplanetoid3;
planetoid myplanetoid4;
PeasyCam cam;
void setup () {
size(600, 600,OPENGL);
smooth();
noStroke();
//INITIALISE
cam = new PeasyCam(this,0,0,0,500);
cam.setMinimumDistance(10);
cam.setMaximumDistance(2500);
myplanetoid = new planetoid(230, 250,7, 90, 3000);
myplanetoid2 = new planetoid(200, 200,5, 200, 4000);
myplanetoid3 = new planetoid(300, 200, 9,260, 6000);
myplanetoid4 = new planetoid(width/2,height/2, 20,0, 1000);
}
void draw() {
background(0);
// sun
fill (255, 255, 255,30);
// translate(width/2, height/2,0);
// sphere(25);
ellipse(0, 0, 550, 550);
//CALL FUNCTIONALITY
fill (241, 145, 2);
myplanetoid.run();
fill (255, 2, 2);
myplanetoid2.run();
fill (22, 2, 255);
myplanetoid3.run();
fill (255, 255, 0);
myplanetoid4.run();
}
//
// ===============================================
//
class planetoid {
float orbitDuration = 5*1000; // 5 second orbit
float orbitRad = 50;
float x = 0;
float y = 0;
float dia=0;
//CONSTRUCTOR
planetoid( float _x, float _y, float _dia,
float _orbitRad,
int _orbitDuration ) {
// x = _x;
// y = _y;
dia=_dia;
orbitRad = _orbitRad;
orbitDuration = _orbitDuration;
}
//FUNCTIONS - declare, run once
void run() {
display();
}
void display() {
float ang = TWO_PI * millis()/orbitDuration;
float x = cos(ang)*orbitRad;
float y = sin(ang)*orbitRad;
pushMatrix();
translate(x,y);
sphere(dia);
//ellipse(x, y, 7, 6);
popMatrix();
}
}