From 21ac57b36a9e3b909853c7d64ac29b7ad72490a3 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 02 Sep 2019 16:52:19 -0400 Subject: [PATCH] Figure panel. --- GroupEditor.java | 2286 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 1,766 insertions(+), 520 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index a0702c4..ae9ebf2 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -16,6 +16,7 @@ //import buoy.widget.BFileChooser; class GroupEditor extends ObjEditor implements //iParse, //iCallBack, + Grafreed.iResourceCallBack, ObjectUI, Runnable, ActionListener, @@ -23,6 +24,350 @@ DragGestureListener, DragSourceListener, DropTargetListener, ItemListener // ListSelectionListener { + + public void AddSkyboxButton(String f, String s, cGridBag row) + { + cButton skyboxButton; + final String path = "cubemaps/" + f + "-skyboxes/" + s; + row.add(skyboxButton = GetButton(path + "/preview.jpg", !Globals.NIMBUSLAF)); + //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF)); + skyboxButton.setToolTipText(s.equals("") ? "No background" : s); + skyboxButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ChangeSkybox(path); + } + }); + } + + public void AddTextureButton(String f, String c, final String t, int count, cGridBag row) + { + cButton textureButton; + final String path = "textures/" + f + "/" + c + "/"; // + t; + row.add(textureButton = GetButton(path + "icons/" + t, !Globals.NIMBUSLAF)); + textureButton.setToolTipText(c + count); + textureButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ChangeTexture(path + t); + } + }); + } + + public void AddSkyboxTab0(JTabbedPane skyboxpanel) + { + cGridBag tab0 = new cGridBag().setVertical(true); + + tab0.setName("Urban"); + skyboxpanel.add(tab0); + + cGridBag row0 = new cGridBag(); + cGridBag row1 = new cGridBag(); + cGridBag row2 = new cGridBag(); + cGridBag row3 = new cGridBag(); + cGridBag row4 = new cGridBag(); + cGridBag row5 = new cGridBag(); + cGridBag row6 = new cGridBag(); + + AddSkyboxButton("default", "", row0); + //AddSkyboxButton("default", "cornell", row0); + AddSkyboxButton("penguins", "dust", row0); + AddSkyboxButton("penguins", "tropic", row0); + AddSkyboxButton("penguins", "yonder", row0); + + AddSkyboxButton("default", "uffizi", row1); + AddSkyboxButton("bridge", "Bridge", row1); + AddSkyboxButton("bridge", "Bridge2", row1); + AddSkyboxButton("urban", "GamlaStan2", row1); + + AddSkyboxButton("urban", "Parliament", row2); + AddSkyboxButton("urban", "Roundabout", row2); + AddSkyboxButton("urban", "SaintLazarusChurch", row2); + AddSkyboxButton("urban", "SaintLazarusChurch2", row2); + + AddSkyboxButton("urban", "SaintLazarusChurch3", row3); + AddSkyboxButton("urban", "UnionSquare", row3); + AddSkyboxButton("urban", "Medborgarplatsen", row3); + AddSkyboxButton("park", "BerzeliiPark", row3); + + AddSkyboxButton("park", "Buddha", row4); + AddSkyboxButton("park", "CNTower2", row4); + AddSkyboxButton("park", "NiagaraFalls1", row4); + AddSkyboxButton("park", "NiagaraFalls3", row4); + + AddSkyboxButton("park", "Park", row5); + AddSkyboxButton("park", "Pond", row5); + AddSkyboxButton("park", "Skansen", row5); + AddSkyboxButton("park", "Skansen2", row5); + + AddSkyboxButton("park", "Skansen3", row6); + AddSkyboxButton("park", "Skansen4", row6); + AddSkyboxButton("park", "Skansen5", row6); + AddSkyboxButton("persson", "VancouverConventionCentre", row6); + + tab0.add(row0); + tab0.add(row1); + tab0.add(row2); + tab0.add(row3); + tab0.add(row4); + tab0.add(row5); + tab0.add(row6); + + for (int i=5; --i>=0;) + { + //oe.toolboxPanel.Return(); + //tab0.add(new cGridBag()); + } + } + + public void AddSkyboxTab1(JTabbedPane skyboxpanel) + { + cGridBag tab0 = new cGridBag().setVertical(true); + + tab0.setName("Nature"); + skyboxpanel.add(tab0); + + cGridBag row0 = new cGridBag(); + cGridBag row1 = new cGridBag(); + cGridBag row2 = new cGridBag(); + cGridBag row3 = new cGridBag(); + cGridBag row4 = new cGridBag(); + cGridBag row5 = new cGridBag(); + cGridBag row6 = new cGridBag(); + + AddSkyboxButton("beach", "HeartInTheSand", row0); + AddSkyboxButton("beach", "LarnacaBeach", row0); + AddSkyboxButton("beach", "PalmTrees", row0); + AddSkyboxButton("beach", "Tenerife", row0); + + AddSkyboxButton("beach", "Tenerife2", row1); + AddSkyboxButton("beach", "Tenerife3", row1); + AddSkyboxButton("field", "FishPond", row1); + AddSkyboxButton("field", "Footballfield", row1); + + AddSkyboxButton("field", "Meadow", row2); + AddSkyboxButton("field", "Sorsele", row2); + AddSkyboxButton("field", "Sorsele2", row2); + AddSkyboxButton("field", "Sorsele3", row2); + + AddSkyboxButton("forest", "Brudslojan", row3); + AddSkyboxButton("forest", "Langholmen2", row3); + AddSkyboxButton("forest", "Plants", row3); + AddSkyboxButton("mountain", "Maskonaive", row3); + + AddSkyboxButton("mountain", "Maskonaive2", row4); + AddSkyboxButton("mountain", "Maskonaive3", row4); + AddSkyboxButton("mountain", "Teide", row4); + AddSkyboxButton("park", "Tantolunden4", row4); + + AddSkyboxButton("park", "Stairs", row5); + AddSkyboxButton("default", "skycube", row6); + AddSkyboxButton("rocky", "Langholmen", row5); + AddSkyboxButton("rocky", "Skinnarviksberget", row5); + + AddSkyboxButton("rocky", "Tantolunden6", row5); + AddSkyboxButton("default", "CloudyHills", row6); + AddSkyboxButton("daz", "Autumn", row6); + AddSkyboxButton("daz", "MountainTrail", row6); + /* +Autumn +Greenlands +MountainTrail +Oasis +TheRock +TopOfTheWorld +Winter + */ + + tab0.add(row0); + tab0.add(row1); + tab0.add(row2); + tab0.add(row3); + tab0.add(row4); + tab0.add(row5); + tab0.add(row6); + + for (int i=5; --i>=0;) + { + //oe.toolboxPanel.Return(); + //tab0.add(new cGridBag()); + } + } + + public void AddSkyboxTab2(JTabbedPane skyboxpanel) + { + cGridBag tab0 = new cGridBag().setVertical(true); + + tab0.setName("Night"); + skyboxpanel.add(tab0); + + cGridBag row0 = new cGridBag(); + cGridBag row1 = new cGridBag(); + cGridBag row2 = new cGridBag(); + cGridBag row3 = new cGridBag(); + cGridBag row4 = new cGridBag(); + cGridBag row5 = new cGridBag(); + cGridBag row6 = new cGridBag(); + + AddSkyboxButton("night", "NightPath", row0); + AddSkyboxButton("night", "PondNight", row0); + AddSkyboxButton("night", "Powerlines", row0); + AddSkyboxButton("night", "SwedishRoyalCastle", row0); + + AddSkyboxButton("urban", "CNTower", row1); + AddSkyboxButton("bridge", "ArstaBridge", row1); + AddSkyboxButton("rocky", "Riddarfjarden", row1); + AddSkyboxButton("penguins", "sleepyhollow", row1); + + AddSkyboxButton("penguins", "kenon_star", row2); + AddSkyboxButton("persson", "corona", row2); + AddSkyboxButton("persson", "spaceskybox", row2); + AddSkyboxButton("indoors", "Vasa", row2); + + AddSkyboxButton("winter", "Backyard", row3); + AddSkyboxButton("winter", "Creek", row3); + AddSkyboxButton("winter", "FootballField3", row3); + AddSkyboxButton("winter", "Forest", row3); + + AddSkyboxButton("winter", "HornstullsStrand2", row4); + AddSkyboxButton("winter", "House", row4); + AddSkyboxButton("winter", "IceLake", row4); + AddSkyboxButton("winter", "IceRiver", row4); + + AddSkyboxButton("winter", "Park3", row5); + AddSkyboxButton("winter", "PondWinter", row5); + AddSkyboxButton("winter", "Tantolunden5", row5); + AddSkyboxButton("winter", "Vindelalven", row5); + + AddSkyboxButton("daz", "TheRock", row6); + AddSkyboxButton("daz", "TopOfTheWorld", row6); + AddSkyboxButton("daz", "Winter", row6); + AddSkyboxButton("mountain", "Ryfjallet", row6); + + tab0.add(row0); + tab0.add(row1); + tab0.add(row2); + tab0.add(row3); + tab0.add(row4); + tab0.add(row5); + tab0.add(row6); + + for (int i=5; --i>=0;) + { + //oe.toolboxPanel.Return(); + //tab0.add(new cGridBag()); + } + } + + public void AddSkyboxTab3(JTabbedPane skyboxpanel) + { + cGridBag tab0 = new cGridBag().setVertical(true); + + tab0.setName("Others"); + skyboxpanel.add(tab0); + + cGridBag row0 = new cGridBag(); + cGridBag row1 = new cGridBag(); + cGridBag row2 = new cGridBag(); + cGridBag row3 = new cGridBag(); + cGridBag row4 = new cGridBag(); + cGridBag row5 = new cGridBag(); + cGridBag row6 = new cGridBag(); + + AddSkyboxButton("mayhem", "afterrain", row0); + AddSkyboxButton("mayhem", "aqua4", row0); + AddSkyboxButton("mayhem", "aqua9", row0); + AddSkyboxButton("mayhem", "flame", row0); + + AddSkyboxButton("mayhem", "h2s", row1); + AddSkyboxButton("mayhem", "prehistoric", row1); + AddSkyboxButton("mayhem", "scorched", row1); + AddSkyboxButton("penguins", "desertdawn", row1); + + AddSkyboxButton("persson", "Citadella", row2); + AddSkyboxButton("persson", "Citadella2", row2); + AddSkyboxButton("persson", "clouds1", row2); + AddSkyboxButton("penguins", "wrath", row2); + + AddSkyboxButton("persson", "FishermansBastion", row3); + AddSkyboxButton("persson", "HeroesSquare", row3); + AddSkyboxButton("indoors", "DallasW", row3); + AddSkyboxButton("indoors", "MarriottMadisonWest", row3); + + AddSkyboxButton("persson", "LancellottiChapel", row4); + AddSkyboxButton("persson", "PereaBeach1", row4); + AddSkyboxButton("persson", "PereaBeach2", row4); + AddSkyboxButton("persson", "redeclipse", row4); + + AddSkyboxButton("daz", "Greenlands", row5); + AddSkyboxButton("daz", "Oasis", row5); + AddSkyboxButton("elyvisions", "arch3", row5); + AddSkyboxButton("elyvisions", "calm_sea", row5); + + AddSkyboxButton("elyvisions", "rainbow", row6); + AddSkyboxButton("elyvisions", "distant_sunset", row6); + AddSkyboxButton("elyvisions", "heaven", row6); + AddSkyboxButton("elyvisions", "hot", row6); + + tab0.add(row0); + tab0.add(row1); + tab0.add(row2); + tab0.add(row3); + tab0.add(row4); + tab0.add(row5); + tab0.add(row6); + + for (int i=5; --i>=0;) + { + //oe.toolboxPanel.Return(); + //tab0.add(new cGridBag()); + } + } + + public void ChangeSkybox(String skybox) + { + if (skybox.endsWith("/")) + { + group.skyboxname = null; + group.skyboxext = null; + cameraView.repaint(); + } + else + { + //cameraView.envyoff = false; + group.skyboxname = skybox; + group.skyboxext = "jpg"; + cameraView.repaint(); + } + } + + public void CreateSkyboxPanel(cGridBag skyboxPanel) + { + JTabbedPane skyboxpane = new JTabbedPane(JTabbedPane.LEFT); + + AddSkyboxTab0(skyboxpane); + AddSkyboxTab1(skyboxpane); + AddSkyboxTab2(skyboxpane); + AddSkyboxTab3(skyboxpane); + + skyboxPanel.add(skyboxpane); + } + + public void ChangeTexture(String texture) + { + for (int i=0; i<group.selection.size(); i++) + { + Object3D obj = group.selection.get(i); + obj.SetPigmentTexture("@" + texture); + } + + refreshContents(); + } + //ObjEditor objEditor; public void closeUI2() { @@ -60,6 +405,16 @@ this.copy = this.group = group; //selectees = this.group.selectees; + assert(false); + +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; +// copy.versionindex = -1; +// +// //Save(true); +// } + if(ui) SetupUI(objEditor); } @@ -74,16 +429,28 @@ this.copy = this.group = copy; //selectees = this.group.selectees; - SetupMenu2(objEditor); + SetupMenu2(this); //objEditor); SetupUI2(objEditor); objEditor.SetupUI(true); SetupViews(objEditor); ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true); + +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; +// copy.versionindex = -1; +// +// //Save(true); +// } } void CloneSelection(boolean supports) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; // Object3D keep = GrafreeD.clipboard; //Object3D obj; for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();) @@ -94,18 +461,19 @@ makeSomething(clone, i==group.selection.size()-1); } + Globals.REPLACEONMAKE = keep; } void CloneClipboard(boolean supports) { - assert(GrafreeD.clipboard.parent == null); - Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent; - GrafreeD.clipboard.get(0).parent = null; // Avoid copy? - if (LA.isIdentity(GrafreeD.clipboard.toParent)) - makeSomething(CloneObject(GrafreeD.clipboard.get(0), false)); + assert(Grafreed.clipboard.parent == null); + Object3D /*Composite*/ keepparent = Grafreed.clipboard.get(0).parent; + Grafreed.clipboard.get(0).parent = null; // Avoid copy? + if (LA.isIdentity(Grafreed.clipboard.toParent)) + makeSomething(CloneObject(Grafreed.clipboard.get(0), false)); else - makeSomething(CloneObject(GrafreeD.clipboard, false)); - GrafreeD.clipboard.get(0).parent = keepparent; + makeSomething(CloneObject(Grafreed.clipboard, false)); + Grafreed.clipboard.get(0).parent = keepparent; } static Object3D CloneObject(Object3D obj, boolean supports) @@ -119,7 +487,7 @@ // obj.support = null; if (!supports) obj.SaveSupports(); - Object3D clone = (Object3D)GrafreeD.clone(obj); + Object3D clone = (Object3D)Grafreed.clone(obj); obj.parent = parent; // obj.support = support; // clone.support = support; // aout 2013 @@ -148,57 +516,51 @@ //JTextField nameField; - void SetupMenu2(ObjEditor oe) + void SetupMenu2(GroupEditor oe) { - if (Globals.ADVANCED) - { - oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest")); - //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection")); - //cameraMenu.add(switchItem = new MenuItem("Reverse View")); - editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf")); - oe.cameraMenu.add("-"); - openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy...")); - openWindowItem.addActionListener(this); - editLeafItem.addActionListener(this); - lookAtItem.addActionListener(this); - //lookFromItem.addActinoListener(this); - //switchItem.addActionListener(this); - } - + oe.jTree = new cTree(); + Menu menu; oe.menuBar.add(menu = new Menu("Edit")); //editItem = menu.add(new MenuItem("Edit")); //editItem.addActionListener(this); - duplicateItem = menu.add(new MenuItem("Duplicate")); + +// undoItem = menu.add(new MenuItem("Undo")); +// undoItem.addActionListener(this); +// redoItem = menu.add(new MenuItem("Redo")); +// redoItem.addActionListener(this); +// menu.add("-"); + duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate")); duplicateItem.addActionListener(this); - cloneItem = menu.add(new MenuItem("Clone")); + + cloneItem = oe.jTree.popup.add(new JMenuItem("Clone")); cloneItem.addActionListener(this); - if (Globals.ADVANCED) + //if (Globals.ADVANCED) { cloneSupportItem = menu.add(new MenuItem("Clone (+supports)")); cloneSupportItem.addActionListener(this); } + oe.jTree.popup.addSeparator(); menu.add("-"); - cutItem = menu.add(new MenuItem("Cut")); + cutItem = oe.jTree.popup.add(new JMenuItem("Cut")); cutItem.addActionListener(this); - copyItem = menu.add(new MenuItem("Copy")); + copyItem = oe.jTree.popup.add(new JMenuItem("Copy")); copyItem.addActionListener(this); pasteItem = menu.add(new MenuItem("Paste")); pasteItem.addActionListener(this); - menu.add("-"); - menu.add("-"); - pasteIntoItem = menu.add(new MenuItem("Paste into")); + oe.jTree.popup.addSeparator(); + //menu.add("-"); + pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into")); pasteIntoItem.addActionListener(this); - pasteLinkItem = menu.add(new MenuItem("Paste link")); + pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link")); pasteLinkItem.addActionListener(this); - pasteCloneItem = menu.add(new MenuItem("Paste clone")); + pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone")); pasteCloneItem.addActionListener(this); -// pasteExpandItem = menu.add(new MenuItem("Paste expand")); +// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand")); // pasteExpandItem.addActionListener(this); - menu.add("-"); - clearItem = menu.add(new MenuItem("Clear")); - clearItem.addActionListener(this); + //menu.add("-"); + oe.jTree.popup.addSeparator(); if (Globals.ADVANCED) { @@ -206,14 +568,95 @@ clearAllItem = menu.add(new MenuItem("Clear All")); clearAllItem.addActionListener(this); } + + menuBar.add(cameraMenu = new Menu("View")); + //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer")); + //zBufferItem.addActionListener(this); + //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens")); + //normalLensItem.addActionListener(this); + cameraMenu.add(restoreCameraItem = new MenuItem("Restore Viewpoint")); + restoreCameraItem.addActionListener(this); + +// cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen")); +// toggleFullScreenItem.addItemListener(this); +// toggleFullScreenItem.setState(CameraPane.FULLSCREEN); +// cameraMenu.add("-"); +// +// cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture")); +// toggleTextureItem.addItemListener(this); +// toggleTextureItem.setState(CameraPane.textureon); +// +// cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch")); +// toggleSwitchItem.addItemListener(this); +// toggleSwitchItem.setState(CameraPane.SWITCH); + + cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Show Handles")); + toggleHandleItem.addItemListener(this); + toggleHandleItem.setState(CameraPane.HANDLES); + + cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode")); + togglePaintItem.addItemListener(this); + togglePaintItem.setState(CameraPane.PAINTMODE); + + if (Globals.ADVANCED) + { + cameraMenu.add("-"); + cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live")); + toggleLiveItem.addItemListener(this); + toggleLiveItem.setState(Globals.isLIVE()); + cameraMenu.add(stepItem = new MenuItem("Step")); + stepItem.addActionListener(this); + // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List")); + // toggleDLItem.addItemListener(this); + // toggleDLItem.setState(false); + + cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render")); + toggleRenderItem.addItemListener(this); + toggleRenderItem.setState(!CameraPane.frozen); + + cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug")); + toggleDebugItem.addItemListener(this); + toggleDebugItem.setState(Globals.DEBUG); + + cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum")); + toggleFrustumItem.addItemListener(this); + toggleFrustumItem.setState(CameraPane.FRUSTUM); + + cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact")); + toggleFootContactItem.addItemListener(this); + toggleFootContactItem.setState(CameraPane.FOOTCONTACT); + + cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline")); + toggleTimelineItem.addItemListener(this); + } + +// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root")); +// toggleRootItem.addItemListener(this); +// toggleRootItem.setState(false); +// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation")); +// animationItem.addItemListener(this); +// animationItem.setState(CameraPane.ANIMATION); + cameraMenu.add("-"); + cameraMenu.add(editCameraItem = new MenuItem("Save Viewpoint")); + editCameraItem.addActionListener(this); + + if (Globals.ADVANCED) + { + oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest")); + //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection")); + //cameraMenu.add(switchViewItem = new MenuItem("Reverse View")); + oe.cameraMenu.add("-"); + openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy...")); + openWindowItem.addActionListener(this); + lookAtItem.addActionListener(this); + //lookFromItem.addActinoListener(this); + //switchViewItem.addActionListener(this); + } + oe.menuBar.add(menu = new Menu("Setting")); if (Globals.ADVANCED) { - resetMeshItem = menu.add(new MenuItem("Reset All")); - resetMeshItem.addActionListener(this); - stepAllItem = menu.add(new MenuItem("Step All")); - stepAllItem.addActionListener(this); revertMeshItem = menu.add(new MenuItem("Revert Meshes")); revertMeshItem.addActionListener(this); resetreferencesItem = menu.add(new MenuItem("Reset Mesh References")); @@ -252,22 +695,37 @@ setMasterItem.addActionListener(this); } - oe.menuBar.add(menu = new Menu("Group")); - grabItem = menu.add(new MenuItem("Grab")); - grabItem.addActionListener(this); + oe.menuBar.add(menu = new Menu("Order")); + backItem = menu.add(new MenuItem("Back")); backItem.addActionListener(this); frontItem = menu.add(new MenuItem("Front")); frontItem.addActionListener(this); - compositeItem = menu.add(new MenuItem("Composite")); - compositeItem.addActionListener(this); +// compositeItem = menu.add(new MenuItem("Composite")); +// compositeItem.addActionListener(this); + + grabItem = oe.jTree.popup.add(new JMenuItem("Group")); + grabItem.addActionListener(this); + + if (Globals.ADVANCED) + { hideItem = menu.add(new MenuItem("Hidden Group")); hideItem.addActionListener(this); - ungroupItem = menu.add(new MenuItem("Ungroup")); + } + ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup")); ungroupItem.addActionListener(this); - menu.add("-"); - randomItem = menu.add(new MenuItem("Switch node")); - randomItem.addActionListener(this); + + oe.jTree.popup.addSeparator(); + + deleteItem = oe.jTree.popup.add(new JMenuItem("Delete")); + deleteItem.addActionListener(this); + +// menu.add("-"); +// +// switchItem = menu.add(new MenuItem("Switch node")); +// switchItem.addActionListener(this); + if (Globals.ADVANCED) + { switchGeoItem = menu.add(new MenuItem("Switch Geometry")); switchGeoItem.addActionListener(this); switchTransfoItem = menu.add(new MenuItem("Switch Transform")); @@ -275,8 +733,6 @@ morphItem = menu.add(new MenuItem("Morph Group")); morphItem.addActionListener(this); - if (Globals.ADVANCED) - { menu.add("-"); physicsItem = menu.add(new MenuItem("Physics")); physicsItem.addActionListener(this); @@ -284,42 +740,52 @@ frameselectorItem.addActionListener(this); scriptNodeItem = menu.add(new MenuItem("Script Node")); scriptNodeItem.addActionListener(this); - cameraItem = menu.add(new MenuItem("Camera")); - cameraItem.addActionListener(this); } oe.menuBar.add(menu = new Menu("Object")); - textureItem = menu.add(new MenuItem("Texture")); - textureItem.addActionListener(this); +// textureItem = menu.add(new MenuItem("Texture")); +// textureItem.addActionListener(this); billboardItem = menu.add(new MenuItem("Billboard")); billboardItem.addActionListener(this); csgItem = menu.add(new MenuItem("CSG")); csgItem.addActionListener(this); - shadowXItem = menu.add(new MenuItem("Shadow X")); + shadowXItem = menu.add(new MenuItem("Shadow Red")); shadowXItem.addActionListener(this); - shadowYItem = menu.add(new MenuItem("Shadow Y")); + shadowYItem = menu.add(new MenuItem("Shadow Green")); shadowYItem.addActionListener(this); - shadowZItem = menu.add(new MenuItem("Shadow Z")); + shadowZItem = menu.add(new MenuItem("Shadow Blue")); shadowZItem.addActionListener(this); + + attributeItem = menu.add(new MenuItem("Attribute")); + attributeItem.addActionListener(this); if (Globals.ADVANCED) { menu.add("-"); linkerItem = menu.add(new MenuItem("Linker")); linkerItem.addActionListener(this); - attributeItem = menu.add(new MenuItem("Attribute")); - attributeItem.addActionListener(this); templateItem = menu.add(new MenuItem("Template")); templateItem.addActionListener(this); pointflowItem = menu.add(new MenuItem("Point Flow")); pointflowItem.addActionListener(this); } menu.add("-"); + textureRatioRItem = menu.add(new MenuItem("Texture Ratio Red")); + textureRatioRItem.addActionListener(this); + textureRatioGItem = menu.add(new MenuItem("Texture Ratio Green")); + textureRatioGItem.addActionListener(this); + textureRatioBItem = menu.add(new MenuItem("Texture Ratio Blue")); + textureRatioBItem.addActionListener(this); + menu.add("-"); resetTransformItem = menu.add(new MenuItem("Reset Transform")); resetTransformItem.addActionListener(this); resetCentroidItem = menu.add(new MenuItem("Reset Centroid")); resetCentroidItem.addActionListener(this); - transformgeometryItem = menu.add(new MenuItem("Transform Geometry")); - transformgeometryItem.addActionListener(this); + resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XZ")); + resetCentroidXZItem.addActionListener(this); + transformGeometryItem = menu.add(new MenuItem("Transform Geometry")); + transformGeometryItem.addActionListener(this); + transformChildrenItem = menu.add(new MenuItem("Transform Children")); + transformChildrenItem.addActionListener(this); oe.menuBar.add(menu = new Menu("Geometry")); genUVItem = menu.add(new MenuItem("Generate UV")); @@ -332,7 +798,7 @@ genNormalsMESHItem.addActionListener(this); if (Globals.ADVANCED) { - genNormalsMINEItem = menu.add(new MenuItem("My Normals")); + genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals")); genNormalsMINEItem.addActionListener(this); } stripifyItem = menu.add(new MenuItem("Stripify")); @@ -366,8 +832,14 @@ } oe.menuBar.add(menu = new Menu("Attributes")); + clearVersionsItem = menu.add(new MenuItem("Clear Versions")); + clearVersionsItem.addActionListener(this); clearMaterialsItem = menu.add(new MenuItem("Clear Materials")); clearMaterialsItem.addActionListener(this); + resetAllItem = menu.add(new MenuItem("Reset All")); + resetAllItem.addActionListener(this); + stepAllItem = menu.add(new MenuItem("Step All")); + stepAllItem.addActionListener(this); menu.add("-"); liveleavesItem = menu.add(new MenuItem("Live Leaves")); liveleavesItem.addActionListener(this); @@ -384,10 +856,18 @@ hideleavesItem.addActionListener(this); showleavesItem = menu.add(new MenuItem("Show Leaves")); showleavesItem.addActionListener(this); - markleavesItem = menu.add(new MenuItem("Mark Leaves")); + markleavesItem = menu.add(new MenuItem("Anim Leaves")); markleavesItem.addActionListener(this); - unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves")); + unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves")); unmarkleavesItem.addActionListener(this); + rewindleavesItem = menu.add(new MenuItem("Rewind Leaves")); + rewindleavesItem.addActionListener(this); + unrewindleavesItem = menu.add(new MenuItem("Unrewind Leaves")); + unrewindleavesItem.addActionListener(this); + randomleavesItem = menu.add(new MenuItem("Random Leaves")); + randomleavesItem.addActionListener(this); + unrandomleavesItem = menu.add(new MenuItem("Unrandom Leaves")); + unrandomleavesItem.addActionListener(this); menu.add("-"); flipVItem = menu.add(new MenuItem("Flip V")); flipVItem.addActionListener(this); @@ -413,58 +893,135 @@ attachBumpItem.addActionListener(this); pigmentBumpItem = menu.add(new MenuItem("Pigment -> Bump")); pigmentBumpItem.addActionListener(this); + //embedTexturesItem detachPigmentItem = menu.add(new MenuItem("Detach Pigment")); detachPigmentItem.addActionListener(this); detachBumpItem = menu.add(new MenuItem("Detach Bump")); detachBumpItem.addActionListener(this); + embedTexturesItem = menu.add(new MenuItem("Embed Textures")); + embedTexturesItem.addActionListener(this); + deEmbedTexturesItem = menu.add(new MenuItem("De-embed Textures")); + deEmbedTexturesItem.addActionListener(this); menu.add("-"); sortbysizeItem = menu.add(new MenuItem("Sort by size")); sortbysizeItem.addActionListener(this); sortbynameItem = menu.add(new MenuItem("Sort by name")); sortbynameItem.addActionListener(this); + menu.add("-"); + shareGeometriesItem = menu.add(new MenuItem("Share Geometries")); + shareGeometriesItem.addActionListener(this); + mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries")); + mergeGeometriesItem.addActionListener(this); + menu.add("-"); + editLeafItem = menu.add(new MenuItem("Edit leaf...")); + editLeafItem.addActionListener(this); if (Globals.ADVANCED) { - menu.add("-"); + // Pretty much the same as duplicate and clone. extractGeometriesItem = menu.add(new MenuItem("Link Geometry")); extractGeometriesItem.addActionListener(this); cloneGeometriesItem = menu.add(new MenuItem("Clone Geometry")); cloneGeometriesItem.addActionListener(this); - shareGeometriesItem = menu.add(new MenuItem("Share Geometry")); - shareGeometriesItem.addActionListener(this); - mergeGeometriesItem = menu.add(new MenuItem("Merge Geometry")); - mergeGeometriesItem.addActionListener(this); } oe.menuBar.add(menu = new Menu("Insert")); buildCreateMenu(menu); - oe.menuBar.add(menu = new Menu("Include")); - importOBJItem = menu.add(new MenuItem("OBJ file...")); - importOBJItem.addActionListener(this); - menu.add("-"); - import3DSItem = menu.add(new MenuItem("3DS file...")); - import3DSItem.addActionListener(this); - menu.add("-"); - importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file...")); - importVRMLX3DItem.addActionListener(this); - menu.add("-"); - importGFDItem = menu.add(new MenuItem("GrafreeD file...")); - importGFDItem.addActionListener(this); - oe.menuBar.add(menu = new Menu("Tools")); buildToolsMenu(menu); } + JTabbedPane resourcecontainer; + cGridBag currenttab; + //boolean added; // patch for jar + + int totalcount = 0; + + int tabcount = 0; + int colcount = 0; + int rowcount = 0; + int texturecount = 0; + + int columns = 5; + int rows = 7; + + public void ResourceCallBack(String[] path) + { +// for (int i = 0; i < path.length; i++) +// System.out.print(path[i] + "/"); +// System.out.println(); + + if (//rowcount == 0 || + path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store")) + { + currenttab = new cGridBag(); + String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); + currenttab.setName(tabname); + //added = false; + resourcecontainer.add(currenttab); + resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname); + rowcount = 1; + colcount = 0; + texturecount = 0; + } + + if (path.length > 2 && (path[2].toLowerCase().endsWith(".jpg") || path[2].toLowerCase().endsWith(".png"))) + { + //if (!added) + { + //added = true; + String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); + currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname)); + } + + AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab); + totalcount++; + + if (++colcount >= columns) + { + colcount = 0; + currenttab.Return(); + + if (rowcount++ >= rows) + { + rowcount = 0; + } + } + } + else + { +// if (!path[path.length-1].equals("icons")) +// resourcecontainer.Return(); + } + } + + void CreateTexturePanel(cGridBag container) + { + resourcecontainer = new JTabbedPane(JTabbedPane.LEFT); + container.add(resourcecontainer); + + Grafreed.ParseResources("textures", this); + + // 935. System.out.println("Total = " + totalcount); + } + void SetupUI2(ObjEditor oe) { + // June 2019 + if (oe == null) + { + //super.SetupUI2(this); + //return; + } + + if (copy != group) + { + //super.SetupUI2(this); + } + //new Exception().printStackTrace(); oe.radioPanel = new JPanel(new GridBagLayout()); - oe.aConstraints.weightx = 1; - oe.aConstraints.weighty = 0; - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; - oe.aConstraints.gridwidth = 100; - oe.aConstraints.gridheight = 1; // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints); oe.buttonGroup = new ButtonGroup(); @@ -485,97 +1042,268 @@ oe.radioPanel.add(dummyButton); oe.buttonGroup.add(dummyButton); */ + cGridBag versionManagerPanel = new cGridBag(); + + versionManagerPanel.preferredHeight = 4; + //this.AddOptions(oe.toolbarPanel, oe.aConstraints); - oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints); - liveCB.setToolTipText("Enabled animation"); - liveCB.addItemListener(this); + //oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + //minButton.setToolTipText("Minimize window"); + //minButton.addActionListener(this); + + if (Globals.ADVANCED) + { +// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// maxButton.setToolTipText("Maximize window"); +// maxButton.addActionListener(this); + } + + cButton gcButton; + +// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// gcButton.setToolTipText("Garbage collect"); +// gcButton.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent e) +// { +// System.gc(); +// } +// }); + + oe.toolbarPanel.add(fullScreenButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + fullScreenButton.setToolTipText("Full-screen window"); + fullScreenButton.addActionListener(this); + + oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + collapseButton.setToolTipText("Collapse toolbar"); + collapseButton.addActionListener(this); + +// oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); +// maximize3DButton.setToolTipText("Maximize 3D view"); +// maximize3DButton.addActionListener(this); + + oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + twoButton.setToolTipText("Show 3D view only"); + twoButton.addActionListener(this); + this.fullscreenLayout = twoButton; + + oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + threeButton.setToolTipText("Show controls and 3D view"); + threeButton.addActionListener(this); + if (Globals.ADVANCED) + { + oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + sixButton.setToolTipText("Show 3D view and controls"); + sixButton.addActionListener(this); + } +// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// sevenButton.setToolTipText("3-column layout"); +// sevenButton.addActionListener(this); + // + + oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + screenfitButton.setToolTipText("Screen fit"); + screenfitButton.addActionListener(this); - oe.toolbarPanel.add(oneStepButton = new cButton("Step", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + restoreCameraButton.setToolTipText("Restore viewpoint"); + restoreCameraButton.addActionListener(this); + + versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + saveVersionButton.setToolTipText("Duplicate current version"); + saveVersionButton.addActionListener(this); + + versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + deleteVersionButton.setToolTipText("Delete current version"); + deleteVersionButton.addActionListener(this); + deleteVersionButton.setEnabled(false); + + versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + previousVersionButton.setToolTipText("Previous version"); + previousVersionButton.addActionListener(this); + previousVersionButton.setEnabled(false); + + cGridBag updown = new cGridBag().setVertical(true); + updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + restoreButton.setToolTipText("Undo (restore current version)"); + restoreButton.addActionListener(this); + restoreButton.setEnabled(false); + + updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + replaceButton.setToolTipText("Save (replace current version)"); + replaceButton.addActionListener(this); + replaceButton.setEnabled(false); + + versionManagerPanel.add(updown); + + versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + nextVersionButton.setToolTipText("Next version"); + nextVersionButton.addActionListener(this); + nextVersionButton.setEnabled(false); + + oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); oneStepButton.setToolTipText("Animate one step forward"); oneStepButton.addActionListener(this); - oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST)); //, constraints); + oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); + liveCB.setToolTipText("Enable animation"); + liveCB.addItemListener(this); + + oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints); fastCB.setToolTipText("Fast mode"); fastCB.addItemListener(this); - oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints); - trackCB.setToolTipText("Enable tracking"); - trackCB.addItemListener(this); - - oe.toolbarPanel.add(screenfitButton = new cButton("@", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - screenfitButton.setToolTipText("Screen fit"); - screenfitButton.addActionListener(this); + //oe.toolboxPanel.Return(); + +// copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints); +// trackCB.setToolTipText("Enable tracking"); +// trackCB.addItemListener(this); // oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints); // screenfitpointButton.addActionListener(this); if (Globals.ADVANCED) { - oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints); snapobjectButton.addActionListener(this); snapobjectButton.setToolTipText("Snap Object"); + + oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + fourButton.addActionListener(this); + fourButton.setToolTipText("Show control panel only"); } - oe.toolbarPanel.add(flashSelectionButton = new cButton("?", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - flashSelectionButton.setToolTipText("Show selection"); - flashSelectionButton.addActionListener(this); + //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - - oe.toolbarPanel.add(twoButton = new cButton("|+|", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - twoButton.setToolTipText("Show center view only"); - twoButton.addActionListener(this); - oe.toolbarPanel.add(fourButton = new cButton("+||", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - fourButton.addActionListener(this); - fourButton.setToolTipText("Show left panel only"); - oe.toolbarPanel.add(sixButton = new cButton("+|+|", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - sixButton.setToolTipText("2-column layout left"); - sixButton.addActionListener(this); - oe.toolbarPanel.add(threeButton = new cButton("|+|+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - threeButton.setToolTipText("2-column layout right"); - threeButton.addActionListener(this); - oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - sevenButton.setToolTipText("3-column layout"); - sevenButton.addActionListener(this); - // - oe.toolbarPanel.add(rootButton = new cButton("o o o", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - rootButton.setToolTipText("Edit selection in new tab"); + oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + rootButton.setToolTipText("Open selection in new tab"); rootButton.addActionListener(this); - oe.toolbarPanel.add(closeButton = new cButton("X", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); closeButton.setToolTipText("Close tab"); closeButton.addActionListener(this); //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints); //clearButton.addActionListener(this); - - cGridBag commandsPanel = new cGridBag(); + + cGridBag row1 = new cGridBag(); - commandsPanel.add(editButton = new cButton("+", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - editButton.setToolTipText("Edit selection"); + // INSERT + row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + gridButton.setToolTipText("Create ground"); + gridButton.addActionListener(this); + + row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + boxButton.setToolTipText("Create box"); + boxButton.addActionListener(this); + + row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + superButton.setToolTipText("Create superellipsoid"); + superButton.addActionListener(this); + + row1.add(sphereButton = GetButton("icons/sphere.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + sphereButton.setToolTipText("Create sphere"); + sphereButton.addActionListener(this); + + row1.add(coneButton = GetButton("icons/cone.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + coneButton.setToolTipText("Create cone"); + coneButton.addActionListener(this); + + row1.add(torusButton = GetButton("icons/torus.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + torusButton.setToolTipText("Create torus"); + torusButton.addActionListener(this); + + if (false) //Globals.ADVANCED) + { + oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + kleinButton.setToolTipText("Create Klein bottle"); + kleinButton.addActionListener(this); + } + + row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + particlesButton.setToolTipText("Create particle system"); + particlesButton.addActionListener(this); + + oe.toolboxPanel.add(row1); + + cGridBag row2 = new cGridBag(); + + row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + groupButton.setToolTipText("Create group"); + groupButton.addActionListener(this); + + row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + compositeButton.setToolTipText("Create composite"); + compositeButton.addActionListener(this); + + row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + switchButton.setToolTipText("Create item switcher"); + switchButton.addActionListener(this); + + row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + loopButton.setToolTipText("Create loop"); + loopButton.addActionListener(this); + + row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + textureButton.setToolTipText("Create texture"); + textureButton.addActionListener(this); + + row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + overlayButton.setToolTipText("Create overlay"); + overlayButton.addActionListener(this); + + row2.add(lightButton = GetButton("icons/light-bulb.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + lightButton.setToolTipText("Create light"); + lightButton.addActionListener(this); + + oe.toolboxPanel.add(row2); + + cGridBag textures = new cGridBag(); + + CreateTexturePanel(textures); + + int tabCount = resourcecontainer.getTabCount(); + + if (tabCount > 0) + resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount)); + + oe.toolboxPanel.add(textures); + + textures.preferredHeight = 100; + + CreateSkyboxPanel(oe.skyboxPanel); + + // EDIT panel + editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + editButton.setToolTipText("Pin selection controls"); editButton.addActionListener(this); - commandsPanel.add(uneditButton = new cButton("-", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - uneditButton.setToolTipText("Unedit selection"); + editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + uneditButton.setToolTipText("Unpin and remove selection controls"); uneditButton.addActionListener(this); - commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints); - allParamsButton.setToolTipText("Edit all params"); + editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints); + allParamsButton.setToolTipText("Show all controls"); allParamsButton.addActionListener(this); - commandsPanel.add(clearPanelButton = new cButton("C", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - clearPanelButton.setToolTipText("Clear edit panel"); + editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + clearPanelButton.setToolTipText("Clear all controls"); clearPanelButton.addActionListener(this); - commandsPanel.add(unselectButton = new cButton("U", !GrafreeD.NIMBUSLAF)); //, oe.aConstraints); - unselectButton.setToolTipText("Unselect"); - unselectButton.addActionListener(this); + //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + //unselectButton.setToolTipText("Unselect"); + //unselectButton.addActionListener(this); - commandsPanel.preferredHeight = 1; + editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + flashSelectionButton.setToolTipText("Highlight selection"); + flashSelectionButton.addActionListener(this); - oe.treePanel.add(commandsPanel); - oe.treePanel.Return(); + editCommandsPanel.preferredHeight = 1; + + SetPinStates(false); +// oe.treePanel.add(commandsPanel); +// oe.treePanel.Return(); // oe.aConstraints.gridx += 1; // oe.aConstraints.weighty = 0; @@ -590,34 +1318,24 @@ cGridBag jSPPanel = new cGridBag(); + jSPPanel.preferredHeight = 20; + JScrollPane jSP; //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints); - jSPPanel.add(jSP = new JScrollPane(oe.jTree = new cTree(null))); //, oe.aConstraints); + jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints); ResetModel(); oe.treePanel.add(jSPPanel); oe.treePanel.Return(); - cGridBag copyOptionsPanel = new cGridBag(); - - copyOptionsPanel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0)); //, oe.aConstraints); - colorCB.setToolTipText("Copy color when dropped"); - colorCB.addItemListener(this); - - copyOptionsPanel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0)); //, oe.aConstraints); - materialCB.setToolTipText("Copy material when dropped"); - materialCB.addItemListener(this); - - copyOptionsPanel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0)); //, oe.aConstraints); - textureCB.setToolTipText("Copy texture when dropped"); - textureCB.addItemListener(this); - - copyOptionsPanel.preferredHeight = 1; - oe.treePanel.add(copyOptionsPanel); + oe.treePanel.add(versionManagerPanel); oe.treePanel.Return(); + versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0); + versionSlider = (cNumberSlider)versionSliderPane.getComponent(1); + versionSliderPane.preferredHeight = 3; -// mainPanel.setDividerLocation(0.5); //1.0); -// mainPanel.setResizeWeight(0.5); +// mainPanel.setDividerLocation(0.1); //1.0); + mainPanel.setResizeWeight(0.4); //jList.addListSelectionListener(this); oe.jTree.addTreeSelectionListener(this); @@ -625,7 +1343,7 @@ //jTree.setEditable(true); oe.jTree.setDragEnabled(true); //jTree.setPreferredSize(new Dimension(10,10)); - jSP.setPreferredSize(new Dimension(100,200)); + //jSP.setPreferredSize(new Dimension(100,200)); oe.jTree.setCellRenderer(new cTreeModel.Renderer()); @@ -637,29 +1355,49 @@ dgr.addDragGestureListener(this); }catch(Exception e) {} */ - radio.layout = sevenButton; + radio.layout = threeButton; // sixButton; oe.toolbarPanel.add(radioPanel); //, oe.aConstraints); } void AddOptions(cGridBag panel) //, GridBagConstraints constraints) { + panel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0)); //, oe.aConstraints); + colorCB.setToolTipText("Copy color when dropped"); + colorCB.addItemListener(this); + + panel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0)); //, oe.aConstraints); + materialCB.setToolTipText("Copy material when dropped"); + materialCB.addItemListener(this); + + panel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0)); //, oe.aConstraints); + textureCB.setToolTipText("Copy texture when dropped"); + textureCB.addItemListener(this); + + panel.Return(); + panel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE)); //, constraints); boxCB.setToolTipText("Display bounding boxes"); boxCB.addItemListener(this); panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE)); //, constraints); - zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel"); + zoomBoxCB.setToolTipText("Display only for wheel"); zoomBoxCB.addItemListener(this); - if (Globals.ADVANCED) + if (true) // Globals.ADVANCED) { - panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints); - supportCB.setToolTipText("Enable rigging"); - supportCB.addItemListener(this); +// panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints); +// supportCB.setToolTipText("Enable rigging"); +// supportCB.addItemListener(this); + + panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints); + freezeCB.setToolTipText("Fast moving camera"); + freezeCB.addItemListener(this); // panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints); // localCB.addItemListener(this); + panel.Return(); + panel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD)); //, constraints); crowdCB.setToolTipText("Used for crowds"); crowdCB.addItemListener(this); @@ -668,14 +1406,19 @@ smoothCB.setToolTipText("Snapping delay"); smoothCB.addItemListener(this); - panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE)); //, constraints); - slowCB.setToolTipText("Smooth interpolation"); - slowCB.addItemListener(this); +// panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE)); //, constraints); +// slowCB.setToolTipText("Smooth interpolation"); +// slowCB.addItemListener(this); + panel.add(minshaderCB = new cCheckBox("Min shader", Globals.MINSHADER)); //, constraints); + minshaderCB.setToolTipText("Minimal fast shader"); + minshaderCB.addItemListener(this); // constraints.gridy += 1; // panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints); // speakerMocapCB.addItemListener(this); + panel.Return(); + if (false) { // handled in scripts @@ -690,67 +1433,126 @@ //constraints.gridy += 1; panel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS)); //, constraints); smoothfocusCB.addItemListener(this); + panel.Return(); } //constraints.gridx += 1; //panel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), constraints); // debugCB.addItemListener(this); + panel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints); + trackCB.setToolTipText("Enable tracking target"); + trackCB.addItemListener(this); + panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints); + oeilCB.setToolTipText("Move camera when tracking"); oeilCB.addItemListener(this); + panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints); + shadowCB.setToolTipText("When live compute shadows"); + shadowCB.addItemListener(this); + + panel.Return(); + panel.add(toggleTextureCB = new cCheckBox("Textures", CameraPane.textureon)); //, constraints); + toggleTextureCB.setToolTipText("Load textures"); + toggleTextureCB.addItemListener(this); + + panel.add(toggleSwitchCB = new cCheckBox("Switch", CameraPane.SWITCH)); //, constraints); + toggleSwitchCB.setToolTipText("Choose a single item"); + toggleSwitchCB.addItemListener(this); + + panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints); + autokeepCB.setToolTipText("On structure change"); + autokeepCB.addItemListener(this); + + panel.Return(); + if (Globals.ADVANCED) + { panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints); lookAtCB.setToolTipText("Look-at target"); lookAtCB.addItemListener(this); + } } cGridBag fill = new cGridBag(); - fill.preferredHeight = 200; + cGridBag fill2 = new cGridBag(); + fill2.preferredHeight = 200; + cGridBag fill3 = new cGridBag(); + fill3.preferredHeight = 200; panel.add(fill); + panel.add(fill2); + panel.add(fill3); } void EditObject(Object3D obj) { + //assert(obj instanceof Composite); + +// if (obj.versionlist == null) +// { +// obj.versionlist = new Object3D[100]; +// obj.versionindex = -1; +// } + cRadio radioButton = new cRadio(obj.name); + + // June 2019. Patch to avoid bug with transparency. + radioButton.hadMaterial = obj.material != null; + if (!radioButton.hadMaterial) + { + obj.material = new cMaterial(); + } + radioButton.SetObject(obj); - radioButton.layout = sevenButton; + radioButton.layout = threeButton; // sixButton; radioButton.SetCamera(cameraView.renderCamera, false); radioButton.addActionListener(this); radioPanel.add(radioButton); buttonGroup.add(radioButton); radioButton.doClick(); } + void SetupViews(ObjEditor oe) { + theFrame = this; + oe.SetupViews(); + if (Globals.DEBUG) System.out.println("SetupViews"); DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ?? /*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this); } - JCheckBox liveCB; - JCheckBox supportCB; - JCheckBox localCB; - JCheckBox crowdCB; - JCheckBox smoothCB; - JCheckBox fastCB; - JCheckBox slowCB; - JCheckBox boxCB; - JCheckBox zoomBoxCB; - JCheckBox trackCB; - JCheckBox smoothfocusCB; + cToggleButton liveCB; + cCheckBox supportCB; + cCheckBox localCB; + cCheckBox crowdCB; + cCheckBox smoothCB; + cCheckBox minshaderCB; + + cToggleButton fastCB; + cCheckBox slowCB; + cCheckBox boxCB; + cCheckBox zoomBoxCB; + cCheckBox freezeCB; + //cToggleButton trackCB; + cCheckBox trackCB; + cCheckBox smoothfocusCB; // JCheckBox speakerMocapCB; - JCheckBox speakerCameraCB; - JCheckBox speakerFocusCB; - JCheckBox debugCB; - JCheckBox oeilCB; - JCheckBox lookAtCB; + cCheckBox speakerCameraCB; + cCheckBox speakerFocusCB; + cCheckBox debugCB; + + cCheckBox oeilCB; + cCheckBox shadowCB; + cCheckBox autokeepCB; + cCheckBox lookAtCB; // static int COLOR = 1; // static int MATERIAL = 2; @@ -758,9 +1560,9 @@ int dropAttributes = Object3D.COLOR | Object3D.MATERIAL; - JCheckBox colorCB; - JCheckBox materialCB; - JCheckBox textureCB; + cCheckBox colorCB; + cCheckBox materialCB; + cCheckBox textureCB; public void itemStateChanged(ItemEvent e) { @@ -788,6 +1590,7 @@ } else if(e.getSource() == liveCB) { cameraView.ToggleLive(); + refreshContents(false); } else if(e.getSource() == supportCB) { @@ -803,6 +1606,12 @@ { cameraView.ToggleInertia(); cameraView.repaint(); + } + else if(e.getSource() == minshaderCB) + { + Globals.MINSHADER ^= true; + cameraView.programInitialized = false; + cameraView.repaint(); } else if(e.getSource() == localCB) { @@ -852,6 +1661,18 @@ { cameraView.ToggleOeil(); } + else if(e.getSource() == shadowCB) + { + Globals.COMPUTESHADOWWHENLIVE ^= true; + } + else if(e.getSource() == freezeCB) + { + Globals.FREEZEONMOVE ^= true; + } + else if(e.getSource() == autokeepCB) + { + Globals.REPLACEONMAKE ^= true; + } else if(e.getSource() == lookAtCB) { cameraView.ToggleLookAt(); @@ -868,7 +1689,8 @@ /**/ //DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultMoveNoDrop, new StringSelection("Allo"), this); - TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent()); + //TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent()); + TreePath path = objEditor.jTree.getSelectionPath(); if ((path == null) || (path.getPathCount() <= 1)) { // We can't move the root node or an empty selection return; @@ -931,8 +1753,6 @@ } } - String string = (String) object; - System.out.println("Transfer = " + object + "; drop : " + target); // if( object instanceof java.io.File[]) // { @@ -940,6 +1760,8 @@ // objEditor.DropFile((java.io.File[]) object, true); // return; // } + + String string = object.toString(); // File path for Mac and Windows if (string.charAt(0) == '/' || string.charAt(1) == ':') @@ -985,23 +1807,33 @@ assert target == objEditor.jTree; TreePath destinationPath = objEditor.jTree.getPathForLocation(objEditor.location.x, objEditor.location.y); + Object3D destinationLeaf; try { - Object3D dummy = (Composite) destinationPath.getLastPathComponent(); + destinationLeaf = (Composite) destinationPath.getLastPathComponent(); } catch (Exception e) { System.out.println("destinationPath : " + destinationPath); return; } - if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK) + for (int i=group.selection.size(); --i>=0;) { + Object3D child = (Object3D)group.selection.elementAt(i); + + // Cannot move into itself + if (child == destinationLeaf) + return; + } + +// june 2019 if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK) +// { loadClipboard(true); objEditor.jTree.setSelectionPath(destinationPath); pasteInto(false, false); - } else { - loadClipboard(false); - objEditor.jTree.setSelectionPath(destinationPath); - pasteInto(false, false); // true); // ??? - } +// } else { +// loadClipboard(false); +// objEditor.jTree.setSelectionPath(destinationPath); +// pasteInto(false, false); // true); // ??? +// } } public void dropActionChanged(DropTargetDragEvent dtde) // Called if the user has modified the current drop gesture @@ -1057,7 +1889,12 @@ TreePath path; public TransferableTreePath(TreePath tp) { - path = tp; + Object[] objs = new Object[tp.getPathCount()]; + for (int i=0; i<objs.length; i++) + { + objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID(); + } + path = new TreePath(objs); } public synchronized DataFlavor[] getTransferDataFlavors() { @@ -1106,22 +1943,30 @@ { //heightFieldItem = menu.add(new MenuItem("Height Field")); //heightFieldItem.addActionListener(this); - gridItem = menu.add(new MenuItem("Grid")); - gridItem.addActionListener(this); - rectoidItem = menu.add(new MenuItem("Box")); - rectoidItem.addActionListener(this); - ellipsoidItem = menu.add(new MenuItem("Sphere")); - ellipsoidItem.addActionListener(this); - coneItem = menu.add(new MenuItem("Cone")); - coneItem.addActionListener(this); - torusItem = menu.add(new MenuItem("Torus")); - torusItem.addActionListener(this); - superItem = menu.add(new MenuItem("Superellipsoid")); - superItem.addActionListener(this); +// gridItem = menu.add(new MenuItem("Grid")); +// gridItem.addActionListener(this); +// rectoidItem = menu.add(new MenuItem("Box")); +// rectoidItem.addActionListener(this); +// ellipsoidItem = menu.add(new MenuItem("Sphere")); +// ellipsoidItem.addActionListener(this); +// coneItem = menu.add(new MenuItem("Cone")); +// coneItem.addActionListener(this); +// torusItem = menu.add(new MenuItem("Torus")); +// torusItem.addActionListener(this); +// superItem = menu.add(new MenuItem("Superellipsoid")); +// superItem.addActionListener(this); + + cameraItem = menu.add(new MenuItem("Camera")); + cameraItem.addActionListener(this); + + if (!Globals.ADVANCED) + { kleinItem = menu.add(new MenuItem("Klein Bottle")); kleinItem.addActionListener(this); - particleItem = menu.add(new MenuItem("Particle system")); - particleItem.addActionListener(this); + } + +// particleItem = menu.add(new MenuItem("Particle system")); +// particleItem.addActionListener(this); if (Globals.ADVANCED) { ragdollItem = menu.add(new MenuItem("Rag Walk")); @@ -1147,15 +1992,15 @@ } bezierItem = menu.add(new MenuItem("Bezier Patch")); bezierItem.addActionListener(this); - overlayItem = menu.add(new MenuItem("Overlay")); - overlayItem.addActionListener(this); - lightItem = menu.add(new MenuItem("Light")); - lightItem.addActionListener(this); +// overlayItem = menu.add(new MenuItem("Overlay")); +// overlayItem.addActionListener(this); +// lightItem = menu.add(new MenuItem("Light")); +// lightItem.addActionListener(this); menu.add("-"); //superLoopItem = menu.add(new MenuItem("Super Loop")); //superLoopItem.addActionListener(this); - loopItem = menu.add(new MenuItem("Loop")); - loopItem.addActionListener(this); +// loopItem = menu.add(new MenuItem("Loop")); +// loopItem.addActionListener(this); doubleItem = menu.add(new MenuItem("Fork")); doubleItem.addActionListener(this); if (Globals.ADVANCED) @@ -1171,6 +2016,9 @@ animationItem.addItemListener(this); animationItem.setState(Globals.ANIMATION); + menu.add(archiveItem = new MenuItem("Archive3D...")); + archiveItem.addActionListener(this); + menu.add("-"); parseverticesItem = menu.add(new MenuItem("Multiplicity")); parseverticesItem.addActionListener(this); @@ -1183,6 +2031,8 @@ reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)")); reduce34MorphItem.addActionListener(this); menu.add("-"); + menu.add(memoryItem = new MenuItem("Memory Usage")); + memoryItem.addActionListener(this); menu.add(computeAOItem = new MenuItem("Compute AO")); computeAOItem.addActionListener(this); @@ -1191,11 +2041,9 @@ mirrorItem = menu.add(new MenuItem("Mirror Poses")); mirrorItem.addActionListener(this); menu.add("-"); - menu.add(memoryItem = new MenuItem("Memory Usage")); - memoryItem.addActionListener(this); menu.add(analyzeItem = new MenuItem("Analyze")); analyzeItem.addActionListener(this); - menu.add(dumpItem = new MenuItem("Dump")); + menu.add(dumpItem = new MenuItem("Print")); dumpItem.addActionListener(this); // menu.add(pathItem = new MenuItem("From-to path")); // pathItem.addActionListener(this); @@ -1278,24 +2126,24 @@ switch(axis) { case 0 : - vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z; - vert2.x = minima.x; vert2.y = maxima.y; vert2.z = minima.z; - vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z; - vert4.x = minima.x; vert4.y = maxima.y; vert4.z = maxima.z; + vert1.x = minima.x + 0.001f; vert1.y = minima.y; vert1.z = minima.z; + vert2.x = minima.x + 0.001f; vert2.y = maxima.y; vert2.z = minima.z; + vert3.x = minima.x + 0.001f; vert3.y = minima.y; vert3.z = maxima.z; + vert4.x = minima.x + 0.001f; vert4.y = maxima.y; vert4.z = maxima.z; norm = cVector.X; break; case 1 : - vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z; - vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z; - vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z; - vert4.x = maxima.x; vert4.y = minima.y; vert4.z = maxima.z; + vert1.x = minima.x; vert1.y = minima.y + 0.001f; vert1.z = minima.z; + vert2.x = maxima.x; vert2.y = minima.y + 0.001f; vert2.z = minima.z; + vert3.x = minima.x; vert3.y = minima.y + 0.001f; vert3.z = maxima.z; + vert4.x = maxima.x; vert4.y = minima.y + 0.001f; vert4.z = maxima.z; norm = cVector.Y; break; case 2 : - vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z; - vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z; - vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z; - vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z; + vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z + 0.001f; + vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z + 0.001f; + vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z + 0.001f; + vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z + 0.001f; norm = cVector.Z; break; } @@ -1336,9 +2184,38 @@ shadow.material = new cMaterial(obj.material); shadow.material.diffuse = 0.0001f; shadow.material.specular = 0.0001f; + shadow.material.opacity = 0.75f; + + AllocProjectedVertices(shadow); + + shadow.projectedVertices[1].x = 300; makeSomething(shadow); } + + private void ClearUnpinned() + { + //for (Object3D obj : listUI) + for (int i=listUI.size(); --i>=0;) + { + Object3D obj = listUI.elementAt(i); + if (!obj.pinned) + { + obj.CloseUI(); + listUI.remove(i); + } + } + } + + private void EditElement(Object3D elem, boolean newWindow) + { + // if (!(elem instanceof Composite)) + // newWindow = false; + listUI.add(elem); + elem.openEditWindow(this, newWindow); //, false); + System.out.println("edit : " + elem); + elem.editWindow.refreshContents(true); // ? new + } /** * applyExample @@ -1542,9 +2419,9 @@ void Overwrite(int mask) { - if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) + if (/*group.selection.size() == 1 &&*/ Grafreed.clipboard.size() == 1) { - Object3D content = GrafreeD.clipboard.get(0); + Object3D content = Grafreed.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -1583,7 +2460,7 @@ { ScreenFit(); } else - if (source == switchItem) + if (source == switchViewItem) { cVector v1 = new cVector(); cVector v2 = new cVector(); @@ -1592,11 +2469,11 @@ objEditor.cameraView.renderCamera.setAim(v2, v1); objEditor.cameraView.repaint(); } else - if (source == rectoidItem) + if (source == rectoidItem || source == boxButton) { makeSomething(new Box()); } else - if (source == particleItem) + if (source == particleItem || source == particlesButton) { ParticleNode particleGeom = new ParticleNode("Particles", 1000); //, particleType); ParticleController particleController = new ParticleController(particleGeom); @@ -1675,27 +2552,27 @@ makeSomething(obj); } else - if (source == gridItem) + if (source == gridItem || source == gridButton) { makeSomething(new Grid()); } else - if (source == ellipsoidItem) + if (source == ellipsoidItem || source == sphereButton) { makeSomething(new Sphere()); } else - if (source == coneItem) + if (source == coneItem || source == coneButton) { makeSomething(new Cone()); } else - if (source == torusItem) + if (source == torusItem || source == torusButton) { makeSomething(new Torus()); } else - if (source == superItem) + if (source == superItem || source == superButton) { makeSomething(new Superellipsoid()); } else - if (source == kleinItem) + if (source == kleinItem || source == kleinButton) { makeSomething(new Klein()); } else @@ -1715,7 +2592,7 @@ { makeSomething(new BezierSurface()); } else - if (source == overlayItem) + if (source == overlayItem || source == overlayButton) { /* Object3D obj = new BezierSurface(5,8); @@ -1763,10 +2640,27 @@ s.setup(); makeSomething(s); } else - if (source == lightItem) + if (source == lightItem || source == lightButton) { makeSomething(new Light()); } else +// if (source == skybox1Button || +// source == skybox2Button || +// source == skybox3Button || +// source == skybox4Button || +// source == skybox5Button || +// source == skybox6Button || +// source == skybox7Button || +// source == skybox11Button || +// source == skybox12Button || +// source == skybox13Button || +// source == skybox14Button || +// source == skybox15Button || +// source == skybox16Button || +// source == skybox17Button) +// { +// ChangeSkybox(source); +// } else if (source == csgItem) { group(new CSG()); @@ -1813,30 +2707,38 @@ group(g); } else - if (source == loopItem) + if (source == loopItem || source == loopButton) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf(); - csg.count = 5; group(csg); - Composite child = new cGroup(); + csg.count = 5; + Composite child = new cGroup("Branch"); csg.addChild(child); child.addChild(csg); + } } else if (source == doubleItem) { - Composite csg = new GroupLeaf(); - csg.count = 5; + if (!group.selection.isEmpty()) + { + Composite csg = new GroupLeaf("Fork"); group(csg); - Composite child = new cGroup(); + csg.count = 5; + Composite child = new cGroup("Branch A"); csg.addChild(child); child.addChild(csg); - child = new cGroup(); + child = new cGroup("Branch B"); csg.addChild(child); child.addChild(csg); + } } else if (source == tripleItem) { - Composite csg = new GroupLeaf(); + if (!group.selection.isEmpty()) + { + Composite csg = new GroupLeaf("Trident"); csg.count = 4; group(csg); Composite child = new cGroup(); @@ -1848,36 +2750,12 @@ child = new cGroup(); csg.addChild(child); child.addChild(csg); - } else - - if (source == importGFDItem) - { - ImportGFD(); - } else - if (source == importVRMLX3DItem) - { - ImportVRMLX3D(); - } else - if (source == import3DSItem) - { - objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS"); - } else - if (source == importOBJItem) - { - //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ"); - FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD); - browser.setVisible(true); - String filename = browser.getFile(); - if (filename != null && filename.length() > 0) - { - String fullname = browser.getDirectory() + filename; - makeSomething(ReadOBJ(fullname), true); - } + } } else if (source == computeAOItem) { Globals.drawMode = CameraPane.OCCLUSION; - Globals.theRenderer.repaint(); + cameraView.repaint(); } else if (source == recompileItem) { @@ -1892,7 +2770,7 @@ if (source == invariantsItem) { System.out.println("Invariants:"); - GrafreeD.grafreeD.universe.invariants(); + Grafreed.grafreed.universe.invariants(); } else if (source == memoryItem) { @@ -1911,6 +2789,65 @@ { DumpObject(); } else + if (source == minButton) + { + Minimize(); + } else + if (source == maxButton) + { + Maximize(); + } else + if (source == fullScreenButton) + { + ToggleFullScreen(); + } else + if (source == collapseButton) + { + this.expandedLayout = radio.layout; + CollapseToolbar(); + } else +// if (source == maximize3DButton) +// { +// this.expandedLayout = radio.layout; +// radio.layout = twoButton; +// CollapseToolbar(); +// Show3DView(); +// } else + if (source == previousVersionButton) + { + // Go to previous version + //if (!Undo()) + //java.awt.Toolkit.getDefaultToolkit().beep(); + PreviousVersion(); + } else + if (source == restoreButton) + { + // Restore current version + Restore(); + //restoreButton.setEnabled(false); + } else + if (source == replaceButton) + { + // Overwrite current version + Replace(); + //replaceButton.setEnabled(false); + } else + if (source == nextVersionButton) + { + // Go to next version + NextVersion(); + } else + if (source == saveVersionButton) + { + // Save a new version + if (!Save(true)) + java.awt.Toolkit.getDefaultToolkit().beep(); + } else + if (source == deleteVersionButton) + { + // Delete a new version + DeleteVersion(); + } else if (source == oneStepButton) { Globals.ONESTEP = true; @@ -1918,17 +2855,14 @@ } else if (source == screenfitButton) { - //Reload(lastConverter, lastFilename, true); ScreenFit(); } else if (source == screenfitpointButton) { - //Reload(lastConverter, lastFilename, true); ScreenFitPoint(); } else if (source == snapobjectButton) { - //Reload(lastConverter, lastFilename, true); SnapObject(); } else // if (event.getSource() == recompileButton) @@ -1965,12 +2899,20 @@ { loadClipboard(true); } else + if (source == undoItem) + { + PreviousVersion(); + } else + if (source == redoItem) + { + NextVersion(); + } else if (source == duplicateItem) { - Object3D keep = GrafreeD.clipboard; + Object3D keep = Grafreed.clipboard; loadClipboard(false); paste(false); - GrafreeD.clipboard = keep; + Grafreed.clipboard = keep; } else if (source == cloneItem) { @@ -2190,9 +3132,9 @@ // group.selection.get(0).setMasterThis(content); // should be identity // refreshContents(); // } - if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) + if (/*group.selection.size() == 1 &&*/ Grafreed.clipboard.size() == 1) { - Object3D content = GrafreeD.clipboard.get(0); + Object3D content = Grafreed.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -2242,9 +3184,9 @@ } else if (source == setMasterItem) { - if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1) + if (group.selection.size() == 1 && Grafreed.clipboard.size() == 1) { - Object3D content = GrafreeD.clipboard.get(0); + Object3D content = Grafreed.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -2257,9 +3199,9 @@ { if (group.selection.size() == 1) { - if (GrafreeD.clipboard.size() == 1) + if (Grafreed.clipboard.size() == 1) { - Object3D content = GrafreeD.clipboard.get(0); + Object3D content = Grafreed.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -2276,7 +3218,7 @@ { RevertMeshes(); } else - if (source == resetMeshItem) + if (source == resetAllItem) { ResetAll(); } else @@ -2284,7 +3226,7 @@ { StepAll(); } else - if (source == clearItem) // || event.getSource() == clearButton) + if (source == deleteItem) // || event.getSource() == clearButton) { //int indices[] = jList.getSelectedIndices(); //for (int i = indices.length - 1; i >= 0; i--) @@ -2296,9 +3238,9 @@ { ClearSelection(true); } else - if (source == grabItem) + if (source == grabItem || source == groupButton) { - group(new cGroup(), true); + group(new cGroup(), false); // true); } else if (source == hideItem) { @@ -2316,11 +3258,11 @@ { makeSomething(new Camera()); } else - if (source == compositeItem) + if (source == compositeItem || source == compositeButton) { group(new Composite()); } else - if (source == randomItem) + if (source == switchItem || source == switchButton) { RandomNode random = new RandomNode(); group(random); @@ -2422,7 +3364,7 @@ { group(new cLinker()); } else - if (source == textureItem) + if (source == textureItem || source == textureButton) { group(new TextureNode()); } else @@ -2442,17 +3384,42 @@ { CastShadow(2); } else - if (source == ungroupItem) + if (source == ungroupItem || source == ungroupButton) { - //ungroup(); + boolean canUngroup = true; + for (int i=0; i<group.selection.size(); i++) { - Ungroup(group.selection.get(i)); + Object3D selectedItem = group.selection.get(i); + + if (selectedItem.Size() == 0) + { + // Cannot ungroup leaves + canUngroup = false; + break; + } + + if (selectedItem == group) + { + // Cannot ungroup root + canUngroup = false; + break; + } } - ClearSelection(false); - - refreshContents(); + if (canUngroup) + { + for (int i=0; i<group.selection.size(); i++) + { + Object3D selectedItem = group.selection.get(i); + + Ungroup(selectedItem); + } + + ClearSelection(false); + + refreshContents(); + } } else if (source == genUVItem) { @@ -2464,7 +3431,7 @@ } else if (source == genNormalsMESHItem) { - GenNormals(true); // TODO + GenNormalsMESH(); } else if (source == genNormalsORGANItem) { @@ -2498,6 +3465,10 @@ { ClearMaterials(); } else + if (source == clearVersionsItem) + { + ClearVersions(); + } else if (source == liveleavesItem) { LiveLeaves(true); @@ -2529,6 +3500,22 @@ if (source == unmarkleavesItem) { MarkLeaves(false); + } else + if (source == rewindleavesItem) + { + RewindLeaves(true); + } else + if (source == unrewindleavesItem) + { + RewindLeaves(false); + } else + if (source == randomleavesItem) + { + RandomLeaves(true); + } else + if (source == unrandomleavesItem) + { + RandomLeaves(false); } else if (source == flipVItem) { @@ -2614,9 +3601,25 @@ { SmoothMesh(); } else - if (source == transformgeometryItem) + if (source == transformGeometryItem) { TransformGeometry(); + } else + if (source == transformChildrenItem) + { + TransformChildren(); + } else + if (source == textureRatioRItem) + { + TextureRatio(0); + } else + if (source == textureRatioGItem) + { + TextureRatio(1); + } else + if (source == textureRatioBItem) + { + TextureRatio(2); } else if (source == resetTransformItem) { @@ -2624,7 +3627,11 @@ } else if (source == resetCentroidItem) { - ResetCentroid(); + ResetCentroid(true); + } else + if (source == resetCentroidXZItem) + { + ResetCentroid(false); } else if (source == resetParentItem) { @@ -2729,7 +3736,7 @@ for (Enumeration e = group.selection.elements(); e.hasMoreElements();) { obj = (Object3D)e.nextElement(); - obj.SetBumpTexture(null); + obj.ResetBumpTexture(); } refreshContents(); @@ -2745,6 +3752,31 @@ refreshContents(); } else + if (source == embedTexturesItem) + { + Object3D obj; + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + obj = (Object3D)e.nextElement(); + obj.EmbedTextures(true); + } + + refreshContents(); + } else + if (source == deEmbedTexturesItem) + { + Object3D obj; + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + obj = (Object3D)e.nextElement(); + obj.EmbedTextures(false); + } + + CameraPane.texturepigment.clear(); + CameraPane.texturebump.clear(); + + refreshContents(); + } else if (source == flashSelectionButton) { CameraPane.flash = true; @@ -2756,42 +3788,36 @@ if (source == twoButton) { radio.layout = twoButton; - // bug - //gridPanel.setDividerLocation(1.0); - //bigPanel.setDividerLocation(0.0); -// bigThree.remove(scenePanel); -// bigThree.remove(centralPanel); -// bigThree.remove(XYZPanel); -// aWindowConstraints.gridx = 0; -// aWindowConstraints.gridy = 0; -// aWindowConstraints.gridwidth = 1; -// // aConstraints.gridheight = 3; -// aWindowConstraints.fill = GridBagConstraints.VERTICAL; -// aWindowConstraints.weightx = 0; -// aWindowConstraints.weighty = 1; -// //bigThree.add(jtp, aWindowConstraints); -// aWindowConstraints.weightx = 1; -// aWindowConstraints.gridwidth = 3; -// // aConstraints.gridheight = 3; -// aWindowConstraints.gridx = 1; -// aWindowConstraints.fill = GridBagConstraints.BOTH; -// bigThree.add(centralPanel, aWindowConstraints); -// aWindowConstraints.weightx = 0; -// aWindowConstraints.gridx = 4; -// aWindowConstraints.gridwidth = 1; -// // aConstraints.gridheight = 3; -// aWindowConstraints.fill = GridBagConstraints.VERTICAL; -// //bigThree.add(XYZPanel, aWindowConstraints); -// scenePanel.setVisible(false); -// centralPanel.setVisible(true); -// XYZPanel.setVisible(false); - bigThree.ClearUI(); - bigThree.add(centralPanel); - bigThree.FlushUI(); + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; + + Show3DView(); + + cameraView.requestFocusInWindow(); + +// refreshContents(true); +// +// try +// { +// java.awt.Robot bot = new java.awt.Robot(); +// int mask = InputEvent.BUTTON1_MASK; +// bot.mouseMove(100, 100); +// bot.mousePress(mask); +// bot.mouseRelease(mask); +// } +// catch (Exception e) +// { +// +// } + } else if (source == threeButton) { radio.layout = threeButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); @@ -2821,13 +3847,18 @@ // centralPanel.setVisible(true); // XYZPanel.setVisible(true); bigThree.ClearUI(); + bigThree.add(scenePanel); bigThree.add(centralPanel); - bigThree.add(XYZPanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == fourButton) { radio.layout = fourButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); @@ -2859,10 +3890,15 @@ bigThree.ClearUI(); bigThree.add(scenePanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == sixButton) { radio.layout = sixButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); @@ -2892,13 +3928,18 @@ // centralPanel.setVisible(true); // XYZPanel.setVisible(false); bigThree.ClearUI(); - bigThree.add(scenePanel); bigThree.add(centralPanel); + bigThree.add(scenePanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == sevenButton) { radio.layout = sevenButton; + + if (CameraPane.FULLSCREEN) + fullscreenLayout = radio.layout; // bigThree.remove(scenePanel); // bigThree.remove(centralPanel); @@ -2932,9 +3973,12 @@ bigThree.add(centralPanel); bigThree.add(XYZPanel); bigThree.FlushUI(); + + cameraView.requestFocusInWindow(); } else if (source == rootButton) { + Replace(); Object3D obj; for (Enumeration e = group.selection.elements(); e.hasMoreElements();) { @@ -2943,31 +3987,50 @@ EditObject(obj); } + cameraView.requestFocusInWindow(); refreshContents(true); } else if (source == closeButton) { //System.out.println("CLOSE: " + buttonGroup.getSelection()); + if (copy.versionlist != null) + Replace(); + cRadio ab; for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) { ab = (cRadio)e.nextElement(); - if(ab.getModel().isSelected() && ab.GetObject() != client) + if (ab.getModel().isSelected() && ab.GetObject() != client) { + // Patch to avoid bug with transparency. + if (!ab.hadMaterial) + { + ab.object.material = null; + } + buttonGroup.remove(ab); radioPanel.remove(ab); - ab.GetObject().editWindow = null; + //ab.GetObject().editWindow = null; + ab.GetObject().manipWindow = null; // ab.GetObject().objectUI = null; // ????????? ((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick(); break; } } + + cameraView.requestFocusInWindow(); refreshContents(true); } else if (source == editItem || source == editButton) { + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + Object3D child = (Object3D)e.nextElement(); + child.pinned = true; + } + EditSelection(false); } else if (source == uneditButton) @@ -2976,11 +4039,12 @@ { Object3D child = (Object3D)e.nextElement(); if(child.editWindow != null) - objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); + child.pinned = false; child.CloseUI(); listUI.remove(child); +// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); - child.editWindow = null; // ??????????? + //child.editWindow = null; // ??????????? } objEditor.ctrlPanel.FlushUI(); //objEditor.jTree.clearSelection(); @@ -2993,16 +4057,18 @@ //copy.ClearUI(); for (Object3D obj : listUI) { + obj.pinned = false; obj.CloseUI(); } listUI.clear(); + SetPinStates(group.selection.size() > 0); refreshContents(true); } else if (source == allParamsButton) { assert(copy == group); - objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); + //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); for (Object3D obj : listUI) { @@ -3028,6 +4094,9 @@ } else if(source instanceof cRadio) { + if (copy.versionlist != null) + Replace(); + group.parent = keepparent; group.attributes = 0; //group.editWindow = null; @@ -3051,6 +4120,7 @@ } copy = group; + //Globals.theRenderer.object = group; if(!useclient) { @@ -3066,20 +4136,75 @@ frontView.object = group; sideView.object = group; } - group.editWindow = this; + +// fix "+" issue + //group.editWindow = this; + group.manipWindow = this; + /* currentLayout = radio.layout; if (currentLayout == null) currentLayout = sevenButton; */ radio.layout.doClick(); + + //assert(copy instanceof Composite); + + if (copy.versionlist == null) + { + copy.versionindex = -1; + + // Cannot work with loops + // To fix this issue, we first mark all nodes above the root, + // and check if any of these nodes are reachable below the root. + Grafreed.grafreed.universe.TagObjects(copy, true); + + if (copy instanceof Composite && !copy.HasTags()) + { + if (copy.versionlist == null) + copy.versionlist = new Object3D[100]; + + //Save(true); + } + else + copy.versionindex = -2; + + Grafreed.grafreed.universe.TagObjects(copy, false); + } + + SetVersionStates(); + + ClearUnpinned(); + + //Grafreed.Assert(group != null); + //Grafreed.Assert(group.selection != null); + SetPinStates(group.selection == null || group.selection.size() > 0); + if (group.selection == null || group.selection.size() == 1) + EditSelection(false); keepparent = group.parent; // PARENT = NULL or not??? //group.parent = null; // ROOT //group.attributes = -1; ResetModel(); + + cameraView.requestFocusInWindow(); refreshContents(true); - } + } else if (event.getSource() == editCameraItem) + { + cameraView.ProtectCamera(); + cameraView.requestFocusInWindow(); + cameraView.repaint(); + return; + } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton) + { + cameraView.RevertCamera(); + cameraView.requestFocusInWindow(); + cameraView.repaint(); + return; + // } else if (event.getSource() == textureButton) + // { + // return; // true; + } else { //return super.action(event, arg); @@ -3088,7 +4213,6 @@ } boolean useclient = false; - cRadio radio; void ToggleRoot() { @@ -3140,6 +4264,40 @@ refreshContents(); } + void TransformChildren() + { + Object3D obj; + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + obj = (Object3D)e.nextElement(); + obj.KeepTextureMatrices(); + obj.TransformChildren(); + obj.RestoreTextureMatrices(); + +// if (obj.parent == null) +// { +// System.out.println("NULL PARENT!"); +// new Exception().printStackTrace(); +// } +// else +// TouchTransform(obj); +// //obj.parent.Touch(); + } + + refreshContents(); + } + + void TextureRatio(int axis) + { + Object3D obj; + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + obj = (Object3D)e.nextElement(); + obj.TextureRatio(axis); + } + + refreshContents(); + } void ResetTransform() { @@ -3156,42 +4314,8 @@ if (obj.toParent == null) continue; - if (mask == -1) - { - if (obj instanceof Camera) // jan 2014 - { - LA.matIdentity(obj.toParent); - LA.matIdentity(obj.fromParent); - } - else - { - obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent); - obj.fromParent = null; // LA.matIdentity(obj.fromParent); - } - TouchTransform(obj); - continue; - } - if ((mask&2) != 0) // Scale - { - obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1; - obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0; - obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0; - obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1; - obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0; - obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0; - } - if ((mask&4) != 0) // Rotation - { - // ? - } - if ((mask&1) != 0) // Translation - { - if (obj.toParent != null) - { - obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0; - obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0; - } - } + obj.ResetTransform(mask); + if (obj.parent == null) { System.out.println("NULL PARENT!"); @@ -3252,7 +4376,7 @@ refreshContents(); } - void ResetCentroid() + void ResetCentroid(boolean full) { Object3D obj; for (Enumeration e = group.selection.elements(); e.hasMoreElements();) @@ -3267,12 +4391,16 @@ LA.matIdentity(Object3D.mat); obj.getBounds(minima, maxima, false); Object3D.mat[3][0] = -(minima.x + maxima.x)/2; - Object3D.mat[3][1] = -(minima.y + maxima.y)/2; + if (full) + Object3D.mat[3][1] = -(minima.y + maxima.y)/2; Object3D.mat[3][2] = -(minima.z + maxima.z)/2; obj.TransformMesh(Object3D.mat); + Object3D.mat[3][0] = (minima.x + maxima.x)/2; - Object3D.mat[3][1] = (minima.y + maxima.y)/2; + if (full) + Object3D.mat[3][1] = (minima.y + maxima.y)/2; Object3D.mat[3][2] = (minima.z + maxima.z)/2; + LA.matConcat(Object3D.mat, obj.toParent, obj.toParent); //Object3D.mat[3][0] = -Object3D.mat[3][0]; //Object3D.mat[3][1] = -Object3D.mat[3][1]; @@ -3301,7 +4429,8 @@ int size = obj.MemorySize(); - System.err.println((size/1024) + " KB is the size of " + obj); + //System.err.println((size/1024) + " KB is the size of " + obj); + System.err.println("the size of " + obj + " is " + size + " (" + (size/1024) + "KB)"); } } catch (Exception e) @@ -3338,9 +4467,9 @@ obj = (Object3D)e.nextElement(); System.out.println("Object is: " + obj); - GrafreeD.AnalyzeObject(obj); + Grafreed.AnalyzeObject(obj); System.out.println("Boundary rep: " + obj.bRep); - GrafreeD.AnalyzeObject(obj.bRep); + Grafreed.AnalyzeObject(obj.bRep); // System.err.println((size/1024) + " KB is the size of " + obj); } @@ -3382,6 +4511,13 @@ void GenNormals(boolean crease) { group.GenNormalsS(crease); + + refreshContents(); + } + + void GenNormalsMESH() + { + group.GenNormalsMeshS(); refreshContents(); } @@ -3554,8 +4690,8 @@ void ParseVertices() { - boolean epsequal = GrafreeD.epsequal; - GrafreeD.epsequal = true; + boolean epsequal = Grafreed.epsequal; + Grafreed.epsequal = true; for (int i=0; i<group.selection.size(); i++) { @@ -3580,7 +4716,7 @@ LA.matTranslate(g.toParent, temp.x, temp.y, temp.z); LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z); - g.add(GrafreeD.clipboard); + g.add(Grafreed.clipboard); buffer.add(g); } @@ -3595,7 +4731,7 @@ makeSomething(buffer, i==group.selection.size()-1); } - GrafreeD.epsequal = epsequal; + Grafreed.epsequal = epsequal; refreshContents(); } @@ -3613,7 +4749,16 @@ String pigment = Object3D.GetPigment(tex); //String bump = Object3D.GetBump(tex); - com.sun.opengl.util.texture.TextureData texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres); + com.sun.opengl.util.texture.TextureData texturedata = null; + + try + { + texturedata = Globals.theRenderer.GetTextureData(tex, false, node.texres); + } + catch (Exception e) + { + System.err.println("FAIL: " + node); + } double s = v.s; @@ -3678,6 +4823,12 @@ for (int i=0; i<group.selection.size(); i++) { Object3D obj = group.selection.get(i); + + if (obj.toParent == null) + { + obj.toParent = LA.newMatrix(); + obj.fromParent = LA.newMatrix(); + } LA.matTranslate(obj.toParent, i * scale, 0, 0); LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0); @@ -3745,7 +4896,7 @@ return; Object3D poses = group.selection.get(0); - Object3D ref = GrafreeD.clipboard.get(0); + Object3D ref = Grafreed.clipboard.get(0); Object3D newgroup = new Object3D("Po:" + poses.name); @@ -3939,9 +5090,9 @@ void ClipMesh() { - if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) + if (/*group.selection.size() == 1 &&*/ Grafreed.clipboard.size() == 1) { - Object3D content = GrafreeD.clipboard.get(0); + Object3D content = Grafreed.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -3950,7 +5101,7 @@ // { // group.selection.get(i).ClipMesh(GrafreeD.clipboard); // } - group.selection.ClipMesh(GrafreeD.clipboard); + group.selection.ClipMesh(Grafreed.clipboard); } // group.selection.ClipMesh(GrafreeD.clipboard); System.out.println("DONE."); @@ -3967,6 +5118,12 @@ void ClearMaterials() { group.selection.ClearMaterials(); + refreshContents(); + } + + void ClearVersions() + { + group.selection.ClearVersions(); refreshContents(); } @@ -3997,6 +5154,18 @@ void MarkLeaves(boolean hide) { group.selection.MarkLeaves(hide); + refreshContents(); + } + + void RewindLeaves(boolean hide) + { + group.selection.RewindLeaves(hide); + refreshContents(); + } + + void RandomLeaves(boolean hide) + { + group.selection.RandomLeaves(hide); refreshContents(); } @@ -4071,28 +5240,25 @@ // } // } - static boolean allparams = true; - - static Vector<Object3D> listUI = new Vector<Object3D>(); - void EditSelection(boolean newWindow) { + if (group.selection == null) + { + EditElement(group, newWindow); // ? new + return; + } + // aConstraints.gridy = 0; for (int i=0; i<group.selection.size(); i++) { //System.out.println("edit : " + objectPanel.indexOfTab("Material")); //objectPanel.setEnabledAt(objectPanel.indexOfTab("Material"), false); - objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); + //objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit")); Object3D elem = (Object3D)group.selection.elementAt(i); - if(elem != group) + if(elem != group || !newWindow) { - // if (!(elem instanceof Composite)) - // newWindow = false; - listUI.add(elem); - elem.openEditWindow(this, newWindow); //, false); - System.out.println("edit : " + elem); - elem.editWindow.refreshContents(true); // ? new + EditElement(elem, newWindow); // ? new } } } @@ -4155,9 +5321,7 @@ freezemodel = false; } - - boolean flashIt = true; - + public void valueChanged(TreeSelectionEvent e) //public boolean handleEvent(Event event) { @@ -4167,7 +5331,8 @@ //new Exception().printStackTrace(); freezemodel = true; - + ClearUnpinned(); + /**/ //switch (event.id) { @@ -4175,7 +5340,6 @@ //case 702: // Event.LIST_DESELECT group.deselectAll(); TreePath tps[] = objEditor.jTree.getSelectionPaths(); - objEditor.ClearInfo(); // .GetMaterial()); if (tps != null) { for (int i=0; i < tps.length; i++) @@ -4184,10 +5348,8 @@ //if (child.parent != null) //child.parent.addSelectee(child); + objEditor.SetMaterial(child); group.addSelectee(child); - objEditor.SetMaterial(child); // .GetMaterial()); - objEditor.AddInfo(child, this, true); // .GetMaterial()); - System.err.println("info : " + child.GetPath()); } } // else @@ -4197,20 +5359,28 @@ // System.err.println("info : " + group.GetPath()); // } - objEditor.SetText(); // jan 2014 - - if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera)) + if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera)) CameraPane.flash = true; - if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera) + if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera) // a camera { - CameraPane.camerachangeframe = 0; // don't refuse it - Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent()); + if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crashes the camera because of invalid lightspace + { + CameraPane.camerachangeframe = 0; // don't refuse it + Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent()); + } // Globals.theRenderer.renderCamera = Globals.theRenderer.manipCamera; // Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera; } + if (tps != null && tps.length == 1) + { + EditSelection(false); + } + + SetPinStates(tps != null && tps.length > 0); + refreshContents(); //return true; } @@ -4219,6 +5389,53 @@ freezemodel = false; } + + void SetPinStates(boolean enabled) + { + editButton.setEnabled(enabled); + uneditButton.setEnabled(enabled); + //unselectButton.setEnabled(enabled); + flashSelectionButton.setEnabled(enabled); + + clearPanelButton.setEnabled(!listUI.isEmpty()); + + boolean allComposites = true; + + if (group.selection != null) + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + Object next = e.nextElement(); + if (!(next instanceof Composite)) // || (next instanceof GroupLeaf)) + { + allComposites = false; + break; + } + } + + rootButton.setEnabled(true); // allComposites); + } + + void refreshContents(boolean cp) + { + if (Globals.SHOWINFO) + //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info")) + if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING) + { + objEditor.ClearInfo(); // .GetMaterial()); + + for (int i=0; i < group.selection.Size(); i++) + { + Object3D child = (Object3D) group.selection.get(i); + + objEditor.AddInfo(child, this, true); +// System.err.println("info : " + child.GetPath()); + } + + objEditor.SetText(); // jan 2014 + } + + super.refreshContents(cp); + } void linkSomething(Object3D thing) { @@ -4290,16 +5507,19 @@ { if (group.selection.isEmpty()) return; - GrafreeD.clipboardIsTempGroup = false; + + Grafreed.clipboardIsTempGroup = false; Composite tGroup = null; if (group.selection.size() > 0) // 1) { tGroup = new cGroup(); - GrafreeD.clipboardIsTempGroup = true; + Grafreed.clipboardIsTempGroup = true; } if (cut) { +// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save. +// Save(); //int indices[] = jList.getSelectedIndices(); //for (int i = indices.length - 1; i >= 0; i--) //jList.remove(indices[i]); @@ -4335,16 +5555,16 @@ //System.out.println("cut " + child); //System.out.println("parent = " + child.parent); // tmp.addChild(child); - if (GrafreeD.clipboardIsTempGroup) + if (Grafreed.clipboardIsTempGroup) tGroup.add/*Child*/(tmp); else - GrafreeD.clipboard = tmp; + Grafreed.clipboard = tmp; } else - if (GrafreeD.clipboardIsTempGroup) + if (Grafreed.clipboardIsTempGroup) tGroup.add/*Child*/(child); else - GrafreeD.clipboard = child; + Grafreed.clipboard = child; } //ResetModel(); @@ -4376,21 +5596,23 @@ //System.out.println("cut " + elem); //System.out.println("parent = " + elem.parent); // tmp.addChild(elem); - if (GrafreeD.clipboardIsTempGroup) + if (Grafreed.clipboardIsTempGroup) tGroup.add/*Child*/(tmp); else - GrafreeD.clipboard = tmp; + Grafreed.clipboard = tmp; } else - if (GrafreeD.clipboardIsTempGroup) + if (Grafreed.clipboardIsTempGroup) tGroup.add/*Child*/(child); else - GrafreeD.clipboard = child; + Grafreed.clipboard = child; } } - if (GrafreeD.clipboardIsTempGroup) - GrafreeD.clipboard = tGroup; + + if (Grafreed.clipboardIsTempGroup) + Grafreed.clipboard = tGroup; + if (cut) { ResetModel(); @@ -4400,11 +5622,15 @@ void paste(boolean expand) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; // if (GrafreeD.clipboard == null) // return; boolean first = true; - if (GrafreeD.clipboardIsTempGroup) + if (Grafreed.clipboardIsTempGroup) { Composite temp; @@ -4415,7 +5641,7 @@ temp = (Composite)Applet3D.clipboard.deepCopy(); */ Object3D elem; - for (Enumeration e = /*temp.children*/GrafreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name)) + for (Enumeration e = /*temp.children*/Grafreed.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name)) { Object3D child = (Object3D)e.nextElement(); @@ -4449,16 +5675,17 @@ //Object3D cb = Applet3D.clipboard; //temp.addChild(cb); //makeSomething((expand?temp.copyExpand():temp.deepCopy()).get(0)); - assert(GrafreeD.clipboard.parent == null); - Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent; - GrafreeD.clipboard.get(0).parent = null; // Avoid copy? - if (LA.isIdentity(GrafreeD.clipboard.toParent)) - makeSomething(expand?GrafreeD.clipboard.get(0).copyExpand():GrafreeD.clipboard.get(0).deepCopy()); + assert(Grafreed.clipboard.parent == null); + Object3D /*Composite*/ keepparent = Grafreed.clipboard.get(0).parent; + Grafreed.clipboard.get(0).parent = null; // Avoid copy? + if (LA.isIdentity(Grafreed.clipboard.toParent)) + makeSomething(expand?Grafreed.clipboard.get(0).copyExpand():Grafreed.clipboard.get(0).deepCopy()); else - makeSomething(expand?GrafreeD.clipboard.copyExpand():GrafreeD.clipboard.deepCopy()); - GrafreeD.clipboard.get(0).parent = keepparent; + makeSomething(expand?Grafreed.clipboard.copyExpand():Grafreed.clipboard.deepCopy()); + Grafreed.clipboard.get(0).parent = keepparent; } + Globals.REPLACEONMAKE = keep; ResetModel(); refreshContents(); } @@ -4505,9 +5732,9 @@ { boolean first = true; - if (GrafreeD.clipboardIsTempGroup) + if (Grafreed.clipboardIsTempGroup) { - Composite temp = (Composite)GrafreeD.clipboard; + Composite temp = (Composite)Grafreed.clipboard; Object3D copy; for (Enumeration e = temp.children.elements(); e.hasMoreElements();) { @@ -4517,7 +5744,7 @@ } } else { - linkSomething(GrafreeD.clipboard); //.get(0)); + linkSomething(Grafreed.clipboard); //.get(0)); } } } @@ -4594,6 +5821,10 @@ void group(Object3D csg, boolean grab) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; if (//false) // why?? !group.selection.isEmpty()) { @@ -4707,10 +5938,15 @@ //node.add(csg); //makeSomething(node); makeSomething(csg); + Globals.REPLACEONMAKE = keep; } void Ungroup(Object3D g) { + if (Globals.REPLACEONMAKE) + Save(); + boolean keep = Globals.REPLACEONMAKE; + Globals.REPLACEONMAKE = false; if (g instanceof HiddenObject) { HiddenObject h = (HiddenObject) g; @@ -4727,6 +5963,7 @@ objEditor.makeSomething(g.get(i), false); } } + Globals.REPLACEONMAKE = keep; } void ungroup() @@ -4922,21 +6159,6 @@ } */ - void ImportGFD() - { - FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); - browser.show(); - String filename = browser.getFile(); - if (filename != null && filename.length() > 0) - { - String fullname = browser.getDirectory() + filename; - - //Object3D readobj = - objEditor.ReadGFD(fullname, objEditor); - //makeSomething(readobj); - } - } - /* public void Callback(Object obj) { @@ -4960,26 +6182,9 @@ } */ - void ImportVRMLX3D() - { - if (GrafreeD.standAlone) - { - /**/ - FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD); - browser.show(); - String filename = browser.getFile(); - if (filename != null && filename.length() > 0) - { - String fullname = browser.getDirectory() + filename; - LoadVRMLX3D(fullname); - } - /**/ - } - } - String GetFile(String dialogName) { - if (GrafreeD.standAlone) + if (Grafreed.standAlone) { FileDialog browser = new FileDialog(objEditor.frame, dialogName, FileDialog.LOAD); browser.show(); @@ -5047,7 +6252,43 @@ cButton clearpanelButton; cButton unselectButton; + cButton restoreCameraButton; + cButton oneStepButton; + + cButton groupButton; + cButton ungroupButton; + cButton compositeButton; + cButton switchButton; + cButton loopButton; + cButton textureButton; + + cButton skybox1Button; + cButton skybox2Button; + cButton skybox3Button; + cButton skybox4Button; + cButton skybox5Button; + cButton skybox6Button; + cButton skybox7Button; + + cButton skybox11Button; + cButton skybox12Button; + cButton skybox13Button; + cButton skybox14Button; + cButton skybox15Button; + cButton skybox16Button; + cButton skybox17Button; + + cButton gridButton; + cButton boxButton; + cButton sphereButton; + cButton coneButton; + cButton torusButton; + cButton superButton; + cButton kleinButton; + cButton particlesButton; + cButton overlayButton; + cButton lightButton; cButton screenfitButton; cButton screenfitpointButton; @@ -5060,14 +6301,6 @@ cButton setsupportButton; - cButton twoButton; - cButton sixButton; - cButton threeButton; - cButton sevenButton; - cButton fourButton; // full panel - cButton oneButton; // full XYZ - //cButton currentLayout; - // //Composite Object3D // to do !! @@ -5077,10 +6310,12 @@ //JTree jTree; private MenuItem lookAtItem; private MenuItem lookFromItem; - private MenuItem switchItem; - private MenuItem cutItem; - private MenuItem duplicateItem; - private MenuItem cloneItem; + private MenuItem switchViewItem; + private JMenuItem cutItem; + private MenuItem undoItem; + private MenuItem redoItem; + private JMenuItem duplicateItem; + private JMenuItem cloneItem; private MenuItem cloneSupportItem; private MenuItem overwriteGeoItem; private MenuItem overwriteMatItem; @@ -5092,7 +6327,7 @@ private MenuItem linkverticesItem; private MenuItem relinkverticesItem; private MenuItem setMasterItem; - private MenuItem resetMeshItem; + private MenuItem resetAllItem; private MenuItem stepAllItem; private MenuItem revertMeshItem; private MenuItem poseMeshItem; @@ -5101,13 +6336,13 @@ private MenuItem cloneGeometriesItem; private MenuItem shareGeometriesItem; private MenuItem mergeGeometriesItem; - private MenuItem copyItem; + private JMenuItem copyItem; private MenuItem pasteItem; - private MenuItem pasteIntoItem; - private MenuItem pasteLinkItem; - private MenuItem pasteCloneItem; - private MenuItem pasteExpandItem; - private MenuItem clearItem; + private JMenuItem pasteIntoItem; + private JMenuItem pasteLinkItem; + private JMenuItem pasteCloneItem; + private JMenuItem pasteExpandItem; + private JMenuItem deleteItem; private MenuItem clearAllItem; private MenuItem genUVItem; private MenuItem genNormalsMESHItem; @@ -5133,6 +6368,7 @@ private MenuItem clipMeshItem; private MenuItem smoothMeshItem; private MenuItem clearMaterialsItem; + private MenuItem clearVersionsItem; private MenuItem liveleavesItem; private MenuItem unliveleavesItem; @@ -5142,6 +6378,10 @@ private MenuItem showleavesItem; private MenuItem markleavesItem; private MenuItem unmarkleavesItem; + private MenuItem rewindleavesItem; + private MenuItem unrewindleavesItem; + private MenuItem randomleavesItem; + private MenuItem unrandomleavesItem; private MenuItem flipVItem; private MenuItem unflipVItem; @@ -5152,16 +6392,21 @@ private MenuItem maxTexturesItem; private MenuItem panoTexturesItem; + private MenuItem textureRatioRItem; + private MenuItem textureRatioGItem; + private MenuItem textureRatioBItem; private MenuItem resetCentroidItem; - private MenuItem transformgeometryItem; + private MenuItem resetCentroidXZItem; private MenuItem resetTransformItem; + private MenuItem transformGeometryItem; + private MenuItem transformChildrenItem; private MenuItem hideItem; - private MenuItem grabItem; + private JMenuItem grabItem; private MenuItem backItem; private MenuItem frontItem; private MenuItem cameraItem; private MenuItem compositeItem; - private MenuItem randomItem; + private MenuItem switchItem; private MenuItem physicsItem; private MenuItem frameselectorItem; private MenuItem scriptNodeItem; @@ -5169,7 +6414,7 @@ private MenuItem switchTransfoItem; private MenuItem morphItem; private MenuItem linkerItem; - private MenuItem ungroupItem; + private JMenuItem ungroupItem; private MenuItem editItem; private MenuItem openWindowItem; private MenuItem editLeafItem; @@ -5185,6 +6430,8 @@ private MenuItem attachBumpItem; private MenuItem detachBumpItem; private MenuItem pigmentBumpItem; + private MenuItem embedTexturesItem; + private MenuItem deEmbedTexturesItem; private MenuItem particleItem; private MenuItem ragdollItem; @@ -5223,11 +6470,6 @@ private MenuItem doubleItem; private MenuItem tripleItem; - private MenuItem importGFDItem; - private MenuItem importVRMLX3DItem; - private MenuItem import3DSItem; - private MenuItem importOBJItem; - private MenuItem computeAOItem; private MenuItem recompileItem; private MenuItem editScriptItem; @@ -5237,4 +6479,8 @@ private MenuItem analyzeItem; private MenuItem dumpItem; //boolean freezemodel = false; + + Menu cameraMenu; + MenuItem editCameraItem; + MenuItem restoreCameraItem; } -- Gitblit v1.6.2