.. | .. |
---|
3207 | 3207 | { |
---|
3208 | 3208 | copy.remove(1); |
---|
3209 | 3209 | } |
---|
| 3210 | + |
---|
3210 | 3211 | ResetModel(); |
---|
3211 | 3212 | objEditor.refreshContents(); |
---|
3212 | 3213 | } |
---|
3213 | 3214 | |
---|
| 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 | + |
---|
3214 | 3316 | void ImportGFD() |
---|
3215 | 3317 | { |
---|
3216 | 3318 | FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); |
---|
.. | .. |
---|
3855 | 3957 | |
---|
3856 | 3958 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3857 | 3959 | { |
---|
| 3960 | + Save(); |
---|
3858 | 3961 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3859 | 3962 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3860 | 3963 | // if (thing instanceof GenericJointDemo) |
---|