Normand Briere
2019-08-20 564f4d12d93813b5d680fc24d4f118c3886d96ed
CameraPane.java
....@@ -113,6 +113,8 @@
113113 /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114114 /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115115 /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
116118 boolean reverseUP = false;
117119 static boolean frozen = false;
118120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -166,7 +168,7 @@
166168
167169
168170 // OPTIONS
169
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
170172 boolean cameraLight = false;
171173 boolean UVdebug = false;
172174 boolean Udebug = false;
....@@ -1817,7 +1819,7 @@
18171819
18181820 display.modelParams7[0] = 0;
18191821 display.modelParams7[1] = 1000;
1820
- display.modelParams7[2] = 0;
1822
+ display.modelParams7[2] = material.parallax;
18211823 display.modelParams7[3] = 0;
18221824
18231825 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2050,9 +2052,9 @@
20502052 switch(viewcode)
20512053 {
20522054 case 0: return "main";
2053
- case 1: return "one";
2054
- case 2: return "two";
2055
- case 3: return "three";
2055
+ case 1: return "Red";
2056
+ case 2: return "Green";
2057
+ case 3: return "Blue";
20562058 case 4: return "light";
20572059 }
20582060
....@@ -2515,7 +2517,7 @@
25152517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25162518 getClass().getClassLoader().getResourceAsStream(name),
25172519 true,
2518
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25192521 } catch (java.io.IOException e)
25202522 {
25212523 throw new javax.media.opengl.GLException(e);
....@@ -10688,9 +10690,18 @@
1068810690 static boolean init = false;
1068910691
1069010692 double[][] matrix = LA.newMatrix();
10693
+
10694
+ // This is to refresh the UI of the material panel.
10695
+ ObjEditor patchMaterial;
1069110696
1069210697 public void display(GLAutoDrawable drawable)
1069310698 {
10699
+ if (patchMaterial.patchMaterial)
10700
+ {
10701
+ patchMaterial.patchMaterial = false;
10702
+ patchMaterial.objectPanel.setSelectedIndex(1);
10703
+ }
10704
+
1069410705 if (Grafreed.savesound && Grafreed.hassound)
1069510706 {
1069610707 Grafreed.wav.save();
....@@ -11082,11 +11093,11 @@
1108211093 //
1108311094 // newenvy = -1;
1108411095
11085
- if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
11096
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1108611097 {
1108711098 if (cubemaprgb == null)
1108811099 {
11089
- cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11100
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
1109011101 }
1109111102
1109211103 cubemap = cubemaprgb;
....@@ -11097,6 +11108,8 @@
1109711108 {
1109811109 if (!object.skyboxname.equals(this.loadedskyboxname))
1109911110 {
11111
+ if (cubemap != null && cubemap != cubemaprgb)
11112
+ cubemap.dispose();
1110011113 cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
1110111114 loadedskyboxname = object.skyboxname;
1110211115 }
....@@ -12580,7 +12593,7 @@
1258012593 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1258112594 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1258212595 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12583
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12596
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1258412597 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1258512598 "PARAM options1 = program.env[62];" + // fog rgb color
1258612599 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12825,7 +12838,7 @@
1282512838 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1282612839 // mar 2013 ??? "KIL alpha.a;" +
1282712840 "MOV alpha, texSamp.aaaa;" + // y;" +
12828
- "KIL alpha.a;" +
12841
+ "KIL alpha.a;" + // not sure with parallax mapping
1282912842 /*
1283012843 "MUL temp.xy, temp, two;" +
1283112844 "TXB bump, temp, texture[0], 2D;" +
....@@ -12911,11 +12924,6 @@
1291112924 "SUB bump0, bump0, half;" +
1291212925 "ADD bump, bump, bump0;" +
1291312926
12914
- "MOV temp.x, texSamp.a;" +
12915
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12916
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12917
- "MOV texSamp.a, temp.x;" +
12918
-
1291912927 // double-sided
1292012928 /**/
1292112929 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12945,6 +12953,41 @@
1294512953 Normalize("U") +
1294612954
1294712955 // 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;" +
1294812991
1294912992 //"MOV temp, fragment.texcoord[0];" +
1295012993 //
....@@ -13415,8 +13458,12 @@
1341513458 program = programmin;
1341613459 }
1341713460
13418
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13419
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
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
+
1342013467 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1342113468
1342213469 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13463,7 +13510,8 @@
1346313510 "\n" +
1346413511 "END\n";
1346513512
13466
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13513
+ if (Globals.DEBUG)
13514
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1346713515 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1346813516
1346913517 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13721,7 +13769,7 @@
1372113769 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1372213770 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1372313771 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13724
- /*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
1372513773
1372613774 //Object3D.cVector2[] vector2buffer;
1372713775
....@@ -14662,11 +14710,17 @@
1466214710 void GoDown(int mod)
1466314711 {
1466414712 MODIFIERS |= COMMAND;
14713
+ boolean isVR = (mouseMode&VR)!=0;
1466514714 /**/
1466614715 if((mod&SHIFT) == SHIFT)
14667
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, -speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, -speed);
14721
+ }
1466814722 else
14669
- manipCamera.RotatePosition(0, -speed);
14723
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1467014724 /**/
1467114725 if ((mod & SHIFT) == SHIFT)
1467214726 {
....@@ -14676,6 +14730,8 @@
1467614730 mouseMode |= BACKFORTH;
1467714731 }
1467814732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1467914735 //prevX = X = anchorX;
1468014736 prevY = Y = anchorY - (int) (renderCamera.Distance());
1468114737 }
....@@ -14684,10 +14740,17 @@
1468414740 {
1468514741 MODIFIERS |= COMMAND;
1468614742 /**/
14743
+ boolean isVR = (mouseMode&VR)!=0;
14744
+
1468714745 if((mod&SHIFT) == SHIFT)
14688
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14746
+ {
14747
+ if (isVR)
14748
+ manipCamera.RotateInterest(0, speed);
14749
+ else
14750
+ manipCamera.RotatePosition(0, speed);
14751
+ }
1468914752 else
14690
- manipCamera.RotatePosition(0, speed);
14753
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1469114754 /**/
1469214755 if ((mod & SHIFT) == SHIFT)
1469314756 {
....@@ -14697,6 +14760,8 @@
1469714760 mouseMode |= BACKFORTH;
1469814761 }
1469914762
14763
+ targetLookAt.set(manipCamera.lookAt);
14764
+
1470014765 //prevX = X = anchorX;
1470114766 prevY = Y = anchorY + (int) (renderCamera.Distance());
1470214767 }
....@@ -14706,9 +14771,14 @@
1470614771 MODIFIERS |= COMMAND;
1470714772 /**/
1470814773 if((mod&SHIFT) == SHIFT)
14709
- manipCamera.Translate(speed*delta, 0, getWidth());
14774
+ manipCamera.Translate(speed*delta, 0, getWidth());
1471014775 else
14711
- manipCamera.RotatePosition(speed, 0);
14776
+ {
14777
+ if ((mouseMode&VR)!=0)
14778
+ manipCamera.RotateInterest(-speed, 0);
14779
+ else
14780
+ manipCamera.RotatePosition(speed, 0);
14781
+ }
1471214782 /**/
1471314783 if ((mod & SHIFT) == SHIFT)
1471414784 {
....@@ -14718,6 +14788,8 @@
1471814788 mouseMode |= ROTATE;
1471914789 } // TRANSLATE;
1472014790
14791
+ targetLookAt.set(manipCamera.lookAt);
14792
+
1472114793 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1472214794 prevY = Y = anchorY;
1472314795 }
....@@ -14727,9 +14799,15 @@
1472714799 MODIFIERS |= COMMAND;
1472814800 /**/
1472914801 if((mod&SHIFT) == SHIFT)
14730
- manipCamera.Translate(-speed*delta, 0, getWidth());
14802
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1473114803 else
14732
- manipCamera.RotatePosition(-speed, 0);
14804
+ {
14805
+ if ((mouseMode&VR)!=0)
14806
+ manipCamera.RotateInterest(speed, 0);
14807
+ else
14808
+ manipCamera.RotatePosition(-speed, 0);
14809
+ }
14810
+
1473314811 /**/
1473414812 if ((mod & SHIFT) == SHIFT)
1473514813 {
....@@ -14739,6 +14817,8 @@
1473914817 mouseMode |= ROTATE;
1474014818 } // TRANSLATE;
1474114819
14820
+ targetLookAt.set(manipCamera.lookAt);
14821
+
1474214822 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1474314823 prevY = Y = anchorY;
1474414824 }
....@@ -15241,8 +15321,8 @@
1524115321 case 'K':
1524215322 KOMPACTTEXTURE ^= true;
1524315323 //textures.clear();
15244
- break;
15245
- case 'P': // Texture Projection macros
15324
+ // break;
15325
+ //case 'P': // Texture Projection macros
1524615326 // SAVETEXTURE ^= true;
1524715327 macromode = true;
1524815328 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15363,7 +15443,7 @@
1536315443 targetLookAt.set(manipCamera.lookAt);
1536415444 repaint();
1536515445 break;
15366
- case 'p':
15446
+ case 'P': // p':
1536715447 // c'est quoi ca au juste? spherical ^= true;
1536815448 Skinshader ^= true; programInitialized = false;
1536915449 repaint();
....@@ -16123,7 +16203,7 @@
1612316203 {
1612416204 switch (hitSomething)
1612516205 {
16126
- case Object3D.hitCenter: gr.setColor(Color.pink);
16206
+ case Object3D.hitCenter: gr.setColor(Color.white);
1612716207 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1612816208 break;
1612916209 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -16149,7 +16229,7 @@
1614916229 if (hasMarquee)
1615016230 {
1615116231 gr.setXORMode(Color.white);
16152
- gr.setColor(Color.red);
16232
+ gr.setColor(Color.white);
1615316233 if (!firstime)
1615416234 {
1615516235 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16788,7 +16868,8 @@
1678816868 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1678916869
1679016870 cubemap.disable();
16791
- ////cubemap.unbind();
16871
+ //cubemap.dispose();
16872
+
1679216873 if (CULLFACE)
1679316874 {
1679416875 gl.glEnable(gl.GL_CULL_FACE);
....@@ -17324,6 +17405,7 @@
1732417405
1732517406 public void init(GLAutoDrawable drawable)
1732617407 {
17408
+ if (Globals.DEBUG)
1732717409 System.out.println("shadow buffer init");
1732817410
1732917411 GL gl = drawable.getGL();