.. | .. |
---|
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) |
---|
.. | .. |
---|
3212 | 3220 | objEditor.refreshContents(); |
---|
3213 | 3221 | } |
---|
3214 | 3222 | |
---|
3215 | | - Object3D graphs[] = new Object3D[10000]; |
---|
3216 | | - int undoindex = 0; |
---|
3217 | | - |
---|
3218 | | - static public Object clone(Object o) |
---|
| 3223 | + static public byte[] Compress(Object3D o) |
---|
3219 | 3224 | { |
---|
3220 | 3225 | try |
---|
3221 | 3226 | { |
---|
3222 | 3227 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3228 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3229 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
3224 | 3230 | |
---|
| 3231 | + Object3D parent = o.parent; |
---|
| 3232 | + o.parent = null; |
---|
| 3233 | + |
---|
3225 | 3234 | out.writeObject(o); |
---|
| 3235 | + |
---|
| 3236 | + o.parent = parent; |
---|
| 3237 | + |
---|
| 3238 | + out.flush(); |
---|
3226 | 3239 | |
---|
3227 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
3228 | | - ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 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); |
---|
3229 | 3259 | Object obj = in.readObject(); |
---|
3230 | 3260 | in.close(); |
---|
3231 | | - out.close(); |
---|
| 3261 | + |
---|
3232 | 3262 | return obj; |
---|
3233 | 3263 | } catch (Exception e) |
---|
3234 | 3264 | { |
---|
.. | .. |
---|
3237 | 3267 | } |
---|
3238 | 3268 | } |
---|
3239 | 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 | + |
---|
3240 | 3316 | public void Save() |
---|
3241 | 3317 | { |
---|
3242 | | - if (true) return; |
---|
| 3318 | + cRadio tab = GetCurrentTab(); |
---|
| 3319 | + |
---|
| 3320 | + boolean temp = CameraPane.SWITCH; |
---|
| 3321 | + CameraPane.SWITCH = false; |
---|
| 3322 | + |
---|
| 3323 | + copy.ExtractBigData(hashtable); |
---|
3243 | 3324 | |
---|
3244 | 3325 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3245 | | - graphs[undoindex++] = (Object3D)clone(copy); |
---|
| 3326 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3246 | 3327 | |
---|
3247 | | - for (int i = undoindex; i < graphs.length; i++) |
---|
| 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++) |
---|
3248 | 3335 | { |
---|
3249 | | - graphs[i] = null; |
---|
| 3336 | + tab.graphs[i] = null; |
---|
3250 | 3337 | } |
---|
3251 | 3338 | |
---|
3252 | 3339 | // test save |
---|
.. | .. |
---|
3254 | 3341 | { |
---|
3255 | 3342 | try |
---|
3256 | 3343 | { |
---|
3257 | | - FileOutputStream ostream = new FileOutputStream("save" + undoindex); |
---|
| 3344 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
3258 | 3345 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3259 | 3346 | |
---|
3260 | 3347 | p.writeObject(copy); |
---|
.. | .. |
---|
3269 | 3356 | } |
---|
3270 | 3357 | } |
---|
3271 | 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 | + |
---|
3272 | 3400 | public void Undo() |
---|
3273 | 3401 | { |
---|
3274 | | - if (undoindex == 0) |
---|
| 3402 | + cRadio tab = GetCurrentTab(); |
---|
| 3403 | + |
---|
| 3404 | + if (tab.undoindex == 0) |
---|
3275 | 3405 | { |
---|
3276 | 3406 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3277 | 3407 | return; |
---|
3278 | 3408 | } |
---|
3279 | 3409 | |
---|
3280 | | - if (graphs[undoindex] == null) |
---|
| 3410 | + if (tab.graphs[tab.undoindex] == null) |
---|
3281 | 3411 | { |
---|
3282 | 3412 | Save(); |
---|
3283 | | - undoindex -= 1; |
---|
| 3413 | + tab.undoindex -= 1; |
---|
3284 | 3414 | } |
---|
3285 | 3415 | |
---|
3286 | | - undoindex -= 1; |
---|
| 3416 | + tab.undoindex -= 1; |
---|
3287 | 3417 | |
---|
3288 | | - copy = graphs[undoindex]; |
---|
3289 | | - |
---|
3290 | | - cameraView.object = copy; |
---|
3291 | | - copy.Touch(); |
---|
3292 | | - |
---|
3293 | | - ResetModel(); |
---|
3294 | | - refreshContents(); |
---|
| 3418 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3295 | 3419 | } |
---|
3296 | 3420 | |
---|
3297 | 3421 | public void Redo() |
---|
3298 | 3422 | { |
---|
3299 | | - if (graphs[undoindex + 1] == null) |
---|
| 3423 | + cRadio tab = GetCurrentTab(); |
---|
| 3424 | + |
---|
| 3425 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
3300 | 3426 | { |
---|
3301 | 3427 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3302 | 3428 | return; |
---|
3303 | 3429 | } |
---|
3304 | 3430 | |
---|
3305 | | - undoindex += 1; |
---|
| 3431 | + tab.undoindex += 1; |
---|
3306 | 3432 | |
---|
3307 | | - copy = graphs[undoindex]; |
---|
3308 | | - |
---|
3309 | | - cameraView.object = copy; |
---|
3310 | | - copy.Touch(); |
---|
3311 | | - |
---|
3312 | | - ResetModel(); |
---|
3313 | | - refreshContents(); |
---|
| 3433 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3314 | 3434 | } |
---|
3315 | 3435 | |
---|
3316 | 3436 | void ImportGFD() |
---|
.. | .. |
---|
4181 | 4301 | |
---|
4182 | 4302 | try |
---|
4183 | 4303 | { |
---|
| 4304 | + // Try compressed version first. |
---|
4184 | 4305 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4185 | 4306 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4186 | 4307 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4250 | 4371 | |
---|
4251 | 4372 | void LoadIt(Object obj) |
---|
4252 | 4373 | { |
---|
| 4374 | + if (obj == null) |
---|
| 4375 | + { |
---|
| 4376 | + // Invalid file |
---|
| 4377 | + return; |
---|
| 4378 | + } |
---|
| 4379 | + |
---|
4253 | 4380 | System.out.println("Loaded " + obj); |
---|
4254 | 4381 | //new Exception().printStackTrace(); |
---|
4255 | 4382 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4259 | 4386 | |
---|
4260 | 4387 | if (readobj != null) |
---|
4261 | 4388 | { |
---|
| 4389 | + Save(); |
---|
4262 | 4390 | try |
---|
4263 | 4391 | { |
---|
4264 | 4392 | //readobj.deepCopySelf(copy); |
---|