Normand Briere
2019-08-20 564f4d12d93813b5d680fc24d4f118c3886d96ed
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
....@@ -187,6 +191,19 @@
187191 }
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
194
+
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196
+ {
197
+ try
198
+ {
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
200
+ } catch (IOException e)
201
+ {
202
+ System.out.println("NAME = " + name);
203
+ e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
205
+ }
206
+ }
190207
191208 void SetAsGLRenderer(boolean b)
192209 {
....@@ -1485,6 +1502,8 @@
14851502 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14861503 }
14871504
1505
+ float[] colorV = new float[4];
1506
+
14881507 void SetColor(Object3D obj, Vertex p0)
14891508 {
14901509 CameraPane display = this;
....@@ -1552,8 +1571,6 @@
15521571 {
15531572 return;
15541573 }
1555
-
1556
- float[] colorV = new float[3];
15571574
15581575 if (false) // marked)
15591576 {
....@@ -1802,7 +1819,7 @@
18021819
18031820 display.modelParams7[0] = 0;
18041821 display.modelParams7[1] = 1000;
1805
- display.modelParams7[2] = 0;
1822
+ display.modelParams7[2] = material.parallax;
18061823 display.modelParams7[3] = 0;
18071824
18081825 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2035,9 +2052,9 @@
20352052 switch(viewcode)
20362053 {
20372054 case 0: return "main";
2038
- case 1: return "one";
2039
- case 2: return "two";
2040
- case 3: return "three";
2055
+ case 1: return "Red";
2056
+ case 2: return "Green";
2057
+ case 3: return "Blue";
20412058 case 4: return "light";
20422059 }
20432060
....@@ -2500,7 +2517,7 @@
25002517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25012518 getClass().getClassLoader().getResourceAsStream(name),
25022519 true,
2503
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25042521 } catch (java.io.IOException e)
25052522 {
25062523 throw new javax.media.opengl.GLException(e);
....@@ -8346,7 +8363,7 @@
83468363 // else
83478364 // if (!texname.startsWith("/"))
83488365 // texname = "/Users/nbriere/Textures/" + texname;
8349
- if (!FileExists(texname))
8366
+ if (!FileExists(texname) && !texname.startsWith("@"))
83508367 {
83518368 texname = fallbackTextureName;
83528369 }
....@@ -8429,6 +8446,15 @@
84298446 new Exception().printStackTrace();
84308447 } else
84318448 {
8449
+ if (texname.startsWith("@"))
8450
+ {
8451
+ // texturecache = textures.get(texname); // suspicious
8452
+ if (texturecache == null)
8453
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8454
+ else
8455
+ new Exception().printStackTrace();
8456
+ } else
8457
+ {
84328458 if (textureon)
84338459 {
84348460 String cachename = texname;
....@@ -8488,6 +8514,7 @@
84888514 texturecache = new CacheTexture(texturedata,resolution);
84898515 //texture = GetTexture(tex, bump);
84908516 }
8517
+ }
84918518 }
84928519 //}
84938520 }
....@@ -8756,10 +8783,12 @@
87568783
87578784 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87588785 MAXSTACK = temp[0];
8759
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8786
+ if (Globals.DEBUG)
8787
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87608788 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87618789 MAXSTACK = temp[0];
8762
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8790
+ if (Globals.DEBUG)
8791
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87638792
87648793 // Use debug pipeline
87658794 //drawable.setGL(new DebugGL(gl)); //
....@@ -8767,7 +8796,8 @@
87678796 gl = drawable.getGL(); //
87688797
87698798 GL gl3 = getGL();
8770
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87718801
87728802
87738803 //float pos[] = { 100, 100, 100, 0 };
....@@ -8932,7 +8962,7 @@
89328962
89338963 if (cubemap == null)
89348964 {
8935
- LoadEnvy(5);
8965
+ //LoadEnvy(1);
89368966 }
89378967
89388968 //cubemap.enable();
....@@ -9208,6 +9238,8 @@
92089238
92099239 void LoadEnvy(int which)
92109240 {
9241
+ assert(false);
9242
+
92119243 String name;
92129244 String ext;
92139245
....@@ -9219,37 +9251,58 @@
92199251 cubemap = null;
92209252 return;
92219253 case 1:
9222
- name = "cubemaps/box_";
9223
- ext = "png";
9254
+ name = "cubemaps/rgb/";
9255
+ ext = "jpg";
92249256 reverseUP = false;
92259257 break;
92269258 case 2:
9227
- name = "cubemaps/uffizi_";
9228
- ext = "png";
9229
- break; // reverseUP = true; break;
9259
+ name = "cubemaps/uffizi/";
9260
+ ext = "jpg";
9261
+ reverseUP = false;
9262
+ break;
92309263 case 3:
9231
- name = "cubemaps/CloudyHills_";
9232
- ext = "tga";
9264
+ name = "cubemaps/CloudyHills/";
9265
+ ext = "jpg";
92339266 reverseUP = false;
92349267 break;
92359268 case 4:
9236
- name = "cubemaps/cornell_";
9269
+ name = "cubemaps/cornell/";
92379270 ext = "png";
92389271 reverseUP = false;
92399272 break;
9273
+ case 5:
9274
+ name = "cubemaps/skycube/";
9275
+ ext = "jpg";
9276
+ reverseUP = false;
9277
+ break;
9278
+ case 6:
9279
+ name = "cubemaps/SaintLazarusChurch3/";
9280
+ ext = "jpg";
9281
+ reverseUP = false;
9282
+ break;
9283
+ case 7:
9284
+ name = "cubemaps/Sodermalmsallen/";
9285
+ ext = "jpg";
9286
+ reverseUP = false;
9287
+ break;
9288
+ case 8:
9289
+ name = "cubemaps/Sodermalmsallen2/";
9290
+ ext = "jpg";
9291
+ reverseUP = false;
9292
+ break;
9293
+ case 9:
9294
+ name = "cubemaps/UnionSquare/";
9295
+ ext = "jpg";
9296
+ reverseUP = false;
9297
+ break;
92409298 default:
9241
- name = "cubemaps/rgb_";
9242
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9299
+ name = "cubemaps/box/";
9300
+ ext = "png"; /*mipmap = true;*/
9301
+ reverseUP = false;
92439302 break;
92449303 }
9245
-
9246
- try
9247
- {
9248
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9249
- } catch (IOException e)
9250
- {
9251
- throw new RuntimeException(e);
9252
- }
9304
+
9305
+ LoadSkybox(name, ext, mipmap);
92539306 }
92549307
92559308 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9281,8 +9334,12 @@
92819334 static double[] model = new double[16];
92829335 double[] camera2light = new double[16];
92839336 double[] light2camera = new double[16];
9284
- int newenvy = -1;
9285
- boolean envyoff = true; // false;
9337
+
9338
+ //int newenvy = -1;
9339
+ //boolean envyoff = false;
9340
+
9341
+ String loadedskyboxname;
9342
+
92869343 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92879344 //float[] light0 = { 0,0,0 };
92889345 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9762,10 +9819,12 @@
97629819 rati = 1 / rati;
97639820 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97649821 }
9765
- assert (newenvy == -1);
9822
+
9823
+ //assert (newenvy == -1);
9824
+
97669825 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97679826 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9768
- DrawSkyBox(gl);
9827
+ DrawSkyBox(gl, (float)rati);
97699828 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97709829 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97719830 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10631,9 +10690,18 @@
1063110690 static boolean init = false;
1063210691
1063310692 double[][] matrix = LA.newMatrix();
10693
+
10694
+ // This is to refresh the UI of the material panel.
10695
+ ObjEditor patchMaterial;
1063410696
1063510697 public void display(GLAutoDrawable drawable)
1063610698 {
10699
+ if (patchMaterial.patchMaterial)
10700
+ {
10701
+ patchMaterial.patchMaterial = false;
10702
+ patchMaterial.objectPanel.setSelectedIndex(1);
10703
+ }
10704
+
1063710705 if (Grafreed.savesound && Grafreed.hassound)
1063810706 {
1063910707 Grafreed.wav.save();
....@@ -10802,7 +10870,7 @@
1080210870
1080310871 if (wait)
1080410872 {
10805
- Sleep(500);
10873
+ Sleep(200); // blocks everything
1080610874
1080710875 wait = false;
1080810876 }
....@@ -11018,13 +11086,43 @@
1101811086 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101911087 }
1102011088
11021
- if (newenvy > -1)
11089
+// if (newenvy > -1)
11090
+// {
11091
+// LoadEnvy(newenvy);
11092
+// }
11093
+//
11094
+// newenvy = -1;
11095
+
11096
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1102211097 {
11023
- LoadEnvy(newenvy);
11098
+ if (cubemaprgb == null)
11099
+ {
11100
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11101
+ }
11102
+
11103
+ cubemap = cubemaprgb;
1102411104 }
11025
-
11026
- newenvy = -1;
11027
-
11105
+ else
11106
+ {
11107
+ if (object.skyboxname != null)
11108
+ {
11109
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11110
+ {
11111
+ if (cubemap != null && cubemap != cubemaprgb)
11112
+ cubemap.dispose();
11113
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11114
+ loadedskyboxname = object.skyboxname;
11115
+ }
11116
+ }
11117
+ else
11118
+ {
11119
+ cubemapcustom = null;
11120
+ loadedskyboxname = null;
11121
+ }
11122
+
11123
+ cubemap = cubemapcustom;
11124
+ }
11125
+
1102811126 ratio = ((double) getWidth()) / getHeight();
1102911127 //System.out.println("ratio = " + ratio);
1103011128
....@@ -11040,7 +11138,7 @@
1104011138
1104111139 if (!IsFrozen() && !ambientOcclusion)
1104211140 {
11043
- DrawSkyBox(gl);
11141
+ DrawSkyBox(gl, (float)ratio);
1104411142 }
1104511143
1104611144 //if (selection_view == -1)
....@@ -11326,7 +11424,7 @@
1132611424
1132711425 // if (cam != lightCamera)
1132811426 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11329
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11427
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1133011428 }
1133111429
1133211430 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12400,7 +12498,7 @@
1240012498
1240112499 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240212500
12403
- String program =
12501
+ String programmin =
1240412502 // Min shader
1240512503 "!!ARBfp1.0\n" +
1240612504 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12451,7 +12549,8 @@
1245112549 //"SUB ndotl.y, zero123.y, ndotl.y;" +
1245212550 //"MUL ndotl.y, ndotl.y, pow2.z;" +
1245312551
12454
- "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12552
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12553
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
1245512554
1245612555 // Pigment
1245712556 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
....@@ -12466,7 +12565,7 @@
1246612565 "MOV result.color, temp;" +
1246712566 "END";
1246812567
12469
- String program2 =
12568
+ String programmax =
1247012569 "!!ARBfp1.0\n" +
1247112570
1247212571 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12494,7 +12593,7 @@
1249412593 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1249512594 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1249612595 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12497
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12596
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1249812597 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1249912598 "PARAM options1 = program.env[62];" + // fog rgb color
1250012599 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12739,7 +12838,7 @@
1273912838 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1274012839 // mar 2013 ??? "KIL alpha.a;" +
1274112840 "MOV alpha, texSamp.aaaa;" + // y;" +
12742
- "KIL alpha.a;" +
12841
+ "KIL alpha.a;" + // not sure with parallax mapping
1274312842 /*
1274412843 "MUL temp.xy, temp, two;" +
1274512844 "TXB bump, temp, texture[0], 2D;" +
....@@ -12825,11 +12924,6 @@
1282512924 "SUB bump0, bump0, half;" +
1282612925 "ADD bump, bump, bump0;" +
1282712926
12828
- "MOV temp.x, texSamp.a;" +
12829
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12830
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12831
- "MOV texSamp.a, temp.x;" +
12832
-
1283312927 // double-sided
1283412928 /**/
1283512929 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12859,6 +12953,41 @@
1285912953 Normalize("U") +
1286012954
1286112955 // parallax mapping
12956
+
12957
+ "DP3 temp2.x, V, eye;" +
12958
+ "DP3 temp2.y, U, eye;" +
12959
+ "DP3 temp2.z, normal, eye;" +
12960
+ "RCP temp2.z, temp2.z;" +
12961
+
12962
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12963
+ "RSQ temp2.w, temp2.w;" +
12964
+ "RCP temp2.w, temp2.w;" +
12965
+
12966
+ "SUB temp2.w, temp2.w, half;" +
12967
+// "SGE temp.x, temp2.w, eps.x;" +
12968
+// "MUL temp2.w, temp2.w, temp.x;" +
12969
+
12970
+ //"MOV texSamp, U;" +
12971
+
12972
+ "MUL temp2.z, temp2.z, temp2.w;" +
12973
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12974
+
12975
+ "MUL temp2, temp2, temp2.z;" +
12976
+
12977
+ "MOV temp, fragment.texcoord[0];" +
12978
+
12979
+ "SUB temp, temp, temp2;" +
12980
+
12981
+ "TEX texSamp, temp, texture[0], 2D;" +
12982
+ "POW texSamp.a, texSamp.a, params6.w;" + // punch through
12983
+ "MOV alpha, texSamp.aaaa;" +
12984
+
12985
+// parallax mapping
12986
+
12987
+ "MOV temp.x, texSamp.a;" +
12988
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12989
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
12990
+ "MOV texSamp.a, temp.x;" +
1286212991
1286312992 //"MOV temp, fragment.texcoord[0];" +
1286412993 //
....@@ -12991,7 +13120,7 @@
1299113120 // display shadow only (fakedepth == 0)
1299213121 "SUB temp.x, half.x, shadow.x;" +
1299313122 "MOV temp.y, -params5.z;" + // params6.x;" +
12994
- "SLT temp.z, temp.y, -one2048th.x;" +
13123
+ "SLT temp.z, temp.y, -c256i.x;" +
1299513124 "SUB temp.y, one.x, temp.z;" +
1299613125 "MUL temp.x, temp.x, temp.y;" +
1299713126 "KIL temp.x;" +
....@@ -13322,8 +13451,19 @@
1332213451 //once = true;
1332313452 }
1332413453
13325
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13326
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13454
+ String program = programmax;
13455
+
13456
+ if (Globals.MINSHADER)
13457
+ {
13458
+ program = programmin;
13459
+ }
13460
+
13461
+ if (Globals.DEBUG)
13462
+ {
13463
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13464
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13465
+ }
13466
+
1332713467 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1332813468
1332913469 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13370,7 +13510,8 @@
1337013510 "\n" +
1337113511 "END\n";
1337213512
13373
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13513
+ if (Globals.DEBUG)
13514
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1337413515 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513516
1337613517 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13628,7 +13769,7 @@
1362813769 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1362913770 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1363013771 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13631
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13772
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1363213773
1363313774 //Object3D.cVector2[] vector2buffer;
1363413775
....@@ -14569,11 +14710,17 @@
1456914710 void GoDown(int mod)
1457014711 {
1457114712 MODIFIERS |= COMMAND;
14713
+ boolean isVR = (mouseMode&VR)!=0;
1457214714 /**/
1457314715 if((mod&SHIFT) == SHIFT)
14574
- manipCamera.RotatePosition(0, -speed);
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, -speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, -speed);
14721
+ }
1457514722 else
14576
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14723
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1457714724 /**/
1457814725 if ((mod & SHIFT) == SHIFT)
1457914726 {
....@@ -14583,6 +14730,8 @@
1458314730 mouseMode |= BACKFORTH;
1458414731 }
1458514732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1458614735 //prevX = X = anchorX;
1458714736 prevY = Y = anchorY - (int) (renderCamera.Distance());
1458814737 }
....@@ -14591,10 +14740,17 @@
1459114740 {
1459214741 MODIFIERS |= COMMAND;
1459314742 /**/
14743
+ boolean isVR = (mouseMode&VR)!=0;
14744
+
1459414745 if((mod&SHIFT) == SHIFT)
14595
- manipCamera.RotatePosition(0, speed);
14746
+ {
14747
+ if (isVR)
14748
+ manipCamera.RotateInterest(0, speed);
14749
+ else
14750
+ manipCamera.RotatePosition(0, speed);
14751
+ }
1459614752 else
14597
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14753
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1459814754 /**/
1459914755 if ((mod & SHIFT) == SHIFT)
1460014756 {
....@@ -14604,6 +14760,8 @@
1460414760 mouseMode |= BACKFORTH;
1460514761 }
1460614762
14763
+ targetLookAt.set(manipCamera.lookAt);
14764
+
1460714765 //prevX = X = anchorX;
1460814766 prevY = Y = anchorY + (int) (renderCamera.Distance());
1460914767 }
....@@ -14613,9 +14771,14 @@
1461314771 MODIFIERS |= COMMAND;
1461414772 /**/
1461514773 if((mod&SHIFT) == SHIFT)
14616
- manipCamera.Translate(speed*delta, 0, getWidth());
14774
+ manipCamera.Translate(speed*delta, 0, getWidth());
1461714775 else
14618
- manipCamera.RotatePosition(speed, 0);
14776
+ {
14777
+ if ((mouseMode&VR)!=0)
14778
+ manipCamera.RotateInterest(-speed, 0);
14779
+ else
14780
+ manipCamera.RotatePosition(speed, 0);
14781
+ }
1461914782 /**/
1462014783 if ((mod & SHIFT) == SHIFT)
1462114784 {
....@@ -14625,6 +14788,8 @@
1462514788 mouseMode |= ROTATE;
1462614789 } // TRANSLATE;
1462714790
14791
+ targetLookAt.set(manipCamera.lookAt);
14792
+
1462814793 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1462914794 prevY = Y = anchorY;
1463014795 }
....@@ -14634,9 +14799,15 @@
1463414799 MODIFIERS |= COMMAND;
1463514800 /**/
1463614801 if((mod&SHIFT) == SHIFT)
14637
- manipCamera.Translate(-speed*delta, 0, getWidth());
14802
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1463814803 else
14639
- manipCamera.RotatePosition(-speed, 0);
14804
+ {
14805
+ if ((mouseMode&VR)!=0)
14806
+ manipCamera.RotateInterest(speed, 0);
14807
+ else
14808
+ manipCamera.RotatePosition(-speed, 0);
14809
+ }
14810
+
1464014811 /**/
1464114812 if ((mod & SHIFT) == SHIFT)
1464214813 {
....@@ -14646,6 +14817,8 @@
1464614817 mouseMode |= ROTATE;
1464714818 } // TRANSLATE;
1464814819
14820
+ targetLookAt.set(manipCamera.lookAt);
14821
+
1464914822 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1465014823 prevY = Y = anchorY;
1465114824 }
....@@ -15148,8 +15321,8 @@
1514815321 case 'K':
1514915322 KOMPACTTEXTURE ^= true;
1515015323 //textures.clear();
15151
- break;
15152
- case 'P': // Texture Projection macros
15324
+ // break;
15325
+ //case 'P': // Texture Projection macros
1515315326 // SAVETEXTURE ^= true;
1515415327 macromode = true;
1515515328 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15270,7 +15443,7 @@
1527015443 targetLookAt.set(manipCamera.lookAt);
1527115444 repaint();
1527215445 break;
15273
- case 'p':
15446
+ case 'P': // p':
1527415447 // c'est quoi ca au juste? spherical ^= true;
1527515448 Skinshader ^= true; programInitialized = false;
1527615449 repaint();
....@@ -15315,20 +15488,24 @@
1531515488 OCCLUSION_CULLING ^= true;
1531615489 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1531715490 break;
15318
- case '0': envyoff ^= true; repaint(); break;
15491
+ //case '0': envyoff ^= true; repaint(); break;
1531915492 case '1':
1532015493 case '2':
1532115494 case '3':
1532215495 case '4':
1532315496 case '5':
15324
- newenvy = Character.getNumericValue(key);
15325
- repaint();
15326
- break;
1532715497 case '6':
1532815498 case '7':
1532915499 case '8':
1533015500 case '9':
15331
- BGcolor = (key - '6')/3.f;
15501
+ if (true) // envyoff)
15502
+ {
15503
+ BGcolor = (key - '1')/8.f;
15504
+ }
15505
+ else
15506
+ {
15507
+ //newenvy = Character.getNumericValue(key);
15508
+ }
1533215509 repaint();
1533315510 break;
1533415511 case '!':
....@@ -16026,14 +16203,14 @@
1602616203 {
1602716204 switch (hitSomething)
1602816205 {
16029
- case Object3D.hitCenter: gr.setColor(Color.pink);
16206
+ case Object3D.hitCenter: gr.setColor(Color.white);
1603016207 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603116208 break;
1603216209 case Object3D.hitRotate: gr.setColor(Color.yellow);
1603316210 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603416211 break;
1603516212 case Object3D.hitScale: gr.setColor(Color.cyan);
16036
- gr.drawLine(X, Y, 0, 0);
16213
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603716214 break;
1603816215 }
1603916216
....@@ -16052,7 +16229,7 @@
1605216229 if (hasMarquee)
1605316230 {
1605416231 gr.setXORMode(Color.white);
16055
- gr.setColor(Color.red);
16232
+ gr.setColor(Color.white);
1605616233 if (!firstime)
1605716234 {
1605816235 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16519,6 +16696,8 @@
1651916696 private /*static*/ boolean firstime;
1652016697 private /*static*/ cVector newView = new cVector();
1652116698 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16699
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16700
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1652216701 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1652316702 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1652416703 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16531,29 +16710,67 @@
1653116710 {
1653216711 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1653316712
16713
+ int usedsuf = 0;
16714
+
1653416715 for (int i = 0; i < suffixes.length; i++)
1653516716 {
16536
- String resourceName = basename + suffixes[i] + "." + suffix;
16537
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16538
- mipmapped,
16539
- FileUtil.getFileSuffix(resourceName));
16540
- if (data == null)
16717
+ String[] suffixe = suffixes;
16718
+ String[] fallback = suffixes2;
16719
+ String[] fallfallback = suffixes3;
16720
+
16721
+ for (int c=usedsuf; --c>=0;)
1654116722 {
16542
- throw new IOException("Unable to load texture " + resourceName);
16723
+// String[] temp = suffixe;
16724
+// suffixe = fallback;
16725
+// fallback = fallfallback;
16726
+// fallfallback = temp;
1654316727 }
16728
+
16729
+ String resourceName = basename + suffixe[i] + "." + suffix;
16730
+ TextureData data;
16731
+
16732
+ try
16733
+ {
16734
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16735
+ mipmapped,
16736
+ FileUtil.getFileSuffix(resourceName));
16737
+ }
16738
+ catch (Exception e)
16739
+ {
16740
+ try
16741
+ {
16742
+ resourceName = basename + fallback[i] + "." + suffix;
16743
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16744
+ mipmapped,
16745
+ FileUtil.getFileSuffix(resourceName));
16746
+ }
16747
+ catch (Exception e2)
16748
+ {
16749
+ resourceName = basename + fallfallback[i] + "." + suffix;
16750
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16751
+ mipmapped,
16752
+ FileUtil.getFileSuffix(resourceName));
16753
+ }
16754
+ }
16755
+
1654416756 //System.out.println("Target = " + targets[i]);
1654516757 cubemap.updateImage(data, targets[i]);
1654616758 }
1654716759
1654816760 return cubemap;
1654916761 }
16762
+
1655016763 int bigsphere = -1;
1655116764
1655216765 float BGcolor = 0.5f;
1655316766
16554
- private void DrawSkyBox(GL gl)
16767
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16768
+
16769
+ private void DrawSkyBox(GL gl, float ratio)
1655516770 {
16556
- if (envyoff || cubemap == null)
16771
+ if (//envyoff ||
16772
+ WIREFRAME ||
16773
+ cubemap == null)
1655716774 {
1655816775 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1655916776 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16568,7 +16785,17 @@
1656816785 // Compensates for ExaminerViewer's modification of modelview matrix
1656916786 gl.glMatrixMode(GL.GL_MODELVIEW);
1657016787 gl.glLoadIdentity();
16788
+ gl.glScalef(1,ratio,1);
1657116789
16790
+// colorV[0] = 2;
16791
+// colorV[1] = 2;
16792
+// colorV[2] = 2;
16793
+// colorV[3] = 1;
16794
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16795
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16796
+//
16797
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16798
+
1657216799 //gl.glActiveTexture(GL.GL_TEXTURE1);
1657316800 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1657416801
....@@ -16600,6 +16827,7 @@
1660016827 {
1660116828 gl.glScalef(1.0f, -1.0f, 1.0f);
1660216829 }
16830
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1660316831 gl.glMultMatrixd(viewrot_1, 0);
1660416832 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1660516833 //viewer.updateInverseRotation(gl);
....@@ -16640,7 +16868,8 @@
1664016868 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1664116869
1664216870 cubemap.disable();
16643
- ////cubemap.unbind();
16871
+ //cubemap.dispose();
16872
+
1664416873 if (CULLFACE)
1664516874 {
1664616875 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16858,7 +17087,7 @@
1685817087 //new Exception().printStackTrace();
1685917088 System.out.println("select buffer init");
1686017089 // Use debug pipeline
16861
- drawable.setGL(new DebugGL(drawable.getGL()));
17090
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1686217091
1686317092 GL gl = drawable.getGL();
1686417093
....@@ -17176,6 +17405,7 @@
1717617405
1717717406 public void init(GLAutoDrawable drawable)
1717817407 {
17408
+ if (Globals.DEBUG)
1717917409 System.out.println("shadow buffer init");
1718017410
1718117411 GL gl = drawable.getGL();
....@@ -17404,10 +17634,14 @@
1740417634 gl.glFlush();
1740517635
1740617636 /**/
17407
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17637
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1740817638
17409
- float[] pixels = occlusionsizebuffer.array();
17639
+ float[] depths = occlusiondepthbuffer.array();
1741017640
17641
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17642
+
17643
+ int[] pixels = selectsizebuffer.array();
17644
+
1741117645 double r = 0, g = 0, b = 0;
1741217646
1741317647 double count = 0;
....@@ -17418,7 +17652,7 @@
1741817652
1741917653 double FACTOR = 1;
1742017654
17421
- for (int i = 0; i < pixels.length; i++)
17655
+ for (int i = 0; i < depths.length; i++)
1742217656 {
1742317657 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1742417658 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17501,7 +17735,7 @@
1750117735
1750217736 double scale = ray.z; // 1; // cos
1750317737
17504
- float depth = pixels[newindex];
17738
+ float depth = depths[newindex];
1750517739
1750617740 /*
1750717741 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17698,11 +17932,14 @@
1769817932 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1769917933 static IntBuffer bigAAbuffer;
1770017934 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17701
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17935
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1770217936 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1770317937 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1770417938 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17705
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17939
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17940
+
17941
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17942
+
1770617943 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1770717944 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1770817945 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();