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);
....@@ -301,65 +318,10 @@
301318 //povItem.addActionListener(this);
302319 closeItem.addActionListener(this);
303320
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);
358
-
359321 objectPanel = new JTabbedPane();
360322 toolbarPanel = new JPanel();
361323 toolbarPanel.setName("Toolbar");
362
- treePanel = new JPanel();
324
+ treePanel = new cGridBag();
363325 treePanel.setName("Tree");
364326 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365327 ctrlPanel.setName("Edit");
....@@ -367,13 +329,15 @@
367329 materialPanel.setName("Material");
368330 /*JTextPane*/
369331 infoarea = createTextPane();
332
+ doc = infoarea.getStyledDocument();
333
+
370334 infoarea.setEditable(true);
371335 SetText();
372336 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
373337 // infoarea.setOpaque(false);
374338 // //infoarea.setForeground(textcolor);
375
- infoarea.setLineWrap(true);
376
- infoarea.setWrapStyleWord(true);
339
+// TEXTAREA infoarea.setLineWrap(true);
340
+// TEXTAREA infoarea.setWrapStyleWord(true);
377341 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
378342 infoPanel.setPreferredSize(new Dimension(50, 200));
379343 infoPanel.setName("Info");
....@@ -384,14 +348,14 @@
384348 mainPanel.setName("Main");
385349 mainPanel.setContinuousLayout(true);
386350 mainPanel.setOneTouchExpandable(true);
387
- mainPanel.setDividerLocation(1.0);
388351 mainPanel.setDividerSize(9);
389
- mainPanel.setResizeWeight(0);
352
+ mainPanel.setDividerLocation(0.5); //1.0);
353
+ mainPanel.setResizeWeight(0.5);
390354
391355 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392356 //mainPanel.setLayout(new GridBagLayout());
393357 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
358
+// treePanel.setLayout(new GridBagLayout());
395359 //ctrlPanel.setLayout(new GridBagLayout());
396360 //materialPanel.setLayout(new GridBagLayout());
397361
....@@ -432,7 +396,7 @@
432396 static String newline = "\n";
433397 protected static final String buttonString = "JButton";
434398 StyledDocument doc;
435
- JTextArea infoarea;
399
+ JTextPane infoarea;
436400
437401 void ClearInfo()
438402 {
....@@ -481,13 +445,13 @@
481445 //SendInfo("Name:", "bold");
482446 if (sel.GetTextures() != null || debug)
483447 {
484
- si.SendInfo(sel.toString(), "bold");
448
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485449 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486450 if (sel.Size() > 0)
487451 {
488452 si.SendInfo("#children = " + sel.Size(), "regular");
489453 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
454
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491455 if (debug)
492456 {
493457 try
....@@ -499,7 +463,10 @@
499463 }
500464
501465 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
466
+ {
467
+ si.SendInfo(" BBox min: " + minima, "regular");
468
+ si.SendInfo(" BBox max: " + maxima, "regular");
469
+ }
503470
504471 if (sel.bRep != null)
505472 {
....@@ -526,7 +493,7 @@
526493 }
527494 if (sel.support != null)
528495 {
529
- si.SendInfo(" support: " + sel.support, "regular");
496
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530497 }
531498 if (sel.scriptnode != null)
532499 {
....@@ -597,6 +564,9 @@
597564 {
598565 CameraPane.pointflow = (PointFlow) sel;
599566 }
567
+
568
+ si.SendInfo("_____________________", "regular");
569
+ si.SendInfo("", "regular");
600570 }
601571 }
602572
....@@ -628,52 +598,52 @@
628598 cameraView.ToggleFullScreen();
629599 }
630600
631
- private JTextArea createTextPane()
601
+ private JTextPane createTextPane()
632602 {
633
- String[] initString =
634
- {
635
- "This is an editable JTextPane, ", //regular
636
- "another ", //italic
637
- "styled ", //bold
638
- "text ", //small
639
- "component, ", //large
640
- "which supports embedded components..." + newline,//regular
641
- " " + newline, //button
642
- "...and embedded icons..." + newline, //regular
643
- " ", //icon
644
- newline + "JTextPane is a subclass of JEditorPane that "
645
- + "uses a StyledEditorKit and StyledDocument, and provides "
646
- + "cover methods for interacting with those objects."
647
- };
603
+// TEXTAREA String[] initString =
604
+// {
605
+// "This is an editable JTextPane, ", //regular
606
+// "another ", //italic
607
+// "styled ", //bold
608
+// "text ", //small
609
+// "component, ", //large
610
+// "which supports embedded components..." + newline,//regular
611
+// " " + newline, //button
612
+// "...and embedded icons..." + newline, //regular
613
+// " ", //icon
614
+// newline + "JTextPane is a subclass of JEditorPane that "
615
+// + "uses a StyledEditorKit and StyledDocument, and provides "
616
+// + "cover methods for interacting with those objects."
617
+// };
618
+//
619
+// String[] initStyles =
620
+// {
621
+// "regular", "italic", "bold", "small", "large",
622
+// "regular", "button", "regular", "icon",
623
+// "regular"
624
+// };
625
+//
626
+// JTextPane textPane = new JTextPane();
627
+// textPane.setEditable(true);
628
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
629
+// addStylesToDocument(doc);
630
+//
631
+// try
632
+// {
633
+// for (int j = 0; j < 2; j++)
634
+// {
635
+// for (int i = 0; i < initString.length; i++)
636
+// {
637
+// doc.insertString(doc.getLength(), initString[i],
638
+// doc.getStyle(initStyles[i]));
639
+// }
640
+// }
641
+// } catch (BadLocationException ble)
642
+// {
643
+// System.err.println("Couldn't insert initial text into text pane.");
644
+// }
648645
649
- String[] initStyles =
650
- {
651
- "regular", "italic", "bold", "small", "large",
652
- "regular", "button", "regular", "icon",
653
- "regular"
654
- };
655
-
656
- JTextPane textPane = new JTextPane();
657
- textPane.setEditable(true);
658
- /*StyledDocument*/ doc = textPane.getStyledDocument();
659
- addStylesToDocument(doc);
660
-
661
- try
662
- {
663
- for (int j = 0; j < 2; j++)
664
- {
665
- for (int i = 0; i < initString.length; i++)
666
- {
667
- doc.insertString(doc.getLength(), initString[i],
668
- doc.getStyle(initStyles[i]));
669
- }
670
- }
671
- } catch (BadLocationException ble)
672
- {
673
- System.err.println("Couldn't insert initial text into text pane.");
674
- }
675
-
676
- return new JTextArea(); // textPane;
646
+ return new JTextPane(); // textPane;
677647 }
678648
679649 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +696,7 @@
726696 protected static ImageIcon createImageIcon(String path,
727697 String description)
728698 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
699
+ java.net.URL imgURL = Grafreed.class.getResource(path);
730700 if (imgURL != null)
731701 {
732702 return new ImageIcon(imgURL, description);
....@@ -758,6 +728,7 @@
758728 // NumberSlider vDivsField;
759729 // JCheckBox endcaps;
760730 JCheckBox liveCB;
731
+ JCheckBox selectCB;
761732 JCheckBox hideCB;
762733 JCheckBox link2masterCB;
763734 JCheckBox markCB;
....@@ -943,10 +914,6 @@
943914
944915 void SetupUI2(ObjEditor oe)
945916 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
950917 //SetupName(oe);
951918
952919 namePanel = new cGridBag();
....@@ -963,32 +930,52 @@
963930 setupPanel = new cGridBag().setVertical(false);
964931
965932 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
933
+ liveCB.setToolTipText("Animate object");
934
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
+ selectCB.setToolTipText("Make object selectable");
968936 // Return();
937
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
938
+ hideCB.setToolTipText("Hide object");
969939 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- 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");
972947
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
+
973956 oe.ctrlPanel.add(setupPanel);
974957 oe.ctrlPanel.Return();
975958
976959 commandsPanel = new cGridBag().setVertical(false);
977960
978961 resetButton = AddButton(commandsPanel, "Reset");
962
+ resetButton.setToolTipText("Jump to frame zero");
979963 stepButton = AddButton(commandsPanel, "Step");
964
+ stepButton.setToolTipText("Step one frame");
980965 // resetAllButton = AddButton(oe, "Reset All");
981966 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
983967 // Return();
984968 slowerButton = AddButton(commandsPanel, "Slow");
969
+ slowerButton.setToolTipText("Decrease animation speed");
985970 fasterButton = AddButton(commandsPanel, "Fast");
971
+ fasterButton.setToolTipText("Increase animation speed");
986972 remarkButton = AddButton(commandsPanel, "Remark");
973
+ remarkButton.setToolTipText("Set the current transform as the target");
987974
988975 oe.ctrlPanel.add(commandsPanel);
989976 oe.ctrlPanel.Return();
990977
991
- 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
992979 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
993980 //Return();
994981
....@@ -1290,7 +1277,7 @@
12901277 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911278
12921279 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1280
+ scenePanel.preferredWidth = 6;
12941281
12951282 JTabbedPane tabbedPane = new JTabbedPane();
12961283 tabbedPane.add(scrollpane);
....@@ -1396,8 +1383,8 @@
13961383
13971384 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981385
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1386
+ frame.setSize(1280, 860);
1387
+ frame.setVisible(true);
14011388
14021389 gridPanel.setDividerLocation(1.0);
14031390
....@@ -1436,17 +1423,25 @@
14361423
14371424 cGridBag editBar = new cGridBag().setVertical(false);
14381425
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1426
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1427
+ createMaterialButton.setToolTipText("Create material");
14401428
14411429 /*
14421430 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14431431 */
14441432
1445
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1446
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1447
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1448
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1433
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1434
+ clearMaterialButton.setToolTipText("Clear material");
1435
+
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
+ }
14491442
1443
+ editBar.preferredHeight = 15;
1444
+
14501445 panel.add(editBar);
14511446
14521447 /**/
....@@ -1712,12 +1707,15 @@
17121707 opacityPowerField.addChangeListener(this);
17131708 /**/
17141709
1715
- resetSlidersButton.addActionListener(this);
17161710 clearMaterialButton.addActionListener(this);
17171711 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
1712
+
1713
+ if (Globals.ADVANCED)
1714
+ {
1715
+ resetSlidersButton.addActionListener(this);
1716
+ propagateToggle.addItemListener(this);
1717
+ multiplyToggle.addItemListener(this);
1718
+ }
17211719 }
17221720
17231721 void DropFile(java.io.File[] files, boolean textures)
....@@ -1888,7 +1886,7 @@
18881886
18891887 //? flashIt = false;
18901888 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
18921890 pane.clickEnd(location.x, location.y, 0, true);
18931891
18941892 if (group.selection.size() == 1)
....@@ -2345,11 +2343,11 @@
23452343
23462344 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23472345 {
2348
- if (GrafreeD.standAlone)
2346
+ if (Grafreed.standAlone)
23492347 {
23502348 /**/
23512349 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
2350
+ browser.setVisible(true);
23532351 String filename = browser.getFile();
23542352 if (filename != null && filename.length() > 0)
23552353 {
....@@ -2709,7 +2707,8 @@
27092707 return;
27102708 }
27112709
2712
- multiplyToggle.setSelected(mat.multiply);
2710
+ if (multiplyToggle != null)
2711
+ multiplyToggle.setSelected(mat.multiply);
27132712
27142713 assert (object.projectedVertices != null);
27152714
....@@ -2924,7 +2923,7 @@
29242923 frame.validate();
29252924
29262925 return;
2927
- } else if (event.getSource() == toggleRandomItem)
2926
+ } else if (event.getSource() == toggleSwitchItem)
29282927 {
29292928 cameraView.ToggleRandom();
29302929 cameraView.repaint();
....@@ -2955,6 +2954,10 @@
29552954 {
29562955 copy.live ^= true;
29572956 return;
2957
+ } else if (event.getSource() == selectCB)
2958
+ {
2959
+ copy.dontselect ^= true;
2960
+ return;
29582961 } else if (event.getSource() == hideCB)
29592962 {
29602963 copy.hide ^= true;
....@@ -2969,6 +2972,7 @@
29692972 if (event.getSource() == randomCB)
29702973 {
29712974 copy.random ^= true;
2975
+ objEditor.refreshContents();
29722976 return;
29732977 }
29742978 if (event.getSource() == speedupCB)
....@@ -2992,8 +2996,9 @@
29922996
29932997 public void actionPerformed(ActionEvent event)
29942998 {
2999
+ Object source = event.getSource();
29953000 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3001
+ if (source == okbutton)
29973002 {
29983003 textpanel.setVisible(false);
29993004 textpanel.remove(textarea);
....@@ -3005,7 +3010,7 @@
30053010 textarea = null;
30063011 textpanel = null;
30073012 }
3008
- if (event.getSource() == cancelbutton)
3013
+ if (source == cancelbutton)
30093014 {
30103015 textpanel.setVisible(false);
30113016 textpanel.remove(textarea);
....@@ -3017,50 +3022,50 @@
30173022 //applySelf();
30183023 //client.refreshEditWindow();
30193024 //refreshContents();
3020
- if (event.getSource() == nameField)
3025
+ if (source == nameField)
30213026 {
30223027 //System.out.println("ObjEditor " + event);
30233028 applySelf0(true);
30243029 //parent.applySelf();
30253030 objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
3031
+ } else if (source == resetButton)
30273032 {
30283033 CameraPane.fullreset = true;
30293034 copy.Reset(); // ResetMeshes();
30303035 copy.Touch();
30313036 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
3037
+ } else if (source == stepItem)
30333038 {
30343039 //cameraView.ONESTEP = true;
30353040 Globals.ONESTEP = true;
30363041 cameraView.repaint();
30373042 return;
3038
- } else if (event.getSource() == stepButton)
3043
+ } else if (source == stepButton)
30393044 {
30403045 copy.Step();
30413046 copy.Touch();
30423047 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
3048
+ } else if (source == slowerButton)
30443049 {
30453050 copy.Slower();
30463051 copy.Touch();
30473052 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
3053
+ } else if (source == fasterButton)
30493054 {
30503055 copy.Faster();
30513056 copy.Touch();
30523057 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
3058
+ } else if (source == remarkButton)
30543059 {
30553060 copy.Remark();
30563061 copy.Touch();
30573062 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
3063
+ } else if (source == stepAllButton)
30593064 {
30603065 copy.StepAll();
30613066 copy.Touch();
30623067 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
3068
+ } else if (source == resetAllButton)
30643069 {
30653070 //CameraPane.fullreset = true;
30663071 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +3098,75 @@
30933098 // Close();
30943099 // }
30953100 // else
3096
- if (event.getSource() == resetSlidersButton)
3101
+ if (source == resetSlidersButton)
30973102 {
30983103 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
3104
+ } else if (source == clearMaterialButton)
31003105 {
31013106 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
3107
+ } else if (source == createMaterialButton)
31033108 {
31043109 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
3110
+ } else if (source == clearPanelButton)
31063111 {
31073112 copy.ClearUI();
31083113 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ 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)
31153139 {
31163140 Close();
31173141 //return true;
3118
- } else if (event.getSource() == loadItem)
3142
+ } else if (source == loadItem)
31193143 {
31203144 load();
31213145 //return true;
3122
- } else if (event.getSource() == saveItem)
3146
+ } else if (source == newItem)
3147
+ {
3148
+ New();
3149
+ } else if (source == saveItem)
31233150 {
31243151 save();
31253152 //return true;
3126
- } else if (event.getSource() == saveAsItem)
3153
+ } else if (source == saveAsItem)
31273154 {
31283155 saveAs();
31293156 //return true;
3130
- } else if (event.getSource() == reexportItem)
3157
+ } else if (source == reexportItem)
31313158 {
31323159 reexport();
31333160 //return true;
3134
- } else if (event.getSource() == exportAsItem)
3161
+ } else if (source == exportAsItem)
31353162 {
31363163 export();
31373164 //return true;
3138
- } else if (event.getSource() == povItem)
3165
+ } else if (source == povItem)
31393166 {
31403167 generatePOV();
31413168 //return true;
3142
- } else if (event.getSource() == zBufferItem)
3169
+ } else if (source == zBufferItem)
31433170 {
31443171 try
31453172 {
....@@ -3161,21 +3188,8 @@
31613188 cameraView.repaint();
31623189 //return true;
31633190 }
3164
- */ else if (event.getSource() == editCameraItem)
3165
- {
3166
- cameraView.ProtectCamera();
3167
- cameraView.repaint();
3168
- return;
3169
- } else if (event.getSource() == revertCameraItem)
3170
- {
3171
- cameraView.RevertCamera();
3172
- cameraView.repaint();
3173
- return;
3174
-// } else if (event.getSource() == textureButton)
3175
-// {
3176
-// return; // true;
3177
- } else // combos...
3178
- if (event.getSource() == texresMenu)
3191
+ */ else // combos...
3192
+ if (source == texresMenu)
31793193 {
31803194 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31813195 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +3201,156 @@
31873201 }
31883202 }
31893203
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
+
31903348 void ToggleAnimation()
31913349 {
31923350 if (!Globals.ANIMATION)
31933351 {
31943352 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
3353
+ browser.setVisible(true);
31963354 String filename = browser.getFile();
31973355 if (filename != null && filename.length() > 0)
31983356 {
....@@ -3202,8 +3360,8 @@
32023360
32033361 Globals.ANIMATION ^= true;
32043362
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
3363
+ Grafreed.wav.cursor = 0;
3364
+ Grafreed.wav.loop = 0;
32073365 }
32083366 } else
32093367 {
....@@ -3224,7 +3382,6 @@
32243382 callee.refreshContents();
32253383 } else
32263384 {
3227
- new Exception().printStackTrace();
32283385 System.exit(0);
32293386 }
32303387 }
....@@ -3254,7 +3411,7 @@
32543411 void CreateMaterial()
32553412 {
32563413 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3414
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583415 if (copy.selection.size() > 0)
32593416 //SetMaterial(copy);
32603417 {
....@@ -3313,11 +3470,11 @@
33133470 {
33143471 copy.ResetBlockLoop(); // temporary problem
33153472
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3473
+ boolean random = CameraPane.SWITCH;
3474
+ CameraPane.SWITCH = false; // parse everything
33183475 copy.ResetDisplayList();
33193476 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3477
+ CameraPane.SWITCH = random;
33213478 }
33223479
33233480 // public void applySelf()
....@@ -3391,6 +3548,36 @@
33913548 {
33923549 //System.out.println("Propagate = " + propagate);
33933550 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
+
33943581 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953582 {
33963583 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3506,7 +3693,7 @@
35063693 }
35073694
35083695 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3696
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35103697 }
35113698
35123699 void SnapObject()
....@@ -3770,6 +3957,7 @@
37703957
37713958 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37723959 {
3960
+ Save();
37733961 //Tween.set(thing, 0).target(1).start(tweenManager);
37743962 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37753963 // if (thing instanceof GenericJointDemo)
....@@ -3973,6 +4161,7 @@
39734161 }
39744162 }
39754163 }
4164
+
39764165 LoadGFDThread loadGFDThread;
39774166
39784167 void ReadGFD(String fullname, iCallBack cb)
....@@ -3993,7 +4182,8 @@
39934182 try
39944183 {
39954184 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- 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);
39974187
39984188 readobj = (Object3D) p.readObject();
39994189 istream.close();
....@@ -4001,7 +4191,20 @@
40014191 readobj.ResetDisplayList();
40024192 } catch (Exception e)
40034193 {
4004
- 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
+ }
40054208 }
40064209 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40074210 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4118,7 +4321,7 @@
41184321
41194322 void load() // throws ClassNotFoundException
41204323 {
4121
- if (GrafreeD.standAlone)
4324
+ if (Grafreed.standAlone)
41224325 {
41234326 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41244327 browser.show();
....@@ -4205,11 +4408,13 @@
42054408 try
42064409 {
42074410 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4411
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4412
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42094413
42104414 p.writeObject(copy);
42114415 p.flush();
42124416
4417
+ zstream.close();
42134418 ostream.close();
42144419
42154420 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4219,11 +4424,12 @@
42194424 {
42204425 }
42214426 }
4427
+
42224428 String lastname;
42234429
42244430 void saveAs()
42254431 {
4226
- if (GrafreeD.standAlone)
4432
+ if (Grafreed.standAlone)
42274433 {
42284434 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42294435 browser.setVisible(true);
....@@ -4328,13 +4534,13 @@
43284534 try
43294535 {
43304536 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4537
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4538
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43334539
43344540 Object3D objectparent = obj.parent;
43354541 obj.parent = null;
43364542
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
4543
+ Object3D object = (Object3D) Grafreed.clone(obj);
43384544
43394545 obj.parent = objectparent;
43404546
....@@ -4346,8 +4552,8 @@
43464552 p.writeObject(object);
43474553 p.flush();
43484554
4555
+ zstream.close();
43494556 ostream.close();
4350
- // zstream.close();
43514557
43524558 // group.selection.get(0).parent = parent;
43534559 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +4574,7 @@
43684574 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43694575 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43704576 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
4577
+ if (Grafreed.standAlone)
43724578 {
43734579 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43744580 browser.show();
....@@ -4394,7 +4600,8 @@
43944600 Object3D client;
43954601 Object3D copy;
43964602 MenuBar menuBar;
4397
- Menu windowMenu;
4603
+ Menu fileMenu;
4604
+ MenuItem newItem;
43984605 MenuItem loadItem;
43994606 MenuItem saveItem;
44004607 MenuItem saveAsItem;
....@@ -4402,11 +4609,9 @@
44024609 MenuItem reexportItem;
44034610 MenuItem povItem;
44044611 MenuItem closeItem;
4405
- Menu cameraMenu;
4612
+
44064613 CheckboxMenuItem zBufferItem;
44074614 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44104615 MenuItem stepItem;
44114616 CheckboxMenuItem toggleLiveItem;
44124617 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,7 +4622,7 @@
44174622 CheckboxMenuItem toggleFootContactItem;
44184623 CheckboxMenuItem toggleDLItem;
44194624 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
4625
+ CheckboxMenuItem toggleSwitchItem;
44214626 CheckboxMenuItem toggleRootItem;
44224627 CheckboxMenuItem animationItem;
44234628 CheckboxMenuItem toggleHandleItem;
....@@ -4425,7 +4630,7 @@
44254630 JSplitPane mainPanel;
44264631 JScrollPane scrollpane;
44274632 JPanel toolbarPanel;
4428
- JPanel treePanel;
4633
+ cGridBag treePanel;
44294634 JPanel radioPanel;
44304635 ButtonGroup buttonGroup;
44314636 cGridBag ctrlPanel;
....@@ -4554,4 +4759,9 @@
45544759 //ObjectUI parent;
45554760
45564761 cNumberSlider normalpushField;
4762
+
4763
+ private MenuItem importGFDItem;
4764
+ private MenuItem importVRMLX3DItem;
4765
+ private MenuItem import3DSItem;
4766
+ private MenuItem importOBJItem;
45574767 }