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;
....@@ -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)
....@@ -2355,11 +2343,11 @@
23552343
23562344 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23572345 {
2358
- if (GrafreeD.standAlone)
2346
+ if (Grafreed.standAlone)
23592347 {
23602348 /**/
23612349 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2362
- browser.show();
2350
+ browser.setVisible(true);
23632351 String filename = browser.getFile();
23642352 if (filename != null && filename.length() > 0)
23652353 {
....@@ -2719,7 +2707,8 @@
27192707 return;
27202708 }
27212709
2722
- multiplyToggle.setSelected(mat.multiply);
2710
+ if (multiplyToggle != null)
2711
+ multiplyToggle.setSelected(mat.multiply);
27232712
27242713 assert (object.projectedVertices != null);
27252714
....@@ -2934,7 +2923,7 @@
29342923 frame.validate();
29352924
29362925 return;
2937
- } else if (event.getSource() == toggleRandomItem)
2926
+ } else if (event.getSource() == toggleSwitchItem)
29382927 {
29392928 cameraView.ToggleRandom();
29402929 cameraView.repaint();
....@@ -2965,6 +2954,10 @@
29652954 {
29662955 copy.live ^= true;
29672956 return;
2957
+ } else if (event.getSource() == selectCB)
2958
+ {
2959
+ copy.dontselect ^= true;
2960
+ return;
29682961 } else if (event.getSource() == hideCB)
29692962 {
29702963 copy.hide ^= true;
....@@ -2979,6 +2972,7 @@
29792972 if (event.getSource() == randomCB)
29802973 {
29812974 copy.random ^= true;
2975
+ objEditor.refreshContents();
29822976 return;
29832977 }
29842978 if (event.getSource() == speedupCB)
....@@ -3002,8 +2996,9 @@
30022996
30032997 public void actionPerformed(ActionEvent event)
30042998 {
2999
+ Object source = event.getSource();
30053000 // SCRIPT DIALOG
3006
- if (event.getSource() == okbutton)
3001
+ if (source == okbutton)
30073002 {
30083003 textpanel.setVisible(false);
30093004 textpanel.remove(textarea);
....@@ -3015,7 +3010,7 @@
30153010 textarea = null;
30163011 textpanel = null;
30173012 }
3018
- if (event.getSource() == cancelbutton)
3013
+ if (source == cancelbutton)
30193014 {
30203015 textpanel.setVisible(false);
30213016 textpanel.remove(textarea);
....@@ -3027,50 +3022,50 @@
30273022 //applySelf();
30283023 //client.refreshEditWindow();
30293024 //refreshContents();
3030
- if (event.getSource() == nameField)
3025
+ if (source == nameField)
30313026 {
30323027 //System.out.println("ObjEditor " + event);
30333028 applySelf0(true);
30343029 //parent.applySelf();
30353030 objEditor.refreshContents();
3036
- } else if (event.getSource() == resetButton)
3031
+ } else if (source == resetButton)
30373032 {
30383033 CameraPane.fullreset = true;
30393034 copy.Reset(); // ResetMeshes();
30403035 copy.Touch();
30413036 objEditor.refreshContents();
3042
- } else if (event.getSource() == stepItem)
3037
+ } else if (source == stepItem)
30433038 {
30443039 //cameraView.ONESTEP = true;
30453040 Globals.ONESTEP = true;
30463041 cameraView.repaint();
30473042 return;
3048
- } else if (event.getSource() == stepButton)
3043
+ } else if (source == stepButton)
30493044 {
30503045 copy.Step();
30513046 copy.Touch();
30523047 objEditor.refreshContents();
3053
- } else if (event.getSource() == slowerButton)
3048
+ } else if (source == slowerButton)
30543049 {
30553050 copy.Slower();
30563051 copy.Touch();
30573052 objEditor.refreshContents();
3058
- } else if (event.getSource() == fasterButton)
3053
+ } else if (source == fasterButton)
30593054 {
30603055 copy.Faster();
30613056 copy.Touch();
30623057 objEditor.refreshContents();
3063
- } else if (event.getSource() == remarkButton)
3058
+ } else if (source == remarkButton)
30643059 {
30653060 copy.Remark();
30663061 copy.Touch();
30673062 objEditor.refreshContents();
3068
- } else if (event.getSource() == stepAllButton)
3063
+ } else if (source == stepAllButton)
30693064 {
30703065 copy.StepAll();
30713066 copy.Touch();
30723067 objEditor.refreshContents();
3073
- } else if (event.getSource() == resetAllButton)
3068
+ } else if (source == resetAllButton)
30743069 {
30753070 //CameraPane.fullreset = true;
30763071 copy.ResetAll(); // ResetMeshes();
....@@ -3103,53 +3098,75 @@
31033098 // Close();
31043099 // }
31053100 // else
3106
- if (event.getSource() == resetSlidersButton)
3101
+ if (source == resetSlidersButton)
31073102 {
31083103 ResetSliders();
3109
- } else if (event.getSource() == clearMaterialButton)
3104
+ } else if (source == clearMaterialButton)
31103105 {
31113106 ClearMaterial();
3112
- } else if (event.getSource() == createMaterialButton)
3107
+ } else if (source == createMaterialButton)
31133108 {
31143109 CreateMaterial();
3115
- } else if (event.getSource() == clearPanelButton)
3110
+ } else if (source == clearPanelButton)
31163111 {
31173112 copy.ClearUI();
31183113 refreshContents(true);
3119
- } /*
3120
- }
3121
-
3122
- public boolean action(Event event, Object arg)
3123
- {
3124
- */ 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)
31253139 {
31263140 Close();
31273141 //return true;
3128
- } else if (event.getSource() == loadItem)
3142
+ } else if (source == loadItem)
31293143 {
31303144 load();
31313145 //return true;
3132
- } else if (event.getSource() == saveItem)
3146
+ } else if (source == newItem)
3147
+ {
3148
+ New();
3149
+ } else if (source == saveItem)
31333150 {
31343151 save();
31353152 //return true;
3136
- } else if (event.getSource() == saveAsItem)
3153
+ } else if (source == saveAsItem)
31373154 {
31383155 saveAs();
31393156 //return true;
3140
- } else if (event.getSource() == reexportItem)
3157
+ } else if (source == reexportItem)
31413158 {
31423159 reexport();
31433160 //return true;
3144
- } else if (event.getSource() == exportAsItem)
3161
+ } else if (source == exportAsItem)
31453162 {
31463163 export();
31473164 //return true;
3148
- } else if (event.getSource() == povItem)
3165
+ } else if (source == povItem)
31493166 {
31503167 generatePOV();
31513168 //return true;
3152
- } else if (event.getSource() == zBufferItem)
3169
+ } else if (source == zBufferItem)
31533170 {
31543171 try
31553172 {
....@@ -3171,21 +3188,8 @@
31713188 cameraView.repaint();
31723189 //return true;
31733190 }
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)
3191
+ */ else // combos...
3192
+ if (source == texresMenu)
31893193 {
31903194 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31913195 copy.texres = texresMenu.getSelectedIndex();
....@@ -3197,6 +3201,150 @@
31973201 }
31983202 }
31993203
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
+
32003348 void ToggleAnimation()
32013349 {
32023350 if (!Globals.ANIMATION)
....@@ -3212,8 +3360,8 @@
32123360
32133361 Globals.ANIMATION ^= true;
32143362
3215
- GrafreeD.wav.cursor = 0;
3216
- GrafreeD.wav.loop = 0;
3363
+ Grafreed.wav.cursor = 0;
3364
+ Grafreed.wav.loop = 0;
32173365 }
32183366 } else
32193367 {
....@@ -3234,7 +3382,6 @@
32343382 callee.refreshContents();
32353383 } else
32363384 {
3237
- new Exception().printStackTrace();
32383385 System.exit(0);
32393386 }
32403387 }
....@@ -3264,7 +3411,7 @@
32643411 void CreateMaterial()
32653412 {
32663413 //copy.ClearMaterial(); // PATCH
3267
- copy.CreateMaterialS(multiplyToggle.isSelected());
3414
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32683415 if (copy.selection.size() > 0)
32693416 //SetMaterial(copy);
32703417 {
....@@ -3323,11 +3470,11 @@
33233470 {
33243471 copy.ResetBlockLoop(); // temporary problem
33253472
3326
- boolean random = CameraPane.RANDOM;
3327
- CameraPane.RANDOM = false; // parse everything
3473
+ boolean random = CameraPane.SWITCH;
3474
+ CameraPane.SWITCH = false; // parse everything
33283475 copy.ResetDisplayList();
33293476 copy.HardTouch();
3330
- CameraPane.RANDOM = random;
3477
+ CameraPane.SWITCH = random;
33313478 }
33323479
33333480 // public void applySelf()
....@@ -3401,6 +3548,36 @@
34013548 {
34023549 //System.out.println("Propagate = " + propagate);
34033550 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
+
34043581 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34053582 {
34063583 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3516,7 +3693,7 @@
35163693 }
35173694
35183695 if (normalpushField != null)
3519
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3696
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35203697 }
35213698
35223699 void SnapObject()
....@@ -3780,6 +3957,7 @@
37803957
37813958 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37823959 {
3960
+ Save();
37833961 //Tween.set(thing, 0).target(1).start(tweenManager);
37843962 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37853963 // if (thing instanceof GenericJointDemo)
....@@ -3983,6 +4161,7 @@
39834161 }
39844162 }
39854163 }
4164
+
39864165 LoadGFDThread loadGFDThread;
39874166
39884167 void ReadGFD(String fullname, iCallBack cb)
....@@ -4003,7 +4182,8 @@
40034182 try
40044183 {
40054184 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4006
- 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);
40074187
40084188 readobj = (Object3D) p.readObject();
40094189 istream.close();
....@@ -4011,7 +4191,20 @@
40114191 readobj.ResetDisplayList();
40124192 } catch (Exception e)
40134193 {
4014
- 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
+ }
40154208 }
40164209 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40174210 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4128,7 +4321,7 @@
41284321
41294322 void load() // throws ClassNotFoundException
41304323 {
4131
- if (GrafreeD.standAlone)
4324
+ if (Grafreed.standAlone)
41324325 {
41334326 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41344327 browser.show();
....@@ -4215,11 +4408,13 @@
42154408 try
42164409 {
42174410 FileOutputStream ostream = new FileOutputStream(lastname);
4218
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4411
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4412
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42194413
42204414 p.writeObject(copy);
42214415 p.flush();
42224416
4417
+ zstream.close();
42234418 ostream.close();
42244419
42254420 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4229,11 +4424,12 @@
42294424 {
42304425 }
42314426 }
4427
+
42324428 String lastname;
42334429
42344430 void saveAs()
42354431 {
4236
- if (GrafreeD.standAlone)
4432
+ if (Grafreed.standAlone)
42374433 {
42384434 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42394435 browser.setVisible(true);
....@@ -4338,13 +4534,13 @@
43384534 try
43394535 {
43404536 FileOutputStream ostream = new FileOutputStream(filename);
4341
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4342
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4537
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4538
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43434539
43444540 Object3D objectparent = obj.parent;
43454541 obj.parent = null;
43464542
4347
- Object3D object = (Object3D) GrafreeD.clone(obj);
4543
+ Object3D object = (Object3D) Grafreed.clone(obj);
43484544
43494545 obj.parent = objectparent;
43504546
....@@ -4356,8 +4552,8 @@
43564552 p.writeObject(object);
43574553 p.flush();
43584554
4555
+ zstream.close();
43594556 ostream.close();
4360
- // zstream.close();
43614557
43624558 // group.selection.get(0).parent = parent;
43634559 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4378,7 +4574,7 @@
43784574 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43794575 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43804576 copy.generatePOV(buffer);
4381
- if (GrafreeD.standAlone)
4577
+ if (Grafreed.standAlone)
43824578 {
43834579 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43844580 browser.show();
....@@ -4404,7 +4600,8 @@
44044600 Object3D client;
44054601 Object3D copy;
44064602 MenuBar menuBar;
4407
- Menu windowMenu;
4603
+ Menu fileMenu;
4604
+ MenuItem newItem;
44084605 MenuItem loadItem;
44094606 MenuItem saveItem;
44104607 MenuItem saveAsItem;
....@@ -4412,11 +4609,9 @@
44124609 MenuItem reexportItem;
44134610 MenuItem povItem;
44144611 MenuItem closeItem;
4415
- Menu cameraMenu;
4612
+
44164613 CheckboxMenuItem zBufferItem;
44174614 //MenuItem normalLensItem;
4418
- MenuItem editCameraItem;
4419
- MenuItem revertCameraItem;
44204615 MenuItem stepItem;
44214616 CheckboxMenuItem toggleLiveItem;
44224617 CheckboxMenuItem toggleFullScreenItem;
....@@ -4427,7 +4622,7 @@
44274622 CheckboxMenuItem toggleFootContactItem;
44284623 CheckboxMenuItem toggleDLItem;
44294624 CheckboxMenuItem toggleTextureItem;
4430
- CheckboxMenuItem toggleRandomItem;
4625
+ CheckboxMenuItem toggleSwitchItem;
44314626 CheckboxMenuItem toggleRootItem;
44324627 CheckboxMenuItem animationItem;
44334628 CheckboxMenuItem toggleHandleItem;
....@@ -4564,4 +4759,9 @@
45644759 //ObjectUI parent;
45654760
45664761 cNumberSlider normalpushField;
4762
+
4763
+ private MenuItem importGFDItem;
4764
+ private MenuItem importVRMLX3DItem;
4765
+ private MenuItem import3DSItem;
4766
+ private MenuItem importOBJItem;
45674767 }