Normand Briere
2019-05-05 d7bc8865056ea0d35df261e719f92e1422af7c6e
Fix Windows issues.
6 files modified
129 ■■■■ changed files
CameraPane.java 16 ●●●●● patch | view | raw | blame | history
GrafreeD.java 4 ●●●● patch | view | raw | blame | history
GroupEditor.java 4 ●●● patch | view | raw | blame | history
Mocap.java 35 ●●●● patch | view | raw | blame | history
Object3D.java 68 ●●●● patch | view | raw | blame | history
cFileSystemPane.java 2 ●●● patch | view | raw | blame | history
CameraPane.java
....@@ -8075,12 +8075,16 @@
80758075 {
80768076 String texname = tex;
80778077
8078
- String[] split = tex.split("Textures");
8079
- if (split.length > 1)
8080
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
- else
8082
- if (!texname.startsWith("/"))
8083
- texname = "/Users/nbriere/Textures/" + texname;
8078
+// String[] split = tex.split("Textures");
8079
+// if (split.length > 1)
8080
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
+// else
8082
+// if (!texname.startsWith("/"))
8083
+// texname = "/Users/nbriere/Textures/" + texname;
8084
+ if (!new File(tex).exists())
8085
+ {
8086
+ texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8087
+ }
80848088
80858089 if (CACHETEXTURE)
80868090 texture = textures.get(texname); // TEXTURE CACHE
GrafreeD.java
....@@ -612,7 +612,7 @@
612612
613613 System.out.println("jarfile0 = " + jarfile);
614614
615
- String jarpath = u.toString().split("file:")[1].split("GrafreeD.jar")[0];
615
+ String jarpath = u.toString().split("file:")[1].split("Grafreed.jar")[0];
616616
617617 System.out.println("jarpath0 = " + jarpath);
618618
....@@ -845,7 +845,7 @@
845845 standAlone = true;
846846 grafreeD = new GrafreeD();
847847 grafreeD.universe = new Composite();
848
- grafreeD.universe.name = "Scene";
848
+ grafreeD.universe.name = "Grafreed";
849849 grafreeD.universe.material = new cMaterial();
850850 // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE;
851851
GroupEditor.java
....@@ -940,7 +940,9 @@
940940 // objEditor.DropFile((java.io.File[]) object, true);
941941 // return;
942942 // }
943
- if (string.charAt(0) == '/')
943
+
944
+ // File path for Mac and Windows
945
+ if (string.charAt(0) == '/' || string.charAt(1) == ':')
944946 {
945947 // file(s)
946948 String[] names = string.split("\n");
Mocap.java
....@@ -3299,23 +3299,40 @@
32993299 // SetPositionDelta(false, true, false); // ?? false);
33003300 {
33013301 if (support == null)
3302
- ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3302
+ {
3303
+ if (new File(fullname).exists())
3304
+ ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3305
+ else
3306
+ {
3307
+ SetGlobalTransform();
3308
+ Rewind();
3309
+ Fade();
3310
+ }
3311
+ }
33033312 else
33043313 {
3305
- try
3306
- {
3314
+// try
3315
+// {
33073316 bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh;
33083317
33093318 // SetPositionDelta(false, true, true, true);
33103319 LoadData();
33113320 Rewind();
33123321 Fade();
3313
- }
3314
- catch (Exception e)
3315
- {
3316
- e.printStackTrace();
3317
- ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3318
- }
3322
+// }
3323
+// catch (Exception e)
3324
+// {
3325
+// System.err.println("An error occured while loading data. Use fallback by loading the file.");
3326
+// //e.printStackTrace();
3327
+// try
3328
+// {
3329
+// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
3330
+// }
3331
+// catch (Exception e2)
3332
+// {
3333
+// System.err.println("Motion file not found: " + fullname);
3334
+// }
3335
+// }
33193336 }
33203337 }
33213338
Object3D.java
....@@ -5159,10 +5159,34 @@
51595159
51605160 // System.out.println("Fullname = " + fullname);
51615161
5162
- if (fullname.name.indexOf(":") == -1)
5163
- return fullname.name;
5162
+ // Does not work on Windows due to C:
5163
+// if (fullname.name.indexOf(":") == -1)
5164
+// return fullname.name;
5165
+//
5166
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51645167
5165
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5168
+ String[] split = fullname.name.split(":");
5169
+
5170
+ if (split.length == 0)
5171
+ {
5172
+ return "";
5173
+ }
5174
+
5175
+ if (split.length <= 2)
5176
+ {
5177
+ if (fullname.name.endsWith(":"))
5178
+ {
5179
+ // Windows
5180
+ return fullname.name.substring(0, fullname.name.length()-1);
5181
+ }
5182
+
5183
+ return split[0];
5184
+ }
5185
+
5186
+ // Windows
5187
+ assert(split.length == 4);
5188
+
5189
+ return split[0] + ":" + split[1];
51665190 }
51675191
51685192 static String GetBump(cTexture fullname)
....@@ -5171,10 +5195,38 @@
51715195 return "";
51725196
51735197 // System.out.println("Fullname = " + fullname);
5174
- if (fullname.name.indexOf(":") == -1)
5175
- return "";
5176
-
5177
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5198
+ // Does not work on Windows due to C:
5199
+// if (fullname.name.indexOf(":") == -1)
5200
+// return "";
5201
+//
5202
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5203
+ String[] split = fullname.name.split(":");
5204
+
5205
+ if (split.length == 0)
5206
+ {
5207
+ return "";
5208
+ }
5209
+
5210
+ if (split.length == 1)
5211
+ {
5212
+ return "";
5213
+ }
5214
+
5215
+ if (split.length == 2)
5216
+ {
5217
+ if (fullname.name.endsWith(":"))
5218
+ {
5219
+ // Windows
5220
+ return "";
5221
+ }
5222
+
5223
+ return split[1];
5224
+ }
5225
+
5226
+ // Windows
5227
+ assert(split.length == 4);
5228
+
5229
+ return split[2] + ":" + split[3];
51785230 }
51795231
51805232 String GetPigmentTexture()
....@@ -5248,7 +5300,7 @@
52485300 System.out.print("; textures = " + textures);
52495301 System.out.println("; usedtextures = " + usedtextures);
52505302
5251
- if (GetTextures() == null)
5303
+ if (GetTextures() == null) // What is that??
52525304 GetTextures().name = ":";
52535305
52545306 String texname = tex;
cFileSystemPane.java
....@@ -136,7 +136,7 @@
136136
137137 jTree.setModel(new cFileSystemModel(
138138 //java.io.File.listRoots()[1])
139
- javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(),
139
+ javax.swing.filechooser.FileSystemView.getFileSystemView().getHomeDirectory(),
140140 filter
141141 ));
142142 }