Draw 2D on top in VR mode


#1

There is the eye function for the VR mode:

https://android.processing.org/reference/vr/eye.html

here an example from the reference:

import processing.vr.*;

void setup() {
  fullScreen(STEREO);
}

void draw() {
   // draw scene...

   pushMatrix();
   eye();
   translate(0, 0, 100);
   ellipse(0, 0, 50, 50);
   popMatrix();
}

As you can see after the eye() call it is followed with a translate in the z direction.
For me to get the 0,0 coordinate in the left top corner I have to do something like:

translate(-width/2, -height/2, 1350);

But the 1350 is just guessing and will probably fail on larger or smaller screens or screen with a different aspect ratio.

Is there a proper way to go into ‘2D’?


#2

You can use hint(DISABLE_DEPTH_TEST) to write on the screen and ENABLE_DEPTH_TEST to change back again.


#3

It ain’t about that. It’s about the position of the camera and the shape of the frustum.
And that the motion doesn’t effect where it is displayed.

A bit like how you can normally use camera() to get to the default position.


#4

What I tried now is:

void begin_2d() {

  pushMatrix();

  resetMatrix();

  // TODO figure out how this is defined

  applyMatrix(
    001.0000, 000.0000, 000.0000, -960.0000, 
    000.0000, 001.0000, 000.0000, -540.0000, 
    000.0000, 000.0000, 001.0000, -935.3074, 
    000.0000, 000.0000, 000.0000, 001.0000
    );

  noLights();
}

void end_2d() {
  popMatrix();
}

I got the coordinates from using a regular app first and checked that matrix.
Although it looks close it is still incorrect.
If someone could still help with the issue that would be really great.


#5

Ok, getting closer:


void begin_2d() {
  hint(DISABLE_DEPTH_TEST);
  pushMatrix();
  resetMatrix();
  ortho(0, width, -height, 0, -Float.MAX_VALUE, Float.MAX_VALUE);
}


void end_2d() {
  popMatrix();  
}

Only DISABLE_DEPTH_TEST doesn’t seem to work.