.. | .. |
---|
168 | 168 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 169 | |
---|
170 | 170 | objEditor.ctrlPanel.remove(setupPanel); |
---|
| 171 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
171 | 172 | objEditor.ctrlPanel.remove(commandsPanel); |
---|
172 | 173 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 174 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
.. | .. |
---|
278 | 279 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 280 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 281 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 282 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 283 | |
---|
283 | 284 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 285 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
419 | 420 | e.printStackTrace(); |
---|
420 | 421 | } |
---|
421 | 422 | |
---|
422 | | - String selection = infoarea.getText(); |
---|
423 | | - java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
424 | | - java.awt.datatransfer.Clipboard clipboard = |
---|
425 | | - Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 423 | +// String selection = infoarea.getText(); |
---|
| 424 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 425 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 426 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 427 | //clipboard.setContents(data, data); |
---|
427 | 428 | } |
---|
428 | 429 | |
---|
.. | .. |
---|
747 | 748 | |
---|
748 | 749 | cGridBag namePanel; |
---|
749 | 750 | cGridBag setupPanel; |
---|
| 751 | + cGridBag setupPanel2; |
---|
750 | 752 | cGridBag commandsPanel; |
---|
751 | 753 | cGridBag pushPanel; |
---|
752 | 754 | cGridBag fillPanel; |
---|
.. | .. |
---|
939 | 941 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | 942 | markCB.setToolTipText("Set the animation target transform"); |
---|
941 | 943 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 944 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 945 | + |
---|
| 946 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 947 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 948 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 949 | + randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 950 | + randomCB.setToolTipText("Rewind or Go back and forth randomly"); |
---|
947 | 951 | |
---|
948 | 952 | if (Globals.ADVANCED) |
---|
949 | 953 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
| 954 | + link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
951 | 955 | link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 956 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 957 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 958 | } |
---|
955 | 959 | |
---|
956 | 960 | oe.ctrlPanel.add(setupPanel); |
---|
| 961 | + oe.ctrlPanel.Return(); |
---|
| 962 | + oe.ctrlPanel.add(setupPanel2); |
---|
957 | 963 | oe.ctrlPanel.Return(); |
---|
958 | 964 | |
---|
959 | 965 | commandsPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
1935 | 1941 | e2.printStackTrace(); |
---|
1936 | 1942 | } |
---|
1937 | 1943 | } |
---|
| 1944 | + |
---|
1938 | 1945 | LoadJMEThread loadThread; |
---|
1939 | 1946 | |
---|
1940 | 1947 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 1999 | //LoadFile0(filename, converter); |
---|
1993 | 2000 | } |
---|
1994 | 2001 | } |
---|
| 2002 | + |
---|
1995 | 2003 | LoadOBJThread loadObjThread; |
---|
1996 | 2004 | |
---|
1997 | 2005 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
2070 | 2078 | |
---|
2071 | 2079 | void LoadObjFile(String fullname) |
---|
2072 | 2080 | { |
---|
2073 | | - /* |
---|
| 2081 | + System.out.println("Loading " + fullname); |
---|
| 2082 | + /**/ |
---|
2074 | 2083 | //lastFilename = fullname; |
---|
2075 | 2084 | if(loadObjThread == null) |
---|
2076 | 2085 | { |
---|
2077 | | - loadObjThread = new LoadOBJThread(); |
---|
2078 | | - loadObjThread.start(); |
---|
| 2086 | + loadObjThread = new LoadOBJThread(); |
---|
| 2087 | + loadObjThread.start(); |
---|
2079 | 2088 | } |
---|
2080 | 2089 | |
---|
2081 | 2090 | loadObjThread.add(fullname); |
---|
2082 | | - */ |
---|
| 2091 | + /**/ |
---|
2083 | 2092 | |
---|
2084 | | - System.out.println("Loading " + fullname); |
---|
2085 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2093 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2086 | 2094 | } |
---|
2087 | 2095 | |
---|
2088 | 2096 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2925 | 2933 | return; |
---|
2926 | 2934 | } else if (event.getSource() == toggleSwitchItem) |
---|
2927 | 2935 | { |
---|
2928 | | - cameraView.ToggleRandom(); |
---|
| 2936 | + cameraView.ToggleSwitch(); |
---|
2929 | 2937 | cameraView.repaint(); |
---|
2930 | 2938 | return; |
---|
2931 | 2939 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3207 | 3215 | { |
---|
3208 | 3216 | copy.remove(1); |
---|
3209 | 3217 | } |
---|
| 3218 | + |
---|
3210 | 3219 | ResetModel(); |
---|
3211 | 3220 | objEditor.refreshContents(); |
---|
3212 | 3221 | } |
---|
3213 | 3222 | |
---|
| 3223 | + static public byte[] Compress(Object3D o) |
---|
| 3224 | + { |
---|
| 3225 | + try |
---|
| 3226 | + { |
---|
| 3227 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3228 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3229 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3230 | + |
---|
| 3231 | + Object3D parent = o.parent; |
---|
| 3232 | + o.parent = null; |
---|
| 3233 | + |
---|
| 3234 | + out.writeObject(o); |
---|
| 3235 | + |
---|
| 3236 | + o.parent = parent; |
---|
| 3237 | + |
---|
| 3238 | + out.flush(); |
---|
| 3239 | + |
---|
| 3240 | + zstream.close(); |
---|
| 3241 | + out.close(); |
---|
| 3242 | + |
---|
| 3243 | + return baos.toByteArray(); |
---|
| 3244 | + } catch (Exception e) |
---|
| 3245 | + { |
---|
| 3246 | + System.err.println(e); |
---|
| 3247 | + return null; |
---|
| 3248 | + } |
---|
| 3249 | + } |
---|
| 3250 | + |
---|
| 3251 | + static public Object Uncompress(byte[] bytes) |
---|
| 3252 | + { |
---|
| 3253 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3254 | + try |
---|
| 3255 | + { |
---|
| 3256 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3257 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3258 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3259 | + Object obj = in.readObject(); |
---|
| 3260 | + in.close(); |
---|
| 3261 | + |
---|
| 3262 | + return obj; |
---|
| 3263 | + } catch (Exception e) |
---|
| 3264 | + { |
---|
| 3265 | + System.err.println(e); |
---|
| 3266 | + return null; |
---|
| 3267 | + } |
---|
| 3268 | + } |
---|
| 3269 | + |
---|
| 3270 | + static public Object clone(Object o) |
---|
| 3271 | + { |
---|
| 3272 | + try |
---|
| 3273 | + { |
---|
| 3274 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3275 | + ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3276 | + |
---|
| 3277 | + out.writeObject(o); |
---|
| 3278 | + |
---|
| 3279 | + out.flush(); |
---|
| 3280 | + out.close(); |
---|
| 3281 | + |
---|
| 3282 | + byte[] bytes = baos.toByteArray(); |
---|
| 3283 | + |
---|
| 3284 | + System.out.println("clone = " + bytes.length); |
---|
| 3285 | + |
---|
| 3286 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3287 | + ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3288 | + Object obj = in.readObject(); |
---|
| 3289 | + in.close(); |
---|
| 3290 | + |
---|
| 3291 | + return obj; |
---|
| 3292 | + } catch (Exception e) |
---|
| 3293 | + { |
---|
| 3294 | + System.err.println(e); |
---|
| 3295 | + return null; |
---|
| 3296 | + } |
---|
| 3297 | + } |
---|
| 3298 | + |
---|
| 3299 | + cRadio GetCurrentTab() |
---|
| 3300 | + { |
---|
| 3301 | + cRadio ab; |
---|
| 3302 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3303 | + { |
---|
| 3304 | + ab = (cRadio)e.nextElement(); |
---|
| 3305 | + if(ab.GetObject() == copy) |
---|
| 3306 | + { |
---|
| 3307 | + return ab; |
---|
| 3308 | + } |
---|
| 3309 | + } |
---|
| 3310 | + |
---|
| 3311 | + return null; |
---|
| 3312 | + } |
---|
| 3313 | + |
---|
| 3314 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3315 | + |
---|
| 3316 | + public void Save() |
---|
| 3317 | + { |
---|
| 3318 | + cRadio tab = GetCurrentTab(); |
---|
| 3319 | + |
---|
| 3320 | + boolean temp = CameraPane.SWITCH; |
---|
| 3321 | + CameraPane.SWITCH = false; |
---|
| 3322 | + |
---|
| 3323 | + copy.ExtractBigData(hashtable); |
---|
| 3324 | + |
---|
| 3325 | + //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
| 3326 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
| 3327 | + |
---|
| 3328 | + copy.RestoreBigData(hashtable); |
---|
| 3329 | + |
---|
| 3330 | + CameraPane.SWITCH = temp; |
---|
| 3331 | + |
---|
| 3332 | + //assert(hashtable.isEmpty()); |
---|
| 3333 | + |
---|
| 3334 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3335 | + { |
---|
| 3336 | + tab.graphs[i] = null; |
---|
| 3337 | + } |
---|
| 3338 | + |
---|
| 3339 | + // test save |
---|
| 3340 | + if (false) |
---|
| 3341 | + { |
---|
| 3342 | + try |
---|
| 3343 | + { |
---|
| 3344 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3345 | + ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
| 3346 | + |
---|
| 3347 | + p.writeObject(copy); |
---|
| 3348 | + |
---|
| 3349 | + p.flush(); |
---|
| 3350 | + |
---|
| 3351 | + ostream.close(); |
---|
| 3352 | + } catch (Exception e) |
---|
| 3353 | + { |
---|
| 3354 | + e.printStackTrace(); |
---|
| 3355 | + } |
---|
| 3356 | + } |
---|
| 3357 | + } |
---|
| 3358 | + |
---|
| 3359 | + void CopyChanged(Object3D obj) |
---|
| 3360 | + { |
---|
| 3361 | + boolean temp = CameraPane.SWITCH; |
---|
| 3362 | + CameraPane.SWITCH = false; |
---|
| 3363 | + |
---|
| 3364 | + copy.ExtractBigData(hashtable); |
---|
| 3365 | + |
---|
| 3366 | + copy.clear(); |
---|
| 3367 | + |
---|
| 3368 | + for (int i=0; i<obj.Size(); i++) |
---|
| 3369 | + { |
---|
| 3370 | + copy.add(obj.get(i)); |
---|
| 3371 | + } |
---|
| 3372 | + |
---|
| 3373 | + copy.RestoreBigData(hashtable); |
---|
| 3374 | + |
---|
| 3375 | + CameraPane.SWITCH = temp; |
---|
| 3376 | + |
---|
| 3377 | + //assert(hashtable.isEmpty()); |
---|
| 3378 | + |
---|
| 3379 | + copy.Touch(); |
---|
| 3380 | + |
---|
| 3381 | + ResetModel(); |
---|
| 3382 | + copy.HardTouch(); // recompile? |
---|
| 3383 | + |
---|
| 3384 | + cRadio ab; |
---|
| 3385 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3386 | + { |
---|
| 3387 | + ab = (cRadio)e.nextElement(); |
---|
| 3388 | + Object3D test = copy.GetObject(ab.object.GetUUID()); |
---|
| 3389 | + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); |
---|
| 3390 | + if (test != null) |
---|
| 3391 | + { |
---|
| 3392 | + test.editWindow = ab.object.editWindow; |
---|
| 3393 | + ab.object = test; |
---|
| 3394 | + } |
---|
| 3395 | + } |
---|
| 3396 | + |
---|
| 3397 | + refreshContents(); |
---|
| 3398 | + } |
---|
| 3399 | + |
---|
| 3400 | + public void Undo() |
---|
| 3401 | + { |
---|
| 3402 | + cRadio tab = GetCurrentTab(); |
---|
| 3403 | + |
---|
| 3404 | + if (tab.undoindex == 0) |
---|
| 3405 | + { |
---|
| 3406 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3407 | + return; |
---|
| 3408 | + } |
---|
| 3409 | + |
---|
| 3410 | + if (tab.graphs[tab.undoindex] == null) |
---|
| 3411 | + { |
---|
| 3412 | + Save(); |
---|
| 3413 | + tab.undoindex -= 1; |
---|
| 3414 | + } |
---|
| 3415 | + |
---|
| 3416 | + tab.undoindex -= 1; |
---|
| 3417 | + |
---|
| 3418 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3419 | + } |
---|
| 3420 | + |
---|
| 3421 | + public void Redo() |
---|
| 3422 | + { |
---|
| 3423 | + cRadio tab = GetCurrentTab(); |
---|
| 3424 | + |
---|
| 3425 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3426 | + { |
---|
| 3427 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3428 | + return; |
---|
| 3429 | + } |
---|
| 3430 | + |
---|
| 3431 | + tab.undoindex += 1; |
---|
| 3432 | + |
---|
| 3433 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3434 | + } |
---|
| 3435 | + |
---|
3214 | 3436 | void ImportGFD() |
---|
3215 | 3437 | { |
---|
3216 | 3438 | FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); |
---|
.. | .. |
---|
3855 | 4077 | |
---|
3856 | 4078 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3857 | 4079 | { |
---|
| 4080 | + Save(); |
---|
3858 | 4081 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3859 | 4082 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3860 | 4083 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4078 | 4301 | |
---|
4079 | 4302 | try |
---|
4080 | 4303 | { |
---|
| 4304 | + // Try compressed version first. |
---|
4081 | 4305 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4082 | 4306 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4083 | 4307 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4147 | 4371 | |
---|
4148 | 4372 | void LoadIt(Object obj) |
---|
4149 | 4373 | { |
---|
| 4374 | + if (obj == null) |
---|
| 4375 | + { |
---|
| 4376 | + // Invalid file |
---|
| 4377 | + return; |
---|
| 4378 | + } |
---|
| 4379 | + |
---|
4150 | 4380 | System.out.println("Loaded " + obj); |
---|
4151 | 4381 | //new Exception().printStackTrace(); |
---|
4152 | 4382 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4156 | 4386 | |
---|
4157 | 4387 | if (readobj != null) |
---|
4158 | 4388 | { |
---|
| 4389 | + Save(); |
---|
4159 | 4390 | try |
---|
4160 | 4391 | { |
---|
4161 | 4392 | //readobj.deepCopySelf(copy); |
---|