Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
CameraPane.java
....@@ -110,7 +110,11 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 static GLContext glcontext = null;
113
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
114118 boolean reverseUP = false;
115119 static boolean frozen = false;
116120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -164,7 +168,7 @@
164168
165169
166170 // OPTIONS
167
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
168172 boolean cameraLight = false;
169173 boolean UVdebug = false;
170174 boolean Udebug = false;
....@@ -173,7 +177,7 @@
173177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174178 boolean anisotropy = true;
175179 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177181
178182 boolean macromode = false;
179183
....@@ -188,15 +192,16 @@
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190194
191
- public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192196 {
193197 try
194198 {
195
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196200 } catch (IOException e)
197201 {
198202 System.out.println("NAME = " + name);
199203 e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
200205 }
201206 }
202207
....@@ -537,7 +542,8 @@
537542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
538543 LA.vecCross(obj.v0, obj.v1, obj.v2);
539544 LA.vecNormalize(obj.v2);
540
- gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
545
+
546
+ SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
541547 }
542548
543549 // P
....@@ -559,7 +565,7 @@
559565 y += ny * obj.NORMALPUSH;
560566 z += nz * obj.NORMALPUSH;
561567
562
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
563569 }
564570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
565571 SetColor(obj, pv);
....@@ -591,7 +597,7 @@
591597 y += ny * obj.NORMALPUSH;
592598 z += nz * obj.NORMALPUSH;
593599
594
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
595601 }
596602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
597603 // boolean locked = false;
....@@ -639,7 +645,7 @@
639645 y += ny * obj.NORMALPUSH;
640646 z += nz * obj.NORMALPUSH;
641647
642
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
643649 }
644650
645651 // if ((dot&4) == 0)
....@@ -875,7 +881,7 @@
875881 //// tris.postdraw(this);
876882 }
877883
878
- static Camera localcamera = new Camera();
884
+ static Camera localAOcamera = new Camera();
879885 static cVector from = new cVector();
880886 static cVector to = new cVector();
881887
....@@ -884,7 +890,7 @@
884890 CameraPane cp = this;
885891
886892 Camera keep = cp.RenderCamera();
887
- cp.renderCamera = localcamera;
893
+ cp.renderCamera = localAOcamera;
888894
889895 if (br.trimmed)
890896 {
....@@ -902,7 +908,7 @@
902908 br.positions[i3 + 2] + br.normals[i3 + 2]);
903909 LA.xformPos(from, transform, from);
904910 LA.xformPos(to, transform, to); // RIGID ONLY
905
- localcamera.setAim(from, to);
911
+ localAOcamera.setAim(from, to);
906912
907913 CameraPane.occlusionbuffer.display();
908914
....@@ -936,7 +942,7 @@
936942 to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
937943 LA.xformPos(from, transform, from);
938944 LA.xformPos(to, transform, to); // RIGID ONLY
939
- localcamera.setAim(from, to);
945
+ localAOcamera.setAim(from, to);
940946
941947 CameraPane.occlusionbuffer.display();
942948
....@@ -1245,10 +1251,10 @@
12451251 {
12461252 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12471253 {
1248
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12491255 } else
12501256 {
1251
- gl.glNormal3f(0, 0, 1);
1257
+ SetGLNormal(gl, 0, 0, 1);
12521258 }
12531259
12541260 if (c != null)
....@@ -1272,10 +1278,10 @@
12721278 {
12731279 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12741280 {
1275
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12761282 } else
12771283 {
1278
- gl.glNormal3f(0, 0, 1);
1284
+ SetGLNormal(gl, 0, 0, 1);
12791285 }
12801286 if (c != null)
12811287 {
....@@ -1300,10 +1306,10 @@
13001306 {
13011307 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
13021308 {
1303
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
13041310 } else
13051311 {
1306
- gl.glNormal3f(0, 0, 1);
1312
+ SetGLNormal(gl, 0, 0, 1);
13071313 }
13081314 if (c != null)
13091315 {
....@@ -1485,7 +1491,7 @@
14851491 {
14861492 if (!selectmode)
14871493 {
1488
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1494
+ SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
14891495 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
14901496
14911497 if (flipV)
....@@ -1814,7 +1820,7 @@
18141820
18151821 display.modelParams7[0] = 0;
18161822 display.modelParams7[1] = 1000;
1817
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
18181824 display.modelParams7[3] = 0;
18191825
18201826 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2047,9 +2053,9 @@
20472053 switch(viewcode)
20482054 {
20492055 case 0: return "main";
2050
- case 1: return "one";
2051
- case 2: return "two";
2052
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
20532059 case 4: return "light";
20542060 }
20552061
....@@ -2470,6 +2476,18 @@
24702476 return CreateBim(bytes, width, height);
24712477 }
24722478
2479
+ private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz)
2480
+ {
2481
+ gl.glNormal3f(nx, ny, nz);
2482
+
2483
+ if (ny > 0.9 || ny < -0.9)
2484
+ // Ground or ceiling
2485
+ gl.glVertexAttrib3f(4, 1, 0, 0);
2486
+ else
2487
+ // Walls
2488
+ gl.glVertexAttrib3f(4, 0, 1, 0);
2489
+ }
2490
+
24732491 /**/
24742492 class CacheTexture
24752493 {
....@@ -2512,7 +2530,7 @@
25122530 com.sun.opengl.util.texture.TextureIO.newTextureData(
25132531 getClass().getClassLoader().getResourceAsStream(name),
25142532 true,
2515
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25162534 } catch (java.io.IOException e)
25172535 {
25182536 throw new javax.media.opengl.GLException(e);
....@@ -9233,6 +9251,8 @@
92339251
92349252 void LoadEnvy(int which)
92359253 {
9254
+ assert(false);
9255
+
92369256 String name;
92379257 String ext;
92389258
....@@ -10683,9 +10703,18 @@
1068310703 static boolean init = false;
1068410704
1068510705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
1068610709
1068710710 public void display(GLAutoDrawable drawable)
1068810711 {
10712
+ if (patchMaterial.patchMaterial)
10713
+ {
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
1068910718 if (Grafreed.savesound && Grafreed.hassound)
1069010719 {
1069110720 Grafreed.wav.save();
....@@ -11077,18 +11106,34 @@
1107711106 //
1107811107 // newenvy = -1;
1107911108
11080
- if (object.skyboxname != null)
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1108111110 {
11082
- if (!object.skyboxname.equals(this.loadedskyboxname))
11111
+ if (cubemaprgb == null)
1108311112 {
11084
- LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
- loadedskyboxname = object.skyboxname;
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
1108611114 }
11115
+
11116
+ cubemap = cubemaprgb;
1108711117 }
1108811118 else
1108911119 {
11090
- cubemap = null;
11091
- loadedskyboxname = null;
11120
+ if (object.skyboxname != null)
11121
+ {
11122
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11123
+ {
11124
+ if (cubemap != null && cubemap != cubemaprgb)
11125
+ cubemap.dispose();
11126
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11127
+ loadedskyboxname = object.skyboxname;
11128
+ }
11129
+ }
11130
+ else
11131
+ {
11132
+ cubemapcustom = null;
11133
+ loadedskyboxname = null;
11134
+ }
11135
+
11136
+ cubemap = cubemapcustom;
1109211137 }
1109311138
1109411139 ratio = ((double) getWidth()) / getHeight();
....@@ -12469,8 +12514,9 @@
1246912514 String programmin =
1247012515 // Min shader
1247112516 "!!ARBfp1.0\n" +
12472
- "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12473
- "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12517
+ "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" +
12518
+ "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" +
12519
+ "PARAM pow2 = { 2, 4, 8, 0.0 };" +
1247412520 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1247512521 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1247612522 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
....@@ -12485,10 +12531,11 @@
1248512531 "TEMP eye;" +
1248612532 "TEMP pos;" +
1248712533
12488
- "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12534
+ "MAD normal, fragment.color, zero12t.z, -zero12t.y;" +
1248912535 Normalize("normal") +
1249012536 "MOV light, state.light[0].position;" +
1249112537 "DP3 ndotl.x, light, normal;" +
12538
+ "MAX ndotl.x, ndotl.x, zero12t.x;" +
1249212539
1249312540 // shadow
1249412541 "MOV pos, fragment.texcoord[1];" +
....@@ -12504,7 +12551,7 @@
1250412551 "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1250512552
1250612553 // Backlit
12507
- "MOV pos.w, zero123.y;" +
12554
+ "MOV pos.w, zero12t.y;" + // one
1250812555 "DP4 eye.x, pos, light2cam0;" +
1250912556 "DP4 eye.y, pos, light2cam1;" +
1251012557 "DP4 eye.z, pos, light2cam2;" +
....@@ -12512,24 +12559,28 @@
1251212559
1251312560 "DP3 ndotl.y, -eye, normal;" +
1251412561 //"MUL ndotl.y, ndotl.y, pow2.x;" +
12515
- "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12516
- "SUB ndotl.y, zero123.y, ndotl.y;" +
12562
+ "POW ndotl.y, ndotl.y, pow2.x;" + // backlit
12563
+ "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y
12564
+ //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit
1251712565 //"SUB ndotl.y, zero123.y, ndotl.y;" +
1251812566 //"MUL ndotl.y, ndotl.y, pow2.z;" +
12567
+ "ADD ndotl.y, ndotl.y, one.x;" +
12568
+ "MUL ndotl.y, ndotl.y, pow_2.x;" +
1251912569
1252012570 //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
1252112571 //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
1252212572
1252312573 // Pigment
1252412574 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12525
- "LRP temp, zero123.w, temp, one;" + // texture proportion
12526
- "MUL temp, temp, ndotl.x;" +
12527
-
12528
- "MUL temp, temp, zero123.z;" +
12575
+ "LRP temp, zero12t.w, temp, one;" + // texture proportion
12576
+ "MUL temp, temp, zero12t.w;" + // Times x
1252912577
1253012578 //"MUL temp, temp, ndotl.y;" +
12579
+ "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" +
1253112580
12532
- "MOV temp.w, zero123.y;" + // reset alpha
12581
+ "MUL temp, temp, ndotl.x;" + // lambert
12582
+
12583
+ "MOV temp.w, zero12t.y;" + // reset alpha
1253312584 "MOV result.color, temp;" +
1253412585 "END";
1253512586
....@@ -12561,7 +12612,7 @@
1256112612 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1256212613 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1256312614 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12564
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12615
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1256512616 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1256612617 "PARAM options1 = program.env[62];" + // fog rgb color
1256712618 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12806,7 +12857,7 @@
1280612857 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1280712858 // mar 2013 ??? "KIL alpha.a;" +
1280812859 "MOV alpha, texSamp.aaaa;" + // y;" +
12809
- "KIL alpha.a;" +
12860
+ "KIL alpha.a;" + // not sure with parallax mapping
1281012861 /*
1281112862 "MUL temp.xy, temp, two;" +
1281212863 "TXB bump, temp, texture[0], 2D;" +
....@@ -12892,11 +12943,6 @@
1289212943 "SUB bump0, bump0, half;" +
1289312944 "ADD bump, bump, bump0;" +
1289412945
12895
- "MOV temp.x, texSamp.a;" +
12896
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12897
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12898
- "MOV texSamp.a, temp.x;" +
12899
-
1290012946 // double-sided
1290112947 /**/
1290212948 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12913,19 +12959,62 @@
1291312959 "MOV normald, normal;" +
1291412960 "MOV normals, normal;" +
1291512961
12962
+ "MOV temp, fragment.texcoord[4];" +
12963
+
1291612964 // UV base
1291712965 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1291812966 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1291912967 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12920
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12921
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12922
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12968
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12969
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12970
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12971
+ Normalize("UP") +
12972
+
1292312973 "XPD V, normal, UP;" +
1292412974 Normalize("V") +
1292512975 "XPD U, V, normal;" +
1292612976 Normalize("U") +
1292712977
1292812978 // parallax mapping
12979
+
12980
+ "DP3 temp2.x, V, eye;" +
12981
+ "DP3 temp2.y, U, eye;" +
12982
+ "DP3 temp2.z, normal, eye;" +
12983
+ "RCP temp2.z, temp2.z;" +
12984
+
12985
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12986
+ "RSQ temp2.w, temp2.w;" +
12987
+ "RCP temp2.w, temp2.w;" +
12988
+
12989
+ "SUB temp2.w, temp2.w, half;" +
12990
+// "SGE temp.x, temp2.w, eps.x;" +
12991
+// "MUL temp2.w, temp2.w, temp.x;" +
12992
+
12993
+ //"MOV texSamp, U;" +
12994
+
12995
+ "MUL temp2.z, temp2.z, temp2.w;" +
12996
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12997
+
12998
+ "MUL temp2, temp2, temp2.z;" +
12999
+
13000
+ "MOV temp, fragment.texcoord[0];" +
13001
+
13002
+ "SUB temp, temp, temp2;" +
13003
+
13004
+ "TEX temp, temp, texture[0], 2D;" +
13005
+ "POW temp.a, temp.a, params6.w;" + // punch through
13006
+
13007
+ "ADD texSamp, temp, texSamp;" +
13008
+ "MUL texSamp.xyz, half, texSamp;" +
13009
+
13010
+ "MOV alpha, texSamp.aaaa;" +
13011
+
13012
+// parallax mapping
13013
+
13014
+ "MOV temp.x, texSamp.a;" +
13015
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13016
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13017
+ "MOV texSamp.a, temp.x;" +
1292913018
1293013019 //"MOV temp, fragment.texcoord[0];" +
1293113020 //
....@@ -13396,8 +13485,12 @@
1339613485 program = programmin;
1339713486 }
1339813487
13399
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13400
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13488
+ if (Globals.DEBUG)
13489
+ {
13490
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13491
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13492
+ }
13493
+
1340113494 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1340213495
1340313496 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13444,7 +13537,8 @@
1344413537 "\n" +
1344513538 "END\n";
1344613539
13447
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13540
+ if (Globals.DEBUG)
13541
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1344813542 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1344913543
1345013544 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13702,7 +13796,7 @@
1370213796 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1370313797 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1370413798 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13705
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13799
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1370613800
1370713801 //Object3D.cVector2[] vector2buffer;
1370813802
....@@ -13869,7 +13963,7 @@
1386913963 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1387013964 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1387113965 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13872
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13966
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1387313967 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1387413968 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1387513969 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13930,7 +14024,7 @@
1393014024 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1393114025 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1393214026 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
13933
- //"MOV result.texcoord, vertex.texcoord;" +
14027
+ //"MOV result.texcoord, vertex.fogcoord;" +
1393414028 "MOV result.texcoord, temp;" +
1393514029 // border fade
1393614030 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -13977,7 +14071,9 @@
1397714071
1397814072 //"ADD temp.z, temp.z, one;" +
1397914073
13980
- "MOV result.color, temp;"
14074
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14075
+
14076
+ "MOV result.color, temp;" // Normal
1398114077 : "MOV result.color, vertex.color;") +
1398214078 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1398314079 : "") +
....@@ -14643,11 +14739,17 @@
1464314739 void GoDown(int mod)
1464414740 {
1464514741 MODIFIERS |= COMMAND;
14742
+ boolean isVR = (mouseMode&VR)!=0;
1464614743 /**/
1464714744 if((mod&SHIFT) == SHIFT)
14648
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14745
+ {
14746
+ if (isVR)
14747
+ manipCamera.RotateInterest(0, -speed);
14748
+ else
14749
+ manipCamera.RotatePosition(0, -speed);
14750
+ }
1464914751 else
14650
- manipCamera.RotatePosition(0, -speed);
14752
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1465114753 /**/
1465214754 if ((mod & SHIFT) == SHIFT)
1465314755 {
....@@ -14657,6 +14759,8 @@
1465714759 mouseMode |= BACKFORTH;
1465814760 }
1465914761
14762
+ targetLookAt.set(manipCamera.lookAt);
14763
+
1466014764 //prevX = X = anchorX;
1466114765 prevY = Y = anchorY - (int) (renderCamera.Distance());
1466214766 }
....@@ -14665,10 +14769,17 @@
1466514769 {
1466614770 MODIFIERS |= COMMAND;
1466714771 /**/
14772
+ boolean isVR = (mouseMode&VR)!=0;
14773
+
1466814774 if((mod&SHIFT) == SHIFT)
14669
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14775
+ {
14776
+ if (isVR)
14777
+ manipCamera.RotateInterest(0, speed);
14778
+ else
14779
+ manipCamera.RotatePosition(0, speed);
14780
+ }
1467014781 else
14671
- manipCamera.RotatePosition(0, speed);
14782
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1467214783 /**/
1467314784 if ((mod & SHIFT) == SHIFT)
1467414785 {
....@@ -14678,6 +14789,8 @@
1467814789 mouseMode |= BACKFORTH;
1467914790 }
1468014791
14792
+ targetLookAt.set(manipCamera.lookAt);
14793
+
1468114794 //prevX = X = anchorX;
1468214795 prevY = Y = anchorY + (int) (renderCamera.Distance());
1468314796 }
....@@ -14687,9 +14800,14 @@
1468714800 MODIFIERS |= COMMAND;
1468814801 /**/
1468914802 if((mod&SHIFT) == SHIFT)
14690
- manipCamera.Translate(speed*delta, 0, getWidth());
14803
+ manipCamera.Translate(speed*delta, 0, getWidth());
1469114804 else
14692
- manipCamera.RotatePosition(speed, 0);
14805
+ {
14806
+ if ((mouseMode&VR)!=0)
14807
+ manipCamera.RotateInterest(-speed, 0);
14808
+ else
14809
+ manipCamera.RotatePosition(speed, 0);
14810
+ }
1469314811 /**/
1469414812 if ((mod & SHIFT) == SHIFT)
1469514813 {
....@@ -14699,6 +14817,8 @@
1469914817 mouseMode |= ROTATE;
1470014818 } // TRANSLATE;
1470114819
14820
+ targetLookAt.set(manipCamera.lookAt);
14821
+
1470214822 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1470314823 prevY = Y = anchorY;
1470414824 }
....@@ -14708,9 +14828,15 @@
1470814828 MODIFIERS |= COMMAND;
1470914829 /**/
1471014830 if((mod&SHIFT) == SHIFT)
14711
- manipCamera.Translate(-speed*delta, 0, getWidth());
14831
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1471214832 else
14713
- manipCamera.RotatePosition(-speed, 0);
14833
+ {
14834
+ if ((mouseMode&VR)!=0)
14835
+ manipCamera.RotateInterest(speed, 0);
14836
+ else
14837
+ manipCamera.RotatePosition(-speed, 0);
14838
+ }
14839
+
1471414840 /**/
1471514841 if ((mod & SHIFT) == SHIFT)
1471614842 {
....@@ -14720,6 +14846,8 @@
1472014846 mouseMode |= ROTATE;
1472114847 } // TRANSLATE;
1472214848
14849
+ targetLookAt.set(manipCamera.lookAt);
14850
+
1472314851 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1472414852 prevY = Y = anchorY;
1472514853 }
....@@ -15222,8 +15350,8 @@
1522215350 case 'K':
1522315351 KOMPACTTEXTURE ^= true;
1522415352 //textures.clear();
15225
- break;
15226
- case 'P': // Texture Projection macros
15353
+ // break;
15354
+ //case 'P': // Texture Projection macros
1522715355 // SAVETEXTURE ^= true;
1522815356 macromode = true;
1522915357 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15344,7 +15472,7 @@
1534415472 targetLookAt.set(manipCamera.lookAt);
1534515473 repaint();
1534615474 break;
15347
- case 'p':
15475
+ case 'P': // p':
1534815476 // c'est quoi ca au juste? spherical ^= true;
1534915477 Skinshader ^= true; programInitialized = false;
1535015478 repaint();
....@@ -15382,7 +15510,7 @@
1538215510 repaint();
1538315511 break;
1538415512 case 'O':
15385
- Globals.drawMode = OCCLUSION; // WARNING
15513
+ // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING
1538615514 repaint();
1538715515 break;
1538815516 case 'o':
....@@ -16104,7 +16232,7 @@
1610416232 {
1610516233 switch (hitSomething)
1610616234 {
16107
- case Object3D.hitCenter: gr.setColor(Color.pink);
16235
+ case Object3D.hitCenter: gr.setColor(Color.white);
1610816236 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1610916237 break;
1611016238 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -16130,7 +16258,7 @@
1613016258 if (hasMarquee)
1613116259 {
1613216260 gr.setXORMode(Color.white);
16133
- gr.setColor(Color.red);
16261
+ gr.setColor(Color.white);
1613416262 if (!firstime)
1613516263 {
1613616264 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16769,7 +16897,8 @@
1676916897 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1677016898
1677116899 cubemap.disable();
16772
- ////cubemap.unbind();
16900
+ //cubemap.dispose();
16901
+
1677316902 if (CULLFACE)
1677416903 {
1677516904 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16825,7 +16954,7 @@
1682516954 gl.glScalef(1.0f, -1.0f, 1.0f);
1682616955 }
1682716956
16828
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16957
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1682916958
1683016959 float step = 2; // 0.1666f; //0.25f;
1683116960 float stepv = 2; // step * 1652 / 998;
....@@ -17305,6 +17434,7 @@
1730517434
1730617435 public void init(GLAutoDrawable drawable)
1730717436 {
17437
+ if (Globals.DEBUG)
1730817438 System.out.println("shadow buffer init");
1730917439
1731017440 GL gl = drawable.getGL();
....@@ -17533,10 +17663,14 @@
1753317663 gl.glFlush();
1753417664
1753517665 /**/
17536
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17666
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1753717667
17538
- float[] pixels = occlusionsizebuffer.array();
17668
+ float[] depths = occlusiondepthbuffer.array();
1753917669
17670
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17671
+
17672
+ int[] pixels = selectsizebuffer.array();
17673
+
1754017674 double r = 0, g = 0, b = 0;
1754117675
1754217676 double count = 0;
....@@ -17547,7 +17681,7 @@
1754717681
1754817682 double FACTOR = 1;
1754917683
17550
- for (int i = 0; i < pixels.length; i++)
17684
+ for (int i = 0; i < depths.length; i++)
1755117685 {
1755217686 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1755317687 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17630,7 +17764,7 @@
1763017764
1763117765 double scale = ray.z; // 1; // cos
1763217766
17633
- float depth = pixels[newindex];
17767
+ float depth = depths[newindex];
1763417768
1763517769 /*
1763617770 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17827,11 +17961,14 @@
1782717961 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1782817962 static IntBuffer bigAAbuffer;
1782917963 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17830
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17964
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1783117965 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1783217966 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1783317967 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17834
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17968
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17969
+
17970
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17971
+
1783517972 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1783617973 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1783717974 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();