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.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › camera and 2D buttons
Page Index Toggle Pages: 1
camera and 2D buttons (Read 1914 times)
camera and 2D buttons
Oct 1st, 2006, 5:27am
 
how can I have a camera() to view my objects in 3D and still have 2D buttons where I can control my camera's position ?

so far when I add the camera, it treats the 2D buttons as shapes in space (so they are NOT 2D buttons anymore).

may calling another window from processing can do it, but I'm NOT sure how I can implement that.

any ideas or sample code ?

Thanks

Salam
Re: camera and 2D buttons
Reply #1 - Oct 1st, 2006, 12:53pm
 
What you need to do, is after you've done all your 3D stuff, do camera(); then if you're using P3D:

Code:
for(int i=0;i<((PGraphics3D)g).zbuffer.length;i++)
((PGraphics3D)g).zbuffer[i]=MAX_FLOAT;


or OpenGL:
Code:
//at the top of the sketch
import javax.media.opengl.*;

//then in draw after you've done the 3D stuff.
GL gl=((PGraphicsOpenGL)g).gl;
gl.glClear(GL.GL_DEPTH_BUFFER_BIT);


This will reset the internals of the scene so that you can draw 2D as normal.
Re: camera and 2D buttons
Reply #2 - Oct 1st, 2006, 6:07pm
 
I tried that but I got the following error:
Type "PGraphicsOpenGL" was not found .

am I missing another import? or something else ?

Thanks

-Salam
Re: camera and 2D buttons
Reply #3 - Oct 1st, 2006, 7:55pm
 
I tried something else and it just worked , I'm posting it just in case other people have the same problem:

void draw ()
{
// this is the moving camera to view in 3D
camera(transX, transY, transZ, 50.0, 50.0, 0.0, 0.0, 1.0, 0.0);

// method that I implemented responsible for the 3D drawing
draw3D_Scene();

// this resets the camera so I can draw in 2D
camera();

// this method is resonpsible of drawing the 2D buttons
drawButtons();
}


but thanks anyway

-Salam
Re: camera and 2D buttons
Reply #4 - Oct 2nd, 2006, 12:50pm
 
salamdaher wrote on Oct 1st, 2006, 6:07pm:
I tried that but I got the following error:
Type "PGraphicsOpenGL" was not found .

am I missing another import or something else

Thanks

-Salam


I think it depends on which version or processing your'e using, I may have got the new name wrong however, you can try PGraphicsGL instead of PGraphicsOpenGL, which might work.
Re: camera and 2D buttons
Reply #5 - Mar 2nd, 2009, 1:08am
 
Hi !
I need to put some 2D elements like buttons in a sketch where everything else is in 3D. I did like Salam, it works, however my texts (controlP5 labels and buttons, same for interfascia) are blurry. I don't understand why, any clue ?
Page Index Toggle Pages: 1