I'm trying to use a diy controller from de controlP5 library examples for controlling the camera in OpenGL. The diy controller works fine without adding the camera function and prints nicely on top of 3d. Only once I add the camerafunction it doesn't print the diy controller on top of 3d but inside 3d. How can I correct this?
I used the following code:
/*
Gemaakt door Willem den Hollander
*/
import processing.opengl.*;
import controlP5.*; //library for graphic interface
//declaring a datafield
Datafield field;
//declaring controlpad and controlP5 (concept!!!)
ControlPad cp;
ControlP5 controlP5;
void setup() {
size(800, 600, OPENGL);
frameRate(30);
controlP5 = new ControlP5(this);
// create a new instance of the ControlPad controller.
cp = new ControlPad(controlP5,"DIY",60,40,100,100);
// register the newly created ControlPad with controlP5
controlP5.register(cp);
//initializing the datafield
field = new Datafield();
//add 5 datacubes
field.addcube("Cube #1", 20, 20, 0);
field.addcube("Cube #2", 20, 50, 0);
field.addcube("Cube #3", 20, 80, 0);
field.addcube("Cube #4", 20, 110, 0);
field.addcube("Cube #5", 20, 140, 0);
//print the data of all datacubes inside the field
I am trying to create a graphbar that i can chance by value by using a varslide (don't know the right name for it
). I have created 2 functions in order to do that, to be able to add more graphbars and varslides. The problem is that when I want to add a varslide all the varslides will get the same value. The problem lies whit global declaring the integer data. I just started programming so I could not find a sulution for this. You can find the code below. Comments are in dutch (sorry
). I could translate if you want to.
Thanks,
Willem
int data=0; // Variabele die veranderd wanneer er op de knoppen wordt gedrukt.
int tempdata=1;
long tempMillis = 0; // Variabelen die worden gebruikt om ervoor te zorgen dat wanneer er op een knop gedrukt wordt de variabele
long interval = 80; // "data" maar met 1 wordt verlaagd of verhoogd.
void setup() {
size(500,500); // Groote van het aplicatie scherm.
background(#D1E5FF); // Kleur van de achtergrond van de aplicatie. Is in dit geval blauw.
PFont fontA;
fontA = loadFont("Calibri-48.vlw");
textFont(fontA, 16);
}
void draw() {
long Millis = millis();
if(Millis - tempMillis > interval) { // Wanneer er op een knop gedrukt wordt zullen de volgende acties pas na de ingestelde tijdinterval weer
tempMillis = Millis; // meedoen met het programma.
int Varslide1 = Varslide(80, 80);
graphbar(50, 50, Varslide1);
}
}
int Varslide(int tempX, int tempY) {
boolean Plus = false; // Plus wordt geinitieerd als "false".
boolean Min = false; // Min wordt geinitieerd als "false".