@@ -54,7 +54,9 @@ protected PGL createPGL(PGraphicsOpenGL pg) {
5454 public void beginDraw () {
5555 super .beginDraw ();
5656 pgl .viewport (viewPort .x , viewPort .y , viewPort .width , viewPort .height );
57- camera (0.0f , 0.0f , cameraZ , 0.0f , 0.0f , 0.0f , 0.0f , 1.0f , 0.0f );
57+ // The camera up direction is along -Y, because of the axis inversion
58+ // in Processing
59+ camera (0.0f , 0.0f , defCameraZ , 0.0f , 0.0f , 0.0f , 0.0f , -1.0f , 0.0f );
5860 setProjection (perspectiveMatrix );
5961 preApplyMatrix (viewMatrix );
6062 }
@@ -71,7 +73,7 @@ public void preApplyMatrix(PMatrix3D source) {
7173 protected void headTransform (HeadTransform headTransform ) {
7274 initVR ();
7375
74- // Get the head view and rotation so the user can use them for object selecton and
76+ // Get the head view and rotation so the user can use them for object selection and
7577 // other operations.
7678 headTransform .getHeadView (headView , 0 );
7779 headTransform .getQuaternion (headRotation , 0 );
@@ -83,11 +85,12 @@ protected void eyeTransform(Eye eye) {
8385 viewPort = eye .getViewport ();
8486
8587 // Matrices in Processing are row-major, and GVR API is column-major
88+ // Also, need to invert Y coordinate, that's why the minus in front of p[5]
8689 float [] p = eye .getPerspective (cameraNear , cameraFar );
87- perspectiveMatrix .set (p [0 ], p [4 ], p [8 ], p [12 ],
88- p [1 ], p [5 ], p [9 ], p [13 ],
89- p [2 ], p [6 ], p [10 ], p [14 ],
90- p [3 ], p [7 ], p [11 ], p [15 ]);
90+ perspectiveMatrix .set (p [0 ], p [4 ], p [8 ], p [12 ],
91+ p [1 ], - p [5 ], p [9 ], p [13 ],
92+ p [2 ], p [6 ], p [10 ], p [14 ],
93+ p [3 ], p [7 ], p [11 ], p [15 ]);
9194
9295 float [] v = eye .getEyeView ();
9396 viewMatrix .set (v [0 ], v [4 ], v [8 ], v [12 ],
0 commit comments