.. | .. |
---|
7444 | 7444 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
7445 | 7445 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
7446 | 7446 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 7447 | +// PATCH FILLE AUX JEANS |
---|
| 7448 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
7447 | 7449 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
7448 | 7450 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
7449 | 7451 | |
---|
.. | .. |
---|
7693 | 7695 | |
---|
7694 | 7696 | if (renderCamera != lightCamera) |
---|
7695 | 7697 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7696 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 7698 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7697 | 7699 | |
---|
7698 | 7700 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7699 | 7701 | |
---|
.. | .. |
---|
7709 | 7711 | |
---|
7710 | 7712 | if (renderCamera != lightCamera) |
---|
7711 | 7713 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7712 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 7714 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7713 | 7715 | |
---|
7714 | 7716 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7715 | 7717 | |
---|
.. | .. |
---|
8915 | 8917 | // if (parentcam != renderCamera) // not a light |
---|
8916 | 8918 | if (cam != lightCamera) |
---|
8917 | 8919 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8918 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 8920 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8919 | 8921 | |
---|
8920 | 8922 | for (int j = 0; j < 4; j++) |
---|
8921 | 8923 | { |
---|
.. | .. |
---|
8930 | 8932 | // if (parentcam != renderCamera) // not a light |
---|
8931 | 8933 | if (cam != lightCamera) |
---|
8932 | 8934 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8933 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 8935 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8934 | 8936 | |
---|
8935 | 8937 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8936 | 8938 | |
---|
.. | .. |
---|
9092 | 9094 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
---|
9093 | 9095 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9094 | 9096 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9097 | +// PATCH FILLE AUX JEANS |
---|
| 9098 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9095 | 9099 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9096 | 9100 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9097 | 9101 | |
---|
.. | .. |
---|
9231 | 9235 | { |
---|
9232 | 9236 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
---|
9233 | 9237 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
---|
| 9238 | +// PATCH FILLE AUX JEANS |
---|
| 9239 | + //scale *= lightCamera.shaper_fovy / 25; |
---|
9234 | 9240 | gl.glScaled(2 * scale, 2 * scale, -scale); |
---|
9235 | 9241 | gl.glTranslated(0, 0, lightCamera.DECAL); |
---|
9236 | 9242 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
---|
.. | .. |
---|
9754 | 9760 | selectedpoint.radius = radius; |
---|
9755 | 9761 | selectedpoint.recalculate(); |
---|
9756 | 9762 | selectedpoint.material = new cMaterial(); |
---|
9757 | | - selectedpoint.material.color = 0.25f; |
---|
| 9763 | + selectedpoint.material.color = 0.15f; // Yellow |
---|
9758 | 9764 | selectedpoint.material.modulation = 0.75f; |
---|
9759 | 9765 | |
---|
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; |
---|
9765 | 9771 | |
---|
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; |
---|
9771 | 9777 | |
---|
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; |
---|
9777 | 9783 | |
---|
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; |
---|
9783 | 9789 | |
---|
9784 | 9790 | InitPoints(radius); |
---|
9785 | 9791 | } |
---|
9786 | 9792 | 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); |
---|
9791 | 9797 | // DrawPoints(this); |
---|
9792 | 9798 | } |
---|
9793 | 9799 | |
---|
.. | .. |
---|
9825 | 9831 | |
---|
9826 | 9832 | if (checker != null && drawMode == DEFAULT) |
---|
9827 | 9833 | { |
---|
9828 | | - // BindTexture(IMMORTAL_TEXTURE); |
---|
| 9834 | + //BindTexture(IMMORTAL_TEXTURE); |
---|
| 9835 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
9829 | 9836 | // NEAREST |
---|
9830 | 9837 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
9831 | 9838 | DrawChecker(gl); |
---|
9832 | 9839 | //checker.Draw(this, null, false); |
---|
9833 | 9840 | // ReleaseTexture(IMMORTAL_TEXTURE); |
---|
| 9841 | + ReleaseTextures(checker.GetTextures()); |
---|
9834 | 9842 | } |
---|
9835 | 9843 | |
---|
9836 | 9844 | if (object.parent != null) |
---|
.. | .. |
---|
10388 | 10396 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
---|
10389 | 10397 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
10390 | 10398 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
---|
| 10399 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
---|
10391 | 10400 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
---|
10392 | 10401 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
---|
10393 | 10402 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
---|
.. | .. |
---|
11302 | 11311 | String Shadow(String depth, String shadow) |
---|
11303 | 11312 | { |
---|
11304 | 11313 | return "MAX temp.x, ndotl.x, one64th.x;" + |
---|
| 11314 | + "MIN temp.x, temp.x, ninetenth.x;" + |
---|
11305 | 11315 | /**/ |
---|
11306 | 11316 | // Sine |
---|
11307 | 11317 | "MUL temp.y, temp.x, temp.x;" + |
---|
.. | .. |
---|
12854 | 12864 | { |
---|
12855 | 12865 | mouseMode |= ZOOM; |
---|
12856 | 12866 | } |
---|
12857 | | - if ((modifiers & META) == META) |
---|
| 12867 | + |
---|
| 12868 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 12869 | + if (capsLocked || (modifiers & META) == META) |
---|
12858 | 12870 | { |
---|
12859 | 12871 | mouseMode |= VR; // BACKFORTH; |
---|
12860 | 12872 | } |
---|
.. | .. |
---|
12868 | 12880 | } |
---|
12869 | 12881 | if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
12870 | 12882 | { |
---|
| 12883 | + mouseMode &= ~VR; |
---|
12871 | 12884 | mouseMode |= TRANSLATE; |
---|
12872 | 12885 | } |
---|
12873 | 12886 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
14435 | 14448 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
---|
14436 | 14449 | gl.glPushMatrix(); |
---|
14437 | 14450 | gl.glLoadIdentity(); |
---|
14438 | | - PushMatrix(checker.toParent); |
---|
| 14451 | + //PushMatrix(checker.toParent); |
---|
14439 | 14452 | |
---|
14440 | 14453 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
14441 | 14454 | gl.glPushMatrix(); |
---|
.. | .. |
---|
14458 | 14471 | |
---|
14459 | 14472 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
14460 | 14473 | |
---|
14461 | | - float step = 0.1666f; //0.25f; |
---|
14462 | | - float stepv = step * 1652 / 998; |
---|
| 14474 | + float step = 2; // 0.1666f; //0.25f; |
---|
| 14475 | + float stepv = 2; // step * 1652 / 998; |
---|
14463 | 14476 | |
---|
14464 | 14477 | int i0 = 0; |
---|
14465 | 14478 | /* |
---|
.. | .. |
---|
14529 | 14542 | |
---|
14530 | 14543 | //float u = (i+1)/2; |
---|
14531 | 14544 | //float v = (j+1)/2; |
---|
14532 | | - 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); |
---|
14533 | 14549 | gl.glVertex3f(i, j, -0.5f); |
---|
14534 | 14550 | |
---|
| 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 |
---|
14535 | 14554 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
---|
14536 | 14555 | gl.glVertex3f(i + step, j, -0.5f); |
---|
14537 | 14556 | |
---|
| 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 |
---|
14538 | 14560 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
---|
14539 | 14561 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
---|
14540 | 14562 | |
---|
| 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 |
---|
14541 | 14566 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
---|
14542 | 14567 | gl.glVertex3f(i, j + stepv, -0.5f); |
---|
14543 | 14568 | } |
---|
.. | .. |
---|
14549 | 14574 | gl.glMatrixMode(GL.GL_PROJECTION); |
---|
14550 | 14575 | gl.glPopMatrix(); |
---|
14551 | 14576 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
14552 | | - PopMatrix(null); // checker.toParent); // null); |
---|
| 14577 | + //PopMatrix(null); // checker.toParent); // null); |
---|
14553 | 14578 | gl.glPopMatrix(); |
---|
14554 | 14579 | PopTextureMatrix(checker.toParent); |
---|
14555 | 14580 | gl.glMatrixMode(GL.GL_TEXTURE); |
---|
.. | .. |
---|
14718 | 14743 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
14719 | 14744 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14720 | 14745 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 14746 | + |
---|
| 14747 | + // Will fit the mesh !!! |
---|
| 14748 | + selectedpoint.toParent[0][0] = 0.0001; |
---|
| 14749 | + selectedpoint.toParent[1][1] = 0.0001; |
---|
| 14750 | + selectedpoint.toParent[2][2] = 0.0001; |
---|
14721 | 14751 | |
---|
14722 | 14752 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14723 | 14753 | |
---|
.. | .. |
---|
15107 | 15137 | gl.glFlush(); |
---|
15108 | 15138 | |
---|
15109 | 15139 | /**/ |
---|
15110 | | - 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); |
---|
15111 | 15141 | |
---|
15112 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 15142 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15113 | 15143 | |
---|
15114 | 15144 | double r = 0, g = 0, b = 0; |
---|
15115 | 15145 | |
---|
15116 | 15146 | double count = 0; |
---|
| 15147 | + |
---|
| 15148 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 15149 | + |
---|
| 15150 | + float mindepth = 1; |
---|
| 15151 | + |
---|
| 15152 | + double FACTOR = 1; |
---|
15117 | 15153 | |
---|
15118 | 15154 | for (int i = 0; i < pixels.length; i++) |
---|
15119 | 15155 | { |
---|
.. | .. |
---|
15198 | 15234 | |
---|
15199 | 15235 | double scale = ray.z; // 1; // cos |
---|
15200 | 15236 | |
---|
15201 | | - int p = pixels[newindex]; |
---|
| 15237 | + float depth = pixels[newindex]; |
---|
15202 | 15238 | |
---|
15203 | 15239 | /* |
---|
15204 | 15240 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15222 | 15258 | scale = (1 - modu) * modv; |
---|
15223 | 15259 | */ |
---|
15224 | 15260 | |
---|
15225 | | - r += ((p >> 16) & 0xFF) * scale / 255; |
---|
15226 | | - g += ((p >> 8) & 0xFF) * scale / 255; |
---|
15227 | | - 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 | + } |
---|
15228 | 15269 | |
---|
| 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 | + |
---|
15229 | 15278 | count += scale; |
---|
15230 | 15279 | } |
---|
15231 | 15280 | |
---|
.. | .. |
---|
15341 | 15390 | int AAbuffersize = 0; |
---|
15342 | 15391 | |
---|
15343 | 15392 | //double[] selectedpoint = new double[3]; |
---|
15344 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 15393 | + static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15345 | 15394 | static Sphere previousselectedpoint = null; |
---|
15346 | | - static Sphere debugpoint = new Sphere(); |
---|
15347 | | - static Sphere debugpoint2 = new Sphere(); |
---|
15348 | | - static Sphere debugpoint3 = new Sphere(); |
---|
15349 | | - 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(); |
---|
15350 | 15399 | |
---|
15351 | 15400 | static Sphere debugpoints[] = new Sphere[8]; |
---|
15352 | 15401 | |
---|
.. | .. |
---|
15399 | 15448 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15400 | 15449 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15401 | 15450 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15402 | | - 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); |
---|
15403 | 15453 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15404 | 15454 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15405 | 15455 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|