Normand Briere
2019-08-22 6a145f6c81dfcbe0653eda27d042efb48daa7512
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)
....@@ -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);
....@@ -8358,7 +8376,7 @@
83588376 // else
83598377 // if (!texname.startsWith("/"))
83608378 // texname = "/Users/nbriere/Textures/" + texname;
8361
- if (!FileExists(texname))
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
83628380 {
83638381 texname = fallbackTextureName;
83648382 }
....@@ -8441,6 +8459,15 @@
84418459 new Exception().printStackTrace();
84428460 } else
84438461 {
8462
+ if (texname.startsWith("@"))
8463
+ {
8464
+ // texturecache = textures.get(texname); // suspicious
8465
+ if (texturecache == null)
8466
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8467
+ else
8468
+ new Exception().printStackTrace();
8469
+ } else
8470
+ {
84448471 if (textureon)
84458472 {
84468473 String cachename = texname;
....@@ -8500,6 +8527,7 @@
85008527 texturecache = new CacheTexture(texturedata,resolution);
85018528 //texture = GetTexture(tex, bump);
85028529 }
8530
+ }
85038531 }
85048532 //}
85058533 }
....@@ -8768,10 +8796,12 @@
87688796
87698797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87708798 MAXSTACK = temp[0];
8771
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87728801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87738802 MAXSTACK = temp[0];
8774
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87758805
87768806 // Use debug pipeline
87778807 //drawable.setGL(new DebugGL(gl)); //
....@@ -8779,7 +8809,8 @@
87798809 gl = drawable.getGL(); //
87808810
87818811 GL gl3 = getGL();
8782
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87838814
87848815
87858816 //float pos[] = { 100, 100, 100, 0 };
....@@ -9220,6 +9251,8 @@
92209251
92219252 void LoadEnvy(int which)
92229253 {
9254
+ assert(false);
9255
+
92239256 String name;
92249257 String ext;
92259258
....@@ -9316,10 +9349,9 @@
93169349 double[] light2camera = new double[16];
93179350
93189351 //int newenvy = -1;
9319
- boolean envyoff = true; // false;
9320
- String skyboxname = "";
9321
- String skyboxext;
9322
- String loadedskyboxname = "";
9352
+ //boolean envyoff = false;
9353
+
9354
+ String loadedskyboxname;
93239355
93249356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
93259357 //float[] light0 = { 0,0,0 };
....@@ -10671,9 +10703,18 @@
1067110703 static boolean init = false;
1067210704
1067310705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
1067410709
1067510710 public void display(GLAutoDrawable drawable)
1067610711 {
10712
+ if (patchMaterial.patchMaterial)
10713
+ {
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
1067710718 if (Grafreed.savesound && Grafreed.hassound)
1067810719 {
1067910720 Grafreed.wav.save();
....@@ -10842,7 +10883,7 @@
1084210883
1084310884 if (wait)
1084410885 {
10845
- Sleep(500);
10886
+ Sleep(200); // blocks everything
1084610887
1084710888 wait = false;
1084810889 }
....@@ -11065,10 +11106,34 @@
1106511106 //
1106611107 // newenvy = -1;
1106711108
11068
- if (!skyboxname.equals(this.loadedskyboxname))
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1106911110 {
11070
- LoadSkybox(skyboxname + "/", skyboxext, false);
11071
- loadedskyboxname = skyboxname;
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
11117
+ }
11118
+ else
11119
+ {
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;
1107211137 }
1107311138
1107411139 ratio = ((double) getWidth()) / getHeight();
....@@ -11372,7 +11437,7 @@
1137211437
1137311438 // if (cam != lightCamera)
1137411439 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11375
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11440
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1137611441 }
1137711442
1137811443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12446,7 +12511,7 @@
1244612511
1244712512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1244812513
12449
- String program0 =
12514
+ String programmin =
1245012515 // Min shader
1245112516 "!!ARBfp1.0\n" +
1245212517 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12513,7 +12578,7 @@
1251312578 "MOV result.color, temp;" +
1251412579 "END";
1251512580
12516
- String program =
12581
+ String programmax =
1251712582 "!!ARBfp1.0\n" +
1251812583
1251912584 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12541,7 +12606,7 @@
1254112606 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1254212607 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1254312608 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12544
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12609
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1254512610 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1254612611 "PARAM options1 = program.env[62];" + // fog rgb color
1254712612 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12786,7 +12851,7 @@
1278612851 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1278712852 // mar 2013 ??? "KIL alpha.a;" +
1278812853 "MOV alpha, texSamp.aaaa;" + // y;" +
12789
- "KIL alpha.a;" +
12854
+ "KIL alpha.a;" + // not sure with parallax mapping
1279012855 /*
1279112856 "MUL temp.xy, temp, two;" +
1279212857 "TXB bump, temp, texture[0], 2D;" +
....@@ -12872,11 +12937,6 @@
1287212937 "SUB bump0, bump0, half;" +
1287312938 "ADD bump, bump, bump0;" +
1287412939
12875
- "MOV temp.x, texSamp.a;" +
12876
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12877
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12878
- "MOV texSamp.a, temp.x;" +
12879
-
1288012940 // double-sided
1288112941 /**/
1288212942 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12893,19 +12953,62 @@
1289312953 "MOV normald, normal;" +
1289412954 "MOV normals, normal;" +
1289512955
12956
+ "MOV temp, fragment.texcoord[4];" +
12957
+
1289612958 // UV base
1289712959 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1289812960 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1289912961 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12900
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12901
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12902
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12962
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12963
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12964
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12965
+ Normalize("UP") +
12966
+
1290312967 "XPD V, normal, UP;" +
1290412968 Normalize("V") +
1290512969 "XPD U, V, normal;" +
1290612970 Normalize("U") +
1290712971
1290812972 // parallax mapping
12973
+
12974
+ "DP3 temp2.x, V, eye;" +
12975
+ "DP3 temp2.y, U, eye;" +
12976
+ "DP3 temp2.z, normal, eye;" +
12977
+ "RCP temp2.z, temp2.z;" +
12978
+
12979
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12980
+ "RSQ temp2.w, temp2.w;" +
12981
+ "RCP temp2.w, temp2.w;" +
12982
+
12983
+ "SUB temp2.w, temp2.w, half;" +
12984
+// "SGE temp.x, temp2.w, eps.x;" +
12985
+// "MUL temp2.w, temp2.w, temp.x;" +
12986
+
12987
+ //"MOV texSamp, U;" +
12988
+
12989
+ "MUL temp2.z, temp2.z, temp2.w;" +
12990
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12991
+
12992
+ "MUL temp2, temp2, temp2.z;" +
12993
+
12994
+ "MOV temp, fragment.texcoord[0];" +
12995
+
12996
+ "SUB temp, temp, temp2;" +
12997
+
12998
+ "TEX temp, temp, texture[0], 2D;" +
12999
+ "POW temp.a, temp.a, params6.w;" + // punch through
13000
+
13001
+ "ADD texSamp, temp, texSamp;" +
13002
+ "MUL texSamp.xyz, half, texSamp;" +
13003
+
13004
+ "MOV alpha, texSamp.aaaa;" +
13005
+
13006
+// parallax mapping
13007
+
13008
+ "MOV temp.x, texSamp.a;" +
13009
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13010
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13011
+ "MOV texSamp.a, temp.x;" +
1290913012
1291013013 //"MOV temp, fragment.texcoord[0];" +
1291113014 //
....@@ -13369,8 +13472,19 @@
1336913472 //once = true;
1337013473 }
1337113474
13372
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13373
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13475
+ String program = programmax;
13476
+
13477
+ if (Globals.MINSHADER)
13478
+ {
13479
+ program = programmin;
13480
+ }
13481
+
13482
+ if (Globals.DEBUG)
13483
+ {
13484
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13485
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13486
+ }
13487
+
1337413488 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513489
1337613490 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13417,7 +13531,8 @@
1341713531 "\n" +
1341813532 "END\n";
1341913533
13420
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13534
+ if (Globals.DEBUG)
13535
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1342113536 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1342213537
1342313538 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13675,7 +13790,7 @@
1367513790 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1367613791 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1367713792 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13678
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13793
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1367913794
1368013795 //Object3D.cVector2[] vector2buffer;
1368113796
....@@ -13842,7 +13957,7 @@
1384213957 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1384313958 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1384413959 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13845
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13960
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1384613961 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1384713962 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1384813963 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13903,7 +14018,7 @@
1390314018 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1390414019 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1390514020 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
13906
- //"MOV result.texcoord, vertex.texcoord;" +
14021
+ //"MOV result.texcoord, vertex.fogcoord;" +
1390714022 "MOV result.texcoord, temp;" +
1390814023 // border fade
1390914024 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -13950,7 +14065,9 @@
1395014065
1395114066 //"ADD temp.z, temp.z, one;" +
1395214067
13953
- "MOV result.color, temp;"
14068
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14069
+
14070
+ "MOV result.color, temp;" // Normal
1395414071 : "MOV result.color, vertex.color;") +
1395514072 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1395614073 : "") +
....@@ -14616,11 +14733,17 @@
1461614733 void GoDown(int mod)
1461714734 {
1461814735 MODIFIERS |= COMMAND;
14736
+ boolean isVR = (mouseMode&VR)!=0;
1461914737 /**/
1462014738 if((mod&SHIFT) == SHIFT)
14621
- manipCamera.RotatePosition(0, -speed);
14739
+ {
14740
+ if (isVR)
14741
+ manipCamera.RotateInterest(0, -speed);
14742
+ else
14743
+ manipCamera.RotatePosition(0, -speed);
14744
+ }
1462214745 else
14623
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14746
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1462414747 /**/
1462514748 if ((mod & SHIFT) == SHIFT)
1462614749 {
....@@ -14630,6 +14753,8 @@
1463014753 mouseMode |= BACKFORTH;
1463114754 }
1463214755
14756
+ targetLookAt.set(manipCamera.lookAt);
14757
+
1463314758 //prevX = X = anchorX;
1463414759 prevY = Y = anchorY - (int) (renderCamera.Distance());
1463514760 }
....@@ -14638,10 +14763,17 @@
1463814763 {
1463914764 MODIFIERS |= COMMAND;
1464014765 /**/
14766
+ boolean isVR = (mouseMode&VR)!=0;
14767
+
1464114768 if((mod&SHIFT) == SHIFT)
14642
- manipCamera.RotatePosition(0, speed);
14769
+ {
14770
+ if (isVR)
14771
+ manipCamera.RotateInterest(0, speed);
14772
+ else
14773
+ manipCamera.RotatePosition(0, speed);
14774
+ }
1464314775 else
14644
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14776
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1464514777 /**/
1464614778 if ((mod & SHIFT) == SHIFT)
1464714779 {
....@@ -14651,6 +14783,8 @@
1465114783 mouseMode |= BACKFORTH;
1465214784 }
1465314785
14786
+ targetLookAt.set(manipCamera.lookAt);
14787
+
1465414788 //prevX = X = anchorX;
1465514789 prevY = Y = anchorY + (int) (renderCamera.Distance());
1465614790 }
....@@ -14660,9 +14794,14 @@
1466014794 MODIFIERS |= COMMAND;
1466114795 /**/
1466214796 if((mod&SHIFT) == SHIFT)
14663
- manipCamera.Translate(speed*delta, 0, getWidth());
14797
+ manipCamera.Translate(speed*delta, 0, getWidth());
1466414798 else
14665
- manipCamera.RotatePosition(speed, 0);
14799
+ {
14800
+ if ((mouseMode&VR)!=0)
14801
+ manipCamera.RotateInterest(-speed, 0);
14802
+ else
14803
+ manipCamera.RotatePosition(speed, 0);
14804
+ }
1466614805 /**/
1466714806 if ((mod & SHIFT) == SHIFT)
1466814807 {
....@@ -14672,6 +14811,8 @@
1467214811 mouseMode |= ROTATE;
1467314812 } // TRANSLATE;
1467414813
14814
+ targetLookAt.set(manipCamera.lookAt);
14815
+
1467514816 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1467614817 prevY = Y = anchorY;
1467714818 }
....@@ -14681,9 +14822,15 @@
1468114822 MODIFIERS |= COMMAND;
1468214823 /**/
1468314824 if((mod&SHIFT) == SHIFT)
14684
- manipCamera.Translate(-speed*delta, 0, getWidth());
14825
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1468514826 else
14686
- manipCamera.RotatePosition(-speed, 0);
14827
+ {
14828
+ if ((mouseMode&VR)!=0)
14829
+ manipCamera.RotateInterest(speed, 0);
14830
+ else
14831
+ manipCamera.RotatePosition(-speed, 0);
14832
+ }
14833
+
1468714834 /**/
1468814835 if ((mod & SHIFT) == SHIFT)
1468914836 {
....@@ -14693,6 +14840,8 @@
1469314840 mouseMode |= ROTATE;
1469414841 } // TRANSLATE;
1469514842
14843
+ targetLookAt.set(manipCamera.lookAt);
14844
+
1469614845 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1469714846 prevY = Y = anchorY;
1469814847 }
....@@ -15195,8 +15344,8 @@
1519515344 case 'K':
1519615345 KOMPACTTEXTURE ^= true;
1519715346 //textures.clear();
15198
- break;
15199
- case 'P': // Texture Projection macros
15347
+ // break;
15348
+ //case 'P': // Texture Projection macros
1520015349 // SAVETEXTURE ^= true;
1520115350 macromode = true;
1520215351 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15317,7 +15466,7 @@
1531715466 targetLookAt.set(manipCamera.lookAt);
1531815467 repaint();
1531915468 break;
15320
- case 'p':
15469
+ case 'P': // p':
1532115470 // c'est quoi ca au juste? spherical ^= true;
1532215471 Skinshader ^= true; programInitialized = false;
1532315472 repaint();
....@@ -15362,7 +15511,7 @@
1536215511 OCCLUSION_CULLING ^= true;
1536315512 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415513 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15514
+ //case '0': envyoff ^= true; repaint(); break;
1536615515 case '1':
1536715516 case '2':
1536815517 case '3':
....@@ -15372,7 +15521,7 @@
1537215521 case '7':
1537315522 case '8':
1537415523 case '9':
15375
- if (envyoff)
15524
+ if (true) // envyoff)
1537615525 {
1537715526 BGcolor = (key - '1')/8.f;
1537815527 }
....@@ -16077,14 +16226,14 @@
1607716226 {
1607816227 switch (hitSomething)
1607916228 {
16080
- case Object3D.hitCenter: gr.setColor(Color.pink);
16229
+ case Object3D.hitCenter: gr.setColor(Color.white);
1608116230 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608216231 break;
1608316232 case Object3D.hitRotate: gr.setColor(Color.yellow);
1608416233 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516234 break;
1608616235 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16236
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816237 break;
1608916238 }
1609016239
....@@ -16103,7 +16252,7 @@
1610316252 if (hasMarquee)
1610416253 {
1610516254 gr.setXORMode(Color.white);
16106
- gr.setColor(Color.red);
16255
+ gr.setColor(Color.white);
1610716256 if (!firstime)
1610816257 {
1610916258 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16570,6 +16719,8 @@
1657016719 private /*static*/ boolean firstime;
1657116720 private /*static*/ cVector newView = new cVector();
1657216721 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16722
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16723
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316724 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416725 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516726 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16733,56 @@
1658216733 {
1658316734 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416735
16736
+ int usedsuf = 0;
16737
+
1658516738 for (int i = 0; i < suffixes.length; i++)
1658616739 {
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)
16740
+ String[] suffixe = suffixes;
16741
+ String[] fallback = suffixes2;
16742
+ String[] fallfallback = suffixes3;
16743
+
16744
+ for (int c=usedsuf; --c>=0;)
1659216745 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16746
+// String[] temp = suffixe;
16747
+// suffixe = fallback;
16748
+// fallback = fallfallback;
16749
+// fallfallback = temp;
1659416750 }
16751
+
16752
+ String resourceName = basename + suffixe[i] + "." + suffix;
16753
+ TextureData data;
16754
+
16755
+ try
16756
+ {
16757
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16758
+ mipmapped,
16759
+ FileUtil.getFileSuffix(resourceName));
16760
+ }
16761
+ catch (Exception e)
16762
+ {
16763
+ try
16764
+ {
16765
+ resourceName = basename + fallback[i] + "." + suffix;
16766
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16767
+ mipmapped,
16768
+ FileUtil.getFileSuffix(resourceName));
16769
+ }
16770
+ catch (Exception e2)
16771
+ {
16772
+ resourceName = basename + fallfallback[i] + "." + suffix;
16773
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16774
+ mipmapped,
16775
+ FileUtil.getFileSuffix(resourceName));
16776
+ }
16777
+ }
16778
+
1659516779 //System.out.println("Target = " + targets[i]);
1659616780 cubemap.updateImage(data, targets[i]);
1659716781 }
1659816782
1659916783 return cubemap;
1660016784 }
16785
+
1660116786 int bigsphere = -1;
1660216787
1660316788 float BGcolor = 0.5f;
....@@ -16606,7 +16791,9 @@
1660616791
1660716792 private void DrawSkyBox(GL gl, float ratio)
1660816793 {
16609
- if (envyoff || cubemap == null)
16794
+ if (//envyoff ||
16795
+ WIREFRAME ||
16796
+ cubemap == null)
1661016797 {
1661116798 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216799 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16623,14 +16810,14 @@
1662316810 gl.glLoadIdentity();
1662416811 gl.glScalef(1,ratio,1);
1662516812
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);
16813
+// colorV[0] = 2;
16814
+// colorV[1] = 2;
16815
+// colorV[2] = 2;
16816
+// colorV[3] = 1;
16817
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16818
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16819
+//
16820
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1663416821
1663516822 //gl.glActiveTexture(GL.GL_TEXTURE1);
1663616823 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16644,7 +16831,7 @@
1664416831 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1664516832 // causes the normals to be sent down. Thanks to Ken Dyke.
1664616833 //gl.glEnable(GL.GL_LIGHTING);
16647
- gl.glEnable(GL.GL_LIGHTING);
16834
+ gl.glDisable(GL.GL_LIGHTING);
1664816835
1664916836 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1665016837 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16663,6 +16850,7 @@
1666316850 {
1666416851 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516852 }
16853
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616854 gl.glMultMatrixd(viewrot_1, 0);
1666716855 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816856 //viewer.updateInverseRotation(gl);
....@@ -16703,7 +16891,8 @@
1670316891 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1670416892
1670516893 cubemap.disable();
16706
- ////cubemap.unbind();
16894
+ //cubemap.dispose();
16895
+
1670716896 if (CULLFACE)
1670816897 {
1670916898 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16759,7 +16948,7 @@
1675916948 gl.glScalef(1.0f, -1.0f, 1.0f);
1676016949 }
1676116950
16762
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16951
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1676316952
1676416953 float step = 2; // 0.1666f; //0.25f;
1676516954 float stepv = 2; // step * 1652 / 998;
....@@ -17239,6 +17428,7 @@
1723917428
1724017429 public void init(GLAutoDrawable drawable)
1724117430 {
17431
+ if (Globals.DEBUG)
1724217432 System.out.println("shadow buffer init");
1724317433
1724417434 GL gl = drawable.getGL();
....@@ -17467,10 +17657,14 @@
1746717657 gl.glFlush();
1746817658
1746917659 /**/
17470
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17660
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1747117661
17472
- float[] pixels = occlusionsizebuffer.array();
17662
+ float[] depths = occlusiondepthbuffer.array();
1747317663
17664
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17665
+
17666
+ int[] pixels = selectsizebuffer.array();
17667
+
1747417668 double r = 0, g = 0, b = 0;
1747517669
1747617670 double count = 0;
....@@ -17481,7 +17675,7 @@
1748117675
1748217676 double FACTOR = 1;
1748317677
17484
- for (int i = 0; i < pixels.length; i++)
17678
+ for (int i = 0; i < depths.length; i++)
1748517679 {
1748617680 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1748717681 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17564,7 +17758,7 @@
1756417758
1756517759 double scale = ray.z; // 1; // cos
1756617760
17567
- float depth = pixels[newindex];
17761
+ float depth = depths[newindex];
1756817762
1756917763 /*
1757017764 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17761,11 +17955,14 @@
1776117955 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1776217956 static IntBuffer bigAAbuffer;
1776317957 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17764
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17958
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1776517959 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1776617960 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1776717961 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17768
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17962
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17963
+
17964
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17965
+
1776917966 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1777017967 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1777117968 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();