@@ -341,6 +341,18 @@ public void dispose() {
341
341
/** Projection matrix stack **/
342
342
protected float [][] projectionStack = new float [MATRIX_STACK_DEPTH ][16 ];
343
343
344
+
345
+ /** Matrix that transform coordinates to the eye coordinate system **/
346
+ protected PMatrix3D eyeMatrix ;
347
+
348
+ /** Matrix that transform coordinates to the system that results from appling the modelview transformation **/
349
+ protected PMatrix3D objMatrix ;
350
+
351
+ /** Vectors defining the eye axes **/
352
+ public float forwardX , forwardY , forwardZ ;
353
+ public float rightX , rightY , rightZ ;
354
+ public float upX , upY , upZ ;
355
+
344
356
// ........................................................
345
357
346
358
// Lights:
@@ -520,14 +532,8 @@ public void dispose() {
520
532
521
533
// ........................................................
522
534
523
- protected PMatrix3D eyeMatrix ;
524
- protected PMatrix3D objMatrix ;
535
+ // Variables used in ray casting:
525
536
526
- public float forwardX , forwardY , forwardZ ;
527
- public float rightX , rightY , rightZ ;
528
- public float upX , upY , upZ ;
529
-
530
- // Variables used in ray casting
531
537
protected PVector [] ray ;
532
538
protected PVector hit = new PVector ();
533
539
protected PVector screen = new PVector ();
@@ -4869,33 +4875,33 @@ public void camera(float eyeX, float eyeY, float eyeZ,
4869
4875
z2 /= eyeDist ;
4870
4876
}
4871
4877
4878
+ forwardX = z0 ;
4879
+ forwardY = z1 ;
4880
+ forwardZ = z2 ;
4881
+
4872
4882
// Calculating Y vector
4873
4883
float y0 = upX ;
4874
4884
float y1 = upY ;
4875
4885
float y2 = upZ ;
4876
4886
4887
+ this .upX = upX ;
4888
+ this .upY = upY ;
4889
+ this .upZ = upZ ;
4890
+
4877
4891
// Computing X vector as Y cross Z
4878
4892
float x0 = y1 * z2 - y2 * z1 ;
4879
4893
float x1 = -y0 * z2 + y2 * z0 ;
4880
4894
float x2 = y0 * z1 - y1 * z0 ;
4881
4895
4896
+ rightX = x0 ;
4897
+ rightY = x1 ;
4898
+ rightZ = x2 ;
4899
+
4882
4900
// Recompute Y = Z cross X
4883
4901
y0 = z1 * x2 - z2 * x1 ;
4884
4902
y1 = -z0 * x2 + z2 * x0 ;
4885
4903
y2 = z0 * x1 - z1 * x0 ;
4886
4904
4887
- forwardX = 0 ;
4888
- forwardY = 0 ;
4889
- forwardZ = 1 ;
4890
-
4891
- rightX = 1 ;
4892
- rightY = 0 ;
4893
- rightZ = 0 ;
4894
-
4895
- this .upX = 0 ;
4896
- this .upY = -1 ;
4897
- this .upZ = 0 ;
4898
-
4899
4905
// Cross product gives area of parallelogram, which is < 1.0 for
4900
4906
// non-perpendicular unit-length vectors; so normalize x, y here:
4901
4907
float xmag = PApplet .sqrt (x0 * x0 + x1 * x1 + x2 * x2 );
0 commit comments