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 › how to - 2d overlay to dynamic 3d view
Page Index Toggle Pages: 1
how to - 2d overlay to dynamic 3d view (Read 2855 times)
how to - 2d overlay to dynamic 3d view
May 13th, 2010, 2:52am
 
Hi All

just started experimenting with 3d processing for a few things after a good while in the 2d world.

here's a link to a little sketch which uses the ocd libraries to set up a camera that explores a simple cube array (with 'solidity' expressed by the cubes). Camera control is via simple mouse movement; try it out and you'll soon learn it...

http://dl.dropbox.com/u/6460407/_00_SANDBOX.zip

what i'd like to do is have a simple 2d overlay to what is seen - ie an hud type display.

I've had a brief look through discourse but can't see a conclusive and simple way of doing this; does anyone have any thoughts/pointers

Many thanks
S



Re: how to - 2d overlay to dynamic 3d view
Reply #1 - May 13th, 2010, 3:52am
 
this is an example on how to use controlp5 with peasycam. but as far as i undertood it should also work for your purpose.
Give it a try and put whatever you want to draw where  controlP5.draw(); is atm.

http://code.google.com/p/controlp5/source/browse/trunk/examples/controlP5WithPea...
Re: how to - 2d overlay to dynamic 3d view
Reply #2 - May 13th, 2010, 12:01pm
 
Cedric,

fantastic, works like a charm. Much appreciated.

http://dl.dropbox.com/u/6460407/_00_SANDBOX.zip

^^revised code for anyone who wants to do this.

S
Re: how to - 2d overlay to dynamic 3d view
Reply #3 - May 14th, 2010, 1:50am
 
Ah, one quickie:

Currently this approach draws the 2d view 'below' the 3d - so when objects appear in perspective they block those seen in plan. see link...

http://dl.dropbox.com/u/6460407/_00_SANDBOX.zip

any thoughts on how to reverse this

S
Re: how to - 2d overlay to dynamic 3d view
Reply #4 - May 14th, 2010, 8:37am
 
for anyone watching; i did it

gui void becomes this:

Code:
void gui() {
camera();
javax.media.opengl.GL gl=((PGraphicsOpenGL)g).beginGL();
gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT);
gl.glDisable(javax.media.opengl.GL.GL_BLEND);
((PGraphicsOpenGL)g).endGL();
fill(0,0,0,255);
for (int i = 0; i < cubes.length; i++){
rect(cubes[i].keyX+50,cubes[i].keyY+50,10,10);
}
fill(255,0,0);
ellipse(viewerX+50,viewerZ+50,5,5);
}


Re: how to - 2d overlay to dynamic 3d view
Reply #5 - May 14th, 2010, 9:04am
 
damkjer library is missing ?
What library have to be dowloaded ?

Edit : OCD one ... ok.
Page Index Toggle Pages: 1