We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
ControlP5 and OPENGL (Read 2978 times)
ControlP5 and OPENGL
Mar 16th, 2010, 6:15pm
 
Hi Community,

I have poured through the forums and tried most of the suggestions to battle this issue but think I am still doing something incorrectly.

I am simply attempting to have my GUI lay on top of my 3D Environment.

I am using the ControlP5 library and OPENGL.

My beautifully slanted menu:
http://net35.ccs.neu.edu/home/ayellet/gui_issue.jpg

I have a few classes and am not sure which way is best to provide code to the forum.

http://net35.ccs.neu.edu/home/ayellet/RunEarth_gui.zip

//A snippet of the code. Complete code in the Zip above

 void draw() {
    background(0,255,0,50);  

    hint(ENABLE_DEPTH_TEST);
    // 3D OpenGL stuff
    earth.drawPlanet();
   
    hint(DISABLE_DEPTH_TEST);
    // 2D OpenGL UI
    pl.drawPlaceList();
  }

I really appreciate your time reading this post!

--
Ayari

Re: ControlP5 and OPENGL
Reply #1 - Mar 16th, 2010, 6:30pm
 
If you use the peasycam library to control your camera, it has a really nice HUD feature that will take care of this.  
Code:
cam.beginHUD();
fill(255,100,0);
rect(0,0,width,100);
cam.endHUD();


Otherwise you'll have to store the camera matrix, draw, then restore the matrix.

Code:
PMatrix3D currCameraMatrix;
PGraphics3D g3;

void setup() {
 size(200,200,P3D);
 g3 = (PGraphics3D)g;
}

void draw(){

 currCameraMatrix = new PMatrix3D(g3.camera);
 camera();
 //  Start HUD
 fill(255);
 rect(10,10,80,30);
 //  End HUD
 g3.camera = currCameraMatrix;
}
Re: ControlP5 and OPENGL
Reply #2 - Mar 16th, 2010, 7:06pm
 
Thank you so much for the prompt reply! I'll definitely try it out

--
Ayari
Re: ControlP5 and OPENGL
Reply #3 - Mar 17th, 2010, 5:39am
 
I have taken your suggestion to use the Peasy library.

While I wasn't able to get the begin and end cam working, I was able to get the rotation working using the library after a little more research.


2 remaining issues:


Now my only problem is that it appears the rotation of my earth is not centered within my sphere. The origin of the rotation needs to be in the center of my sphere

Could this have something to do with my creation of the earth in a class

ALSO, my menu appears to disappear when using P3D, OPENGL does show it (though it definitely isn't displayed permanently on top of my 3d environment)

Feels like i'm very close!


using P3D:
http://net35.ccs.neu.edu/home/ayellet/P3D_gui.jpg

using OpenGL:
http://net35.ccs.neu.edu/home/ayellet/openGL_gui.jpg


Code:

PeasyCam cam;
PGraphics3D g3;
PMatrix3D currCameraMatrix;
ControlP5 controlP5;

Planet earth = new Planet("earth.jpg", 30, 200);
PlaceList pl = new PlaceList();
int planetScale = 200;


void setup(){

   // The size of our stage. P3D / OPENGL.
   size(900,900,P3D);
   g3 = (PGraphics3D)g;
   cam = new PeasyCam(this, 100);
 
   ControlP5 controlP5 = new ControlP5(this);
   pl.setupPlaceList(controlP5);
   
   earth.setupPlanet();
}

 void draw() {
    background(0,255,0,50);
    earth.drawPlanet();
    gui();
       
  }
 
  void gui() {
  currCameraMatrix = new PMatrix3D(g3.camera);
  camera();
  pl.drawPlaceList();
  g3.camera = currCameraMatrix;
}
 
Re: ControlP5 and OPENGL
Reply #4 - Mar 17th, 2010, 10:31am
 
Doh!
ControlP5 controlP5 = new ControlP5(this); is not correct!

All well over here.

Thanks again for your help!
Re: ControlP5 and OPENGL
Reply #5 - Mar 17th, 2010, 2:03pm
 
You might also want to turn of the light via noLight(); before drawing the HUD.
Re: ControlP5 and OPENGL
Reply #6 - Mar 29th, 2010, 9:04pm
 
The suggestions above were perfect. The GUI stays stationary on top of my 3D camera.

Now I'm having problems with the text on the buttons. Using P3D, the font is blurry and unreadable. Using OPENGL, the font is perfect but my 3D environment requires me to use P3D(otherwise it breaks).

Are there any suggestions for the code below to get the font working properly? I've sifted through the forums and haven't found something that has helped me resolve this.

Thank you for your time, I've almost gotten my functionality completed!!

PeasyCam cam;
PGraphics3D g3;
PMatrix3D currCameraMatrix;

 void setup(){

   // The size of our stage. P3D / OPENGL.
   size(500,500,P3D);
   g3 = (PGraphics3D)g;
   cam = new PeasyCam(this, 700);
   controlP5 = new ControlP5(this);
}


 void draw() {
    background(0,255,0,50);  
    earth.drawPlanet();
   
   ///Loop through each city and fly to each sig graph location we need.
   if(playButtonArray.contains(3)){
     for(int i = 0; i < countryMapSelected.size(); i++) {
       for(int j = 0; j < sig_cities.size(); j++) {
           flightPaths.drawCurves(getCountry((Integer)countryMapSelected.get(i)),                getSigCity(j), planetScale);
       }
     }
   }
    gui();
    locationMenu();
  }

  void gui() {
   currCameraMatrix = new PMatrix3D(g3.camera);
   camera();
   controlP5.draw();
   g3.camera = currCameraMatrix;
  }
Re: ControlP5 and OPENGL
Reply #7 - Mar 31st, 2010, 9:42am
 
Try adding this in your setup.
hint(ENABLE_NATIVE_FONTS);
Page Index Toggle Pages: 1