.. | .. |
---|
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; |
---|
.. | .. |
---|
8358 | 8362 | { |
---|
8359 | 8363 | TextureData texturedata = null; |
---|
8360 | 8364 | |
---|
8361 | | - if (texdata != null) |
---|
| 8365 | + if (texdata != null && textureon) |
---|
8362 | 8366 | { |
---|
8363 | | - BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
8364 | 8368 | |
---|
8365 | | - CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
8366 | 8377 | |
---|
8367 | 8378 | texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
8368 | 8379 | bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
8369 | 8385 | } |
---|
8370 | 8386 | else |
---|
8371 | 8387 | if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
.. | .. |
---|
8560 | 8576 | { |
---|
8561 | 8577 | if (tex.pigmentdata == null) |
---|
8562 | 8578 | { |
---|
8563 | | - String texname = Object3D.GetPigment(tex); |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
8564 | 8580 | |
---|
8565 | 8581 | CacheTexture texturecache = texturepigment.get(tex); |
---|
8566 | 8582 | |
---|
8567 | 8583 | if (texturecache != null) |
---|
8568 | 8584 | { |
---|
8569 | | - tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
8570 | 8585 | tex.pw = texturecache.texturedata.getWidth(); |
---|
8571 | 8586 | tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
8572 | 8591 | } |
---|
8573 | 8592 | } |
---|
8574 | 8593 | |
---|
8575 | 8594 | if (tex.bumpdata == null) |
---|
8576 | 8595 | { |
---|
8577 | | - String texname = Object3D.GetBump(tex); |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
8578 | 8597 | |
---|
8579 | 8598 | CacheTexture texturecache = texturebump.get(tex); |
---|
8580 | 8599 | |
---|
8581 | 8600 | if (texturecache != null) |
---|
8582 | 8601 | { |
---|
8583 | | - tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
8584 | 8602 | tex.bw = texturecache.texturedata.getWidth(); |
---|
8585 | 8603 | tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
8586 | 8605 | } |
---|
8587 | 8606 | } |
---|
8588 | 8607 | } |
---|
.. | .. |
---|
8654 | 8673 | return true; // Warning: not used. |
---|
8655 | 8674 | } |
---|
8656 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
8657 | 8742 | ShadowBuffer shadowPBuf; |
---|
8658 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8659 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
11399 | 11484 | } |
---|
11400 | 11485 | } |
---|
11401 | 11486 | |
---|
11402 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11403 | 11488 | { |
---|
11404 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11405 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11407 | 11492 | |
---|
11408 | 11493 | boolean texon = textureon; |
---|
11409 | 11494 | |
---|
11410 | | - if (RENDERPROGRAM > 0) |
---|
11411 | | - { |
---|
11412 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11413 | | - textureon = false; |
---|
11414 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11415 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11416 | 11499 | //System.out.println("ALLO"); |
---|
11417 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11418 | 11501 | DrawObject(gl); |
---|
11419 | | - if (RENDERPROGRAM > 0) |
---|
11420 | | - { |
---|
11421 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11422 | | - textureon = texon; |
---|
11423 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11424 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11425 | 11507 | |
---|
11426 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11427 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11428 | 11510 | } |
---|
11429 | 11511 | |
---|
11430 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
12318 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12319 | 12401 | |
---|
12320 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
12321 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
12322 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12323 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
12324 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12433 | 12560 | "TEMP shininess;" + |
---|
12434 | 12561 | "\n" + |
---|
12435 | 12562 | "MOV texSamp, one;" + |
---|
12436 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12437 | | - |
---|
| 12563 | + |
---|
12438 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
12439 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
12440 | 12566 | /* |
---|
.. | .. |
---|
12839 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12840 | 12966 | "") + |
---|
12841 | 12967 | |
---|
12842 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
12843 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
12844 | 12970 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12845 | 12971 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13271 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13272 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13273 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13274 | 13402 | "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;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13279 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13280 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13281 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13282 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13283 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13284 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13285 | 13411 | |
---|
13286 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13287 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13288 | 13414 | } |
---|
13289 | 13415 | |
---|
13290 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13331 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13332 | 13458 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13333 | 13459 | |
---|
13334 | | - // No shadow when out of frustrum |
---|
| 13460 | + // No shadow when out of frustum |
---|
13335 | 13461 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13336 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13337 | 13463 | ""; |
---|
.. | .. |
---|
14129 | 14255 | drag = false; |
---|
14130 | 14256 | //System.out.println("Mouse DOWN"); |
---|
14131 | 14257 | 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); |
---|
| 14258 | + //ClickInfo info = new ClickInfo(); |
---|
| 14259 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14260 | + object.clickInfo.pane = this; |
---|
| 14261 | + object.clickInfo.camera = renderCamera; |
---|
| 14262 | + object.clickInfo.x = x; |
---|
| 14263 | + object.clickInfo.y = y; |
---|
| 14264 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14265 | + editObj = object.doEditClick(//info, |
---|
| 14266 | + 0); |
---|
14140 | 14267 | if (!editObj) |
---|
14141 | 14268 | { |
---|
14142 | 14269 | hasMarquee = true; |
---|
.. | .. |
---|
14536 | 14663 | if (editObj) |
---|
14537 | 14664 | { |
---|
14538 | 14665 | drag = true; |
---|
14539 | | - ClickInfo info = new ClickInfo(); |
---|
14540 | | - info.bounds.setBounds(0, 0, |
---|
| 14666 | + //ClickInfo info = new ClickInfo(); |
---|
| 14667 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14541 | 14668 | (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); |
---|
| 14669 | + object.clickInfo.pane = this; |
---|
| 14670 | + object.clickInfo.camera = renderCamera; |
---|
| 14671 | + object.clickInfo.x = x; |
---|
| 14672 | + object.clickInfo.y = y; |
---|
| 14673 | + object //.GetWindow().copy |
---|
| 14674 | + .doEditDrag(//info, |
---|
| 14675 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14548 | 14676 | } else |
---|
14549 | 14677 | { |
---|
14550 | 14678 | if (x < startX) |
---|
.. | .. |
---|
14693 | 14821 | } |
---|
14694 | 14822 | } |
---|
14695 | 14823 | |
---|
| 14824 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14825 | + |
---|
14696 | 14826 | public void mouseMoved(MouseEvent e) |
---|
14697 | 14827 | { |
---|
14698 | 14828 | //System.out.println("mouseMoved: " + e); |
---|
14699 | 14829 | if (isRenderer) |
---|
14700 | 14830 | return; |
---|
14701 | 14831 | |
---|
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; |
---|
| 14832 | + // Mouse cursor feedback |
---|
| 14833 | + object.clickInfo.x = e.getX(); |
---|
| 14834 | + object.clickInfo.y = e.getY(); |
---|
| 14835 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14836 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14837 | + object.clickInfo.pane = this; |
---|
| 14838 | + object.clickInfo.camera = renderCamera; |
---|
14709 | 14839 | if (!isRenderer) |
---|
14710 | 14840 | { |
---|
14711 | 14841 | //ObjEditor editWindow = object.editWindow; |
---|
14712 | 14842 | //Object3D copy = editWindow.copy; |
---|
14713 | | - if (object.doEditClick(ci, 0)) |
---|
| 14843 | + if (object.doEditClick(//clickInfo, |
---|
| 14844 | + 0)) |
---|
14714 | 14845 | { |
---|
14715 | 14846 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14716 | 14847 | } else |
---|
.. | .. |
---|
15736 | 15867 | |
---|
15737 | 15868 | int width = getBounds().width; |
---|
15738 | 15869 | int height = getBounds().height; |
---|
15739 | | - ClickInfo info = new ClickInfo(); |
---|
15740 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15741 | 15870 | //Image img = CreateImage(width, height); |
---|
15742 | 15871 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15743 | 15872 | |
---|
.. | .. |
---|
15814 | 15943 | } |
---|
15815 | 15944 | if (object != null && !hasMarquee) |
---|
15816 | 15945 | { |
---|
| 15946 | + if (object.clickInfo == null) |
---|
| 15947 | + object.clickInfo = new ClickInfo(); |
---|
| 15948 | + ClickInfo info = object.clickInfo; |
---|
| 15949 | + //ClickInfo info = new ClickInfo(); |
---|
| 15950 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15951 | + |
---|
15817 | 15952 | if (isRenderer) |
---|
15818 | 15953 | { |
---|
15819 | | - info.flags++; |
---|
| 15954 | + object.clickInfo.flags++; |
---|
15820 | 15955 | double frameAspect = (double) width / (double) height; |
---|
15821 | 15956 | if (frameAspect > renderCamera.aspect) |
---|
15822 | 15957 | { |
---|
15823 | 15958 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15824 | | - info.bounds.width -= width - desired; |
---|
15825 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15959 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15960 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15826 | 15961 | } else |
---|
15827 | 15962 | { |
---|
15828 | 15963 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15829 | | - info.bounds.height -= height - desired; |
---|
15830 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15964 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15965 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15831 | 15966 | } |
---|
15832 | 15967 | } |
---|
15833 | 15968 | |
---|
15834 | | - info.g = gr; |
---|
15835 | | - info.camera = renderCamera; |
---|
| 15969 | + object.clickInfo.g = gr; |
---|
| 15970 | + object.clickInfo.camera = renderCamera; |
---|
15836 | 15971 | /* |
---|
15837 | 15972 | // Memory intensive (brep.verticescopy) |
---|
15838 | 15973 | if (!(object instanceof Composite)) |
---|
15839 | 15974 | object.draw(info, 0, false); // SLOW : |
---|
15840 | 15975 | */ |
---|
15841 | | - if (!isRenderer) |
---|
| 15976 | + if (!isRenderer) // && drag) |
---|
15842 | 15977 | { |
---|
15843 | 15978 | Grafreed.Assert(object != null); |
---|
15844 | 15979 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15846 | 15981 | { |
---|
15847 | 15982 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15848 | 15983 | |
---|
15849 | | - info.DX = 0; |
---|
15850 | | - info.DY = 0; |
---|
15851 | | - info.W = 1; |
---|
| 15984 | + object.clickInfo.DX = 0; |
---|
| 15985 | + object.clickInfo.DY = 0; |
---|
| 15986 | + object.clickInfo.W = 1; |
---|
15852 | 15987 | if (hitSomething == Object3D.hitCenter) |
---|
15853 | 15988 | { |
---|
15854 | 15989 | info.DX = X; |
---|
.. | .. |
---|
15860 | 15995 | info.DY -= info.bounds.height/2; |
---|
15861 | 15996 | } |
---|
15862 | 15997 | |
---|
15863 | | - object.drawEditHandles(info, 0); |
---|
| 15998 | + object.drawEditHandles(//info, |
---|
| 15999 | + 0); |
---|
15864 | 16000 | |
---|
15865 | 16001 | if (drag && (X != 0 || Y != 0)) |
---|
15866 | 16002 | { |
---|
.. | .. |
---|
15873 | 16009 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15874 | 16010 | break; |
---|
15875 | 16011 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15876 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16012 | + gr.drawLine(X, Y, 0, 0); |
---|
15877 | 16013 | break; |
---|
15878 | 16014 | } |
---|
15879 | 16015 | |
---|