From d7bc8865056ea0d35df261e719f92e1422af7c6e Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 05 May 2019 09:00:26 -0400 Subject: [PATCH] Fix Windows issues. --- CameraPane.java | 16 +++-- GroupEditor.java | 4 + GrafreeD.java | 4 cFileSystemPane.java | 2 Mocap.java | 35 ++++++++--- Object3D.java | 68 ++++++++++++++++++++-- 6 files changed, 102 insertions(+), 27 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index e5811ae..83bde94 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -8075,12 +8075,16 @@ { String texname = tex; - String[] split = tex.split("Textures"); - if (split.length > 1) - texname = "/Users/nbriere/Textures" + split[split.length-1]; - else - if (!texname.startsWith("/")) - texname = "/Users/nbriere/Textures/" + texname; +// String[] split = tex.split("Textures"); +// if (split.length > 1) +// texname = "/Users/nbriere/Textures" + split[split.length-1]; +// else +// if (!texname.startsWith("/")) +// texname = "/Users/nbriere/Textures/" + texname; + if (!new File(tex).exists()) + { + texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; + } if (CACHETEXTURE) texture = textures.get(texname); // TEXTURE CACHE diff --git a/GrafreeD.java b/GrafreeD.java index d82d57e..6485281 100644 --- a/GrafreeD.java +++ b/GrafreeD.java @@ -612,7 +612,7 @@ System.out.println("jarfile0 = " + jarfile); - String jarpath = u.toString().split("file:")[1].split("GrafreeD.jar")[0]; + String jarpath = u.toString().split("file:")[1].split("Grafreed.jar")[0]; System.out.println("jarpath0 = " + jarpath); @@ -845,7 +845,7 @@ standAlone = true; grafreeD = new GrafreeD(); grafreeD.universe = new Composite(); - grafreeD.universe.name = "Scene"; + grafreeD.universe.name = "Grafreed"; grafreeD.universe.material = new cMaterial(); // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; diff --git a/GroupEditor.java b/GroupEditor.java index 6995fb1..cbd2ec6 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -940,7 +940,9 @@ // objEditor.DropFile((java.io.File[]) object, true); // return; // } - if (string.charAt(0) == '/') + + // File path for Mac and Windows + if (string.charAt(0) == '/' || string.charAt(1) == ':') { // file(s) String[] names = string.split("\n"); diff --git a/Mocap.java b/Mocap.java index 0bbe7d9..fc0ff2e 100644 --- a/Mocap.java +++ b/Mocap.java @@ -3299,23 +3299,40 @@ // SetPositionDelta(false, true, false); // ?? false); { if (support == null) - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); + { + if (new File(fullname).exists()) + ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); + else + { + SetGlobalTransform(); + Rewind(); + Fade(); + } + } else { - try - { +// try +// { bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh; // SetPositionDelta(false, true, true, true); LoadData(); Rewind(); Fade(); - } - catch (Exception e) - { - e.printStackTrace(); - ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); - } +// } +// catch (Exception e) +// { +// System.err.println("An error occured while loading data. Use fallback by loading the file."); +// //e.printStackTrace(); +// try +// { +// ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest); +// } +// catch (Exception e2) +// { +// System.err.println("Motion file not found: " + fullname); +// } +// } } } diff --git a/Object3D.java b/Object3D.java index 1478589..2b543d0 100644 --- a/Object3D.java +++ b/Object3D.java @@ -5159,10 +5159,34 @@ // System.out.println("Fullname = " + fullname); - if (fullname.name.indexOf(":") == -1) - return fullname.name; + // Does not work on Windows due to C: +// if (fullname.name.indexOf(":") == -1) +// return fullname.name; +// +// return fullname.name.substring(0,fullname.name.indexOf(":")); - return fullname.name.substring(0,fullname.name.indexOf(":")); + String[] split = fullname.name.split(":"); + + if (split.length == 0) + { + return ""; + } + + if (split.length <= 2) + { + if (fullname.name.endsWith(":")) + { + // Windows + return fullname.name.substring(0, fullname.name.length()-1); + } + + return split[0]; + } + + // Windows + assert(split.length == 4); + + return split[0] + ":" + split[1]; } static String GetBump(cTexture fullname) @@ -5171,10 +5195,38 @@ return ""; // System.out.println("Fullname = " + fullname); - if (fullname.name.indexOf(":") == -1) - return ""; - - return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); + // Does not work on Windows due to C: +// if (fullname.name.indexOf(":") == -1) +// return ""; +// +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); + String[] split = fullname.name.split(":"); + + if (split.length == 0) + { + return ""; + } + + if (split.length == 1) + { + return ""; + } + + if (split.length == 2) + { + if (fullname.name.endsWith(":")) + { + // Windows + return ""; + } + + return split[1]; + } + + // Windows + assert(split.length == 4); + + return split[2] + ":" + split[3]; } String GetPigmentTexture() @@ -5248,7 +5300,7 @@ System.out.print("; textures = " + textures); System.out.println("; usedtextures = " + usedtextures); - if (GetTextures() == null) + if (GetTextures() == null) // What is that?? GetTextures().name = ":"; String texname = tex; diff --git a/cFileSystemPane.java b/cFileSystemPane.java index a446d0f..9b42459 100644 --- a/cFileSystemPane.java +++ b/cFileSystemPane.java @@ -136,7 +136,7 @@ jTree.setModel(new cFileSystemModel( //java.io.File.listRoots()[1]) - javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(), + javax.swing.filechooser.FileSystemView.getFileSystemView().getHomeDirectory(), filter )); } -- Gitblit v1.6.2