Normand Briere
2019-07-25 7058eef32e524cae08a7373d8bc1061e373b223c
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,6 +33,7 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
3438 class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3539 {
....@@ -93,7 +97,7 @@
9397 //boolean REDUCETEXTURE = true;
9498 boolean CACHETEXTURE = true;
9599 boolean CLEANCACHE = false; // true;
96
- boolean MIPMAP = true; // false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
97101 boolean COMPRESSTEXTURE = false;
98102 boolean KOMPACTTEXTURE = false; // true;
99103 boolean RESIZETEXTURE = false;
....@@ -202,7 +206,8 @@
202206
203207 SetCamera(cam);
204208
205
- SetLight(new Camera(new cVector(10, 10, -20)));
209
+ // Warning: not used.
210
+ SetLight(new Camera(new cVector(15, 10, -20)));
206211
207212 object = o;
208213
....@@ -8358,14 +8363,26 @@
83588363 {
83598364 TextureData texturedata = null;
83608365
8361
- if (texdata != null)
8366
+ if (texdata != null && textureon)
83628367 {
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);
83648369
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
+ }
83668378
83678379 texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
83688380 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;
83698386 }
83708387 else
83718388 if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
....@@ -8560,29 +8577,32 @@
85608577 {
85618578 if (tex.pigmentdata == null)
85628579 {
8563
- String texname = Object3D.GetPigment(tex);
8580
+ //String texname = Object3D.GetPigment(tex);
85648581
85658582 CacheTexture texturecache = texturepigment.get(tex);
85668583
85678584 if (texturecache != null)
85688585 {
8569
- tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
85708586 tex.pw = texturecache.texturedata.getWidth();
85718587 tex.ph = texturecache.texturedata.getHeight();
8588
+ tex.pigmentdata = //CompressJPEG(CreateBim
8589
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8590
+ ;
8591
+ //, tex.pw, tex.ph), 0.5f);
85728592 }
85738593 }
85748594
85758595 if (tex.bumpdata == null)
85768596 {
8577
- String texname = Object3D.GetBump(tex);
8597
+ //String texname = Object3D.GetBump(tex);
85788598
85798599 CacheTexture texturecache = texturebump.get(tex);
85808600
85818601 if (texturecache != null)
85828602 {
8583
- tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
85848603 tex.bw = texturecache.texturedata.getWidth();
85858604 tex.bh = texturecache.texturedata.getHeight();
8605
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
85868606 }
85878607 }
85888608 }
....@@ -8654,6 +8674,72 @@
86548674 return true; // Warning: not used.
86558675 }
86568676
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
+
86578743 ShadowBuffer shadowPBuf;
86588744 AntialiasBuffer antialiasPBuf;
86598745 int MAXSTACK;
....@@ -9614,7 +9700,7 @@
96149700
96159701 if (renderCamera != lightCamera)
96169702 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9703
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
96189704
96199705 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
96209706
....@@ -9630,7 +9716,7 @@
96309716
96319717 if (renderCamera != lightCamera)
96329718 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9719
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
96349720
96359721 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
96369722
....@@ -10831,7 +10917,7 @@
1083110917 // if (parentcam != renderCamera) // not a light
1083210918 if (cam != lightCamera)
1083310919 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10920
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1083510921
1083610922 for (int j = 0; j < 4; j++)
1083710923 {
....@@ -10846,7 +10932,7 @@
1084610932 // if (parentcam != renderCamera) // not a light
1084710933 if (cam != lightCamera)
1084810934 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10935
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1085010936
1085110937 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1085210938
....@@ -11399,7 +11485,7 @@
1139911485 }
1140011486 }
1140111487
11402
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11488
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1140311489 {
1140411490 //gl.glDepthFunc(GL.GL_LEQUAL);
1140511491 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11407,24 +11493,21 @@
1140711493
1140811494 boolean texon = textureon;
1140911495
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
+
1141511499 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1141611500 //System.out.println("ALLO");
1141711501 gl.glColorMask(false, false, false, false);
1141811502 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
+
1142411507 gl.glColorMask(true, true, true, true);
1142511508
1142611509 gl.glDepthFunc(GL.GL_EQUAL);
11427
- //gl.glDepthMask(false);
11510
+ gl.glDepthMask(false);
1142811511 }
1142911512
1143011513 if (false) // DrawMode() == SHADOW)
....@@ -12318,7 +12401,74 @@
1231812401 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1231912402
1232012403 String program =
12404
+ // Min shader
1232112405 "!!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
+
1232212472 //"OPTION ARB_fragment_program_shadow;" +
1232312473 "PARAM light2cam0 = program.env[10];" +
1232412474 "PARAM light2cam1 = program.env[11];" +
....@@ -12433,8 +12583,7 @@
1243312583 "TEMP shininess;" +
1243412584 "\n" +
1243512585 "MOV texSamp, one;" +
12436
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12437
-
12586
+
1243812587 "MOV mapgrid.x, one2048th.x;" +
1243912588 "MOV temp, fragment.texcoord[1];" +
1244012589 /*
....@@ -12455,20 +12604,20 @@
1245512604 "MUL temp, floor, mapgrid.x;" +
1245612605 //"TEX depth0, temp, texture[1], 2D;" +
1245712606 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12458
- TextureFetch("depth0", "temp", "1") +
12607
+ ShadowTextureFetch("depth0", "temp", "1") +
1245912608 "") +
1246012609 "ADD temp.x, temp.x, mapgrid.x;" +
1246112610 //"TEX depth1, temp, texture[1], 2D;" +
1246212611 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12463
- TextureFetch("depth1", "temp", "1") +
12612
+ ShadowTextureFetch("depth1", "temp", "1") +
1246412613 "") +
1246512614 "ADD temp.y, temp.y, mapgrid.x;" +
1246612615 //"TEX depth2, temp, texture[1], 2D;" +
12467
- TextureFetch("depth2", "temp", "1") +
12616
+ ShadowTextureFetch("depth2", "temp", "1") +
1246812617 "SUB temp.x, temp.x, mapgrid.x;" +
1246912618 //"TEX depth3, temp, texture[1], 2D;" +
1247012619 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12471
- TextureFetch("depth3", "temp", "1") +
12620
+ ShadowTextureFetch("depth3", "temp", "1") +
1247212621 "") +
1247312622 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1247412623 //"MOV params, material;" +
....@@ -12839,7 +12988,7 @@
1283912988 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1284012989 "") +
1284112990
12842
- // display shadow only (bump == 0)
12991
+ // display shadow only (fakedepth == 0)
1284312992 "SUB temp.x, half.x, shadow.x;" +
1284412993 "MOV temp.y, -params5.z;" + // params6.x;" +
1284512994 "SLT temp.z, temp.y, -one2048th.x;" +
....@@ -13266,25 +13415,26 @@
1326613415 return out;
1326713416 }
1326813417
13269
- String TextureFetch(String dest, String src, String unit)
13418
+ // Also does frustum culling
13419
+ String ShadowTextureFetch(String dest, String src, String unit)
1327013420 {
1327113421 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1327213422 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1327313423 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13424
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13425
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1327413426 "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;" +
1327913429 //"SWZ buffer, temp, w,w,w,w;";
13280
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13430
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1328113431 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1328213432 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1328313433 //"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;";
1328513435
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;";
1328813438 }
1328913439
1329013440 String Shadow(String depth, String shadow)
....@@ -13331,7 +13481,7 @@
1333113481 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1333213482 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1333313483
13334
- // No shadow when out of frustrum
13484
+ // No shadow when out of frustum
1333513485 "SGE temp.x, " + depth + ".z, one.z;" +
1333613486 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1333713487 "";
....@@ -14129,14 +14279,15 @@
1412914279 drag = false;
1413014280 //System.out.println("Mouse DOWN");
1413114281 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);
1414014291 if (!editObj)
1414114292 {
1414214293 hasMarquee = true;
....@@ -14536,15 +14687,16 @@
1453614687 if (editObj)
1453714688 {
1453814689 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,
1454114692 (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);
1454814700 } else
1454914701 {
1455014702 if (x < startX)
....@@ -14693,24 +14845,27 @@
1469314845 }
1469414846 }
1469514847
14848
+// ClickInfo clickInfo = new ClickInfo();
14849
+
1469614850 public void mouseMoved(MouseEvent e)
1469714851 {
1469814852 //System.out.println("mouseMoved: " + e);
1469914853 if (isRenderer)
1470014854 return;
1470114855
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;
1470914863 if (!isRenderer)
1471014864 {
1471114865 //ObjEditor editWindow = object.editWindow;
1471214866 //Object3D copy = editWindow.copy;
14713
- if (object.doEditClick(ci, 0))
14867
+ if (object.doEditClick(//clickInfo,
14868
+ 0))
1471414869 {
1471514870 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1471614871 } else
....@@ -15736,8 +15891,6 @@
1573615891
1573715892 int width = getBounds().width;
1573815893 int height = getBounds().height;
15739
- ClickInfo info = new ClickInfo();
15740
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1574115894 //Image img = CreateImage(width, height);
1574215895 //System.out.println("width = " + width + "; height = " + height + "\n");
1574315896
....@@ -15814,31 +15967,37 @@
1581415967 }
1581515968 if (object != null && !hasMarquee)
1581615969 {
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
+
1581715976 if (isRenderer)
1581815977 {
15819
- info.flags++;
15978
+ object.clickInfo.flags++;
1582015979 double frameAspect = (double) width / (double) height;
1582115980 if (frameAspect > renderCamera.aspect)
1582215981 {
1582315982 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;
1582615985 } else
1582715986 {
1582815987 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;
1583115990 }
1583215991 }
1583315992
15834
- info.g = gr;
15835
- info.camera = renderCamera;
15993
+ object.clickInfo.g = gr;
15994
+ object.clickInfo.camera = renderCamera;
1583615995 /*
1583715996 // Memory intensive (brep.verticescopy)
1583815997 if (!(object instanceof Composite))
1583915998 object.draw(info, 0, false); // SLOW :
1584015999 */
15841
- if (!isRenderer)
16000
+ if (!isRenderer) // && drag)
1584216001 {
1584316002 Grafreed.Assert(object != null);
1584416003 Grafreed.Assert(object.selection != null);
....@@ -15846,9 +16005,9 @@
1584616005 {
1584716006 int hitSomething = object.selection.get(0).hitSomething;
1584816007
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;
1585216011 if (hitSomething == Object3D.hitCenter)
1585316012 {
1585416013 info.DX = X;
....@@ -15860,7 +16019,8 @@
1586016019 info.DY -= info.bounds.height/2;
1586116020 }
1586216021
15863
- object.drawEditHandles(info, 0);
16022
+ object.drawEditHandles(//info,
16023
+ 0);
1586416024
1586516025 if (drag && (X != 0 || Y != 0))
1586616026 {
....@@ -15873,7 +16033,7 @@
1587316033 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1587416034 break;
1587516035 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);
1587716037 break;
1587816038 }
1587916039