.. | .. |
---|
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 |
---|
.. | .. |
---|
3212 | 3214 | objEditor.refreshContents(); |
---|
3213 | 3215 | } |
---|
3214 | 3216 | |
---|
3215 | | - Object3D graphs[] = new Object3D[10000]; |
---|
3216 | | - int undoindex = 0; |
---|
3217 | | - |
---|
3218 | | - static public Object clone(Object o) |
---|
| 3217 | + static public byte[] Compress(Object o) |
---|
3219 | 3218 | { |
---|
3220 | 3219 | try |
---|
3221 | 3220 | { |
---|
3222 | 3221 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3222 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3223 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
3224 | 3224 | |
---|
3225 | 3225 | out.writeObject(o); |
---|
| 3226 | + |
---|
| 3227 | + out.flush(); |
---|
3226 | 3228 | |
---|
3227 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
3228 | | - ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 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); |
---|
3229 | 3247 | Object obj = in.readObject(); |
---|
3230 | 3248 | in.close(); |
---|
3231 | | - out.close(); |
---|
| 3249 | + |
---|
3232 | 3250 | return obj; |
---|
3233 | 3251 | } catch (Exception e) |
---|
3234 | 3252 | { |
---|
.. | .. |
---|
3237 | 3255 | } |
---|
3238 | 3256 | } |
---|
3239 | 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 | + |
---|
3240 | 3304 | public void Save() |
---|
3241 | 3305 | { |
---|
3242 | | - if (true) return; |
---|
| 3306 | + cRadio tab = GetCurrentTab(); |
---|
| 3307 | + |
---|
| 3308 | + copy.ExtractBigData(hashtable); |
---|
3243 | 3309 | |
---|
3244 | 3310 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3245 | | - graphs[undoindex++] = (Object3D)clone(copy); |
---|
| 3311 | + tab.graphs[tab.undoindex++] = (Object3D)clone(copy); |
---|
3246 | 3312 | |
---|
3247 | | - for (int i = undoindex; i < graphs.length; i++) |
---|
| 3313 | + copy.RestoreBigData(hashtable); |
---|
| 3314 | + |
---|
| 3315 | + //assert(hashtable.isEmpty()); |
---|
| 3316 | + |
---|
| 3317 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3248 | 3318 | { |
---|
3249 | | - graphs[i] = null; |
---|
| 3319 | + tab.graphs[i] = null; |
---|
3250 | 3320 | } |
---|
3251 | 3321 | |
---|
3252 | 3322 | // test save |
---|
.. | .. |
---|
3254 | 3324 | { |
---|
3255 | 3325 | try |
---|
3256 | 3326 | { |
---|
3257 | | - FileOutputStream ostream = new FileOutputStream("save" + undoindex); |
---|
| 3327 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
3258 | 3328 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3259 | 3329 | |
---|
3260 | 3330 | p.writeObject(copy); |
---|
.. | .. |
---|
3269 | 3339 | } |
---|
3270 | 3340 | } |
---|
3271 | 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 | + |
---|
3272 | 3378 | public void Undo() |
---|
3273 | 3379 | { |
---|
3274 | | - if (undoindex == 0) |
---|
| 3380 | + cRadio tab = GetCurrentTab(); |
---|
| 3381 | + |
---|
| 3382 | + if (tab.undoindex == 0) |
---|
3275 | 3383 | { |
---|
3276 | 3384 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3277 | 3385 | return; |
---|
3278 | 3386 | } |
---|
3279 | 3387 | |
---|
3280 | | - if (graphs[undoindex] == null) |
---|
| 3388 | + if (tab.graphs[tab.undoindex] == null) |
---|
3281 | 3389 | { |
---|
3282 | 3390 | Save(); |
---|
3283 | | - undoindex -= 1; |
---|
| 3391 | + tab.undoindex -= 1; |
---|
3284 | 3392 | } |
---|
3285 | 3393 | |
---|
3286 | | - undoindex -= 1; |
---|
| 3394 | + tab.undoindex -= 1; |
---|
3287 | 3395 | |
---|
3288 | | - copy = graphs[undoindex]; |
---|
3289 | | - |
---|
3290 | | - cameraView.object = copy; |
---|
3291 | | - copy.Touch(); |
---|
3292 | | - |
---|
3293 | | - ResetModel(); |
---|
3294 | | - refreshContents(); |
---|
| 3396 | + CopyChanged(tab.graphs[tab.undoindex]); |
---|
3295 | 3397 | } |
---|
3296 | 3398 | |
---|
3297 | 3399 | public void Redo() |
---|
3298 | 3400 | { |
---|
3299 | | - if (graphs[undoindex + 1] == null) |
---|
| 3401 | + cRadio tab = GetCurrentTab(); |
---|
| 3402 | + |
---|
| 3403 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
3300 | 3404 | { |
---|
3301 | 3405 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3302 | 3406 | return; |
---|
3303 | 3407 | } |
---|
3304 | 3408 | |
---|
3305 | | - undoindex += 1; |
---|
| 3409 | + tab.undoindex += 1; |
---|
3306 | 3410 | |
---|
3307 | | - copy = graphs[undoindex]; |
---|
3308 | | - |
---|
3309 | | - cameraView.object = copy; |
---|
3310 | | - copy.Touch(); |
---|
3311 | | - |
---|
3312 | | - ResetModel(); |
---|
3313 | | - refreshContents(); |
---|
| 3411 | + CopyChanged(tab.graphs[tab.undoindex]); |
---|
3314 | 3412 | } |
---|
3315 | 3413 | |
---|
3316 | 3414 | void ImportGFD() |
---|
.. | .. |
---|
4259 | 4357 | |
---|
4260 | 4358 | if (readobj != null) |
---|
4261 | 4359 | { |
---|
| 4360 | + Save(); |
---|
4262 | 4361 | try |
---|
4263 | 4362 | { |
---|
4264 | 4363 | //readobj.deepCopySelf(copy); |
---|