Graphic interface on top 3d + camera();
in
Core Library Questions
•
2 years ago
Hello everyone,
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
- //to the terminal
- field.printcubes();
- }
- void draw() {
- background(0);
- //camera control (concept!!!)
- camera(20 , 20 , 220, // eyeX, eyeY, eyeZ
- 20 , 20 , 0, // centerX, centerY, centerZ
- 0.0, 1.0, 0.0 ); // upX, upY, upZ
- hint(ENABLE_DEPTH_TEST);
- //printing 3d images
- field.displaycubes();
- field.displayfield();
- hint(DISABLE_DEPTH_TEST);
- }
- void controlEvent(ControlEvent theEvent) {
- println(theEvent.arrayValue());
- }
1