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 };
....@@ -10841,7 +10854,7 @@
1084110854
1084210855 if (wait)
1084310856 {
10844
- Sleep(500);
10857
+ Sleep(200); // blocks everything
1084510858
1084610859 wait = false;
1084710860 }
....@@ -11379,7 +11392,7 @@
1137911392
1138011393 // if (cam != lightCamera)
1138111394 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11382
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11395
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1138311396 }
1138411397
1138511398 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12453,7 +12466,7 @@
1245312466
1245412467 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1245512468
12456
- String program0 =
12469
+ String programmin =
1245712470 // Min shader
1245812471 "!!ARBfp1.0\n" +
1245912472 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12520,7 +12533,7 @@
1252012533 "MOV result.color, temp;" +
1252112534 "END";
1252212535
12523
- String program =
12536
+ String programmax =
1252412537 "!!ARBfp1.0\n" +
1252512538
1252612539 //"OPTION ARB_fragment_program_shadow;" +
....@@ -13376,6 +13389,13 @@
1337613389 //once = true;
1337713390 }
1337813391
13392
+ String program = programmax;
13393
+
13394
+ if (Globals.MINSHADER)
13395
+ {
13396
+ program = programmin;
13397
+ }
13398
+
1337913399 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1338013400 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1338113401 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -14625,9 +14645,9 @@
1462514645 MODIFIERS |= COMMAND;
1462614646 /**/
1462714647 if((mod&SHIFT) == SHIFT)
14628
- manipCamera.RotatePosition(0, -speed);
14629
- else
1463014648 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14649
+ else
14650
+ manipCamera.RotatePosition(0, -speed);
1463114651 /**/
1463214652 if ((mod & SHIFT) == SHIFT)
1463314653 {
....@@ -14646,9 +14666,9 @@
1464614666 MODIFIERS |= COMMAND;
1464714667 /**/
1464814668 if((mod&SHIFT) == SHIFT)
14649
- manipCamera.RotatePosition(0, speed);
14650
- else
1465114669 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14670
+ else
14671
+ manipCamera.RotatePosition(0, speed);
1465214672 /**/
1465314673 if ((mod & SHIFT) == SHIFT)
1465414674 {
....@@ -16091,7 +16111,7 @@
1609116111 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1609216112 break;
1609316113 case Object3D.hitScale: gr.setColor(Color.cyan);
16094
- gr.drawLine(X, Y, 0, 0);
16114
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1609516115 break;
1609616116 }
1609716117
....@@ -16650,6 +16670,7 @@
1665016670 private void DrawSkyBox(GL gl, float ratio)
1665116671 {
1665216672 if (//envyoff ||
16673
+ WIREFRAME ||
1665316674 cubemap == null)
1665416675 {
1665516676 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
....@@ -16667,14 +16688,14 @@
1666716688 gl.glLoadIdentity();
1666816689 gl.glScalef(1,ratio,1);
1666916690
16670
- colorV[0] = 2;
16671
- colorV[1] = 2;
16672
- colorV[2] = 2;
16673
- colorV[3] = 1;
16674
- gl.glDisable(gl.GL_COLOR_MATERIAL);
16675
- gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16676
-
16677
- 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);
1667816699
1667916700 //gl.glActiveTexture(GL.GL_TEXTURE1);
1668016701 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16688,7 +16709,7 @@
1668816709 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1668916710 // causes the normals to be sent down. Thanks to Ken Dyke.
1669016711 //gl.glEnable(GL.GL_LIGHTING);
16691
- gl.glEnable(GL.GL_LIGHTING);
16712
+ gl.glDisable(GL.GL_LIGHTING);
1669216713
1669316714 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1669416715 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -17512,10 +17533,14 @@
1751217533 gl.glFlush();
1751317534
1751417535 /**/
17515
- 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);
1751617537
17517
- float[] pixels = occlusionsizebuffer.array();
17538
+ float[] depths = occlusiondepthbuffer.array();
1751817539
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
+
1751917544 double r = 0, g = 0, b = 0;
1752017545
1752117546 double count = 0;
....@@ -17526,7 +17551,7 @@
1752617551
1752717552 double FACTOR = 1;
1752817553
17529
- for (int i = 0; i < pixels.length; i++)
17554
+ for (int i = 0; i < depths.length; i++)
1753017555 {
1753117556 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1753217557 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17609,7 +17634,7 @@
1760917634
1761017635 double scale = ray.z; // 1; // cos
1761117636
17612
- float depth = pixels[newindex];
17637
+ float depth = depths[newindex];
1761317638
1761417639 /*
1761517640 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17806,11 +17831,14 @@
1780617831 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1780717832 static IntBuffer bigAAbuffer;
1780817833 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17809
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17834
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1781017835 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1781117836 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1781217837 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17813
- 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
+
1781417842 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1781517843 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1781617844 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();