Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
ObjEditor.java
....@@ -276,24 +276,40 @@
276276 void SetupMenu()
277277 {
278278 frame.setMenuBar(menuBar = new MenuBar());
279
- menuBar.add(windowMenu = new Menu("File"));
280
- windowMenu.add(loadItem = new MenuItem("Load..."));
281
- windowMenu.add("-");
282
- windowMenu.add(saveItem = new MenuItem("Save"));
283
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
279
+ menuBar.add(fileMenu = new Menu("File"));
280
+ fileMenu.add(newItem = new MenuItem("New"));
281
+ fileMenu.add(loadItem = new MenuItem("Load..."));
282
+
283
+ //oe.menuBar.add(menu = new Menu("Include"));
284
+ Menu menu = new Menu("Import");
285
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
286
+ importOBJItem.addActionListener(this);
287
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
288
+ import3DSItem.addActionListener(this);
289
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
290
+ importVRMLX3DItem.addActionListener(this);
291
+ menu.add("-");
292
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
293
+ importGFDItem.addActionListener(this);
294
+ fileMenu.add(menu);
295
+ fileMenu.add("-");
296
+
297
+ fileMenu.add(saveItem = new MenuItem("Save"));
298
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
284299 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
285
- windowMenu.add("-");
286
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
287
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
288
- windowMenu.add("-");
300
+ fileMenu.add("-");
301
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
302
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
303
+ fileMenu.add("-");
289304 if (client.parent != null)
290305 {
291
- windowMenu.add(closeItem = new MenuItem("Close"));
306
+ fileMenu.add(closeItem = new MenuItem("Close"));
292307 } else
293308 {
294
- windowMenu.add(closeItem = new MenuItem("Exit"));
309
+ fileMenu.add(closeItem = new MenuItem("Exit"));
295310 }
296311
312
+ newItem.addActionListener(this);
297313 loadItem.addActionListener(this);
298314 saveItem.addActionListener(this);
299315 saveAsItem.addActionListener(this);
....@@ -301,78 +317,6 @@
301317 reexportItem.addActionListener(this);
302318 //povItem.addActionListener(this);
303319 closeItem.addActionListener(this);
304
-
305
- menuBar.add(cameraMenu = new Menu("View"));
306
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
307
- //zBufferItem.addActionListener(this);
308
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
309
- //normalLensItem.addActionListener(this);
310
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
311
- revertCameraItem.addActionListener(this);
312
-
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
-
318
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
319
- toggleTextureItem.addItemListener(this);
320
- toggleTextureItem.setState(CameraPane.textureon);
321
-
322
- cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
323
- toggleSwitchItem.addItemListener(this);
324
- toggleSwitchItem.setState(CameraPane.SWITCH);
325
-
326
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
327
- toggleHandleItem.addItemListener(this);
328
- toggleHandleItem.setState(CameraPane.HANDLES);
329
-
330
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
331
- togglePaintItem.addItemListener(this);
332
- togglePaintItem.setState(CameraPane.PAINTMODE);
333
-
334
- if (Globals.ADVANCED)
335
- {
336
- cameraMenu.add("-");
337
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
338
- toggleLiveItem.addItemListener(this);
339
- toggleLiveItem.setState(Globals.isLIVE());
340
-
341
- cameraMenu.add(stepItem = new MenuItem("Step"));
342
- stepItem.addActionListener(this);
343
- // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
344
- // toggleDLItem.addItemListener(this);
345
- // toggleDLItem.setState(false);
346
-
347
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
348
- toggleRenderItem.addItemListener(this);
349
- toggleRenderItem.setState(!CameraPane.frozen);
350
-
351
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
352
- toggleDebugItem.addItemListener(this);
353
- toggleDebugItem.setState(CameraPane.DEBUG);
354
-
355
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
356
- toggleFrustumItem.addItemListener(this);
357
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
358
-
359
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
360
- toggleFootContactItem.addItemListener(this);
361
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
362
-
363
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
364
- toggleTimelineItem.addItemListener(this);
365
- }
366
-
367
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
368
-// toggleRootItem.addItemListener(this);
369
-// toggleRootItem.setState(false);
370
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
371
-// animationItem.addItemListener(this);
372
-// animationItem.setState(CameraPane.ANIMATION);
373
- cameraMenu.add("-");
374
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
375
- editCameraItem.addActionListener(this);
376320
377321 objectPanel = new JTabbedPane();
378322 toolbarPanel = new JPanel();
....@@ -501,13 +445,13 @@
501445 //SendInfo("Name:", "bold");
502446 if (sel.GetTextures() != null || debug)
503447 {
504
- si.SendInfo(sel.toString(), "bold");
448
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
505449 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
506450 if (sel.Size() > 0)
507451 {
508452 si.SendInfo("#children = " + sel.Size(), "regular");
509453 }
510
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
454
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
511455 if (debug)
512456 {
513457 try
....@@ -549,7 +493,7 @@
549493 }
550494 if (sel.support != null)
551495 {
552
- si.SendInfo(" support: " + sel.support, "regular");
496
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
553497 }
554498 if (sel.scriptnode != null)
555499 {
....@@ -752,7 +696,7 @@
752696 protected static ImageIcon createImageIcon(String path,
753697 String description)
754698 {
755
- java.net.URL imgURL = GrafreeD.class.getResource(path);
699
+ java.net.URL imgURL = Grafreed.class.getResource(path);
756700 if (imgURL != null)
757701 {
758702 return new ImageIcon(imgURL, description);
....@@ -784,6 +728,7 @@
784728 // NumberSlider vDivsField;
785729 // JCheckBox endcaps;
786730 JCheckBox liveCB;
731
+ JCheckBox selectCB;
787732 JCheckBox hideCB;
788733 JCheckBox link2masterCB;
789734 JCheckBox markCB;
....@@ -986,9 +931,11 @@
986931
987932 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
988933 liveCB.setToolTipText("Animate object");
934
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
+ selectCB.setToolTipText("Make object selectable");
936
+// Return();
989937 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
990938 hideCB.setToolTipText("Hide object");
991
-// Return();
992939 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
993940 markCB.setToolTipText("Set the animation target transform");
994941
....@@ -1028,7 +975,7 @@
1028975 oe.ctrlPanel.add(commandsPanel);
1029976 oe.ctrlPanel.Return();
1030977
1031
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
978
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1032979 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1033980 //Return();
1034981
....@@ -1476,19 +1423,19 @@
14761423
14771424 cGridBag editBar = new cGridBag().setVertical(false);
14781425
1479
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1426
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14801427 createMaterialButton.setToolTipText("Create material");
14811428
14821429 /*
14831430 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14841431 */
14851432
1486
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1433
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14871434 clearMaterialButton.setToolTipText("Clear material");
14881435
14891436 if (Globals.ADVANCED)
14901437 {
1491
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1438
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
14921439 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
14931440 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
14941441 }
....@@ -1939,7 +1886,7 @@
19391886
19401887 //? flashIt = false;
19411888 CameraPane pane = (CameraPane) cameraView;
1942
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
19431890 pane.clickEnd(location.x, location.y, 0, true);
19441891
19451892 if (group.selection.size() == 1)
....@@ -1988,6 +1935,7 @@
19881935 e2.printStackTrace();
19891936 }
19901937 }
1938
+
19911939 LoadJMEThread loadThread;
19921940
19931941 class LoadJMEThread extends Thread
....@@ -2045,6 +1993,7 @@
20451993 //LoadFile0(filename, converter);
20461994 }
20471995 }
1996
+
20481997 LoadOBJThread loadObjThread;
20491998
20501999 class LoadOBJThread extends Thread
....@@ -2396,11 +2345,11 @@
23962345
23972346 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23982347 {
2399
- if (GrafreeD.standAlone)
2348
+ if (Grafreed.standAlone)
24002349 {
24012350 /**/
24022351 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2403
- browser.show();
2352
+ browser.setVisible(true);
24042353 String filename = browser.getFile();
24052354 if (filename != null && filename.length() > 0)
24062355 {
....@@ -3007,6 +2956,10 @@
30072956 {
30082957 copy.live ^= true;
30092958 return;
2959
+ } else if (event.getSource() == selectCB)
2960
+ {
2961
+ copy.dontselect ^= true;
2962
+ return;
30102963 } else if (event.getSource() == hideCB)
30112964 {
30122965 copy.hide ^= true;
....@@ -3045,8 +2998,9 @@
30452998
30462999 public void actionPerformed(ActionEvent event)
30473000 {
3001
+ Object source = event.getSource();
30483002 // SCRIPT DIALOG
3049
- if (event.getSource() == okbutton)
3003
+ if (source == okbutton)
30503004 {
30513005 textpanel.setVisible(false);
30523006 textpanel.remove(textarea);
....@@ -3058,7 +3012,7 @@
30583012 textarea = null;
30593013 textpanel = null;
30603014 }
3061
- if (event.getSource() == cancelbutton)
3015
+ if (source == cancelbutton)
30623016 {
30633017 textpanel.setVisible(false);
30643018 textpanel.remove(textarea);
....@@ -3070,50 +3024,50 @@
30703024 //applySelf();
30713025 //client.refreshEditWindow();
30723026 //refreshContents();
3073
- if (event.getSource() == nameField)
3027
+ if (source == nameField)
30743028 {
30753029 //System.out.println("ObjEditor " + event);
30763030 applySelf0(true);
30773031 //parent.applySelf();
30783032 objEditor.refreshContents();
3079
- } else if (event.getSource() == resetButton)
3033
+ } else if (source == resetButton)
30803034 {
30813035 CameraPane.fullreset = true;
30823036 copy.Reset(); // ResetMeshes();
30833037 copy.Touch();
30843038 objEditor.refreshContents();
3085
- } else if (event.getSource() == stepItem)
3039
+ } else if (source == stepItem)
30863040 {
30873041 //cameraView.ONESTEP = true;
30883042 Globals.ONESTEP = true;
30893043 cameraView.repaint();
30903044 return;
3091
- } else if (event.getSource() == stepButton)
3045
+ } else if (source == stepButton)
30923046 {
30933047 copy.Step();
30943048 copy.Touch();
30953049 objEditor.refreshContents();
3096
- } else if (event.getSource() == slowerButton)
3050
+ } else if (source == slowerButton)
30973051 {
30983052 copy.Slower();
30993053 copy.Touch();
31003054 objEditor.refreshContents();
3101
- } else if (event.getSource() == fasterButton)
3055
+ } else if (source == fasterButton)
31023056 {
31033057 copy.Faster();
31043058 copy.Touch();
31053059 objEditor.refreshContents();
3106
- } else if (event.getSource() == remarkButton)
3060
+ } else if (source == remarkButton)
31073061 {
31083062 copy.Remark();
31093063 copy.Touch();
31103064 objEditor.refreshContents();
3111
- } else if (event.getSource() == stepAllButton)
3065
+ } else if (source == stepAllButton)
31123066 {
31133067 copy.StepAll();
31143068 copy.Touch();
31153069 objEditor.refreshContents();
3116
- } else if (event.getSource() == resetAllButton)
3070
+ } else if (source == resetAllButton)
31173071 {
31183072 //CameraPane.fullreset = true;
31193073 copy.ResetAll(); // ResetMeshes();
....@@ -3146,53 +3100,75 @@
31463100 // Close();
31473101 // }
31483102 // else
3149
- if (event.getSource() == resetSlidersButton)
3103
+ if (source == resetSlidersButton)
31503104 {
31513105 ResetSliders();
3152
- } else if (event.getSource() == clearMaterialButton)
3106
+ } else if (source == clearMaterialButton)
31533107 {
31543108 ClearMaterial();
3155
- } else if (event.getSource() == createMaterialButton)
3109
+ } else if (source == createMaterialButton)
31563110 {
31573111 CreateMaterial();
3158
- } else if (event.getSource() == clearPanelButton)
3112
+ } else if (source == clearPanelButton)
31593113 {
31603114 copy.ClearUI();
31613115 refreshContents(true);
3162
- } /*
3163
- }
3164
-
3165
- public boolean action(Event event, Object arg)
3166
- {
3167
- */ else if (event.getSource() == closeItem)
3116
+ } else if (source == importGFDItem)
3117
+ {
3118
+ ImportGFD();
3119
+ } else
3120
+ if (source == importVRMLX3DItem)
3121
+ {
3122
+ ImportVRMLX3D();
3123
+ } else
3124
+ if (source == import3DSItem)
3125
+ {
3126
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3127
+ } else
3128
+ if (source == importOBJItem)
3129
+ {
3130
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3131
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3132
+ browser.setVisible(true);
3133
+ String filename = browser.getFile();
3134
+ if (filename != null && filename.length() > 0)
3135
+ {
3136
+ String fullname = browser.getDirectory() + filename;
3137
+ makeSomething(ReadOBJ(fullname), true);
3138
+ }
3139
+ } else
3140
+ if (source == closeItem)
31683141 {
31693142 Close();
31703143 //return true;
3171
- } else if (event.getSource() == loadItem)
3144
+ } else if (source == loadItem)
31723145 {
31733146 load();
31743147 //return true;
3175
- } else if (event.getSource() == saveItem)
3148
+ } else if (source == newItem)
3149
+ {
3150
+ New();
3151
+ } else if (source == saveItem)
31763152 {
31773153 save();
31783154 //return true;
3179
- } else if (event.getSource() == saveAsItem)
3155
+ } else if (source == saveAsItem)
31803156 {
31813157 saveAs();
31823158 //return true;
3183
- } else if (event.getSource() == reexportItem)
3159
+ } else if (source == reexportItem)
31843160 {
31853161 reexport();
31863162 //return true;
3187
- } else if (event.getSource() == exportAsItem)
3163
+ } else if (source == exportAsItem)
31883164 {
31893165 export();
31903166 //return true;
3191
- } else if (event.getSource() == povItem)
3167
+ } else if (source == povItem)
31923168 {
31933169 generatePOV();
31943170 //return true;
3195
- } else if (event.getSource() == zBufferItem)
3171
+ } else if (source == zBufferItem)
31963172 {
31973173 try
31983174 {
....@@ -3214,21 +3190,8 @@
32143190 cameraView.repaint();
32153191 //return true;
32163192 }
3217
- */ else if (event.getSource() == editCameraItem)
3218
- {
3219
- cameraView.ProtectCamera();
3220
- cameraView.repaint();
3221
- return;
3222
- } else if (event.getSource() == revertCameraItem)
3223
- {
3224
- cameraView.RevertCamera();
3225
- cameraView.repaint();
3226
- return;
3227
-// } else if (event.getSource() == textureButton)
3228
-// {
3229
-// return; // true;
3230
- } else // combos...
3231
- if (event.getSource() == texresMenu)
3193
+ */ else // combos...
3194
+ if (source == texresMenu)
32323195 {
32333196 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32343197 copy.texres = texresMenu.getSelectedIndex();
....@@ -3240,6 +3203,246 @@
32403203 }
32413204 }
32423205
3206
+ void New()
3207
+ {
3208
+ while (copy.Size() > 1)
3209
+ {
3210
+ copy.remove(1);
3211
+ }
3212
+
3213
+ ResetModel();
3214
+ objEditor.refreshContents();
3215
+ }
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
+
3414
+ void ImportGFD()
3415
+ {
3416
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3417
+ browser.show();
3418
+ String filename = browser.getFile();
3419
+ if (filename != null && filename.length() > 0)
3420
+ {
3421
+ String fullname = browser.getDirectory() + filename;
3422
+
3423
+ //Object3D readobj =
3424
+ objEditor.ReadGFD(fullname, objEditor);
3425
+ //makeSomething(readobj);
3426
+ }
3427
+ }
3428
+
3429
+ void ImportVRMLX3D()
3430
+ {
3431
+ if (Grafreed.standAlone)
3432
+ {
3433
+ /**/
3434
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3435
+ browser.show();
3436
+ String filename = browser.getFile();
3437
+ if (filename != null && filename.length() > 0)
3438
+ {
3439
+ String fullname = browser.getDirectory() + filename;
3440
+ LoadVRMLX3D(fullname);
3441
+ }
3442
+ /**/
3443
+ }
3444
+ }
3445
+
32433446 void ToggleAnimation()
32443447 {
32453448 if (!Globals.ANIMATION)
....@@ -3255,8 +3458,8 @@
32553458
32563459 Globals.ANIMATION ^= true;
32573460
3258
- GrafreeD.wav.cursor = 0;
3259
- GrafreeD.wav.loop = 0;
3461
+ Grafreed.wav.cursor = 0;
3462
+ Grafreed.wav.loop = 0;
32603463 }
32613464 } else
32623465 {
....@@ -3443,6 +3646,36 @@
34433646 {
34443647 //System.out.println("Propagate = " + propagate);
34453648 copy.UpdateMaterial(anchor, current, propagate);
3649
+
3650
+ if (copy.material != null)
3651
+ {
3652
+ cMaterial mat = copy.material;
3653
+
3654
+ colorField.SetToolTipValue((mat.color));
3655
+ modulationField.SetToolTipValue((mat.modulation));
3656
+ metalnessField.SetToolTipValue((mat.metalness));
3657
+ diffuseField.SetToolTipValue((mat.diffuse));
3658
+ specularField.SetToolTipValue((mat.specular));
3659
+ shininessField.SetToolTipValue((mat.shininess));
3660
+ shiftField.SetToolTipValue((mat.shift));
3661
+ ambientField.SetToolTipValue((mat.ambient));
3662
+ lightareaField.SetToolTipValue((mat.lightarea));
3663
+ diffusenessField.SetToolTipValue((mat.factor));
3664
+ velvetField.SetToolTipValue((mat.velvet));
3665
+ sheenField.SetToolTipValue((mat.sheen));
3666
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3667
+ backlitField.SetToolTipValue((mat.bump));
3668
+ anisoField.SetToolTipValue((mat.aniso));
3669
+ anisoVField.SetToolTipValue((mat.anisoV));
3670
+ cameraField.SetToolTipValue((mat.cameralight));
3671
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3672
+ shadowField.SetToolTipValue((mat.shadow));
3673
+ textureField.SetToolTipValue((mat.texture));
3674
+ opacityField.SetToolTipValue((mat.opacity));
3675
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3676
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3677
+ }
3678
+
34463679 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34473680 {
34483681 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3558,7 +3791,7 @@
35583791 }
35593792
35603793 if (normalpushField != null)
3561
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3794
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35623795 }
35633796
35643797 void SnapObject()
....@@ -3822,6 +4055,7 @@
38224055
38234056 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38244057 {
4058
+ Save();
38254059 //Tween.set(thing, 0).target(1).start(tweenManager);
38264060 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38274061 // if (thing instanceof GenericJointDemo)
....@@ -4025,6 +4259,7 @@
40254259 }
40264260 }
40274261 }
4262
+
40284263 LoadGFDThread loadGFDThread;
40294264
40304265 void ReadGFD(String fullname, iCallBack cb)
....@@ -4045,7 +4280,8 @@
40454280 try
40464281 {
40474282 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4048
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4283
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4284
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40494285
40504286 readobj = (Object3D) p.readObject();
40514287 istream.close();
....@@ -4053,7 +4289,20 @@
40534289 readobj.ResetDisplayList();
40544290 } catch (Exception e)
40554291 {
4056
- e.printStackTrace();
4292
+ //e.printStackTrace();
4293
+ try
4294
+ {
4295
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4296
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4297
+
4298
+ readobj = (Object3D) p.readObject();
4299
+ istream.close();
4300
+
4301
+ readobj.ResetDisplayList();
4302
+ } catch (Exception e2)
4303
+ {
4304
+ e2.printStackTrace();
4305
+ }
40574306 }
40584307 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40594308 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4108,6 +4357,7 @@
41084357
41094358 if (readobj != null)
41104359 {
4360
+ Save();
41114361 try
41124362 {
41134363 //readobj.deepCopySelf(copy);
....@@ -4170,7 +4420,7 @@
41704420
41714421 void load() // throws ClassNotFoundException
41724422 {
4173
- if (GrafreeD.standAlone)
4423
+ if (Grafreed.standAlone)
41744424 {
41754425 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41764426 browser.show();
....@@ -4257,11 +4507,13 @@
42574507 try
42584508 {
42594509 FileOutputStream ostream = new FileOutputStream(lastname);
4260
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4510
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4511
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42614512
42624513 p.writeObject(copy);
42634514 p.flush();
42644515
4516
+ zstream.close();
42654517 ostream.close();
42664518
42674519 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4271,11 +4523,12 @@
42714523 {
42724524 }
42734525 }
4526
+
42744527 String lastname;
42754528
42764529 void saveAs()
42774530 {
4278
- if (GrafreeD.standAlone)
4531
+ if (Grafreed.standAlone)
42794532 {
42804533 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42814534 browser.setVisible(true);
....@@ -4380,13 +4633,13 @@
43804633 try
43814634 {
43824635 FileOutputStream ostream = new FileOutputStream(filename);
4383
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4384
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4636
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4637
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43854638
43864639 Object3D objectparent = obj.parent;
43874640 obj.parent = null;
43884641
4389
- Object3D object = (Object3D) GrafreeD.clone(obj);
4642
+ Object3D object = (Object3D) Grafreed.clone(obj);
43904643
43914644 obj.parent = objectparent;
43924645
....@@ -4398,8 +4651,8 @@
43984651 p.writeObject(object);
43994652 p.flush();
44004653
4654
+ zstream.close();
44014655 ostream.close();
4402
- // zstream.close();
44034656
44044657 // group.selection.get(0).parent = parent;
44054658 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4420,7 +4673,7 @@
44204673 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
44214674 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
44224675 copy.generatePOV(buffer);
4423
- if (GrafreeD.standAlone)
4676
+ if (Grafreed.standAlone)
44244677 {
44254678 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44264679 browser.show();
....@@ -4446,7 +4699,8 @@
44464699 Object3D client;
44474700 Object3D copy;
44484701 MenuBar menuBar;
4449
- Menu windowMenu;
4702
+ Menu fileMenu;
4703
+ MenuItem newItem;
44504704 MenuItem loadItem;
44514705 MenuItem saveItem;
44524706 MenuItem saveAsItem;
....@@ -4454,11 +4708,9 @@
44544708 MenuItem reexportItem;
44554709 MenuItem povItem;
44564710 MenuItem closeItem;
4457
- Menu cameraMenu;
4711
+
44584712 CheckboxMenuItem zBufferItem;
44594713 //MenuItem normalLensItem;
4460
- MenuItem editCameraItem;
4461
- MenuItem revertCameraItem;
44624714 MenuItem stepItem;
44634715 CheckboxMenuItem toggleLiveItem;
44644716 CheckboxMenuItem toggleFullScreenItem;
....@@ -4606,4 +4858,9 @@
46064858 //ObjectUI parent;
46074859
46084860 cNumberSlider normalpushField;
4861
+
4862
+ private MenuItem importGFDItem;
4863
+ private MenuItem importVRMLX3DItem;
4864
+ private MenuItem import3DSItem;
4865
+ private MenuItem importOBJItem;
46094866 }