Normand Briere
2018-12-15 6ed65dcb597fb2153cef75bf1845978f1115658c
CameraPane.java
....@@ -7444,6 +7444,8 @@
74447444 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74457445 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74467446 double scale = lightCamera.SCALE / lightCamera.Distance();
7447
+// PATCH FILLE AUX JEANS
7448
+ //scale *= lightCamera.shaper_fovy / 25;
74477449 gl.glScaled(2 * scale, 2 * scale, -scale);
74487450 gl.glTranslated(0, 0, lightCamera.DECAL);
74497451
....@@ -7693,7 +7695,7 @@
76937695
76947696 if (renderCamera != lightCamera)
76957697 for (int count = parentcam.GetTransformCount(); --count>=0;)
7696
- LA.matConcat(parentcam.toParent, matrix, matrix);
7698
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76977699
76987700 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76997701
....@@ -7709,7 +7711,7 @@
77097711
77107712 if (renderCamera != lightCamera)
77117713 for (int count = parentcam.GetTransformCount(); --count>=0;)
7712
- LA.matConcat(matrix, parentcam.fromParent, matrix);
7714
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77137715
77147716 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77157717
....@@ -8915,7 +8917,7 @@
89158917 // if (parentcam != renderCamera) // not a light
89168918 if (cam != lightCamera)
89178919 for (int count = parentcam.GetTransformCount(); --count>=0;)
8918
- LA.matConcat(parentcam.toParent, matrix, matrix);
8920
+ LA.matConcat(matrix, parentcam.toParent, matrix);
89198921
89208922 for (int j = 0; j < 4; j++)
89218923 {
....@@ -8930,7 +8932,7 @@
89308932 // if (parentcam != renderCamera) // not a light
89318933 if (cam != lightCamera)
89328934 for (int count = parentcam.GetTransformCount(); --count>=0;)
8933
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8935
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
89348936
89358937 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
89368938
....@@ -9092,6 +9094,8 @@
90929094 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
90939095 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
90949096 double scale = lightCamera.SCALE / lightCamera.Distance();
9097
+// PATCH FILLE AUX JEANS
9098
+ //scale *= lightCamera.shaper_fovy / 25;
90959099 gl.glScaled(2 * scale, 2 * scale, -scale);
90969100 gl.glTranslated(0, 0, lightCamera.DECAL);
90979101
....@@ -9231,6 +9235,8 @@
92319235 {
92329236 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
92339237 double scale = lightCamera.SCALE / lightCamera.Distance();
9238
+// PATCH FILLE AUX JEANS
9239
+ //scale *= lightCamera.shaper_fovy / 25;
92349240 gl.glScaled(2 * scale, 2 * scale, -scale);
92359241 gl.glTranslated(0, 0, lightCamera.DECAL);
92369242 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9754,40 +9760,40 @@
97549760 selectedpoint.radius = radius;
97559761 selectedpoint.recalculate();
97569762 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.25f;
9763
+ selectedpoint.material.color = 0.15f; // Yellow
97589764 selectedpoint.material.modulation = 0.75f;
97599765
9760
- debugpoint.radius = radius;
9761
- debugpoint.recalculate();
9762
- debugpoint.material = new cMaterial();
9763
- debugpoint.material.color = 0.25f;
9764
- debugpoint.material.modulation = 0.75f;
9766
+ debugpointG.radius = radius;
9767
+ debugpointG.recalculate();
9768
+ debugpointG.material = new cMaterial();
9769
+ debugpointG.material.color = 0.25f; // Green
9770
+ debugpointG.material.modulation = 0.75f;
97659771
9766
- debugpoint2.radius = radius;
9767
- debugpoint2.recalculate();
9768
- debugpoint2.material = new cMaterial();
9769
- debugpoint2.material.color = 0.75f;
9770
- debugpoint2.material.modulation = 0.75f;
9772
+ debugpointP.radius = radius;
9773
+ debugpointP.recalculate();
9774
+ debugpointP.material = new cMaterial();
9775
+ debugpointP.material.color = 0.75f; // Purple
9776
+ debugpointP.material.modulation = 0.75f;
97719777
9772
- debugpoint3.radius = radius;
9773
- debugpoint3.recalculate();
9774
- debugpoint3.material = new cMaterial();
9775
- debugpoint3.material.color = 0.5f;
9776
- debugpoint3.material.modulation = 0.75f;
9778
+ debugpointC.radius = radius;
9779
+ debugpointC.recalculate();
9780
+ debugpointC.material = new cMaterial();
9781
+ debugpointC.material.color = 0.5f; // Cyan
9782
+ debugpointC.material.modulation = 0.75f;
97779783
9778
- debugpoint4.radius = radius;
9779
- debugpoint4.recalculate();
9780
- debugpoint4.material = new cMaterial();
9781
- debugpoint4.material.color = 0f;
9782
- debugpoint4.material.modulation = 0.75f;
9784
+ debugpointR.radius = radius;
9785
+ debugpointR.recalculate();
9786
+ debugpointR.material = new cMaterial();
9787
+ debugpointR.material.color = 0f; // Red
9788
+ debugpointR.material.modulation = 0.75f;
97839789
97849790 InitPoints(radius);
97859791 }
97869792 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9787
- debugpoint.draw(this, /*(Composite)*/ null, false,false);
9788
- debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9789
- debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9790
- debugpoint4.draw(this, /*(Composite)*/ null, false,false);
9793
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
9794
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
9795
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
9796
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
97919797 // DrawPoints(this);
97929798 }
97939799
....@@ -9825,12 +9831,14 @@
98259831
98269832 if (checker != null && drawMode == DEFAULT)
98279833 {
9828
- // BindTexture(IMMORTAL_TEXTURE);
9834
+ //BindTexture(IMMORTAL_TEXTURE);
9835
+ BindTextures(checker.GetTextures(), checker.texres);
98299836 // NEAREST
98309837 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
98319838 DrawChecker(gl);
98329839 //checker.Draw(this, null, false);
98339840 // ReleaseTexture(IMMORTAL_TEXTURE);
9841
+ ReleaseTextures(checker.GetTextures());
98349842 }
98359843
98369844 if (object.parent != null)
....@@ -10388,6 +10396,7 @@
1038810396 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038910397 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1039010398 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
10399
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1039110400 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1039210401 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1039310402 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -11302,6 +11311,7 @@
1130211311 String Shadow(String depth, String shadow)
1130311312 {
1130411313 return "MAX temp.x, ndotl.x, one64th.x;" +
11314
+ "MIN temp.x, temp.x, ninetenth.x;" +
1130511315 /**/
1130611316 // Sine
1130711317 "MUL temp.y, temp.x, temp.x;" +
....@@ -14438,7 +14448,7 @@
1443814448 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1443914449 gl.glPushMatrix();
1444014450 gl.glLoadIdentity();
14441
- PushMatrix(checker.toParent);
14451
+ //PushMatrix(checker.toParent);
1444214452
1444314453 gl.glMatrixMode(GL.GL_TEXTURE);
1444414454 gl.glPushMatrix();
....@@ -14461,8 +14471,8 @@
1446114471
1446214472 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1446314473
14464
- float step = 0.1666f; //0.25f;
14465
- float stepv = step * 1652 / 998;
14474
+ float step = 2; // 0.1666f; //0.25f;
14475
+ float stepv = 2; // step * 1652 / 998;
1446614476
1446714477 int i0 = 0;
1446814478 /*
....@@ -14532,15 +14542,27 @@
1453214542
1453314543 //float u = (i+1)/2;
1453414544 //float v = (j+1)/2;
14535
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
14545
+ if (checker.flipV)
14546
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
14547
+ else
14548
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1453614549 gl.glVertex3f(i, j, -0.5f);
1453714550
14551
+ if (checker.flipV)
14552
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
14553
+ else
1453814554 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1453914555 gl.glVertex3f(i + step, j, -0.5f);
1454014556
14557
+ if (checker.flipV)
14558
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
14559
+ else
1454114560 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1454214561 gl.glVertex3f(i + step, j + stepv, -0.5f);
1454314562
14563
+ if (checker.flipV)
14564
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
14565
+ else
1454414566 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1454514567 gl.glVertex3f(i, j + stepv, -0.5f);
1454614568 }
....@@ -14552,7 +14574,7 @@
1455214574 gl.glMatrixMode(GL.GL_PROJECTION);
1455314575 gl.glPopMatrix();
1455414576 gl.glMatrixMode(GL.GL_MODELVIEW);
14555
- PopMatrix(null); // checker.toParent); // null);
14577
+ //PopMatrix(null); // checker.toParent); // null);
1455614578 gl.glPopMatrix();
1455714579 PopTextureMatrix(checker.toParent);
1455814580 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -15115,13 +15137,19 @@
1511515137 gl.glFlush();
1511615138
1511715139 /**/
15118
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
15140
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1511915141
15120
- int[] pixels = occlusionsizebuffer.array();
15142
+ float[] pixels = occlusionsizebuffer.array();
1512115143
1512215144 double r = 0, g = 0, b = 0;
1512315145
1512415146 double count = 0;
15147
+
15148
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
15149
+
15150
+ float mindepth = 1;
15151
+
15152
+ double FACTOR = 1;
1512515153
1512615154 for (int i = 0; i < pixels.length; i++)
1512715155 {
....@@ -15206,7 +15234,7 @@
1520615234
1520715235 double scale = ray.z; // 1; // cos
1520815236
15209
- int p = pixels[newindex];
15237
+ float depth = pixels[newindex];
1521015238
1521115239 /*
1521215240 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15230,10 +15258,23 @@
1523015258 scale = (1 - modu) * modv;
1523115259 */
1523215260
15233
- r += ((p >> 16) & 0xFF) * scale / 255;
15234
- g += ((p >> 8) & 0xFF) * scale / 255;
15235
- b += (p & 0xFF) * scale / 255;
15261
+ //r += ((p >> 16) & 0xFF) * scale / 255;
15262
+ //g += ((p >> 8) & 0xFF) * scale / 255;
15263
+ //b += (p & 0xFF) * scale / 255;
15264
+
15265
+ if (mindepth > depth)
15266
+ {
15267
+ mindepth = depth;
15268
+ }
1523615269
15270
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
15271
+
15272
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
15273
+
15274
+ r += factor * scale;
15275
+ g += factor * scale;
15276
+ b += factor * scale;
15277
+
1523715278 count += scale;
1523815279 }
1523915280
....@@ -15351,10 +15392,10 @@
1535115392 //double[] selectedpoint = new double[3];
1535215393 static Superellipsoid selectedpoint = new Superellipsoid();
1535315394 static Sphere previousselectedpoint = null;
15354
- static Sphere debugpoint = new Sphere();
15355
- static Sphere debugpoint2 = new Sphere();
15356
- static Sphere debugpoint3 = new Sphere();
15357
- static Sphere debugpoint4 = new Sphere();
15395
+ static Sphere debugpointG = new Sphere();
15396
+ static Sphere debugpointP = new Sphere();
15397
+ static Sphere debugpointC = new Sphere();
15398
+ static Sphere debugpointR = new Sphere();
1535815399
1535915400 static Sphere debugpoints[] = new Sphere[8];
1536015401
....@@ -15407,7 +15448,8 @@
1540715448 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1540815449 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1540915450 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15410
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
15451
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
15452
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1541115453 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1541215454 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1541315455 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();