Normand Briere
2019-06-16 b33ef80d78f01a6a61f4248b1bb7deaade42d503
Attribute editor
6 files modified
142 ■■■■■ changed files
AttributeEditor.java 28 ●●●●● patch | view | raw | blame | history
Camera.java 1 ●●●● patch | view | raw | blame | history
CameraPane.java 71 ●●●●● patch | view | raw | blame | history
Globals.java 2 ●●●●● patch | view | raw | blame | history
ObjEditor.java 21 ●●●●● patch | view | raw | blame | history
Object3D.java 19 ●●●● patch | view | raw | blame | history
AttributeEditor.java
....@@ -41,20 +41,24 @@
4141 super.SetupUI2(oe); // Shows composite UI !!
4242 //super.SetupName(oe);
4343
44
- oe.aConstraints.weighty = 0;
45
-
46
- oe.aConstraints.gridwidth = 1;
47
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
48
- oe.aConstraints.gridwidth = 1;
49
- oe.aConstraints.anchor = GridBagConstraints.WEST;
50
- oe.ctrlPanel.add(cleardepth = new JCheckBox("Clear Depth", attribute.cleardepth), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
51
- oe.aConstraints.gridx += 1;
44
+// oe.aConstraints.weighty = 0;
45
+//
46
+// oe.aConstraints.gridwidth = 1;
47
+// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
48
+// oe.aConstraints.gridwidth = 1;
49
+// oe.aConstraints.anchor = GridBagConstraints.WEST;
50
+ oe.ctrlPanel.add(cleardepth = new JCheckBox("Clear Depth", attribute.cleardepth)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
51
+
52
+ oe.ctrlPanel.Return();
53
+// oe.aConstraints.gridx += 1;
5254 // oe.ctrlPanel.add(passtest = new JCheckBox("Write depth", attribute.passtest), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
5355 // oe.aConstraints.gridx += 1;
54
- oe.ctrlPanel.add(passtest = new JCheckBox("Pass Test", attribute.passtest), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
55
- oe.aConstraints.gridx += 1;
56
- oe.ctrlPanel.add(backfacecull = new JCheckBox("Backface Cull", attribute.backfacecull), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
57
- oe.aConstraints.gridx += 1;
56
+ oe.ctrlPanel.add(passtest = new JCheckBox("Pass Test", attribute.passtest)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
57
+ oe.ctrlPanel.Return();
58
+// oe.aConstraints.gridx += 1;
59
+ oe.ctrlPanel.add(backfacecull = new JCheckBox("Backface Cull", attribute.backfacecull)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
60
+ oe.ctrlPanel.Return();
61
+// oe.aConstraints.gridx += 1;
5862
5963 cleardepth.addItemListener(this);
6064 passtest.addItemListener(this);
Camera.java
....@@ -3,7 +3,6 @@
33 // Decompiler options: packimports(3)
44 // Source File Name: Camera.java
55
6
-
76 class Camera extends Object3D
87 {
98 static final long serialVersionUID = 4754289789178680517L;
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!!");
....@@ -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.GlobalTransformInv(), 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.GlobalTransform(), matrix, matrix);
93319355
93329356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93339357
....@@ -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.GlobalTransformInv(), 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.GlobalTransform(), 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.GlobalTransformInv(), 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.GlobalTransformInv(), light0); // may 2013
1096110985 }
1096210986
1096310987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -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).GlobalTransformInv(), 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.GlobalTransformInv(), light); // may 2013
1189211916
1189311917 LA.xformPos(light, renderCamera.toScreen, light);
1189411918
....@@ -13812,6 +13836,7 @@
1381213836 //System.out.println("mouseDragged: " + e);
1381313837 if (isRenderer)
1381413838 movingcamera = true;
13839
+
1381513840 //if (drawing)
1381613841 //return;
1381713842 if ((e.getModifiersEx() & CTRL) != 0
....@@ -15911,7 +15936,7 @@
1591115936 Object3D object;
1591215937 static Object3D trackedobject;
1591315938 Camera renderCamera; // Light or Eye (or Occlusion)
15914
- /*static*/ Camera manipCamera; // Light or Eye
15939
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1591515940 /*static*/ Camera eyeCamera;
1591615941 /*static*/ Camera lightCamera;
1591715942 int cameracount;
Globals.java
....@@ -7,6 +7,8 @@
77
88 private static boolean LIVE = false;
99 public static boolean RENDERSHADOW = true;
10
+
11
+ // Hold on calculation when moving camera
1012 public static boolean FREEZEONMOVE = false; // true;
1113
1214 static boolean CROWD = false;
ObjEditor.java
....@@ -278,7 +278,7 @@
278278 frame.setMenuBar(menuBar = new MenuBar());
279279 menuBar.add(fileMenu = new Menu("File"));
280280 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
281
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282282
283283 //oe.menuBar.add(menu = new Menu("Include"));
284284 Menu menu = new Menu("Import");
....@@ -2072,19 +2072,19 @@
20722072
20732073 void LoadObjFile(String fullname)
20742074 {
2075
- /*
2075
+ System.out.println("Loading " + fullname);
2076
+ /**/
20762077 //lastFilename = fullname;
20772078 if(loadObjThread == null)
20782079 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2080
+ loadObjThread = new LoadOBJThread();
2081
+ loadObjThread.start();
20812082 }
20822083
20832084 loadObjThread.add(fullname);
2084
- */
2085
+ /**/
20852086
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2087
+ //makeSomething(new FileObject(fullname, true), true);
20882088 }
20892089
20902090 void LoadGFDFile(String fullname)
....@@ -3214,7 +3214,7 @@
32143214 objEditor.refreshContents();
32153215 }
32163216
3217
- static public byte[] Compress(Object o)
3217
+ static public byte[] Compress(Object3D o)
32183218 {
32193219 try
32203220 {
....@@ -3222,8 +3222,13 @@
32223222 java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
32233223 ObjectOutputStream out = new ObjectOutputStream(zstream);
32243224
3225
+ Object3D parent = o.parent;
3226
+ o.parent = null;
3227
+
32253228 out.writeObject(o);
32263229
3230
+ o.parent = parent;
3231
+
32273232 out.flush();
32283233
32293234 zstream.close();
Object3D.java
....@@ -174,7 +174,7 @@
174174 {
175175 Object3D o = hashtable.get(GetUUID());
176176
177
- assert(this.bRep == o.bRep);
177
+ Grafreed.Assert(this.bRep == o.bRep);
178178 if (this.bRep != null)
179179 assert(this.bRep.support == o.transientrep);
180180
....@@ -563,12 +563,14 @@
563563 toParent = LA.newMatrix();
564564 fromParent = LA.newMatrix();
565565 }
566
+
566567 if (toParentMarked == null)
567568 {
568569 if (maxcount != 1)
569570 {
570571 new Exception().printStackTrace();
571572 }
573
+
572574 toParentMarked = LA.newMatrix();
573575 fromParentMarked = LA.newMatrix();
574576 }
....@@ -5572,12 +5574,23 @@
55725574 boolean NeedSupport()
55735575 {
55745576 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5577
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765578 // PROBLEM with CROWD!!
55775579 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785580 }
55795581
55805582 static boolean DEBUG_SELECTION = false;
5583
+
5584
+ boolean IsLive()
5585
+ {
5586
+ if (live)
5587
+ return true;
5588
+
5589
+ if (parent == null)
5590
+ return false;
5591
+
5592
+ return parent.IsLive();
5593
+ }
55815594
55825595 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835596 {
....@@ -5640,7 +5653,7 @@
56405653 support = support;
56415654
56425655 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5643
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5656
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445657
56455658 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465659 {