Normand Briere
2019-06-16 b33ef80d78f01a6a61f4248b1bb7deaade42d503
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("Open..."));
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,61 +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
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
313
- toggleTimelineItem.addItemListener(this);
314
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
315
- toggleFullScreenItem.addItemListener(this);
316
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
317
- cameraMenu.add("-");
318
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
319
- toggleTextureItem.addItemListener(this);
320
- toggleTextureItem.setState(CameraPane.textureon);
321
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
322
- toggleLiveItem.addItemListener(this);
323
- toggleLiveItem.setState(Globals.isLIVE());
324
- cameraMenu.add(stepItem = new MenuItem("Step"));
325
- stepItem.addActionListener(this);
326
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
327
-// toggleDLItem.addItemListener(this);
328
-// toggleDLItem.setState(false);
329
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
330
- toggleRenderItem.addItemListener(this);
331
- toggleRenderItem.setState(!CameraPane.frozen);
332
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
333
- toggleDebugItem.addItemListener(this);
334
- toggleDebugItem.setState(CameraPane.DEBUG);
335
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
336
- toggleFrustumItem.addItemListener(this);
337
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
338
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
339
- toggleFootContactItem.addItemListener(this);
340
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
341
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
342
- toggleRandomItem.addItemListener(this);
343
- toggleRandomItem.setState(CameraPane.RANDOM);
344
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
345
- toggleHandleItem.addItemListener(this);
346
- toggleHandleItem.setState(CameraPane.HANDLES);
347
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
348
- togglePaintItem.addItemListener(this);
349
- togglePaintItem.setState(CameraPane.PAINTMODE);
350
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
351
-// toggleRootItem.addItemListener(this);
352
-// toggleRootItem.setState(false);
353
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
354
-// animationItem.addItemListener(this);
355
-// animationItem.setState(CameraPane.ANIMATION);
356
- cameraMenu.add("-");
357
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
358
- editCameraItem.addActionListener(this);
359320
360321 objectPanel = new JTabbedPane();
361322 toolbarPanel = new JPanel();
....@@ -484,13 +445,13 @@
484445 //SendInfo("Name:", "bold");
485446 if (sel.GetTextures() != null || debug)
486447 {
487
- si.SendInfo(sel.toString(), "bold");
448
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
488449 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
489450 if (sel.Size() > 0)
490451 {
491452 si.SendInfo("#children = " + sel.Size(), "regular");
492453 }
493
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
454
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
494455 if (debug)
495456 {
496457 try
....@@ -532,7 +493,7 @@
532493 }
533494 if (sel.support != null)
534495 {
535
- si.SendInfo(" support: " + sel.support, "regular");
496
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
536497 }
537498 if (sel.scriptnode != null)
538499 {
....@@ -735,7 +696,7 @@
735696 protected static ImageIcon createImageIcon(String path,
736697 String description)
737698 {
738
- java.net.URL imgURL = GrafreeD.class.getResource(path);
699
+ java.net.URL imgURL = Grafreed.class.getResource(path);
739700 if (imgURL != null)
740701 {
741702 return new ImageIcon(imgURL, description);
....@@ -767,6 +728,7 @@
767728 // NumberSlider vDivsField;
768729 // JCheckBox endcaps;
769730 JCheckBox liveCB;
731
+ JCheckBox selectCB;
770732 JCheckBox hideCB;
771733 JCheckBox link2masterCB;
772734 JCheckBox markCB;
....@@ -969,9 +931,11 @@
969931
970932 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
971933 liveCB.setToolTipText("Animate object");
934
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
+ selectCB.setToolTipText("Make object selectable");
936
+// Return();
972937 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
973938 hideCB.setToolTipText("Hide object");
974
-// Return();
975939 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
976940 markCB.setToolTipText("Set the animation target transform");
977941
....@@ -1011,7 +975,7 @@
1011975 oe.ctrlPanel.add(commandsPanel);
1012976 oe.ctrlPanel.Return();
1013977
1014
- 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
1015979 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1016980 //Return();
1017981
....@@ -1313,7 +1277,7 @@
13131277 scrollpane.addMouseWheelListener(this); // Default not fast enough
13141278
13151279 /*JTabbedPane*/ scenePanel = new cGridBag();
1316
- scenePanel.preferredWidth = 7;
1280
+ scenePanel.preferredWidth = 6;
13171281
13181282 JTabbedPane tabbedPane = new JTabbedPane();
13191283 tabbedPane.add(scrollpane);
....@@ -1419,8 +1383,8 @@
14191383
14201384 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14211385
1422
- frame.setSize(1024, 768);
1423
- frame.show();
1386
+ frame.setSize(1280, 860);
1387
+ frame.setVisible(true);
14241388
14251389 gridPanel.setDividerLocation(1.0);
14261390
....@@ -1459,19 +1423,22 @@
14591423
14601424 cGridBag editBar = new cGridBag().setVertical(false);
14611425
1462
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1426
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14631427 createMaterialButton.setToolTipText("Create material");
14641428
14651429 /*
14661430 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14671431 */
14681432
1469
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1433
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14701434 clearMaterialButton.setToolTipText("Clear material");
14711435
1472
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1473
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1474
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1436
+ if (Globals.ADVANCED)
1437
+ {
1438
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1439
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1440
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1441
+ }
14751442
14761443 editBar.preferredHeight = 15;
14771444
....@@ -1740,12 +1707,15 @@
17401707 opacityPowerField.addChangeListener(this);
17411708 /**/
17421709
1743
- resetSlidersButton.addActionListener(this);
17441710 clearMaterialButton.addActionListener(this);
17451711 createMaterialButton.addActionListener(this);
1746
-
1747
- propagateToggle.addItemListener(this);
1748
- multiplyToggle.addItemListener(this);
1712
+
1713
+ if (Globals.ADVANCED)
1714
+ {
1715
+ resetSlidersButton.addActionListener(this);
1716
+ propagateToggle.addItemListener(this);
1717
+ multiplyToggle.addItemListener(this);
1718
+ }
17491719 }
17501720
17511721 void DropFile(java.io.File[] files, boolean textures)
....@@ -1916,7 +1886,7 @@
19161886
19171887 //? flashIt = false;
19181888 CameraPane pane = (CameraPane) cameraView;
1919
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
19201890 pane.clickEnd(location.x, location.y, 0, true);
19211891
19221892 if (group.selection.size() == 1)
....@@ -1965,6 +1935,7 @@
19651935 e2.printStackTrace();
19661936 }
19671937 }
1938
+
19681939 LoadJMEThread loadThread;
19691940
19701941 class LoadJMEThread extends Thread
....@@ -2022,6 +1993,7 @@
20221993 //LoadFile0(filename, converter);
20231994 }
20241995 }
1996
+
20251997 LoadOBJThread loadObjThread;
20261998
20271999 class LoadOBJThread extends Thread
....@@ -2100,19 +2072,19 @@
21002072
21012073 void LoadObjFile(String fullname)
21022074 {
2103
- /*
2075
+ System.out.println("Loading " + fullname);
2076
+ /**/
21042077 //lastFilename = fullname;
21052078 if(loadObjThread == null)
21062079 {
2107
- loadObjThread = new LoadOBJThread();
2108
- loadObjThread.start();
2080
+ loadObjThread = new LoadOBJThread();
2081
+ loadObjThread.start();
21092082 }
21102083
21112084 loadObjThread.add(fullname);
2112
- */
2085
+ /**/
21132086
2114
- System.out.println("Loading " + fullname);
2115
- makeSomething(new FileObject(fullname, true), true);
2087
+ //makeSomething(new FileObject(fullname, true), true);
21162088 }
21172089
21182090 void LoadGFDFile(String fullname)
....@@ -2373,11 +2345,11 @@
23732345
23742346 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23752347 {
2376
- if (GrafreeD.standAlone)
2348
+ if (Grafreed.standAlone)
23772349 {
23782350 /**/
23792351 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2380
- browser.show();
2352
+ browser.setVisible(true);
23812353 String filename = browser.getFile();
23822354 if (filename != null && filename.length() > 0)
23832355 {
....@@ -2737,7 +2709,8 @@
27372709 return;
27382710 }
27392711
2740
- multiplyToggle.setSelected(mat.multiply);
2712
+ if (multiplyToggle != null)
2713
+ multiplyToggle.setSelected(mat.multiply);
27412714
27422715 assert (object.projectedVertices != null);
27432716
....@@ -2952,9 +2925,9 @@
29522925 frame.validate();
29532926
29542927 return;
2955
- } else if (event.getSource() == toggleRandomItem)
2928
+ } else if (event.getSource() == toggleSwitchItem)
29562929 {
2957
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29582931 cameraView.repaint();
29592932 return;
29602933 } else if (event.getSource() == toggleHandleItem)
....@@ -2982,6 +2955,10 @@
29822955 } else if (event.getSource() == liveCB)
29832956 {
29842957 copy.live ^= true;
2958
+ return;
2959
+ } else if (event.getSource() == selectCB)
2960
+ {
2961
+ copy.dontselect ^= true;
29852962 return;
29862963 } else if (event.getSource() == hideCB)
29872964 {
....@@ -3021,8 +2998,9 @@
30212998
30222999 public void actionPerformed(ActionEvent event)
30233000 {
3001
+ Object source = event.getSource();
30243002 // SCRIPT DIALOG
3025
- if (event.getSource() == okbutton)
3003
+ if (source == okbutton)
30263004 {
30273005 textpanel.setVisible(false);
30283006 textpanel.remove(textarea);
....@@ -3034,7 +3012,7 @@
30343012 textarea = null;
30353013 textpanel = null;
30363014 }
3037
- if (event.getSource() == cancelbutton)
3015
+ if (source == cancelbutton)
30383016 {
30393017 textpanel.setVisible(false);
30403018 textpanel.remove(textarea);
....@@ -3046,50 +3024,50 @@
30463024 //applySelf();
30473025 //client.refreshEditWindow();
30483026 //refreshContents();
3049
- if (event.getSource() == nameField)
3027
+ if (source == nameField)
30503028 {
30513029 //System.out.println("ObjEditor " + event);
30523030 applySelf0(true);
30533031 //parent.applySelf();
30543032 objEditor.refreshContents();
3055
- } else if (event.getSource() == resetButton)
3033
+ } else if (source == resetButton)
30563034 {
30573035 CameraPane.fullreset = true;
30583036 copy.Reset(); // ResetMeshes();
30593037 copy.Touch();
30603038 objEditor.refreshContents();
3061
- } else if (event.getSource() == stepItem)
3039
+ } else if (source == stepItem)
30623040 {
30633041 //cameraView.ONESTEP = true;
30643042 Globals.ONESTEP = true;
30653043 cameraView.repaint();
30663044 return;
3067
- } else if (event.getSource() == stepButton)
3045
+ } else if (source == stepButton)
30683046 {
30693047 copy.Step();
30703048 copy.Touch();
30713049 objEditor.refreshContents();
3072
- } else if (event.getSource() == slowerButton)
3050
+ } else if (source == slowerButton)
30733051 {
30743052 copy.Slower();
30753053 copy.Touch();
30763054 objEditor.refreshContents();
3077
- } else if (event.getSource() == fasterButton)
3055
+ } else if (source == fasterButton)
30783056 {
30793057 copy.Faster();
30803058 copy.Touch();
30813059 objEditor.refreshContents();
3082
- } else if (event.getSource() == remarkButton)
3060
+ } else if (source == remarkButton)
30833061 {
30843062 copy.Remark();
30853063 copy.Touch();
30863064 objEditor.refreshContents();
3087
- } else if (event.getSource() == stepAllButton)
3065
+ } else if (source == stepAllButton)
30883066 {
30893067 copy.StepAll();
30903068 copy.Touch();
30913069 objEditor.refreshContents();
3092
- } else if (event.getSource() == resetAllButton)
3070
+ } else if (source == resetAllButton)
30933071 {
30943072 //CameraPane.fullreset = true;
30953073 copy.ResetAll(); // ResetMeshes();
....@@ -3122,53 +3100,75 @@
31223100 // Close();
31233101 // }
31243102 // else
3125
- if (event.getSource() == resetSlidersButton)
3103
+ if (source == resetSlidersButton)
31263104 {
31273105 ResetSliders();
3128
- } else if (event.getSource() == clearMaterialButton)
3106
+ } else if (source == clearMaterialButton)
31293107 {
31303108 ClearMaterial();
3131
- } else if (event.getSource() == createMaterialButton)
3109
+ } else if (source == createMaterialButton)
31323110 {
31333111 CreateMaterial();
3134
- } else if (event.getSource() == clearPanelButton)
3112
+ } else if (source == clearPanelButton)
31353113 {
31363114 copy.ClearUI();
31373115 refreshContents(true);
3138
- } /*
3139
- }
3140
-
3141
- public boolean action(Event event, Object arg)
3142
- {
3143
- */ 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)
31443141 {
31453142 Close();
31463143 //return true;
3147
- } else if (event.getSource() == loadItem)
3144
+ } else if (source == loadItem)
31483145 {
31493146 load();
31503147 //return true;
3151
- } else if (event.getSource() == saveItem)
3148
+ } else if (source == newItem)
3149
+ {
3150
+ New();
3151
+ } else if (source == saveItem)
31523152 {
31533153 save();
31543154 //return true;
3155
- } else if (event.getSource() == saveAsItem)
3155
+ } else if (source == saveAsItem)
31563156 {
31573157 saveAs();
31583158 //return true;
3159
- } else if (event.getSource() == reexportItem)
3159
+ } else if (source == reexportItem)
31603160 {
31613161 reexport();
31623162 //return true;
3163
- } else if (event.getSource() == exportAsItem)
3163
+ } else if (source == exportAsItem)
31643164 {
31653165 export();
31663166 //return true;
3167
- } else if (event.getSource() == povItem)
3167
+ } else if (source == povItem)
31683168 {
31693169 generatePOV();
31703170 //return true;
3171
- } else if (event.getSource() == zBufferItem)
3171
+ } else if (source == zBufferItem)
31723172 {
31733173 try
31743174 {
....@@ -3190,21 +3190,8 @@
31903190 cameraView.repaint();
31913191 //return true;
31923192 }
3193
- */ else if (event.getSource() == editCameraItem)
3194
- {
3195
- cameraView.ProtectCamera();
3196
- cameraView.repaint();
3197
- return;
3198
- } else if (event.getSource() == revertCameraItem)
3199
- {
3200
- cameraView.RevertCamera();
3201
- cameraView.repaint();
3202
- return;
3203
-// } else if (event.getSource() == textureButton)
3204
-// {
3205
-// return; // true;
3206
- } else // combos...
3207
- if (event.getSource() == texresMenu)
3193
+ */ else // combos...
3194
+ if (source == texresMenu)
32083195 {
32093196 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32103197 copy.texres = texresMenu.getSelectedIndex();
....@@ -3216,6 +3203,262 @@
32163203 }
32173204 }
32183205
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(Object3D 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
+ Object3D parent = o.parent;
3226
+ o.parent = null;
3227
+
3228
+ out.writeObject(o);
3229
+
3230
+ o.parent = parent;
3231
+
3232
+ out.flush();
3233
+
3234
+ zstream.close();
3235
+ out.close();
3236
+
3237
+ return baos.toByteArray();
3238
+ } catch (Exception e)
3239
+ {
3240
+ System.err.println(e);
3241
+ return null;
3242
+ }
3243
+ }
3244
+
3245
+ static public Object Uncompress(byte[] bytes)
3246
+ {
3247
+ System.out.println("#bytes = " + bytes.length);
3248
+ try
3249
+ {
3250
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3251
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3252
+ ObjectInputStream in = new ObjectInputStream(istream);
3253
+ Object obj = in.readObject();
3254
+ in.close();
3255
+
3256
+ return obj;
3257
+ } catch (Exception e)
3258
+ {
3259
+ System.err.println(e);
3260
+ return null;
3261
+ }
3262
+ }
3263
+
3264
+ static public Object clone(Object o)
3265
+ {
3266
+ try
3267
+ {
3268
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3269
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3270
+
3271
+ out.writeObject(o);
3272
+
3273
+ out.flush();
3274
+ out.close();
3275
+
3276
+ byte[] bytes = baos.toByteArray();
3277
+
3278
+ System.out.println("clone = " + bytes.length);
3279
+
3280
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3281
+ ObjectInputStream in = new ObjectInputStream(bais);
3282
+ Object obj = in.readObject();
3283
+ in.close();
3284
+
3285
+ return obj;
3286
+ } catch (Exception e)
3287
+ {
3288
+ System.err.println(e);
3289
+ return null;
3290
+ }
3291
+ }
3292
+
3293
+ cRadio GetCurrentTab()
3294
+ {
3295
+ cRadio ab;
3296
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3297
+ {
3298
+ ab = (cRadio)e.nextElement();
3299
+ if(ab.GetObject() == copy)
3300
+ {
3301
+ return ab;
3302
+ }
3303
+ }
3304
+
3305
+ return null;
3306
+ }
3307
+
3308
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3309
+
3310
+ public void Save()
3311
+ {
3312
+ cRadio tab = GetCurrentTab();
3313
+
3314
+ boolean temp = CameraPane.SWITCH;
3315
+ CameraPane.SWITCH = false;
3316
+
3317
+ copy.ExtractBigData(hashtable);
3318
+
3319
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3320
+ tab.graphs[tab.undoindex++] = Compress(copy);
3321
+
3322
+ copy.RestoreBigData(hashtable);
3323
+
3324
+ CameraPane.SWITCH = temp;
3325
+
3326
+ //assert(hashtable.isEmpty());
3327
+
3328
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3329
+ {
3330
+ tab.graphs[i] = null;
3331
+ }
3332
+
3333
+ // test save
3334
+ if (false)
3335
+ {
3336
+ try
3337
+ {
3338
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3339
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3340
+
3341
+ p.writeObject(copy);
3342
+
3343
+ p.flush();
3344
+
3345
+ ostream.close();
3346
+ } catch (Exception e)
3347
+ {
3348
+ e.printStackTrace();
3349
+ }
3350
+ }
3351
+ }
3352
+
3353
+ void CopyChanged(Object3D obj)
3354
+ {
3355
+ boolean temp = CameraPane.SWITCH;
3356
+ CameraPane.SWITCH = false;
3357
+
3358
+ copy.ExtractBigData(hashtable);
3359
+
3360
+ copy.clear();
3361
+
3362
+ for (int i=0; i<obj.Size(); i++)
3363
+ {
3364
+ copy.add(obj.get(i));
3365
+ }
3366
+
3367
+ copy.RestoreBigData(hashtable);
3368
+
3369
+ CameraPane.SWITCH = temp;
3370
+
3371
+ //assert(hashtable.isEmpty());
3372
+
3373
+ copy.Touch();
3374
+
3375
+ ResetModel();
3376
+ copy.HardTouch(); // recompile?
3377
+
3378
+ cRadio ab;
3379
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3380
+ {
3381
+ ab = (cRadio)e.nextElement();
3382
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3383
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3384
+ if (test != null)
3385
+ {
3386
+ test.editWindow = ab.object.editWindow;
3387
+ ab.object = test;
3388
+ }
3389
+ }
3390
+
3391
+ refreshContents();
3392
+ }
3393
+
3394
+ public void Undo()
3395
+ {
3396
+ cRadio tab = GetCurrentTab();
3397
+
3398
+ if (tab.undoindex == 0)
3399
+ {
3400
+ java.awt.Toolkit.getDefaultToolkit().beep();
3401
+ return;
3402
+ }
3403
+
3404
+ if (tab.graphs[tab.undoindex] == null)
3405
+ {
3406
+ Save();
3407
+ tab.undoindex -= 1;
3408
+ }
3409
+
3410
+ tab.undoindex -= 1;
3411
+
3412
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3413
+ }
3414
+
3415
+ public void Redo()
3416
+ {
3417
+ cRadio tab = GetCurrentTab();
3418
+
3419
+ if (tab.graphs[tab.undoindex + 1] == null)
3420
+ {
3421
+ java.awt.Toolkit.getDefaultToolkit().beep();
3422
+ return;
3423
+ }
3424
+
3425
+ tab.undoindex += 1;
3426
+
3427
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3428
+ }
3429
+
3430
+ void ImportGFD()
3431
+ {
3432
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3433
+ browser.show();
3434
+ String filename = browser.getFile();
3435
+ if (filename != null && filename.length() > 0)
3436
+ {
3437
+ String fullname = browser.getDirectory() + filename;
3438
+
3439
+ //Object3D readobj =
3440
+ objEditor.ReadGFD(fullname, objEditor);
3441
+ //makeSomething(readobj);
3442
+ }
3443
+ }
3444
+
3445
+ void ImportVRMLX3D()
3446
+ {
3447
+ if (Grafreed.standAlone)
3448
+ {
3449
+ /**/
3450
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3451
+ browser.show();
3452
+ String filename = browser.getFile();
3453
+ if (filename != null && filename.length() > 0)
3454
+ {
3455
+ String fullname = browser.getDirectory() + filename;
3456
+ LoadVRMLX3D(fullname);
3457
+ }
3458
+ /**/
3459
+ }
3460
+ }
3461
+
32193462 void ToggleAnimation()
32203463 {
32213464 if (!Globals.ANIMATION)
....@@ -3231,8 +3474,8 @@
32313474
32323475 Globals.ANIMATION ^= true;
32333476
3234
- GrafreeD.wav.cursor = 0;
3235
- GrafreeD.wav.loop = 0;
3477
+ Grafreed.wav.cursor = 0;
3478
+ Grafreed.wav.loop = 0;
32363479 }
32373480 } else
32383481 {
....@@ -3253,7 +3496,6 @@
32533496 callee.refreshContents();
32543497 } else
32553498 {
3256
- new Exception().printStackTrace();
32573499 System.exit(0);
32583500 }
32593501 }
....@@ -3283,7 +3525,7 @@
32833525 void CreateMaterial()
32843526 {
32853527 //copy.ClearMaterial(); // PATCH
3286
- copy.CreateMaterialS(multiplyToggle.isSelected());
3528
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32873529 if (copy.selection.size() > 0)
32883530 //SetMaterial(copy);
32893531 {
....@@ -3342,11 +3584,11 @@
33423584 {
33433585 copy.ResetBlockLoop(); // temporary problem
33443586
3345
- boolean random = CameraPane.RANDOM;
3346
- CameraPane.RANDOM = false; // parse everything
3587
+ boolean random = CameraPane.SWITCH;
3588
+ CameraPane.SWITCH = false; // parse everything
33473589 copy.ResetDisplayList();
33483590 copy.HardTouch();
3349
- CameraPane.RANDOM = random;
3591
+ CameraPane.SWITCH = random;
33503592 }
33513593
33523594 // public void applySelf()
....@@ -3420,6 +3662,36 @@
34203662 {
34213663 //System.out.println("Propagate = " + propagate);
34223664 copy.UpdateMaterial(anchor, current, propagate);
3665
+
3666
+ if (copy.material != null)
3667
+ {
3668
+ cMaterial mat = copy.material;
3669
+
3670
+ colorField.SetToolTipValue((mat.color));
3671
+ modulationField.SetToolTipValue((mat.modulation));
3672
+ metalnessField.SetToolTipValue((mat.metalness));
3673
+ diffuseField.SetToolTipValue((mat.diffuse));
3674
+ specularField.SetToolTipValue((mat.specular));
3675
+ shininessField.SetToolTipValue((mat.shininess));
3676
+ shiftField.SetToolTipValue((mat.shift));
3677
+ ambientField.SetToolTipValue((mat.ambient));
3678
+ lightareaField.SetToolTipValue((mat.lightarea));
3679
+ diffusenessField.SetToolTipValue((mat.factor));
3680
+ velvetField.SetToolTipValue((mat.velvet));
3681
+ sheenField.SetToolTipValue((mat.sheen));
3682
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3683
+ backlitField.SetToolTipValue((mat.bump));
3684
+ anisoField.SetToolTipValue((mat.aniso));
3685
+ anisoVField.SetToolTipValue((mat.anisoV));
3686
+ cameraField.SetToolTipValue((mat.cameralight));
3687
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3688
+ shadowField.SetToolTipValue((mat.shadow));
3689
+ textureField.SetToolTipValue((mat.texture));
3690
+ opacityField.SetToolTipValue((mat.opacity));
3691
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3692
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3693
+ }
3694
+
34233695 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34243696 {
34253697 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3535,7 +3807,7 @@
35353807 }
35363808
35373809 if (normalpushField != null)
3538
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3810
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35393811 }
35403812
35413813 void SnapObject()
....@@ -3799,6 +4071,7 @@
37994071
38004072 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38014073 {
4074
+ Save();
38024075 //Tween.set(thing, 0).target(1).start(tweenManager);
38034076 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38044077 // if (thing instanceof GenericJointDemo)
....@@ -4002,6 +4275,7 @@
40024275 }
40034276 }
40044277 }
4278
+
40054279 LoadGFDThread loadGFDThread;
40064280
40074281 void ReadGFD(String fullname, iCallBack cb)
....@@ -4022,7 +4296,8 @@
40224296 try
40234297 {
40244298 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4025
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4299
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4300
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40264301
40274302 readobj = (Object3D) p.readObject();
40284303 istream.close();
....@@ -4030,7 +4305,20 @@
40304305 readobj.ResetDisplayList();
40314306 } catch (Exception e)
40324307 {
4033
- e.printStackTrace();
4308
+ //e.printStackTrace();
4309
+ try
4310
+ {
4311
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4312
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4313
+
4314
+ readobj = (Object3D) p.readObject();
4315
+ istream.close();
4316
+
4317
+ readobj.ResetDisplayList();
4318
+ } catch (Exception e2)
4319
+ {
4320
+ e2.printStackTrace();
4321
+ }
40344322 }
40354323 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40364324 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4085,6 +4373,7 @@
40854373
40864374 if (readobj != null)
40874375 {
4376
+ Save();
40884377 try
40894378 {
40904379 //readobj.deepCopySelf(copy);
....@@ -4147,7 +4436,7 @@
41474436
41484437 void load() // throws ClassNotFoundException
41494438 {
4150
- if (GrafreeD.standAlone)
4439
+ if (Grafreed.standAlone)
41514440 {
41524441 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41534442 browser.show();
....@@ -4234,11 +4523,13 @@
42344523 try
42354524 {
42364525 FileOutputStream ostream = new FileOutputStream(lastname);
4237
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4526
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4527
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42384528
42394529 p.writeObject(copy);
42404530 p.flush();
42414531
4532
+ zstream.close();
42424533 ostream.close();
42434534
42444535 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4248,11 +4539,12 @@
42484539 {
42494540 }
42504541 }
4542
+
42514543 String lastname;
42524544
42534545 void saveAs()
42544546 {
4255
- if (GrafreeD.standAlone)
4547
+ if (Grafreed.standAlone)
42564548 {
42574549 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42584550 browser.setVisible(true);
....@@ -4357,13 +4649,13 @@
43574649 try
43584650 {
43594651 FileOutputStream ostream = new FileOutputStream(filename);
4360
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4361
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4652
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4653
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43624654
43634655 Object3D objectparent = obj.parent;
43644656 obj.parent = null;
43654657
4366
- Object3D object = (Object3D) GrafreeD.clone(obj);
4658
+ Object3D object = (Object3D) Grafreed.clone(obj);
43674659
43684660 obj.parent = objectparent;
43694661
....@@ -4375,8 +4667,8 @@
43754667 p.writeObject(object);
43764668 p.flush();
43774669
4670
+ zstream.close();
43784671 ostream.close();
4379
- // zstream.close();
43804672
43814673 // group.selection.get(0).parent = parent;
43824674 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4397,7 +4689,7 @@
43974689 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43984690 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43994691 copy.generatePOV(buffer);
4400
- if (GrafreeD.standAlone)
4692
+ if (Grafreed.standAlone)
44014693 {
44024694 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44034695 browser.show();
....@@ -4423,7 +4715,8 @@
44234715 Object3D client;
44244716 Object3D copy;
44254717 MenuBar menuBar;
4426
- Menu windowMenu;
4718
+ Menu fileMenu;
4719
+ MenuItem newItem;
44274720 MenuItem loadItem;
44284721 MenuItem saveItem;
44294722 MenuItem saveAsItem;
....@@ -4431,11 +4724,9 @@
44314724 MenuItem reexportItem;
44324725 MenuItem povItem;
44334726 MenuItem closeItem;
4434
- Menu cameraMenu;
4727
+
44354728 CheckboxMenuItem zBufferItem;
44364729 //MenuItem normalLensItem;
4437
- MenuItem editCameraItem;
4438
- MenuItem revertCameraItem;
44394730 MenuItem stepItem;
44404731 CheckboxMenuItem toggleLiveItem;
44414732 CheckboxMenuItem toggleFullScreenItem;
....@@ -4446,7 +4737,7 @@
44464737 CheckboxMenuItem toggleFootContactItem;
44474738 CheckboxMenuItem toggleDLItem;
44484739 CheckboxMenuItem toggleTextureItem;
4449
- CheckboxMenuItem toggleRandomItem;
4740
+ CheckboxMenuItem toggleSwitchItem;
44504741 CheckboxMenuItem toggleRootItem;
44514742 CheckboxMenuItem animationItem;
44524743 CheckboxMenuItem toggleHandleItem;
....@@ -4583,4 +4874,9 @@
45834874 //ObjectUI parent;
45844875
45854876 cNumberSlider normalpushField;
4877
+
4878
+ private MenuItem importGFDItem;
4879
+ private MenuItem importVRMLX3DItem;
4880
+ private MenuItem import3DSItem;
4881
+ private MenuItem importOBJItem;
45864882 }