Normand Briere
2019-06-16 b33ef80d78f01a6a61f4248b1bb7deaade42d503
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();
....@@ -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;
....@@ -951,10 +914,6 @@
951914
952915 void SetupUI2(ObjEditor oe)
953916 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958917 //SetupName(oe);
959918
960919 namePanel = new cGridBag();
....@@ -971,32 +930,52 @@
971930 setupPanel = new cGridBag().setVertical(false);
972931
973932 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
974
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
975
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
933
+ liveCB.setToolTipText("Animate object");
934
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
+ selectCB.setToolTipText("Make object selectable");
976936 // Return();
937
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
938
+ hideCB.setToolTipText("Hide object");
977939 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
978
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
979
- 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");
980947
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
+
981956 oe.ctrlPanel.add(setupPanel);
982957 oe.ctrlPanel.Return();
983958
984959 commandsPanel = new cGridBag().setVertical(false);
985960
986961 resetButton = AddButton(commandsPanel, "Reset");
962
+ resetButton.setToolTipText("Jump to frame zero");
987963 stepButton = AddButton(commandsPanel, "Step");
964
+ stepButton.setToolTipText("Step one frame");
988965 // resetAllButton = AddButton(oe, "Reset All");
989966 // stepAllButton = AddButton(oe, "Step All");
990
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
991967 // Return();
992968 slowerButton = AddButton(commandsPanel, "Slow");
969
+ slowerButton.setToolTipText("Decrease animation speed");
993970 fasterButton = AddButton(commandsPanel, "Fast");
971
+ fasterButton.setToolTipText("Increase animation speed");
994972 remarkButton = AddButton(commandsPanel, "Remark");
973
+ remarkButton.setToolTipText("Set the current transform as the target");
995974
996975 oe.ctrlPanel.add(commandsPanel);
997976 oe.ctrlPanel.Return();
998977
999
- 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
1000979 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1001980 //Return();
1002981
....@@ -1298,7 +1277,7 @@
12981277 scrollpane.addMouseWheelListener(this); // Default not fast enough
12991278
13001279 /*JTabbedPane*/ scenePanel = new cGridBag();
1301
- scenePanel.preferredWidth = 7;
1280
+ scenePanel.preferredWidth = 6;
13021281
13031282 JTabbedPane tabbedPane = new JTabbedPane();
13041283 tabbedPane.add(scrollpane);
....@@ -1404,8 +1383,8 @@
14041383
14051384 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14061385
1407
- frame.setSize(1024, 768);
1408
- frame.show();
1386
+ frame.setSize(1280, 860);
1387
+ frame.setVisible(true);
14091388
14101389 gridPanel.setDividerLocation(1.0);
14111390
....@@ -1444,19 +1423,22 @@
14441423
14451424 cGridBag editBar = new cGridBag().setVertical(false);
14461425
1447
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1426
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14481427 createMaterialButton.setToolTipText("Create material");
14491428
14501429 /*
14511430 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14521431 */
14531432
1454
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1433
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14551434 clearMaterialButton.setToolTipText("Clear material");
14561435
1457
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1458
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1459
- 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
+ }
14601442
14611443 editBar.preferredHeight = 15;
14621444
....@@ -1725,12 +1707,15 @@
17251707 opacityPowerField.addChangeListener(this);
17261708 /**/
17271709
1728
- resetSlidersButton.addActionListener(this);
17291710 clearMaterialButton.addActionListener(this);
17301711 createMaterialButton.addActionListener(this);
1731
-
1732
- propagateToggle.addItemListener(this);
1733
- multiplyToggle.addItemListener(this);
1712
+
1713
+ if (Globals.ADVANCED)
1714
+ {
1715
+ resetSlidersButton.addActionListener(this);
1716
+ propagateToggle.addItemListener(this);
1717
+ multiplyToggle.addItemListener(this);
1718
+ }
17341719 }
17351720
17361721 void DropFile(java.io.File[] files, boolean textures)
....@@ -1901,7 +1886,7 @@
19011886
19021887 //? flashIt = false;
19031888 CameraPane pane = (CameraPane) cameraView;
1904
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
19051890 pane.clickEnd(location.x, location.y, 0, true);
19061891
19071892 if (group.selection.size() == 1)
....@@ -1950,6 +1935,7 @@
19501935 e2.printStackTrace();
19511936 }
19521937 }
1938
+
19531939 LoadJMEThread loadThread;
19541940
19551941 class LoadJMEThread extends Thread
....@@ -2007,6 +1993,7 @@
20071993 //LoadFile0(filename, converter);
20081994 }
20091995 }
1996
+
20101997 LoadOBJThread loadObjThread;
20111998
20121999 class LoadOBJThread extends Thread
....@@ -2085,19 +2072,19 @@
20852072
20862073 void LoadObjFile(String fullname)
20872074 {
2088
- /*
2075
+ System.out.println("Loading " + fullname);
2076
+ /**/
20892077 //lastFilename = fullname;
20902078 if(loadObjThread == null)
20912079 {
2092
- loadObjThread = new LoadOBJThread();
2093
- loadObjThread.start();
2080
+ loadObjThread = new LoadOBJThread();
2081
+ loadObjThread.start();
20942082 }
20952083
20962084 loadObjThread.add(fullname);
2097
- */
2085
+ /**/
20982086
2099
- System.out.println("Loading " + fullname);
2100
- makeSomething(new FileObject(fullname, true), true);
2087
+ //makeSomething(new FileObject(fullname, true), true);
21012088 }
21022089
21032090 void LoadGFDFile(String fullname)
....@@ -2358,11 +2345,11 @@
23582345
23592346 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23602347 {
2361
- if (GrafreeD.standAlone)
2348
+ if (Grafreed.standAlone)
23622349 {
23632350 /**/
23642351 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2365
- browser.show();
2352
+ browser.setVisible(true);
23662353 String filename = browser.getFile();
23672354 if (filename != null && filename.length() > 0)
23682355 {
....@@ -2722,7 +2709,8 @@
27222709 return;
27232710 }
27242711
2725
- multiplyToggle.setSelected(mat.multiply);
2712
+ if (multiplyToggle != null)
2713
+ multiplyToggle.setSelected(mat.multiply);
27262714
27272715 assert (object.projectedVertices != null);
27282716
....@@ -2937,9 +2925,9 @@
29372925 frame.validate();
29382926
29392927 return;
2940
- } else if (event.getSource() == toggleRandomItem)
2928
+ } else if (event.getSource() == toggleSwitchItem)
29412929 {
2942
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29432931 cameraView.repaint();
29442932 return;
29452933 } else if (event.getSource() == toggleHandleItem)
....@@ -2968,6 +2956,10 @@
29682956 {
29692957 copy.live ^= true;
29702958 return;
2959
+ } else if (event.getSource() == selectCB)
2960
+ {
2961
+ copy.dontselect ^= true;
2962
+ return;
29712963 } else if (event.getSource() == hideCB)
29722964 {
29732965 copy.hide ^= true;
....@@ -2982,6 +2974,7 @@
29822974 if (event.getSource() == randomCB)
29832975 {
29842976 copy.random ^= true;
2977
+ objEditor.refreshContents();
29852978 return;
29862979 }
29872980 if (event.getSource() == speedupCB)
....@@ -3005,8 +2998,9 @@
30052998
30062999 public void actionPerformed(ActionEvent event)
30073000 {
3001
+ Object source = event.getSource();
30083002 // SCRIPT DIALOG
3009
- if (event.getSource() == okbutton)
3003
+ if (source == okbutton)
30103004 {
30113005 textpanel.setVisible(false);
30123006 textpanel.remove(textarea);
....@@ -3018,7 +3012,7 @@
30183012 textarea = null;
30193013 textpanel = null;
30203014 }
3021
- if (event.getSource() == cancelbutton)
3015
+ if (source == cancelbutton)
30223016 {
30233017 textpanel.setVisible(false);
30243018 textpanel.remove(textarea);
....@@ -3030,50 +3024,50 @@
30303024 //applySelf();
30313025 //client.refreshEditWindow();
30323026 //refreshContents();
3033
- if (event.getSource() == nameField)
3027
+ if (source == nameField)
30343028 {
30353029 //System.out.println("ObjEditor " + event);
30363030 applySelf0(true);
30373031 //parent.applySelf();
30383032 objEditor.refreshContents();
3039
- } else if (event.getSource() == resetButton)
3033
+ } else if (source == resetButton)
30403034 {
30413035 CameraPane.fullreset = true;
30423036 copy.Reset(); // ResetMeshes();
30433037 copy.Touch();
30443038 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepItem)
3039
+ } else if (source == stepItem)
30463040 {
30473041 //cameraView.ONESTEP = true;
30483042 Globals.ONESTEP = true;
30493043 cameraView.repaint();
30503044 return;
3051
- } else if (event.getSource() == stepButton)
3045
+ } else if (source == stepButton)
30523046 {
30533047 copy.Step();
30543048 copy.Touch();
30553049 objEditor.refreshContents();
3056
- } else if (event.getSource() == slowerButton)
3050
+ } else if (source == slowerButton)
30573051 {
30583052 copy.Slower();
30593053 copy.Touch();
30603054 objEditor.refreshContents();
3061
- } else if (event.getSource() == fasterButton)
3055
+ } else if (source == fasterButton)
30623056 {
30633057 copy.Faster();
30643058 copy.Touch();
30653059 objEditor.refreshContents();
3066
- } else if (event.getSource() == remarkButton)
3060
+ } else if (source == remarkButton)
30673061 {
30683062 copy.Remark();
30693063 copy.Touch();
30703064 objEditor.refreshContents();
3071
- } else if (event.getSource() == stepAllButton)
3065
+ } else if (source == stepAllButton)
30723066 {
30733067 copy.StepAll();
30743068 copy.Touch();
30753069 objEditor.refreshContents();
3076
- } else if (event.getSource() == resetAllButton)
3070
+ } else if (source == resetAllButton)
30773071 {
30783072 //CameraPane.fullreset = true;
30793073 copy.ResetAll(); // ResetMeshes();
....@@ -3106,53 +3100,75 @@
31063100 // Close();
31073101 // }
31083102 // else
3109
- if (event.getSource() == resetSlidersButton)
3103
+ if (source == resetSlidersButton)
31103104 {
31113105 ResetSliders();
3112
- } else if (event.getSource() == clearMaterialButton)
3106
+ } else if (source == clearMaterialButton)
31133107 {
31143108 ClearMaterial();
3115
- } else if (event.getSource() == createMaterialButton)
3109
+ } else if (source == createMaterialButton)
31163110 {
31173111 CreateMaterial();
3118
- } else if (event.getSource() == clearPanelButton)
3112
+ } else if (source == clearPanelButton)
31193113 {
31203114 copy.ClearUI();
31213115 refreshContents(true);
3122
- } /*
3123
- }
3124
-
3125
- public boolean action(Event event, Object arg)
3126
- {
3127
- */ 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)
31283141 {
31293142 Close();
31303143 //return true;
3131
- } else if (event.getSource() == loadItem)
3144
+ } else if (source == loadItem)
31323145 {
31333146 load();
31343147 //return true;
3135
- } else if (event.getSource() == saveItem)
3148
+ } else if (source == newItem)
3149
+ {
3150
+ New();
3151
+ } else if (source == saveItem)
31363152 {
31373153 save();
31383154 //return true;
3139
- } else if (event.getSource() == saveAsItem)
3155
+ } else if (source == saveAsItem)
31403156 {
31413157 saveAs();
31423158 //return true;
3143
- } else if (event.getSource() == reexportItem)
3159
+ } else if (source == reexportItem)
31443160 {
31453161 reexport();
31463162 //return true;
3147
- } else if (event.getSource() == exportAsItem)
3163
+ } else if (source == exportAsItem)
31483164 {
31493165 export();
31503166 //return true;
3151
- } else if (event.getSource() == povItem)
3167
+ } else if (source == povItem)
31523168 {
31533169 generatePOV();
31543170 //return true;
3155
- } else if (event.getSource() == zBufferItem)
3171
+ } else if (source == zBufferItem)
31563172 {
31573173 try
31583174 {
....@@ -3174,21 +3190,8 @@
31743190 cameraView.repaint();
31753191 //return true;
31763192 }
3177
- */ else if (event.getSource() == editCameraItem)
3178
- {
3179
- cameraView.ProtectCamera();
3180
- cameraView.repaint();
3181
- return;
3182
- } else if (event.getSource() == revertCameraItem)
3183
- {
3184
- cameraView.RevertCamera();
3185
- cameraView.repaint();
3186
- return;
3187
-// } else if (event.getSource() == textureButton)
3188
-// {
3189
-// return; // true;
3190
- } else // combos...
3191
- if (event.getSource() == texresMenu)
3193
+ */ else // combos...
3194
+ if (source == texresMenu)
31923195 {
31933196 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31943197 copy.texres = texresMenu.getSelectedIndex();
....@@ -3200,6 +3203,262 @@
32003203 }
32013204 }
32023205
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
+
32033462 void ToggleAnimation()
32043463 {
32053464 if (!Globals.ANIMATION)
....@@ -3215,8 +3474,8 @@
32153474
32163475 Globals.ANIMATION ^= true;
32173476
3218
- GrafreeD.wav.cursor = 0;
3219
- GrafreeD.wav.loop = 0;
3477
+ Grafreed.wav.cursor = 0;
3478
+ Grafreed.wav.loop = 0;
32203479 }
32213480 } else
32223481 {
....@@ -3237,7 +3496,6 @@
32373496 callee.refreshContents();
32383497 } else
32393498 {
3240
- new Exception().printStackTrace();
32413499 System.exit(0);
32423500 }
32433501 }
....@@ -3267,7 +3525,7 @@
32673525 void CreateMaterial()
32683526 {
32693527 //copy.ClearMaterial(); // PATCH
3270
- copy.CreateMaterialS(multiplyToggle.isSelected());
3528
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32713529 if (copy.selection.size() > 0)
32723530 //SetMaterial(copy);
32733531 {
....@@ -3326,11 +3584,11 @@
33263584 {
33273585 copy.ResetBlockLoop(); // temporary problem
33283586
3329
- boolean random = CameraPane.RANDOM;
3330
- CameraPane.RANDOM = false; // parse everything
3587
+ boolean random = CameraPane.SWITCH;
3588
+ CameraPane.SWITCH = false; // parse everything
33313589 copy.ResetDisplayList();
33323590 copy.HardTouch();
3333
- CameraPane.RANDOM = random;
3591
+ CameraPane.SWITCH = random;
33343592 }
33353593
33363594 // public void applySelf()
....@@ -3404,6 +3662,36 @@
34043662 {
34053663 //System.out.println("Propagate = " + propagate);
34063664 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
+
34073695 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34083696 {
34093697 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3519,7 +3807,7 @@
35193807 }
35203808
35213809 if (normalpushField != null)
3522
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3810
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35233811 }
35243812
35253813 void SnapObject()
....@@ -3783,6 +4071,7 @@
37834071
37844072 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37854073 {
4074
+ Save();
37864075 //Tween.set(thing, 0).target(1).start(tweenManager);
37874076 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37884077 // if (thing instanceof GenericJointDemo)
....@@ -3986,6 +4275,7 @@
39864275 }
39874276 }
39884277 }
4278
+
39894279 LoadGFDThread loadGFDThread;
39904280
39914281 void ReadGFD(String fullname, iCallBack cb)
....@@ -4006,7 +4296,8 @@
40064296 try
40074297 {
40084298 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4009
- 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);
40104301
40114302 readobj = (Object3D) p.readObject();
40124303 istream.close();
....@@ -4014,7 +4305,20 @@
40144305 readobj.ResetDisplayList();
40154306 } catch (Exception e)
40164307 {
4017
- 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
+ }
40184322 }
40194323 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40204324 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4069,6 +4373,7 @@
40694373
40704374 if (readobj != null)
40714375 {
4376
+ Save();
40724377 try
40734378 {
40744379 //readobj.deepCopySelf(copy);
....@@ -4131,7 +4436,7 @@
41314436
41324437 void load() // throws ClassNotFoundException
41334438 {
4134
- if (GrafreeD.standAlone)
4439
+ if (Grafreed.standAlone)
41354440 {
41364441 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41374442 browser.show();
....@@ -4218,11 +4523,13 @@
42184523 try
42194524 {
42204525 FileOutputStream ostream = new FileOutputStream(lastname);
4221
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4526
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4527
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42224528
42234529 p.writeObject(copy);
42244530 p.flush();
42254531
4532
+ zstream.close();
42264533 ostream.close();
42274534
42284535 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4232,11 +4539,12 @@
42324539 {
42334540 }
42344541 }
4542
+
42354543 String lastname;
42364544
42374545 void saveAs()
42384546 {
4239
- if (GrafreeD.standAlone)
4547
+ if (Grafreed.standAlone)
42404548 {
42414549 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42424550 browser.setVisible(true);
....@@ -4341,13 +4649,13 @@
43414649 try
43424650 {
43434651 FileOutputStream ostream = new FileOutputStream(filename);
4344
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4345
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4652
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4653
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43464654
43474655 Object3D objectparent = obj.parent;
43484656 obj.parent = null;
43494657
4350
- Object3D object = (Object3D) GrafreeD.clone(obj);
4658
+ Object3D object = (Object3D) Grafreed.clone(obj);
43514659
43524660 obj.parent = objectparent;
43534661
....@@ -4359,8 +4667,8 @@
43594667 p.writeObject(object);
43604668 p.flush();
43614669
4670
+ zstream.close();
43624671 ostream.close();
4363
- // zstream.close();
43644672
43654673 // group.selection.get(0).parent = parent;
43664674 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4381,7 +4689,7 @@
43814689 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43824690 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43834691 copy.generatePOV(buffer);
4384
- if (GrafreeD.standAlone)
4692
+ if (Grafreed.standAlone)
43854693 {
43864694 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43874695 browser.show();
....@@ -4407,7 +4715,8 @@
44074715 Object3D client;
44084716 Object3D copy;
44094717 MenuBar menuBar;
4410
- Menu windowMenu;
4718
+ Menu fileMenu;
4719
+ MenuItem newItem;
44114720 MenuItem loadItem;
44124721 MenuItem saveItem;
44134722 MenuItem saveAsItem;
....@@ -4415,11 +4724,9 @@
44154724 MenuItem reexportItem;
44164725 MenuItem povItem;
44174726 MenuItem closeItem;
4418
- Menu cameraMenu;
4727
+
44194728 CheckboxMenuItem zBufferItem;
44204729 //MenuItem normalLensItem;
4421
- MenuItem editCameraItem;
4422
- MenuItem revertCameraItem;
44234730 MenuItem stepItem;
44244731 CheckboxMenuItem toggleLiveItem;
44254732 CheckboxMenuItem toggleFullScreenItem;
....@@ -4430,7 +4737,7 @@
44304737 CheckboxMenuItem toggleFootContactItem;
44314738 CheckboxMenuItem toggleDLItem;
44324739 CheckboxMenuItem toggleTextureItem;
4433
- CheckboxMenuItem toggleRandomItem;
4740
+ CheckboxMenuItem toggleSwitchItem;
44344741 CheckboxMenuItem toggleRootItem;
44354742 CheckboxMenuItem animationItem;
44364743 CheckboxMenuItem toggleHandleItem;
....@@ -4567,4 +4874,9 @@
45674874 //ObjectUI parent;
45684875
45694876 cNumberSlider normalpushField;
4877
+
4878
+ private MenuItem importGFDItem;
4879
+ private MenuItem importVRMLX3DItem;
4880
+ private MenuItem import3DSItem;
4881
+ private MenuItem importOBJItem;
45704882 }