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 & HelpPrograms › 2D interface in a 3D world.
Page Index Toggle Pages: 1
2D interface in a 3D world. (Read 897 times)
2D interface in a 3D world.
Nov 30th, 2009, 12:44pm
 
The question is simple, the answer my be not.

I need to display 2D graphics in a 3D environment....
like in a game, 2D menus over a 3D world.

any ideas? thanks in advanced.

sorry for any sintaxe errors, english is not my native language.


********************

i don't really need you guys to do something from scratch, just an idea of the best aproach, i know my ways around processing, i thought about making a class that calculates the 2D position of the window and display stuff there like an invisible frame... but, it terrifies me thinking about get all that horrible math needed to do it.
Re: 2D interface in a 3D world.
Reply #1 - Nov 30th, 2009, 2:09pm
 
There are 2 ways of doing this

Method 1
Code:


PMatrix3D baseMat;

void setup(){
 size(400,400, P3D); // or OPENGL
 
 // Remember the start model view matrix values
 baseMat = getMatrix(baseMat);
}

void draw(){
 background(40);
 pushMatrix();
 camera(0, 0, 400, 0, 0, 0, 0, 1, 0);
 directionalLight(255, 255, 255, -100, 150, -100);
 ambientLight(40, 40, 40);

 // 3D drawing stuff here

 popMatrix();

 // Restore the base matrix and lighting ready for 2D
 this.setMatrix(baseMat);
 ambientLight(255,255,255);

 // draw 2D stuff here


}


Method 2
Since you want various 2D components then use one of the GUI libraries
http://processing.org/reference/libraries/#interface

You might try G4P you can see examples of this library working at
http://www.lagers.org.uk/g4p/applets/g4p_showcase/index.html

This library will probably do what you want, but then I am biased towards it.

Re: 2D interface in a 3D world.
Reply #2 - Nov 30th, 2009, 2:15pm
 
thanks a lot Quark.
i'll try those solutions and see which one meets  my needs.
i'll try not to forget to send feed back.

cheers
Re: 2D interface in a 3D world.
Reply #3 - Nov 30th, 2009, 9:10pm
 
If you use the great peasyCam http://mrfeinberg.com/peasycam/ there is a special command for that

/ Utility methods to permit the use of a Heads-Up Display
// Thanks, A.W. Martin
camera.beginHUD();
// now draw things that you want relative to the camera's position and orientation
camera.endHUD(); // always!
Re: 2D interface in a 3D world.
Reply #4 - Dec 1st, 2009, 2:53pm
 
peasycam looks great, thanks a lot Cedric.
Page Index Toggle Pages: 1