Normand Briere
2019-06-16 7b6b5ba546450e71ecc812356952b594acc5add5
ObjEditor.java
....@@ -143,6 +143,8 @@
143143 //nameField.removeActionListener(this);
144144 // objEditor.ctrlPanel.remove(nameField);
145145
146
+ objEditor.ctrlPanel.remove(namePanel);
147
+
146148 if (!GroupEditor.allparams)
147149 return;
148150
....@@ -165,7 +167,6 @@
165167 // objEditor.ctrlPanel.remove(fasterButton);
166168 // objEditor.ctrlPanel.remove(remarkButton);
167169
168
- objEditor.ctrlPanel.remove(namePanel);
169170 objEditor.ctrlPanel.remove(setupPanel);
170171 objEditor.ctrlPanel.remove(commandsPanel);
171172 objEditor.ctrlPanel.remove(pushPanel);
....@@ -275,24 +276,40 @@
275276 void SetupMenu()
276277 {
277278 frame.setMenuBar(menuBar = new MenuBar());
278
- menuBar.add(windowMenu = new Menu("File"));
279
- windowMenu.add(loadItem = new MenuItem("Load..."));
280
- windowMenu.add("-");
281
- windowMenu.add(saveItem = new MenuItem("Save"));
282
- 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..."));
283299 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
284
- windowMenu.add("-");
285
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
286
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
287
- windowMenu.add("-");
300
+ fileMenu.add("-");
301
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
302
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
303
+ fileMenu.add("-");
288304 if (client.parent != null)
289305 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
306
+ fileMenu.add(closeItem = new MenuItem("Close"));
291307 } else
292308 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
309
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294310 }
295311
312
+ newItem.addActionListener(this);
296313 loadItem.addActionListener(this);
297314 saveItem.addActionListener(this);
298315 saveAsItem.addActionListener(this);
....@@ -300,61 +317,6 @@
300317 reexportItem.addActionListener(this);
301318 //povItem.addActionListener(this);
302319 closeItem.addActionListener(this);
303
-
304
- menuBar.add(cameraMenu = new Menu("View"));
305
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
306
- //zBufferItem.addActionListener(this);
307
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
308
- //normalLensItem.addActionListener(this);
309
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
310
- revertCameraItem.addActionListener(this);
311
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
312
- toggleTimelineItem.addItemListener(this);
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
318
- toggleTextureItem.addItemListener(this);
319
- toggleTextureItem.setState(CameraPane.textureon);
320
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
321
- toggleLiveItem.addItemListener(this);
322
- toggleLiveItem.setState(Globals.isLIVE());
323
- cameraMenu.add(stepItem = new MenuItem("Step"));
324
- stepItem.addActionListener(this);
325
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
326
-// toggleDLItem.addItemListener(this);
327
-// toggleDLItem.setState(false);
328
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
329
- toggleRenderItem.addItemListener(this);
330
- toggleRenderItem.setState(!CameraPane.frozen);
331
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
332
- toggleDebugItem.addItemListener(this);
333
- toggleDebugItem.setState(CameraPane.DEBUG);
334
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
335
- toggleFrustumItem.addItemListener(this);
336
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
337
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
338
- toggleFootContactItem.addItemListener(this);
339
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
340
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
341
- toggleRandomItem.addItemListener(this);
342
- toggleRandomItem.setState(CameraPane.RANDOM);
343
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
344
- toggleHandleItem.addItemListener(this);
345
- toggleHandleItem.setState(CameraPane.HANDLES);
346
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
347
- togglePaintItem.addItemListener(this);
348
- togglePaintItem.setState(CameraPane.PAINTMODE);
349
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
350
-// toggleRootItem.addItemListener(this);
351
-// toggleRootItem.setState(false);
352
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
353
-// animationItem.addItemListener(this);
354
-// animationItem.setState(CameraPane.ANIMATION);
355
- cameraMenu.add("-");
356
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
357
- editCameraItem.addActionListener(this);
358320
359321 objectPanel = new JTabbedPane();
360322 toolbarPanel = new JPanel();
....@@ -457,10 +419,10 @@
457419 e.printStackTrace();
458420 }
459421
460
- String selection = infoarea.getText();
461
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
462
- java.awt.datatransfer.Clipboard clipboard =
463
- Toolkit.getDefaultToolkit().getSystemClipboard();
422
+// String selection = infoarea.getText();
423
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
424
+// java.awt.datatransfer.Clipboard clipboard =
425
+// Toolkit.getDefaultToolkit().getSystemClipboard();
464426 //clipboard.setContents(data, data);
465427 }
466428
....@@ -483,13 +445,13 @@
483445 //SendInfo("Name:", "bold");
484446 if (sel.GetTextures() != null || debug)
485447 {
486
- si.SendInfo(sel.toString(), "bold");
448
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
487449 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
488450 if (sel.Size() > 0)
489451 {
490452 si.SendInfo("#children = " + sel.Size(), "regular");
491453 }
492
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
454
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
493455 if (debug)
494456 {
495457 try
....@@ -531,7 +493,7 @@
531493 }
532494 if (sel.support != null)
533495 {
534
- si.SendInfo(" support: " + sel.support, "regular");
496
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
535497 }
536498 if (sel.scriptnode != null)
537499 {
....@@ -734,7 +696,7 @@
734696 protected static ImageIcon createImageIcon(String path,
735697 String description)
736698 {
737
- java.net.URL imgURL = GrafreeD.class.getResource(path);
699
+ java.net.URL imgURL = Grafreed.class.getResource(path);
738700 if (imgURL != null)
739701 {
740702 return new ImageIcon(imgURL, description);
....@@ -766,6 +728,7 @@
766728 // NumberSlider vDivsField;
767729 // JCheckBox endcaps;
768730 JCheckBox liveCB;
731
+ JCheckBox selectCB;
769732 JCheckBox hideCB;
770733 JCheckBox link2masterCB;
771734 JCheckBox markCB;
....@@ -967,33 +930,52 @@
967930 setupPanel = new cGridBag().setVertical(false);
968931
969932 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
970
- if (Globals.ADVANCED)
971
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
972
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
933
+ liveCB.setToolTipText("Animate object");
934
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
+ selectCB.setToolTipText("Make object selectable");
973936 // Return();
937
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
938
+ hideCB.setToolTipText("Hide object");
974939 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
975
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
976
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
940
+ markCB.setToolTipText("Set the animation target transform");
941
+
942
+ rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
943
+ rewindCB.setToolTipText("Rewind animation");
944
+
945
+ randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
+ randomCB.setToolTipText("Option for switch node");
977947
948
+ if (Globals.ADVANCED)
949
+ {
950
+ link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
+ link2masterCB.setToolTipText("Attach to support");
952
+ speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
953
+ speedupCB.setToolTipText("Option motion capture");
954
+ }
955
+
978956 oe.ctrlPanel.add(setupPanel);
979957 oe.ctrlPanel.Return();
980958
981959 commandsPanel = new cGridBag().setVertical(false);
982960
983961 resetButton = AddButton(commandsPanel, "Reset");
962
+ resetButton.setToolTipText("Jump to frame zero");
984963 stepButton = AddButton(commandsPanel, "Step");
964
+ stepButton.setToolTipText("Step one frame");
985965 // resetAllButton = AddButton(oe, "Reset All");
986966 // stepAllButton = AddButton(oe, "Step All");
987
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
988967 // Return();
989968 slowerButton = AddButton(commandsPanel, "Slow");
969
+ slowerButton.setToolTipText("Decrease animation speed");
990970 fasterButton = AddButton(commandsPanel, "Fast");
971
+ fasterButton.setToolTipText("Increase animation speed");
991972 remarkButton = AddButton(commandsPanel, "Remark");
973
+ remarkButton.setToolTipText("Set the current transform as the target");
992974
993975 oe.ctrlPanel.add(commandsPanel);
994976 oe.ctrlPanel.Return();
995977
996
- 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
997979 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
998980 //Return();
999981
....@@ -1295,7 +1277,7 @@
12951277 scrollpane.addMouseWheelListener(this); // Default not fast enough
12961278
12971279 /*JTabbedPane*/ scenePanel = new cGridBag();
1298
- scenePanel.preferredWidth = 7;
1280
+ scenePanel.preferredWidth = 6;
12991281
13001282 JTabbedPane tabbedPane = new JTabbedPane();
13011283 tabbedPane.add(scrollpane);
....@@ -1401,8 +1383,8 @@
14011383
14021384 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14031385
1404
- frame.setSize(1024, 768);
1405
- frame.show();
1386
+ frame.setSize(1280, 860);
1387
+ frame.setVisible(true);
14061388
14071389 gridPanel.setDividerLocation(1.0);
14081390
....@@ -1441,19 +1423,22 @@
14411423
14421424 cGridBag editBar = new cGridBag().setVertical(false);
14431425
1444
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1426
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14451427 createMaterialButton.setToolTipText("Create material");
14461428
14471429 /*
14481430 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14491431 */
14501432
1451
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1433
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14521434 clearMaterialButton.setToolTipText("Clear material");
14531435
1454
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1455
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1456
- 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
+ }
14571442
14581443 editBar.preferredHeight = 15;
14591444
....@@ -1722,12 +1707,15 @@
17221707 opacityPowerField.addChangeListener(this);
17231708 /**/
17241709
1725
- resetSlidersButton.addActionListener(this);
17261710 clearMaterialButton.addActionListener(this);
17271711 createMaterialButton.addActionListener(this);
1728
-
1729
- propagateToggle.addItemListener(this);
1730
- multiplyToggle.addItemListener(this);
1712
+
1713
+ if (Globals.ADVANCED)
1714
+ {
1715
+ resetSlidersButton.addActionListener(this);
1716
+ propagateToggle.addItemListener(this);
1717
+ multiplyToggle.addItemListener(this);
1718
+ }
17311719 }
17321720
17331721 void DropFile(java.io.File[] files, boolean textures)
....@@ -1898,7 +1886,7 @@
18981886
18991887 //? flashIt = false;
19001888 CameraPane pane = (CameraPane) cameraView;
1901
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
19021890 pane.clickEnd(location.x, location.y, 0, true);
19031891
19041892 if (group.selection.size() == 1)
....@@ -1947,6 +1935,7 @@
19471935 e2.printStackTrace();
19481936 }
19491937 }
1938
+
19501939 LoadJMEThread loadThread;
19511940
19521941 class LoadJMEThread extends Thread
....@@ -2004,6 +1993,7 @@
20041993 //LoadFile0(filename, converter);
20051994 }
20061995 }
1996
+
20071997 LoadOBJThread loadObjThread;
20081998
20091999 class LoadOBJThread extends Thread
....@@ -2082,19 +2072,19 @@
20822072
20832073 void LoadObjFile(String fullname)
20842074 {
2085
- /*
2075
+ System.out.println("Loading " + fullname);
2076
+ /**/
20862077 //lastFilename = fullname;
20872078 if(loadObjThread == null)
20882079 {
2089
- loadObjThread = new LoadOBJThread();
2090
- loadObjThread.start();
2080
+ loadObjThread = new LoadOBJThread();
2081
+ loadObjThread.start();
20912082 }
20922083
20932084 loadObjThread.add(fullname);
2094
- */
2085
+ /**/
20952086
2096
- System.out.println("Loading " + fullname);
2097
- makeSomething(new FileObject(fullname, true), true);
2087
+ //makeSomething(new FileObject(fullname, true), true);
20982088 }
20992089
21002090 void LoadGFDFile(String fullname)
....@@ -2355,11 +2345,11 @@
23552345
23562346 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23572347 {
2358
- if (GrafreeD.standAlone)
2348
+ if (Grafreed.standAlone)
23592349 {
23602350 /**/
23612351 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2362
- browser.show();
2352
+ browser.setVisible(true);
23632353 String filename = browser.getFile();
23642354 if (filename != null && filename.length() > 0)
23652355 {
....@@ -2719,7 +2709,8 @@
27192709 return;
27202710 }
27212711
2722
- multiplyToggle.setSelected(mat.multiply);
2712
+ if (multiplyToggle != null)
2713
+ multiplyToggle.setSelected(mat.multiply);
27232714
27242715 assert (object.projectedVertices != null);
27252716
....@@ -2934,9 +2925,9 @@
29342925 frame.validate();
29352926
29362927 return;
2937
- } else if (event.getSource() == toggleRandomItem)
2928
+ } else if (event.getSource() == toggleSwitchItem)
29382929 {
2939
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29402931 cameraView.repaint();
29412932 return;
29422933 } else if (event.getSource() == toggleHandleItem)
....@@ -2965,6 +2956,10 @@
29652956 {
29662957 copy.live ^= true;
29672958 return;
2959
+ } else if (event.getSource() == selectCB)
2960
+ {
2961
+ copy.dontselect ^= true;
2962
+ return;
29682963 } else if (event.getSource() == hideCB)
29692964 {
29702965 copy.hide ^= true;
....@@ -2979,6 +2974,7 @@
29792974 if (event.getSource() == randomCB)
29802975 {
29812976 copy.random ^= true;
2977
+ objEditor.refreshContents();
29822978 return;
29832979 }
29842980 if (event.getSource() == speedupCB)
....@@ -3002,8 +2998,9 @@
30022998
30032999 public void actionPerformed(ActionEvent event)
30043000 {
3001
+ Object source = event.getSource();
30053002 // SCRIPT DIALOG
3006
- if (event.getSource() == okbutton)
3003
+ if (source == okbutton)
30073004 {
30083005 textpanel.setVisible(false);
30093006 textpanel.remove(textarea);
....@@ -3015,7 +3012,7 @@
30153012 textarea = null;
30163013 textpanel = null;
30173014 }
3018
- if (event.getSource() == cancelbutton)
3015
+ if (source == cancelbutton)
30193016 {
30203017 textpanel.setVisible(false);
30213018 textpanel.remove(textarea);
....@@ -3027,50 +3024,50 @@
30273024 //applySelf();
30283025 //client.refreshEditWindow();
30293026 //refreshContents();
3030
- if (event.getSource() == nameField)
3027
+ if (source == nameField)
30313028 {
30323029 //System.out.println("ObjEditor " + event);
30333030 applySelf0(true);
30343031 //parent.applySelf();
30353032 objEditor.refreshContents();
3036
- } else if (event.getSource() == resetButton)
3033
+ } else if (source == resetButton)
30373034 {
30383035 CameraPane.fullreset = true;
30393036 copy.Reset(); // ResetMeshes();
30403037 copy.Touch();
30413038 objEditor.refreshContents();
3042
- } else if (event.getSource() == stepItem)
3039
+ } else if (source == stepItem)
30433040 {
30443041 //cameraView.ONESTEP = true;
30453042 Globals.ONESTEP = true;
30463043 cameraView.repaint();
30473044 return;
3048
- } else if (event.getSource() == stepButton)
3045
+ } else if (source == stepButton)
30493046 {
30503047 copy.Step();
30513048 copy.Touch();
30523049 objEditor.refreshContents();
3053
- } else if (event.getSource() == slowerButton)
3050
+ } else if (source == slowerButton)
30543051 {
30553052 copy.Slower();
30563053 copy.Touch();
30573054 objEditor.refreshContents();
3058
- } else if (event.getSource() == fasterButton)
3055
+ } else if (source == fasterButton)
30593056 {
30603057 copy.Faster();
30613058 copy.Touch();
30623059 objEditor.refreshContents();
3063
- } else if (event.getSource() == remarkButton)
3060
+ } else if (source == remarkButton)
30643061 {
30653062 copy.Remark();
30663063 copy.Touch();
30673064 objEditor.refreshContents();
3068
- } else if (event.getSource() == stepAllButton)
3065
+ } else if (source == stepAllButton)
30693066 {
30703067 copy.StepAll();
30713068 copy.Touch();
30723069 objEditor.refreshContents();
3073
- } else if (event.getSource() == resetAllButton)
3070
+ } else if (source == resetAllButton)
30743071 {
30753072 //CameraPane.fullreset = true;
30763073 copy.ResetAll(); // ResetMeshes();
....@@ -3103,53 +3100,75 @@
31033100 // Close();
31043101 // }
31053102 // else
3106
- if (event.getSource() == resetSlidersButton)
3103
+ if (source == resetSlidersButton)
31073104 {
31083105 ResetSliders();
3109
- } else if (event.getSource() == clearMaterialButton)
3106
+ } else if (source == clearMaterialButton)
31103107 {
31113108 ClearMaterial();
3112
- } else if (event.getSource() == createMaterialButton)
3109
+ } else if (source == createMaterialButton)
31133110 {
31143111 CreateMaterial();
3115
- } else if (event.getSource() == clearPanelButton)
3112
+ } else if (source == clearPanelButton)
31163113 {
31173114 copy.ClearUI();
31183115 refreshContents(true);
3119
- } /*
3120
- }
3121
-
3122
- public boolean action(Event event, Object arg)
3123
- {
3124
- */ 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)
31253141 {
31263142 Close();
31273143 //return true;
3128
- } else if (event.getSource() == loadItem)
3144
+ } else if (source == loadItem)
31293145 {
31303146 load();
31313147 //return true;
3132
- } else if (event.getSource() == saveItem)
3148
+ } else if (source == newItem)
3149
+ {
3150
+ New();
3151
+ } else if (source == saveItem)
31333152 {
31343153 save();
31353154 //return true;
3136
- } else if (event.getSource() == saveAsItem)
3155
+ } else if (source == saveAsItem)
31373156 {
31383157 saveAs();
31393158 //return true;
3140
- } else if (event.getSource() == reexportItem)
3159
+ } else if (source == reexportItem)
31413160 {
31423161 reexport();
31433162 //return true;
3144
- } else if (event.getSource() == exportAsItem)
3163
+ } else if (source == exportAsItem)
31453164 {
31463165 export();
31473166 //return true;
3148
- } else if (event.getSource() == povItem)
3167
+ } else if (source == povItem)
31493168 {
31503169 generatePOV();
31513170 //return true;
3152
- } else if (event.getSource() == zBufferItem)
3171
+ } else if (source == zBufferItem)
31533172 {
31543173 try
31553174 {
....@@ -3171,21 +3190,8 @@
31713190 cameraView.repaint();
31723191 //return true;
31733192 }
3174
- */ else if (event.getSource() == editCameraItem)
3175
- {
3176
- cameraView.ProtectCamera();
3177
- cameraView.repaint();
3178
- return;
3179
- } else if (event.getSource() == revertCameraItem)
3180
- {
3181
- cameraView.RevertCamera();
3182
- cameraView.repaint();
3183
- return;
3184
-// } else if (event.getSource() == textureButton)
3185
-// {
3186
-// return; // true;
3187
- } else // combos...
3188
- if (event.getSource() == texresMenu)
3193
+ */ else // combos...
3194
+ if (source == texresMenu)
31893195 {
31903196 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31913197 copy.texres = texresMenu.getSelectedIndex();
....@@ -3197,6 +3203,262 @@
31973203 }
31983204 }
31993205
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
+
32003462 void ToggleAnimation()
32013463 {
32023464 if (!Globals.ANIMATION)
....@@ -3212,8 +3474,8 @@
32123474
32133475 Globals.ANIMATION ^= true;
32143476
3215
- GrafreeD.wav.cursor = 0;
3216
- GrafreeD.wav.loop = 0;
3477
+ Grafreed.wav.cursor = 0;
3478
+ Grafreed.wav.loop = 0;
32173479 }
32183480 } else
32193481 {
....@@ -3234,7 +3496,6 @@
32343496 callee.refreshContents();
32353497 } else
32363498 {
3237
- new Exception().printStackTrace();
32383499 System.exit(0);
32393500 }
32403501 }
....@@ -3264,7 +3525,7 @@
32643525 void CreateMaterial()
32653526 {
32663527 //copy.ClearMaterial(); // PATCH
3267
- copy.CreateMaterialS(multiplyToggle.isSelected());
3528
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32683529 if (copy.selection.size() > 0)
32693530 //SetMaterial(copy);
32703531 {
....@@ -3323,11 +3584,11 @@
33233584 {
33243585 copy.ResetBlockLoop(); // temporary problem
33253586
3326
- boolean random = CameraPane.RANDOM;
3327
- CameraPane.RANDOM = false; // parse everything
3587
+ boolean random = CameraPane.SWITCH;
3588
+ CameraPane.SWITCH = false; // parse everything
33283589 copy.ResetDisplayList();
33293590 copy.HardTouch();
3330
- CameraPane.RANDOM = random;
3591
+ CameraPane.SWITCH = random;
33313592 }
33323593
33333594 // public void applySelf()
....@@ -3401,6 +3662,36 @@
34013662 {
34023663 //System.out.println("Propagate = " + propagate);
34033664 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
+
34043695 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34053696 {
34063697 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3516,7 +3807,7 @@
35163807 }
35173808
35183809 if (normalpushField != null)
3519
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3810
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35203811 }
35213812
35223813 void SnapObject()
....@@ -3780,6 +4071,7 @@
37804071
37814072 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37824073 {
4074
+ Save();
37834075 //Tween.set(thing, 0).target(1).start(tweenManager);
37844076 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37854077 // if (thing instanceof GenericJointDemo)
....@@ -3983,6 +4275,7 @@
39834275 }
39844276 }
39854277 }
4278
+
39864279 LoadGFDThread loadGFDThread;
39874280
39884281 void ReadGFD(String fullname, iCallBack cb)
....@@ -4002,8 +4295,10 @@
40024295
40034296 try
40044297 {
4298
+ // Try compressed version first.
40054299 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4006
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4300
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4301
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40074302
40084303 readobj = (Object3D) p.readObject();
40094304 istream.close();
....@@ -4011,7 +4306,20 @@
40114306 readobj.ResetDisplayList();
40124307 } catch (Exception e)
40134308 {
4014
- e.printStackTrace();
4309
+ //e.printStackTrace();
4310
+ try
4311
+ {
4312
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4313
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4314
+
4315
+ readobj = (Object3D) p.readObject();
4316
+ istream.close();
4317
+
4318
+ readobj.ResetDisplayList();
4319
+ } catch (Exception e2)
4320
+ {
4321
+ e2.printStackTrace();
4322
+ }
40154323 }
40164324 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40174325 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4057,6 +4365,12 @@
40574365
40584366 void LoadIt(Object obj)
40594367 {
4368
+ if (obj == null)
4369
+ {
4370
+ // Invalid file
4371
+ return;
4372
+ }
4373
+
40604374 System.out.println("Loaded " + obj);
40614375 //new Exception().printStackTrace();
40624376 Object3D readobj = (Object3D) obj;
....@@ -4066,6 +4380,7 @@
40664380
40674381 if (readobj != null)
40684382 {
4383
+ Save();
40694384 try
40704385 {
40714386 //readobj.deepCopySelf(copy);
....@@ -4128,7 +4443,7 @@
41284443
41294444 void load() // throws ClassNotFoundException
41304445 {
4131
- if (GrafreeD.standAlone)
4446
+ if (Grafreed.standAlone)
41324447 {
41334448 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41344449 browser.show();
....@@ -4215,11 +4530,13 @@
42154530 try
42164531 {
42174532 FileOutputStream ostream = new FileOutputStream(lastname);
4218
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4533
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4534
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42194535
42204536 p.writeObject(copy);
42214537 p.flush();
42224538
4539
+ zstream.close();
42234540 ostream.close();
42244541
42254542 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4229,11 +4546,12 @@
42294546 {
42304547 }
42314548 }
4549
+
42324550 String lastname;
42334551
42344552 void saveAs()
42354553 {
4236
- if (GrafreeD.standAlone)
4554
+ if (Grafreed.standAlone)
42374555 {
42384556 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42394557 browser.setVisible(true);
....@@ -4338,13 +4656,13 @@
43384656 try
43394657 {
43404658 FileOutputStream ostream = new FileOutputStream(filename);
4341
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4342
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4659
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4660
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43434661
43444662 Object3D objectparent = obj.parent;
43454663 obj.parent = null;
43464664
4347
- Object3D object = (Object3D) GrafreeD.clone(obj);
4665
+ Object3D object = (Object3D) Grafreed.clone(obj);
43484666
43494667 obj.parent = objectparent;
43504668
....@@ -4356,8 +4674,8 @@
43564674 p.writeObject(object);
43574675 p.flush();
43584676
4677
+ zstream.close();
43594678 ostream.close();
4360
- // zstream.close();
43614679
43624680 // group.selection.get(0).parent = parent;
43634681 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4378,7 +4696,7 @@
43784696 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43794697 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43804698 copy.generatePOV(buffer);
4381
- if (GrafreeD.standAlone)
4699
+ if (Grafreed.standAlone)
43824700 {
43834701 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43844702 browser.show();
....@@ -4404,7 +4722,8 @@
44044722 Object3D client;
44054723 Object3D copy;
44064724 MenuBar menuBar;
4407
- Menu windowMenu;
4725
+ Menu fileMenu;
4726
+ MenuItem newItem;
44084727 MenuItem loadItem;
44094728 MenuItem saveItem;
44104729 MenuItem saveAsItem;
....@@ -4412,11 +4731,9 @@
44124731 MenuItem reexportItem;
44134732 MenuItem povItem;
44144733 MenuItem closeItem;
4415
- Menu cameraMenu;
4734
+
44164735 CheckboxMenuItem zBufferItem;
44174736 //MenuItem normalLensItem;
4418
- MenuItem editCameraItem;
4419
- MenuItem revertCameraItem;
44204737 MenuItem stepItem;
44214738 CheckboxMenuItem toggleLiveItem;
44224739 CheckboxMenuItem toggleFullScreenItem;
....@@ -4427,7 +4744,7 @@
44274744 CheckboxMenuItem toggleFootContactItem;
44284745 CheckboxMenuItem toggleDLItem;
44294746 CheckboxMenuItem toggleTextureItem;
4430
- CheckboxMenuItem toggleRandomItem;
4747
+ CheckboxMenuItem toggleSwitchItem;
44314748 CheckboxMenuItem toggleRootItem;
44324749 CheckboxMenuItem animationItem;
44334750 CheckboxMenuItem toggleHandleItem;
....@@ -4564,4 +4881,9 @@
45644881 //ObjectUI parent;
45654882
45664883 cNumberSlider normalpushField;
4884
+
4885
+ private MenuItem importGFDItem;
4886
+ private MenuItem importVRMLX3DItem;
4887
+ private MenuItem import3DSItem;
4888
+ private MenuItem importOBJItem;
45674889 }