Normand Briere
2019-08-09 912749d2520afedd9b56458d771400c261fe2b88
CameraPane.java
....@@ -8358,7 +8358,7 @@
83588358 // else
83598359 // if (!texname.startsWith("/"))
83608360 // texname = "/Users/nbriere/Textures/" + texname;
8361
- if (!FileExists(texname))
8361
+ if (!FileExists(texname) && !texname.startsWith("@"))
83628362 {
83638363 texname = fallbackTextureName;
83648364 }
....@@ -8441,6 +8441,15 @@
84418441 new Exception().printStackTrace();
84428442 } else
84438443 {
8444
+ if (texname.startsWith("@"))
8445
+ {
8446
+ // texturecache = textures.get(texname); // suspicious
8447
+ if (texturecache == null)
8448
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8449
+ else
8450
+ new Exception().printStackTrace();
8451
+ } else
8452
+ {
84448453 if (textureon)
84458454 {
84468455 String cachename = texname;
....@@ -8500,6 +8509,7 @@
85008509 texturecache = new CacheTexture(texturedata,resolution);
85018510 //texture = GetTexture(tex, bump);
85028511 }
8512
+ }
85038513 }
85048514 //}
85058515 }
....@@ -9316,10 +9326,9 @@
93169326 double[] light2camera = new double[16];
93179327
93189328 //int newenvy = -1;
9319
- boolean envyoff = true; // false;
9320
- String skyboxname = "";
9321
- String skyboxext;
9322
- String loadedskyboxname = "";
9329
+ //boolean envyoff = false;
9330
+
9331
+ String loadedskyboxname;
93239332
93249333 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
93259334 //float[] light0 = { 0,0,0 };
....@@ -10842,7 +10851,7 @@
1084210851
1084310852 if (wait)
1084410853 {
10845
- Sleep(500);
10854
+ Sleep(200); // blocks everything
1084610855
1084710856 wait = false;
1084810857 }
....@@ -11065,10 +11074,18 @@
1106511074 //
1106611075 // newenvy = -1;
1106711076
11068
- if (!skyboxname.equals(this.loadedskyboxname))
11077
+ if (object.skyboxname != null)
1106911078 {
11070
- LoadSkybox(skyboxname + "/", skyboxext, false);
11071
- loadedskyboxname = skyboxname;
11079
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11080
+ {
11081
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11082
+ loadedskyboxname = object.skyboxname;
11083
+ }
11084
+ }
11085
+ else
11086
+ {
11087
+ cubemap = null;
11088
+ loadedskyboxname = null;
1107211089 }
1107311090
1107411091 ratio = ((double) getWidth()) / getHeight();
....@@ -11372,7 +11389,7 @@
1137211389
1137311390 // if (cam != lightCamera)
1137411391 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11375
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11392
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1137611393 }
1137711394
1137811395 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12446,7 +12463,7 @@
1244612463
1244712464 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1244812465
12449
- String program0 =
12466
+ String programmin =
1245012467 // Min shader
1245112468 "!!ARBfp1.0\n" +
1245212469 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12513,7 +12530,7 @@
1251312530 "MOV result.color, temp;" +
1251412531 "END";
1251512532
12516
- String program =
12533
+ String programmax =
1251712534 "!!ARBfp1.0\n" +
1251812535
1251912536 //"OPTION ARB_fragment_program_shadow;" +
....@@ -13369,6 +13386,13 @@
1336913386 //once = true;
1337013387 }
1337113388
13389
+ String program = programmax;
13390
+
13391
+ if (Globals.MINSHADER)
13392
+ {
13393
+ program = programmin;
13394
+ }
13395
+
1337213396 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1337313397 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1337413398 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -14618,9 +14642,9 @@
1461814642 MODIFIERS |= COMMAND;
1461914643 /**/
1462014644 if((mod&SHIFT) == SHIFT)
14621
- manipCamera.RotatePosition(0, -speed);
14622
- else
1462314645 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14646
+ else
14647
+ manipCamera.RotatePosition(0, -speed);
1462414648 /**/
1462514649 if ((mod & SHIFT) == SHIFT)
1462614650 {
....@@ -14639,9 +14663,9 @@
1463914663 MODIFIERS |= COMMAND;
1464014664 /**/
1464114665 if((mod&SHIFT) == SHIFT)
14642
- manipCamera.RotatePosition(0, speed);
14643
- else
1464414666 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14667
+ else
14668
+ manipCamera.RotatePosition(0, speed);
1464514669 /**/
1464614670 if ((mod & SHIFT) == SHIFT)
1464714671 {
....@@ -15362,7 +15386,7 @@
1536215386 OCCLUSION_CULLING ^= true;
1536315387 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415388 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15389
+ //case '0': envyoff ^= true; repaint(); break;
1536615390 case '1':
1536715391 case '2':
1536815392 case '3':
....@@ -15372,7 +15396,7 @@
1537215396 case '7':
1537315397 case '8':
1537415398 case '9':
15375
- if (envyoff)
15399
+ if (true) // envyoff)
1537615400 {
1537715401 BGcolor = (key - '1')/8.f;
1537815402 }
....@@ -16084,7 +16108,7 @@
1608416108 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516109 break;
1608616110 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16111
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816112 break;
1608916113 }
1609016114
....@@ -16570,6 +16594,8 @@
1657016594 private /*static*/ boolean firstime;
1657116595 private /*static*/ cVector newView = new cVector();
1657216596 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16597
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16598
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316599 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416600 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516601 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16608,56 @@
1658216608 {
1658316609 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416610
16611
+ int usedsuf = 0;
16612
+
1658516613 for (int i = 0; i < suffixes.length; i++)
1658616614 {
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)
16615
+ String[] suffixe = suffixes;
16616
+ String[] fallback = suffixes2;
16617
+ String[] fallfallback = suffixes3;
16618
+
16619
+ for (int c=usedsuf; --c>=0;)
1659216620 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16621
+// String[] temp = suffixe;
16622
+// suffixe = fallback;
16623
+// fallback = fallfallback;
16624
+// fallfallback = temp;
1659416625 }
16626
+
16627
+ String resourceName = basename + suffixe[i] + "." + suffix;
16628
+ TextureData data;
16629
+
16630
+ try
16631
+ {
16632
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16633
+ mipmapped,
16634
+ FileUtil.getFileSuffix(resourceName));
16635
+ }
16636
+ catch (Exception e)
16637
+ {
16638
+ try
16639
+ {
16640
+ resourceName = basename + fallback[i] + "." + suffix;
16641
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16642
+ mipmapped,
16643
+ FileUtil.getFileSuffix(resourceName));
16644
+ }
16645
+ catch (Exception e2)
16646
+ {
16647
+ resourceName = basename + fallfallback[i] + "." + suffix;
16648
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16649
+ mipmapped,
16650
+ FileUtil.getFileSuffix(resourceName));
16651
+ }
16652
+ }
16653
+
1659516654 //System.out.println("Target = " + targets[i]);
1659616655 cubemap.updateImage(data, targets[i]);
1659716656 }
1659816657
1659916658 return cubemap;
1660016659 }
16660
+
1660116661 int bigsphere = -1;
1660216662
1660316663 float BGcolor = 0.5f;
....@@ -16606,7 +16666,8 @@
1660616666
1660716667 private void DrawSkyBox(GL gl, float ratio)
1660816668 {
16609
- if (envyoff || cubemap == null)
16669
+ if (//envyoff ||
16670
+ cubemap == null)
1661016671 {
1661116672 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216673 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16623,14 +16684,14 @@
1662316684 gl.glLoadIdentity();
1662416685 gl.glScalef(1,ratio,1);
1662516686
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);
16687
+// colorV[0] = 2;
16688
+// colorV[1] = 2;
16689
+// colorV[2] = 2;
16690
+// colorV[3] = 1;
16691
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16692
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16693
+//
16694
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1663416695
1663516696 //gl.glActiveTexture(GL.GL_TEXTURE1);
1663616697 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16644,7 +16705,7 @@
1664416705 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1664516706 // causes the normals to be sent down. Thanks to Ken Dyke.
1664616707 //gl.glEnable(GL.GL_LIGHTING);
16647
- gl.glEnable(GL.GL_LIGHTING);
16708
+ gl.glDisable(GL.GL_LIGHTING);
1664816709
1664916710 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1665016711 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16663,6 +16724,7 @@
1666316724 {
1666416725 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516726 }
16727
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616728 gl.glMultMatrixd(viewrot_1, 0);
1666716729 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816730 //viewer.updateInverseRotation(gl);