Normand Briere
2019-06-09 79d0f9a45d36656051a77a7b0837aa0318f81ee5
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,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)
....@@ -2373,11 +2343,11 @@
23732343
23742344 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23752345 {
2376
- if (GrafreeD.standAlone)
2346
+ if (Grafreed.standAlone)
23772347 {
23782348 /**/
23792349 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2380
- browser.show();
2350
+ browser.setVisible(true);
23812351 String filename = browser.getFile();
23822352 if (filename != null && filename.length() > 0)
23832353 {
....@@ -2737,7 +2707,8 @@
27372707 return;
27382708 }
27392709
2740
- multiplyToggle.setSelected(mat.multiply);
2710
+ if (multiplyToggle != null)
2711
+ multiplyToggle.setSelected(mat.multiply);
27412712
27422713 assert (object.projectedVertices != null);
27432714
....@@ -2952,7 +2923,7 @@
29522923 frame.validate();
29532924
29542925 return;
2955
- } else if (event.getSource() == toggleRandomItem)
2926
+ } else if (event.getSource() == toggleSwitchItem)
29562927 {
29572928 cameraView.ToggleRandom();
29582929 cameraView.repaint();
....@@ -2982,6 +2953,10 @@
29822953 } else if (event.getSource() == liveCB)
29832954 {
29842955 copy.live ^= true;
2956
+ return;
2957
+ } else if (event.getSource() == selectCB)
2958
+ {
2959
+ copy.dontselect ^= true;
29852960 return;
29862961 } else if (event.getSource() == hideCB)
29872962 {
....@@ -3021,8 +2996,9 @@
30212996
30222997 public void actionPerformed(ActionEvent event)
30232998 {
2999
+ Object source = event.getSource();
30243000 // SCRIPT DIALOG
3025
- if (event.getSource() == okbutton)
3001
+ if (source == okbutton)
30263002 {
30273003 textpanel.setVisible(false);
30283004 textpanel.remove(textarea);
....@@ -3034,7 +3010,7 @@
30343010 textarea = null;
30353011 textpanel = null;
30363012 }
3037
- if (event.getSource() == cancelbutton)
3013
+ if (source == cancelbutton)
30383014 {
30393015 textpanel.setVisible(false);
30403016 textpanel.remove(textarea);
....@@ -3046,50 +3022,50 @@
30463022 //applySelf();
30473023 //client.refreshEditWindow();
30483024 //refreshContents();
3049
- if (event.getSource() == nameField)
3025
+ if (source == nameField)
30503026 {
30513027 //System.out.println("ObjEditor " + event);
30523028 applySelf0(true);
30533029 //parent.applySelf();
30543030 objEditor.refreshContents();
3055
- } else if (event.getSource() == resetButton)
3031
+ } else if (source == resetButton)
30563032 {
30573033 CameraPane.fullreset = true;
30583034 copy.Reset(); // ResetMeshes();
30593035 copy.Touch();
30603036 objEditor.refreshContents();
3061
- } else if (event.getSource() == stepItem)
3037
+ } else if (source == stepItem)
30623038 {
30633039 //cameraView.ONESTEP = true;
30643040 Globals.ONESTEP = true;
30653041 cameraView.repaint();
30663042 return;
3067
- } else if (event.getSource() == stepButton)
3043
+ } else if (source == stepButton)
30683044 {
30693045 copy.Step();
30703046 copy.Touch();
30713047 objEditor.refreshContents();
3072
- } else if (event.getSource() == slowerButton)
3048
+ } else if (source == slowerButton)
30733049 {
30743050 copy.Slower();
30753051 copy.Touch();
30763052 objEditor.refreshContents();
3077
- } else if (event.getSource() == fasterButton)
3053
+ } else if (source == fasterButton)
30783054 {
30793055 copy.Faster();
30803056 copy.Touch();
30813057 objEditor.refreshContents();
3082
- } else if (event.getSource() == remarkButton)
3058
+ } else if (source == remarkButton)
30833059 {
30843060 copy.Remark();
30853061 copy.Touch();
30863062 objEditor.refreshContents();
3087
- } else if (event.getSource() == stepAllButton)
3063
+ } else if (source == stepAllButton)
30883064 {
30893065 copy.StepAll();
30903066 copy.Touch();
30913067 objEditor.refreshContents();
3092
- } else if (event.getSource() == resetAllButton)
3068
+ } else if (source == resetAllButton)
30933069 {
30943070 //CameraPane.fullreset = true;
30953071 copy.ResetAll(); // ResetMeshes();
....@@ -3122,53 +3098,75 @@
31223098 // Close();
31233099 // }
31243100 // else
3125
- if (event.getSource() == resetSlidersButton)
3101
+ if (source == resetSlidersButton)
31263102 {
31273103 ResetSliders();
3128
- } else if (event.getSource() == clearMaterialButton)
3104
+ } else if (source == clearMaterialButton)
31293105 {
31303106 ClearMaterial();
3131
- } else if (event.getSource() == createMaterialButton)
3107
+ } else if (source == createMaterialButton)
31323108 {
31333109 CreateMaterial();
3134
- } else if (event.getSource() == clearPanelButton)
3110
+ } else if (source == clearPanelButton)
31353111 {
31363112 copy.ClearUI();
31373113 refreshContents(true);
3138
- } /*
3139
- }
3140
-
3141
- public boolean action(Event event, Object arg)
3142
- {
3143
- */ else if (event.getSource() == closeItem)
3114
+ } else if (source == importGFDItem)
3115
+ {
3116
+ ImportGFD();
3117
+ } else
3118
+ if (source == importVRMLX3DItem)
3119
+ {
3120
+ ImportVRMLX3D();
3121
+ } else
3122
+ if (source == import3DSItem)
3123
+ {
3124
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3125
+ } else
3126
+ if (source == importOBJItem)
3127
+ {
3128
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3129
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3130
+ browser.setVisible(true);
3131
+ String filename = browser.getFile();
3132
+ if (filename != null && filename.length() > 0)
3133
+ {
3134
+ String fullname = browser.getDirectory() + filename;
3135
+ makeSomething(ReadOBJ(fullname), true);
3136
+ }
3137
+ } else
3138
+ if (source == closeItem)
31443139 {
31453140 Close();
31463141 //return true;
3147
- } else if (event.getSource() == loadItem)
3142
+ } else if (source == loadItem)
31483143 {
31493144 load();
31503145 //return true;
3151
- } else if (event.getSource() == saveItem)
3146
+ } else if (source == newItem)
3147
+ {
3148
+ New();
3149
+ } else if (source == saveItem)
31523150 {
31533151 save();
31543152 //return true;
3155
- } else if (event.getSource() == saveAsItem)
3153
+ } else if (source == saveAsItem)
31563154 {
31573155 saveAs();
31583156 //return true;
3159
- } else if (event.getSource() == reexportItem)
3157
+ } else if (source == reexportItem)
31603158 {
31613159 reexport();
31623160 //return true;
3163
- } else if (event.getSource() == exportAsItem)
3161
+ } else if (source == exportAsItem)
31643162 {
31653163 export();
31663164 //return true;
3167
- } else if (event.getSource() == povItem)
3165
+ } else if (source == povItem)
31683166 {
31693167 generatePOV();
31703168 //return true;
3171
- } else if (event.getSource() == zBufferItem)
3169
+ } else if (source == zBufferItem)
31723170 {
31733171 try
31743172 {
....@@ -3190,21 +3188,8 @@
31903188 cameraView.repaint();
31913189 //return true;
31923190 }
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)
3191
+ */ else // combos...
3192
+ if (source == texresMenu)
32083193 {
32093194 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32103195 copy.texres = texresMenu.getSelectedIndex();
....@@ -3216,6 +3201,150 @@
32163201 }
32173202 }
32183203
3204
+ void New()
3205
+ {
3206
+ while (copy.Size() > 1)
3207
+ {
3208
+ copy.remove(1);
3209
+ }
3210
+
3211
+ ResetModel();
3212
+ objEditor.refreshContents();
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
+
3316
+ void ImportGFD()
3317
+ {
3318
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3319
+ browser.show();
3320
+ String filename = browser.getFile();
3321
+ if (filename != null && filename.length() > 0)
3322
+ {
3323
+ String fullname = browser.getDirectory() + filename;
3324
+
3325
+ //Object3D readobj =
3326
+ objEditor.ReadGFD(fullname, objEditor);
3327
+ //makeSomething(readobj);
3328
+ }
3329
+ }
3330
+
3331
+ void ImportVRMLX3D()
3332
+ {
3333
+ if (Grafreed.standAlone)
3334
+ {
3335
+ /**/
3336
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3337
+ browser.show();
3338
+ String filename = browser.getFile();
3339
+ if (filename != null && filename.length() > 0)
3340
+ {
3341
+ String fullname = browser.getDirectory() + filename;
3342
+ LoadVRMLX3D(fullname);
3343
+ }
3344
+ /**/
3345
+ }
3346
+ }
3347
+
32193348 void ToggleAnimation()
32203349 {
32213350 if (!Globals.ANIMATION)
....@@ -3231,8 +3360,8 @@
32313360
32323361 Globals.ANIMATION ^= true;
32333362
3234
- GrafreeD.wav.cursor = 0;
3235
- GrafreeD.wav.loop = 0;
3363
+ Grafreed.wav.cursor = 0;
3364
+ Grafreed.wav.loop = 0;
32363365 }
32373366 } else
32383367 {
....@@ -3253,7 +3382,6 @@
32533382 callee.refreshContents();
32543383 } else
32553384 {
3256
- new Exception().printStackTrace();
32573385 System.exit(0);
32583386 }
32593387 }
....@@ -3283,7 +3411,7 @@
32833411 void CreateMaterial()
32843412 {
32853413 //copy.ClearMaterial(); // PATCH
3286
- copy.CreateMaterialS(multiplyToggle.isSelected());
3414
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32873415 if (copy.selection.size() > 0)
32883416 //SetMaterial(copy);
32893417 {
....@@ -3342,11 +3470,11 @@
33423470 {
33433471 copy.ResetBlockLoop(); // temporary problem
33443472
3345
- boolean random = CameraPane.RANDOM;
3346
- CameraPane.RANDOM = false; // parse everything
3473
+ boolean random = CameraPane.SWITCH;
3474
+ CameraPane.SWITCH = false; // parse everything
33473475 copy.ResetDisplayList();
33483476 copy.HardTouch();
3349
- CameraPane.RANDOM = random;
3477
+ CameraPane.SWITCH = random;
33503478 }
33513479
33523480 // public void applySelf()
....@@ -3420,6 +3548,36 @@
34203548 {
34213549 //System.out.println("Propagate = " + propagate);
34223550 copy.UpdateMaterial(anchor, current, propagate);
3551
+
3552
+ if (copy.material != null)
3553
+ {
3554
+ cMaterial mat = copy.material;
3555
+
3556
+ colorField.SetToolTipValue((mat.color));
3557
+ modulationField.SetToolTipValue((mat.modulation));
3558
+ metalnessField.SetToolTipValue((mat.metalness));
3559
+ diffuseField.SetToolTipValue((mat.diffuse));
3560
+ specularField.SetToolTipValue((mat.specular));
3561
+ shininessField.SetToolTipValue((mat.shininess));
3562
+ shiftField.SetToolTipValue((mat.shift));
3563
+ ambientField.SetToolTipValue((mat.ambient));
3564
+ lightareaField.SetToolTipValue((mat.lightarea));
3565
+ diffusenessField.SetToolTipValue((mat.factor));
3566
+ velvetField.SetToolTipValue((mat.velvet));
3567
+ sheenField.SetToolTipValue((mat.sheen));
3568
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3569
+ backlitField.SetToolTipValue((mat.bump));
3570
+ anisoField.SetToolTipValue((mat.aniso));
3571
+ anisoVField.SetToolTipValue((mat.anisoV));
3572
+ cameraField.SetToolTipValue((mat.cameralight));
3573
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3574
+ shadowField.SetToolTipValue((mat.shadow));
3575
+ textureField.SetToolTipValue((mat.texture));
3576
+ opacityField.SetToolTipValue((mat.opacity));
3577
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3578
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3579
+ }
3580
+
34233581 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34243582 {
34253583 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3535,7 +3693,7 @@
35353693 }
35363694
35373695 if (normalpushField != null)
3538
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3696
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35393697 }
35403698
35413699 void SnapObject()
....@@ -3799,6 +3957,7 @@
37993957
38003958 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38013959 {
3960
+ Save();
38023961 //Tween.set(thing, 0).target(1).start(tweenManager);
38033962 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38043963 // if (thing instanceof GenericJointDemo)
....@@ -4002,6 +4161,7 @@
40024161 }
40034162 }
40044163 }
4164
+
40054165 LoadGFDThread loadGFDThread;
40064166
40074167 void ReadGFD(String fullname, iCallBack cb)
....@@ -4022,7 +4182,8 @@
40224182 try
40234183 {
40244184 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4025
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4185
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4186
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40264187
40274188 readobj = (Object3D) p.readObject();
40284189 istream.close();
....@@ -4030,7 +4191,20 @@
40304191 readobj.ResetDisplayList();
40314192 } catch (Exception e)
40324193 {
4033
- e.printStackTrace();
4194
+ //e.printStackTrace();
4195
+ try
4196
+ {
4197
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4198
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4199
+
4200
+ readobj = (Object3D) p.readObject();
4201
+ istream.close();
4202
+
4203
+ readobj.ResetDisplayList();
4204
+ } catch (Exception e2)
4205
+ {
4206
+ e2.printStackTrace();
4207
+ }
40344208 }
40354209 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40364210 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4147,7 +4321,7 @@
41474321
41484322 void load() // throws ClassNotFoundException
41494323 {
4150
- if (GrafreeD.standAlone)
4324
+ if (Grafreed.standAlone)
41514325 {
41524326 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41534327 browser.show();
....@@ -4234,11 +4408,13 @@
42344408 try
42354409 {
42364410 FileOutputStream ostream = new FileOutputStream(lastname);
4237
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4411
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4412
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42384413
42394414 p.writeObject(copy);
42404415 p.flush();
42414416
4417
+ zstream.close();
42424418 ostream.close();
42434419
42444420 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4248,11 +4424,12 @@
42484424 {
42494425 }
42504426 }
4427
+
42514428 String lastname;
42524429
42534430 void saveAs()
42544431 {
4255
- if (GrafreeD.standAlone)
4432
+ if (Grafreed.standAlone)
42564433 {
42574434 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42584435 browser.setVisible(true);
....@@ -4357,13 +4534,13 @@
43574534 try
43584535 {
43594536 FileOutputStream ostream = new FileOutputStream(filename);
4360
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4361
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4537
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4538
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43624539
43634540 Object3D objectparent = obj.parent;
43644541 obj.parent = null;
43654542
4366
- Object3D object = (Object3D) GrafreeD.clone(obj);
4543
+ Object3D object = (Object3D) Grafreed.clone(obj);
43674544
43684545 obj.parent = objectparent;
43694546
....@@ -4375,8 +4552,8 @@
43754552 p.writeObject(object);
43764553 p.flush();
43774554
4555
+ zstream.close();
43784556 ostream.close();
4379
- // zstream.close();
43804557
43814558 // group.selection.get(0).parent = parent;
43824559 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4397,7 +4574,7 @@
43974574 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43984575 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43994576 copy.generatePOV(buffer);
4400
- if (GrafreeD.standAlone)
4577
+ if (Grafreed.standAlone)
44014578 {
44024579 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44034580 browser.show();
....@@ -4423,7 +4600,8 @@
44234600 Object3D client;
44244601 Object3D copy;
44254602 MenuBar menuBar;
4426
- Menu windowMenu;
4603
+ Menu fileMenu;
4604
+ MenuItem newItem;
44274605 MenuItem loadItem;
44284606 MenuItem saveItem;
44294607 MenuItem saveAsItem;
....@@ -4431,11 +4609,9 @@
44314609 MenuItem reexportItem;
44324610 MenuItem povItem;
44334611 MenuItem closeItem;
4434
- Menu cameraMenu;
4612
+
44354613 CheckboxMenuItem zBufferItem;
44364614 //MenuItem normalLensItem;
4437
- MenuItem editCameraItem;
4438
- MenuItem revertCameraItem;
44394615 MenuItem stepItem;
44404616 CheckboxMenuItem toggleLiveItem;
44414617 CheckboxMenuItem toggleFullScreenItem;
....@@ -4446,7 +4622,7 @@
44464622 CheckboxMenuItem toggleFootContactItem;
44474623 CheckboxMenuItem toggleDLItem;
44484624 CheckboxMenuItem toggleTextureItem;
4449
- CheckboxMenuItem toggleRandomItem;
4625
+ CheckboxMenuItem toggleSwitchItem;
44504626 CheckboxMenuItem toggleRootItem;
44514627 CheckboxMenuItem animationItem;
44524628 CheckboxMenuItem toggleHandleItem;
....@@ -4583,4 +4759,9 @@
45834759 //ObjectUI parent;
45844760
45854761 cNumberSlider normalpushField;
4762
+
4763
+ private MenuItem importGFDItem;
4764
+ private MenuItem importVRMLX3DItem;
4765
+ private MenuItem import3DSItem;
4766
+ private MenuItem importOBJItem;
45864767 }