@@ -54,7 +54,9 @@ protected PGL createPGL(PGraphicsOpenGL pg) {
54
54
public void beginDraw () {
55
55
super .beginDraw ();
56
56
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 );
58
60
setProjection (perspectiveMatrix );
59
61
preApplyMatrix (viewMatrix );
60
62
}
@@ -71,7 +73,7 @@ public void preApplyMatrix(PMatrix3D source) {
71
73
protected void headTransform (HeadTransform headTransform ) {
72
74
initVR ();
73
75
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
75
77
// other operations.
76
78
headTransform .getHeadView (headView , 0 );
77
79
headTransform .getQuaternion (headRotation , 0 );
@@ -83,11 +85,12 @@ protected void eyeTransform(Eye eye) {
83
85
viewPort = eye .getViewport ();
84
86
85
87
// 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]
86
89
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 ]);
91
94
92
95
float [] v = eye .getEyeView ();
93
96
viewMatrix .set (v [0 ], v [4 ], v [8 ], v [12 ],
0 commit comments