We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import controlP5.*;
ControlP5 cp5;
Object sun;
Object earth;
Object moon;
PVector camPos;
PVector camEye;
float camRadius, camTheta, camPhi;
void setup()
{
size(displayWidth, displayHeight, P3D);
cp5 = new ControlP5(this);
cp5.setAutoDraw(false);
cp5.addButton("Button",1,20,20,100,20);
earth = new Object(1000, 0, 0, 100);
moon = new Object(1200, 0, 0, 20);
camPos = new PVector(300, 0, 20);
camEye = new PVector(0, 0, 0);
camRadius = 2000;
camTheta = 160;
camPhi = -40;
}
void draw()
{
background(100, 100, 100);
camera(camPos.x, camPos.y, camPos.z, camEye.x, camEye.y, camEye.z, 0, 0, 1);
noLights();
pointLight(255, 255, 255, 150, 0, 0);
if(mousePressed)
{
camTheta += (mouseX - pmouseX);
camPhi += (pmouseY - mouseY);
}
updateCamera();
earth.draw();
moon.draw();
}
void updateCamera()
{
camPos.x = camEye.x + camRadius * cos(camPhi * PI/180) * sin(camTheta * PI/180);
camPos.y = camEye.y + camRadius * cos(camPhi * PI/180) * cos(camTheta * PI/180);
camPos.z = camEye.z + camRadius * sin(camPhi * PI/180);
}
Answers
https://forum.Processing.org/two/discussion/17503/controlp5-acting-up
I had to add code at the end of draw()
It's called a HUD