Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
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();
....@@ -12446,7 +12453,7 @@
1244612453
1244712454 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1244812455
12449
- String program0 =
12456
+ String programmin =
1245012457 // Min shader
1245112458 "!!ARBfp1.0\n" +
1245212459 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12513,7 +12520,7 @@
1251312520 "MOV result.color, temp;" +
1251412521 "END";
1251512522
12516
- String program =
12523
+ String programmax =
1251712524 "!!ARBfp1.0\n" +
1251812525
1251912526 //"OPTION ARB_fragment_program_shadow;" +
....@@ -13369,6 +13376,13 @@
1336913376 //once = true;
1337013377 }
1337113378
13379
+ String program = programmax;
13380
+
13381
+ if (Globals.MINSHADER)
13382
+ {
13383
+ program = programmin;
13384
+ }
13385
+
1337213386 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1337313387 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1337413388 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -15362,7 +15376,7 @@
1536215376 OCCLUSION_CULLING ^= true;
1536315377 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415378 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15379
+ //case '0': envyoff ^= true; repaint(); break;
1536615380 case '1':
1536715381 case '2':
1536815382 case '3':
....@@ -15372,7 +15386,7 @@
1537215386 case '7':
1537315387 case '8':
1537415388 case '9':
15375
- if (envyoff)
15389
+ if (true) // envyoff)
1537615390 {
1537715391 BGcolor = (key - '1')/8.f;
1537815392 }
....@@ -16084,7 +16098,7 @@
1608416098 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516099 break;
1608616100 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16101
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816102 break;
1608916103 }
1609016104
....@@ -16570,6 +16584,8 @@
1657016584 private /*static*/ boolean firstime;
1657116585 private /*static*/ cVector newView = new cVector();
1657216586 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16587
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16588
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316589 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416590 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516591 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16598,56 @@
1658216598 {
1658316599 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416600
16601
+ int usedsuf = 0;
16602
+
1658516603 for (int i = 0; i < suffixes.length; i++)
1658616604 {
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)
16605
+ String[] suffixe = suffixes;
16606
+ String[] fallback = suffixes2;
16607
+ String[] fallfallback = suffixes3;
16608
+
16609
+ for (int c=usedsuf; --c>=0;)
1659216610 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16611
+// String[] temp = suffixe;
16612
+// suffixe = fallback;
16613
+// fallback = fallfallback;
16614
+// fallfallback = temp;
1659416615 }
16616
+
16617
+ String resourceName = basename + suffixe[i] + "." + suffix;
16618
+ TextureData data;
16619
+
16620
+ try
16621
+ {
16622
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16623
+ mipmapped,
16624
+ FileUtil.getFileSuffix(resourceName));
16625
+ }
16626
+ catch (Exception e)
16627
+ {
16628
+ try
16629
+ {
16630
+ resourceName = basename + fallback[i] + "." + suffix;
16631
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16632
+ mipmapped,
16633
+ FileUtil.getFileSuffix(resourceName));
16634
+ }
16635
+ catch (Exception e2)
16636
+ {
16637
+ resourceName = basename + fallfallback[i] + "." + suffix;
16638
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16639
+ mipmapped,
16640
+ FileUtil.getFileSuffix(resourceName));
16641
+ }
16642
+ }
16643
+
1659516644 //System.out.println("Target = " + targets[i]);
1659616645 cubemap.updateImage(data, targets[i]);
1659716646 }
1659816647
1659916648 return cubemap;
1660016649 }
16650
+
1660116651 int bigsphere = -1;
1660216652
1660316653 float BGcolor = 0.5f;
....@@ -16606,7 +16656,8 @@
1660616656
1660716657 private void DrawSkyBox(GL gl, float ratio)
1660816658 {
16609
- if (envyoff || cubemap == null)
16659
+ if (//envyoff ||
16660
+ cubemap == null)
1661016661 {
1661116662 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216663 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16623,14 +16674,14 @@
1662316674 gl.glLoadIdentity();
1662416675 gl.glScalef(1,ratio,1);
1662516676
16626
- colorV[0] = 2;
16627
- colorV[1] = 2;
16628
- colorV[2] = 2;
16629
- colorV[3] = 1;
16630
- gl.glDisable(gl.GL_COLOR_MATERIAL);
16631
- gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16632
-
16633
- gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16677
+// colorV[0] = 2;
16678
+// colorV[1] = 2;
16679
+// colorV[2] = 2;
16680
+// colorV[3] = 1;
16681
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16682
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16683
+//
16684
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1663416685
1663516686 //gl.glActiveTexture(GL.GL_TEXTURE1);
1663616687 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16644,7 +16695,7 @@
1664416695 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1664516696 // causes the normals to be sent down. Thanks to Ken Dyke.
1664616697 //gl.glEnable(GL.GL_LIGHTING);
16647
- gl.glEnable(GL.GL_LIGHTING);
16698
+ gl.glDisable(GL.GL_LIGHTING);
1664816699
1664916700 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1665016701 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16663,6 +16714,7 @@
1666316714 {
1666416715 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516716 }
16717
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616718 gl.glMultMatrixd(viewrot_1, 0);
1666716719 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816720 //viewer.updateInverseRotation(gl);