.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
93 | 97 | //boolean REDUCETEXTURE = true; |
---|
94 | 98 | boolean CACHETEXTURE = true; |
---|
95 | 99 | boolean CLEANCACHE = false; // true; |
---|
96 | | - boolean MIPMAP = true; // false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
97 | 101 | boolean COMPRESSTEXTURE = false; |
---|
98 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
99 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
202 | 206 | |
---|
203 | 207 | SetCamera(cam); |
---|
204 | 208 | |
---|
205 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 209 | + // Warning: not used. |
---|
| 210 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
206 | 211 | |
---|
207 | 212 | object = o; |
---|
208 | 213 | |
---|
.. | .. |
---|
8358 | 8363 | { |
---|
8359 | 8364 | TextureData texturedata = null; |
---|
8360 | 8365 | |
---|
8361 | | - if (texdata != null) |
---|
| 8366 | + if (texdata != null && textureon) |
---|
8362 | 8367 | { |
---|
8363 | | - BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
8364 | 8369 | |
---|
8365 | | - CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8370 | + try |
---|
| 8371 | + { |
---|
| 8372 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8373 | + } |
---|
| 8374 | + catch (Exception e) |
---|
| 8375 | + { |
---|
| 8376 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8377 | + } |
---|
8366 | 8378 | |
---|
8367 | 8379 | texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
8368 | 8380 | bimtextures.put(texdata, texturecache); |
---|
| 8381 | + |
---|
| 8382 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8383 | + |
---|
| 8384 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8385 | + //bim2 = bim; |
---|
8369 | 8386 | } |
---|
8370 | 8387 | else |
---|
8371 | 8388 | if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
.. | .. |
---|
8560 | 8577 | { |
---|
8561 | 8578 | if (tex.pigmentdata == null) |
---|
8562 | 8579 | { |
---|
8563 | | - String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + //String texname = Object3D.GetPigment(tex); |
---|
8564 | 8581 | |
---|
8565 | 8582 | CacheTexture texturecache = texturepigment.get(tex); |
---|
8566 | 8583 | |
---|
8567 | 8584 | if (texturecache != null) |
---|
8568 | 8585 | { |
---|
8569 | | - tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
8570 | 8586 | tex.pw = texturecache.texturedata.getWidth(); |
---|
8571 | 8587 | tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8588 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8589 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8590 | + ; |
---|
| 8591 | + //, tex.pw, tex.ph), 0.5f); |
---|
8572 | 8592 | } |
---|
8573 | 8593 | } |
---|
8574 | 8594 | |
---|
8575 | 8595 | if (tex.bumpdata == null) |
---|
8576 | 8596 | { |
---|
8577 | | - String texname = Object3D.GetBump(tex); |
---|
| 8597 | + //String texname = Object3D.GetBump(tex); |
---|
8578 | 8598 | |
---|
8579 | 8599 | CacheTexture texturecache = texturebump.get(tex); |
---|
8580 | 8600 | |
---|
8581 | 8601 | if (texturecache != null) |
---|
8582 | 8602 | { |
---|
8583 | | - tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
8584 | 8603 | tex.bw = texturecache.texturedata.getWidth(); |
---|
8585 | 8604 | tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8605 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
8586 | 8606 | } |
---|
8587 | 8607 | } |
---|
8588 | 8608 | } |
---|
.. | .. |
---|
8654 | 8674 | return true; // Warning: not used. |
---|
8655 | 8675 | } |
---|
8656 | 8676 | |
---|
| 8677 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8678 | + { |
---|
| 8679 | + try |
---|
| 8680 | + { |
---|
| 8681 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8682 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8683 | + ImageWriter writer = writers.next(); |
---|
| 8684 | + |
---|
| 8685 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8686 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8687 | + param.setCompressionQuality(quality); |
---|
| 8688 | + |
---|
| 8689 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8690 | + writer.setOutput(ios); |
---|
| 8691 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8692 | + |
---|
| 8693 | + byte[] data = baos.toByteArray(); |
---|
| 8694 | + writer.dispose(); |
---|
| 8695 | + return data; |
---|
| 8696 | + } |
---|
| 8697 | + catch (Exception e) |
---|
| 8698 | + { |
---|
| 8699 | + e.printStackTrace(); |
---|
| 8700 | + return null; |
---|
| 8701 | + } |
---|
| 8702 | + } |
---|
| 8703 | + |
---|
| 8704 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8705 | + { |
---|
| 8706 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8707 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8708 | + ImageReader reader = writers.next(); |
---|
| 8709 | + |
---|
| 8710 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8711 | + |
---|
| 8712 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8713 | + param.setDestination(bim); |
---|
| 8714 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8715 | + |
---|
| 8716 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8717 | + reader.setInput(ios); |
---|
| 8718 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8719 | + reader.dispose(); |
---|
| 8720 | + |
---|
| 8721 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8722 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8723 | +// byte[] bytes = data.getData(); |
---|
| 8724 | +// |
---|
| 8725 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8726 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8727 | +// { |
---|
| 8728 | +// int i3 = i*3; |
---|
| 8729 | +// pixels[i] = 0xFF; |
---|
| 8730 | +// pixels[i] <<= 8; |
---|
| 8731 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8732 | +// pixels[i] <<= 8; |
---|
| 8733 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8734 | +// pixels[i] <<= 8; |
---|
| 8735 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8736 | +// } |
---|
| 8737 | +// |
---|
| 8738 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8739 | + |
---|
| 8740 | + return bim; |
---|
| 8741 | + } |
---|
| 8742 | + |
---|
8657 | 8743 | ShadowBuffer shadowPBuf; |
---|
8658 | 8744 | AntialiasBuffer antialiasPBuf; |
---|
8659 | 8745 | int MAXSTACK; |
---|
.. | .. |
---|
9614 | 9700 | |
---|
9615 | 9701 | if (renderCamera != lightCamera) |
---|
9616 | 9702 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9617 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9703 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9618 | 9704 | |
---|
9619 | 9705 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9620 | 9706 | |
---|
.. | .. |
---|
9630 | 9716 | |
---|
9631 | 9717 | if (renderCamera != lightCamera) |
---|
9632 | 9718 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9633 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9719 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9634 | 9720 | |
---|
9635 | 9721 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9636 | 9722 | |
---|
.. | .. |
---|
10831 | 10917 | // if (parentcam != renderCamera) // not a light |
---|
10832 | 10918 | if (cam != lightCamera) |
---|
10833 | 10919 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10834 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10920 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10835 | 10921 | |
---|
10836 | 10922 | for (int j = 0; j < 4; j++) |
---|
10837 | 10923 | { |
---|
.. | .. |
---|
10846 | 10932 | // if (parentcam != renderCamera) // not a light |
---|
10847 | 10933 | if (cam != lightCamera) |
---|
10848 | 10934 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10849 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10935 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10850 | 10936 | |
---|
10851 | 10937 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10852 | 10938 | |
---|
.. | .. |
---|
11399 | 11485 | } |
---|
11400 | 11486 | } |
---|
11401 | 11487 | |
---|
11402 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11488 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11403 | 11489 | { |
---|
11404 | 11490 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11405 | 11491 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11407 | 11493 | |
---|
11408 | 11494 | boolean texon = textureon; |
---|
11409 | 11495 | |
---|
11410 | | - if (RENDERPROGRAM > 0) |
---|
11411 | | - { |
---|
11412 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11413 | | - textureon = false; |
---|
11414 | | - } |
---|
| 11496 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11497 | + textureon = false; |
---|
| 11498 | + |
---|
11415 | 11499 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11416 | 11500 | //System.out.println("ALLO"); |
---|
11417 | 11501 | gl.glColorMask(false, false, false, false); |
---|
11418 | 11502 | DrawObject(gl); |
---|
11419 | | - if (RENDERPROGRAM > 0) |
---|
11420 | | - { |
---|
11421 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11422 | | - textureon = texon; |
---|
11423 | | - } |
---|
| 11503 | + |
---|
| 11504 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11505 | + textureon = texon; |
---|
| 11506 | + |
---|
11424 | 11507 | gl.glColorMask(true, true, true, true); |
---|
11425 | 11508 | |
---|
11426 | 11509 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11427 | | - //gl.glDepthMask(false); |
---|
| 11510 | + gl.glDepthMask(false); |
---|
11428 | 11511 | } |
---|
11429 | 11512 | |
---|
11430 | 11513 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
12318 | 12401 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12319 | 12402 | |
---|
12320 | 12403 | String program = |
---|
| 12404 | + // Min shader |
---|
12321 | 12405 | "!!ARBfp1.0\n" + |
---|
| 12406 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12407 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12408 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12409 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12410 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12411 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12412 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12413 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12414 | + "TEMP temp;" + |
---|
| 12415 | + "TEMP light;" + |
---|
| 12416 | + "TEMP ndotl;" + |
---|
| 12417 | + "TEMP normal;" + |
---|
| 12418 | + "TEMP depth;" + |
---|
| 12419 | + "TEMP eye;" + |
---|
| 12420 | + "TEMP pos;" + |
---|
| 12421 | + |
---|
| 12422 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12423 | + Normalize("normal") + |
---|
| 12424 | + "MOV light, state.light[0].position;" + |
---|
| 12425 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12426 | + |
---|
| 12427 | + // shadow |
---|
| 12428 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12429 | + "MOV temp, pos;" + |
---|
| 12430 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12431 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12432 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12433 | + |
---|
| 12434 | + // No shadow when out of frustum |
---|
| 12435 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12436 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12437 | + |
---|
| 12438 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12439 | + |
---|
| 12440 | + // Backlit |
---|
| 12441 | + "MOV pos.w, zero123.y;" + |
---|
| 12442 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12443 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12444 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12445 | + Normalize("eye") + |
---|
| 12446 | + |
---|
| 12447 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12448 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12449 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12450 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12451 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12452 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12453 | + |
---|
| 12454 | + "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12455 | + |
---|
| 12456 | + // Pigment |
---|
| 12457 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12458 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12459 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12460 | + |
---|
| 12461 | + "MUL temp, temp, zero123.z;" + |
---|
| 12462 | + |
---|
| 12463 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12464 | + |
---|
| 12465 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12466 | + "MOV result.color, temp;" + |
---|
| 12467 | + "END"; |
---|
| 12468 | + |
---|
| 12469 | + String program2 = |
---|
| 12470 | + "!!ARBfp1.0\n" + |
---|
| 12471 | + |
---|
12322 | 12472 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12323 | 12473 | "PARAM light2cam0 = program.env[10];" + |
---|
12324 | 12474 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12433 | 12583 | "TEMP shininess;" + |
---|
12434 | 12584 | "\n" + |
---|
12435 | 12585 | "MOV texSamp, one;" + |
---|
12436 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12437 | | - |
---|
| 12586 | + |
---|
12438 | 12587 | "MOV mapgrid.x, one2048th.x;" + |
---|
12439 | 12588 | "MOV temp, fragment.texcoord[1];" + |
---|
12440 | 12589 | /* |
---|
.. | .. |
---|
12455 | 12604 | "MUL temp, floor, mapgrid.x;" + |
---|
12456 | 12605 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12457 | 12606 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12458 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12607 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12459 | 12608 | "") + |
---|
12460 | 12609 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12461 | 12610 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12462 | 12611 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12463 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12612 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12464 | 12613 | "") + |
---|
12465 | 12614 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12466 | 12615 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12467 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12616 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12468 | 12617 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12469 | 12618 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12470 | 12619 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12471 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12620 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12472 | 12621 | "") + |
---|
12473 | 12622 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12474 | 12623 | //"MOV params, material;" + |
---|
.. | .. |
---|
12839 | 12988 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12840 | 12989 | "") + |
---|
12841 | 12990 | |
---|
12842 | | - // display shadow only (bump == 0) |
---|
| 12991 | + // display shadow only (fakedepth == 0) |
---|
12843 | 12992 | "SUB temp.x, half.x, shadow.x;" + |
---|
12844 | 12993 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12845 | 12994 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13266 | 13415 | return out; |
---|
13267 | 13416 | } |
---|
13268 | 13417 | |
---|
13269 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13418 | + // Also does frustum culling |
---|
| 13419 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13270 | 13420 | { |
---|
13271 | 13421 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13272 | 13422 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13273 | 13423 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13424 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13425 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13274 | 13426 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13275 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13276 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13277 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13278 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13427 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13428 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13279 | 13429 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13280 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13430 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13281 | 13431 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13282 | 13432 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13283 | 13433 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13284 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13434 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13285 | 13435 | |
---|
13286 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13287 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13436 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13437 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13288 | 13438 | } |
---|
13289 | 13439 | |
---|
13290 | 13440 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13331 | 13481 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13332 | 13482 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13333 | 13483 | |
---|
13334 | | - // No shadow when out of frustrum |
---|
| 13484 | + // No shadow when out of frustum |
---|
13335 | 13485 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13336 | 13486 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13337 | 13487 | ""; |
---|
.. | .. |
---|
14129 | 14279 | drag = false; |
---|
14130 | 14280 | //System.out.println("Mouse DOWN"); |
---|
14131 | 14281 | editObj = false; |
---|
14132 | | - ClickInfo info = new ClickInfo(); |
---|
14133 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14134 | | - info.pane = this; |
---|
14135 | | - info.camera = renderCamera; |
---|
14136 | | - info.x = x; |
---|
14137 | | - info.y = y; |
---|
14138 | | - info.modifiers = modifiersex; |
---|
14139 | | - editObj = object.doEditClick(info, 0); |
---|
| 14282 | + //ClickInfo info = new ClickInfo(); |
---|
| 14283 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14284 | + object.clickInfo.pane = this; |
---|
| 14285 | + object.clickInfo.camera = renderCamera; |
---|
| 14286 | + object.clickInfo.x = x; |
---|
| 14287 | + object.clickInfo.y = y; |
---|
| 14288 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14289 | + editObj = object.doEditClick(//info, |
---|
| 14290 | + 0); |
---|
14140 | 14291 | if (!editObj) |
---|
14141 | 14292 | { |
---|
14142 | 14293 | hasMarquee = true; |
---|
.. | .. |
---|
14536 | 14687 | if (editObj) |
---|
14537 | 14688 | { |
---|
14538 | 14689 | drag = true; |
---|
14539 | | - ClickInfo info = new ClickInfo(); |
---|
14540 | | - info.bounds.setBounds(0, 0, |
---|
| 14690 | + //ClickInfo info = new ClickInfo(); |
---|
| 14691 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14541 | 14692 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14542 | | - info.pane = this; |
---|
14543 | | - info.camera = renderCamera; |
---|
14544 | | - info.x = x; |
---|
14545 | | - info.y = y; |
---|
14546 | | - object.GetWindow().copy |
---|
14547 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14693 | + object.clickInfo.pane = this; |
---|
| 14694 | + object.clickInfo.camera = renderCamera; |
---|
| 14695 | + object.clickInfo.x = x; |
---|
| 14696 | + object.clickInfo.y = y; |
---|
| 14697 | + object //.GetWindow().copy |
---|
| 14698 | + .doEditDrag(//info, |
---|
| 14699 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14548 | 14700 | } else |
---|
14549 | 14701 | { |
---|
14550 | 14702 | if (x < startX) |
---|
.. | .. |
---|
14693 | 14845 | } |
---|
14694 | 14846 | } |
---|
14695 | 14847 | |
---|
| 14848 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14849 | + |
---|
14696 | 14850 | public void mouseMoved(MouseEvent e) |
---|
14697 | 14851 | { |
---|
14698 | 14852 | //System.out.println("mouseMoved: " + e); |
---|
14699 | 14853 | if (isRenderer) |
---|
14700 | 14854 | return; |
---|
14701 | 14855 | |
---|
14702 | | - ClickInfo ci = new ClickInfo(); |
---|
14703 | | - ci.x = e.getX(); |
---|
14704 | | - ci.y = e.getY(); |
---|
14705 | | - ci.modifiers = e.getModifiersEx(); |
---|
14706 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14707 | | - ci.pane = this; |
---|
14708 | | - ci.camera = renderCamera; |
---|
| 14856 | + // Mouse cursor feedback |
---|
| 14857 | + object.clickInfo.x = e.getX(); |
---|
| 14858 | + object.clickInfo.y = e.getY(); |
---|
| 14859 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14860 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14861 | + object.clickInfo.pane = this; |
---|
| 14862 | + object.clickInfo.camera = renderCamera; |
---|
14709 | 14863 | if (!isRenderer) |
---|
14710 | 14864 | { |
---|
14711 | 14865 | //ObjEditor editWindow = object.editWindow; |
---|
14712 | 14866 | //Object3D copy = editWindow.copy; |
---|
14713 | | - if (object.doEditClick(ci, 0)) |
---|
| 14867 | + if (object.doEditClick(//clickInfo, |
---|
| 14868 | + 0)) |
---|
14714 | 14869 | { |
---|
14715 | 14870 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14716 | 14871 | } else |
---|
.. | .. |
---|
15736 | 15891 | |
---|
15737 | 15892 | int width = getBounds().width; |
---|
15738 | 15893 | int height = getBounds().height; |
---|
15739 | | - ClickInfo info = new ClickInfo(); |
---|
15740 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15741 | 15894 | //Image img = CreateImage(width, height); |
---|
15742 | 15895 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15743 | 15896 | |
---|
.. | .. |
---|
15814 | 15967 | } |
---|
15815 | 15968 | if (object != null && !hasMarquee) |
---|
15816 | 15969 | { |
---|
| 15970 | + if (object.clickInfo == null) |
---|
| 15971 | + object.clickInfo = new ClickInfo(); |
---|
| 15972 | + ClickInfo info = object.clickInfo; |
---|
| 15973 | + //ClickInfo info = new ClickInfo(); |
---|
| 15974 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15975 | + |
---|
15817 | 15976 | if (isRenderer) |
---|
15818 | 15977 | { |
---|
15819 | | - info.flags++; |
---|
| 15978 | + object.clickInfo.flags++; |
---|
15820 | 15979 | double frameAspect = (double) width / (double) height; |
---|
15821 | 15980 | if (frameAspect > renderCamera.aspect) |
---|
15822 | 15981 | { |
---|
15823 | 15982 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15824 | | - info.bounds.width -= width - desired; |
---|
15825 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15983 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15984 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15826 | 15985 | } else |
---|
15827 | 15986 | { |
---|
15828 | 15987 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15829 | | - info.bounds.height -= height - desired; |
---|
15830 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15988 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15989 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15831 | 15990 | } |
---|
15832 | 15991 | } |
---|
15833 | 15992 | |
---|
15834 | | - info.g = gr; |
---|
15835 | | - info.camera = renderCamera; |
---|
| 15993 | + object.clickInfo.g = gr; |
---|
| 15994 | + object.clickInfo.camera = renderCamera; |
---|
15836 | 15995 | /* |
---|
15837 | 15996 | // Memory intensive (brep.verticescopy) |
---|
15838 | 15997 | if (!(object instanceof Composite)) |
---|
15839 | 15998 | object.draw(info, 0, false); // SLOW : |
---|
15840 | 15999 | */ |
---|
15841 | | - if (!isRenderer) |
---|
| 16000 | + if (!isRenderer) // && drag) |
---|
15842 | 16001 | { |
---|
15843 | 16002 | Grafreed.Assert(object != null); |
---|
15844 | 16003 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15846 | 16005 | { |
---|
15847 | 16006 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15848 | 16007 | |
---|
15849 | | - info.DX = 0; |
---|
15850 | | - info.DY = 0; |
---|
15851 | | - info.W = 1; |
---|
| 16008 | + object.clickInfo.DX = 0; |
---|
| 16009 | + object.clickInfo.DY = 0; |
---|
| 16010 | + object.clickInfo.W = 1; |
---|
15852 | 16011 | if (hitSomething == Object3D.hitCenter) |
---|
15853 | 16012 | { |
---|
15854 | 16013 | info.DX = X; |
---|
.. | .. |
---|
15860 | 16019 | info.DY -= info.bounds.height/2; |
---|
15861 | 16020 | } |
---|
15862 | 16021 | |
---|
15863 | | - object.drawEditHandles(info, 0); |
---|
| 16022 | + object.drawEditHandles(//info, |
---|
| 16023 | + 0); |
---|
15864 | 16024 | |
---|
15865 | 16025 | if (drag && (X != 0 || Y != 0)) |
---|
15866 | 16026 | { |
---|
.. | .. |
---|
15873 | 16033 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15874 | 16034 | break; |
---|
15875 | 16035 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15876 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16036 | + gr.drawLine(X, Y, 0, 0); |
---|
15877 | 16037 | break; |
---|
15878 | 16038 | } |
---|
15879 | 16039 | |
---|