.. | .. |
---|
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 |
---|
.. | .. |
---|
188 | 192 | |
---|
189 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
190 | 194 | |
---|
191 | | - public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
192 | 196 | { |
---|
193 | 197 | try |
---|
194 | 198 | { |
---|
195 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
196 | 200 | } catch (IOException e) |
---|
197 | 201 | { |
---|
198 | 202 | System.out.println("NAME = " + name); |
---|
199 | 203 | e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
200 | 205 | } |
---|
201 | 206 | } |
---|
202 | 207 | |
---|
.. | .. |
---|
2512 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2513 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2514 | 2519 | true, |
---|
2515 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2516 | 2521 | } catch (java.io.IOException e) |
---|
2517 | 2522 | { |
---|
2518 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
9233 | 9238 | |
---|
9234 | 9239 | void LoadEnvy(int which) |
---|
9235 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9236 | 9243 | String name; |
---|
9237 | 9244 | String ext; |
---|
9238 | 9245 | |
---|
.. | .. |
---|
11077 | 11084 | // |
---|
11078 | 11085 | // newenvy = -1; |
---|
11079 | 11086 | |
---|
11080 | | - if (object.skyboxname != null) |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11081 | 11088 | { |
---|
11082 | | - if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11089 | + if (cubemaprgb == null) |
---|
11083 | 11090 | { |
---|
11084 | | - LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11085 | | - loadedskyboxname = object.skyboxname; |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
11086 | 11092 | } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
11087 | 11095 | } |
---|
11088 | 11096 | else |
---|
11089 | 11097 | { |
---|
11090 | | - cubemap = null; |
---|
11091 | | - loadedskyboxname = null; |
---|
| 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; |
---|
11092 | 11115 | } |
---|
11093 | 11116 | |
---|
11094 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
13396 | 13419 | program = programmin; |
---|
13397 | 13420 | } |
---|
13398 | 13421 | |
---|
13399 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13400 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 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 | + |
---|
13401 | 13428 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13402 | 13429 | |
---|
13403 | 13430 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13444 | 13471 | "\n" + |
---|
13445 | 13472 | "END\n"; |
---|
13446 | 13473 | |
---|
13447 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13474 | + if (Globals.DEBUG) |
---|
| 13475 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13448 | 13476 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13449 | 13477 | |
---|
13450 | 13478 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
14643 | 14671 | void GoDown(int mod) |
---|
14644 | 14672 | { |
---|
14645 | 14673 | MODIFIERS |= COMMAND; |
---|
| 14674 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14646 | 14675 | /**/ |
---|
14647 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
14648 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14677 | + { |
---|
| 14678 | + if (isVR) |
---|
| 14679 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14680 | + else |
---|
| 14681 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14682 | + } |
---|
14649 | 14683 | else |
---|
14650 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14684 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14651 | 14685 | /**/ |
---|
14652 | 14686 | if ((mod & SHIFT) == SHIFT) |
---|
14653 | 14687 | { |
---|
.. | .. |
---|
14657 | 14691 | mouseMode |= BACKFORTH; |
---|
14658 | 14692 | } |
---|
14659 | 14693 | |
---|
| 14694 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14695 | + |
---|
14660 | 14696 | //prevX = X = anchorX; |
---|
14661 | 14697 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14662 | 14698 | } |
---|
.. | .. |
---|
14665 | 14701 | { |
---|
14666 | 14702 | MODIFIERS |= COMMAND; |
---|
14667 | 14703 | /**/ |
---|
| 14704 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14705 | + |
---|
14668 | 14706 | if((mod&SHIFT) == SHIFT) |
---|
14669 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14707 | + { |
---|
| 14708 | + if (isVR) |
---|
| 14709 | + manipCamera.RotateInterest(0, speed); |
---|
| 14710 | + else |
---|
| 14711 | + manipCamera.RotatePosition(0, speed); |
---|
| 14712 | + } |
---|
14670 | 14713 | else |
---|
14671 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14714 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14672 | 14715 | /**/ |
---|
14673 | 14716 | if ((mod & SHIFT) == SHIFT) |
---|
14674 | 14717 | { |
---|
.. | .. |
---|
14678 | 14721 | mouseMode |= BACKFORTH; |
---|
14679 | 14722 | } |
---|
14680 | 14723 | |
---|
| 14724 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14725 | + |
---|
14681 | 14726 | //prevX = X = anchorX; |
---|
14682 | 14727 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14683 | 14728 | } |
---|
.. | .. |
---|
14687 | 14732 | MODIFIERS |= COMMAND; |
---|
14688 | 14733 | /**/ |
---|
14689 | 14734 | if((mod&SHIFT) == SHIFT) |
---|
14690 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14735 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14691 | 14736 | else |
---|
14692 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14737 | + { |
---|
| 14738 | + if ((mouseMode&VR)!=0) |
---|
| 14739 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14740 | + else |
---|
| 14741 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14742 | + } |
---|
14693 | 14743 | /**/ |
---|
14694 | 14744 | if ((mod & SHIFT) == SHIFT) |
---|
14695 | 14745 | { |
---|
.. | .. |
---|
14699 | 14749 | mouseMode |= ROTATE; |
---|
14700 | 14750 | } // TRANSLATE; |
---|
14701 | 14751 | |
---|
| 14752 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14753 | + |
---|
14702 | 14754 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14703 | 14755 | prevY = Y = anchorY; |
---|
14704 | 14756 | } |
---|
.. | .. |
---|
14708 | 14760 | MODIFIERS |= COMMAND; |
---|
14709 | 14761 | /**/ |
---|
14710 | 14762 | if((mod&SHIFT) == SHIFT) |
---|
14711 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14763 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14712 | 14764 | else |
---|
14713 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14765 | + { |
---|
| 14766 | + if ((mouseMode&VR)!=0) |
---|
| 14767 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14768 | + else |
---|
| 14769 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14770 | + } |
---|
| 14771 | + |
---|
14714 | 14772 | /**/ |
---|
14715 | 14773 | if ((mod & SHIFT) == SHIFT) |
---|
14716 | 14774 | { |
---|
.. | .. |
---|
14720 | 14778 | mouseMode |= ROTATE; |
---|
14721 | 14779 | } // TRANSLATE; |
---|
14722 | 14780 | |
---|
| 14781 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14782 | + |
---|
14723 | 14783 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14724 | 14784 | prevY = Y = anchorY; |
---|
14725 | 14785 | } |
---|
.. | .. |
---|
16104 | 16164 | { |
---|
16105 | 16165 | switch (hitSomething) |
---|
16106 | 16166 | { |
---|
16107 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16167 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16108 | 16168 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16109 | 16169 | break; |
---|
16110 | 16170 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
16130 | 16190 | if (hasMarquee) |
---|
16131 | 16191 | { |
---|
16132 | 16192 | gr.setXORMode(Color.white); |
---|
16133 | | - gr.setColor(Color.red); |
---|
| 16193 | + gr.setColor(Color.white); |
---|
16134 | 16194 | if (!firstime) |
---|
16135 | 16195 | { |
---|
16136 | 16196 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16769 | 16829 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16770 | 16830 | |
---|
16771 | 16831 | cubemap.disable(); |
---|
16772 | | - ////cubemap.unbind(); |
---|
| 16832 | + //cubemap.dispose(); |
---|
| 16833 | + |
---|
16773 | 16834 | if (CULLFACE) |
---|
16774 | 16835 | { |
---|
16775 | 16836 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17305 | 17366 | |
---|
17306 | 17367 | public void init(GLAutoDrawable drawable) |
---|
17307 | 17368 | { |
---|
| 17369 | + if (Globals.DEBUG) |
---|
17308 | 17370 | System.out.println("shadow buffer init"); |
---|
17309 | 17371 | |
---|
17310 | 17372 | GL gl = drawable.getGL(); |
---|