resetMatrix() has unexpected result in P3D (or, how to display "HUD" text?)

I was trying to draw some text inside a pushMattrix/popMatrix by using resetMatrix, it works well in 2D but not in P3D, any pointers to what I’m doing wrong?

size(500, 500)   # then try size(500, 500, P3D)  
textSize(40)
translate(250, 250)
rotate(QUARTER_PI)
pushMatrix()
resetMatrix()      # then use camera() instead!
text("Hello", 250, 250)
popMatrix()
text("Hello", 0, 0)

UPDATE: As per the link sent by @Chrisir, using camera() instead of resetMatrix() worked!

check #9

here 25 life-saving tips for Processing | Amnon P5 - Experiments with Processing by Amnon Owed

keywords: 2D 3D Head-up display HUD

4 Likes

Thanks! I guess adding camera() was what I was missing!

1 Like

Additionally

1

apart from that: in 3D it’s always nice to us lights(); - use noLights(); for the HUD

2

and avoid clipping

void avoidClipping() {
  // avoid clipping (at camera): 
  // https : // 
  // forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
  perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func 
//
1 Like