.. | .. |
---|
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 |
---|
.. | .. |
---|
164 | 168 | |
---|
165 | 169 | |
---|
166 | 170 | // OPTIONS |
---|
167 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
168 | 172 | boolean cameraLight = false; |
---|
169 | 173 | boolean UVdebug = false; |
---|
170 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
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 | |
---|
.. | .. |
---|
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 | |
---|
.. | .. |
---|
10683 | 10690 | static boolean init = false; |
---|
10684 | 10691 | |
---|
10685 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
10686 | 10696 | |
---|
10687 | 10697 | public void display(GLAutoDrawable drawable) |
---|
10688 | 10698 | { |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
| 10700 | + { |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(0); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
10689 | 10705 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10690 | 10706 | { |
---|
10691 | 10707 | Grafreed.wav.save(); |
---|
.. | .. |
---|
11077 | 11093 | // |
---|
11078 | 11094 | // newenvy = -1; |
---|
11079 | 11095 | |
---|
11080 | | - if (object.skyboxname != null) |
---|
| 11096 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11081 | 11097 | { |
---|
11082 | | - if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11098 | + if (cubemaprgb == null) |
---|
11083 | 11099 | { |
---|
11084 | | - LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11085 | | - loadedskyboxname = object.skyboxname; |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
11086 | 11101 | } |
---|
| 11102 | + |
---|
| 11103 | + cubemap = cubemaprgb; |
---|
11087 | 11104 | } |
---|
11088 | 11105 | else |
---|
11089 | 11106 | { |
---|
11090 | | - cubemap = null; |
---|
11091 | | - loadedskyboxname = null; |
---|
| 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; |
---|
11092 | 11124 | } |
---|
11093 | 11125 | |
---|
11094 | 11126 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
13396 | 13428 | program = programmin; |
---|
13397 | 13429 | } |
---|
13398 | 13430 | |
---|
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 " : "")); |
---|
| 13431 | + if (Globals.DEBUG) |
---|
| 13432 | + { |
---|
| 13433 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13434 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13435 | + } |
---|
| 13436 | + |
---|
13401 | 13437 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13402 | 13438 | |
---|
13403 | 13439 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13444 | 13480 | "\n" + |
---|
13445 | 13481 | "END\n"; |
---|
13446 | 13482 | |
---|
13447 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13483 | + if (Globals.DEBUG) |
---|
| 13484 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13448 | 13485 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13449 | 13486 | |
---|
13450 | 13487 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
14643 | 14680 | void GoDown(int mod) |
---|
14644 | 14681 | { |
---|
14645 | 14682 | MODIFIERS |= COMMAND; |
---|
| 14683 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14646 | 14684 | /**/ |
---|
14647 | 14685 | if((mod&SHIFT) == SHIFT) |
---|
14648 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14686 | + { |
---|
| 14687 | + if (isVR) |
---|
| 14688 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14691 | + } |
---|
14649 | 14692 | else |
---|
14650 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14693 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14651 | 14694 | /**/ |
---|
14652 | 14695 | if ((mod & SHIFT) == SHIFT) |
---|
14653 | 14696 | { |
---|
.. | .. |
---|
14657 | 14700 | mouseMode |= BACKFORTH; |
---|
14658 | 14701 | } |
---|
14659 | 14702 | |
---|
| 14703 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14704 | + |
---|
14660 | 14705 | //prevX = X = anchorX; |
---|
14661 | 14706 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14662 | 14707 | } |
---|
.. | .. |
---|
14665 | 14710 | { |
---|
14666 | 14711 | MODIFIERS |= COMMAND; |
---|
14667 | 14712 | /**/ |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14714 | + |
---|
14668 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
14669 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, speed); |
---|
| 14721 | + } |
---|
14670 | 14722 | else |
---|
14671 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14723 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14672 | 14724 | /**/ |
---|
14673 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
14674 | 14726 | { |
---|
.. | .. |
---|
14678 | 14730 | mouseMode |= BACKFORTH; |
---|
14679 | 14731 | } |
---|
14680 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
14681 | 14735 | //prevX = X = anchorX; |
---|
14682 | 14736 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14683 | 14737 | } |
---|
.. | .. |
---|
14687 | 14741 | MODIFIERS |= COMMAND; |
---|
14688 | 14742 | /**/ |
---|
14689 | 14743 | if((mod&SHIFT) == SHIFT) |
---|
14690 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14744 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14691 | 14745 | else |
---|
14692 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14746 | + { |
---|
| 14747 | + if ((mouseMode&VR)!=0) |
---|
| 14748 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14751 | + } |
---|
14693 | 14752 | /**/ |
---|
14694 | 14753 | if ((mod & SHIFT) == SHIFT) |
---|
14695 | 14754 | { |
---|
.. | .. |
---|
14699 | 14758 | mouseMode |= ROTATE; |
---|
14700 | 14759 | } // TRANSLATE; |
---|
14701 | 14760 | |
---|
| 14761 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14762 | + |
---|
14702 | 14763 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14703 | 14764 | prevY = Y = anchorY; |
---|
14704 | 14765 | } |
---|
.. | .. |
---|
14708 | 14769 | MODIFIERS |= COMMAND; |
---|
14709 | 14770 | /**/ |
---|
14710 | 14771 | if((mod&SHIFT) == SHIFT) |
---|
14711 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14772 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14712 | 14773 | else |
---|
14713 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14774 | + { |
---|
| 14775 | + if ((mouseMode&VR)!=0) |
---|
| 14776 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14777 | + else |
---|
| 14778 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14779 | + } |
---|
| 14780 | + |
---|
14714 | 14781 | /**/ |
---|
14715 | 14782 | if ((mod & SHIFT) == SHIFT) |
---|
14716 | 14783 | { |
---|
.. | .. |
---|
14720 | 14787 | mouseMode |= ROTATE; |
---|
14721 | 14788 | } // TRANSLATE; |
---|
14722 | 14789 | |
---|
| 14790 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14791 | + |
---|
14723 | 14792 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14724 | 14793 | prevY = Y = anchorY; |
---|
14725 | 14794 | } |
---|
.. | .. |
---|
15222 | 15291 | case 'K': |
---|
15223 | 15292 | KOMPACTTEXTURE ^= true; |
---|
15224 | 15293 | //textures.clear(); |
---|
15225 | | - break; |
---|
15226 | | - case 'P': // Texture Projection macros |
---|
| 15294 | + // break; |
---|
| 15295 | + //case 'P': // Texture Projection macros |
---|
15227 | 15296 | // SAVETEXTURE ^= true; |
---|
15228 | 15297 | macromode = true; |
---|
15229 | 15298 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15344 | 15413 | targetLookAt.set(manipCamera.lookAt); |
---|
15345 | 15414 | repaint(); |
---|
15346 | 15415 | break; |
---|
15347 | | - case 'p': |
---|
| 15416 | + case 'P': // p': |
---|
15348 | 15417 | // c'est quoi ca au juste? spherical ^= true; |
---|
15349 | 15418 | Skinshader ^= true; programInitialized = false; |
---|
15350 | 15419 | repaint(); |
---|
.. | .. |
---|
16104 | 16173 | { |
---|
16105 | 16174 | switch (hitSomething) |
---|
16106 | 16175 | { |
---|
16107 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16176 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16108 | 16177 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16109 | 16178 | break; |
---|
16110 | 16179 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
16130 | 16199 | if (hasMarquee) |
---|
16131 | 16200 | { |
---|
16132 | 16201 | gr.setXORMode(Color.white); |
---|
16133 | | - gr.setColor(Color.red); |
---|
| 16202 | + gr.setColor(Color.white); |
---|
16134 | 16203 | if (!firstime) |
---|
16135 | 16204 | { |
---|
16136 | 16205 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16769 | 16838 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16770 | 16839 | |
---|
16771 | 16840 | cubemap.disable(); |
---|
16772 | | - ////cubemap.unbind(); |
---|
| 16841 | + //cubemap.dispose(); |
---|
| 16842 | + |
---|
16773 | 16843 | if (CULLFACE) |
---|
16774 | 16844 | { |
---|
16775 | 16845 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17305 | 17375 | |
---|
17306 | 17376 | public void init(GLAutoDrawable drawable) |
---|
17307 | 17377 | { |
---|
| 17378 | + if (Globals.DEBUG) |
---|
17308 | 17379 | System.out.println("shadow buffer init"); |
---|
17309 | 17380 | |
---|
17310 | 17381 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17533 | 17604 | gl.glFlush(); |
---|
17534 | 17605 | |
---|
17535 | 17606 | /**/ |
---|
17536 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17607 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17537 | 17608 | |
---|
17538 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17609 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17539 | 17610 | |
---|
| 17611 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17612 | + |
---|
| 17613 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17614 | + |
---|
17540 | 17615 | double r = 0, g = 0, b = 0; |
---|
17541 | 17616 | |
---|
17542 | 17617 | double count = 0; |
---|
.. | .. |
---|
17547 | 17622 | |
---|
17548 | 17623 | double FACTOR = 1; |
---|
17549 | 17624 | |
---|
17550 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17625 | + for (int i = 0; i < depths.length; i++) |
---|
17551 | 17626 | { |
---|
17552 | 17627 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17553 | 17628 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17630 | 17705 | |
---|
17631 | 17706 | double scale = ray.z; // 1; // cos |
---|
17632 | 17707 | |
---|
17633 | | - float depth = pixels[newindex]; |
---|
| 17708 | + float depth = depths[newindex]; |
---|
17634 | 17709 | |
---|
17635 | 17710 | /* |
---|
17636 | 17711 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17827 | 17902 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17828 | 17903 | static IntBuffer bigAAbuffer; |
---|
17829 | 17904 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17830 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17905 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17831 | 17906 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17832 | 17907 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17833 | 17908 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17834 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17909 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17910 | + |
---|
| 17911 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17912 | + |
---|
17835 | 17913 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17836 | 17914 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17837 | 17915 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|