Normand Briere
2019-08-01 c99d954f5e2bffa601c599142371cfeb45630f40
CameraPane.java
....@@ -9316,10 +9316,9 @@
93169316 double[] light2camera = new double[16];
93179317
93189318 //int newenvy = -1;
9319
- boolean envyoff = true; // false;
9320
- String skyboxname = "";
9321
- String skyboxext;
9322
- String loadedskyboxname = "";
9319
+ //boolean envyoff = false;
9320
+
9321
+ String loadedskyboxname;
93239322
93249323 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
93259324 //float[] light0 = { 0,0,0 };
....@@ -11065,10 +11064,18 @@
1106511064 //
1106611065 // newenvy = -1;
1106711066
11068
- if (!skyboxname.equals(this.loadedskyboxname))
11067
+ if (object.skyboxname != null)
1106911068 {
11070
- LoadSkybox(skyboxname + "/", skyboxext, false);
11071
- loadedskyboxname = skyboxname;
11069
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11070
+ {
11071
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11072
+ loadedskyboxname = object.skyboxname;
11073
+ }
11074
+ }
11075
+ else
11076
+ {
11077
+ cubemap = null;
11078
+ loadedskyboxname = null;
1107211079 }
1107311080
1107411081 ratio = ((double) getWidth()) / getHeight();
....@@ -15362,7 +15369,7 @@
1536215369 OCCLUSION_CULLING ^= true;
1536315370 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415371 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15372
+ //case '0': envyoff ^= true; repaint(); break;
1536615373 case '1':
1536715374 case '2':
1536815375 case '3':
....@@ -15372,7 +15379,7 @@
1537215379 case '7':
1537315380 case '8':
1537415381 case '9':
15375
- if (envyoff)
15382
+ if (true) // envyoff)
1537615383 {
1537715384 BGcolor = (key - '1')/8.f;
1537815385 }
....@@ -16084,7 +16091,7 @@
1608416091 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516092 break;
1608616093 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16094
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816095 break;
1608916096 }
1609016097
....@@ -16570,6 +16577,8 @@
1657016577 private /*static*/ boolean firstime;
1657116578 private /*static*/ cVector newView = new cVector();
1657216579 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16580
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16581
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316582 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416583 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516584 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16591,56 @@
1658216591 {
1658316592 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416593
16594
+ int usedsuf = 0;
16595
+
1658516596 for (int i = 0; i < suffixes.length; i++)
1658616597 {
16587
- String resourceName = basename + suffixes[i] + "." + suffix;
16588
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16589
- mipmapped,
16590
- FileUtil.getFileSuffix(resourceName));
16591
- if (data == null)
16598
+ String[] suffixe = suffixes;
16599
+ String[] fallback = suffixes2;
16600
+ String[] fallfallback = suffixes3;
16601
+
16602
+ for (int c=usedsuf; --c>=0;)
1659216603 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16604
+// String[] temp = suffixe;
16605
+// suffixe = fallback;
16606
+// fallback = fallfallback;
16607
+// fallfallback = temp;
1659416608 }
16609
+
16610
+ String resourceName = basename + suffixe[i] + "." + suffix;
16611
+ TextureData data;
16612
+
16613
+ try
16614
+ {
16615
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16616
+ mipmapped,
16617
+ FileUtil.getFileSuffix(resourceName));
16618
+ }
16619
+ catch (Exception e)
16620
+ {
16621
+ try
16622
+ {
16623
+ resourceName = basename + fallback[i] + "." + suffix;
16624
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16625
+ mipmapped,
16626
+ FileUtil.getFileSuffix(resourceName));
16627
+ }
16628
+ catch (Exception e2)
16629
+ {
16630
+ resourceName = basename + fallfallback[i] + "." + suffix;
16631
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16632
+ mipmapped,
16633
+ FileUtil.getFileSuffix(resourceName));
16634
+ }
16635
+ }
16636
+
1659516637 //System.out.println("Target = " + targets[i]);
1659616638 cubemap.updateImage(data, targets[i]);
1659716639 }
1659816640
1659916641 return cubemap;
1660016642 }
16643
+
1660116644 int bigsphere = -1;
1660216645
1660316646 float BGcolor = 0.5f;
....@@ -16606,7 +16649,8 @@
1660616649
1660716650 private void DrawSkyBox(GL gl, float ratio)
1660816651 {
16609
- if (envyoff || cubemap == null)
16652
+ if (//envyoff ||
16653
+ cubemap == null)
1661016654 {
1661116655 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216656 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16663,6 +16707,7 @@
1666316707 {
1666416708 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516709 }
16710
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616711 gl.glMultMatrixd(viewrot_1, 0);
1666716712 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816713 //viewer.updateInverseRotation(gl);