From c67de8aca04d988179191ccb52461af00125920e Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 13 Aug 2019 11:41:53 -0400 Subject: [PATCH] RGB skybox --- ObjEditor.java | 31 +++++++++++++++ CameraPane.java | 37 ++++++++++++++---- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index df28651..778fb13 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -110,7 +110,9 @@ //private Mat4f spotlightTransform = new Mat4f(); //private Mat4f spotlightInverseTransform = new Mat4f(); static GLContext glcontext = null; - /*static*/ com.sun.opengl.util.texture.Texture cubemap; + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; boolean reverseUP = false; static boolean frozen = false; boolean enablebackspace = false; // patch for back buffer refresh @@ -188,15 +190,16 @@ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); - public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException { try { - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); } catch (IOException e) { System.out.println("NAME = " + name); e.printStackTrace(); // throw new RuntimeException(e); + return null; } } @@ -9233,6 +9236,8 @@ void LoadEnvy(int which) { + assert(false); + String name; String ext; @@ -11077,18 +11082,32 @@ // // newenvy = -1; - if (object.skyboxname != null) + if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) { - if (!object.skyboxname.equals(this.loadedskyboxname)) + if (cubemaprgb == null) { - LoadSkybox(object.skyboxname + "/", object.skyboxext, false); - loadedskyboxname = object.skyboxname; + cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); } + + cubemap = cubemaprgb; } else { - cubemap = null; - loadedskyboxname = null; + if (object.skyboxname != null) + { + if (!object.skyboxname.equals(this.loadedskyboxname)) + { + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); + loadedskyboxname = object.skyboxname; + } + } + else + { + cubemapcustom = null; + loadedskyboxname = null; + } + + cubemap = cubemapcustom; } ratio = ((double) getWidth()) / getHeight(); diff --git a/ObjEditor.java b/ObjEditor.java index c2908ed..4b4a90a 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -433,6 +433,8 @@ ChangeListener changeListener = new ChangeListener() { + String name; + public void stateChanged(ChangeEvent changeEvent) { // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) @@ -451,7 +453,36 @@ // EditSelection(false); // } + if (objectPanel.getSelectedIndex() == 4) + { + name = copy.skyboxname; + + if (name == null) + { + name = ""; + } + + copy.skyboxname = "cubemaps/default-skyboxes/rgb"; + copy.skyboxext = "jpg"; + } + else + { + if (name != null) + { + if (name.equals("")) + { + copy.skyboxname = null; + copy.skyboxext = null; + } + else + { + copy.skyboxname = name; + } + } + } + // refreshContents(false); // To refresh Info tab + cameraView.repaint(); } }; objectPanel.addChangeListener(changeListener); -- Gitblit v1.6.2