Loading...
Logo
Processing Forum

make a gui in P3D

in Programming Questions  •  3 months ago  
hi guys
im doing a 3d project, and if i use size(100,800,P3D); i can use 2d shapes to make a gui
example:
if i right:

rect(0,0,500,500);

---------------------------------------------
the image will apear in a p3d refenrencial

how can i make this apear in sreen coordinates

thks
:D
sry for the bad english.

Replies(3)

Re: make a gui in P3D

3 months ago
Do not double post. A double post is when you post the exact same question in multiple threads. This is the second time you do this. Don't do this anymore.

To answer your question: search the forum, this has been answered many times before.

Re: make a gui in P3D

3 months ago

yes, one way:

see bold below

Copy code
  1. void setup() {
  2.   size(600, 500, P3D);
  3. }

  4. void draw() {
  5.   //
  6.   background(0);
  7.   lights();
  8.   //
  9.   pushMatrix();
  10.   translate(width/2, height/2);
  11.   rotateX(millis() / 1000f);
  12.   rotateY(millis() / 800f);
  13.   rotateZ(millis() / 700f);
  14.   lights();
  15.   stroke(111);
  16.   fill(222);
  17.   box(100);
  18.   popMatrix();
  19.   //
  20.   // now text
  21.   camera(); //resets viewport to 2D equivalent
  22.   noLights();
  23.   stroke(255);
  24.   noFill();
  25.   rect(85, 85, 40, 25);
  26.   fill(255);
  27.   text("hi", 100, 100);
  28. }
  29. //
  30. void mousePressed() {
  31.   if ( mouseInside(85, 85, 40, 25) ) {
  32.     println ("hit");
  33.   }
  34. }
  35. //
  36. boolean mouseInside(float x, float y, float w, float h) {
  37.   return (mouseX>=x&&mouseY>=y &&
  38.     mouseX<=x+w && mouseY<=y+h );
  39. }
  40. //