Normand Briere
2018-10-27 d34fd9341c61d13677e029cb187d4dacff5e44ea
CameraPane.java
....@@ -7693,7 +7693,7 @@
76937693
76947694 if (renderCamera != lightCamera)
76957695 for (int count = parentcam.GetTransformCount(); --count>=0;)
7696
- LA.matConcat(parentcam.toParent, matrix, matrix);
7696
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76977697
76987698 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76997699
....@@ -7709,7 +7709,7 @@
77097709
77107710 if (renderCamera != lightCamera)
77117711 for (int count = parentcam.GetTransformCount(); --count>=0;)
7712
- LA.matConcat(matrix, parentcam.fromParent, matrix);
7712
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77137713
77147714 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77157715
....@@ -8915,7 +8915,7 @@
89158915 // if (parentcam != renderCamera) // not a light
89168916 if (cam != lightCamera)
89178917 for (int count = parentcam.GetTransformCount(); --count>=0;)
8918
- LA.matConcat(parentcam.toParent, matrix, matrix);
8918
+ LA.matConcat(matrix, parentcam.toParent, matrix);
89198919
89208920 for (int j = 0; j < 4; j++)
89218921 {
....@@ -8930,7 +8930,7 @@
89308930 // if (parentcam != renderCamera) // not a light
89318931 if (cam != lightCamera)
89328932 for (int count = parentcam.GetTransformCount(); --count>=0;)
8933
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8933
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
89348934
89358935 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
89368936
....@@ -9754,7 +9754,7 @@
97549754 selectedpoint.radius = radius;
97559755 selectedpoint.recalculate();
97569756 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.25f;
9757
+ selectedpoint.material.color = 0.15f;
97589758 selectedpoint.material.modulation = 0.75f;
97599759
97609760 debugpoint.radius = radius;
....@@ -12854,7 +12854,9 @@
1285412854 {
1285512855 mouseMode |= ZOOM;
1285612856 }
12857
- if ((modifiers & META) == META)
12857
+
12858
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
12859
+ if (capsLocked || (modifiers & META) == META)
1285812860 {
1285912861 mouseMode |= VR; // BACKFORTH;
1286012862 }
....@@ -12868,6 +12870,7 @@
1286812870 }
1286912871 if ((modifiers & SHIFT) == SHIFT || forcetranslate)
1287012872 {
12873
+ mouseMode &= ~VR;
1287112874 mouseMode |= TRANSLATE;
1287212875 }
1287312876 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -14719,6 +14722,11 @@
1471914722 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1472014723 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1472114724
14725
+ // Will fit the mesh !!!
14726
+ selectedpoint.toParent[0][0] = 0.0001;
14727
+ selectedpoint.toParent[1][1] = 0.0001;
14728
+ selectedpoint.toParent[2][2] = 0.0001;
14729
+
1472214730 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1472314731
1472414732 // if (object.selection != null && object.selection.Size() > 0)
....@@ -15107,13 +15115,19 @@
1510715115 gl.glFlush();
1510815116
1510915117 /**/
15110
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
15118
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1511115119
15112
- int[] pixels = occlusionsizebuffer.array();
15120
+ float[] pixels = occlusionsizebuffer.array();
1511315121
1511415122 double r = 0, g = 0, b = 0;
1511515123
1511615124 double count = 0;
15125
+
15126
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
15127
+
15128
+ float mindepth = 1;
15129
+
15130
+ double FACTOR = 1;
1511715131
1511815132 for (int i = 0; i < pixels.length; i++)
1511915133 {
....@@ -15198,7 +15212,7 @@
1519815212
1519915213 double scale = ray.z; // 1; // cos
1520015214
15201
- int p = pixels[newindex];
15215
+ float depth = pixels[newindex];
1520215216
1520315217 /*
1520415218 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15222,10 +15236,23 @@
1522215236 scale = (1 - modu) * modv;
1522315237 */
1522415238
15225
- r += ((p >> 16) & 0xFF) * scale / 255;
15226
- g += ((p >> 8) & 0xFF) * scale / 255;
15227
- b += (p & 0xFF) * scale / 255;
15239
+ //r += ((p >> 16) & 0xFF) * scale / 255;
15240
+ //g += ((p >> 8) & 0xFF) * scale / 255;
15241
+ //b += (p & 0xFF) * scale / 255;
15242
+
15243
+ if (mindepth > depth)
15244
+ {
15245
+ mindepth = depth;
15246
+ }
1522815247
15248
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
15249
+
15250
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
15251
+
15252
+ r += factor * scale;
15253
+ g += factor * scale;
15254
+ b += factor * scale;
15255
+
1522915256 count += scale;
1523015257 }
1523115258
....@@ -15341,7 +15368,7 @@
1534115368 int AAbuffersize = 0;
1534215369
1534315370 //double[] selectedpoint = new double[3];
15344
- static Sphere selectedpoint = new Sphere();
15371
+ static Superellipsoid selectedpoint = new Superellipsoid();
1534515372 static Sphere previousselectedpoint = null;
1534615373 static Sphere debugpoint = new Sphere();
1534715374 static Sphere debugpoint2 = new Sphere();
....@@ -15399,7 +15426,8 @@
1539915426 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1540015427 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1540115428 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15402
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
15429
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
15430
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1540315431 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1540415432 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1540515433 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();