From a434119e65146fe53d612c28e1ee7af532d1b70a Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 28 Jul 2019 15:25:44 -0400 Subject: [PATCH] Skyboxes --- GroupEditor.java | 344 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 272 insertions(+), 72 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index a08dc18..696071e 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -23,6 +23,31 @@ DragGestureListener, DragSourceListener, DropTargetListener, ItemListener // ListSelectionListener { + + public void AddSkyboxButton(String f, String s, cGridBag row3) + { + cButton skyboxButton; + final String path = "cubemaps/" + f + "-skyboxes/" + s; + row3.add(skyboxButton = GetButton(path + "/" + s + ".jpg", !Grafreed.NIMBUSLAF)); + skyboxButton.setToolTipText(s); + skyboxButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ChangeSkybox(path); + } + }); + } + + public void ChangeSkybox(String name) + { + cameraView.envyoff = false; + cameraView.skyboxname = name; + cameraView.skyboxext = "jpg"; + cameraView.repaint(); + } + //ObjEditor objEditor; public void closeUI2() { @@ -80,18 +105,20 @@ this.copy = this.group = copy; //selectees = this.group.selectees; - if (copy.versions == null) - { - copy.versions = new byte[100][]; - copy.versionindex = -1; - } - SetupMenu2(this); //objEditor); SetupUI2(objEditor); objEditor.SetupUI(true); SetupViews(objEditor); ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true); + + if (copy.versions == null) + { + copy.versions = new byte[100][]; + copy.versionindex = -1; + + Save(true); + } } void CloneSelection(boolean supports) @@ -206,8 +233,8 @@ // pasteExpandItem = menu.add(new MenuItem("Paste expand")); // pasteExpandItem.addActionListener(this); menu.add("-"); - clearItem = menu.add(new MenuItem("Clear")); - clearItem.addActionListener(this); + deleteItem = menu.add(new MenuItem("Delete")); + deleteItem.addActionListener(this); if (Globals.ADVANCED) { @@ -433,7 +460,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")); @@ -526,10 +553,15 @@ 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); @@ -601,7 +633,7 @@ */ cGridBag copyOptionsPanel = new cGridBag(); - copyOptionsPanel.preferredHeight = 1; + copyOptionsPanel.preferredHeight = 2; //this.AddOptions(oe.toolbarPanel, oe.aConstraints); @@ -681,31 +713,32 @@ oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); snapobjectButton.addActionListener(this); snapobjectButton.setToolTipText("Snap Object"); + + oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + fourButton.addActionListener(this); + fourButton.setToolTipText("Show control panel only"); } //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - twoButton.setToolTipText("Show center view only"); + oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + twoButton.setToolTipText("Show 3D view only"); twoButton.addActionListener(this); this.fullscreenLayout = twoButton; - 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"); + oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + threeButton.setToolTipText("Show controls and 3D view"); threeButton.addActionListener(this); - oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - sevenButton.setToolTipText("3-column layout"); - sevenButton.addActionListener(this); + oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.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(rootButton = GetButton("icons/write.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - rootButton.setToolTipText("Edit selection in new tab"); + oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + rootButton.setToolTipText("Open selection in new tab"); rootButton.addActionListener(this); oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); @@ -714,28 +747,30 @@ //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints); //clearButton.addActionListener(this); + cGridBag row1 = new cGridBag(); + // INSERT - oe.toolboxPanel.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); gridButton.setToolTipText("Create grid"); gridButton.addActionListener(this); - oe.toolboxPanel.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); boxButton.setToolTipText("Create box"); boxButton.addActionListener(this); - oe.toolboxPanel.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); sphereButton.setToolTipText("Create sphere"); sphereButton.addActionListener(this); - oe.toolboxPanel.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); coneButton.setToolTipText("Create cone"); coneButton.addActionListener(this); - oe.toolboxPanel.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); torusButton.setToolTipText("Create torus"); torusButton.addActionListener(this); - oe.toolboxPanel.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); superButton.setToolTipText("Create superellipsoid"); superButton.addActionListener(this); @@ -746,50 +781,144 @@ kleinButton.addActionListener(this); } - oe.toolboxPanel.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); particlesButton.setToolTipText("Create particle system"); particlesButton.addActionListener(this); - oe.toolboxPanel.Return(); + oe.toolboxPanel.add(row1); - oe.toolboxPanel.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + cGridBag row2 = new cGridBag(); + + row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); groupButton.setToolTipText("Create group"); groupButton.addActionListener(this); - oe.toolboxPanel.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); compositeButton.setToolTipText("Create composite"); compositeButton.addActionListener(this); - oe.toolboxPanel.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); switchButton.setToolTipText("Create item switcher"); switchButton.addActionListener(this); - oe.toolboxPanel.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); loopButton.setToolTipText("Create loop"); loopButton.addActionListener(this); - oe.toolboxPanel.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); textureButton.setToolTipText("Create texture"); textureButton.addActionListener(this); - oe.toolboxPanel.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); overlayButton.setToolTipText("Create overlay"); overlayButton.addActionListener(this); - oe.toolboxPanel.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); lightButton.setToolTipText("Create light"); lightButton.addActionListener(this); - for (int i=6; --i>=0;) + oe.toolboxPanel.add(row2); + + // ENVYMAPS + cGridBag row3 = new cGridBag(); + row3.preferredHeight = 20; + + AddSkyboxButton("default", "rgb", row3); + AddSkyboxButton("default", "cornell", row3); + AddSkyboxButton("default", "uffizi", row3); + AddSkyboxButton("default", "CloudyHills", row3); + AddSkyboxButton("default", "skycube", row3); + + oe.toolboxPanel.add(row3); + + cGridBag row4 = new cGridBag(); + row4.preferredHeight = 20; + + AddSkyboxButton("bridge", "Bridge2", row4); + AddSkyboxButton("urban", "GamlaStan2", row4); + AddSkyboxButton("urban", "Parliament", row4); + AddSkyboxButton("urban", "Roundabout", row4); + + oe.toolboxPanel.add(row4); + + cGridBag row5 = new cGridBag(); + row5.preferredHeight = 20; + + AddSkyboxButton("urban", "SaintLazarusChurch", row5); + AddSkyboxButton("urban", "SaintLazarusChurch2", row5); + AddSkyboxButton("urban", "SaintLazarusChurch3", row5); + AddSkyboxButton("urban", "UnionSquare", row5); + + oe.toolboxPanel.add(row5); + + cGridBag row6 = new cGridBag(); + row6.preferredHeight = 20; + + AddSkyboxButton("park", "BerzeliiPark", row6); + AddSkyboxButton("park", "Buddha", row6); + AddSkyboxButton("park", "CNTower2", row6); + //AddSkyboxButton("park", "Fatbursparken", row6); + AddSkyboxButton("park", "NiagaraFalls1", row6); + + oe.toolboxPanel.add(row6); + + cGridBag row7 = new cGridBag(); + row7.preferredHeight = 20; + + AddSkyboxButton("park", "NiagaraFalls3", row7); + AddSkyboxButton("park", "Park", row7); + //AddSkyboxButton("park", "Park2", row6); + //AddSkyboxButton("park", "Path", row6); + AddSkyboxButton("park", "Pond", row7); + AddSkyboxButton("park", "Skansen", row7); + + oe.toolboxPanel.add(row7); + + cGridBag row8 = new cGridBag(); + row8.preferredHeight = 20; + + AddSkyboxButton("park", "Skansen2", row8); + AddSkyboxButton("park", "Skansen3", row8); + AddSkyboxButton("park", "Skansen4", row8); + AddSkyboxButton("park", "Skansen5", row8); + + oe.toolboxPanel.add(row8); + + cGridBag row9 = new cGridBag(); + row9.preferredHeight = 20; + + AddSkyboxButton("park", "Stairs", row9); + //AddSkyboxButton("park", "Tantolunden", row6); + //AddSkyboxButton("park", "Tantolunden3", row6); + AddSkyboxButton("park", "Tantolunden4", row9); + + oe.toolboxPanel.add(row9); +/* +BerzeliiPark +Buddha +CNTower2 +Fatbursparken +NiagaraFalls1 +NiagaraFalls3 +Park +Park2 +Path +Pond +Skansen +Skansen2 +Skansen3 +Skansen4 +Skansen5 +Stairs +Tantolunden +Tantolunden3 +Tantolunden4 + */ + + for (int i=1; --i>=0;) { - oe.toolboxPanel.Return(); - oe.toolboxPanel.add(new cGridBag()); - oe.toolboxPanel.add(new cGridBag()); - oe.toolboxPanel.add(new cGridBag()); - oe.toolboxPanel.add(new cGridBag()); - oe.toolboxPanel.add(new cGridBag()); - oe.toolboxPanel.add(new cGridBag()); - oe.toolboxPanel.add(new cGridBag()); + //oe.toolboxPanel.Return(); + oe.toolboxPanel.add(new cGridBag()); } // EDIT panel @@ -850,8 +979,8 @@ versionSlider = (cNumberSlider)sliderPane.getComponent(1); sliderPane.preferredHeight = 1; -// 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); @@ -859,7 +988,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()); @@ -871,7 +1000,7 @@ dgr.addDragGestureListener(this); }catch(Exception e) {} */ - radio.layout = sevenButton; + radio.layout = sixButton; // sevenButton; oe.toolbarPanel.add(radioPanel); //, oe.aConstraints); } @@ -1013,7 +1142,7 @@ } radioButton.SetObject(obj); - radioButton.layout = sevenButton; + radioButton.layout = sixButton; // sevenButton; radioButton.SetCamera(cameraView.renderCamera, false); radioButton.addActionListener(this); radioPanel.add(radioButton); @@ -1693,6 +1822,16 @@ } } } + + 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 @@ -2121,6 +2260,23 @@ { 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()); @@ -2206,7 +2362,7 @@ if (source == computeAOItem) { Globals.drawMode = CameraPane.OCCLUSION; - Globals.theRenderer.repaint(); + cameraView.repaint(); } else if (source == recompileItem) { @@ -2658,7 +2814,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--) @@ -3140,7 +3296,7 @@ for (Enumeration e = group.selection.elements(); e.hasMoreElements();) { obj = (Object3D)e.nextElement(); - obj.SetBumpTexture(null); + obj.ResetBumpTexture(); } refreshContents(); @@ -3154,6 +3310,31 @@ obj.SetBumpTexture(obj.GetPigmentTexture()); } + 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) @@ -3257,8 +3438,8 @@ // centralPanel.setVisible(true); // XYZPanel.setVisible(true); bigThree.ClearUI(); + bigThree.add(scenePanel); bigThree.add(centralPanel); - bigThree.add(XYZPanel); bigThree.FlushUI(); cameraView.requestFocusInWindow(); @@ -3338,8 +3519,8 @@ // centralPanel.setVisible(true); // XYZPanel.setVisible(false); bigThree.ClearUI(); - bigThree.add(scenePanel); bigThree.add(centralPanel); + bigThree.add(scenePanel); bigThree.FlushUI(); cameraView.requestFocusInWindow(); @@ -3553,10 +3734,10 @@ radio.layout.doClick(); ClearUnpinned(); - Grafreed.Assert(group != null); - Grafreed.Assert(group.selection != null); - SetPinStates(group.selection.size() > 0); - if (group.selection.size() == 1) + //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??? @@ -4150,7 +4331,7 @@ try { - texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres); + texturedata = Globals.theRenderer.GetTextureData(tex, false, node.texres); } catch (Exception e) { @@ -4627,6 +4808,12 @@ 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++) { @@ -4637,12 +4824,7 @@ Object3D elem = (Object3D)group.selection.elementAt(i); 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 } } } @@ -4786,7 +4968,7 @@ void refreshContents(boolean cp) { - if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info")) + if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info")) if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING) { objEditor.ClearInfo(); // .GetMaterial()); @@ -5632,6 +5814,22 @@ 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; @@ -5695,7 +5893,7 @@ private MenuItem pasteLinkItem; private MenuItem pasteCloneItem; private MenuItem pasteExpandItem; - private MenuItem clearItem; + private MenuItem deleteItem; private MenuItem clearAllItem; private MenuItem genUVItem; private MenuItem genNormalsMESHItem; @@ -5779,6 +5977,8 @@ private MenuItem attachBumpItem; private MenuItem detachBumpItem; private MenuItem pigmentBumpItem; + private MenuItem embedTexturesItem; + private MenuItem deEmbedTexturesItem; private MenuItem particleItem; private MenuItem ragdollItem; -- Gitblit v1.6.2