.. | .. |
---|
1935 | 1935 | e2.printStackTrace(); |
---|
1936 | 1936 | } |
---|
1937 | 1937 | } |
---|
| 1938 | + |
---|
1938 | 1939 | LoadJMEThread loadThread; |
---|
1939 | 1940 | |
---|
1940 | 1941 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 1993 | //LoadFile0(filename, converter); |
---|
1993 | 1994 | } |
---|
1994 | 1995 | } |
---|
| 1996 | + |
---|
1995 | 1997 | LoadOBJThread loadObjThread; |
---|
1996 | 1998 | |
---|
1997 | 1999 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
3207 | 3209 | { |
---|
3208 | 3210 | copy.remove(1); |
---|
3209 | 3211 | } |
---|
| 3212 | + |
---|
3210 | 3213 | ResetModel(); |
---|
3211 | 3214 | objEditor.refreshContents(); |
---|
3212 | 3215 | } |
---|
3213 | 3216 | |
---|
| 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 | + |
---|
3214 | 3414 | void ImportGFD() |
---|
3215 | 3415 | { |
---|
3216 | 3416 | FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); |
---|
.. | .. |
---|
3855 | 4055 | |
---|
3856 | 4056 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3857 | 4057 | { |
---|
| 4058 | + Save(); |
---|
3858 | 4059 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3859 | 4060 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3860 | 4061 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4156 | 4357 | |
---|
4157 | 4358 | if (readobj != null) |
---|
4158 | 4359 | { |
---|
| 4360 | + Save(); |
---|
4159 | 4361 | try |
---|
4160 | 4362 | { |
---|
4161 | 4363 | //readobj.deepCopySelf(copy); |
---|