Hello. How to draw a button?

edited August 2016 in Library Questions

Screenshot_2016-08-14-21-16-13

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

Sign In or Register to comment.