Normand Briere
2019-06-09 79d0f9a45d36656051a77a7b0837aa0318f81ee5
ObjEditor.java
....@@ -3207,10 +3207,112 @@
32073207 {
32083208 copy.remove(1);
32093209 }
3210
+
32103211 ResetModel();
32113212 objEditor.refreshContents();
32123213 }
32133214
3215
+ Object3D graphs[] = new Object3D[10000];
3216
+ int undoindex = 0;
3217
+
3218
+ static public Object clone(Object o)
3219
+ {
3220
+ try
3221
+ {
3222
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3223
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3224
+
3225
+ out.writeObject(o);
3226
+
3227
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3228
+ ObjectInputStream in = new ObjectInputStream(bais);
3229
+ Object obj = in.readObject();
3230
+ in.close();
3231
+ out.close();
3232
+ return obj;
3233
+ } catch (Exception e)
3234
+ {
3235
+ System.err.println(e);
3236
+ return null;
3237
+ }
3238
+ }
3239
+
3240
+ public void Save()
3241
+ {
3242
+ if (true) return;
3243
+
3244
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3245
+ graphs[undoindex++] = (Object3D)clone(copy);
3246
+
3247
+ for (int i = undoindex; i < graphs.length; i++)
3248
+ {
3249
+ graphs[i] = null;
3250
+ }
3251
+
3252
+ // test save
3253
+ if (false)
3254
+ {
3255
+ try
3256
+ {
3257
+ FileOutputStream ostream = new FileOutputStream("save" + undoindex);
3258
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3259
+
3260
+ p.writeObject(copy);
3261
+
3262
+ p.flush();
3263
+
3264
+ ostream.close();
3265
+ } catch (Exception e)
3266
+ {
3267
+ e.printStackTrace();
3268
+ }
3269
+ }
3270
+ }
3271
+
3272
+ public void Undo()
3273
+ {
3274
+ if (undoindex == 0)
3275
+ {
3276
+ java.awt.Toolkit.getDefaultToolkit().beep();
3277
+ return;
3278
+ }
3279
+
3280
+ if (graphs[undoindex] == null)
3281
+ {
3282
+ Save();
3283
+ undoindex -= 1;
3284
+ }
3285
+
3286
+ undoindex -= 1;
3287
+
3288
+ copy = graphs[undoindex];
3289
+
3290
+ cameraView.object = copy;
3291
+ copy.Touch();
3292
+
3293
+ ResetModel();
3294
+ refreshContents();
3295
+ }
3296
+
3297
+ public void Redo()
3298
+ {
3299
+ if (graphs[undoindex + 1] == null)
3300
+ {
3301
+ java.awt.Toolkit.getDefaultToolkit().beep();
3302
+ return;
3303
+ }
3304
+
3305
+ undoindex += 1;
3306
+
3307
+ copy = graphs[undoindex];
3308
+
3309
+ cameraView.object = copy;
3310
+ copy.Touch();
3311
+
3312
+ ResetModel();
3313
+ refreshContents();
3314
+ }
3315
+
32143316 void ImportGFD()
32153317 {
32163318 FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
....@@ -3855,6 +3957,7 @@
38553957
38563958 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38573959 {
3960
+ Save();
38583961 //Tween.set(thing, 0).target(1).start(tweenManager);
38593962 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38603963 // if (thing instanceof GenericJointDemo)