.. | .. |
---|
113 | 113 | /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
114 | 114 | /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
115 | 115 | /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
116 | 118 | boolean reverseUP = false; |
---|
117 | 119 | static boolean frozen = false; |
---|
118 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
166 | 168 | |
---|
167 | 169 | |
---|
168 | 170 | // OPTIONS |
---|
169 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
170 | 172 | boolean cameraLight = false; |
---|
171 | 173 | boolean UVdebug = false; |
---|
172 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
1817 | 1819 | |
---|
1818 | 1820 | display.modelParams7[0] = 0; |
---|
1819 | 1821 | display.modelParams7[1] = 1000; |
---|
1820 | | - display.modelParams7[2] = 0; |
---|
| 1822 | + display.modelParams7[2] = material.parallax; |
---|
1821 | 1823 | display.modelParams7[3] = 0; |
---|
1822 | 1824 | |
---|
1823 | 1825 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2050 | 2052 | switch(viewcode) |
---|
2051 | 2053 | { |
---|
2052 | 2054 | 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"; |
---|
2056 | 2058 | case 4: return "light"; |
---|
2057 | 2059 | } |
---|
2058 | 2060 | |
---|
.. | .. |
---|
2515 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2516 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2517 | 2519 | true, |
---|
2518 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2519 | 2521 | } catch (java.io.IOException e) |
---|
2520 | 2522 | { |
---|
2521 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
10688 | 10690 | static boolean init = false; |
---|
10689 | 10691 | |
---|
10690 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
10691 | 10696 | |
---|
10692 | 10697 | public void display(GLAutoDrawable drawable) |
---|
10693 | 10698 | { |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
| 10700 | + { |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
10694 | 10705 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10695 | 10706 | { |
---|
10696 | 10707 | Grafreed.wav.save(); |
---|
.. | .. |
---|
11082 | 11093 | // |
---|
11083 | 11094 | // newenvy = -1; |
---|
11084 | 11095 | |
---|
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")) |
---|
11086 | 11097 | { |
---|
11087 | 11098 | if (cubemaprgb == null) |
---|
11088 | 11099 | { |
---|
11089 | | - cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
11090 | 11101 | } |
---|
11091 | 11102 | |
---|
11092 | 11103 | cubemap = cubemaprgb; |
---|
.. | .. |
---|
11097 | 11108 | { |
---|
11098 | 11109 | if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
11099 | 11110 | { |
---|
| 11111 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11112 | + cubemap.dispose(); |
---|
11100 | 11113 | cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11101 | 11114 | loadedskyboxname = object.skyboxname; |
---|
11102 | 11115 | } |
---|
.. | .. |
---|
12580 | 12593 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12581 | 12594 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12582 | 12595 | "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 |
---|
12584 | 12597 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12585 | 12598 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12586 | 12599 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12825 | 12838 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12826 | 12839 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12827 | 12840 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12828 | | - "KIL alpha.a;" + |
---|
| 12841 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12829 | 12842 | /* |
---|
12830 | 12843 | "MUL temp.xy, temp, two;" + |
---|
12831 | 12844 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12911 | 12924 | "SUB bump0, bump0, half;" + |
---|
12912 | 12925 | "ADD bump, bump, bump0;" + |
---|
12913 | 12926 | |
---|
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 | | - |
---|
12919 | 12927 | // double-sided |
---|
12920 | 12928 | /**/ |
---|
12921 | 12929 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12945 | 12953 | Normalize("U") + |
---|
12946 | 12954 | |
---|
12947 | 12955 | // 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;" + |
---|
12948 | 12991 | |
---|
12949 | 12992 | //"MOV temp, fragment.texcoord[0];" + |
---|
12950 | 12993 | // |
---|
.. | .. |
---|
13415 | 13458 | program = programmin; |
---|
13416 | 13459 | } |
---|
13417 | 13460 | |
---|
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 | + |
---|
13420 | 13467 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13421 | 13468 | |
---|
13422 | 13469 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13463 | 13510 | "\n" + |
---|
13464 | 13511 | "END\n"; |
---|
13465 | 13512 | |
---|
13466 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13513 | + if (Globals.DEBUG) |
---|
| 13514 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13467 | 13515 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13468 | 13516 | |
---|
13469 | 13517 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13721 | 13769 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13722 | 13770 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13723 | 13771 | /*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 |
---|
13725 | 13773 | |
---|
13726 | 13774 | //Object3D.cVector2[] vector2buffer; |
---|
13727 | 13775 | |
---|
.. | .. |
---|
14662 | 14710 | void GoDown(int mod) |
---|
14663 | 14711 | { |
---|
14664 | 14712 | MODIFIERS |= COMMAND; |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14665 | 14714 | /**/ |
---|
14666 | 14715 | 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 | + } |
---|
14668 | 14722 | else |
---|
14669 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14723 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14670 | 14724 | /**/ |
---|
14671 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
14672 | 14726 | { |
---|
.. | .. |
---|
14676 | 14730 | mouseMode |= BACKFORTH; |
---|
14677 | 14731 | } |
---|
14678 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
14679 | 14735 | //prevX = X = anchorX; |
---|
14680 | 14736 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14681 | 14737 | } |
---|
.. | .. |
---|
14684 | 14740 | { |
---|
14685 | 14741 | MODIFIERS |= COMMAND; |
---|
14686 | 14742 | /**/ |
---|
| 14743 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14744 | + |
---|
14687 | 14745 | 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 | + } |
---|
14689 | 14752 | else |
---|
14690 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14753 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14691 | 14754 | /**/ |
---|
14692 | 14755 | if ((mod & SHIFT) == SHIFT) |
---|
14693 | 14756 | { |
---|
.. | .. |
---|
14697 | 14760 | mouseMode |= BACKFORTH; |
---|
14698 | 14761 | } |
---|
14699 | 14762 | |
---|
| 14763 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14764 | + |
---|
14700 | 14765 | //prevX = X = anchorX; |
---|
14701 | 14766 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14702 | 14767 | } |
---|
.. | .. |
---|
14706 | 14771 | MODIFIERS |= COMMAND; |
---|
14707 | 14772 | /**/ |
---|
14708 | 14773 | if((mod&SHIFT) == SHIFT) |
---|
14709 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14774 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14710 | 14775 | 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 | + } |
---|
14712 | 14782 | /**/ |
---|
14713 | 14783 | if ((mod & SHIFT) == SHIFT) |
---|
14714 | 14784 | { |
---|
.. | .. |
---|
14718 | 14788 | mouseMode |= ROTATE; |
---|
14719 | 14789 | } // TRANSLATE; |
---|
14720 | 14790 | |
---|
| 14791 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14792 | + |
---|
14721 | 14793 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14722 | 14794 | prevY = Y = anchorY; |
---|
14723 | 14795 | } |
---|
.. | .. |
---|
14727 | 14799 | MODIFIERS |= COMMAND; |
---|
14728 | 14800 | /**/ |
---|
14729 | 14801 | if((mod&SHIFT) == SHIFT) |
---|
14730 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14802 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14731 | 14803 | 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 | + |
---|
14733 | 14811 | /**/ |
---|
14734 | 14812 | if ((mod & SHIFT) == SHIFT) |
---|
14735 | 14813 | { |
---|
.. | .. |
---|
14739 | 14817 | mouseMode |= ROTATE; |
---|
14740 | 14818 | } // TRANSLATE; |
---|
14741 | 14819 | |
---|
| 14820 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14821 | + |
---|
14742 | 14822 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14743 | 14823 | prevY = Y = anchorY; |
---|
14744 | 14824 | } |
---|
.. | .. |
---|
15241 | 15321 | case 'K': |
---|
15242 | 15322 | KOMPACTTEXTURE ^= true; |
---|
15243 | 15323 | //textures.clear(); |
---|
15244 | | - break; |
---|
15245 | | - case 'P': // Texture Projection macros |
---|
| 15324 | + // break; |
---|
| 15325 | + //case 'P': // Texture Projection macros |
---|
15246 | 15326 | // SAVETEXTURE ^= true; |
---|
15247 | 15327 | macromode = true; |
---|
15248 | 15328 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15363 | 15443 | targetLookAt.set(manipCamera.lookAt); |
---|
15364 | 15444 | repaint(); |
---|
15365 | 15445 | break; |
---|
15366 | | - case 'p': |
---|
| 15446 | + case 'P': // p': |
---|
15367 | 15447 | // c'est quoi ca au juste? spherical ^= true; |
---|
15368 | 15448 | Skinshader ^= true; programInitialized = false; |
---|
15369 | 15449 | repaint(); |
---|
.. | .. |
---|
16123 | 16203 | { |
---|
16124 | 16204 | switch (hitSomething) |
---|
16125 | 16205 | { |
---|
16126 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16206 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16127 | 16207 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16128 | 16208 | break; |
---|
16129 | 16209 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
16149 | 16229 | if (hasMarquee) |
---|
16150 | 16230 | { |
---|
16151 | 16231 | gr.setXORMode(Color.white); |
---|
16152 | | - gr.setColor(Color.red); |
---|
| 16232 | + gr.setColor(Color.white); |
---|
16153 | 16233 | if (!firstime) |
---|
16154 | 16234 | { |
---|
16155 | 16235 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16788 | 16868 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16789 | 16869 | |
---|
16790 | 16870 | cubemap.disable(); |
---|
16791 | | - ////cubemap.unbind(); |
---|
| 16871 | + //cubemap.dispose(); |
---|
| 16872 | + |
---|
16792 | 16873 | if (CULLFACE) |
---|
16793 | 16874 | { |
---|
16794 | 16875 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17324 | 17405 | |
---|
17325 | 17406 | public void init(GLAutoDrawable drawable) |
---|
17326 | 17407 | { |
---|
| 17408 | + if (Globals.DEBUG) |
---|
17327 | 17409 | System.out.println("shadow buffer init"); |
---|
17328 | 17410 | |
---|
17329 | 17411 | GL gl = drawable.getGL(); |
---|