Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
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 }
....@@ -8768,10 +8778,12 @@
87688778
87698779 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87708780 MAXSTACK = temp[0];
8771
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8781
+ if (Globals.DEBUG)
8782
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87728783 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87738784 MAXSTACK = temp[0];
8774
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8785
+ if (Globals.DEBUG)
8786
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87758787
87768788 // Use debug pipeline
87778789 //drawable.setGL(new DebugGL(gl)); //
....@@ -8779,7 +8791,8 @@
87798791 gl = drawable.getGL(); //
87808792
87818793 GL gl3 = getGL();
8782
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8794
+ if (Globals.DEBUG)
8795
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87838796
87848797
87858798 //float pos[] = { 100, 100, 100, 0 };
....@@ -9316,10 +9329,9 @@
93169329 double[] light2camera = new double[16];
93179330
93189331 //int newenvy = -1;
9319
- boolean envyoff = true; // false;
9320
- String skyboxname = "";
9321
- String skyboxext;
9322
- String loadedskyboxname = "";
9332
+ //boolean envyoff = false;
9333
+
9334
+ String loadedskyboxname;
93239335
93249336 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
93259337 //float[] light0 = { 0,0,0 };
....@@ -10842,7 +10854,7 @@
1084210854
1084310855 if (wait)
1084410856 {
10845
- Sleep(500);
10857
+ Sleep(200); // blocks everything
1084610858
1084710859 wait = false;
1084810860 }
....@@ -11065,10 +11077,18 @@
1106511077 //
1106611078 // newenvy = -1;
1106711079
11068
- if (!skyboxname.equals(this.loadedskyboxname))
11080
+ if (object.skyboxname != null)
1106911081 {
11070
- LoadSkybox(skyboxname + "/", skyboxext, false);
11071
- loadedskyboxname = skyboxname;
11082
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11083
+ {
11084
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
+ loadedskyboxname = object.skyboxname;
11086
+ }
11087
+ }
11088
+ else
11089
+ {
11090
+ cubemap = null;
11091
+ loadedskyboxname = null;
1107211092 }
1107311093
1107411094 ratio = ((double) getWidth()) / getHeight();
....@@ -11372,7 +11392,7 @@
1137211392
1137311393 // if (cam != lightCamera)
1137411394 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11375
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11395
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1137611396 }
1137711397
1137811398 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12446,7 +12466,7 @@
1244612466
1244712467 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1244812468
12449
- String program0 =
12469
+ String programmin =
1245012470 // Min shader
1245112471 "!!ARBfp1.0\n" +
1245212472 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12513,7 +12533,7 @@
1251312533 "MOV result.color, temp;" +
1251412534 "END";
1251512535
12516
- String program =
12536
+ String programmax =
1251712537 "!!ARBfp1.0\n" +
1251812538
1251912539 //"OPTION ARB_fragment_program_shadow;" +
....@@ -13369,6 +13389,13 @@
1336913389 //once = true;
1337013390 }
1337113391
13392
+ String program = programmax;
13393
+
13394
+ if (Globals.MINSHADER)
13395
+ {
13396
+ program = programmin;
13397
+ }
13398
+
1337213399 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1337313400 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1337413401 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -14618,9 +14645,9 @@
1461814645 MODIFIERS |= COMMAND;
1461914646 /**/
1462014647 if((mod&SHIFT) == SHIFT)
14621
- manipCamera.RotatePosition(0, -speed);
14622
- else
1462314648 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14649
+ else
14650
+ manipCamera.RotatePosition(0, -speed);
1462414651 /**/
1462514652 if ((mod & SHIFT) == SHIFT)
1462614653 {
....@@ -14639,9 +14666,9 @@
1463914666 MODIFIERS |= COMMAND;
1464014667 /**/
1464114668 if((mod&SHIFT) == SHIFT)
14642
- manipCamera.RotatePosition(0, speed);
14643
- else
1464414669 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14670
+ else
14671
+ manipCamera.RotatePosition(0, speed);
1464514672 /**/
1464614673 if ((mod & SHIFT) == SHIFT)
1464714674 {
....@@ -15362,7 +15389,7 @@
1536215389 OCCLUSION_CULLING ^= true;
1536315390 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415391 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15392
+ //case '0': envyoff ^= true; repaint(); break;
1536615393 case '1':
1536715394 case '2':
1536815395 case '3':
....@@ -15372,7 +15399,7 @@
1537215399 case '7':
1537315400 case '8':
1537415401 case '9':
15375
- if (envyoff)
15402
+ if (true) // envyoff)
1537615403 {
1537715404 BGcolor = (key - '1')/8.f;
1537815405 }
....@@ -16084,7 +16111,7 @@
1608416111 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516112 break;
1608616113 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16114
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816115 break;
1608916116 }
1609016117
....@@ -16570,6 +16597,8 @@
1657016597 private /*static*/ boolean firstime;
1657116598 private /*static*/ cVector newView = new cVector();
1657216599 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16600
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16601
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316602 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416603 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516604 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16611,56 @@
1658216611 {
1658316612 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416613
16614
+ int usedsuf = 0;
16615
+
1658516616 for (int i = 0; i < suffixes.length; i++)
1658616617 {
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)
16618
+ String[] suffixe = suffixes;
16619
+ String[] fallback = suffixes2;
16620
+ String[] fallfallback = suffixes3;
16621
+
16622
+ for (int c=usedsuf; --c>=0;)
1659216623 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16624
+// String[] temp = suffixe;
16625
+// suffixe = fallback;
16626
+// fallback = fallfallback;
16627
+// fallfallback = temp;
1659416628 }
16629
+
16630
+ String resourceName = basename + suffixe[i] + "." + suffix;
16631
+ TextureData data;
16632
+
16633
+ try
16634
+ {
16635
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16636
+ mipmapped,
16637
+ FileUtil.getFileSuffix(resourceName));
16638
+ }
16639
+ catch (Exception e)
16640
+ {
16641
+ try
16642
+ {
16643
+ resourceName = basename + fallback[i] + "." + suffix;
16644
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16645
+ mipmapped,
16646
+ FileUtil.getFileSuffix(resourceName));
16647
+ }
16648
+ catch (Exception e2)
16649
+ {
16650
+ resourceName = basename + fallfallback[i] + "." + suffix;
16651
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16652
+ mipmapped,
16653
+ FileUtil.getFileSuffix(resourceName));
16654
+ }
16655
+ }
16656
+
1659516657 //System.out.println("Target = " + targets[i]);
1659616658 cubemap.updateImage(data, targets[i]);
1659716659 }
1659816660
1659916661 return cubemap;
1660016662 }
16663
+
1660116664 int bigsphere = -1;
1660216665
1660316666 float BGcolor = 0.5f;
....@@ -16606,7 +16669,9 @@
1660616669
1660716670 private void DrawSkyBox(GL gl, float ratio)
1660816671 {
16609
- if (envyoff || cubemap == null)
16672
+ if (//envyoff ||
16673
+ WIREFRAME ||
16674
+ cubemap == null)
1661016675 {
1661116676 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216677 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16623,14 +16688,14 @@
1662316688 gl.glLoadIdentity();
1662416689 gl.glScalef(1,ratio,1);
1662516690
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);
16691
+// colorV[0] = 2;
16692
+// colorV[1] = 2;
16693
+// colorV[2] = 2;
16694
+// colorV[3] = 1;
16695
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16696
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16697
+//
16698
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1663416699
1663516700 //gl.glActiveTexture(GL.GL_TEXTURE1);
1663616701 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16644,7 +16709,7 @@
1664416709 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1664516710 // causes the normals to be sent down. Thanks to Ken Dyke.
1664616711 //gl.glEnable(GL.GL_LIGHTING);
16647
- gl.glEnable(GL.GL_LIGHTING);
16712
+ gl.glDisable(GL.GL_LIGHTING);
1664816713
1664916714 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1665016715 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16663,6 +16728,7 @@
1666316728 {
1666416729 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516730 }
16731
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616732 gl.glMultMatrixd(viewrot_1, 0);
1666716733 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816734 //viewer.updateInverseRotation(gl);