.. | .. |
---|
7693 | 7693 | |
---|
7694 | 7694 | if (renderCamera != lightCamera) |
---|
7695 | 7695 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7696 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 7696 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
7697 | 7697 | |
---|
7698 | 7698 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
7699 | 7699 | |
---|
.. | .. |
---|
7709 | 7709 | |
---|
7710 | 7710 | if (renderCamera != lightCamera) |
---|
7711 | 7711 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
7712 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 7712 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
7713 | 7713 | |
---|
7714 | 7714 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
7715 | 7715 | |
---|
.. | .. |
---|
8915 | 8915 | // if (parentcam != renderCamera) // not a light |
---|
8916 | 8916 | if (cam != lightCamera) |
---|
8917 | 8917 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8918 | | - LA.matConcat(parentcam.toParent, matrix, matrix); |
---|
| 8918 | + LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
8919 | 8919 | |
---|
8920 | 8920 | for (int j = 0; j < 4; j++) |
---|
8921 | 8921 | { |
---|
.. | .. |
---|
8930 | 8930 | // if (parentcam != renderCamera) // not a light |
---|
8931 | 8931 | if (cam != lightCamera) |
---|
8932 | 8932 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8933 | | - LA.matConcat(matrix, parentcam.fromParent, matrix); |
---|
| 8933 | + LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
8934 | 8934 | |
---|
8935 | 8935 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
8936 | 8936 | |
---|
.. | .. |
---|
9754 | 9754 | selectedpoint.radius = radius; |
---|
9755 | 9755 | selectedpoint.recalculate(); |
---|
9756 | 9756 | selectedpoint.material = new cMaterial(); |
---|
9757 | | - selectedpoint.material.color = 0.25f; |
---|
| 9757 | + selectedpoint.material.color = 0.15f; |
---|
9758 | 9758 | selectedpoint.material.modulation = 0.75f; |
---|
9759 | 9759 | |
---|
9760 | 9760 | debugpoint.radius = radius; |
---|
.. | .. |
---|
12854 | 12854 | { |
---|
12855 | 12855 | mouseMode |= ZOOM; |
---|
12856 | 12856 | } |
---|
12857 | | - if ((modifiers & META) == META) |
---|
| 12857 | + |
---|
| 12858 | + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 12859 | + if (capsLocked || (modifiers & META) == META) |
---|
12858 | 12860 | { |
---|
12859 | 12861 | mouseMode |= VR; // BACKFORTH; |
---|
12860 | 12862 | } |
---|
.. | .. |
---|
12868 | 12870 | } |
---|
12869 | 12871 | if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
12870 | 12872 | { |
---|
| 12873 | + mouseMode &= ~VR; |
---|
12871 | 12874 | mouseMode |= TRANSLATE; |
---|
12872 | 12875 | } |
---|
12873 | 12876 | // if ((modifiers & SHIFT_META) == SHIFT_META) |
---|
.. | .. |
---|
14719 | 14722 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
14720 | 14723 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
14721 | 14724 | |
---|
| 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 | + |
---|
14722 | 14730 | glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); |
---|
14723 | 14731 | |
---|
14724 | 14732 | // if (object.selection != null && object.selection.Size() > 0) |
---|
.. | .. |
---|
15107 | 15115 | gl.glFlush(); |
---|
15108 | 15116 | |
---|
15109 | 15117 | /**/ |
---|
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); |
---|
15111 | 15119 | |
---|
15112 | | - int[] pixels = occlusionsizebuffer.array(); |
---|
| 15120 | + float[] pixels = occlusionsizebuffer.array(); |
---|
15113 | 15121 | |
---|
15114 | 15122 | double r = 0, g = 0, b = 0; |
---|
15115 | 15123 | |
---|
15116 | 15124 | double count = 0; |
---|
| 15125 | + |
---|
| 15126 | + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); |
---|
| 15127 | + |
---|
| 15128 | + float mindepth = 1; |
---|
| 15129 | + |
---|
| 15130 | + double FACTOR = 1; |
---|
15117 | 15131 | |
---|
15118 | 15132 | for (int i = 0; i < pixels.length; i++) |
---|
15119 | 15133 | { |
---|
.. | .. |
---|
15198 | 15212 | |
---|
15199 | 15213 | double scale = ray.z; // 1; // cos |
---|
15200 | 15214 | |
---|
15201 | | - int p = pixels[newindex]; |
---|
| 15215 | + float depth = pixels[newindex]; |
---|
15202 | 15216 | |
---|
15203 | 15217 | /* |
---|
15204 | 15218 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
15222 | 15236 | scale = (1 - modu) * modv; |
---|
15223 | 15237 | */ |
---|
15224 | 15238 | |
---|
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 | + } |
---|
15228 | 15247 | |
---|
| 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 | + |
---|
15229 | 15256 | count += scale; |
---|
15230 | 15257 | } |
---|
15231 | 15258 | |
---|
.. | .. |
---|
15341 | 15368 | int AAbuffersize = 0; |
---|
15342 | 15369 | |
---|
15343 | 15370 | //double[] selectedpoint = new double[3]; |
---|
15344 | | - static Sphere selectedpoint = new Sphere(); |
---|
| 15371 | + static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
15345 | 15372 | static Sphere previousselectedpoint = null; |
---|
15346 | 15373 | static Sphere debugpoint = new Sphere(); |
---|
15347 | 15374 | static Sphere debugpoint2 = new Sphere(); |
---|
.. | .. |
---|
15399 | 15426 | static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
15400 | 15427 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
15401 | 15428 | 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); |
---|
15403 | 15431 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
15404 | 15432 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
15405 | 15433 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|