Normand Briere
2019-08-13 0cdf3fb57ddea3226f094ba45c836c7e9b123e3a
CameraPane.java
....@@ -173,7 +173,7 @@
173173 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174174 boolean anisotropy = true;
175175 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
176
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177177
178178 boolean macromode = false;
179179
....@@ -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
....@@ -16633,6 +16660,7 @@
1663316660
1663416661 return cubemap;
1663516662 }
16663
+
1663616664 int bigsphere = -1;
1663716665
1663816666 float BGcolor = 0.5f;
....@@ -16641,7 +16669,9 @@
1664116669
1664216670 private void DrawSkyBox(GL gl, float ratio)
1664316671 {
16644
- if (envyoff || cubemap == null)
16672
+ if (//envyoff ||
16673
+ WIREFRAME ||
16674
+ cubemap == null)
1664516675 {
1664616676 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1664716677 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16658,14 +16688,14 @@
1665816688 gl.glLoadIdentity();
1665916689 gl.glScalef(1,ratio,1);
1666016690
16661
- colorV[0] = 2;
16662
- colorV[1] = 2;
16663
- colorV[2] = 2;
16664
- colorV[3] = 1;
16665
- gl.glDisable(gl.GL_COLOR_MATERIAL);
16666
- gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16667
-
16668
- 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);
1666916699
1667016700 //gl.glActiveTexture(GL.GL_TEXTURE1);
1667116701 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16679,7 +16709,7 @@
1667916709 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1668016710 // causes the normals to be sent down. Thanks to Ken Dyke.
1668116711 //gl.glEnable(GL.GL_LIGHTING);
16682
- gl.glEnable(GL.GL_LIGHTING);
16712
+ gl.glDisable(GL.GL_LIGHTING);
1668316713
1668416714 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1668516715 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -17503,10 +17533,14 @@
1750317533 gl.glFlush();
1750417534
1750517535 /**/
17506
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17536
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1750717537
17508
- float[] pixels = occlusionsizebuffer.array();
17538
+ float[] depths = occlusiondepthbuffer.array();
1750917539
17540
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17541
+
17542
+ int[] pixels = selectsizebuffer.array();
17543
+
1751017544 double r = 0, g = 0, b = 0;
1751117545
1751217546 double count = 0;
....@@ -17517,7 +17551,7 @@
1751717551
1751817552 double FACTOR = 1;
1751917553
17520
- for (int i = 0; i < pixels.length; i++)
17554
+ for (int i = 0; i < depths.length; i++)
1752117555 {
1752217556 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1752317557 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17600,7 +17634,7 @@
1760017634
1760117635 double scale = ray.z; // 1; // cos
1760217636
17603
- float depth = pixels[newindex];
17637
+ float depth = depths[newindex];
1760417638
1760517639 /*
1760617640 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17797,11 +17831,14 @@
1779717831 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1779817832 static IntBuffer bigAAbuffer;
1779917833 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17800
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17834
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1780117835 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1780217836 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1780317837 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17804
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17838
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17839
+
17840
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17841
+
1780517842 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1780617843 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1780717844 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();