Normand Briere
2019-06-09 79d0f9a45d36656051a77a7b0837aa0318f81ee5
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("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..."));
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)
....@@ -2358,11 +2343,11 @@
23582343
23592344 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23602345 {
2361
- if (GrafreeD.standAlone)
2346
+ if (Grafreed.standAlone)
23622347 {
23632348 /**/
23642349 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2365
- browser.show();
2350
+ browser.setVisible(true);
23662351 String filename = browser.getFile();
23672352 if (filename != null && filename.length() > 0)
23682353 {
....@@ -2722,7 +2707,8 @@
27222707 return;
27232708 }
27242709
2725
- multiplyToggle.setSelected(mat.multiply);
2710
+ if (multiplyToggle != null)
2711
+ multiplyToggle.setSelected(mat.multiply);
27262712
27272713 assert (object.projectedVertices != null);
27282714
....@@ -2937,7 +2923,7 @@
29372923 frame.validate();
29382924
29392925 return;
2940
- } else if (event.getSource() == toggleRandomItem)
2926
+ } else if (event.getSource() == toggleSwitchItem)
29412927 {
29422928 cameraView.ToggleRandom();
29432929 cameraView.repaint();
....@@ -2968,6 +2954,10 @@
29682954 {
29692955 copy.live ^= true;
29702956 return;
2957
+ } else if (event.getSource() == selectCB)
2958
+ {
2959
+ copy.dontselect ^= true;
2960
+ return;
29712961 } else if (event.getSource() == hideCB)
29722962 {
29732963 copy.hide ^= true;
....@@ -2982,6 +2972,7 @@
29822972 if (event.getSource() == randomCB)
29832973 {
29842974 copy.random ^= true;
2975
+ objEditor.refreshContents();
29852976 return;
29862977 }
29872978 if (event.getSource() == speedupCB)
....@@ -3005,8 +2996,9 @@
30052996
30062997 public void actionPerformed(ActionEvent event)
30072998 {
2999
+ Object source = event.getSource();
30083000 // SCRIPT DIALOG
3009
- if (event.getSource() == okbutton)
3001
+ if (source == okbutton)
30103002 {
30113003 textpanel.setVisible(false);
30123004 textpanel.remove(textarea);
....@@ -3018,7 +3010,7 @@
30183010 textarea = null;
30193011 textpanel = null;
30203012 }
3021
- if (event.getSource() == cancelbutton)
3013
+ if (source == cancelbutton)
30223014 {
30233015 textpanel.setVisible(false);
30243016 textpanel.remove(textarea);
....@@ -3030,50 +3022,50 @@
30303022 //applySelf();
30313023 //client.refreshEditWindow();
30323024 //refreshContents();
3033
- if (event.getSource() == nameField)
3025
+ if (source == nameField)
30343026 {
30353027 //System.out.println("ObjEditor " + event);
30363028 applySelf0(true);
30373029 //parent.applySelf();
30383030 objEditor.refreshContents();
3039
- } else if (event.getSource() == resetButton)
3031
+ } else if (source == resetButton)
30403032 {
30413033 CameraPane.fullreset = true;
30423034 copy.Reset(); // ResetMeshes();
30433035 copy.Touch();
30443036 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepItem)
3037
+ } else if (source == stepItem)
30463038 {
30473039 //cameraView.ONESTEP = true;
30483040 Globals.ONESTEP = true;
30493041 cameraView.repaint();
30503042 return;
3051
- } else if (event.getSource() == stepButton)
3043
+ } else if (source == stepButton)
30523044 {
30533045 copy.Step();
30543046 copy.Touch();
30553047 objEditor.refreshContents();
3056
- } else if (event.getSource() == slowerButton)
3048
+ } else if (source == slowerButton)
30573049 {
30583050 copy.Slower();
30593051 copy.Touch();
30603052 objEditor.refreshContents();
3061
- } else if (event.getSource() == fasterButton)
3053
+ } else if (source == fasterButton)
30623054 {
30633055 copy.Faster();
30643056 copy.Touch();
30653057 objEditor.refreshContents();
3066
- } else if (event.getSource() == remarkButton)
3058
+ } else if (source == remarkButton)
30673059 {
30683060 copy.Remark();
30693061 copy.Touch();
30703062 objEditor.refreshContents();
3071
- } else if (event.getSource() == stepAllButton)
3063
+ } else if (source == stepAllButton)
30723064 {
30733065 copy.StepAll();
30743066 copy.Touch();
30753067 objEditor.refreshContents();
3076
- } else if (event.getSource() == resetAllButton)
3068
+ } else if (source == resetAllButton)
30773069 {
30783070 //CameraPane.fullreset = true;
30793071 copy.ResetAll(); // ResetMeshes();
....@@ -3106,53 +3098,75 @@
31063098 // Close();
31073099 // }
31083100 // else
3109
- if (event.getSource() == resetSlidersButton)
3101
+ if (source == resetSlidersButton)
31103102 {
31113103 ResetSliders();
3112
- } else if (event.getSource() == clearMaterialButton)
3104
+ } else if (source == clearMaterialButton)
31133105 {
31143106 ClearMaterial();
3115
- } else if (event.getSource() == createMaterialButton)
3107
+ } else if (source == createMaterialButton)
31163108 {
31173109 CreateMaterial();
3118
- } else if (event.getSource() == clearPanelButton)
3110
+ } else if (source == clearPanelButton)
31193111 {
31203112 copy.ClearUI();
31213113 refreshContents(true);
3122
- } /*
3123
- }
3124
-
3125
- public boolean action(Event event, Object arg)
3126
- {
3127
- */ 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)
31283139 {
31293140 Close();
31303141 //return true;
3131
- } else if (event.getSource() == loadItem)
3142
+ } else if (source == loadItem)
31323143 {
31333144 load();
31343145 //return true;
3135
- } else if (event.getSource() == saveItem)
3146
+ } else if (source == newItem)
3147
+ {
3148
+ New();
3149
+ } else if (source == saveItem)
31363150 {
31373151 save();
31383152 //return true;
3139
- } else if (event.getSource() == saveAsItem)
3153
+ } else if (source == saveAsItem)
31403154 {
31413155 saveAs();
31423156 //return true;
3143
- } else if (event.getSource() == reexportItem)
3157
+ } else if (source == reexportItem)
31443158 {
31453159 reexport();
31463160 //return true;
3147
- } else if (event.getSource() == exportAsItem)
3161
+ } else if (source == exportAsItem)
31483162 {
31493163 export();
31503164 //return true;
3151
- } else if (event.getSource() == povItem)
3165
+ } else if (source == povItem)
31523166 {
31533167 generatePOV();
31543168 //return true;
3155
- } else if (event.getSource() == zBufferItem)
3169
+ } else if (source == zBufferItem)
31563170 {
31573171 try
31583172 {
....@@ -3174,21 +3188,8 @@
31743188 cameraView.repaint();
31753189 //return true;
31763190 }
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)
3191
+ */ else // combos...
3192
+ if (source == texresMenu)
31923193 {
31933194 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31943195 copy.texres = texresMenu.getSelectedIndex();
....@@ -3200,6 +3201,150 @@
32003201 }
32013202 }
32023203
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
+
32033348 void ToggleAnimation()
32043349 {
32053350 if (!Globals.ANIMATION)
....@@ -3215,8 +3360,8 @@
32153360
32163361 Globals.ANIMATION ^= true;
32173362
3218
- GrafreeD.wav.cursor = 0;
3219
- GrafreeD.wav.loop = 0;
3363
+ Grafreed.wav.cursor = 0;
3364
+ Grafreed.wav.loop = 0;
32203365 }
32213366 } else
32223367 {
....@@ -3237,7 +3382,6 @@
32373382 callee.refreshContents();
32383383 } else
32393384 {
3240
- new Exception().printStackTrace();
32413385 System.exit(0);
32423386 }
32433387 }
....@@ -3267,7 +3411,7 @@
32673411 void CreateMaterial()
32683412 {
32693413 //copy.ClearMaterial(); // PATCH
3270
- copy.CreateMaterialS(multiplyToggle.isSelected());
3414
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32713415 if (copy.selection.size() > 0)
32723416 //SetMaterial(copy);
32733417 {
....@@ -3326,11 +3470,11 @@
33263470 {
33273471 copy.ResetBlockLoop(); // temporary problem
33283472
3329
- boolean random = CameraPane.RANDOM;
3330
- CameraPane.RANDOM = false; // parse everything
3473
+ boolean random = CameraPane.SWITCH;
3474
+ CameraPane.SWITCH = false; // parse everything
33313475 copy.ResetDisplayList();
33323476 copy.HardTouch();
3333
- CameraPane.RANDOM = random;
3477
+ CameraPane.SWITCH = random;
33343478 }
33353479
33363480 // public void applySelf()
....@@ -3404,6 +3548,36 @@
34043548 {
34053549 //System.out.println("Propagate = " + propagate);
34063550 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
+
34073581 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34083582 {
34093583 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3519,7 +3693,7 @@
35193693 }
35203694
35213695 if (normalpushField != null)
3522
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3696
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35233697 }
35243698
35253699 void SnapObject()
....@@ -3783,6 +3957,7 @@
37833957
37843958 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37853959 {
3960
+ Save();
37863961 //Tween.set(thing, 0).target(1).start(tweenManager);
37873962 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37883963 // if (thing instanceof GenericJointDemo)
....@@ -3986,6 +4161,7 @@
39864161 }
39874162 }
39884163 }
4164
+
39894165 LoadGFDThread loadGFDThread;
39904166
39914167 void ReadGFD(String fullname, iCallBack cb)
....@@ -4006,7 +4182,8 @@
40064182 try
40074183 {
40084184 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4009
- 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);
40104187
40114188 readobj = (Object3D) p.readObject();
40124189 istream.close();
....@@ -4014,7 +4191,20 @@
40144191 readobj.ResetDisplayList();
40154192 } catch (Exception e)
40164193 {
4017
- 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
+ }
40184208 }
40194209 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40204210 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4131,7 +4321,7 @@
41314321
41324322 void load() // throws ClassNotFoundException
41334323 {
4134
- if (GrafreeD.standAlone)
4324
+ if (Grafreed.standAlone)
41354325 {
41364326 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41374327 browser.show();
....@@ -4218,11 +4408,13 @@
42184408 try
42194409 {
42204410 FileOutputStream ostream = new FileOutputStream(lastname);
4221
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4411
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4412
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42224413
42234414 p.writeObject(copy);
42244415 p.flush();
42254416
4417
+ zstream.close();
42264418 ostream.close();
42274419
42284420 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4232,11 +4424,12 @@
42324424 {
42334425 }
42344426 }
4427
+
42354428 String lastname;
42364429
42374430 void saveAs()
42384431 {
4239
- if (GrafreeD.standAlone)
4432
+ if (Grafreed.standAlone)
42404433 {
42414434 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42424435 browser.setVisible(true);
....@@ -4341,13 +4534,13 @@
43414534 try
43424535 {
43434536 FileOutputStream ostream = new FileOutputStream(filename);
4344
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4345
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4537
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4538
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43464539
43474540 Object3D objectparent = obj.parent;
43484541 obj.parent = null;
43494542
4350
- Object3D object = (Object3D) GrafreeD.clone(obj);
4543
+ Object3D object = (Object3D) Grafreed.clone(obj);
43514544
43524545 obj.parent = objectparent;
43534546
....@@ -4359,8 +4552,8 @@
43594552 p.writeObject(object);
43604553 p.flush();
43614554
4555
+ zstream.close();
43624556 ostream.close();
4363
- // zstream.close();
43644557
43654558 // group.selection.get(0).parent = parent;
43664559 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4381,7 +4574,7 @@
43814574 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43824575 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43834576 copy.generatePOV(buffer);
4384
- if (GrafreeD.standAlone)
4577
+ if (Grafreed.standAlone)
43854578 {
43864579 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43874580 browser.show();
....@@ -4407,7 +4600,8 @@
44074600 Object3D client;
44084601 Object3D copy;
44094602 MenuBar menuBar;
4410
- Menu windowMenu;
4603
+ Menu fileMenu;
4604
+ MenuItem newItem;
44114605 MenuItem loadItem;
44124606 MenuItem saveItem;
44134607 MenuItem saveAsItem;
....@@ -4415,11 +4609,9 @@
44154609 MenuItem reexportItem;
44164610 MenuItem povItem;
44174611 MenuItem closeItem;
4418
- Menu cameraMenu;
4612
+
44194613 CheckboxMenuItem zBufferItem;
44204614 //MenuItem normalLensItem;
4421
- MenuItem editCameraItem;
4422
- MenuItem revertCameraItem;
44234615 MenuItem stepItem;
44244616 CheckboxMenuItem toggleLiveItem;
44254617 CheckboxMenuItem toggleFullScreenItem;
....@@ -4430,7 +4622,7 @@
44304622 CheckboxMenuItem toggleFootContactItem;
44314623 CheckboxMenuItem toggleDLItem;
44324624 CheckboxMenuItem toggleTextureItem;
4433
- CheckboxMenuItem toggleRandomItem;
4625
+ CheckboxMenuItem toggleSwitchItem;
44344626 CheckboxMenuItem toggleRootItem;
44354627 CheckboxMenuItem animationItem;
44364628 CheckboxMenuItem toggleHandleItem;
....@@ -4567,4 +4759,9 @@
45674759 //ObjectUI parent;
45684760
45694761 cNumberSlider normalpushField;
4762
+
4763
+ private MenuItem importGFDItem;
4764
+ private MenuItem importVRMLX3DItem;
4765
+ private MenuItem import3DSItem;
4766
+ private MenuItem importOBJItem;
45704767 }