Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
ObjEditor.java
....@@ -1935,6 +1935,7 @@
19351935 e2.printStackTrace();
19361936 }
19371937 }
1938
+
19381939 LoadJMEThread loadThread;
19391940
19401941 class LoadJMEThread extends Thread
....@@ -1992,6 +1993,7 @@
19921993 //LoadFile0(filename, converter);
19931994 }
19941995 }
1996
+
19951997 LoadOBJThread loadObjThread;
19961998
19971999 class LoadOBJThread extends Thread
....@@ -3207,10 +3209,208 @@
32073209 {
32083210 copy.remove(1);
32093211 }
3212
+
32103213 ResetModel();
32113214 objEditor.refreshContents();
32123215 }
32133216
3217
+ static public byte[] Compress(Object o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3224
+
3225
+ out.writeObject(o);
3226
+
3227
+ out.flush();
3228
+
3229
+ zstream.close();
3230
+ out.close();
3231
+
3232
+ return baos.toByteArray();
3233
+ } catch (Exception e)
3234
+ {
3235
+ System.err.println(e);
3236
+ return null;
3237
+ }
3238
+ }
3239
+
3240
+ static public Object Uncompress(byte[] bytes)
3241
+ {
3242
+ try
3243
+ {
3244
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3245
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3246
+ ObjectInputStream in = new ObjectInputStream(istream);
3247
+ Object obj = in.readObject();
3248
+ in.close();
3249
+
3250
+ return obj;
3251
+ } catch (Exception e)
3252
+ {
3253
+ System.err.println(e);
3254
+ return null;
3255
+ }
3256
+ }
3257
+
3258
+ static public Object clone(Object o)
3259
+ {
3260
+ try
3261
+ {
3262
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3263
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3264
+
3265
+ out.writeObject(o);
3266
+
3267
+ out.flush();
3268
+ out.close();
3269
+
3270
+ byte[] bytes = baos.toByteArray();
3271
+
3272
+ System.out.println("clone = " + bytes.length);
3273
+
3274
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3275
+ ObjectInputStream in = new ObjectInputStream(bais);
3276
+ Object obj = in.readObject();
3277
+ in.close();
3278
+
3279
+ return obj;
3280
+ } catch (Exception e)
3281
+ {
3282
+ System.err.println(e);
3283
+ return null;
3284
+ }
3285
+ }
3286
+
3287
+ cRadio GetCurrentTab()
3288
+ {
3289
+ cRadio ab;
3290
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3291
+ {
3292
+ ab = (cRadio)e.nextElement();
3293
+ if(ab.GetObject() == copy)
3294
+ {
3295
+ return ab;
3296
+ }
3297
+ }
3298
+
3299
+ return null;
3300
+ }
3301
+
3302
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3303
+
3304
+ public void Save()
3305
+ {
3306
+ cRadio tab = GetCurrentTab();
3307
+
3308
+ copy.ExtractBigData(hashtable);
3309
+
3310
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3311
+ tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3312
+
3313
+ copy.RestoreBigData(hashtable);
3314
+
3315
+ //assert(hashtable.isEmpty());
3316
+
3317
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3318
+ {
3319
+ tab.graphs[i] = null;
3320
+ }
3321
+
3322
+ // test save
3323
+ if (false)
3324
+ {
3325
+ try
3326
+ {
3327
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3328
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3329
+
3330
+ p.writeObject(copy);
3331
+
3332
+ p.flush();
3333
+
3334
+ ostream.close();
3335
+ } catch (Exception e)
3336
+ {
3337
+ e.printStackTrace();
3338
+ }
3339
+ }
3340
+ }
3341
+
3342
+ void CopyChanged(Object3D obj)
3343
+ {
3344
+ copy.ExtractBigData(hashtable);
3345
+
3346
+ copy.clear();
3347
+
3348
+ for (int i=0; i<obj.Size(); i++)
3349
+ {
3350
+ copy.add(obj.get(i));
3351
+ }
3352
+
3353
+ copy.RestoreBigData(hashtable);
3354
+
3355
+ //assert(hashtable.isEmpty());
3356
+
3357
+ copy.Touch();
3358
+
3359
+ ResetModel();
3360
+ copy.HardTouch(); // recompile?
3361
+
3362
+ cRadio ab;
3363
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3364
+ {
3365
+ ab = (cRadio)e.nextElement();
3366
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3367
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3368
+ if (test != null)
3369
+ {
3370
+ test.editWindow = ab.object.editWindow;
3371
+ ab.object = test;
3372
+ }
3373
+ }
3374
+
3375
+ refreshContents();
3376
+ }
3377
+
3378
+ public void Undo()
3379
+ {
3380
+ cRadio tab = GetCurrentTab();
3381
+
3382
+ if (tab.undoindex == 0)
3383
+ {
3384
+ java.awt.Toolkit.getDefaultToolkit().beep();
3385
+ return;
3386
+ }
3387
+
3388
+ if (tab.graphs[tab.undoindex] == null)
3389
+ {
3390
+ Save();
3391
+ tab.undoindex -= 1;
3392
+ }
3393
+
3394
+ tab.undoindex -= 1;
3395
+
3396
+ CopyChanged(tab.graphs[tab.undoindex]);
3397
+ }
3398
+
3399
+ public void Redo()
3400
+ {
3401
+ cRadio tab = GetCurrentTab();
3402
+
3403
+ if (tab.graphs[tab.undoindex + 1] == null)
3404
+ {
3405
+ java.awt.Toolkit.getDefaultToolkit().beep();
3406
+ return;
3407
+ }
3408
+
3409
+ tab.undoindex += 1;
3410
+
3411
+ CopyChanged(tab.graphs[tab.undoindex]);
3412
+ }
3413
+
32143414 void ImportGFD()
32153415 {
32163416 FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
....@@ -3855,6 +4055,7 @@
38554055
38564056 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38574057 {
4058
+ Save();
38584059 //Tween.set(thing, 0).target(1).start(tweenManager);
38594060 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38604061 // if (thing instanceof GenericJointDemo)
....@@ -4156,6 +4357,7 @@
41564357
41574358 if (readobj != null)
41584359 {
4360
+ Save();
41594361 try
41604362 {
41614363 //readobj.deepCopySelf(copy);