.. | .. |
---|
1 | 1 | |
---|
| 2 | +import com.bulletphysics.dynamics.RigidBody; |
---|
2 | 3 | import java.awt.*; |
---|
3 | 4 | import java.awt.event.*; |
---|
4 | 5 | import java.awt.image.*; |
---|
.. | .. |
---|
18 | 19 | import javax.imageio.ImageIO; |
---|
19 | 20 | import javax.imageio.ImageWriteParam; |
---|
20 | 21 | import javax.imageio.ImageWriter; |
---|
| 22 | +import javax.imageio.ImageReadParam; |
---|
| 23 | +import javax.imageio.ImageReader; |
---|
21 | 24 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 25 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 26 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 27 | import javax.imageio.ImageWriteParam; |
---|
24 | 28 | |
---|
.. | .. |
---|
30 | 34 | import java.nio.*; |
---|
31 | 35 | |
---|
32 | 36 | import gleem.linalg.Mat4f; |
---|
| 37 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 38 | |
---|
34 | 39 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 40 | { |
---|
.. | .. |
---|
44 | 49 | static boolean ABORTED = false; |
---|
45 | 50 | |
---|
46 | 51 | static int STEP = 1; |
---|
| 52 | + |
---|
| 53 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 54 | + { |
---|
| 55 | + int[] pixels = new int[bytes.length/3]; |
---|
| 56 | + for (int i=pixels.length; --i>=0;) |
---|
| 57 | + { |
---|
| 58 | + int i3 = i*3; |
---|
| 59 | + pixels[i] = 0xFF; |
---|
| 60 | + pixels[i] <<= 8; |
---|
| 61 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 62 | + pixels[i] <<= 8; |
---|
| 63 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 64 | + pixels[i] <<= 8; |
---|
| 65 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 66 | + } |
---|
| 67 | + /* |
---|
| 68 | + int r=0,g=0,b=0,a=0; |
---|
| 69 | + for (int i=0; i<width; i++) |
---|
| 70 | + for (int j=0; j<height; j++) |
---|
| 71 | + { |
---|
| 72 | + int index = j*width+i; |
---|
| 73 | + int p = pixels[index]; |
---|
| 74 | + a = ((p>>24) & 0xFF); |
---|
| 75 | + r = ((p>>16) & 0xFF); |
---|
| 76 | + g = ((p>>8) & 0xFF); |
---|
| 77 | + b = (p & 0xFF); |
---|
| 78 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 79 | + } |
---|
| 80 | + /**/ |
---|
| 81 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 82 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 83 | + return rendImage; |
---|
| 84 | + } |
---|
47 | 85 | |
---|
48 | 86 | /*static*/ private boolean CULLFACE = false; // true; |
---|
49 | 87 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
60 | 98 | //boolean REDUCETEXTURE = true; |
---|
61 | 99 | boolean CACHETEXTURE = true; |
---|
62 | 100 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 101 | + boolean MIPMAP = false; // true; // never works... |
---|
64 | 102 | boolean COMPRESSTEXTURE = false; |
---|
65 | 103 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 104 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
73 | 111 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
74 | 112 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
75 | 113 | static GLContext glcontext = null; |
---|
76 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 116 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 117 | + boolean transformMode; |
---|
| 118 | + |
---|
77 | 119 | boolean reverseUP = false; |
---|
78 | 120 | static boolean frozen = false; |
---|
79 | 121 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
93 | 135 | static boolean ZOOMBOXMODE = false; |
---|
94 | 136 | static boolean BOXMODE = false; |
---|
95 | 137 | static boolean IMAGEFLIP = false; |
---|
96 | | -static boolean SMOOTHFOCUS = false; |
---|
| 138 | +static boolean SMOOTHFOCUS = true; // false; |
---|
97 | 139 | static boolean SPEAKERMOCAP = true; // jan 2014 false; |
---|
98 | 140 | static boolean SPEAKERCAMERA = false; |
---|
99 | 141 | static boolean SPEAKERFOCUS = false; |
---|
.. | .. |
---|
127 | 169 | |
---|
128 | 170 | |
---|
129 | 171 | // OPTIONS |
---|
130 | | - boolean Skinshader = true; |
---|
| 172 | + boolean Skinshader = false; // true; |
---|
131 | 173 | boolean cameraLight = false; |
---|
132 | 174 | boolean UVdebug = false; |
---|
133 | 175 | boolean Udebug = false; |
---|
134 | 176 | boolean Vdebug = false; |
---|
135 | 177 | boolean NORMALdebug = false; |
---|
136 | | - static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
| 178 | + static boolean doublesided = true; // false; // reversed normals are awful for conformance |
---|
137 | 179 | boolean anisotropy = true; |
---|
138 | 180 | boolean softshadow = true; // slower but better false; |
---|
139 | | - boolean opacityhalo = false; |
---|
| 181 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
140 | 182 | |
---|
141 | 183 | boolean macromode = false; |
---|
142 | 184 | |
---|
.. | .. |
---|
150 | 192 | } |
---|
151 | 193 | |
---|
152 | 194 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 195 | + |
---|
| 196 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 197 | + { |
---|
| 198 | + try |
---|
| 199 | + { |
---|
| 200 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 201 | + } catch (IOException e) |
---|
| 202 | + { |
---|
| 203 | + System.out.println("NAME = " + name); |
---|
| 204 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 205 | + return null; |
---|
| 206 | + } |
---|
| 207 | + } |
---|
153 | 208 | |
---|
154 | 209 | void SetAsGLRenderer(boolean b) |
---|
155 | 210 | { |
---|
.. | .. |
---|
167 | 222 | cameras = new Camera[2]; |
---|
168 | 223 | targetLookAts = new cVector[2]; |
---|
169 | 224 | |
---|
170 | | - SetCamera(cam); |
---|
| 225 | + SetCamera(cam, true); |
---|
171 | 226 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 227 | + // Warning: not used. |
---|
| 228 | + //SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 229 | |
---|
174 | 230 | object = o; |
---|
175 | 231 | |
---|
.. | .. |
---|
487 | 543 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
488 | 544 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
489 | 545 | LA.vecNormalize(obj.v2); |
---|
490 | | - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 546 | + |
---|
| 547 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
491 | 548 | } |
---|
492 | 549 | |
---|
493 | 550 | // P |
---|
.. | .. |
---|
509 | 566 | y += ny * obj.NORMALPUSH; |
---|
510 | 567 | z += nz * obj.NORMALPUSH; |
---|
511 | 568 | |
---|
512 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 569 | + SetGLNormal(gl, nx, ny, nz); |
---|
513 | 570 | } |
---|
514 | 571 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
515 | 572 | SetColor(obj, pv); |
---|
.. | .. |
---|
541 | 598 | y += ny * obj.NORMALPUSH; |
---|
542 | 599 | z += nz * obj.NORMALPUSH; |
---|
543 | 600 | |
---|
544 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 601 | + SetGLNormal(gl, nx, ny, nz); |
---|
545 | 602 | } |
---|
546 | 603 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
547 | 604 | // boolean locked = false; |
---|
.. | .. |
---|
589 | 646 | y += ny * obj.NORMALPUSH; |
---|
590 | 647 | z += nz * obj.NORMALPUSH; |
---|
591 | 648 | |
---|
592 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 649 | + SetGLNormal(gl, nx, ny, nz); |
---|
593 | 650 | } |
---|
594 | 651 | |
---|
595 | 652 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
825 | 882 | //// tris.postdraw(this); |
---|
826 | 883 | } |
---|
827 | 884 | |
---|
828 | | - static Camera localcamera = new Camera(); |
---|
| 885 | + static Camera localAOcamera = new Camera(); |
---|
829 | 886 | static cVector from = new cVector(); |
---|
830 | 887 | static cVector to = new cVector(); |
---|
831 | 888 | |
---|
.. | .. |
---|
834 | 891 | CameraPane cp = this; |
---|
835 | 892 | |
---|
836 | 893 | Camera keep = cp.RenderCamera(); |
---|
837 | | - cp.renderCamera = localcamera; |
---|
| 894 | + cp.renderCamera = localAOcamera; |
---|
838 | 895 | |
---|
839 | 896 | if (br.trimmed) |
---|
840 | 897 | { |
---|
.. | .. |
---|
852 | 909 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
853 | 910 | LA.xformPos(from, transform, from); |
---|
854 | 911 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
855 | | - localcamera.setAim(from, to); |
---|
| 912 | + localAOcamera.setAim(from, to); |
---|
856 | 913 | |
---|
857 | 914 | CameraPane.occlusionbuffer.display(); |
---|
858 | 915 | |
---|
.. | .. |
---|
886 | 943 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
887 | 944 | LA.xformPos(from, transform, from); |
---|
888 | 945 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
889 | | - localcamera.setAim(from, to); |
---|
| 946 | + localAOcamera.setAim(from, to); |
---|
890 | 947 | |
---|
891 | 948 | CameraPane.occlusionbuffer.display(); |
---|
892 | 949 | |
---|
.. | .. |
---|
1195 | 1252 | { |
---|
1196 | 1253 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1197 | 1254 | { |
---|
1198 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1255 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1199 | 1256 | } else |
---|
1200 | 1257 | { |
---|
1201 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1258 | + SetGLNormal(gl, 0, 0, 1); |
---|
1202 | 1259 | } |
---|
1203 | 1260 | |
---|
1204 | 1261 | if (c != null) |
---|
.. | .. |
---|
1222 | 1279 | { |
---|
1223 | 1280 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1224 | 1281 | { |
---|
1225 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1282 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1226 | 1283 | } else |
---|
1227 | 1284 | { |
---|
1228 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1285 | + SetGLNormal(gl, 0, 0, 1); |
---|
1229 | 1286 | } |
---|
1230 | 1287 | if (c != null) |
---|
1231 | 1288 | { |
---|
.. | .. |
---|
1250 | 1307 | { |
---|
1251 | 1308 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1252 | 1309 | { |
---|
1253 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1310 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1254 | 1311 | } else |
---|
1255 | 1312 | { |
---|
1256 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1313 | + SetGLNormal(gl, 0, 0, 1); |
---|
1257 | 1314 | } |
---|
1258 | 1315 | if (c != null) |
---|
1259 | 1316 | { |
---|
.. | .. |
---|
1435 | 1492 | { |
---|
1436 | 1493 | if (!selectmode) |
---|
1437 | 1494 | { |
---|
1438 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1495 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
1439 | 1496 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1440 | 1497 | |
---|
1441 | 1498 | if (flipV) |
---|
.. | .. |
---|
1447 | 1504 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1448 | 1505 | } |
---|
1449 | 1506 | |
---|
| 1507 | + float[] colorV = new float[4]; |
---|
| 1508 | + |
---|
1450 | 1509 | void SetColor(Object3D obj, Vertex p0) |
---|
1451 | 1510 | { |
---|
1452 | 1511 | CameraPane display = this; |
---|
.. | .. |
---|
1514 | 1573 | { |
---|
1515 | 1574 | return; |
---|
1516 | 1575 | } |
---|
1517 | | - |
---|
1518 | | - float[] colorV = new float[3]; |
---|
1519 | 1576 | |
---|
1520 | 1577 | if (false) // marked) |
---|
1521 | 1578 | { |
---|
.. | .. |
---|
1764 | 1821 | |
---|
1765 | 1822 | display.modelParams7[0] = 0; |
---|
1766 | 1823 | display.modelParams7[1] = 1000; |
---|
1767 | | - display.modelParams7[2] = 0; |
---|
| 1824 | + display.modelParams7[2] = material.parallax; |
---|
1768 | 1825 | display.modelParams7[3] = 0; |
---|
1769 | 1826 | |
---|
1770 | 1827 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
1997 | 2054 | switch(viewcode) |
---|
1998 | 2055 | { |
---|
1999 | 2056 | case 0: return "main"; |
---|
2000 | | - case 1: return "one"; |
---|
2001 | | - case 2: return "two"; |
---|
2002 | | - case 3: return "three"; |
---|
| 2057 | + case 1: return "Red"; |
---|
| 2058 | + case 2: return "Green"; |
---|
| 2059 | + case 3: return "Blue"; |
---|
2003 | 2060 | case 4: return "light"; |
---|
2004 | 2061 | } |
---|
2005 | 2062 | |
---|
.. | .. |
---|
2008 | 2065 | |
---|
2009 | 2066 | static int camerachangeframe; |
---|
2010 | 2067 | |
---|
2011 | | - public boolean SetCamera(Camera cam) |
---|
| 2068 | + public boolean SetCamera(Camera cam, boolean set) |
---|
2012 | 2069 | { |
---|
2013 | 2070 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
2014 | 2071 | // return false; |
---|
.. | .. |
---|
2026 | 2083 | |
---|
2027 | 2084 | camerachangeframe = Globals.framecount; |
---|
2028 | 2085 | |
---|
2029 | | - cam.hAspect = -1; // Read only |
---|
| 2086 | + if (cam != null) |
---|
| 2087 | + cam.hAspect = -1; // Read only |
---|
2030 | 2088 | |
---|
2031 | 2089 | cameras[0] = cam; |
---|
2032 | 2090 | targetLookAts[0] = new cVector(cam.lookAt); |
---|
.. | .. |
---|
2036 | 2094 | { |
---|
2037 | 2095 | cameras[i] = new Camera(cam.viewCode); |
---|
2038 | 2096 | } |
---|
2039 | | - |
---|
2040 | | - cameras[i].setAim(cam.location, cam.lookAt); |
---|
2041 | | - cameras[i].shaper_fovy = cam.shaper_fovy; |
---|
2042 | | - cameras[i].UP.set(cam.UP); |
---|
2043 | | - targetLookAts[i] = new cVector(cameras[i].lookAt); |
---|
| 2097 | + |
---|
| 2098 | + if (set) |
---|
| 2099 | + { |
---|
| 2100 | + cameras[i].setAim(cam.location, cam.lookAt); |
---|
| 2101 | + cameras[i].shaper_fovy = cam.shaper_fovy; |
---|
| 2102 | + cameras[i].UP.set(cam.UP); |
---|
| 2103 | + targetLookAts[i] = new cVector(cameras[i].lookAt); |
---|
| 2104 | + } |
---|
2044 | 2105 | } |
---|
2045 | 2106 | cameracount = 0; |
---|
2046 | 2107 | targetLookAt = targetLookAts[cameracount]; |
---|
.. | .. |
---|
2049 | 2110 | // Start with free camera |
---|
2050 | 2111 | SwitchCameras(true); |
---|
2051 | 2112 | |
---|
2052 | | - pingthread.jump = true; // optional? |
---|
| 2113 | +// pingthread.jump = true; // optional? |
---|
2053 | 2114 | |
---|
2054 | 2115 | if (TRACKONCE) |
---|
2055 | 2116 | { |
---|
.. | .. |
---|
2065 | 2126 | //System.err.println("Oeil on"); |
---|
2066 | 2127 | OEIL = true; |
---|
2067 | 2128 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2068 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2129 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2069 | 2130 | //pingthread.StepToTarget(true); |
---|
2070 | 2131 | } |
---|
2071 | 2132 | |
---|
.. | .. |
---|
2236 | 2297 | public void ToggleTrack() |
---|
2237 | 2298 | { |
---|
2238 | 2299 | TRACK ^= true; |
---|
2239 | | - if (TRACK) |
---|
2240 | | - { |
---|
2241 | | - if (object.selection != null && |
---|
2242 | | - object.selection.size() > 0 && |
---|
2243 | | - object.selection.elementAt(0) != null && |
---|
2244 | | - !(object.selection.elementAt(0) instanceof Camera) && |
---|
2245 | | - !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
2246 | | - { |
---|
2247 | | - trackedobject = object.selection.elementAt(0); |
---|
2248 | | - repaint(); |
---|
2249 | | - } |
---|
2250 | | - } |
---|
2251 | 2300 | |
---|
2252 | 2301 | repaint(); |
---|
2253 | 2302 | } |
---|
.. | .. |
---|
2298 | 2347 | HANDLES ^= true; |
---|
2299 | 2348 | } |
---|
2300 | 2349 | |
---|
| 2350 | + Object3D paintFolder; |
---|
| 2351 | + |
---|
2301 | 2352 | void TogglePaint() |
---|
2302 | 2353 | { |
---|
2303 | 2354 | PAINTMODE ^= true; |
---|
2304 | 2355 | paintcount = 0; |
---|
| 2356 | + |
---|
| 2357 | + if (PAINTMODE) |
---|
| 2358 | + { |
---|
| 2359 | + paintFolder = GetFolder(); |
---|
| 2360 | + } |
---|
2305 | 2361 | } |
---|
2306 | 2362 | |
---|
2307 | 2363 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2332 | 2388 | { |
---|
2333 | 2389 | //System.out.println("PROTECTION = " + cam.hAspect); |
---|
2334 | 2390 | //assert (cam.hAspect == 0); |
---|
2335 | | - cam.hAspect = 0; |
---|
| 2391 | + if (cam != null) |
---|
| 2392 | + cam.hAspect = 0; |
---|
2336 | 2393 | lightCamera = cam; |
---|
2337 | 2394 | } |
---|
2338 | 2395 | |
---|
.. | .. |
---|
2398 | 2455 | return currentGL; |
---|
2399 | 2456 | } |
---|
2400 | 2457 | |
---|
| 2458 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2459 | + { |
---|
| 2460 | + Grafreed.Assert(texturedata != null); |
---|
| 2461 | + |
---|
| 2462 | + int width = texturedata.getWidth(); |
---|
| 2463 | + int height = texturedata.getHeight(); |
---|
| 2464 | + |
---|
| 2465 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2466 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2467 | + |
---|
| 2468 | + byte[] bytes = bytebuf.array(); |
---|
| 2469 | + |
---|
| 2470 | + return CreateBim(bytes, width, height); |
---|
| 2471 | + } |
---|
| 2472 | + |
---|
| 2473 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2474 | + { |
---|
| 2475 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2476 | + |
---|
| 2477 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2478 | + // Ground or ceiling |
---|
| 2479 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2480 | + else |
---|
| 2481 | + // Walls |
---|
| 2482 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2483 | + } |
---|
| 2484 | + |
---|
2401 | 2485 | /**/ |
---|
2402 | 2486 | class CacheTexture |
---|
2403 | 2487 | { |
---|
.. | .. |
---|
2406 | 2490 | |
---|
2407 | 2491 | int resolution; |
---|
2408 | 2492 | |
---|
2409 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2493 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2410 | 2494 | { |
---|
2411 | | - texture = tex; |
---|
| 2495 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2496 | + texturedata = texdata; |
---|
2412 | 2497 | resolution = res; |
---|
2413 | 2498 | } |
---|
2414 | 2499 | } |
---|
2415 | 2500 | /**/ |
---|
2416 | 2501 | |
---|
2417 | 2502 | // TEXTURE static Texture texture; |
---|
2418 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2419 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2420 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2503 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2504 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2505 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2506 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2507 | + |
---|
2421 | 2508 | int pigmentdepth = 0; |
---|
2422 | 2509 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2423 | 2510 | int bumpdepth = 0; |
---|
2424 | 2511 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2425 | 2512 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2426 | 2513 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2427 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2514 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2428 | 2515 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2429 | 2516 | |
---|
2430 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2517 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2431 | 2518 | { |
---|
2432 | 2519 | TextureData texturedata = null; |
---|
2433 | 2520 | |
---|
.. | .. |
---|
2437 | 2524 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2438 | 2525 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2439 | 2526 | true, |
---|
2440 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2527 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2441 | 2528 | } catch (java.io.IOException e) |
---|
2442 | 2529 | { |
---|
2443 | 2530 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2446 | 2533 | if (bump) |
---|
2447 | 2534 | texturedata = ConvertBump(texturedata, false); |
---|
2448 | 2535 | |
---|
2449 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2450 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2536 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2537 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2451 | 2538 | |
---|
2452 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2453 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2539 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2540 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2454 | 2541 | |
---|
2455 | | - return texture; |
---|
| 2542 | + return texturedata; |
---|
| 2543 | + } |
---|
| 2544 | + |
---|
| 2545 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2546 | + { |
---|
| 2547 | + TextureData texturedata = null; |
---|
| 2548 | + |
---|
| 2549 | + try |
---|
| 2550 | + { |
---|
| 2551 | + texturedata = |
---|
| 2552 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2553 | + bim, |
---|
| 2554 | + true); |
---|
| 2555 | + } catch (Exception e) |
---|
| 2556 | + { |
---|
| 2557 | + throw new javax.media.opengl.GLException(e); |
---|
| 2558 | + } |
---|
| 2559 | + |
---|
| 2560 | + if (bump) |
---|
| 2561 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2562 | + |
---|
| 2563 | + return texturedata; |
---|
2456 | 2564 | } |
---|
2457 | 2565 | |
---|
2458 | 2566 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3482 | 3590 | }; |
---|
3483 | 3591 | /**/ |
---|
3484 | 3592 | |
---|
| 3593 | + static Object3D lastObject; |
---|
| 3594 | + |
---|
3485 | 3595 | //com.sun.opengl.util.texture.Texture |
---|
3486 | 3596 | TextureData |
---|
3487 | 3597 | GetFileTexture(String name, boolean bump, int resolution) |
---|
.. | .. |
---|
3518 | 3628 | // return null; |
---|
3519 | 3629 | //if (i == 2) |
---|
3520 | 3630 | // return null; |
---|
| 3631 | + // TIFF issue sept 2019 |
---|
| 3632 | + System.err.println("lastObject = " + lastObject); |
---|
3521 | 3633 | e.printStackTrace(); |
---|
3522 | 3634 | name = name.split("\\.tif")[0] + ".jpg"; |
---|
3523 | 3635 | } |
---|
.. | .. |
---|
3525 | 3637 | |
---|
3526 | 3638 | System.out.println("LOADING TEXTURE : " + name); |
---|
3527 | 3639 | |
---|
| 3640 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3641 | + |
---|
3528 | 3642 | // |
---|
3529 | 3643 | if (false) // compressbit > 0) |
---|
3530 | 3644 | { |
---|
.. | .. |
---|
6848 | 6962 | short residu = 0; |
---|
6849 | 6963 | |
---|
6850 | 6964 | // wraparound workarounds |
---|
6851 | | - short fuck = (short) (buffer[i] & 0xFF); |
---|
| 6965 | + short ww = (short) (buffer[i] & 0xFF); |
---|
6852 | 6966 | /* |
---|
6853 | | - residu += (fuck%2); |
---|
6854 | | - if(fuck/2 < 256-residu/2) |
---|
| 6967 | + residu += (ww%2); |
---|
| 6968 | + if(ww/2 < 256-residu/2) |
---|
6855 | 6969 | { |
---|
6856 | | - fuck = (short)((fuck/2) + residu/2); |
---|
| 6970 | + ww = (short)((ww/2) + residu/2); |
---|
6857 | 6971 | if(residu == 2) |
---|
6858 | 6972 | residu = 0; |
---|
6859 | 6973 | } |
---|
6860 | 6974 | else |
---|
6861 | 6975 | { |
---|
6862 | 6976 | residu = 0; |
---|
6863 | | - fuck /= 2; |
---|
| 6977 | + ww /= 2; |
---|
6864 | 6978 | } |
---|
6865 | 6979 | */ |
---|
6866 | | - if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254) |
---|
| 6980 | + if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254) |
---|
6867 | 6981 | { |
---|
6868 | | - fuck /= 2; |
---|
| 6982 | + ww /= 2; |
---|
6869 | 6983 | } else |
---|
6870 | 6984 | { |
---|
6871 | | - fuck = (short) ((fuck / 2) + fuck % 2); |
---|
| 6985 | + ww = (short) ((ww / 2) + ww % 2); |
---|
6872 | 6986 | } |
---|
6873 | 6987 | |
---|
6874 | | - buffer[i] = (byte) fuck; |
---|
| 6988 | + buffer[i] = (byte) ww; |
---|
6875 | 6989 | } |
---|
6876 | 6990 | //System.out.print(bytes[i] + " "); |
---|
6877 | 6991 | //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps; |
---|
.. | .. |
---|
7923 | 8037 | String pigment = Object3D.GetPigment(tex); |
---|
7924 | 8038 | String bump = Object3D.GetBump(tex); |
---|
7925 | 8039 | |
---|
7926 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8040 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7927 | 8041 | { |
---|
7928 | 8042 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7929 | 8043 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7938 | 8052 | pigment = null; |
---|
7939 | 8053 | } |
---|
7940 | 8054 | |
---|
7941 | | - ReleaseTexture(bump, true); |
---|
7942 | | - ReleaseTexture(pigment, false); |
---|
| 8055 | + ReleaseTexture(tex, true); |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
7943 | 8057 | } |
---|
7944 | 8058 | |
---|
7945 | 8059 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7957 | 8071 | |
---|
7958 | 8072 | String pigment = Object3D.GetPigment(tex); |
---|
7959 | 8073 | |
---|
7960 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7961 | 8075 | { |
---|
7962 | 8076 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7963 | 8077 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7968 | 8082 | pigment = null; |
---|
7969 | 8083 | } |
---|
7970 | 8084 | |
---|
7971 | | - ReleaseTexture(pigment, false); |
---|
| 8085 | + ReleaseTexture(tex, false); |
---|
7972 | 8086 | } |
---|
7973 | 8087 | |
---|
7974 | 8088 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7986 | 8100 | |
---|
7987 | 8101 | String bump = Object3D.GetBump(tex); |
---|
7988 | 8102 | |
---|
7989 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8103 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7990 | 8104 | { |
---|
7991 | 8105 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7992 | 8106 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7997 | 8111 | bump = null; |
---|
7998 | 8112 | } |
---|
7999 | 8113 | |
---|
8000 | | - ReleaseTexture(bump, true); |
---|
| 8114 | + ReleaseTexture(tex, true); |
---|
8001 | 8115 | } |
---|
8002 | 8116 | |
---|
8003 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8117 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8004 | 8118 | { |
---|
8005 | 8119 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8006 | 8120 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8011 | 8125 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8012 | 8126 | |
---|
8013 | 8127 | if (tex != null) |
---|
8014 | | - texture = textures.get(tex); |
---|
| 8128 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8015 | 8129 | |
---|
8016 | 8130 | // //assert( texture != null ); |
---|
8017 | 8131 | // if (texture == null) |
---|
.. | .. |
---|
8105 | 8219 | |
---|
8106 | 8220 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8107 | 8221 | { |
---|
8108 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8109 | | - ambientOcclusion ) // || !textureon) |
---|
8110 | | - { |
---|
8111 | | - return; // false; |
---|
8112 | | - } |
---|
8113 | | - |
---|
8114 | | - if (tex == null) |
---|
8115 | | - { |
---|
8116 | | - BindTexture(null,false,resolution); |
---|
8117 | | - BindTexture(null,true,resolution); |
---|
8118 | | - return; |
---|
8119 | | - } |
---|
| 8222 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8223 | +// ambientOcclusion ) // || !textureon) |
---|
| 8224 | +// { |
---|
| 8225 | +// return; // false; |
---|
| 8226 | +// } |
---|
| 8227 | +// |
---|
| 8228 | +// if (tex == null) |
---|
| 8229 | +// { |
---|
| 8230 | +// BindTexture(null,false,resolution); |
---|
| 8231 | +// BindTexture(null,true,resolution); |
---|
| 8232 | +// return; |
---|
| 8233 | +// } |
---|
| 8234 | +// |
---|
| 8235 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8236 | +// String bump = Object3D.GetBump(tex); |
---|
| 8237 | +// |
---|
| 8238 | +// usedtextures.add(pigment); |
---|
| 8239 | +// usedtextures.add(bump); |
---|
| 8240 | +// |
---|
| 8241 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8242 | +// { |
---|
| 8243 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8244 | +// // System.out.println("; bump = " + bump); |
---|
| 8245 | +// } |
---|
| 8246 | +// |
---|
| 8247 | +// if (bump.equals("")) |
---|
| 8248 | +// { |
---|
| 8249 | +// bump = null; |
---|
| 8250 | +// } |
---|
| 8251 | +// if (pigment.equals("")) |
---|
| 8252 | +// { |
---|
| 8253 | +// pigment = null; |
---|
| 8254 | +// } |
---|
| 8255 | +// |
---|
| 8256 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8257 | +// BindTexture(pigment, false, resolution); |
---|
| 8258 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8259 | +// BindTexture(bump, true, resolution); |
---|
| 8260 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8261 | +// |
---|
| 8262 | +// return; // true; |
---|
8120 | 8263 | |
---|
8121 | | - String pigment = Object3D.GetPigment(tex); |
---|
8122 | | - String bump = Object3D.GetBump(tex); |
---|
8123 | | - |
---|
8124 | | - usedtextures.put(pigment, pigment); |
---|
8125 | | - usedtextures.put(bump, bump); |
---|
8126 | | - |
---|
8127 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8128 | | - { |
---|
8129 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8130 | | - // System.out.println("; bump = " + bump); |
---|
8131 | | - } |
---|
8132 | | - |
---|
8133 | | - if (bump.equals("")) |
---|
8134 | | - { |
---|
8135 | | - bump = null; |
---|
8136 | | - } |
---|
8137 | | - if (pigment.equals("")) |
---|
8138 | | - { |
---|
8139 | | - pigment = null; |
---|
8140 | | - } |
---|
8141 | | - |
---|
8142 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8143 | | - BindTexture(pigment, false, resolution); |
---|
8144 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8145 | | - BindTexture(bump, true, resolution); |
---|
8146 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8147 | | - |
---|
8148 | | - return; // true; |
---|
| 8264 | + BindPigmentTexture(tex, resolution); |
---|
| 8265 | + BindBumpTexture(tex, resolution); |
---|
8149 | 8266 | } |
---|
8150 | 8267 | |
---|
8151 | 8268 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8164 | 8281 | |
---|
8165 | 8282 | String pigment = Object3D.GetPigment(tex); |
---|
8166 | 8283 | |
---|
8167 | | - usedtextures.put(pigment, pigment); |
---|
| 8284 | + usedtextures.add(tex); |
---|
8168 | 8285 | |
---|
8169 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8286 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8170 | 8287 | { |
---|
8171 | 8288 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8172 | 8289 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8178 | 8295 | } |
---|
8179 | 8296 | |
---|
8180 | 8297 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8181 | | - BindTexture(pigment, false, resolution); |
---|
| 8298 | + BindTexture(tex, false, resolution); |
---|
8182 | 8299 | } |
---|
8183 | 8300 | |
---|
8184 | 8301 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8197 | 8314 | |
---|
8198 | 8315 | String bump = Object3D.GetBump(tex); |
---|
8199 | 8316 | |
---|
8200 | | - usedtextures.put(bump, bump); |
---|
| 8317 | + usedtextures.add(tex); |
---|
8201 | 8318 | |
---|
8202 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8319 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8203 | 8320 | { |
---|
8204 | 8321 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8205 | 8322 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8211 | 8328 | } |
---|
8212 | 8329 | |
---|
8213 | 8330 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8214 | | - BindTexture(bump, true, resolution); |
---|
| 8331 | + BindTexture(tex, true, resolution); |
---|
8215 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8216 | 8333 | } |
---|
8217 | 8334 | |
---|
.. | .. |
---|
8235 | 8352 | return fileExists; |
---|
8236 | 8353 | } |
---|
8237 | 8354 | |
---|
8238 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8355 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8239 | 8356 | { |
---|
8240 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8357 | + CacheTexture texturecache = null; |
---|
8241 | 8358 | |
---|
8242 | 8359 | if (tex != null) |
---|
8243 | 8360 | { |
---|
8244 | | - String texname = tex; |
---|
| 8361 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8362 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8363 | + |
---|
| 8364 | + if (texname.equals("") && texdata == null) |
---|
| 8365 | + { |
---|
| 8366 | + return null; |
---|
| 8367 | + } |
---|
8245 | 8368 | |
---|
8246 | 8369 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8247 | 8370 | |
---|
.. | .. |
---|
8251 | 8374 | // else |
---|
8252 | 8375 | // if (!texname.startsWith("/")) |
---|
8253 | 8376 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8254 | | - if (!FileExists(tex)) |
---|
| 8377 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8255 | 8378 | { |
---|
8256 | 8379 | texname = fallbackTextureName; |
---|
8257 | 8380 | } |
---|
8258 | 8381 | |
---|
8259 | 8382 | if (CACHETEXTURE) |
---|
8260 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8261 | | - |
---|
8262 | | - TextureData texturedata = null; |
---|
8263 | | - |
---|
8264 | | - if (texture == null || texture.resolution < resolution) |
---|
8265 | 8383 | { |
---|
8266 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8384 | + if (texdata == null) |
---|
| 8385 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8386 | + else |
---|
| 8387 | + texturecache = bimtextures.get(texdata); |
---|
| 8388 | + } |
---|
| 8389 | + |
---|
| 8390 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8391 | + { |
---|
| 8392 | + TextureData texturedata = null; |
---|
| 8393 | + |
---|
| 8394 | + if (texdata != null && textureon) |
---|
| 8395 | + { |
---|
| 8396 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8397 | + |
---|
| 8398 | + try |
---|
| 8399 | + { |
---|
| 8400 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8401 | + } |
---|
| 8402 | + catch (Exception e) |
---|
| 8403 | + { |
---|
| 8404 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8405 | + } |
---|
| 8406 | + |
---|
| 8407 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8408 | + bimtextures.put(texdata, texturecache); |
---|
| 8409 | + |
---|
| 8410 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8411 | + |
---|
| 8412 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8413 | + //bim2 = bim; |
---|
| 8414 | + } |
---|
| 8415 | + else |
---|
| 8416 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8267 | 8417 | { |
---|
8268 | 8418 | assert(!bump); |
---|
8269 | 8419 | // if (bump) |
---|
.. | .. |
---|
8274 | 8424 | // } |
---|
8275 | 8425 | // else |
---|
8276 | 8426 | // { |
---|
8277 | | - texture = textures.get(tex); |
---|
8278 | | - if (texture == null) |
---|
| 8427 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8428 | + if (texturecache == null) |
---|
8279 | 8429 | { |
---|
8280 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8430 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8281 | 8431 | } |
---|
| 8432 | + else |
---|
| 8433 | + new Exception().printStackTrace(); |
---|
8282 | 8434 | // } |
---|
8283 | 8435 | } else |
---|
8284 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8436 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8285 | 8437 | { |
---|
8286 | 8438 | assert(bump); |
---|
8287 | | - texture = textures.get(tex); |
---|
8288 | | - if (texture == null) |
---|
8289 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8439 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8440 | + if (texturecache == null) |
---|
| 8441 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8442 | + else |
---|
| 8443 | + new Exception().printStackTrace(); |
---|
8290 | 8444 | } else |
---|
8291 | 8445 | { |
---|
8292 | 8446 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8294 | 8448 | // texture = GetResourceTexture("default.png"); |
---|
8295 | 8449 | //} else |
---|
8296 | 8450 | //{ |
---|
8297 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8451 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8298 | 8452 | { |
---|
8299 | | - texture = textures.get(tex); |
---|
8300 | | - if (texture == null) |
---|
8301 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8453 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8454 | + if (texturecache == null) |
---|
| 8455 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.jpg", bump),resolution); |
---|
| 8456 | + else |
---|
| 8457 | + new Exception().printStackTrace(); |
---|
| 8458 | + } else |
---|
| 8459 | + { |
---|
| 8460 | + if (texname.startsWith("@") && textureon) |
---|
| 8461 | + { |
---|
| 8462 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8463 | + if (texturecache == null) |
---|
| 8464 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8465 | + else |
---|
| 8466 | + new Exception().printStackTrace(); |
---|
8302 | 8467 | } else |
---|
8303 | 8468 | { |
---|
8304 | 8469 | if (textureon) |
---|
.. | .. |
---|
8357 | 8522 | if (texturedata == null) |
---|
8358 | 8523 | throw new Exception(); |
---|
8359 | 8524 | |
---|
8360 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8525 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8361 | 8526 | //texture = GetTexture(tex, bump); |
---|
8362 | 8527 | } |
---|
| 8528 | + } |
---|
8363 | 8529 | } |
---|
8364 | 8530 | //} |
---|
8365 | 8531 | } |
---|
8366 | 8532 | |
---|
8367 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8533 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8368 | 8534 | { |
---|
8369 | 8535 | //return false; |
---|
8370 | 8536 | |
---|
8371 | 8537 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8372 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8538 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8373 | 8539 | { |
---|
8374 | 8540 | // String ext = "_highres"; |
---|
8375 | 8541 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8386 | 8552 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8387 | 8553 | if (!cachefile.exists()) |
---|
8388 | 8554 | { |
---|
8389 | | - // cache to disk |
---|
8390 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8391 | | - //buffers[0]. |
---|
8392 | | - |
---|
8393 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8394 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8395 | | - |
---|
8396 | | - // squared size heuristic... |
---|
8397 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8555 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8398 | 8556 | { |
---|
8399 | | - for (int i=pixels.length; --i>=0;) |
---|
8400 | | - { |
---|
8401 | | - int i3 = i*3; |
---|
8402 | | - pixels[i] = 0xFF; |
---|
8403 | | - pixels[i] <<= 8; |
---|
8404 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8405 | | - pixels[i] <<= 8; |
---|
8406 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8407 | | - pixels[i] <<= 8; |
---|
8408 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8409 | | - } |
---|
8410 | | - |
---|
8411 | | - /* |
---|
8412 | | - int r=0,g=0,b=0,a=0; |
---|
8413 | | - for (int i=0; i<width; i++) |
---|
8414 | | - for (int j=0; j<height; j++) |
---|
8415 | | - { |
---|
8416 | | - int index = j*width+i; |
---|
8417 | | - int p = pixels[index]; |
---|
8418 | | - a = ((p>>24) & 0xFF); |
---|
8419 | | - r = ((p>>16) & 0xFF); |
---|
8420 | | - g = ((p>>8) & 0xFF); |
---|
8421 | | - b = (p & 0xFF); |
---|
8422 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8423 | | - } |
---|
8424 | | - /**/ |
---|
8425 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8426 | | - int height = width; |
---|
8427 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8428 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8557 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8558 | + |
---|
8429 | 8559 | ImageWriter writer = null; |
---|
8430 | 8560 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8431 | 8561 | if (iter.hasNext()) { |
---|
8432 | 8562 | writer = (ImageWriter)iter.next(); |
---|
8433 | 8563 | } |
---|
8434 | | - float compressionQuality = 0.9f; |
---|
| 8564 | + |
---|
| 8565 | + float compressionQuality = 0.85f; |
---|
8435 | 8566 | try |
---|
8436 | 8567 | { |
---|
8437 | 8568 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8448 | 8579 | } |
---|
8449 | 8580 | } |
---|
8450 | 8581 | } |
---|
8451 | | - |
---|
| 8582 | + |
---|
| 8583 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8584 | + |
---|
8452 | 8585 | //System.out.println("Texture = " + tex); |
---|
8453 | | - if (textures.containsKey(texname)) |
---|
| 8586 | + if (textures.containsKey(tex)) |
---|
8454 | 8587 | { |
---|
8455 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8588 | + CacheTexture thetex = textures.get(tex); |
---|
8456 | 8589 | thetex.texture.disable(); |
---|
8457 | 8590 | thetex.texture.dispose(); |
---|
8458 | | - textures.remove(texname); |
---|
| 8591 | + textures.remove(tex); |
---|
8459 | 8592 | } |
---|
8460 | 8593 | |
---|
8461 | | - texture.texturedata = texturedata; |
---|
8462 | | - textures.put(texname, texture); |
---|
| 8594 | + //texture.texturedata = texturedata; |
---|
| 8595 | + textures.put(tex, texturecache); |
---|
8463 | 8596 | |
---|
8464 | 8597 | // newtex = true; |
---|
8465 | 8598 | } |
---|
.. | .. |
---|
8475 | 8608 | } |
---|
8476 | 8609 | } |
---|
8477 | 8610 | |
---|
8478 | | - return texture; |
---|
| 8611 | + return texturecache; |
---|
8479 | 8612 | } |
---|
8480 | 8613 | |
---|
8481 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8614 | + static void EmbedTextures(cTexture tex) |
---|
| 8615 | + { |
---|
| 8616 | + if (tex.pigmentdata == null) |
---|
| 8617 | + { |
---|
| 8618 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8619 | + |
---|
| 8620 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8621 | + |
---|
| 8622 | + if (texturecache != null) |
---|
| 8623 | + { |
---|
| 8624 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8625 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8626 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8627 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8628 | + ; |
---|
| 8629 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8630 | + } |
---|
| 8631 | + } |
---|
| 8632 | + |
---|
| 8633 | + if (tex.bumpdata == null) |
---|
| 8634 | + { |
---|
| 8635 | + //String texname = Object3D.GetBump(tex); |
---|
| 8636 | + |
---|
| 8637 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8638 | + |
---|
| 8639 | + if (texturecache != null) |
---|
| 8640 | + { |
---|
| 8641 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8642 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8643 | + tex.bumpdata = //CompressJPEG(CreateBim( |
---|
| 8644 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8645 | + //, tex.bw, tex.bh), 0.5f); |
---|
| 8646 | + } |
---|
| 8647 | + } |
---|
| 8648 | + } |
---|
| 8649 | + |
---|
| 8650 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8482 | 8651 | { |
---|
8483 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8484 | 8653 | |
---|
.. | .. |
---|
8496 | 8665 | return texture!=null?texture.texture:null; |
---|
8497 | 8666 | } |
---|
8498 | 8667 | |
---|
8499 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8668 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8500 | 8669 | { |
---|
8501 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8502 | 8671 | |
---|
8503 | 8672 | return texture!=null?texture.texturedata:null; |
---|
8504 | 8673 | } |
---|
8505 | 8674 | |
---|
8506 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8507 | 8676 | { |
---|
8508 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8509 | 8678 | { |
---|
8510 | 8679 | return false; |
---|
8511 | 8680 | } |
---|
8512 | 8681 | |
---|
8513 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
8514 | 8683 | |
---|
8515 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8516 | 8685 | |
---|
.. | .. |
---|
8542 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8543 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8544 | 8713 | |
---|
8545 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
8546 | 8715 | } |
---|
8547 | 8716 | |
---|
| 8717 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8718 | + { |
---|
| 8719 | + try |
---|
| 8720 | + { |
---|
| 8721 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8722 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8723 | + ImageWriter writer = writers.next(); |
---|
| 8724 | + |
---|
| 8725 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8726 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8727 | + param.setCompressionQuality(quality); |
---|
| 8728 | + |
---|
| 8729 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8730 | + writer.setOutput(ios); |
---|
| 8731 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8732 | + |
---|
| 8733 | + byte[] data = baos.toByteArray(); |
---|
| 8734 | + writer.dispose(); |
---|
| 8735 | + return data; |
---|
| 8736 | + } |
---|
| 8737 | + catch (Exception e) |
---|
| 8738 | + { |
---|
| 8739 | + e.printStackTrace(); |
---|
| 8740 | + return null; |
---|
| 8741 | + } |
---|
| 8742 | + } |
---|
| 8743 | + |
---|
| 8744 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8745 | + { |
---|
| 8746 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8747 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8748 | + ImageReader reader = writers.next(); |
---|
| 8749 | + |
---|
| 8750 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8751 | + |
---|
| 8752 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8753 | + param.setDestination(bim); |
---|
| 8754 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8755 | + |
---|
| 8756 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8757 | + reader.setInput(ios); |
---|
| 8758 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8759 | + reader.dispose(); |
---|
| 8760 | + |
---|
| 8761 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8762 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8763 | +// byte[] bytes = data.getData(); |
---|
| 8764 | +// |
---|
| 8765 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8766 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8767 | +// { |
---|
| 8768 | +// int i3 = i*3; |
---|
| 8769 | +// pixels[i] = 0xFF; |
---|
| 8770 | +// pixels[i] <<= 8; |
---|
| 8771 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8772 | +// pixels[i] <<= 8; |
---|
| 8773 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8774 | +// pixels[i] <<= 8; |
---|
| 8775 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8776 | +// } |
---|
| 8777 | +// |
---|
| 8778 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8779 | + |
---|
| 8780 | + return bim; |
---|
| 8781 | + } |
---|
| 8782 | + |
---|
8548 | 8783 | ShadowBuffer shadowPBuf; |
---|
8549 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8550 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8561 | 8796 | |
---|
8562 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8563 | 8798 | MAXSTACK = temp[0]; |
---|
8564 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8565 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8566 | 8802 | MAXSTACK = temp[0]; |
---|
8567 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8568 | 8805 | |
---|
8569 | 8806 | // Use debug pipeline |
---|
8570 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8572 | 8809 | gl = drawable.getGL(); // |
---|
8573 | 8810 | |
---|
8574 | 8811 | GL gl3 = getGL(); |
---|
8575 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8576 | 8814 | |
---|
8577 | 8815 | |
---|
8578 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8737 | 8975 | |
---|
8738 | 8976 | if (cubemap == null) |
---|
8739 | 8977 | { |
---|
8740 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8741 | 8979 | } |
---|
8742 | 8980 | |
---|
8743 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9013 | 9251 | |
---|
9014 | 9252 | void LoadEnvy(int which) |
---|
9015 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9016 | 9256 | String name; |
---|
9017 | 9257 | String ext; |
---|
9018 | 9258 | |
---|
.. | .. |
---|
9024 | 9264 | cubemap = null; |
---|
9025 | 9265 | return; |
---|
9026 | 9266 | case 1: |
---|
9027 | | - name = "cubemaps/box_"; |
---|
9028 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9029 | 9269 | reverseUP = false; |
---|
9030 | 9270 | break; |
---|
9031 | 9271 | case 2: |
---|
9032 | | - name = "cubemaps/uffizi_"; |
---|
9033 | | - ext = "png"; |
---|
9034 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9035 | 9276 | case 3: |
---|
9036 | | - name = "cubemaps/CloudyHills_"; |
---|
9037 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9038 | 9279 | reverseUP = false; |
---|
9039 | 9280 | break; |
---|
9040 | 9281 | case 4: |
---|
9041 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9042 | 9283 | ext = "png"; |
---|
9043 | 9284 | reverseUP = false; |
---|
9044 | 9285 | break; |
---|
| 9286 | + case 5: |
---|
| 9287 | + name = "cubemaps/skycube/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
| 9291 | + case 6: |
---|
| 9292 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9293 | + ext = "jpg"; |
---|
| 9294 | + reverseUP = false; |
---|
| 9295 | + break; |
---|
| 9296 | + case 7: |
---|
| 9297 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9298 | + ext = "jpg"; |
---|
| 9299 | + reverseUP = false; |
---|
| 9300 | + break; |
---|
| 9301 | + case 8: |
---|
| 9302 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9303 | + ext = "jpg"; |
---|
| 9304 | + reverseUP = false; |
---|
| 9305 | + break; |
---|
| 9306 | + case 9: |
---|
| 9307 | + name = "cubemaps/UnionSquare/"; |
---|
| 9308 | + ext = "jpg"; |
---|
| 9309 | + reverseUP = false; |
---|
| 9310 | + break; |
---|
9045 | 9311 | default: |
---|
9046 | | - name = "cubemaps/rgb_"; |
---|
9047 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9048 | 9315 | break; |
---|
9049 | 9316 | } |
---|
9050 | | - |
---|
9051 | | - try |
---|
9052 | | - { |
---|
9053 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9054 | | - } catch (IOException e) |
---|
9055 | | - { |
---|
9056 | | - throw new RuntimeException(e); |
---|
9057 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9058 | 9319 | } |
---|
9059 | 9320 | |
---|
9060 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9086 | 9347 | static double[] model = new double[16]; |
---|
9087 | 9348 | double[] camera2light = new double[16]; |
---|
9088 | 9349 | double[] light2camera = new double[16]; |
---|
9089 | | - int newenvy = -1; |
---|
9090 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9091 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9092 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9093 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9505 | 9770 | |
---|
9506 | 9771 | if (renderCamera != lightCamera) |
---|
9507 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9508 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9509 | 9774 | |
---|
9510 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9511 | 9776 | |
---|
.. | .. |
---|
9521 | 9786 | |
---|
9522 | 9787 | if (renderCamera != lightCamera) |
---|
9523 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9524 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9525 | 9790 | |
---|
9526 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9527 | 9792 | |
---|
.. | .. |
---|
9567 | 9832 | rati = 1 / rati; |
---|
9568 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9569 | 9834 | } |
---|
9570 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9571 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9572 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9573 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9574 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9575 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9576 | | - accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
| 9843 | + |
---|
| 9844 | + boolean vr = capsLocked && !lightMode; |
---|
| 9845 | + |
---|
| 9846 | + accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
9577 | 9847 | ratio, |
---|
9578 | 9848 | //near_plane, far_plane, |
---|
9579 | 9849 | renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(), |
---|
.. | .. |
---|
10436 | 10706 | static boolean init = false; |
---|
10437 | 10707 | |
---|
10438 | 10708 | double[][] matrix = LA.newMatrix(); |
---|
| 10709 | + |
---|
| 10710 | + // This is to refresh the UI of the material panel. |
---|
| 10711 | + ObjEditor patchMaterial; |
---|
10439 | 10712 | |
---|
10440 | 10713 | public void display(GLAutoDrawable drawable) |
---|
10441 | 10714 | { |
---|
| 10715 | + if (patchMaterial.patchMaterial) |
---|
| 10716 | + { |
---|
| 10717 | + patchMaterial.patchMaterial = false; |
---|
| 10718 | + patchMaterial.objectTabbedPane.setSelectedIndex(1); |
---|
| 10719 | + } |
---|
| 10720 | + |
---|
10442 | 10721 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10443 | 10722 | { |
---|
10444 | 10723 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10534 | 10813 | |
---|
10535 | 10814 | if (DrawMode() == DEFAULT) |
---|
10536 | 10815 | { |
---|
| 10816 | + if (manipCamera == lightCamera) |
---|
| 10817 | + { |
---|
| 10818 | +// switch (e.getKeyCode()) |
---|
| 10819 | +// { |
---|
| 10820 | +// case DOWN_ARROW: |
---|
| 10821 | +// lightCamera.DECAL /= 2; |
---|
| 10822 | +// repaint(); |
---|
| 10823 | +// break; |
---|
| 10824 | +// case UP_ARROW: |
---|
| 10825 | +// lightCamera.DECAL *= 2; |
---|
| 10826 | +// repaint(); |
---|
| 10827 | +// break; |
---|
| 10828 | +// case LEFT_ARROW: |
---|
| 10829 | +// lightCamera.SCALE /= 2; |
---|
| 10830 | +// repaint(); |
---|
| 10831 | +// break; |
---|
| 10832 | +// case RIGHT_ARROW: |
---|
| 10833 | +// lightCamera.SCALE *= 2; |
---|
| 10834 | +// repaint(); |
---|
| 10835 | +// break; |
---|
| 10836 | +// default: |
---|
| 10837 | +// break; |
---|
| 10838 | + if (keys[DOWN_ARROW]) |
---|
| 10839 | + { |
---|
| 10840 | + lightCamera.DECAL /= 2; |
---|
| 10841 | + } |
---|
| 10842 | + |
---|
| 10843 | + if (keys[UP_ARROW]) |
---|
| 10844 | + { |
---|
| 10845 | + lightCamera.DECAL *= 2; |
---|
| 10846 | + } |
---|
| 10847 | + |
---|
| 10848 | + if (keys[LEFT_ARROW]) |
---|
| 10849 | + { |
---|
| 10850 | + lightCamera.SCALE /= 2; |
---|
| 10851 | + } |
---|
| 10852 | + |
---|
| 10853 | + if (keys[RIGHT_ARROW]) |
---|
| 10854 | + { |
---|
| 10855 | + lightCamera.SCALE *= 2; |
---|
| 10856 | + } |
---|
| 10857 | + } |
---|
| 10858 | + else |
---|
| 10859 | + { |
---|
| 10860 | + //pingthread.mute = true; |
---|
| 10861 | + |
---|
| 10862 | + boolean keyon = false; |
---|
| 10863 | + |
---|
| 10864 | + if (keys[DOWN_ARROW]) |
---|
| 10865 | + { |
---|
| 10866 | + speed = ++speedkey[DOWN_ARROW]; |
---|
| 10867 | + if (speed > 20) |
---|
| 10868 | + speed = 20; |
---|
| 10869 | + GoDown(modifiers); |
---|
| 10870 | + keyon = true; |
---|
| 10871 | + } |
---|
| 10872 | + else |
---|
| 10873 | + speedkey[DOWN_ARROW] = 0; |
---|
| 10874 | + |
---|
| 10875 | + if (keys[UP_ARROW]) |
---|
| 10876 | + { |
---|
| 10877 | + speed = ++speedkey[UP_ARROW]; |
---|
| 10878 | + if (speed > 20) |
---|
| 10879 | + speed = 20; |
---|
| 10880 | + GoUp(modifiers); |
---|
| 10881 | + keyon = true; |
---|
| 10882 | + } |
---|
| 10883 | + else |
---|
| 10884 | + speedkey[UP_ARROW] = 0; |
---|
| 10885 | + |
---|
| 10886 | + if (keys[LEFT_ARROW]) |
---|
| 10887 | + { |
---|
| 10888 | + speed = ++speedkey[LEFT_ARROW]; |
---|
| 10889 | + if (speed > 20) |
---|
| 10890 | + speed = 20; |
---|
| 10891 | + GoLeft(modifiers); |
---|
| 10892 | + keyon = true; |
---|
| 10893 | + } |
---|
| 10894 | + else |
---|
| 10895 | + speedkey[LEFT_ARROW] = 0; |
---|
| 10896 | + |
---|
| 10897 | + if (keys[RIGHT_ARROW]) |
---|
| 10898 | + { |
---|
| 10899 | + speed = ++speedkey[RIGHT_ARROW]; |
---|
| 10900 | + if (speed > 20) |
---|
| 10901 | + speed = 20; |
---|
| 10902 | + GoRight(modifiers); |
---|
| 10903 | + keyon = true; |
---|
| 10904 | + } |
---|
| 10905 | + else |
---|
| 10906 | + speedkey[RIGHT_ARROW] = 0; |
---|
| 10907 | + |
---|
| 10908 | + if (Globals.WALK && capsLocked) |
---|
| 10909 | + { |
---|
| 10910 | + Walk(); |
---|
| 10911 | + keyon = true; |
---|
| 10912 | + } |
---|
| 10913 | + |
---|
| 10914 | + if (keyon) |
---|
| 10915 | + { |
---|
| 10916 | + repaint(); |
---|
| 10917 | + } |
---|
| 10918 | + |
---|
| 10919 | + //pingthread.mute = false; |
---|
| 10920 | + } |
---|
| 10921 | + |
---|
10537 | 10922 | currentlydrawing = true; |
---|
10538 | 10923 | } |
---|
10539 | 10924 | |
---|
.. | .. |
---|
10607 | 10992 | |
---|
10608 | 10993 | if (wait) |
---|
10609 | 10994 | { |
---|
10610 | | - Sleep(500); |
---|
| 10995 | + Sleep(200); // blocks everything |
---|
10611 | 10996 | |
---|
10612 | 10997 | wait = false; |
---|
10613 | 10998 | } |
---|
.. | .. |
---|
10722 | 11107 | // if (parentcam != renderCamera) // not a light |
---|
10723 | 11108 | if (cam != lightCamera) |
---|
10724 | 11109 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10725 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11110 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10726 | 11111 | |
---|
10727 | 11112 | for (int j = 0; j < 4; j++) |
---|
10728 | 11113 | { |
---|
.. | .. |
---|
10737 | 11122 | // if (parentcam != renderCamera) // not a light |
---|
10738 | 11123 | if (cam != lightCamera) |
---|
10739 | 11124 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10740 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11125 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10741 | 11126 | |
---|
10742 | 11127 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10743 | 11128 | |
---|
.. | .. |
---|
10823 | 11208 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10824 | 11209 | } |
---|
10825 | 11210 | |
---|
10826 | | - if (newenvy > -1) |
---|
| 11211 | +// if (newenvy > -1) |
---|
| 11212 | +// { |
---|
| 11213 | +// LoadEnvy(newenvy); |
---|
| 11214 | +// } |
---|
| 11215 | +// |
---|
| 11216 | +// newenvy = -1; |
---|
| 11217 | + |
---|
| 11218 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
10827 | 11219 | { |
---|
10828 | | - LoadEnvy(newenvy); |
---|
| 11220 | + if (cubemaprgb == null) |
---|
| 11221 | + { |
---|
| 11222 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11223 | + } |
---|
| 11224 | + |
---|
| 11225 | + cubemap = cubemaprgb; |
---|
10829 | 11226 | } |
---|
10830 | | - |
---|
10831 | | - newenvy = -1; |
---|
10832 | | - |
---|
| 11227 | + else |
---|
| 11228 | + { |
---|
| 11229 | + if (object.skyboxname != null) |
---|
| 11230 | + { |
---|
| 11231 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11232 | + { |
---|
| 11233 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11234 | + cubemap.dispose(); |
---|
| 11235 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11236 | + loadedskyboxname = object.skyboxname; |
---|
| 11237 | + } |
---|
| 11238 | + } |
---|
| 11239 | + else |
---|
| 11240 | + { |
---|
| 11241 | + cubemapcustom = null; |
---|
| 11242 | + loadedskyboxname = null; |
---|
| 11243 | + } |
---|
| 11244 | + |
---|
| 11245 | + cubemap = cubemapcustom; |
---|
| 11246 | + } |
---|
| 11247 | + |
---|
10833 | 11248 | ratio = ((double) getWidth()) / getHeight(); |
---|
10834 | 11249 | //System.out.println("ratio = " + ratio); |
---|
10835 | 11250 | |
---|
.. | .. |
---|
10845 | 11260 | |
---|
10846 | 11261 | if (!IsFrozen() && !ambientOcclusion) |
---|
10847 | 11262 | { |
---|
10848 | | - DrawSkyBox(gl); |
---|
| 11263 | + DrawSkyBox(gl, (float)ratio); |
---|
10849 | 11264 | } |
---|
10850 | 11265 | |
---|
10851 | 11266 | //if (selection_view == -1) |
---|
.. | .. |
---|
11028 | 11443 | |
---|
11029 | 11444 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
11030 | 11445 | |
---|
11031 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11032 | 11446 | //gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11447 | +//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11033 | 11448 | //gl.glEnable(gl.GL_MULTISAMPLE); |
---|
11034 | 11449 | } else |
---|
11035 | 11450 | { |
---|
.. | .. |
---|
11041 | 11456 | //System.out.println("BLENDING ON"); |
---|
11042 | 11457 | gl.glEnable(GL.GL_BLEND); |
---|
11043 | 11458 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11044 | | - |
---|
| 11459 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11045 | 11460 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11046 | 11461 | gl.glLoadIdentity(); |
---|
11047 | 11462 | |
---|
.. | .. |
---|
11091 | 11506 | //gl.glOrtho(-BOOST, BOOST, -BOOST, BOOST, 0.001, 1000); |
---|
11092 | 11507 | } else |
---|
11093 | 11508 | { |
---|
11094 | | - glu.gluPerspective(cam.shaper_fovy / ratio, ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); |
---|
| 11509 | + boolean vr = capsLocked && !lightMode; |
---|
| 11510 | + |
---|
| 11511 | + glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
| 11512 | + ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); |
---|
11095 | 11513 | } |
---|
11096 | 11514 | } |
---|
11097 | 11515 | |
---|
.. | .. |
---|
11131 | 11549 | |
---|
11132 | 11550 | // if (cam != lightCamera) |
---|
11133 | 11551 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11134 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11552 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11135 | 11553 | } |
---|
11136 | 11554 | |
---|
11137 | 11555 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11290 | 11708 | } |
---|
11291 | 11709 | } |
---|
11292 | 11710 | |
---|
11293 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11711 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11294 | 11712 | { |
---|
11295 | 11713 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11296 | 11714 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11298 | 11716 | |
---|
11299 | 11717 | boolean texon = textureon; |
---|
11300 | 11718 | |
---|
11301 | | - if (RENDERPROGRAM > 0) |
---|
11302 | | - { |
---|
11303 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11304 | | - textureon = false; |
---|
11305 | | - } |
---|
| 11719 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11720 | + textureon = false; |
---|
| 11721 | + |
---|
11306 | 11722 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11307 | 11723 | //System.out.println("ALLO"); |
---|
11308 | 11724 | gl.glColorMask(false, false, false, false); |
---|
11309 | 11725 | DrawObject(gl); |
---|
11310 | | - if (RENDERPROGRAM > 0) |
---|
11311 | | - { |
---|
11312 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11313 | | - textureon = texon; |
---|
11314 | | - } |
---|
| 11726 | + |
---|
| 11727 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11728 | + textureon = texon; |
---|
| 11729 | + |
---|
11315 | 11730 | gl.glColorMask(true, true, true, true); |
---|
11316 | 11731 | |
---|
11317 | 11732 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11318 | | - //gl.glDepthMask(false); |
---|
| 11733 | + gl.glDepthMask(false); |
---|
11319 | 11734 | } |
---|
11320 | 11735 | |
---|
11321 | 11736 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11450 | 11865 | repaint(); |
---|
11451 | 11866 | } |
---|
11452 | 11867 | |
---|
11453 | | - if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
| 11868 | + if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 |
---|
| 11869 | + { |
---|
| 11870 | + renderCamera.computeTransform(); |
---|
11454 | 11871 | repaint(); |
---|
| 11872 | + } |
---|
11455 | 11873 | |
---|
11456 | 11874 | displaydone = true; |
---|
11457 | 11875 | } |
---|
.. | .. |
---|
11526 | 11944 | //GL gl = getGL(); |
---|
11527 | 11945 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11528 | 11946 | { |
---|
| 11947 | + if (TRACK) |
---|
| 11948 | + { |
---|
| 11949 | + if (object.selection != null && |
---|
| 11950 | + object.selection.size() > 0 && |
---|
| 11951 | + object.selection.elementAt(0) != null && |
---|
| 11952 | + !(object.selection.elementAt(0) instanceof Camera) && |
---|
| 11953 | + !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
| 11954 | + { |
---|
| 11955 | + trackedobject = object.selection.elementAt(0); |
---|
| 11956 | + //repaint(); |
---|
| 11957 | + } |
---|
| 11958 | + else |
---|
| 11959 | + trackedobject = null; |
---|
| 11960 | + } |
---|
11529 | 11961 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11530 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11531 | | - pingthread.StepToTarget(true); // true); |
---|
| 11962 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11963 | + pingthread.StepToTarget(); // true); |
---|
11532 | 11964 | // zoomonce = false; |
---|
11533 | 11965 | } |
---|
11534 | 11966 | |
---|
.. | .. |
---|
11655 | 12087 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11656 | 12088 | |
---|
11657 | 12089 | if (CLEANCACHE) |
---|
11658 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 12090 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11659 | 12091 | { |
---|
11660 | | - String tex = e.nextElement(); |
---|
| 12092 | + cTexture tex = e.nextElement(); |
---|
11661 | 12093 | |
---|
11662 | 12094 | // System.out.println("Texture --------- " + tex); |
---|
11663 | 12095 | |
---|
11664 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 12096 | + if (tex.equals("WHITE_NOISE:")) |
---|
11665 | 12097 | continue; |
---|
11666 | 12098 | |
---|
11667 | | - if (!usedtextures.containsKey(tex)) |
---|
| 12099 | + if (!usedtextures.contains(tex)) |
---|
11668 | 12100 | { |
---|
| 12101 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11669 | 12102 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11670 | | - textures.get(tex).texture.dispose(); |
---|
11671 | | - textures.remove(tex); |
---|
| 12103 | + if (gettex != null) |
---|
| 12104 | + { |
---|
| 12105 | + gettex.texture.dispose(); |
---|
| 12106 | + texturepigment.remove(tex); |
---|
| 12107 | + } |
---|
| 12108 | + |
---|
| 12109 | + gettex = texturebump.get(tex); |
---|
| 12110 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 12111 | + if (gettex != null) |
---|
| 12112 | + { |
---|
| 12113 | + gettex.texture.dispose(); |
---|
| 12114 | + texturebump.remove(tex); |
---|
| 12115 | + } |
---|
11672 | 12116 | } |
---|
11673 | 12117 | } |
---|
11674 | 12118 | } |
---|
.. | .. |
---|
12196 | 12640 | |
---|
12197 | 12641 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12198 | 12642 | |
---|
12199 | | - String program = |
---|
| 12643 | + String programmin = |
---|
| 12644 | + // Min shader |
---|
12200 | 12645 | "!!ARBfp1.0\n" + |
---|
| 12646 | + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12647 | + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12648 | + "PARAM pow2 = { 2, 4, 8, 0.0 };" + |
---|
| 12649 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12650 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12651 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12652 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12653 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12654 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12655 | + "TEMP temp;" + |
---|
| 12656 | + "TEMP light;" + |
---|
| 12657 | + "TEMP ndotl;" + |
---|
| 12658 | + "TEMP normal;" + |
---|
| 12659 | + "TEMP depth;" + |
---|
| 12660 | + "TEMP eye;" + |
---|
| 12661 | + "TEMP pos;" + |
---|
| 12662 | + |
---|
| 12663 | + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + |
---|
| 12664 | + Normalize("normal") + |
---|
| 12665 | + "MOV light, state.light[0].position;" + |
---|
| 12666 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12667 | + "MAX ndotl.x, ndotl.x, zero12t.x;" + |
---|
| 12668 | + |
---|
| 12669 | + // shadow |
---|
| 12670 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12671 | + "MOV temp, pos;" + |
---|
| 12672 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12673 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12674 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12675 | + |
---|
| 12676 | + // No shadow when out of frustum |
---|
| 12677 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12678 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12679 | + |
---|
| 12680 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12681 | + |
---|
| 12682 | + // Backlit |
---|
| 12683 | + "MOV pos.w, zero12t.y;" + // one |
---|
| 12684 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12685 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12686 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12687 | + Normalize("eye") + |
---|
| 12688 | + |
---|
| 12689 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12690 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12691 | + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit |
---|
| 12692 | + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y |
---|
| 12693 | + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12694 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12695 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12696 | + "ADD ndotl.y, ndotl.y, one.x;" + |
---|
| 12697 | + "MUL ndotl.y, ndotl.y, pow_2.x;" + |
---|
| 12698 | + |
---|
| 12699 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12700 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12701 | + |
---|
| 12702 | + // Pigment |
---|
| 12703 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12704 | + "LRP temp, zero12t.w, temp, one;" + // texture proportion |
---|
| 12705 | + "MUL temp, temp, zero12t.w;" + // Times x |
---|
| 12706 | + |
---|
| 12707 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12708 | + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + |
---|
| 12709 | + |
---|
| 12710 | + "MUL temp, temp, ndotl.x;" + // lambert |
---|
| 12711 | + |
---|
| 12712 | + "MOV temp.w, zero12t.y;" + // reset alpha |
---|
| 12713 | + "MOV result.color, temp;" + |
---|
| 12714 | + "END"; |
---|
| 12715 | + |
---|
| 12716 | + String programmax = |
---|
| 12717 | + "!!ARBfp1.0\n" + |
---|
| 12718 | + |
---|
12201 | 12719 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12202 | 12720 | "PARAM light2cam0 = program.env[10];" + |
---|
12203 | 12721 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12223 | 12741 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12224 | 12742 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12225 | 12743 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12226 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12744 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12227 | 12745 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12228 | 12746 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12229 | 12747 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12312 | 12830 | "TEMP shininess;" + |
---|
12313 | 12831 | "\n" + |
---|
12314 | 12832 | "MOV texSamp, one;" + |
---|
12315 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12316 | | - |
---|
| 12833 | + |
---|
12317 | 12834 | "MOV mapgrid.x, one2048th.x;" + |
---|
12318 | 12835 | "MOV temp, fragment.texcoord[1];" + |
---|
12319 | 12836 | /* |
---|
.. | .. |
---|
12334 | 12851 | "MUL temp, floor, mapgrid.x;" + |
---|
12335 | 12852 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12336 | 12853 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12337 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12854 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12338 | 12855 | "") + |
---|
12339 | 12856 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12340 | 12857 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12341 | 12858 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12342 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12859 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12343 | 12860 | "") + |
---|
12344 | 12861 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12345 | 12862 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12346 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12863 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12347 | 12864 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12348 | 12865 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12349 | 12866 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12350 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12867 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12351 | 12868 | "") + |
---|
12352 | 12869 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12353 | 12870 | //"MOV params, material;" + |
---|
.. | .. |
---|
12469 | 12986 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12470 | 12987 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12471 | 12988 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12472 | | - "KIL alpha.a;" + |
---|
| 12989 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12473 | 12990 | /* |
---|
12474 | 12991 | "MUL temp.xy, temp, two;" + |
---|
12475 | 12992 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12555 | 13072 | "SUB bump0, bump0, half;" + |
---|
12556 | 13073 | "ADD bump, bump, bump0;" + |
---|
12557 | 13074 | |
---|
12558 | | - "MOV temp.x, texSamp.a;" + |
---|
12559 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12560 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12561 | | - "MOV texSamp.a, temp.x;" + |
---|
12562 | | - |
---|
12563 | 13075 | // double-sided |
---|
12564 | 13076 | /**/ |
---|
12565 | 13077 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12569 | 13081 | "ADD temp.x, temp.x, one.x;" + |
---|
12570 | 13082 | "MUL normal, normal, temp.xxxx;":"" |
---|
12571 | 13083 | ) + |
---|
12572 | | - /**/ |
---|
12573 | | -//// Normalize("normal") + |
---|
12574 | | -//// "MAX normal.z, eps.x, normal.z;" + |
---|
12575 | | -// Normalize("normal") + |
---|
12576 | | - "MOV normald, normal;" + |
---|
12577 | | - "MOV normals, normal;" + |
---|
| 13084 | + /**/ |
---|
| 13085 | + |
---|
| 13086 | + "MOV temp, fragment.texcoord[4];" + |
---|
12578 | 13087 | |
---|
12579 | 13088 | // UV base |
---|
12580 | 13089 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12581 | 13090 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12582 | 13091 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12583 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12584 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12585 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 13092 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 13093 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 13094 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 13095 | + Normalize("UP") + |
---|
| 13096 | + |
---|
12586 | 13097 | "XPD V, normal, UP;" + |
---|
12587 | 13098 | Normalize("V") + |
---|
12588 | 13099 | "XPD U, V, normal;" + |
---|
12589 | 13100 | Normalize("U") + |
---|
12590 | 13101 | |
---|
| 13102 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 13103 | + |
---|
| 13104 | +// "MAD normal, -temp.x, U, normal;" + |
---|
| 13105 | +// "MAD normal, -temp.y, V, normal;" + |
---|
| 13106 | +// Normalize("normal") + |
---|
| 13107 | + |
---|
| 13108 | +//// "MAX normal.z, eps.x, normal.z;" + |
---|
| 13109 | +// Normalize("normal") + |
---|
| 13110 | + "MOV normald, normal;" + |
---|
| 13111 | + "MOV normals, normal;" + |
---|
| 13112 | + |
---|
12591 | 13113 | // parallax mapping |
---|
| 13114 | + |
---|
| 13115 | + "DP3 temp2.x, V, eye;" + |
---|
| 13116 | + "DP3 temp2.y, U, eye;" + |
---|
| 13117 | + "DP3 temp2.z, normal, eye;" + |
---|
| 13118 | + "RCP temp2.z, temp2.z;" + |
---|
| 13119 | + |
---|
| 13120 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 13121 | + "RSQ temp2.w, temp2.w;" + |
---|
| 13122 | + "RCP temp2.w, temp2.w;" + |
---|
| 13123 | + |
---|
| 13124 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 13125 | + // "SGE temp.x, temp2.w, eps.x;" + |
---|
| 13126 | + // "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 13127 | + |
---|
| 13128 | + // "MOV texSamp, U;" + |
---|
| 13129 | + |
---|
| 13130 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 13131 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 13132 | + |
---|
| 13133 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 13134 | + |
---|
| 13135 | + "SUB temp, temp, temp2;" + |
---|
| 13136 | + |
---|
| 13137 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 13138 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13139 | + |
---|
| 13140 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13141 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13142 | + |
---|
| 13143 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13144 | + |
---|
| 13145 | +// parallax mapping |
---|
| 13146 | + |
---|
| 13147 | + "MOV temp.x, texSamp.a;" + |
---|
| 13148 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13149 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13150 | + "MOV texSamp.a, temp.x;" + |
---|
12592 | 13151 | |
---|
12593 | 13152 | //"MOV temp, fragment.texcoord[0];" + |
---|
12594 | 13153 | // |
---|
.. | .. |
---|
12718 | 13277 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12719 | 13278 | "") + |
---|
12720 | 13279 | |
---|
12721 | | - // display shadow only (bump == 0) |
---|
| 13280 | + // display shadow only (fakedepth == 0) |
---|
12722 | 13281 | "SUB temp.x, half.x, shadow.x;" + |
---|
12723 | 13282 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12724 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13283 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12725 | 13284 | "SUB temp.y, one.x, temp.z;" + |
---|
12726 | 13285 | "MUL temp.x, temp.x, temp.y;" + |
---|
12727 | 13286 | "KIL temp.x;" + |
---|
.. | .. |
---|
13052 | 13611 | //once = true; |
---|
13053 | 13612 | } |
---|
13054 | 13613 | |
---|
13055 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13056 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13614 | + String program = programmax; |
---|
| 13615 | + |
---|
| 13616 | + if (Globals.MINSHADER) |
---|
| 13617 | + { |
---|
| 13618 | + program = programmin; |
---|
| 13619 | + } |
---|
| 13620 | + |
---|
| 13621 | + if (Globals.DEBUG) |
---|
| 13622 | + { |
---|
| 13623 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13624 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13625 | + } |
---|
| 13626 | + |
---|
13057 | 13627 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13058 | 13628 | |
---|
13059 | 13629 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13100 | 13670 | "\n" + |
---|
13101 | 13671 | "END\n"; |
---|
13102 | 13672 | |
---|
13103 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13673 | + if (Globals.DEBUG) |
---|
| 13674 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13104 | 13675 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13105 | 13676 | |
---|
13106 | 13677 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13145 | 13716 | return out; |
---|
13146 | 13717 | } |
---|
13147 | 13718 | |
---|
13148 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13719 | + // Also does frustum culling |
---|
| 13720 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13149 | 13721 | { |
---|
13150 | 13722 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13151 | 13723 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13152 | 13724 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13725 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13726 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13153 | 13727 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13154 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13155 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13156 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13157 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13728 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13729 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13158 | 13730 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13159 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13731 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13160 | 13732 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13161 | 13733 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13162 | 13734 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13163 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13735 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13164 | 13736 | |
---|
13165 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13166 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13737 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13738 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13167 | 13739 | } |
---|
13168 | 13740 | |
---|
13169 | 13741 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13210 | 13782 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13211 | 13783 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13212 | 13784 | |
---|
13213 | | - // No shadow when out of frustrum |
---|
| 13785 | + // No shadow when out of frustum |
---|
13214 | 13786 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13215 | 13787 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13216 | 13788 | ""; |
---|
.. | .. |
---|
13357 | 13929 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13358 | 13930 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13359 | 13931 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13360 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13932 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13361 | 13933 | |
---|
13362 | 13934 | //Object3D.cVector2[] vector2buffer; |
---|
13363 | 13935 | |
---|
.. | .. |
---|
13524 | 14096 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13525 | 14097 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13526 | 14098 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13527 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 14099 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13528 | 14100 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13529 | 14101 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13530 | 14102 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13585 | 14157 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13586 | 14158 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13587 | 14159 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13588 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14160 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13589 | 14161 | "MOV result.texcoord, temp;" + |
---|
13590 | 14162 | // border fade |
---|
13591 | 14163 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13632 | 14204 | |
---|
13633 | 14205 | //"ADD temp.z, temp.z, one;" + |
---|
13634 | 14206 | |
---|
13635 | | - "MOV result.color, temp;" |
---|
| 14207 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14208 | + |
---|
| 14209 | + "MOV result.color, temp;" // Normal |
---|
13636 | 14210 | : "MOV result.color, vertex.color;") + |
---|
13637 | 14211 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13638 | 14212 | : "") + |
---|
.. | .. |
---|
13767 | 14341 | public void mouseClicked(MouseEvent e) |
---|
13768 | 14342 | { |
---|
13769 | 14343 | System.out.println("mouseClicked: " + e); |
---|
| 14344 | + System.exit(0); |
---|
13770 | 14345 | } |
---|
13771 | 14346 | |
---|
13772 | 14347 | public void mousePressed(MouseEvent e) |
---|
13773 | 14348 | { |
---|
| 14349 | + RigidBody.justclicked = true; |
---|
| 14350 | + System.out.println("justclicked: " + e); |
---|
13774 | 14351 | //System.out.println("mousePressed: " + e); |
---|
13775 | 14352 | clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13776 | 14353 | } |
---|
.. | .. |
---|
13805 | 14382 | return; |
---|
13806 | 14383 | } |
---|
13807 | 14384 | |
---|
13808 | | - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 14385 | + //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 14386 | + |
---|
| 14387 | + boolean vr = capsLocked && !lightMode; |
---|
13809 | 14388 | |
---|
13810 | 14389 | // TIMER |
---|
13811 | | - if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14390 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !vr) // VR |
---|
13812 | 14391 | { |
---|
13813 | 14392 | keepboxmode = BOXMODE; |
---|
13814 | 14393 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
13849 | 14428 | //} |
---|
13850 | 14429 | |
---|
13851 | 14430 | SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
13852 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
| 14431 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx()); |
---|
13853 | 14432 | anchorX = ax; |
---|
13854 | 14433 | anchorY = ay; |
---|
13855 | 14434 | prevX = px; |
---|
.. | .. |
---|
13943 | 14522 | |
---|
13944 | 14523 | // fev 2014??? |
---|
13945 | 14524 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13946 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13947 | | - pingthread.StepToTarget(true); // true); |
---|
| 14525 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14526 | + pingthread.StepToTarget(); // true); |
---|
13948 | 14527 | } |
---|
| 14528 | + |
---|
13949 | 14529 | // if (!LIVE) |
---|
13950 | 14530 | super.repaint(); |
---|
13951 | 14531 | } |
---|
.. | .. |
---|
14008 | 14588 | drag = false; |
---|
14009 | 14589 | //System.out.println("Mouse DOWN"); |
---|
14010 | 14590 | editObj = false; |
---|
14011 | | - ClickInfo info = new ClickInfo(); |
---|
14012 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14013 | | - info.pane = this; |
---|
14014 | | - info.camera = renderCamera; |
---|
14015 | | - info.x = x; |
---|
14016 | | - info.y = y; |
---|
14017 | | - info.modifiers = modifiersex; |
---|
14018 | | - editObj = object.doEditClick(info, 0); |
---|
| 14591 | + //ClickInfo info = new ClickInfo(); |
---|
| 14592 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14593 | + object.clickInfo.pane = this; |
---|
| 14594 | + object.clickInfo.camera = renderCamera; |
---|
| 14595 | + object.clickInfo.x = x; |
---|
| 14596 | + object.clickInfo.y = y; |
---|
| 14597 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14598 | + editObj = object.doEditClick(//info, |
---|
| 14599 | + 0); |
---|
14019 | 14600 | if (!editObj) |
---|
14020 | 14601 | { |
---|
14021 | 14602 | hasMarquee = true; |
---|
.. | .. |
---|
14039 | 14620 | |
---|
14040 | 14621 | //if (drawing) |
---|
14041 | 14622 | //return; |
---|
14042 | | - if ((e.getModifiersEx() & CTRL) != 0 |
---|
14043 | | - || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
| 14623 | + if ((e.getModifiersEx() & CTRL) != 0 || |
---|
| 14624 | + (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
14044 | 14625 | { |
---|
14045 | 14626 | //System.out.println("mouseDragged: " + e); |
---|
14046 | 14627 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
.. | .. |
---|
14064 | 14645 | return targetLookAt; |
---|
14065 | 14646 | } |
---|
14066 | 14647 | |
---|
| 14648 | + javax.vecmath.Point3d eye = new javax.vecmath.Point3d(); |
---|
| 14649 | + javax.vecmath.Point3d eye2 = new javax.vecmath.Point3d(); |
---|
| 14650 | + javax.vecmath.Vector3d dir = new javax.vecmath.Vector3d(); |
---|
| 14651 | + |
---|
| 14652 | + |
---|
14067 | 14653 | class PingThread extends Thread |
---|
14068 | 14654 | { |
---|
14069 | 14655 | boolean jump; |
---|
| 14656 | + boolean live; |
---|
| 14657 | + |
---|
| 14658 | + boolean mute; |
---|
14070 | 14659 | |
---|
14071 | 14660 | // void JumpToTarget() |
---|
14072 | 14661 | // { |
---|
.. | .. |
---|
14082 | 14671 | // only one thread!? synchronized |
---|
14083 | 14672 | void StepToTarget(boolean jump) |
---|
14084 | 14673 | { |
---|
| 14674 | + RigidBody.pos.x = 0; |
---|
| 14675 | + RigidBody.pos.y = 0; |
---|
| 14676 | + RigidBody.pos.z = 0; |
---|
| 14677 | + if (RigidBody.justclicked) |
---|
| 14678 | + { |
---|
| 14679 | + RigidBody.pos.x = (float)manipCamera.lookAt.x; |
---|
| 14680 | + RigidBody.pos.y = (float)manipCamera.lookAt.y; |
---|
| 14681 | + RigidBody.pos.z = (float)manipCamera.lookAt.z; |
---|
| 14682 | + RigidBody.wind.set(RigidBody.pos); |
---|
| 14683 | + RigidBody.wind.x -= (float)manipCamera.location.x; |
---|
| 14684 | + RigidBody.wind.y -= (float)manipCamera.location.y; |
---|
| 14685 | + RigidBody.wind.z -= (float)manipCamera.location.z; |
---|
| 14686 | + RigidBody.wind.normalize(); |
---|
| 14687 | + } |
---|
| 14688 | + |
---|
| 14689 | + if (mute) |
---|
| 14690 | + return; |
---|
| 14691 | + |
---|
| 14692 | + if (capsLocked && manipCamera.viewCode == 0) |
---|
| 14693 | + { |
---|
| 14694 | + eye.x = manipCamera.location.x; |
---|
| 14695 | + eye.y = manipCamera.location.y + 0.25; |
---|
| 14696 | + eye.z = manipCamera.location.z; |
---|
| 14697 | + |
---|
| 14698 | + dir.y = -1; |
---|
| 14699 | + |
---|
| 14700 | + Ray ray = new Ray(eye, dir); |
---|
| 14701 | + |
---|
| 14702 | + IntersectResult res = new IntersectResult(); |
---|
| 14703 | + res.t = Double.POSITIVE_INFINITY; |
---|
| 14704 | + |
---|
| 14705 | + tmp.set(targetLookAt); |
---|
| 14706 | + tmp.sub(manipCamera.location); |
---|
| 14707 | + |
---|
| 14708 | + double dist = tmp.length(); |
---|
| 14709 | + |
---|
| 14710 | + tmp.normalize(); |
---|
| 14711 | + |
---|
| 14712 | + eye2.x = manipCamera.location.x + tmp.x * 0.25; |
---|
| 14713 | + eye2.y = manipCamera.location.y + 0.25; |
---|
| 14714 | + eye2.z = manipCamera.location.z + tmp.z * 0.25; |
---|
| 14715 | + |
---|
| 14716 | + Ray ray2 = new Ray(eye2, dir); |
---|
| 14717 | + |
---|
| 14718 | + IntersectResult res2 = new IntersectResult(); |
---|
| 14719 | + res2.t = Double.POSITIVE_INFINITY; |
---|
| 14720 | + |
---|
| 14721 | + if (object.intersect(ray, res) && object.intersect(ray2, res2) && Math.abs(res.t - res2.t) < 0.25) |
---|
| 14722 | + { |
---|
| 14723 | + //tmp.set(manipCamera.location); |
---|
| 14724 | + |
---|
| 14725 | + manipCamera.location.x = ray.eyePoint.x + ray.viewDirection.x * res.t; |
---|
| 14726 | + manipCamera.location.y = ray.eyePoint.y + ray.viewDirection.y * res.t + 0.5; |
---|
| 14727 | + manipCamera.location.z = ray.eyePoint.z + ray.viewDirection.z * res.t; |
---|
| 14728 | + |
---|
| 14729 | + //tmp.sub(manipCamera.location); |
---|
| 14730 | + |
---|
| 14731 | + targetLookAt.x = ray2.eyePoint.x + ray2.viewDirection.x * res2.t; |
---|
| 14732 | + targetLookAt.y = ray2.eyePoint.y + ray2.viewDirection.y * res2.t + 0.5; |
---|
| 14733 | + targetLookAt.z = ray2.eyePoint.z + ray2.viewDirection.z * res2.t; |
---|
| 14734 | + |
---|
| 14735 | + targetLookAt.sub(manipCamera.location); |
---|
| 14736 | + targetLookAt.normalize(); |
---|
| 14737 | + targetLookAt.mul(dist); |
---|
| 14738 | + targetLookAt.add(manipCamera.location); |
---|
| 14739 | + |
---|
| 14740 | + //if (tmp.dot(tmp) > 0.000001) |
---|
| 14741 | + // System.out.println("INTERSECTION " + manipCamera.location); |
---|
| 14742 | + |
---|
| 14743 | + manipCamera.lookAt.set(targetLookAt); |
---|
| 14744 | + |
---|
| 14745 | + tmp.x = res.n.x; |
---|
| 14746 | + tmp.y = res.n.y; |
---|
| 14747 | + tmp.z = res.n.z; |
---|
| 14748 | + tmp.x += res2.n.x; |
---|
| 14749 | + tmp.y += res2.n.y; |
---|
| 14750 | + tmp.z += res2.n.z; |
---|
| 14751 | + tmp.normalize(); |
---|
| 14752 | + manipCamera.UP.set(tmp); |
---|
| 14753 | + } |
---|
| 14754 | + } |
---|
| 14755 | + |
---|
14085 | 14756 | tmp.set(targetLookAt); |
---|
14086 | 14757 | tmp.sub(manipCamera.lookAt); // june 2014 |
---|
14087 | 14758 | |
---|
.. | .. |
---|
14119 | 14790 | |
---|
14120 | 14791 | if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target |
---|
14121 | 14792 | { |
---|
14122 | | - jump = true; // step = 1; |
---|
| 14793 | + // sep 2019 jump = true; // step = 1; |
---|
14123 | 14794 | } |
---|
14124 | 14795 | |
---|
14125 | 14796 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
14154 | 14825 | if (tmp.dot(tmp) < 0.00001) |
---|
14155 | 14826 | { |
---|
14156 | 14827 | zoomonce = false; |
---|
| 14828 | + live = false; |
---|
14157 | 14829 | } |
---|
| 14830 | + else |
---|
| 14831 | + live = true; |
---|
14158 | 14832 | |
---|
14159 | 14833 | tmp.mul(step > step2 ? step : step2); |
---|
14160 | 14834 | } |
---|
.. | .. |
---|
14181 | 14855 | { |
---|
14182 | 14856 | if (LOOKAT) |
---|
14183 | 14857 | manipCamera.lookAt.add(tmp); |
---|
14184 | | - if (OEIL) |
---|
| 14858 | + if (OEIL && !capsLocked) |
---|
14185 | 14859 | manipCamera.location.add(tmp); |
---|
14186 | 14860 | |
---|
14187 | 14861 | { |
---|
.. | .. |
---|
14196 | 14870 | lightCamera.computeTransform(); |
---|
14197 | 14871 | } |
---|
14198 | 14872 | } |
---|
14199 | | - manipCamera.computeTransform(); |
---|
| 14873 | + if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0) |
---|
| 14874 | + { |
---|
| 14875 | + manipCamera.computeTransform(); |
---|
| 14876 | + } |
---|
14200 | 14877 | } |
---|
14201 | 14878 | // ?????? mouseDown = true; |
---|
14202 | 14879 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
.. | .. |
---|
14289 | 14966 | } |
---|
14290 | 14967 | } |
---|
14291 | 14968 | } |
---|
| 14969 | + |
---|
14292 | 14970 | PingThread pingthread = new PingThread(); |
---|
14293 | | - int delta = 5; |
---|
14294 | | - int speed = 5; |
---|
| 14971 | + int delta = 1; |
---|
| 14972 | + int speed = 1; |
---|
| 14973 | + int walk = 8; |
---|
14295 | 14974 | boolean autorepeat = false; |
---|
14296 | 14975 | |
---|
| 14976 | + void Walk() |
---|
| 14977 | + { |
---|
| 14978 | + manipCamera.BackForth(0, walk, 1000); |
---|
| 14979 | + |
---|
| 14980 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14981 | + } |
---|
| 14982 | + |
---|
| 14983 | + void ViewAngle(float dy) |
---|
| 14984 | + { |
---|
| 14985 | + double factor = Math.exp(-dy/300.0); // (1 + dy/100); |
---|
| 14986 | + |
---|
| 14987 | + if (manipCamera.shaper_fovy * factor > 1 && |
---|
| 14988 | + manipCamera.shaper_fovy * factor < 150) |
---|
| 14989 | + { |
---|
| 14990 | + manipCamera.shaper_fovy *= factor; |
---|
| 14991 | + //System.out.println("fovy = " + shaper_fovy); |
---|
| 14992 | + } |
---|
| 14993 | + } |
---|
| 14994 | + |
---|
14297 | 14995 | void GoDown(int mod) |
---|
14298 | 14996 | { |
---|
14299 | 14997 | MODIFIERS |= COMMAND; |
---|
14300 | | - /* |
---|
| 14998 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14999 | + /**/ |
---|
14301 | 15000 | if((mod&SHIFT) == SHIFT) |
---|
14302 | | - manipCamera.RotatePosition(0, -speed); |
---|
14303 | | - else |
---|
14304 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14305 | | - */ |
---|
14306 | | - if ((mod & SHIFT) == SHIFT) |
---|
14307 | 15001 | { |
---|
14308 | | - mouseMode = mouseMode; // VR?? |
---|
14309 | | - } else |
---|
14310 | | - { |
---|
14311 | | - mouseMode |= BACKFORTH; |
---|
| 15002 | +// if (isVR) |
---|
| 15003 | +// manipCamera.RotateInterest(0, speed); |
---|
| 15004 | +// else |
---|
| 15005 | + if (isVR) |
---|
| 15006 | + ViewAngle(-speed*delta); |
---|
| 15007 | + else |
---|
| 15008 | + manipCamera.Translate(0, -speed*delta, getWidth()); |
---|
14312 | 15009 | } |
---|
| 15010 | + else |
---|
| 15011 | + { |
---|
| 15012 | + if (isVR) |
---|
| 15013 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15014 | + else |
---|
| 15015 | + manipCamera.RotatePosition(0, -speed); |
---|
| 15016 | + } |
---|
| 15017 | + |
---|
| 15018 | + /**/ |
---|
| 15019 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15020 | +// { |
---|
| 15021 | +// mouseMode = mouseMode; // VR?? |
---|
| 15022 | +// } else |
---|
| 15023 | +// { |
---|
| 15024 | +// mouseMode |= BACKFORTH; |
---|
| 15025 | +// } |
---|
14313 | 15026 | |
---|
| 15027 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15028 | + |
---|
14314 | 15029 | //prevX = X = anchorX; |
---|
14315 | 15030 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14316 | 15031 | } |
---|
14317 | 15032 | |
---|
14318 | 15033 | void GoUp(int mod) |
---|
14319 | 15034 | { |
---|
| 15035 | + RigidBody.justclicked = true; |
---|
| 15036 | + |
---|
14320 | 15037 | MODIFIERS |= COMMAND; |
---|
14321 | | - /* |
---|
| 15038 | + /**/ |
---|
| 15039 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 15040 | + |
---|
14322 | 15041 | if((mod&SHIFT) == SHIFT) |
---|
14323 | | - manipCamera.RotatePosition(0, speed); |
---|
14324 | | - else |
---|
14325 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14326 | | - */ |
---|
14327 | | - if ((mod & SHIFT) == SHIFT) |
---|
14328 | 15042 | { |
---|
14329 | | - mouseMode = mouseMode; |
---|
14330 | | - } else |
---|
14331 | | - { |
---|
14332 | | - mouseMode |= BACKFORTH; |
---|
| 15043 | +// if (isVR) |
---|
| 15044 | +// manipCamera.RotateInterest(0, -speed); |
---|
| 15045 | +// else |
---|
| 15046 | + if (isVR) |
---|
| 15047 | + ViewAngle(speed*delta); |
---|
| 15048 | + else |
---|
| 15049 | + manipCamera.Translate(0, speed*delta, getWidth()); |
---|
14333 | 15050 | } |
---|
| 15051 | + else |
---|
| 15052 | + { |
---|
| 15053 | + if (isVR) |
---|
| 15054 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15055 | + else |
---|
| 15056 | + manipCamera.RotatePosition(0, speed); |
---|
| 15057 | + } |
---|
| 15058 | + |
---|
| 15059 | + /**/ |
---|
| 15060 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15061 | +// { |
---|
| 15062 | +// mouseMode = mouseMode; |
---|
| 15063 | +// } else |
---|
| 15064 | +// { |
---|
| 15065 | +// mouseMode |= BACKFORTH; |
---|
| 15066 | +// } |
---|
14334 | 15067 | |
---|
| 15068 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15069 | + |
---|
14335 | 15070 | //prevX = X = anchorX; |
---|
14336 | 15071 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14337 | 15072 | } |
---|
.. | .. |
---|
14339 | 15074 | void GoLeft(int mod) |
---|
14340 | 15075 | { |
---|
14341 | 15076 | MODIFIERS |= COMMAND; |
---|
14342 | | - /* |
---|
| 15077 | + /**/ |
---|
14343 | 15078 | if((mod&SHIFT) == SHIFT) |
---|
14344 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 15079 | + manipCamera.Translate(speed, 0, getWidth()); |
---|
14345 | 15080 | else |
---|
14346 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14347 | | - */ |
---|
14348 | | - if ((mod & SHIFT) == SHIFT) |
---|
14349 | 15081 | { |
---|
14350 | | - mouseMode = mouseMode; |
---|
14351 | | - } else |
---|
14352 | | - { |
---|
14353 | | - mouseMode |= ROTATE; |
---|
14354 | | - } // TRANSLATE; |
---|
| 15082 | + if ((mouseMode&VR)!=0) |
---|
| 15083 | + manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15084 | + else |
---|
| 15085 | + manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15086 | + } |
---|
| 15087 | + |
---|
| 15088 | + /**/ |
---|
| 15089 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15090 | +// { |
---|
| 15091 | +// mouseMode = mouseMode; |
---|
| 15092 | +// } else |
---|
| 15093 | +// { |
---|
| 15094 | +// mouseMode |= ROTATE; |
---|
| 15095 | +// } // TRANSLATE; |
---|
14355 | 15096 | |
---|
| 15097 | + //System.err.println("lookAt = " + manipCamera.lookAt); |
---|
| 15098 | + //System.err.println("location = " + manipCamera.location); |
---|
| 15099 | + |
---|
| 15100 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15101 | + |
---|
14356 | 15102 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14357 | 15103 | prevY = Y = anchorY; |
---|
14358 | 15104 | } |
---|
.. | .. |
---|
14360 | 15106 | void GoRight(int mod) |
---|
14361 | 15107 | { |
---|
14362 | 15108 | MODIFIERS |= COMMAND; |
---|
14363 | | - /* |
---|
| 15109 | + /**/ |
---|
14364 | 15110 | if((mod&SHIFT) == SHIFT) |
---|
14365 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 15111 | + manipCamera.Translate(-speed, 0, getWidth()); |
---|
14366 | 15112 | else |
---|
14367 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14368 | | - */ |
---|
14369 | | - if ((mod & SHIFT) == SHIFT) |
---|
14370 | 15113 | { |
---|
14371 | | - mouseMode = mouseMode; |
---|
14372 | | - } else |
---|
14373 | | - { |
---|
14374 | | - mouseMode |= ROTATE; |
---|
14375 | | - } // TRANSLATE; |
---|
| 15114 | + if ((mouseMode&VR)!=0) |
---|
| 15115 | + manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15116 | + else |
---|
| 15117 | + manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15118 | + } |
---|
| 15119 | + |
---|
| 15120 | + /**/ |
---|
| 15121 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15122 | +// { |
---|
| 15123 | +// mouseMode = mouseMode; |
---|
| 15124 | +// } else |
---|
| 15125 | +// { |
---|
| 15126 | +// mouseMode |= ROTATE; |
---|
| 15127 | +// } // TRANSLATE; |
---|
14376 | 15128 | |
---|
| 15129 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15130 | + |
---|
14377 | 15131 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14378 | 15132 | prevY = Y = anchorY; |
---|
14379 | 15133 | } |
---|
.. | .. |
---|
14415 | 15169 | if (editObj) |
---|
14416 | 15170 | { |
---|
14417 | 15171 | drag = true; |
---|
14418 | | - ClickInfo info = new ClickInfo(); |
---|
14419 | | - info.bounds.setBounds(0, 0, |
---|
| 15172 | + //ClickInfo info = new ClickInfo(); |
---|
| 15173 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14420 | 15174 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14421 | | - info.pane = this; |
---|
14422 | | - info.camera = renderCamera; |
---|
14423 | | - info.x = x; |
---|
14424 | | - info.y = y; |
---|
14425 | | - object.GetWindow().copy |
---|
14426 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 15175 | + object.clickInfo.pane = this; |
---|
| 15176 | + object.clickInfo.camera = renderCamera; |
---|
| 15177 | + object.clickInfo.x = x; |
---|
| 15178 | + object.clickInfo.y = y; |
---|
| 15179 | + object //.GetWindow().copy |
---|
| 15180 | + .doEditDrag(//info, |
---|
| 15181 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14427 | 15182 | } else |
---|
14428 | 15183 | { |
---|
14429 | 15184 | if (x < startX) |
---|
.. | .. |
---|
14506 | 15261 | if ((mouseMode & ZOOM) != 0) |
---|
14507 | 15262 | { |
---|
14508 | 15263 | //if ((mouseMode & BACKFORTH) != 0) |
---|
| 15264 | + if ((modifiersex & SHIFT) == SHIFT) |
---|
| 15265 | + { |
---|
| 15266 | + ViewAngle(dy); |
---|
| 15267 | + } |
---|
| 15268 | + else |
---|
14509 | 15269 | if ((mouseMode & VR) != 0) |
---|
14510 | 15270 | manipCamera.BackForth(dx, dy, getWidth()); |
---|
14511 | 15271 | else |
---|
.. | .. |
---|
14572 | 15332 | } |
---|
14573 | 15333 | } |
---|
14574 | 15334 | |
---|
| 15335 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15336 | + |
---|
14575 | 15337 | public void mouseMoved(MouseEvent e) |
---|
14576 | 15338 | { |
---|
| 15339 | +//object.editWindow.frame. |
---|
| 15340 | + setCursor(Cursor.getDefaultCursor()); |
---|
| 15341 | + |
---|
14577 | 15342 | //System.out.println("mouseMoved: " + e); |
---|
14578 | 15343 | if (isRenderer) |
---|
14579 | 15344 | return; |
---|
14580 | 15345 | |
---|
14581 | | - ClickInfo ci = new ClickInfo(); |
---|
14582 | | - ci.x = e.getX(); |
---|
14583 | | - ci.y = e.getY(); |
---|
14584 | | - ci.modifiers = e.getModifiersEx(); |
---|
14585 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14586 | | - ci.pane = this; |
---|
14587 | | - ci.camera = renderCamera; |
---|
| 15346 | + // Mouse cursor feedback |
---|
| 15347 | + object.clickInfo.x = e.getX(); |
---|
| 15348 | + object.clickInfo.y = e.getY(); |
---|
| 15349 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15350 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15351 | + object.clickInfo.pane = this; |
---|
| 15352 | + object.clickInfo.camera = renderCamera; |
---|
14588 | 15353 | if (!isRenderer) |
---|
14589 | 15354 | { |
---|
14590 | 15355 | //ObjEditor editWindow = object.editWindow; |
---|
14591 | 15356 | //Object3D copy = editWindow.copy; |
---|
14592 | | - if (object.doEditClick(ci, 0)) |
---|
| 15357 | + if (object.doEditClick(//clickInfo, |
---|
| 15358 | + 0)) |
---|
14593 | 15359 | { |
---|
14594 | 15360 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14595 | 15361 | } else |
---|
.. | .. |
---|
14604 | 15370 | Globals.MOUSEDRAGGED = false; |
---|
14605 | 15371 | |
---|
14606 | 15372 | movingcamera = false; |
---|
14607 | | - X = Y = 0; |
---|
| 15373 | + X = 0; // getBounds().width/2; |
---|
| 15374 | + Y = 0; // getBounds().height/2; |
---|
14608 | 15375 | //System.out.println("mouseReleased: " + e); |
---|
14609 | 15376 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14610 | 15377 | } |
---|
.. | .. |
---|
14756 | 15523 | mouseMode |= ZOOM; |
---|
14757 | 15524 | } |
---|
14758 | 15525 | |
---|
14759 | | - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14760 | | - if (capsLocked) // || (modifiers & META) == META) |
---|
| 15526 | + //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 15527 | + boolean vr = capsLocked && !lightMode; |
---|
| 15528 | + |
---|
| 15529 | + if (vr) // || (modifiers & META) == META) |
---|
14761 | 15530 | { |
---|
14762 | 15531 | mouseMode |= VR; // BACKFORTH; |
---|
14763 | 15532 | } |
---|
.. | .. |
---|
14769 | 15538 | { |
---|
14770 | 15539 | mouseMode |= SELECT; |
---|
14771 | 15540 | } |
---|
14772 | | - if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15541 | + if (//(modifiersex & SHIFT) == SHIFT || |
---|
| 15542 | + forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14773 | 15543 | { |
---|
14774 | 15544 | mouseMode &= ~VR; |
---|
14775 | 15545 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14813 | 15583 | float SATPOW = 1; // 2; // 0.5f; |
---|
14814 | 15584 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
14815 | 15585 | |
---|
| 15586 | +static BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); |
---|
| 15587 | + |
---|
| 15588 | +// Create a new blank cursor. |
---|
| 15589 | +static Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor( |
---|
| 15590 | + cursorImg, new Point(0, 0), "blank cursor"); |
---|
| 15591 | + |
---|
14816 | 15592 | public void keyPressed(int key) |
---|
14817 | 15593 | { |
---|
| 15594 | +// Set the blank cursor to the JFrame. |
---|
| 15595 | +//object.editWindow.frame. |
---|
| 15596 | + setCursor(blankCursor); |
---|
| 15597 | + |
---|
14818 | 15598 | if (key >= '0' && key <= '5') |
---|
14819 | 15599 | clampbit = (key-'0'); |
---|
14820 | 15600 | |
---|
.. | .. |
---|
14860 | 15640 | // break; |
---|
14861 | 15641 | case 'T': |
---|
14862 | 15642 | CACHETEXTURE ^= true; |
---|
14863 | | - textures.clear(); |
---|
| 15643 | + texturepigment.clear(); |
---|
| 15644 | + texturebump.clear(); |
---|
14864 | 15645 | // repaint(); |
---|
14865 | 15646 | break; |
---|
14866 | 15647 | case 'Y': |
---|
.. | .. |
---|
14870 | 15651 | case 'K': |
---|
14871 | 15652 | KOMPACTTEXTURE ^= true; |
---|
14872 | 15653 | //textures.clear(); |
---|
14873 | | - break; |
---|
14874 | | - case 'P': // Texture Projection macros |
---|
| 15654 | + // break; |
---|
| 15655 | + //case 'P': // Texture Projection macros |
---|
14875 | 15656 | // SAVETEXTURE ^= true; |
---|
14876 | 15657 | macromode = true; |
---|
14877 | 15658 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
14945 | 15726 | case 'E' : COMPACT ^= true; |
---|
14946 | 15727 | repaint(); |
---|
14947 | 15728 | break; |
---|
14948 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15729 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15730 | + //DEBUGHSB ^= true; |
---|
| 15731 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14949 | 15732 | repaint(); |
---|
14950 | 15733 | break; |
---|
14951 | 15734 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14970 | 15753 | RevertCamera(); |
---|
14971 | 15754 | repaint(); |
---|
14972 | 15755 | break; |
---|
14973 | | - case 'l': |
---|
14974 | | - lightMode ^= true; |
---|
14975 | | - Globals.lighttouched = true; |
---|
14976 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14977 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14978 | | - repaint(); |
---|
14979 | | - break; |
---|
| 15756 | + //case 'l': |
---|
14980 | 15757 | case 'L': |
---|
14981 | 15758 | if (lightMode) |
---|
14982 | 15759 | { |
---|
.. | .. |
---|
14996 | 15773 | targetLookAt.set(manipCamera.lookAt); |
---|
14997 | 15774 | repaint(); |
---|
14998 | 15775 | break; |
---|
14999 | | - case 'p': |
---|
| 15776 | + case 'P': // p': |
---|
15000 | 15777 | // c'est quoi ca au juste? spherical ^= true; |
---|
15001 | 15778 | Skinshader ^= true; programInitialized = false; |
---|
15002 | 15779 | repaint(); |
---|
.. | .. |
---|
15007 | 15784 | break; |
---|
15008 | 15785 | case 'm': |
---|
15009 | 15786 | { |
---|
15010 | | - PrintMemory(); |
---|
| 15787 | + //PrintMemory(); |
---|
| 15788 | + ToggleImageFlip(); |
---|
15011 | 15789 | break; |
---|
15012 | 15790 | } |
---|
15013 | 15791 | case 'M': |
---|
.. | .. |
---|
15034 | 15812 | repaint(); |
---|
15035 | 15813 | break; |
---|
15036 | 15814 | case 'O': |
---|
15037 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
15038 | | - repaint(); |
---|
15039 | | - break; |
---|
| 15815 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15816 | + //repaint(); |
---|
| 15817 | + //break; |
---|
15040 | 15818 | case 'o': |
---|
15041 | 15819 | OCCLUSION_CULLING ^= true; |
---|
15042 | 15820 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15043 | 15821 | break; |
---|
15044 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15822 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15045 | 15823 | case '1': |
---|
15046 | 15824 | case '2': |
---|
15047 | 15825 | case '3': |
---|
15048 | 15826 | case '4': |
---|
15049 | 15827 | case '5': |
---|
15050 | | - newenvy = Character.getNumericValue(key); |
---|
15051 | | - repaint(); |
---|
15052 | | - break; |
---|
15053 | 15828 | case '6': |
---|
15054 | 15829 | case '7': |
---|
15055 | 15830 | case '8': |
---|
15056 | 15831 | case '9': |
---|
15057 | | - BGcolor = (key - '6')/3.f; |
---|
| 15832 | + if (true) // envyoff) |
---|
| 15833 | + { |
---|
| 15834 | + BGcolor = (key - '1')/8.f; |
---|
| 15835 | + } |
---|
| 15836 | + else |
---|
| 15837 | + { |
---|
| 15838 | + //newenvy = Character.getNumericValue(key); |
---|
| 15839 | + } |
---|
15058 | 15840 | repaint(); |
---|
15059 | 15841 | break; |
---|
15060 | 15842 | case '!': |
---|
.. | .. |
---|
15124 | 15906 | // kompactbit = 6; |
---|
15125 | 15907 | // break; |
---|
15126 | 15908 | case ' ': |
---|
15127 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15909 | + capsLocked ^= true; |
---|
| 15910 | + repaint(); |
---|
| 15911 | + break; |
---|
| 15912 | + case 'l': |
---|
| 15913 | + lightMode ^= true; |
---|
| 15914 | + if (lightMode) |
---|
| 15915 | + { |
---|
| 15916 | + keepshadow = Globals.RENDERSHADOW; |
---|
| 15917 | + Globals.RENDERSHADOW = false; |
---|
| 15918 | + } |
---|
| 15919 | + else |
---|
| 15920 | + { |
---|
| 15921 | + Globals.RENDERSHADOW = keepshadow; |
---|
| 15922 | + } |
---|
| 15923 | + |
---|
| 15924 | + Globals.lighttouched = true; |
---|
| 15925 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15926 | + targetLookAt.set(manipCamera.lookAt); |
---|
15128 | 15927 | repaint(); |
---|
15129 | 15928 | break; |
---|
15130 | 15929 | //case '`' : |
---|
15131 | 15930 | case ESC: |
---|
| 15931 | + if (FULLSCREEN) |
---|
| 15932 | + object.editWindow.ToggleFullScreen(); |
---|
| 15933 | + break; |
---|
| 15934 | + case 'p': |
---|
15132 | 15935 | RENDERPROGRAM += 1; |
---|
15133 | 15936 | RENDERPROGRAM %= 3; |
---|
15134 | 15937 | |
---|
.. | .. |
---|
15167 | 15970 | case ENTER: |
---|
15168 | 15971 | // object.editWindow.ScreenFit(); // Edit(); |
---|
15169 | 15972 | ToggleLive(); |
---|
| 15973 | + if (capsLocked) |
---|
| 15974 | + { |
---|
| 15975 | + Globals.WALK ^= true; |
---|
| 15976 | + } |
---|
15170 | 15977 | break; |
---|
15171 | 15978 | case DELETE: |
---|
15172 | 15979 | ClearSelection(); |
---|
.. | .. |
---|
15190 | 15997 | case '=': |
---|
15191 | 15998 | IncDepth(); |
---|
15192 | 15999 | //fontsize += 1; |
---|
15193 | | - object.editWindow.refreshContents(true); |
---|
| 16000 | + object.GetWindow().refreshContents(true); |
---|
15194 | 16001 | maskbit = 6; |
---|
15195 | 16002 | break; |
---|
15196 | 16003 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15197 | 16004 | DecDepth(); |
---|
15198 | 16005 | maskbit = 5; |
---|
15199 | 16006 | //if(fontsize > 1) fontsize -= 1; |
---|
15200 | | - if (object.editWindow == null) |
---|
15201 | | - new Exception().printStackTrace(); |
---|
15202 | | - else |
---|
15203 | | - object.editWindow.refreshContents(true); |
---|
| 16007 | +// if (object.editWindow == null) |
---|
| 16008 | +// new Exception().printStackTrace(); |
---|
| 16009 | +// else |
---|
| 16010 | + object.GetWindow().refreshContents(true); |
---|
15204 | 16011 | break; |
---|
15205 | 16012 | case '{': |
---|
15206 | | - manipCamera.shaper_fovy /= 1.1; |
---|
| 16013 | + double factor = 1.1; |
---|
| 16014 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16015 | + manipCamera.shaper_fovy /= factor; |
---|
15207 | 16016 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15208 | 16017 | repaint(); |
---|
15209 | 16018 | break; |
---|
15210 | 16019 | case '}': |
---|
15211 | | - manipCamera.shaper_fovy *= 1.1; |
---|
| 16020 | + factor = 1.1; |
---|
| 16021 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16022 | + manipCamera.shaper_fovy *= factor; |
---|
15212 | 16023 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15213 | 16024 | repaint(); |
---|
15214 | 16025 | break; |
---|
15215 | 16026 | case '[': |
---|
15216 | | - manipCamera.shaper_fovy /= 1.01; |
---|
| 16027 | + factor = 1.01; |
---|
| 16028 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16029 | + manipCamera.shaper_fovy /= factor; |
---|
15217 | 16030 | if (false) //manipCamera.hAspect == 0) |
---|
15218 | 16031 | { |
---|
15219 | 16032 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15229 | 16042 | break; |
---|
15230 | 16043 | case ']': |
---|
15231 | 16044 | //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1; |
---|
15232 | | - manipCamera.shaper_fovy *= 1.01; |
---|
| 16045 | + factor = 1.01; |
---|
| 16046 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16047 | + manipCamera.shaper_fovy *= factor; |
---|
15233 | 16048 | if (false) //manipCamera.hAspect == 0) |
---|
15234 | 16049 | { |
---|
15235 | 16050 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15267 | 16082 | } |
---|
15268 | 16083 | } |
---|
15269 | 16084 | |
---|
| 16085 | + boolean keys[] = new boolean[256]; |
---|
| 16086 | + int speedkey[] = new int[256]; |
---|
| 16087 | + int modifiers = 0; |
---|
| 16088 | + |
---|
15270 | 16089 | public void processKeyEvent(KeyEvent e) |
---|
15271 | 16090 | { |
---|
15272 | 16091 | switch (e.getID()) |
---|
15273 | 16092 | { |
---|
15274 | 16093 | case KeyEvent.KEY_PRESSED: |
---|
15275 | | - if (!autorepeat) |
---|
15276 | | - { |
---|
15277 | | - //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); |
---|
15278 | | - keyPressed(e.getKeyChar(), e.getModifiersEx()); |
---|
15279 | | - } |
---|
15280 | | - if (manipCamera == lightCamera) |
---|
15281 | | - { |
---|
15282 | | - switch (e.getKeyCode()) |
---|
15283 | | - { |
---|
15284 | | - case DOWN_ARROW: |
---|
15285 | | - lightCamera.DECAL /= 2; |
---|
15286 | | - repaint(); |
---|
15287 | | - break; |
---|
15288 | | - case UP_ARROW: |
---|
15289 | | - lightCamera.DECAL *= 2; |
---|
15290 | | - repaint(); |
---|
15291 | | - break; |
---|
15292 | | - case LEFT_ARROW: |
---|
15293 | | - lightCamera.SCALE /= 2; |
---|
15294 | | - repaint(); |
---|
15295 | | - break; |
---|
15296 | | - case RIGHT_ARROW: |
---|
15297 | | - lightCamera.SCALE *= 2; |
---|
15298 | | - repaint(); |
---|
15299 | | - break; |
---|
15300 | | - default: |
---|
15301 | | - break; |
---|
15302 | | - } |
---|
15303 | | - |
---|
15304 | | - System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); |
---|
15305 | | - } else |
---|
15306 | | - { |
---|
15307 | | - if (true) // !autorepeat) |
---|
15308 | | - { |
---|
15309 | | - boolean reset = true; |
---|
15310 | | - |
---|
15311 | | - switch (e.getKeyCode()) |
---|
15312 | | - { |
---|
15313 | | - case DOWN_ARROW: |
---|
15314 | | - GoDown(e.getModifiersEx()); |
---|
15315 | | - repaint(); |
---|
15316 | | - break; |
---|
15317 | | - case UP_ARROW: |
---|
15318 | | - GoUp(e.getModifiersEx()); |
---|
15319 | | - repaint(); |
---|
15320 | | - break; |
---|
15321 | | - case LEFT_ARROW: |
---|
15322 | | - GoLeft(e.getModifiersEx()); |
---|
15323 | | - repaint(); |
---|
15324 | | - break; |
---|
15325 | | - case RIGHT_ARROW: |
---|
15326 | | - GoRight(e.getModifiersEx()); |
---|
15327 | | - repaint(); |
---|
15328 | | - break; |
---|
15329 | | - default: |
---|
15330 | | - reset = false; |
---|
15331 | | - break; |
---|
15332 | | - } |
---|
15333 | | - |
---|
15334 | | - if (reset) |
---|
15335 | | - { |
---|
15336 | | - autorepeat = true; |
---|
15337 | | - |
---|
15338 | | - targetLookAt.set(manipCamera.lookAt); |
---|
15339 | | - } |
---|
15340 | | - } |
---|
15341 | | - } |
---|
| 16094 | + keys[e.getKeyCode()] = true; |
---|
| 16095 | + modifiers = e.getModifiersEx(); |
---|
| 16096 | + keyPressed(e.getKeyChar(), modifiers); |
---|
| 16097 | + //Globals.theRenderer.keyPressed(e.getKeyChar()); |
---|
| 16098 | + repaint(); |
---|
15342 | 16099 | break; |
---|
15343 | | - case KeyEvent.KEY_TYPED: |
---|
15344 | | - break; |
---|
| 16100 | +// if (!autorepeat) |
---|
| 16101 | +// { |
---|
| 16102 | +// //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); |
---|
| 16103 | +// keyPressed(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16104 | +// } |
---|
| 16105 | +// if (manipCamera == lightCamera) |
---|
| 16106 | +// { |
---|
| 16107 | +// switch (e.getKeyCode()) |
---|
| 16108 | +// { |
---|
| 16109 | +// case DOWN_ARROW: |
---|
| 16110 | +// lightCamera.DECAL /= 2; |
---|
| 16111 | +// repaint(); |
---|
| 16112 | +// break; |
---|
| 16113 | +// case UP_ARROW: |
---|
| 16114 | +// lightCamera.DECAL *= 2; |
---|
| 16115 | +// repaint(); |
---|
| 16116 | +// break; |
---|
| 16117 | +// case LEFT_ARROW: |
---|
| 16118 | +// lightCamera.SCALE /= 2; |
---|
| 16119 | +// repaint(); |
---|
| 16120 | +// break; |
---|
| 16121 | +// case RIGHT_ARROW: |
---|
| 16122 | +// lightCamera.SCALE *= 2; |
---|
| 16123 | +// repaint(); |
---|
| 16124 | +// break; |
---|
| 16125 | +// default: |
---|
| 16126 | +// break; |
---|
| 16127 | +// } |
---|
| 16128 | +// |
---|
| 16129 | +// System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); |
---|
| 16130 | +// } else |
---|
| 16131 | +// { |
---|
| 16132 | +// if (true) // !autorepeat) |
---|
| 16133 | +// { |
---|
| 16134 | +// boolean reset = true; |
---|
| 16135 | +// |
---|
| 16136 | +// switch (e.getKeyCode()) |
---|
| 16137 | +// { |
---|
| 16138 | +// case DOWN_ARROW: |
---|
| 16139 | +// GoDown(e.getModifiersEx()); |
---|
| 16140 | +// repaint(); |
---|
| 16141 | +// break; |
---|
| 16142 | +// case UP_ARROW: |
---|
| 16143 | +// GoUp(e.getModifiersEx()); |
---|
| 16144 | +// repaint(); |
---|
| 16145 | +// break; |
---|
| 16146 | +// case LEFT_ARROW: |
---|
| 16147 | +// GoLeft(e.getModifiersEx()); |
---|
| 16148 | +// repaint(); |
---|
| 16149 | +// break; |
---|
| 16150 | +// case RIGHT_ARROW: |
---|
| 16151 | +// GoRight(e.getModifiersEx()); |
---|
| 16152 | +// repaint(); |
---|
| 16153 | +// break; |
---|
| 16154 | +// default: |
---|
| 16155 | +// reset = false; |
---|
| 16156 | +// break; |
---|
| 16157 | +// } |
---|
| 16158 | +// |
---|
| 16159 | +// if (reset) |
---|
| 16160 | +// { |
---|
| 16161 | +// autorepeat = true; |
---|
| 16162 | +// |
---|
| 16163 | +// targetLookAt.set(manipCamera.lookAt); |
---|
| 16164 | +// } |
---|
| 16165 | +// } |
---|
| 16166 | +// } |
---|
| 16167 | +// break; |
---|
| 16168 | +// case KeyEvent.KEY_TYPED: |
---|
| 16169 | +// break; |
---|
15345 | 16170 | case KeyEvent.KEY_RELEASED: |
---|
15346 | | - { |
---|
15347 | | - switch (e.getKeyCode()) |
---|
15348 | | - { |
---|
15349 | | - case DOWN_ARROW: |
---|
15350 | | - case UP_ARROW: |
---|
15351 | | - case LEFT_ARROW: |
---|
15352 | | - case RIGHT_ARROW: |
---|
15353 | | - MODIFIERS &= ~COMMAND; |
---|
15354 | | - autorepeat = false; |
---|
15355 | | - break; |
---|
15356 | | - default: |
---|
15357 | | - break; |
---|
15358 | | - } |
---|
| 16171 | + keys[e.getKeyCode()] = false; |
---|
| 16172 | + modifiers = e.getModifiersEx(); |
---|
15359 | 16173 | keyReleased(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16174 | + repaint(); |
---|
15360 | 16175 | break; |
---|
15361 | | - } |
---|
| 16176 | +// { |
---|
| 16177 | +// switch (e.getKeyCode()) |
---|
| 16178 | +// { |
---|
| 16179 | +// case DOWN_ARROW: |
---|
| 16180 | +// case UP_ARROW: |
---|
| 16181 | +// case LEFT_ARROW: |
---|
| 16182 | +// case RIGHT_ARROW: |
---|
| 16183 | +// MODIFIERS &= ~COMMAND; |
---|
| 16184 | +// autorepeat = false; |
---|
| 16185 | +// break; |
---|
| 16186 | +// default: |
---|
| 16187 | +// break; |
---|
| 16188 | +// } |
---|
| 16189 | +// keyReleased(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16190 | +// break; |
---|
| 16191 | +// } |
---|
15362 | 16192 | default: |
---|
15363 | 16193 | break; |
---|
15364 | 16194 | } |
---|
.. | .. |
---|
15424 | 16254 | } |
---|
15425 | 16255 | */ |
---|
15426 | 16256 | |
---|
15427 | | - object.editWindow.EditSelection(false); |
---|
| 16257 | + object.GetWindow().EditSelection(false); |
---|
15428 | 16258 | } |
---|
15429 | 16259 | |
---|
15430 | 16260 | void SelectParent() |
---|
.. | .. |
---|
15441 | 16271 | { |
---|
15442 | 16272 | //selectees.remove(i); |
---|
15443 | 16273 | System.out.println("select parent of " + elem); |
---|
15444 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 16274 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15445 | 16275 | } else |
---|
15446 | 16276 | { |
---|
15447 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 16277 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15448 | 16278 | } |
---|
15449 | 16279 | |
---|
15450 | 16280 | first = false; |
---|
.. | .. |
---|
15486 | 16316 | for (int j = 0; j < group.children.size(); j++) |
---|
15487 | 16317 | { |
---|
15488 | 16318 | elem = (Object3D) group.children.elementAt(j); |
---|
15489 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 16319 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15490 | 16320 | first = false; |
---|
15491 | 16321 | } |
---|
15492 | 16322 | } else |
---|
15493 | 16323 | { |
---|
15494 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 16324 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15495 | 16325 | } |
---|
15496 | 16326 | |
---|
15497 | 16327 | first = false; |
---|
.. | .. |
---|
15502 | 16332 | { |
---|
15503 | 16333 | //Composite group = (Composite) object; |
---|
15504 | 16334 | Object3D group = object; |
---|
15505 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 16335 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15506 | 16336 | } |
---|
15507 | 16337 | |
---|
15508 | 16338 | void ResetTransform(int mask) |
---|
15509 | 16339 | { |
---|
15510 | 16340 | //Composite group = (Composite) object; |
---|
15511 | 16341 | Object3D group = object; |
---|
15512 | | - group.editWindow.ResetTransform(mask); |
---|
| 16342 | + group.GetWindow().ResetTransform(mask); |
---|
15513 | 16343 | } |
---|
15514 | 16344 | |
---|
15515 | 16345 | void FlipTransform() |
---|
15516 | 16346 | { |
---|
15517 | 16347 | //Composite group = (Composite) object; |
---|
15518 | 16348 | Object3D group = object; |
---|
15519 | | - group.editWindow.FlipTransform(); |
---|
| 16349 | + group.GetWindow().FlipTransform(); |
---|
15520 | 16350 | // group.editWindow.ReduceMesh(true); |
---|
15521 | 16351 | } |
---|
15522 | 16352 | |
---|
.. | .. |
---|
15524 | 16354 | { |
---|
15525 | 16355 | //Composite group = (Composite) object; |
---|
15526 | 16356 | Object3D group = object; |
---|
15527 | | - group.editWindow.PrintMemory(); |
---|
| 16357 | + group.GetWindow().PrintMemory(); |
---|
15528 | 16358 | // group.editWindow.ReduceMesh(true); |
---|
15529 | 16359 | } |
---|
15530 | 16360 | |
---|
.. | .. |
---|
15532 | 16362 | { |
---|
15533 | 16363 | //Composite group = (Composite) object; |
---|
15534 | 16364 | Object3D group = object; |
---|
15535 | | - group.editWindow.ResetCentroid(); |
---|
| 16365 | + group.GetWindow().ResetCentroid(); |
---|
15536 | 16366 | } |
---|
15537 | 16367 | |
---|
15538 | 16368 | void IncDepth() |
---|
.. | .. |
---|
15614 | 16444 | |
---|
15615 | 16445 | int width = getBounds().width; |
---|
15616 | 16446 | int height = getBounds().height; |
---|
15617 | | - ClickInfo info = new ClickInfo(); |
---|
15618 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15619 | 16447 | //Image img = CreateImage(width, height); |
---|
15620 | 16448 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15621 | 16449 | |
---|
.. | .. |
---|
15692 | 16520 | } |
---|
15693 | 16521 | if (object != null && !hasMarquee) |
---|
15694 | 16522 | { |
---|
| 16523 | + if (object.clickInfo == null) |
---|
| 16524 | + object.clickInfo = new ClickInfo(); |
---|
| 16525 | + ClickInfo info = object.clickInfo; |
---|
| 16526 | + //ClickInfo info = new ClickInfo(); |
---|
| 16527 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16528 | + |
---|
15695 | 16529 | if (isRenderer) |
---|
15696 | 16530 | { |
---|
15697 | | - info.flags++; |
---|
| 16531 | + object.clickInfo.flags++; |
---|
15698 | 16532 | double frameAspect = (double) width / (double) height; |
---|
15699 | 16533 | if (frameAspect > renderCamera.aspect) |
---|
15700 | 16534 | { |
---|
15701 | 16535 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15702 | | - info.bounds.width -= width - desired; |
---|
15703 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16536 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16537 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15704 | 16538 | } else |
---|
15705 | 16539 | { |
---|
15706 | 16540 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15707 | | - info.bounds.height -= height - desired; |
---|
15708 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16541 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16542 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15709 | 16543 | } |
---|
15710 | 16544 | } |
---|
15711 | | - info.g = gr; |
---|
15712 | | - info.camera = renderCamera; |
---|
| 16545 | + |
---|
| 16546 | + object.clickInfo.g = gr; |
---|
| 16547 | + object.clickInfo.camera = renderCamera; |
---|
15713 | 16548 | /* |
---|
15714 | 16549 | // Memory intensive (brep.verticescopy) |
---|
15715 | 16550 | if (!(object instanceof Composite)) |
---|
15716 | 16551 | object.draw(info, 0, false); // SLOW : |
---|
15717 | 16552 | */ |
---|
15718 | | - if (!isRenderer) |
---|
| 16553 | + if (!isRenderer) // && drag) |
---|
15719 | 16554 | { |
---|
15720 | | - object.drawEditHandles(info, 0); |
---|
15721 | | - |
---|
15722 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16555 | + Grafreed.Assert(object != null); |
---|
| 16556 | + Grafreed.Assert(object.selection != null); |
---|
| 16557 | + if (object.selection.Size() > 0) |
---|
15723 | 16558 | { |
---|
15724 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16559 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16560 | + |
---|
| 16561 | + object.clickInfo.DX = 0; |
---|
| 16562 | + object.clickInfo.DY = 0; |
---|
| 16563 | + object.clickInfo.W = 1; |
---|
| 16564 | + if (hitSomething == Object3D.hitCenter) |
---|
15725 | 16565 | { |
---|
15726 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15727 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15728 | | - break; |
---|
15729 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15730 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15731 | | - break; |
---|
15732 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15733 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15734 | | - break; |
---|
| 16566 | + info.DX = X; |
---|
| 16567 | + if (X != 0) |
---|
| 16568 | + info.DX -= info.bounds.width/2; |
---|
| 16569 | + |
---|
| 16570 | + info.DY = Y; |
---|
| 16571 | + if (Y != 0) |
---|
| 16572 | + info.DY -= info.bounds.height/2; |
---|
15735 | 16573 | } |
---|
15736 | | - |
---|
| 16574 | + |
---|
| 16575 | + object.drawEditHandles(//info, |
---|
| 16576 | + 0); |
---|
| 16577 | + |
---|
| 16578 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16579 | + { |
---|
| 16580 | + switch (hitSomething) |
---|
| 16581 | + { |
---|
| 16582 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16583 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16584 | + break; |
---|
| 16585 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16586 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16587 | + break; |
---|
| 16588 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16589 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16590 | + break; |
---|
| 16591 | + } |
---|
| 16592 | + |
---|
| 16593 | + } |
---|
15737 | 16594 | } |
---|
15738 | 16595 | } |
---|
15739 | 16596 | } |
---|
.. | .. |
---|
15748 | 16605 | if (hasMarquee) |
---|
15749 | 16606 | { |
---|
15750 | 16607 | gr.setXORMode(Color.white); |
---|
15751 | | - gr.setColor(Color.red); |
---|
| 16608 | + gr.setColor(Color.white); |
---|
15752 | 16609 | if (!firstime) |
---|
15753 | 16610 | { |
---|
15754 | 16611 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
15907 | 16764 | |
---|
15908 | 16765 | public boolean mouseDrag(Event evt, int x, int y) |
---|
15909 | 16766 | { |
---|
15910 | | - //System.out.println("mouseDrag: " + evt); |
---|
| 16767 | + System.out.println("mouseDrag: " + evt); |
---|
| 16768 | + System.exit(0); |
---|
15911 | 16769 | /* |
---|
15912 | 16770 | drag = true; |
---|
15913 | 16771 | //System.out.println("Mouse DRAG"); |
---|
.. | .. |
---|
16026 | 16884 | public boolean mouseUp(Event evt, int x, int y) |
---|
16027 | 16885 | { |
---|
16028 | 16886 | System.out.println("mouseUp: " + evt); |
---|
| 16887 | + System.exit(0); |
---|
16029 | 16888 | /* |
---|
16030 | 16889 | locked = false; |
---|
16031 | 16890 | if (isRenderer) |
---|
.. | .. |
---|
16215 | 17074 | private /*static*/ boolean firstime; |
---|
16216 | 17075 | private /*static*/ cVector newView = new cVector(); |
---|
16217 | 17076 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 17077 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 17078 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16218 | 17079 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16219 | 17080 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16220 | 17081 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16227 | 17088 | { |
---|
16228 | 17089 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16229 | 17090 | |
---|
| 17091 | + int usedsuf = 0; |
---|
| 17092 | + |
---|
16230 | 17093 | for (int i = 0; i < suffixes.length; i++) |
---|
16231 | 17094 | { |
---|
16232 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16233 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16234 | | - mipmapped, |
---|
16235 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16236 | | - if (data == null) |
---|
| 17095 | + String[] suffixe = suffixes; |
---|
| 17096 | + String[] fallback = suffixes2; |
---|
| 17097 | + String[] fallfallback = suffixes3; |
---|
| 17098 | + |
---|
| 17099 | + for (int c=usedsuf; --c>=0;) |
---|
16237 | 17100 | { |
---|
16238 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 17101 | +// String[] temp = suffixe; |
---|
| 17102 | +// suffixe = fallback; |
---|
| 17103 | +// fallback = fallfallback; |
---|
| 17104 | +// fallfallback = temp; |
---|
16239 | 17105 | } |
---|
| 17106 | + |
---|
| 17107 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 17108 | + TextureData data; |
---|
| 17109 | + |
---|
| 17110 | + try |
---|
| 17111 | + { |
---|
| 17112 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 17113 | + mipmapped, |
---|
| 17114 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 17115 | + } |
---|
| 17116 | + catch (Exception e) |
---|
| 17117 | + { |
---|
| 17118 | + try |
---|
| 17119 | + { |
---|
| 17120 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 17121 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 17122 | + mipmapped, |
---|
| 17123 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 17124 | + } |
---|
| 17125 | + catch (Exception e2) |
---|
| 17126 | + { |
---|
| 17127 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 17128 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 17129 | + mipmapped, |
---|
| 17130 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 17131 | + } |
---|
| 17132 | + } |
---|
| 17133 | + |
---|
16240 | 17134 | //System.out.println("Target = " + targets[i]); |
---|
16241 | 17135 | cubemap.updateImage(data, targets[i]); |
---|
16242 | 17136 | } |
---|
16243 | 17137 | |
---|
16244 | 17138 | return cubemap; |
---|
16245 | 17139 | } |
---|
| 17140 | + |
---|
16246 | 17141 | int bigsphere = -1; |
---|
16247 | 17142 | |
---|
16248 | 17143 | float BGcolor = 0.5f; |
---|
16249 | 17144 | |
---|
16250 | | - private void DrawSkyBox(GL gl) |
---|
| 17145 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 17146 | + |
---|
| 17147 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16251 | 17148 | { |
---|
16252 | | - if (envyoff || cubemap == null) |
---|
| 17149 | + if (//envyoff || |
---|
| 17150 | + WIREFRAME || |
---|
| 17151 | + cubemap == null) |
---|
16253 | 17152 | { |
---|
16254 | 17153 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16255 | 17154 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16264 | 17163 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16265 | 17164 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16266 | 17165 | gl.glLoadIdentity(); |
---|
| 17166 | + gl.glScalef(1,ratio,1); |
---|
16267 | 17167 | |
---|
| 17168 | +// colorV[0] = 2; |
---|
| 17169 | +// colorV[1] = 2; |
---|
| 17170 | +// colorV[2] = 2; |
---|
| 17171 | +// colorV[3] = 1; |
---|
| 17172 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 17173 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 17174 | +// |
---|
| 17175 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 17176 | + |
---|
16268 | 17177 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16269 | 17178 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16270 | 17179 | |
---|
.. | .. |
---|
16296 | 17205 | { |
---|
16297 | 17206 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16298 | 17207 | } |
---|
| 17208 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16299 | 17209 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16300 | 17210 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16301 | 17211 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16336 | 17246 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16337 | 17247 | |
---|
16338 | 17248 | cubemap.disable(); |
---|
16339 | | - ////cubemap.unbind(); |
---|
| 17249 | + //cubemap.dispose(); |
---|
| 17250 | + |
---|
16340 | 17251 | if (CULLFACE) |
---|
16341 | 17252 | { |
---|
16342 | 17253 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16392 | 17303 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16393 | 17304 | } |
---|
16394 | 17305 | |
---|
16395 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 17306 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16396 | 17307 | |
---|
16397 | 17308 | float step = 2; // 0.1666f; //0.25f; |
---|
16398 | 17309 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16531 | 17442 | } |
---|
16532 | 17443 | } |
---|
16533 | 17444 | |
---|
| 17445 | + private Object3D GetFolder() |
---|
| 17446 | + { |
---|
| 17447 | + Object3D folder = object.GetWindow().copy; |
---|
| 17448 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17449 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17450 | + return folder; |
---|
| 17451 | + } |
---|
| 17452 | + |
---|
16534 | 17453 | class SelectBuffer implements GLEventListener |
---|
16535 | 17454 | { |
---|
16536 | 17455 | |
---|
.. | .. |
---|
16546 | 17465 | //new Exception().printStackTrace(); |
---|
16547 | 17466 | System.out.println("select buffer init"); |
---|
16548 | 17467 | // Use debug pipeline |
---|
16549 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17468 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16550 | 17469 | |
---|
16551 | 17470 | GL gl = drawable.getGL(); |
---|
16552 | 17471 | |
---|
.. | .. |
---|
16610 | 17529 | |
---|
16611 | 17530 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16612 | 17531 | |
---|
| 17532 | + if (PAINTMODE) |
---|
| 17533 | + { |
---|
| 17534 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17535 | + { |
---|
| 17536 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17537 | + |
---|
| 17538 | + // Make what you paint not selectable. |
---|
| 17539 | + paintobj.ResetSelectable(); |
---|
| 17540 | + } |
---|
| 17541 | + } |
---|
| 17542 | + |
---|
16613 | 17543 | //int tmp = selection_view; |
---|
16614 | 17544 | //selection_view = -1; |
---|
16615 | 17545 | int temp = DrawMode(); |
---|
.. | .. |
---|
16621 | 17551 | // temp = DEFAULT; // patch for selection debug |
---|
16622 | 17552 | Globals.drawMode = temp; // WARNING |
---|
16623 | 17553 | |
---|
| 17554 | + if (PAINTMODE) |
---|
| 17555 | + { |
---|
| 17556 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17557 | + { |
---|
| 17558 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17559 | + |
---|
| 17560 | + // Revert. |
---|
| 17561 | + paintobj.RestoreSelectable(); |
---|
| 17562 | + } |
---|
| 17563 | + } |
---|
| 17564 | + |
---|
16624 | 17565 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16625 | 17566 | |
---|
16626 | 17567 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16651 | 17592 | |
---|
16652 | 17593 | float depth = depths[y * TEX_SIZE + x]; |
---|
16653 | 17594 | |
---|
16654 | | - if (pointselection && mouseMode == SELECT && depth != 0 && depth != 1) |
---|
| 17595 | + if (pointselection && (mouseMode & SELECT) == SELECT && depth != 0 && depth != 1) |
---|
16655 | 17596 | { |
---|
16656 | 17597 | pointselection = false; |
---|
16657 | 17598 | |
---|
.. | .. |
---|
16724 | 17665 | } |
---|
16725 | 17666 | |
---|
16726 | 17667 | if (!movingcamera && !PAINTMODE) |
---|
16727 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17668 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16728 | 17669 | |
---|
16729 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17670 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16730 | 17671 | { |
---|
16731 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17672 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16732 | 17673 | |
---|
16733 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17674 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17675 | + { |
---|
| 17676 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16734 | 17677 | |
---|
16735 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16736 | | - |
---|
16737 | | - group.add(paintobj); // link |
---|
16738 | | - |
---|
16739 | | - object.editWindow.SnapObject(group); |
---|
16740 | | - |
---|
16741 | | - Object3D folder = object.editWindow.copy; |
---|
16742 | | - |
---|
16743 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16744 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16745 | | - |
---|
16746 | | - folder.add(group); |
---|
16747 | | - |
---|
16748 | | - object.editWindow.ResetModel(); |
---|
16749 | | - object.editWindow.refreshContents(); |
---|
| 17678 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17679 | + |
---|
| 17680 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17681 | + |
---|
| 17682 | + inst.add(paintobj); // link |
---|
| 17683 | + |
---|
| 17684 | + object.GetWindow().SnapObject(inst); |
---|
| 17685 | + |
---|
| 17686 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17687 | + |
---|
| 17688 | + folder.add(inst); |
---|
| 17689 | + |
---|
| 17690 | + object.GetWindow().ResetModel(); |
---|
| 17691 | + object.GetWindow().refreshContents(); |
---|
| 17692 | + } |
---|
16750 | 17693 | } |
---|
16751 | 17694 | else |
---|
16752 | 17695 | paintcount = 0; |
---|
.. | .. |
---|
16840 | 17783 | |
---|
16841 | 17784 | public void init(GLAutoDrawable drawable) |
---|
16842 | 17785 | { |
---|
| 17786 | + if (Globals.DEBUG) |
---|
16843 | 17787 | System.out.println("shadow buffer init"); |
---|
16844 | 17788 | |
---|
16845 | 17789 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17068 | 18012 | gl.glFlush(); |
---|
17069 | 18013 | |
---|
17070 | 18014 | /**/ |
---|
17071 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 18015 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17072 | 18016 | |
---|
17073 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 18017 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17074 | 18018 | |
---|
| 18019 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 18020 | + |
---|
| 18021 | + int[] pixels = selectsizebuffer.array(); |
---|
| 18022 | + |
---|
17075 | 18023 | double r = 0, g = 0, b = 0; |
---|
17076 | 18024 | |
---|
17077 | 18025 | double count = 0; |
---|
.. | .. |
---|
17082 | 18030 | |
---|
17083 | 18031 | double FACTOR = 1; |
---|
17084 | 18032 | |
---|
17085 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 18033 | + for (int i = 0; i < depths.length; i++) |
---|
17086 | 18034 | { |
---|
17087 | 18035 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17088 | 18036 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17165 | 18113 | |
---|
17166 | 18114 | double scale = ray.z; // 1; // cos |
---|
17167 | 18115 | |
---|
17168 | | - float depth = pixels[newindex]; |
---|
| 18116 | + float depth = depths[newindex]; |
---|
17169 | 18117 | |
---|
17170 | 18118 | /* |
---|
17171 | 18119 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17308 | 18256 | static boolean DEBUG_SELECTION = false; |
---|
17309 | 18257 | boolean OCCLUSION_CULLING = false; //true; |
---|
17310 | 18258 | public boolean lightMode = false; |
---|
| 18259 | + |
---|
| 18260 | + private boolean keepshadow; |
---|
| 18261 | + |
---|
| 18262 | + static public boolean capsLocked = false; // VR |
---|
| 18263 | + |
---|
17311 | 18264 | static public int indexcount = 0; |
---|
17312 | 18265 | /*static*/ cColor vertexOcclusion = new cColor(); |
---|
17313 | 18266 | //private int selection_view = -1; |
---|
.. | .. |
---|
17362 | 18315 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17363 | 18316 | static IntBuffer bigAAbuffer; |
---|
17364 | 18317 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17365 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 18318 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17366 | 18319 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17367 | 18320 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17368 | 18321 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17369 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 18322 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 18323 | + |
---|
| 18324 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 18325 | + |
---|
17370 | 18326 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17371 | 18327 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17372 | 18328 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|