Normand Briere
2019-08-13 c67de8aca04d988179191ccb52461af00125920e
RGB skybox
2 files modified
68 ■■■■ changed files
CameraPane.java 37 ●●●● patch | view | raw | blame | history
ObjEditor.java 31 ●●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -110,7 +110,9 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 static GLContext glcontext = null;
113
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
114116 boolean reverseUP = false;
115117 static boolean frozen = false;
116118 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -188,15 +190,16 @@
188190
189191 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190192
191
- public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
193
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192194 {
193195 try
194196 {
195
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
197
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196198 } catch (IOException e)
197199 {
198200 System.out.println("NAME = " + name);
199201 e.printStackTrace(); // throw new RuntimeException(e);
202
+ return null;
200203 }
201204 }
202205
....@@ -9233,6 +9236,8 @@
92339236
92349237 void LoadEnvy(int which)
92359238 {
9239
+ assert(false);
9240
+
92369241 String name;
92379242 String ext;
92389243
....@@ -11077,18 +11082,32 @@
1107711082 //
1107811083 // newenvy = -1;
1107911084
11080
- if (object.skyboxname != null)
11085
+ if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1108111086 {
11082
- if (!object.skyboxname.equals(this.loadedskyboxname))
11087
+ if (cubemaprgb == null)
1108311088 {
11084
- LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
- loadedskyboxname = object.skyboxname;
11089
+ cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
1108611090 }
11091
+
11092
+ cubemap = cubemaprgb;
1108711093 }
1108811094 else
1108911095 {
11090
- cubemap = null;
11091
- loadedskyboxname = null;
11096
+ if (object.skyboxname != null)
11097
+ {
11098
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11099
+ {
11100
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11101
+ loadedskyboxname = object.skyboxname;
11102
+ }
11103
+ }
11104
+ else
11105
+ {
11106
+ cubemapcustom = null;
11107
+ loadedskyboxname = null;
11108
+ }
11109
+
11110
+ cubemap = cubemapcustom;
1109211111 }
1109311112
1109411113 ratio = ((double) getWidth()) / getHeight();
ObjEditor.java
....@@ -433,6 +433,8 @@
433433
434434 ChangeListener changeListener = new ChangeListener()
435435 {
436
+ String name;
437
+
436438 public void stateChanged(ChangeEvent changeEvent)
437439 {
438440 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -451,7 +453,36 @@
451453 // EditSelection(false);
452454 // }
453455
456
+ if (objectPanel.getSelectedIndex() == 4)
457
+ {
458
+ name = copy.skyboxname;
459
+
460
+ if (name == null)
461
+ {
462
+ name = "";
463
+ }
464
+
465
+ copy.skyboxname = "cubemaps/default-skyboxes/rgb";
466
+ copy.skyboxext = "jpg";
467
+ }
468
+ else
469
+ {
470
+ if (name != null)
471
+ {
472
+ if (name.equals(""))
473
+ {
474
+ copy.skyboxname = null;
475
+ copy.skyboxext = null;
476
+ }
477
+ else
478
+ {
479
+ copy.skyboxname = name;
480
+ }
481
+ }
482
+ }
483
+
454484 // refreshContents(false); // To refresh Info tab
485
+ cameraView.repaint();
455486 }
456487 };
457488 objectPanel.addChangeListener(changeListener);