Normand Briere
2019-06-17 13e9febe94aaeebad9c97f6d3e2aa4d73b2495c8
CameraPane.java
....@@ -150,6 +150,8 @@
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152152
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154
+
153155 void SetAsGLRenderer(boolean b)
154156 {
155157 isRenderer = b;
....@@ -462,7 +464,7 @@
462464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463465 {
464466 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
466468 if (!hasnorm)
467469 {
468470 // System.out.println("FUCK!!");
....@@ -1888,7 +1890,7 @@
18881890 void PushMatrix(double[][] matrix)
18891891 {
18901892 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
18921894 }
18931895
18941896 void PushMatrix()
....@@ -2265,7 +2267,7 @@
22652267 LOOKAT ^= true;
22662268 }
22672269
2268
- void ToggleRandom()
2270
+ void ToggleSwitch()
22692271 {
22702272 SWITCH ^= true;
22712273 }
....@@ -2374,7 +2376,7 @@
23742376 {
23752377 return currentGL;
23762378 }
2377
-
2379
+
23782380 /**/
23792381 class CacheTexture
23802382 {
....@@ -8067,6 +8069,26 @@
80678069 return; // true;
80688070 }
80698071
8072
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8073
+
8074
+ private boolean FileExists(String tex)
8075
+ {
8076
+ if (missingTextures.contains(tex))
8077
+ {
8078
+ return false;
8079
+ }
8080
+
8081
+ boolean fileExists = new File(tex).exists();
8082
+
8083
+ if (!fileExists)
8084
+ {
8085
+ // If file exists, the "new File()" is not executed sgain
8086
+ missingTextures.add(tex);
8087
+ }
8088
+
8089
+ return fileExists;
8090
+ }
8091
+
80708092 CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718093 {
80728094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
....@@ -8075,15 +8097,17 @@
80758097 {
80768098 String texname = tex;
80778099
8100
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8101
+
80788102 // String[] split = tex.split("Textures");
80798103 // if (split.length > 1)
80808104 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818105 // else
80828106 // if (!texname.startsWith("/"))
80838107 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8108
+ if (!FileExists(tex))
80858109 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8110
+ texname = fallbackTextureName;
80878111 }
80888112
80898113 if (CACHETEXTURE)
....@@ -8153,7 +8177,7 @@
81538177 }
81548178
81558179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
81578181 cachename = texname;
81588182 else
81598183 processbump = false; // don't process bump map again
....@@ -8175,7 +8199,7 @@
81758199 }
81768200
81778201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
81798203 cachename = texname;
81808204 else
81818205 processbump = false; // don't process bump map again
....@@ -9310,8 +9334,8 @@
93109334 assert (parentcam != renderCamera);
93119335
93129336 if (renderCamera != lightCamera)
9313
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9314
- LA.matConcat(matrix, parentcam.toParent, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93159339
93169340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93179341
....@@ -9326,8 +9350,8 @@
93269350 LA.matCopy(renderCamera.fromScreen, matrix);
93279351
93289352 if (renderCamera != lightCamera)
9329
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9330
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93319355
93329356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93339357
....@@ -10392,13 +10416,13 @@
1039210416 ambientOcclusion = false;
1039310417 }
1039410418
10395
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039610420 {
1039710421 //if (RENDERSHADOW) // ?
1039810422 if (!IsFrozen())
1039910423 {
1040010424 // dec 2012
10401
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040210426 {
1040310427 Globals.framecount++;
1040410428 shadowbuffer.display();
....@@ -10525,8 +10549,8 @@
1052510549
1052610550 // if (parentcam != renderCamera) // not a light
1052710551 if (cam != lightCamera)
10528
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10529
- LA.matConcat(matrix, parentcam.toParent, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1053010554
1053110555 for (int j = 0; j < 4; j++)
1053210556 {
....@@ -10540,8 +10564,8 @@
1054010564
1054110565 // if (parentcam != renderCamera) // not a light
1054210566 if (cam != lightCamera)
10543
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10544
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054510569
1054610570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054710571
....@@ -10934,8 +10958,8 @@
1093410958 System.err.println("parentcam != renderCamera");
1093510959
1093610960 // if (cam != lightCamera)
10937
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10938
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
10961
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1093910963 }
1094010964
1094110965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10956,8 +10980,8 @@
1095610980 if (true) // TODO
1095710981 {
1095810982 if (cam != lightCamera)
10959
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10960
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
10983
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1096110985 }
1096210986
1096310987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11552,7 +11576,7 @@
1155211576 return;
1155311577 }
1155411578
11555
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
1155611580
1155711581 GL gl = GetGL();
1155811582
....@@ -11869,8 +11893,8 @@
1186911893 //obj.TransformToWorld(light, light);
1187011894 for (int i = tp.size(); --i >= 0;)
1187111895 {
11872
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11873
- LA.xformPos(light, tp.get(i).toParent, light);
11896
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1187411898 }
1187511899
1187611900
....@@ -11887,8 +11911,8 @@
1188711911 parentcam = cameras[0];
1188811912 }
1188911913
11890
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11891
- LA.xformPos(light, parentcam.toParent, light); // may 2013
11914
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1189211916
1189311917 LA.xformPos(light, renderCamera.toScreen, light);
1189411918
....@@ -13809,9 +13833,12 @@
1380913833
1381013834 public void mouseDragged(MouseEvent e)
1381113835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
1381213838 //System.out.println("mouseDragged: " + e);
1381313839 if (isRenderer)
1381413840 movingcamera = true;
13841
+
1381513842 //if (drawing)
1381613843 //return;
1381713844 if ((e.getModifiersEx() & CTRL) != 0
....@@ -14373,7 +14400,10 @@
1437314400
1437414401 public void mouseReleased(MouseEvent e)
1437514402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1437614405 movingcamera = false;
14406
+ X = Y = 0;
1437714407 //System.out.println("mouseReleased: " + e);
1437814408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1437914409 }
....@@ -15382,7 +15412,9 @@
1538215412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1538315413 //Image img = CreateImage(width, height);
1538415414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1538515416 Graphics gr = g; // img.getGraphics();
15417
+
1538615418 if (!hasMarquee)
1538715419 {
1538815420 if (Xmin < Xmax) // !locked)
....@@ -15480,14 +15512,33 @@
1548015512 if (!isRenderer)
1548115513 {
1548215514 object.drawEditHandles(info, 0);
15515
+
15516
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15517
+ {
15518
+ switch (object.selection.get(0).hitSomething)
15519
+ {
15520
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15521
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15522
+ break;
15523
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15524
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15525
+ break;
15526
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15527
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15528
+ break;
15529
+ }
15530
+
15531
+ }
1548315532 }
1548415533 }
15534
+
1548515535 if (isRenderer)
1548615536 {
1548715537 //gr.setColor(Color.black);
1548815538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1548915539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1549015540 }
15541
+
1549115542 if (hasMarquee)
1549215543 {
1549315544 gr.setXORMode(Color.white);
....@@ -15894,7 +15945,7 @@
1589415945 Object3D object;
1589515946 static Object3D trackedobject;
1589615947 Camera renderCamera; // Light or Eye (or Occlusion)
15897
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1589815949 /*static*/ Camera eyeCamera;
1589915950 /*static*/ Camera lightCamera;
1590015951 int cameracount;