.. | .. |
---|
110 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
111 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
112 | 112 | 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 | + |
---|
114 | 118 | boolean reverseUP = false; |
---|
115 | 119 | static boolean frozen = false; |
---|
116 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
173 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 178 | boolean anisotropy = true; |
---|
175 | 179 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 181 | |
---|
178 | 182 | boolean macromode = false; |
---|
179 | 183 | |
---|
.. | .. |
---|
187 | 191 | } |
---|
188 | 192 | |
---|
189 | 193 | 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 | + } |
---|
190 | 207 | |
---|
191 | 208 | void SetAsGLRenderer(boolean b) |
---|
192 | 209 | { |
---|
.. | .. |
---|
1485 | 1502 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1486 | 1503 | } |
---|
1487 | 1504 | |
---|
| 1505 | + float[] colorV = new float[4]; |
---|
| 1506 | + |
---|
1488 | 1507 | void SetColor(Object3D obj, Vertex p0) |
---|
1489 | 1508 | { |
---|
1490 | 1509 | CameraPane display = this; |
---|
.. | .. |
---|
1552 | 1571 | { |
---|
1553 | 1572 | return; |
---|
1554 | 1573 | } |
---|
1555 | | - |
---|
1556 | | - float[] colorV = new float[3]; |
---|
1557 | 1574 | |
---|
1558 | 1575 | if (false) // marked) |
---|
1559 | 1576 | { |
---|
.. | .. |
---|
2500 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2501 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2502 | 2519 | true, |
---|
2503 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2504 | 2521 | } catch (java.io.IOException e) |
---|
2505 | 2522 | { |
---|
2506 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8346 | 8363 | // else |
---|
8347 | 8364 | // if (!texname.startsWith("/")) |
---|
8348 | 8365 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8349 | | - if (!FileExists(texname)) |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8350 | 8367 | { |
---|
8351 | 8368 | texname = fallbackTextureName; |
---|
8352 | 8369 | } |
---|
.. | .. |
---|
8429 | 8446 | new Exception().printStackTrace(); |
---|
8430 | 8447 | } else |
---|
8431 | 8448 | { |
---|
| 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 | + { |
---|
8432 | 8458 | if (textureon) |
---|
8433 | 8459 | { |
---|
8434 | 8460 | String cachename = texname; |
---|
.. | .. |
---|
8488 | 8514 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8489 | 8515 | //texture = GetTexture(tex, bump); |
---|
8490 | 8516 | } |
---|
| 8517 | + } |
---|
8491 | 8518 | } |
---|
8492 | 8519 | //} |
---|
8493 | 8520 | } |
---|
.. | .. |
---|
8756 | 8783 | |
---|
8757 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8758 | 8785 | 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); |
---|
8760 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8761 | 8789 | 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); |
---|
8763 | 8792 | |
---|
8764 | 8793 | // Use debug pipeline |
---|
8765 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8767 | 8796 | gl = drawable.getGL(); // |
---|
8768 | 8797 | |
---|
8769 | 8798 | 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()); |
---|
8771 | 8801 | |
---|
8772 | 8802 | |
---|
8773 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8932 | 8962 | |
---|
8933 | 8963 | if (cubemap == null) |
---|
8934 | 8964 | { |
---|
8935 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
8936 | 8966 | } |
---|
8937 | 8967 | |
---|
8938 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
9208 | 9238 | |
---|
9209 | 9239 | void LoadEnvy(int which) |
---|
9210 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9211 | 9243 | String name; |
---|
9212 | 9244 | String ext; |
---|
9213 | 9245 | |
---|
.. | .. |
---|
9219 | 9251 | cubemap = null; |
---|
9220 | 9252 | return; |
---|
9221 | 9253 | case 1: |
---|
9222 | | - name = "cubemaps/box_"; |
---|
9223 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
9224 | 9256 | reverseUP = false; |
---|
9225 | 9257 | break; |
---|
9226 | 9258 | 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; |
---|
9230 | 9263 | case 3: |
---|
9231 | | - name = "cubemaps/CloudyHills_"; |
---|
9232 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
9233 | 9266 | reverseUP = false; |
---|
9234 | 9267 | break; |
---|
9235 | 9268 | case 4: |
---|
9236 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
9237 | 9270 | ext = "png"; |
---|
9238 | 9271 | reverseUP = false; |
---|
9239 | 9272 | 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; |
---|
9240 | 9298 | default: |
---|
9241 | | - name = "cubemaps/rgb_"; |
---|
9242 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
9243 | 9302 | break; |
---|
9244 | 9303 | } |
---|
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); |
---|
9253 | 9306 | } |
---|
9254 | 9307 | |
---|
9255 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9281 | 9334 | static double[] model = new double[16]; |
---|
9282 | 9335 | double[] camera2light = new double[16]; |
---|
9283 | 9336 | 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 | + |
---|
9286 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9287 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
9288 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9762 | 9819 | rati = 1 / rati; |
---|
9763 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9764 | 9821 | } |
---|
9765 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
9766 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9767 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9768 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
9769 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9770 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9771 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10802 | 10861 | |
---|
10803 | 10862 | if (wait) |
---|
10804 | 10863 | { |
---|
10805 | | - Sleep(500); |
---|
| 10864 | + Sleep(200); // blocks everything |
---|
10806 | 10865 | |
---|
10807 | 10866 | wait = false; |
---|
10808 | 10867 | } |
---|
.. | .. |
---|
11018 | 11077 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11019 | 11078 | } |
---|
11020 | 11079 | |
---|
11021 | | - if (newenvy > -1) |
---|
| 11080 | +// if (newenvy > -1) |
---|
| 11081 | +// { |
---|
| 11082 | +// LoadEnvy(newenvy); |
---|
| 11083 | +// } |
---|
| 11084 | +// |
---|
| 11085 | +// newenvy = -1; |
---|
| 11086 | + |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11022 | 11088 | { |
---|
11023 | | - LoadEnvy(newenvy); |
---|
| 11089 | + if (cubemaprgb == null) |
---|
| 11090 | + { |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
11024 | 11095 | } |
---|
11025 | | - |
---|
11026 | | - newenvy = -1; |
---|
11027 | | - |
---|
| 11096 | + else |
---|
| 11097 | + { |
---|
| 11098 | + if (object.skyboxname != null) |
---|
| 11099 | + { |
---|
| 11100 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11101 | + { |
---|
| 11102 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11103 | + cubemap.dispose(); |
---|
| 11104 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11105 | + loadedskyboxname = object.skyboxname; |
---|
| 11106 | + } |
---|
| 11107 | + } |
---|
| 11108 | + else |
---|
| 11109 | + { |
---|
| 11110 | + cubemapcustom = null; |
---|
| 11111 | + loadedskyboxname = null; |
---|
| 11112 | + } |
---|
| 11113 | + |
---|
| 11114 | + cubemap = cubemapcustom; |
---|
| 11115 | + } |
---|
| 11116 | + |
---|
11028 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
11029 | 11118 | //System.out.println("ratio = " + ratio); |
---|
11030 | 11119 | |
---|
.. | .. |
---|
11040 | 11129 | |
---|
11041 | 11130 | if (!IsFrozen() && !ambientOcclusion) |
---|
11042 | 11131 | { |
---|
11043 | | - DrawSkyBox(gl); |
---|
| 11132 | + DrawSkyBox(gl, (float)ratio); |
---|
11044 | 11133 | } |
---|
11045 | 11134 | |
---|
11046 | 11135 | //if (selection_view == -1) |
---|
.. | .. |
---|
11326 | 11415 | |
---|
11327 | 11416 | // if (cam != lightCamera) |
---|
11328 | 11417 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11329 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11418 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11330 | 11419 | } |
---|
11331 | 11420 | |
---|
11332 | 11421 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12400 | 12489 | |
---|
12401 | 12490 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12402 | 12491 | |
---|
12403 | | - String program = |
---|
| 12492 | + String programmin = |
---|
12404 | 12493 | // Min shader |
---|
12405 | 12494 | "!!ARBfp1.0\n" + |
---|
12406 | 12495 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12451 | 12540 | //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
12452 | 12541 | //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
12453 | 12542 | |
---|
12454 | | - "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12543 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12544 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
12455 | 12545 | |
---|
12456 | 12546 | // Pigment |
---|
12457 | 12547 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
.. | .. |
---|
12466 | 12556 | "MOV result.color, temp;" + |
---|
12467 | 12557 | "END"; |
---|
12468 | 12558 | |
---|
12469 | | - String program2 = |
---|
| 12559 | + String programmax = |
---|
12470 | 12560 | "!!ARBfp1.0\n" + |
---|
12471 | 12561 | |
---|
12472 | 12562 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12991 | 13081 | // display shadow only (fakedepth == 0) |
---|
12992 | 13082 | "SUB temp.x, half.x, shadow.x;" + |
---|
12993 | 13083 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12994 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13084 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12995 | 13085 | "SUB temp.y, one.x, temp.z;" + |
---|
12996 | 13086 | "MUL temp.x, temp.x, temp.y;" + |
---|
12997 | 13087 | "KIL temp.x;" + |
---|
.. | .. |
---|
13322 | 13412 | //once = true; |
---|
13323 | 13413 | } |
---|
13324 | 13414 | |
---|
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 " : "")); |
---|
| 13415 | + String program = programmax; |
---|
| 13416 | + |
---|
| 13417 | + if (Globals.MINSHADER) |
---|
| 13418 | + { |
---|
| 13419 | + program = programmin; |
---|
| 13420 | + } |
---|
| 13421 | + |
---|
| 13422 | + if (Globals.DEBUG) |
---|
| 13423 | + { |
---|
| 13424 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13425 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13426 | + } |
---|
| 13427 | + |
---|
13327 | 13428 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13328 | 13429 | |
---|
13329 | 13430 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13370 | 13471 | "\n" + |
---|
13371 | 13472 | "END\n"; |
---|
13372 | 13473 | |
---|
13373 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13474 | + if (Globals.DEBUG) |
---|
| 13475 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13374 | 13476 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13375 | 13477 | |
---|
13376 | 13478 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
14569 | 14671 | void GoDown(int mod) |
---|
14570 | 14672 | { |
---|
14571 | 14673 | MODIFIERS |= COMMAND; |
---|
| 14674 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14572 | 14675 | /**/ |
---|
14573 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
14574 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14677 | + { |
---|
| 14678 | + if (isVR) |
---|
| 14679 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14680 | + else |
---|
| 14681 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14682 | + } |
---|
14575 | 14683 | else |
---|
14576 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14684 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14577 | 14685 | /**/ |
---|
14578 | 14686 | if ((mod & SHIFT) == SHIFT) |
---|
14579 | 14687 | { |
---|
.. | .. |
---|
14583 | 14691 | mouseMode |= BACKFORTH; |
---|
14584 | 14692 | } |
---|
14585 | 14693 | |
---|
| 14694 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14695 | + |
---|
14586 | 14696 | //prevX = X = anchorX; |
---|
14587 | 14697 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14588 | 14698 | } |
---|
.. | .. |
---|
14591 | 14701 | { |
---|
14592 | 14702 | MODIFIERS |= COMMAND; |
---|
14593 | 14703 | /**/ |
---|
| 14704 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14705 | + |
---|
14594 | 14706 | if((mod&SHIFT) == SHIFT) |
---|
14595 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14707 | + { |
---|
| 14708 | + if (isVR) |
---|
| 14709 | + manipCamera.RotateInterest(0, speed); |
---|
| 14710 | + else |
---|
| 14711 | + manipCamera.RotatePosition(0, speed); |
---|
| 14712 | + } |
---|
14596 | 14713 | else |
---|
14597 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14714 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14598 | 14715 | /**/ |
---|
14599 | 14716 | if ((mod & SHIFT) == SHIFT) |
---|
14600 | 14717 | { |
---|
.. | .. |
---|
14604 | 14721 | mouseMode |= BACKFORTH; |
---|
14605 | 14722 | } |
---|
14606 | 14723 | |
---|
| 14724 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14725 | + |
---|
14607 | 14726 | //prevX = X = anchorX; |
---|
14608 | 14727 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14609 | 14728 | } |
---|
.. | .. |
---|
14613 | 14732 | MODIFIERS |= COMMAND; |
---|
14614 | 14733 | /**/ |
---|
14615 | 14734 | if((mod&SHIFT) == SHIFT) |
---|
14616 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14735 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14617 | 14736 | else |
---|
14618 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14737 | + { |
---|
| 14738 | + if ((mouseMode&VR)!=0) |
---|
| 14739 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14740 | + else |
---|
| 14741 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14742 | + } |
---|
14619 | 14743 | /**/ |
---|
14620 | 14744 | if ((mod & SHIFT) == SHIFT) |
---|
14621 | 14745 | { |
---|
.. | .. |
---|
14625 | 14749 | mouseMode |= ROTATE; |
---|
14626 | 14750 | } // TRANSLATE; |
---|
14627 | 14751 | |
---|
| 14752 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14753 | + |
---|
14628 | 14754 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14629 | 14755 | prevY = Y = anchorY; |
---|
14630 | 14756 | } |
---|
.. | .. |
---|
14634 | 14760 | MODIFIERS |= COMMAND; |
---|
14635 | 14761 | /**/ |
---|
14636 | 14762 | if((mod&SHIFT) == SHIFT) |
---|
14637 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14763 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14638 | 14764 | else |
---|
14639 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14765 | + { |
---|
| 14766 | + if ((mouseMode&VR)!=0) |
---|
| 14767 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14768 | + else |
---|
| 14769 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14770 | + } |
---|
| 14771 | + |
---|
14640 | 14772 | /**/ |
---|
14641 | 14773 | if ((mod & SHIFT) == SHIFT) |
---|
14642 | 14774 | { |
---|
.. | .. |
---|
14646 | 14778 | mouseMode |= ROTATE; |
---|
14647 | 14779 | } // TRANSLATE; |
---|
14648 | 14780 | |
---|
| 14781 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14782 | + |
---|
14649 | 14783 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14650 | 14784 | prevY = Y = anchorY; |
---|
14651 | 14785 | } |
---|
.. | .. |
---|
15315 | 15449 | OCCLUSION_CULLING ^= true; |
---|
15316 | 15450 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15317 | 15451 | break; |
---|
15318 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15452 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15319 | 15453 | case '1': |
---|
15320 | 15454 | case '2': |
---|
15321 | 15455 | case '3': |
---|
15322 | 15456 | case '4': |
---|
15323 | 15457 | case '5': |
---|
15324 | | - newenvy = Character.getNumericValue(key); |
---|
15325 | | - repaint(); |
---|
15326 | | - break; |
---|
15327 | 15458 | case '6': |
---|
15328 | 15459 | case '7': |
---|
15329 | 15460 | case '8': |
---|
15330 | 15461 | case '9': |
---|
15331 | | - BGcolor = (key - '6')/3.f; |
---|
| 15462 | + if (true) // envyoff) |
---|
| 15463 | + { |
---|
| 15464 | + BGcolor = (key - '1')/8.f; |
---|
| 15465 | + } |
---|
| 15466 | + else |
---|
| 15467 | + { |
---|
| 15468 | + //newenvy = Character.getNumericValue(key); |
---|
| 15469 | + } |
---|
15332 | 15470 | repaint(); |
---|
15333 | 15471 | break; |
---|
15334 | 15472 | case '!': |
---|
.. | .. |
---|
16026 | 16164 | { |
---|
16027 | 16165 | switch (hitSomething) |
---|
16028 | 16166 | { |
---|
16029 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16167 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16030 | 16168 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16031 | 16169 | break; |
---|
16032 | 16170 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
16033 | 16171 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16034 | 16172 | break; |
---|
16035 | 16173 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16036 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16174 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16037 | 16175 | break; |
---|
16038 | 16176 | } |
---|
16039 | 16177 | |
---|
.. | .. |
---|
16052 | 16190 | if (hasMarquee) |
---|
16053 | 16191 | { |
---|
16054 | 16192 | gr.setXORMode(Color.white); |
---|
16055 | | - gr.setColor(Color.red); |
---|
| 16193 | + gr.setColor(Color.white); |
---|
16056 | 16194 | if (!firstime) |
---|
16057 | 16195 | { |
---|
16058 | 16196 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16519 | 16657 | private /*static*/ boolean firstime; |
---|
16520 | 16658 | private /*static*/ cVector newView = new cVector(); |
---|
16521 | 16659 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16660 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16661 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16522 | 16662 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16523 | 16663 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16524 | 16664 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16531 | 16671 | { |
---|
16532 | 16672 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16533 | 16673 | |
---|
| 16674 | + int usedsuf = 0; |
---|
| 16675 | + |
---|
16534 | 16676 | for (int i = 0; i < suffixes.length; i++) |
---|
16535 | 16677 | { |
---|
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) |
---|
| 16678 | + String[] suffixe = suffixes; |
---|
| 16679 | + String[] fallback = suffixes2; |
---|
| 16680 | + String[] fallfallback = suffixes3; |
---|
| 16681 | + |
---|
| 16682 | + for (int c=usedsuf; --c>=0;) |
---|
16541 | 16683 | { |
---|
16542 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16684 | +// String[] temp = suffixe; |
---|
| 16685 | +// suffixe = fallback; |
---|
| 16686 | +// fallback = fallfallback; |
---|
| 16687 | +// fallfallback = temp; |
---|
16543 | 16688 | } |
---|
| 16689 | + |
---|
| 16690 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16691 | + TextureData data; |
---|
| 16692 | + |
---|
| 16693 | + try |
---|
| 16694 | + { |
---|
| 16695 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16696 | + mipmapped, |
---|
| 16697 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16698 | + } |
---|
| 16699 | + catch (Exception e) |
---|
| 16700 | + { |
---|
| 16701 | + try |
---|
| 16702 | + { |
---|
| 16703 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e2) |
---|
| 16709 | + { |
---|
| 16710 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16711 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16712 | + mipmapped, |
---|
| 16713 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16714 | + } |
---|
| 16715 | + } |
---|
| 16716 | + |
---|
16544 | 16717 | //System.out.println("Target = " + targets[i]); |
---|
16545 | 16718 | cubemap.updateImage(data, targets[i]); |
---|
16546 | 16719 | } |
---|
16547 | 16720 | |
---|
16548 | 16721 | return cubemap; |
---|
16549 | 16722 | } |
---|
| 16723 | + |
---|
16550 | 16724 | int bigsphere = -1; |
---|
16551 | 16725 | |
---|
16552 | 16726 | float BGcolor = 0.5f; |
---|
16553 | 16727 | |
---|
16554 | | - private void DrawSkyBox(GL gl) |
---|
| 16728 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16729 | + |
---|
| 16730 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16555 | 16731 | { |
---|
16556 | | - if (envyoff || cubemap == null) |
---|
| 16732 | + if (//envyoff || |
---|
| 16733 | + WIREFRAME || |
---|
| 16734 | + cubemap == null) |
---|
16557 | 16735 | { |
---|
16558 | 16736 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16559 | 16737 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16568 | 16746 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16569 | 16747 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16570 | 16748 | gl.glLoadIdentity(); |
---|
| 16749 | + gl.glScalef(1,ratio,1); |
---|
16571 | 16750 | |
---|
| 16751 | +// colorV[0] = 2; |
---|
| 16752 | +// colorV[1] = 2; |
---|
| 16753 | +// colorV[2] = 2; |
---|
| 16754 | +// colorV[3] = 1; |
---|
| 16755 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16756 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16757 | +// |
---|
| 16758 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16759 | + |
---|
16572 | 16760 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16573 | 16761 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16574 | 16762 | |
---|
.. | .. |
---|
16600 | 16788 | { |
---|
16601 | 16789 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16602 | 16790 | } |
---|
| 16791 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16603 | 16792 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16604 | 16793 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16605 | 16794 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16640 | 16829 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16641 | 16830 | |
---|
16642 | 16831 | cubemap.disable(); |
---|
16643 | | - ////cubemap.unbind(); |
---|
| 16832 | + //cubemap.dispose(); |
---|
| 16833 | + |
---|
16644 | 16834 | if (CULLFACE) |
---|
16645 | 16835 | { |
---|
16646 | 16836 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16858 | 17048 | //new Exception().printStackTrace(); |
---|
16859 | 17049 | System.out.println("select buffer init"); |
---|
16860 | 17050 | // Use debug pipeline |
---|
16861 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17051 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16862 | 17052 | |
---|
16863 | 17053 | GL gl = drawable.getGL(); |
---|
16864 | 17054 | |
---|
.. | .. |
---|
17176 | 17366 | |
---|
17177 | 17367 | public void init(GLAutoDrawable drawable) |
---|
17178 | 17368 | { |
---|
| 17369 | + if (Globals.DEBUG) |
---|
17179 | 17370 | System.out.println("shadow buffer init"); |
---|
17180 | 17371 | |
---|
17181 | 17372 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17404 | 17595 | gl.glFlush(); |
---|
17405 | 17596 | |
---|
17406 | 17597 | /**/ |
---|
17407 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17598 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17408 | 17599 | |
---|
17409 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17600 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17410 | 17601 | |
---|
| 17602 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17603 | + |
---|
| 17604 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17605 | + |
---|
17411 | 17606 | double r = 0, g = 0, b = 0; |
---|
17412 | 17607 | |
---|
17413 | 17608 | double count = 0; |
---|
.. | .. |
---|
17418 | 17613 | |
---|
17419 | 17614 | double FACTOR = 1; |
---|
17420 | 17615 | |
---|
17421 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17616 | + for (int i = 0; i < depths.length; i++) |
---|
17422 | 17617 | { |
---|
17423 | 17618 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17424 | 17619 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17501 | 17696 | |
---|
17502 | 17697 | double scale = ray.z; // 1; // cos |
---|
17503 | 17698 | |
---|
17504 | | - float depth = pixels[newindex]; |
---|
| 17699 | + float depth = depths[newindex]; |
---|
17505 | 17700 | |
---|
17506 | 17701 | /* |
---|
17507 | 17702 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17698 | 17893 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17699 | 17894 | static IntBuffer bigAAbuffer; |
---|
17700 | 17895 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17701 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17896 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17702 | 17897 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17703 | 17898 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17704 | 17899 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17705 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17900 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17901 | + |
---|
| 17902 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17903 | + |
---|
17706 | 17904 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17707 | 17905 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17708 | 17906 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|