.. | .. |
---|
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 | |
---|
.. | .. |
---|
335 | 391 | display.options1[2] = material.shadowbias; |
---|
336 | 392 | display.options1[3] = material.aniso; |
---|
337 | 393 | display.options1[4] = material.anisoV; |
---|
| 394 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 395 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 396 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 397 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 398 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
338 | 399 | display.options2[0] = material.opacity; |
---|
339 | 400 | display.options2[1] = material.diffuse; |
---|
340 | 401 | display.options2[2] = material.factor; |
---|
| 402 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 403 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 404 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
341 | 405 | |
---|
342 | 406 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 407 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 408 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 409 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
343 | 410 | display.options4[0] = material.cameralight/0.2f; |
---|
344 | 411 | display.options4[1] = material.subsurface; |
---|
345 | 412 | display.options4[2] = material.sheen; |
---|
| 413 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 414 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 415 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
346 | 416 | |
---|
347 | 417 | // if (display.CURRENTANTIALIAS > 0) |
---|
348 | 418 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
473 | 543 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
474 | 544 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
475 | 545 | LA.vecNormalize(obj.v2); |
---|
476 | | - 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); |
---|
477 | 548 | } |
---|
478 | 549 | |
---|
479 | 550 | // P |
---|
.. | .. |
---|
495 | 566 | y += ny * obj.NORMALPUSH; |
---|
496 | 567 | z += nz * obj.NORMALPUSH; |
---|
497 | 568 | |
---|
498 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 569 | + SetGLNormal(gl, nx, ny, nz); |
---|
499 | 570 | } |
---|
500 | 571 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
501 | 572 | SetColor(obj, pv); |
---|
.. | .. |
---|
527 | 598 | y += ny * obj.NORMALPUSH; |
---|
528 | 599 | z += nz * obj.NORMALPUSH; |
---|
529 | 600 | |
---|
530 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 601 | + SetGLNormal(gl, nx, ny, nz); |
---|
531 | 602 | } |
---|
532 | 603 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
533 | 604 | // boolean locked = false; |
---|
.. | .. |
---|
575 | 646 | y += ny * obj.NORMALPUSH; |
---|
576 | 647 | z += nz * obj.NORMALPUSH; |
---|
577 | 648 | |
---|
578 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 649 | + SetGLNormal(gl, nx, ny, nz); |
---|
579 | 650 | } |
---|
580 | 651 | |
---|
581 | 652 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
811 | 882 | //// tris.postdraw(this); |
---|
812 | 883 | } |
---|
813 | 884 | |
---|
814 | | - static Camera localcamera = new Camera(); |
---|
| 885 | + static Camera localAOcamera = new Camera(); |
---|
815 | 886 | static cVector from = new cVector(); |
---|
816 | 887 | static cVector to = new cVector(); |
---|
817 | 888 | |
---|
.. | .. |
---|
820 | 891 | CameraPane cp = this; |
---|
821 | 892 | |
---|
822 | 893 | Camera keep = cp.RenderCamera(); |
---|
823 | | - cp.renderCamera = localcamera; |
---|
| 894 | + cp.renderCamera = localAOcamera; |
---|
824 | 895 | |
---|
825 | 896 | if (br.trimmed) |
---|
826 | 897 | { |
---|
.. | .. |
---|
838 | 909 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
839 | 910 | LA.xformPos(from, transform, from); |
---|
840 | 911 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
841 | | - localcamera.setAim(from, to); |
---|
| 912 | + localAOcamera.setAim(from, to); |
---|
842 | 913 | |
---|
843 | 914 | CameraPane.occlusionbuffer.display(); |
---|
844 | 915 | |
---|
.. | .. |
---|
872 | 943 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
873 | 944 | LA.xformPos(from, transform, from); |
---|
874 | 945 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
875 | | - localcamera.setAim(from, to); |
---|
| 946 | + localAOcamera.setAim(from, to); |
---|
876 | 947 | |
---|
877 | 948 | CameraPane.occlusionbuffer.display(); |
---|
878 | 949 | |
---|
.. | .. |
---|
1181 | 1252 | { |
---|
1182 | 1253 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1183 | 1254 | { |
---|
1184 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1255 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1185 | 1256 | } else |
---|
1186 | 1257 | { |
---|
1187 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1258 | + SetGLNormal(gl, 0, 0, 1); |
---|
1188 | 1259 | } |
---|
1189 | 1260 | |
---|
1190 | 1261 | if (c != null) |
---|
.. | .. |
---|
1208 | 1279 | { |
---|
1209 | 1280 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1210 | 1281 | { |
---|
1211 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1282 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1212 | 1283 | } else |
---|
1213 | 1284 | { |
---|
1214 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1285 | + SetGLNormal(gl, 0, 0, 1); |
---|
1215 | 1286 | } |
---|
1216 | 1287 | if (c != null) |
---|
1217 | 1288 | { |
---|
.. | .. |
---|
1236 | 1307 | { |
---|
1237 | 1308 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1238 | 1309 | { |
---|
1239 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1310 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1240 | 1311 | } else |
---|
1241 | 1312 | { |
---|
1242 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1313 | + SetGLNormal(gl, 0, 0, 1); |
---|
1243 | 1314 | } |
---|
1244 | 1315 | if (c != null) |
---|
1245 | 1316 | { |
---|
.. | .. |
---|
1421 | 1492 | { |
---|
1422 | 1493 | if (!selectmode) |
---|
1423 | 1494 | { |
---|
1424 | | - 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); |
---|
1425 | 1496 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1426 | 1497 | |
---|
1427 | 1498 | if (flipV) |
---|
.. | .. |
---|
1433 | 1504 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1434 | 1505 | } |
---|
1435 | 1506 | |
---|
| 1507 | + float[] colorV = new float[4]; |
---|
| 1508 | + |
---|
1436 | 1509 | void SetColor(Object3D obj, Vertex p0) |
---|
1437 | 1510 | { |
---|
1438 | 1511 | CameraPane display = this; |
---|
.. | .. |
---|
1500 | 1573 | { |
---|
1501 | 1574 | return; |
---|
1502 | 1575 | } |
---|
1503 | | - |
---|
1504 | | - float[] colorV = new float[3]; |
---|
1505 | 1576 | |
---|
1506 | 1577 | if (false) // marked) |
---|
1507 | 1578 | { |
---|
.. | .. |
---|
1750 | 1821 | |
---|
1751 | 1822 | display.modelParams7[0] = 0; |
---|
1752 | 1823 | display.modelParams7[1] = 1000; |
---|
1753 | | - display.modelParams7[2] = 0; |
---|
| 1824 | + display.modelParams7[2] = material.parallax; |
---|
1754 | 1825 | display.modelParams7[3] = 0; |
---|
1755 | 1826 | |
---|
1756 | 1827 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
1983 | 2054 | switch(viewcode) |
---|
1984 | 2055 | { |
---|
1985 | 2056 | case 0: return "main"; |
---|
1986 | | - case 1: return "one"; |
---|
1987 | | - case 2: return "two"; |
---|
1988 | | - case 3: return "three"; |
---|
| 2057 | + case 1: return "Red"; |
---|
| 2058 | + case 2: return "Green"; |
---|
| 2059 | + case 3: return "Blue"; |
---|
1989 | 2060 | case 4: return "light"; |
---|
1990 | 2061 | } |
---|
1991 | 2062 | |
---|
.. | .. |
---|
1994 | 2065 | |
---|
1995 | 2066 | static int camerachangeframe; |
---|
1996 | 2067 | |
---|
1997 | | - public boolean SetCamera(Camera cam) |
---|
| 2068 | + public boolean SetCamera(Camera cam, boolean set) |
---|
1998 | 2069 | { |
---|
1999 | 2070 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
2000 | 2071 | // return false; |
---|
.. | .. |
---|
2012 | 2083 | |
---|
2013 | 2084 | camerachangeframe = Globals.framecount; |
---|
2014 | 2085 | |
---|
2015 | | - cam.hAspect = -1; // Read only |
---|
| 2086 | + if (cam != null) |
---|
| 2087 | + cam.hAspect = -1; // Read only |
---|
2016 | 2088 | |
---|
2017 | 2089 | cameras[0] = cam; |
---|
2018 | 2090 | targetLookAts[0] = new cVector(cam.lookAt); |
---|
.. | .. |
---|
2022 | 2094 | { |
---|
2023 | 2095 | cameras[i] = new Camera(cam.viewCode); |
---|
2024 | 2096 | } |
---|
2025 | | - |
---|
2026 | | - cameras[i].setAim(cam.location, cam.lookAt); |
---|
2027 | | - cameras[i].shaper_fovy = cam.shaper_fovy; |
---|
2028 | | - cameras[i].UP.set(cam.UP); |
---|
2029 | | - 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 | + } |
---|
2030 | 2105 | } |
---|
2031 | 2106 | cameracount = 0; |
---|
2032 | 2107 | targetLookAt = targetLookAts[cameracount]; |
---|
.. | .. |
---|
2035 | 2110 | // Start with free camera |
---|
2036 | 2111 | SwitchCameras(true); |
---|
2037 | 2112 | |
---|
2038 | | - pingthread.jump = true; // optional? |
---|
| 2113 | +// pingthread.jump = true; // optional? |
---|
2039 | 2114 | |
---|
2040 | 2115 | if (TRACKONCE) |
---|
2041 | 2116 | { |
---|
.. | .. |
---|
2051 | 2126 | //System.err.println("Oeil on"); |
---|
2052 | 2127 | OEIL = true; |
---|
2053 | 2128 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2054 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2129 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2055 | 2130 | //pingthread.StepToTarget(true); |
---|
2056 | 2131 | } |
---|
2057 | 2132 | |
---|
.. | .. |
---|
2222 | 2297 | public void ToggleTrack() |
---|
2223 | 2298 | { |
---|
2224 | 2299 | TRACK ^= true; |
---|
2225 | | - if (TRACK) |
---|
2226 | | - { |
---|
2227 | | - if (object.selection != null && |
---|
2228 | | - object.selection.size() > 0 && |
---|
2229 | | - object.selection.elementAt(0) != null && |
---|
2230 | | - !(object.selection.elementAt(0) instanceof Camera) && |
---|
2231 | | - !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
2232 | | - { |
---|
2233 | | - trackedobject = object.selection.elementAt(0); |
---|
2234 | | - repaint(); |
---|
2235 | | - } |
---|
2236 | | - } |
---|
2237 | 2300 | |
---|
2238 | 2301 | repaint(); |
---|
2239 | 2302 | } |
---|
.. | .. |
---|
2284 | 2347 | HANDLES ^= true; |
---|
2285 | 2348 | } |
---|
2286 | 2349 | |
---|
| 2350 | + Object3D paintFolder; |
---|
| 2351 | + |
---|
2287 | 2352 | void TogglePaint() |
---|
2288 | 2353 | { |
---|
2289 | 2354 | PAINTMODE ^= true; |
---|
2290 | 2355 | paintcount = 0; |
---|
| 2356 | + |
---|
| 2357 | + if (PAINTMODE) |
---|
| 2358 | + { |
---|
| 2359 | + paintFolder = GetFolder(); |
---|
| 2360 | + } |
---|
2291 | 2361 | } |
---|
2292 | 2362 | |
---|
2293 | 2363 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2318 | 2388 | { |
---|
2319 | 2389 | //System.out.println("PROTECTION = " + cam.hAspect); |
---|
2320 | 2390 | //assert (cam.hAspect == 0); |
---|
2321 | | - cam.hAspect = 0; |
---|
| 2391 | + if (cam != null) |
---|
| 2392 | + cam.hAspect = 0; |
---|
2322 | 2393 | lightCamera = cam; |
---|
2323 | 2394 | } |
---|
2324 | 2395 | |
---|
.. | .. |
---|
2384 | 2455 | return currentGL; |
---|
2385 | 2456 | } |
---|
2386 | 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 | + |
---|
2387 | 2485 | /**/ |
---|
2388 | 2486 | class CacheTexture |
---|
2389 | 2487 | { |
---|
.. | .. |
---|
2392 | 2490 | |
---|
2393 | 2491 | int resolution; |
---|
2394 | 2492 | |
---|
2395 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2493 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2396 | 2494 | { |
---|
2397 | | - texture = tex; |
---|
| 2495 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2496 | + texturedata = texdata; |
---|
2398 | 2497 | resolution = res; |
---|
2399 | 2498 | } |
---|
2400 | 2499 | } |
---|
2401 | 2500 | /**/ |
---|
2402 | 2501 | |
---|
2403 | 2502 | // TEXTURE static Texture texture; |
---|
2404 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2405 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2406 | | - 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 | + |
---|
2407 | 2508 | int pigmentdepth = 0; |
---|
2408 | 2509 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2409 | 2510 | int bumpdepth = 0; |
---|
2410 | 2511 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2411 | 2512 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2412 | 2513 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2413 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2514 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2414 | 2515 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2415 | 2516 | |
---|
2416 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2517 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2417 | 2518 | { |
---|
2418 | 2519 | TextureData texturedata = null; |
---|
2419 | 2520 | |
---|
.. | .. |
---|
2423 | 2524 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2424 | 2525 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2425 | 2526 | true, |
---|
2426 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2527 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2427 | 2528 | } catch (java.io.IOException e) |
---|
2428 | 2529 | { |
---|
2429 | 2530 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2432 | 2533 | if (bump) |
---|
2433 | 2534 | texturedata = ConvertBump(texturedata, false); |
---|
2434 | 2535 | |
---|
2435 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2436 | | - 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); |
---|
2437 | 2538 | |
---|
2438 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2439 | | - 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); |
---|
2440 | 2541 | |
---|
2441 | | - 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; |
---|
2442 | 2564 | } |
---|
2443 | 2565 | |
---|
2444 | 2566 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3468 | 3590 | }; |
---|
3469 | 3591 | /**/ |
---|
3470 | 3592 | |
---|
| 3593 | + static Object3D lastObject; |
---|
| 3594 | + |
---|
3471 | 3595 | //com.sun.opengl.util.texture.Texture |
---|
3472 | 3596 | TextureData |
---|
3473 | 3597 | GetFileTexture(String name, boolean bump, int resolution) |
---|
.. | .. |
---|
3504 | 3628 | // return null; |
---|
3505 | 3629 | //if (i == 2) |
---|
3506 | 3630 | // return null; |
---|
| 3631 | + // TIFF issue sept 2019 |
---|
| 3632 | + System.err.println("lastObject = " + lastObject); |
---|
3507 | 3633 | e.printStackTrace(); |
---|
3508 | 3634 | name = name.split("\\.tif")[0] + ".jpg"; |
---|
3509 | 3635 | } |
---|
.. | .. |
---|
3511 | 3637 | |
---|
3512 | 3638 | System.out.println("LOADING TEXTURE : " + name); |
---|
3513 | 3639 | |
---|
| 3640 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3641 | + |
---|
3514 | 3642 | // |
---|
3515 | 3643 | if (false) // compressbit > 0) |
---|
3516 | 3644 | { |
---|
.. | .. |
---|
6834 | 6962 | short residu = 0; |
---|
6835 | 6963 | |
---|
6836 | 6964 | // wraparound workarounds |
---|
6837 | | - short fuck = (short) (buffer[i] & 0xFF); |
---|
| 6965 | + short ww = (short) (buffer[i] & 0xFF); |
---|
6838 | 6966 | /* |
---|
6839 | | - residu += (fuck%2); |
---|
6840 | | - if(fuck/2 < 256-residu/2) |
---|
| 6967 | + residu += (ww%2); |
---|
| 6968 | + if(ww/2 < 256-residu/2) |
---|
6841 | 6969 | { |
---|
6842 | | - fuck = (short)((fuck/2) + residu/2); |
---|
| 6970 | + ww = (short)((ww/2) + residu/2); |
---|
6843 | 6971 | if(residu == 2) |
---|
6844 | 6972 | residu = 0; |
---|
6845 | 6973 | } |
---|
6846 | 6974 | else |
---|
6847 | 6975 | { |
---|
6848 | 6976 | residu = 0; |
---|
6849 | | - fuck /= 2; |
---|
| 6977 | + ww /= 2; |
---|
6850 | 6978 | } |
---|
6851 | 6979 | */ |
---|
6852 | | - if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254) |
---|
| 6980 | + if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254) |
---|
6853 | 6981 | { |
---|
6854 | | - fuck /= 2; |
---|
| 6982 | + ww /= 2; |
---|
6855 | 6983 | } else |
---|
6856 | 6984 | { |
---|
6857 | | - fuck = (short) ((fuck / 2) + fuck % 2); |
---|
| 6985 | + ww = (short) ((ww / 2) + ww % 2); |
---|
6858 | 6986 | } |
---|
6859 | 6987 | |
---|
6860 | | - buffer[i] = (byte) fuck; |
---|
| 6988 | + buffer[i] = (byte) ww; |
---|
6861 | 6989 | } |
---|
6862 | 6990 | //System.out.print(bytes[i] + " "); |
---|
6863 | 6991 | //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps; |
---|
.. | .. |
---|
7909 | 8037 | String pigment = Object3D.GetPigment(tex); |
---|
7910 | 8038 | String bump = Object3D.GetBump(tex); |
---|
7911 | 8039 | |
---|
7912 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8040 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7913 | 8041 | { |
---|
7914 | 8042 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7915 | 8043 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7924 | 8052 | pigment = null; |
---|
7925 | 8053 | } |
---|
7926 | 8054 | |
---|
7927 | | - ReleaseTexture(bump, true); |
---|
7928 | | - ReleaseTexture(pigment, false); |
---|
| 8055 | + ReleaseTexture(tex, true); |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
7929 | 8057 | } |
---|
7930 | 8058 | |
---|
7931 | 8059 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7943 | 8071 | |
---|
7944 | 8072 | String pigment = Object3D.GetPigment(tex); |
---|
7945 | 8073 | |
---|
7946 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7947 | 8075 | { |
---|
7948 | 8076 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7949 | 8077 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7954 | 8082 | pigment = null; |
---|
7955 | 8083 | } |
---|
7956 | 8084 | |
---|
7957 | | - ReleaseTexture(pigment, false); |
---|
| 8085 | + ReleaseTexture(tex, false); |
---|
7958 | 8086 | } |
---|
7959 | 8087 | |
---|
7960 | 8088 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7972 | 8100 | |
---|
7973 | 8101 | String bump = Object3D.GetBump(tex); |
---|
7974 | 8102 | |
---|
7975 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8103 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7976 | 8104 | { |
---|
7977 | 8105 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7978 | 8106 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7983 | 8111 | bump = null; |
---|
7984 | 8112 | } |
---|
7985 | 8113 | |
---|
7986 | | - ReleaseTexture(bump, true); |
---|
| 8114 | + ReleaseTexture(tex, true); |
---|
7987 | 8115 | } |
---|
7988 | 8116 | |
---|
7989 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8117 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7990 | 8118 | { |
---|
7991 | 8119 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7992 | 8120 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7997 | 8125 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7998 | 8126 | |
---|
7999 | 8127 | if (tex != null) |
---|
8000 | | - texture = textures.get(tex); |
---|
| 8128 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8001 | 8129 | |
---|
8002 | 8130 | // //assert( texture != null ); |
---|
8003 | 8131 | // if (texture == null) |
---|
.. | .. |
---|
8091 | 8219 | |
---|
8092 | 8220 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8093 | 8221 | { |
---|
8094 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8095 | | - ambientOcclusion ) // || !textureon) |
---|
8096 | | - { |
---|
8097 | | - return; // false; |
---|
8098 | | - } |
---|
8099 | | - |
---|
8100 | | - if (tex == null) |
---|
8101 | | - { |
---|
8102 | | - BindTexture(null,false,resolution); |
---|
8103 | | - BindTexture(null,true,resolution); |
---|
8104 | | - return; |
---|
8105 | | - } |
---|
| 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; |
---|
8106 | 8263 | |
---|
8107 | | - String pigment = Object3D.GetPigment(tex); |
---|
8108 | | - String bump = Object3D.GetBump(tex); |
---|
8109 | | - |
---|
8110 | | - usedtextures.put(pigment, pigment); |
---|
8111 | | - usedtextures.put(bump, bump); |
---|
8112 | | - |
---|
8113 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8114 | | - { |
---|
8115 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8116 | | - // System.out.println("; bump = " + bump); |
---|
8117 | | - } |
---|
8118 | | - |
---|
8119 | | - if (bump.equals("")) |
---|
8120 | | - { |
---|
8121 | | - bump = null; |
---|
8122 | | - } |
---|
8123 | | - if (pigment.equals("")) |
---|
8124 | | - { |
---|
8125 | | - pigment = null; |
---|
8126 | | - } |
---|
8127 | | - |
---|
8128 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8129 | | - BindTexture(pigment, false, resolution); |
---|
8130 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8131 | | - BindTexture(bump, true, resolution); |
---|
8132 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8133 | | - |
---|
8134 | | - return; // true; |
---|
| 8264 | + BindPigmentTexture(tex, resolution); |
---|
| 8265 | + BindBumpTexture(tex, resolution); |
---|
8135 | 8266 | } |
---|
8136 | 8267 | |
---|
8137 | 8268 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8150 | 8281 | |
---|
8151 | 8282 | String pigment = Object3D.GetPigment(tex); |
---|
8152 | 8283 | |
---|
8153 | | - usedtextures.put(pigment, pigment); |
---|
| 8284 | + usedtextures.add(tex); |
---|
8154 | 8285 | |
---|
8155 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8286 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8156 | 8287 | { |
---|
8157 | 8288 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8158 | 8289 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8164 | 8295 | } |
---|
8165 | 8296 | |
---|
8166 | 8297 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8167 | | - BindTexture(pigment, false, resolution); |
---|
| 8298 | + BindTexture(tex, false, resolution); |
---|
8168 | 8299 | } |
---|
8169 | 8300 | |
---|
8170 | 8301 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8183 | 8314 | |
---|
8184 | 8315 | String bump = Object3D.GetBump(tex); |
---|
8185 | 8316 | |
---|
8186 | | - usedtextures.put(bump, bump); |
---|
| 8317 | + usedtextures.add(tex); |
---|
8187 | 8318 | |
---|
8188 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8319 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8189 | 8320 | { |
---|
8190 | 8321 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8191 | 8322 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8197 | 8328 | } |
---|
8198 | 8329 | |
---|
8199 | 8330 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8200 | | - BindTexture(bump, true, resolution); |
---|
| 8331 | + BindTexture(tex, true, resolution); |
---|
8201 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8202 | 8333 | } |
---|
8203 | 8334 | |
---|
.. | .. |
---|
8221 | 8352 | return fileExists; |
---|
8222 | 8353 | } |
---|
8223 | 8354 | |
---|
8224 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8355 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8225 | 8356 | { |
---|
8226 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8357 | + CacheTexture texturecache = null; |
---|
8227 | 8358 | |
---|
8228 | 8359 | if (tex != null) |
---|
8229 | 8360 | { |
---|
8230 | | - 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 | + } |
---|
8231 | 8368 | |
---|
8232 | 8369 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8233 | 8370 | |
---|
.. | .. |
---|
8237 | 8374 | // else |
---|
8238 | 8375 | // if (!texname.startsWith("/")) |
---|
8239 | 8376 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8240 | | - if (!FileExists(tex)) |
---|
| 8377 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8241 | 8378 | { |
---|
8242 | 8379 | texname = fallbackTextureName; |
---|
8243 | 8380 | } |
---|
8244 | 8381 | |
---|
8245 | 8382 | if (CACHETEXTURE) |
---|
8246 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8247 | | - |
---|
8248 | | - TextureData texturedata = null; |
---|
8249 | | - |
---|
8250 | | - if (texture == null || texture.resolution < resolution) |
---|
8251 | 8383 | { |
---|
8252 | | - 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("")) |
---|
8253 | 8417 | { |
---|
8254 | 8418 | assert(!bump); |
---|
8255 | 8419 | // if (bump) |
---|
.. | .. |
---|
8260 | 8424 | // } |
---|
8261 | 8425 | // else |
---|
8262 | 8426 | // { |
---|
8263 | | - texture = textures.get(tex); |
---|
8264 | | - if (texture == null) |
---|
| 8427 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8428 | + if (texturecache == null) |
---|
8265 | 8429 | { |
---|
8266 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8430 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8267 | 8431 | } |
---|
| 8432 | + else |
---|
| 8433 | + new Exception().printStackTrace(); |
---|
8268 | 8434 | // } |
---|
8269 | 8435 | } else |
---|
8270 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8436 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8271 | 8437 | { |
---|
8272 | 8438 | assert(bump); |
---|
8273 | | - texture = textures.get(tex); |
---|
8274 | | - if (texture == null) |
---|
8275 | | - 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(); |
---|
8276 | 8444 | } else |
---|
8277 | 8445 | { |
---|
8278 | 8446 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8280 | 8448 | // texture = GetResourceTexture("default.png"); |
---|
8281 | 8449 | //} else |
---|
8282 | 8450 | //{ |
---|
8283 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8451 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8284 | 8452 | { |
---|
8285 | | - texture = textures.get(tex); |
---|
8286 | | - if (texture == null) |
---|
8287 | | - 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(); |
---|
8288 | 8467 | } else |
---|
8289 | 8468 | { |
---|
8290 | 8469 | if (textureon) |
---|
.. | .. |
---|
8343 | 8522 | if (texturedata == null) |
---|
8344 | 8523 | throw new Exception(); |
---|
8345 | 8524 | |
---|
8346 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8525 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8347 | 8526 | //texture = GetTexture(tex, bump); |
---|
8348 | 8527 | } |
---|
| 8528 | + } |
---|
8349 | 8529 | } |
---|
8350 | 8530 | //} |
---|
8351 | 8531 | } |
---|
8352 | 8532 | |
---|
8353 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8533 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8354 | 8534 | { |
---|
8355 | 8535 | //return false; |
---|
8356 | 8536 | |
---|
8357 | 8537 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8358 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8538 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8359 | 8539 | { |
---|
8360 | 8540 | // String ext = "_highres"; |
---|
8361 | 8541 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8372 | 8552 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8373 | 8553 | if (!cachefile.exists()) |
---|
8374 | 8554 | { |
---|
8375 | | - // cache to disk |
---|
8376 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8377 | | - //buffers[0]. |
---|
8378 | | - |
---|
8379 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8380 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8381 | | - |
---|
8382 | | - // squared size heuristic... |
---|
8383 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8555 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8384 | 8556 | { |
---|
8385 | | - for (int i=pixels.length; --i>=0;) |
---|
8386 | | - { |
---|
8387 | | - int i3 = i*3; |
---|
8388 | | - pixels[i] = 0xFF; |
---|
8389 | | - pixels[i] <<= 8; |
---|
8390 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8391 | | - pixels[i] <<= 8; |
---|
8392 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8393 | | - pixels[i] <<= 8; |
---|
8394 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8395 | | - } |
---|
8396 | | - |
---|
8397 | | - /* |
---|
8398 | | - int r=0,g=0,b=0,a=0; |
---|
8399 | | - for (int i=0; i<width; i++) |
---|
8400 | | - for (int j=0; j<height; j++) |
---|
8401 | | - { |
---|
8402 | | - int index = j*width+i; |
---|
8403 | | - int p = pixels[index]; |
---|
8404 | | - a = ((p>>24) & 0xFF); |
---|
8405 | | - r = ((p>>16) & 0xFF); |
---|
8406 | | - g = ((p>>8) & 0xFF); |
---|
8407 | | - b = (p & 0xFF); |
---|
8408 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8409 | | - } |
---|
8410 | | - /**/ |
---|
8411 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8412 | | - int height = width; |
---|
8413 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8414 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8557 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8558 | + |
---|
8415 | 8559 | ImageWriter writer = null; |
---|
8416 | 8560 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8417 | 8561 | if (iter.hasNext()) { |
---|
8418 | 8562 | writer = (ImageWriter)iter.next(); |
---|
8419 | 8563 | } |
---|
8420 | | - float compressionQuality = 0.9f; |
---|
| 8564 | + |
---|
| 8565 | + float compressionQuality = 0.85f; |
---|
8421 | 8566 | try |
---|
8422 | 8567 | { |
---|
8423 | 8568 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8434 | 8579 | } |
---|
8435 | 8580 | } |
---|
8436 | 8581 | } |
---|
8437 | | - |
---|
| 8582 | + |
---|
| 8583 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8584 | + |
---|
8438 | 8585 | //System.out.println("Texture = " + tex); |
---|
8439 | | - if (textures.containsKey(texname)) |
---|
| 8586 | + if (textures.containsKey(tex)) |
---|
8440 | 8587 | { |
---|
8441 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8588 | + CacheTexture thetex = textures.get(tex); |
---|
8442 | 8589 | thetex.texture.disable(); |
---|
8443 | 8590 | thetex.texture.dispose(); |
---|
8444 | | - textures.remove(texname); |
---|
| 8591 | + textures.remove(tex); |
---|
8445 | 8592 | } |
---|
8446 | 8593 | |
---|
8447 | | - texture.texturedata = texturedata; |
---|
8448 | | - textures.put(texname, texture); |
---|
| 8594 | + //texture.texturedata = texturedata; |
---|
| 8595 | + textures.put(tex, texturecache); |
---|
8449 | 8596 | |
---|
8450 | 8597 | // newtex = true; |
---|
8451 | 8598 | } |
---|
.. | .. |
---|
8461 | 8608 | } |
---|
8462 | 8609 | } |
---|
8463 | 8610 | |
---|
8464 | | - return texture; |
---|
| 8611 | + return texturecache; |
---|
8465 | 8612 | } |
---|
8466 | 8613 | |
---|
8467 | | - 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 |
---|
8468 | 8651 | { |
---|
8469 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8470 | 8653 | |
---|
.. | .. |
---|
8482 | 8665 | return texture!=null?texture.texture:null; |
---|
8483 | 8666 | } |
---|
8484 | 8667 | |
---|
8485 | | - 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 |
---|
8486 | 8669 | { |
---|
8487 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8488 | 8671 | |
---|
8489 | 8672 | return texture!=null?texture.texturedata:null; |
---|
8490 | 8673 | } |
---|
8491 | 8674 | |
---|
8492 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8493 | 8676 | { |
---|
8494 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8495 | 8678 | { |
---|
8496 | 8679 | return false; |
---|
8497 | 8680 | } |
---|
8498 | 8681 | |
---|
8499 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
8500 | 8683 | |
---|
8501 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8502 | 8685 | |
---|
.. | .. |
---|
8528 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8529 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8530 | 8713 | |
---|
8531 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
8532 | 8715 | } |
---|
8533 | 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 | + |
---|
8534 | 8783 | ShadowBuffer shadowPBuf; |
---|
8535 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8536 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8547 | 8796 | |
---|
8548 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8549 | 8798 | MAXSTACK = temp[0]; |
---|
8550 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8551 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8552 | 8802 | MAXSTACK = temp[0]; |
---|
8553 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8554 | 8805 | |
---|
8555 | 8806 | // Use debug pipeline |
---|
8556 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8558 | 8809 | gl = drawable.getGL(); // |
---|
8559 | 8810 | |
---|
8560 | 8811 | GL gl3 = getGL(); |
---|
8561 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8562 | 8814 | |
---|
8563 | 8815 | |
---|
8564 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8723 | 8975 | |
---|
8724 | 8976 | if (cubemap == null) |
---|
8725 | 8977 | { |
---|
8726 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8727 | 8979 | } |
---|
8728 | 8980 | |
---|
8729 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
8999 | 9251 | |
---|
9000 | 9252 | void LoadEnvy(int which) |
---|
9001 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9002 | 9256 | String name; |
---|
9003 | 9257 | String ext; |
---|
9004 | 9258 | |
---|
.. | .. |
---|
9010 | 9264 | cubemap = null; |
---|
9011 | 9265 | return; |
---|
9012 | 9266 | case 1: |
---|
9013 | | - name = "cubemaps/box_"; |
---|
9014 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9015 | 9269 | reverseUP = false; |
---|
9016 | 9270 | break; |
---|
9017 | 9271 | case 2: |
---|
9018 | | - name = "cubemaps/uffizi_"; |
---|
9019 | | - ext = "png"; |
---|
9020 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9021 | 9276 | case 3: |
---|
9022 | | - name = "cubemaps/CloudyHills_"; |
---|
9023 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9024 | 9279 | reverseUP = false; |
---|
9025 | 9280 | break; |
---|
9026 | 9281 | case 4: |
---|
9027 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9028 | 9283 | ext = "png"; |
---|
9029 | 9284 | reverseUP = false; |
---|
9030 | 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; |
---|
9031 | 9311 | default: |
---|
9032 | | - name = "cubemaps/rgb_"; |
---|
9033 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9034 | 9315 | break; |
---|
9035 | 9316 | } |
---|
9036 | | - |
---|
9037 | | - try |
---|
9038 | | - { |
---|
9039 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9040 | | - } catch (IOException e) |
---|
9041 | | - { |
---|
9042 | | - throw new RuntimeException(e); |
---|
9043 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9044 | 9319 | } |
---|
9045 | 9320 | |
---|
9046 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9072 | 9347 | static double[] model = new double[16]; |
---|
9073 | 9348 | double[] camera2light = new double[16]; |
---|
9074 | 9349 | double[] light2camera = new double[16]; |
---|
9075 | | - int newenvy = -1; |
---|
9076 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9077 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9078 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9079 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9366 | 9645 | jy8[3] = 0.5f; |
---|
9367 | 9646 | } |
---|
9368 | 9647 | |
---|
9369 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9648 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9370 | 9649 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9371 | 9650 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9372 | 9651 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9373 | 9652 | |
---|
| 9653 | + void ResetOptions() |
---|
| 9654 | + { |
---|
| 9655 | + options1[0] = 100; |
---|
| 9656 | + options1[1] = 0.025f; |
---|
| 9657 | + options1[2] = 0.01f; |
---|
| 9658 | + options1[3] = 0; |
---|
| 9659 | + options1[4] = 0; |
---|
| 9660 | + |
---|
| 9661 | + options2[0] = 0; |
---|
| 9662 | + options2[1] = 0.75f; |
---|
| 9663 | + options2[2] = 0; |
---|
| 9664 | + options2[3] = 0; |
---|
| 9665 | + |
---|
| 9666 | + options3[0] = 1; |
---|
| 9667 | + options3[1] = 1; |
---|
| 9668 | + options3[2] = 1; |
---|
| 9669 | + options3[3] = 0; |
---|
| 9670 | + |
---|
| 9671 | + options4[0] = 1; |
---|
| 9672 | + options4[1] = 0; |
---|
| 9673 | + options4[2] = 1; |
---|
| 9674 | + options4[3] = 0; |
---|
| 9675 | + } |
---|
| 9676 | + |
---|
9374 | 9677 | static int imagecount = 0; // movie generation |
---|
9375 | 9678 | |
---|
9376 | 9679 | static int jitter = 0; |
---|
.. | .. |
---|
9467 | 9770 | |
---|
9468 | 9771 | if (renderCamera != lightCamera) |
---|
9469 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9470 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9471 | 9774 | |
---|
9472 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9473 | 9776 | |
---|
.. | .. |
---|
9483 | 9786 | |
---|
9484 | 9787 | if (renderCamera != lightCamera) |
---|
9485 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9486 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9487 | 9790 | |
---|
9488 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9489 | 9792 | |
---|
.. | .. |
---|
9529 | 9832 | rati = 1 / rati; |
---|
9530 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9531 | 9834 | } |
---|
9532 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9533 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9534 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9535 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9536 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9537 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9538 | | - accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
| 9843 | + |
---|
| 9844 | + boolean vr = capsLocked && !lightMode; |
---|
| 9845 | + |
---|
| 9846 | + accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
9539 | 9847 | ratio, |
---|
9540 | 9848 | //near_plane, far_plane, |
---|
9541 | 9849 | renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(), |
---|
.. | .. |
---|
10398 | 10706 | static boolean init = false; |
---|
10399 | 10707 | |
---|
10400 | 10708 | double[][] matrix = LA.newMatrix(); |
---|
| 10709 | + |
---|
| 10710 | + // This is to refresh the UI of the material panel. |
---|
| 10711 | + ObjEditor patchMaterial; |
---|
10401 | 10712 | |
---|
10402 | 10713 | public void display(GLAutoDrawable drawable) |
---|
10403 | 10714 | { |
---|
| 10715 | + if (patchMaterial.patchMaterial) |
---|
| 10716 | + { |
---|
| 10717 | + patchMaterial.patchMaterial = false; |
---|
| 10718 | + patchMaterial.objectTabbedPane.setSelectedIndex(1); |
---|
| 10719 | + } |
---|
| 10720 | + |
---|
10404 | 10721 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10405 | 10722 | { |
---|
10406 | 10723 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10481 | 10798 | ANTIALIAS = 0; |
---|
10482 | 10799 | //System.out.println("RESTART"); |
---|
10483 | 10800 | AAtimer.restart(); |
---|
| 10801 | + Globals.TIMERRUNNING = true; |
---|
10484 | 10802 | } |
---|
10485 | 10803 | } |
---|
10486 | 10804 | } |
---|
.. | .. |
---|
10495 | 10813 | |
---|
10496 | 10814 | if (DrawMode() == DEFAULT) |
---|
10497 | 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 | + |
---|
10498 | 10922 | currentlydrawing = true; |
---|
10499 | 10923 | } |
---|
10500 | 10924 | |
---|
.. | .. |
---|
10568 | 10992 | |
---|
10569 | 10993 | if (wait) |
---|
10570 | 10994 | { |
---|
10571 | | - Sleep(500); |
---|
| 10995 | + Sleep(200); // blocks everything |
---|
10572 | 10996 | |
---|
10573 | 10997 | wait = false; |
---|
10574 | 10998 | } |
---|
.. | .. |
---|
10683 | 11107 | // if (parentcam != renderCamera) // not a light |
---|
10684 | 11108 | if (cam != lightCamera) |
---|
10685 | 11109 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10686 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11110 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10687 | 11111 | |
---|
10688 | 11112 | for (int j = 0; j < 4; j++) |
---|
10689 | 11113 | { |
---|
.. | .. |
---|
10698 | 11122 | // if (parentcam != renderCamera) // not a light |
---|
10699 | 11123 | if (cam != lightCamera) |
---|
10700 | 11124 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10701 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11125 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10702 | 11126 | |
---|
10703 | 11127 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10704 | 11128 | |
---|
.. | .. |
---|
10784 | 11208 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10785 | 11209 | } |
---|
10786 | 11210 | |
---|
10787 | | - 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")) |
---|
10788 | 11219 | { |
---|
10789 | | - LoadEnvy(newenvy); |
---|
| 11220 | + if (cubemaprgb == null) |
---|
| 11221 | + { |
---|
| 11222 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11223 | + } |
---|
| 11224 | + |
---|
| 11225 | + cubemap = cubemaprgb; |
---|
10790 | 11226 | } |
---|
10791 | | - |
---|
10792 | | - newenvy = -1; |
---|
10793 | | - |
---|
| 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 | + |
---|
10794 | 11248 | ratio = ((double) getWidth()) / getHeight(); |
---|
10795 | 11249 | //System.out.println("ratio = " + ratio); |
---|
10796 | 11250 | |
---|
.. | .. |
---|
10806 | 11260 | |
---|
10807 | 11261 | if (!IsFrozen() && !ambientOcclusion) |
---|
10808 | 11262 | { |
---|
10809 | | - DrawSkyBox(gl); |
---|
| 11263 | + DrawSkyBox(gl, (float)ratio); |
---|
10810 | 11264 | } |
---|
10811 | 11265 | |
---|
10812 | 11266 | //if (selection_view == -1) |
---|
.. | .. |
---|
10989 | 11443 | |
---|
10990 | 11444 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10991 | 11445 | |
---|
10992 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10993 | 11446 | //gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11447 | +//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10994 | 11448 | //gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10995 | 11449 | } else |
---|
10996 | 11450 | { |
---|
.. | .. |
---|
11002 | 11456 | //System.out.println("BLENDING ON"); |
---|
11003 | 11457 | gl.glEnable(GL.GL_BLEND); |
---|
11004 | 11458 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11005 | | - |
---|
| 11459 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11006 | 11460 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11007 | 11461 | gl.glLoadIdentity(); |
---|
11008 | 11462 | |
---|
.. | .. |
---|
11052 | 11506 | //gl.glOrtho(-BOOST, BOOST, -BOOST, BOOST, 0.001, 1000); |
---|
11053 | 11507 | } else |
---|
11054 | 11508 | { |
---|
11055 | | - 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()); |
---|
11056 | 11513 | } |
---|
11057 | 11514 | } |
---|
11058 | 11515 | |
---|
.. | .. |
---|
11092 | 11549 | |
---|
11093 | 11550 | // if (cam != lightCamera) |
---|
11094 | 11551 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11095 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11552 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11096 | 11553 | } |
---|
11097 | 11554 | |
---|
11098 | 11555 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11251 | 11708 | } |
---|
11252 | 11709 | } |
---|
11253 | 11710 | |
---|
11254 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11711 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11255 | 11712 | { |
---|
11256 | 11713 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11257 | 11714 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11259 | 11716 | |
---|
11260 | 11717 | boolean texon = textureon; |
---|
11261 | 11718 | |
---|
11262 | | - if (RENDERPROGRAM > 0) |
---|
11263 | | - { |
---|
11264 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11265 | | - textureon = false; |
---|
11266 | | - } |
---|
| 11719 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11720 | + textureon = false; |
---|
| 11721 | + |
---|
11267 | 11722 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11268 | 11723 | //System.out.println("ALLO"); |
---|
11269 | 11724 | gl.glColorMask(false, false, false, false); |
---|
11270 | 11725 | DrawObject(gl); |
---|
11271 | | - if (RENDERPROGRAM > 0) |
---|
11272 | | - { |
---|
11273 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11274 | | - textureon = texon; |
---|
11275 | | - } |
---|
| 11726 | + |
---|
| 11727 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11728 | + textureon = texon; |
---|
| 11729 | + |
---|
11276 | 11730 | gl.glColorMask(true, true, true, true); |
---|
11277 | 11731 | |
---|
11278 | 11732 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11279 | | - //gl.glDepthMask(false); |
---|
| 11733 | + gl.glDepthMask(false); |
---|
11280 | 11734 | } |
---|
11281 | 11735 | |
---|
11282 | 11736 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11411 | 11865 | repaint(); |
---|
11412 | 11866 | } |
---|
11413 | 11867 | |
---|
11414 | | - if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
| 11868 | + if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 |
---|
| 11869 | + { |
---|
| 11870 | + renderCamera.computeTransform(); |
---|
11415 | 11871 | repaint(); |
---|
| 11872 | + } |
---|
11416 | 11873 | |
---|
11417 | 11874 | displaydone = true; |
---|
11418 | 11875 | } |
---|
.. | .. |
---|
11479 | 11936 | |
---|
11480 | 11937 | void DrawObject(GL gl, boolean draw) |
---|
11481 | 11938 | { |
---|
| 11939 | + // To clear camera values |
---|
| 11940 | + ResetOptions(); |
---|
| 11941 | + |
---|
11482 | 11942 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11483 | 11943 | // DrawMode() = SELECTION; |
---|
11484 | 11944 | //GL gl = getGL(); |
---|
11485 | 11945 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11486 | 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 | + } |
---|
11487 | 11961 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11488 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11489 | | - pingthread.StepToTarget(true); // true); |
---|
| 11962 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11963 | + pingthread.StepToTarget(); // true); |
---|
11490 | 11964 | // zoomonce = false; |
---|
11491 | 11965 | } |
---|
11492 | 11966 | |
---|
.. | .. |
---|
11613 | 12087 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11614 | 12088 | |
---|
11615 | 12089 | if (CLEANCACHE) |
---|
11616 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 12090 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11617 | 12091 | { |
---|
11618 | | - String tex = e.nextElement(); |
---|
| 12092 | + cTexture tex = e.nextElement(); |
---|
11619 | 12093 | |
---|
11620 | 12094 | // System.out.println("Texture --------- " + tex); |
---|
11621 | 12095 | |
---|
11622 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 12096 | + if (tex.equals("WHITE_NOISE:")) |
---|
11623 | 12097 | continue; |
---|
11624 | 12098 | |
---|
11625 | | - if (!usedtextures.containsKey(tex)) |
---|
| 12099 | + if (!usedtextures.contains(tex)) |
---|
11626 | 12100 | { |
---|
| 12101 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11627 | 12102 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11628 | | - textures.get(tex).texture.dispose(); |
---|
11629 | | - 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 | + } |
---|
11630 | 12116 | } |
---|
11631 | 12117 | } |
---|
11632 | 12118 | } |
---|
.. | .. |
---|
12046 | 12532 | for (int i = tp.size(); --i >= 0;) |
---|
12047 | 12533 | { |
---|
12048 | 12534 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12049 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12535 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12050 | 12536 | } |
---|
12051 | 12537 | |
---|
12052 | 12538 | |
---|
.. | .. |
---|
12154 | 12640 | |
---|
12155 | 12641 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12156 | 12642 | |
---|
12157 | | - String program = |
---|
| 12643 | + String programmin = |
---|
| 12644 | + // Min shader |
---|
12158 | 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 | + |
---|
12159 | 12719 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12160 | 12720 | "PARAM light2cam0 = program.env[10];" + |
---|
12161 | 12721 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12181 | 12741 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12182 | 12742 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12183 | 12743 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12184 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12744 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12185 | 12745 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12186 | 12746 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12187 | 12747 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12270 | 12830 | "TEMP shininess;" + |
---|
12271 | 12831 | "\n" + |
---|
12272 | 12832 | "MOV texSamp, one;" + |
---|
12273 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12274 | | - |
---|
| 12833 | + |
---|
12275 | 12834 | "MOV mapgrid.x, one2048th.x;" + |
---|
12276 | 12835 | "MOV temp, fragment.texcoord[1];" + |
---|
12277 | 12836 | /* |
---|
.. | .. |
---|
12292 | 12851 | "MUL temp, floor, mapgrid.x;" + |
---|
12293 | 12852 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12294 | 12853 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12295 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12854 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12296 | 12855 | "") + |
---|
12297 | 12856 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12298 | 12857 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12299 | 12858 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12300 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12859 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12301 | 12860 | "") + |
---|
12302 | 12861 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12303 | 12862 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12304 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12863 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12305 | 12864 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12306 | 12865 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12307 | 12866 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12308 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12867 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12309 | 12868 | "") + |
---|
12310 | 12869 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12311 | 12870 | //"MOV params, material;" + |
---|
.. | .. |
---|
12427 | 12986 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12428 | 12987 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12429 | 12988 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12430 | | - "KIL alpha.a;" + |
---|
| 12989 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12431 | 12990 | /* |
---|
12432 | 12991 | "MUL temp.xy, temp, two;" + |
---|
12433 | 12992 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12513 | 13072 | "SUB bump0, bump0, half;" + |
---|
12514 | 13073 | "ADD bump, bump, bump0;" + |
---|
12515 | 13074 | |
---|
12516 | | - "MOV temp.x, texSamp.a;" + |
---|
12517 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12518 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12519 | | - "MOV texSamp.a, temp.x;" + |
---|
12520 | | - |
---|
12521 | 13075 | // double-sided |
---|
12522 | 13076 | /**/ |
---|
12523 | 13077 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12527 | 13081 | "ADD temp.x, temp.x, one.x;" + |
---|
12528 | 13082 | "MUL normal, normal, temp.xxxx;":"" |
---|
12529 | 13083 | ) + |
---|
12530 | | - /**/ |
---|
12531 | | -//// Normalize("normal") + |
---|
12532 | | -//// "MAX normal.z, eps.x, normal.z;" + |
---|
12533 | | -// Normalize("normal") + |
---|
12534 | | - "MOV normald, normal;" + |
---|
12535 | | - "MOV normals, normal;" + |
---|
| 13084 | + /**/ |
---|
| 13085 | + |
---|
| 13086 | + "MOV temp, fragment.texcoord[4];" + |
---|
12536 | 13087 | |
---|
12537 | 13088 | // UV base |
---|
12538 | 13089 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12539 | 13090 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12540 | 13091 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12541 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12542 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12543 | | - "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 | + |
---|
12544 | 13097 | "XPD V, normal, UP;" + |
---|
12545 | 13098 | Normalize("V") + |
---|
12546 | 13099 | "XPD U, V, normal;" + |
---|
12547 | 13100 | Normalize("U") + |
---|
12548 | 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 | + |
---|
12549 | 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;" + |
---|
12550 | 13151 | |
---|
12551 | 13152 | //"MOV temp, fragment.texcoord[0];" + |
---|
12552 | 13153 | // |
---|
.. | .. |
---|
12676 | 13277 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12677 | 13278 | "") + |
---|
12678 | 13279 | |
---|
12679 | | - // display shadow only (bump == 0) |
---|
| 13280 | + // display shadow only (fakedepth == 0) |
---|
12680 | 13281 | "SUB temp.x, half.x, shadow.x;" + |
---|
12681 | 13282 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12682 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13283 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12683 | 13284 | "SUB temp.y, one.x, temp.z;" + |
---|
12684 | 13285 | "MUL temp.x, temp.x, temp.y;" + |
---|
12685 | 13286 | "KIL temp.x;" + |
---|
.. | .. |
---|
13010 | 13611 | //once = true; |
---|
13011 | 13612 | } |
---|
13012 | 13613 | |
---|
13013 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13014 | | - 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 | + |
---|
13015 | 13627 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13016 | 13628 | |
---|
13017 | 13629 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13058 | 13670 | "\n" + |
---|
13059 | 13671 | "END\n"; |
---|
13060 | 13672 | |
---|
13061 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13673 | + if (Globals.DEBUG) |
---|
| 13674 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13062 | 13675 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13063 | 13676 | |
---|
13064 | 13677 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13103 | 13716 | return out; |
---|
13104 | 13717 | } |
---|
13105 | 13718 | |
---|
13106 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13719 | + // Also does frustum culling |
---|
| 13720 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13107 | 13721 | { |
---|
13108 | 13722 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13109 | 13723 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13110 | 13724 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13725 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13726 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13111 | 13727 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13112 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13113 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13114 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13115 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13728 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13729 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13116 | 13730 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13117 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13731 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13118 | 13732 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13119 | 13733 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13120 | 13734 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13121 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13735 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13122 | 13736 | |
---|
13123 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13124 | | - //"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;"; |
---|
13125 | 13739 | } |
---|
13126 | 13740 | |
---|
13127 | 13741 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13168 | 13782 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13169 | 13783 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13170 | 13784 | |
---|
13171 | | - // No shadow when out of frustrum |
---|
| 13785 | + // No shadow when out of frustum |
---|
13172 | 13786 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13173 | 13787 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13174 | 13788 | ""; |
---|
.. | .. |
---|
13315 | 13929 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13316 | 13930 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13317 | 13931 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13318 | | - /*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 |
---|
13319 | 13933 | |
---|
13320 | 13934 | //Object3D.cVector2[] vector2buffer; |
---|
13321 | 13935 | |
---|
.. | .. |
---|
13333 | 13947 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13334 | 13948 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13335 | 13949 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13336 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13337 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13338 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13950 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13951 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13952 | + |
---|
| 13953 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13339 | 13954 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13340 | 13955 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13341 | 13956 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13481 | 14096 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13482 | 14097 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13483 | 14098 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13484 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 14099 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13485 | 14100 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13486 | 14101 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13487 | 14102 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13542 | 14157 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13543 | 14158 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13544 | 14159 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13545 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14160 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13546 | 14161 | "MOV result.texcoord, temp;" + |
---|
13547 | 14162 | // border fade |
---|
13548 | 14163 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13589 | 14204 | |
---|
13590 | 14205 | //"ADD temp.z, temp.z, one;" + |
---|
13591 | 14206 | |
---|
13592 | | - "MOV result.color, temp;" |
---|
| 14207 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14208 | + |
---|
| 14209 | + "MOV result.color, temp;" // Normal |
---|
13593 | 14210 | : "MOV result.color, vertex.color;") + |
---|
13594 | 14211 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13595 | 14212 | : "") + |
---|
.. | .. |
---|
13724 | 14341 | public void mouseClicked(MouseEvent e) |
---|
13725 | 14342 | { |
---|
13726 | 14343 | System.out.println("mouseClicked: " + e); |
---|
| 14344 | + System.exit(0); |
---|
13727 | 14345 | } |
---|
13728 | 14346 | |
---|
13729 | 14347 | public void mousePressed(MouseEvent e) |
---|
13730 | 14348 | { |
---|
| 14349 | + RigidBody.justclicked = true; |
---|
| 14350 | + System.out.println("justclicked: " + e); |
---|
13731 | 14351 | //System.out.println("mousePressed: " + e); |
---|
13732 | 14352 | clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13733 | 14353 | } |
---|
.. | .. |
---|
13762 | 14382 | return; |
---|
13763 | 14383 | } |
---|
13764 | 14384 | |
---|
13765 | | - 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; |
---|
13766 | 14388 | |
---|
13767 | 14389 | // TIMER |
---|
13768 | | - if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14390 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !vr) // VR |
---|
13769 | 14391 | { |
---|
13770 | 14392 | keepboxmode = BOXMODE; |
---|
13771 | 14393 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
13806 | 14428 | //} |
---|
13807 | 14429 | |
---|
13808 | 14430 | SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
13809 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
| 14431 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx()); |
---|
13810 | 14432 | anchorX = ax; |
---|
13811 | 14433 | anchorY = ay; |
---|
13812 | 14434 | prevX = px; |
---|
.. | .. |
---|
13840 | 14462 | else |
---|
13841 | 14463 | if (evt.getSource() == AAtimer) |
---|
13842 | 14464 | { |
---|
| 14465 | + Globals.TIMERRUNNING = false; |
---|
13843 | 14466 | if (mouseDown) |
---|
13844 | 14467 | { |
---|
13845 | 14468 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13899 | 14522 | |
---|
13900 | 14523 | // fev 2014??? |
---|
13901 | 14524 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13902 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13903 | | - pingthread.StepToTarget(true); // true); |
---|
| 14525 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14526 | + pingthread.StepToTarget(); // true); |
---|
13904 | 14527 | } |
---|
| 14528 | + |
---|
13905 | 14529 | // if (!LIVE) |
---|
13906 | 14530 | super.repaint(); |
---|
13907 | 14531 | } |
---|
.. | .. |
---|
13914 | 14538 | return; |
---|
13915 | 14539 | |
---|
13916 | 14540 | AAtimer.restart(); // |
---|
| 14541 | + Globals.TIMERRUNNING = true; |
---|
13917 | 14542 | |
---|
13918 | 14543 | // waslive = LIVE; |
---|
13919 | 14544 | // LIVE = false; |
---|
.. | .. |
---|
13963 | 14588 | drag = false; |
---|
13964 | 14589 | //System.out.println("Mouse DOWN"); |
---|
13965 | 14590 | editObj = false; |
---|
13966 | | - ClickInfo info = new ClickInfo(); |
---|
13967 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13968 | | - info.pane = this; |
---|
13969 | | - info.camera = renderCamera; |
---|
13970 | | - info.x = x; |
---|
13971 | | - info.y = y; |
---|
13972 | | - info.modifiers = modifiersex; |
---|
13973 | | - 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); |
---|
13974 | 14600 | if (!editObj) |
---|
13975 | 14601 | { |
---|
13976 | 14602 | hasMarquee = true; |
---|
.. | .. |
---|
13994 | 14620 | |
---|
13995 | 14621 | //if (drawing) |
---|
13996 | 14622 | //return; |
---|
13997 | | - if ((e.getModifiersEx() & CTRL) != 0 |
---|
13998 | | - || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
| 14623 | + if ((e.getModifiersEx() & CTRL) != 0 || |
---|
| 14624 | + (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13999 | 14625 | { |
---|
14000 | 14626 | //System.out.println("mouseDragged: " + e); |
---|
14001 | 14627 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
.. | .. |
---|
14019 | 14645 | return targetLookAt; |
---|
14020 | 14646 | } |
---|
14021 | 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 | + |
---|
14022 | 14653 | class PingThread extends Thread |
---|
14023 | 14654 | { |
---|
14024 | 14655 | boolean jump; |
---|
| 14656 | + boolean live; |
---|
| 14657 | + |
---|
| 14658 | + boolean mute; |
---|
14025 | 14659 | |
---|
14026 | 14660 | // void JumpToTarget() |
---|
14027 | 14661 | // { |
---|
.. | .. |
---|
14037 | 14671 | // only one thread!? synchronized |
---|
14038 | 14672 | void StepToTarget(boolean jump) |
---|
14039 | 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 | + |
---|
14040 | 14756 | tmp.set(targetLookAt); |
---|
14041 | 14757 | tmp.sub(manipCamera.lookAt); // june 2014 |
---|
14042 | 14758 | |
---|
.. | .. |
---|
14074 | 14790 | |
---|
14075 | 14791 | if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target |
---|
14076 | 14792 | { |
---|
14077 | | - jump = true; // step = 1; |
---|
| 14793 | + // sep 2019 jump = true; // step = 1; |
---|
14078 | 14794 | } |
---|
14079 | 14795 | |
---|
14080 | 14796 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
14109 | 14825 | if (tmp.dot(tmp) < 0.00001) |
---|
14110 | 14826 | { |
---|
14111 | 14827 | zoomonce = false; |
---|
| 14828 | + live = false; |
---|
14112 | 14829 | } |
---|
| 14830 | + else |
---|
| 14831 | + live = true; |
---|
14113 | 14832 | |
---|
14114 | 14833 | tmp.mul(step > step2 ? step : step2); |
---|
14115 | 14834 | } |
---|
.. | .. |
---|
14136 | 14855 | { |
---|
14137 | 14856 | if (LOOKAT) |
---|
14138 | 14857 | manipCamera.lookAt.add(tmp); |
---|
14139 | | - if (OEIL) |
---|
| 14858 | + if (OEIL && !capsLocked) |
---|
14140 | 14859 | manipCamera.location.add(tmp); |
---|
14141 | 14860 | |
---|
14142 | 14861 | { |
---|
.. | .. |
---|
14151 | 14870 | lightCamera.computeTransform(); |
---|
14152 | 14871 | } |
---|
14153 | 14872 | } |
---|
14154 | | - manipCamera.computeTransform(); |
---|
| 14873 | + if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0) |
---|
| 14874 | + { |
---|
| 14875 | + manipCamera.computeTransform(); |
---|
| 14876 | + } |
---|
14155 | 14877 | } |
---|
14156 | 14878 | // ?????? mouseDown = true; |
---|
14157 | 14879 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
.. | .. |
---|
14244 | 14966 | } |
---|
14245 | 14967 | } |
---|
14246 | 14968 | } |
---|
| 14969 | + |
---|
14247 | 14970 | PingThread pingthread = new PingThread(); |
---|
14248 | | - int delta = 5; |
---|
14249 | | - int speed = 5; |
---|
| 14971 | + int delta = 1; |
---|
| 14972 | + int speed = 1; |
---|
| 14973 | + int walk = 8; |
---|
14250 | 14974 | boolean autorepeat = false; |
---|
14251 | 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 | + |
---|
14252 | 14995 | void GoDown(int mod) |
---|
14253 | 14996 | { |
---|
14254 | 14997 | MODIFIERS |= COMMAND; |
---|
14255 | | - /* |
---|
| 14998 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14999 | + /**/ |
---|
14256 | 15000 | if((mod&SHIFT) == SHIFT) |
---|
14257 | | - manipCamera.RotatePosition(0, -speed); |
---|
14258 | | - else |
---|
14259 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14260 | | - */ |
---|
14261 | | - if ((mod & SHIFT) == SHIFT) |
---|
14262 | 15001 | { |
---|
14263 | | - mouseMode = mouseMode; // VR?? |
---|
14264 | | - } else |
---|
14265 | | - { |
---|
14266 | | - 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()); |
---|
14267 | 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 | +// } |
---|
14268 | 15026 | |
---|
| 15027 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15028 | + |
---|
14269 | 15029 | //prevX = X = anchorX; |
---|
14270 | 15030 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14271 | 15031 | } |
---|
14272 | 15032 | |
---|
14273 | 15033 | void GoUp(int mod) |
---|
14274 | 15034 | { |
---|
| 15035 | + RigidBody.justclicked = true; |
---|
| 15036 | + |
---|
14275 | 15037 | MODIFIERS |= COMMAND; |
---|
14276 | | - /* |
---|
| 15038 | + /**/ |
---|
| 15039 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 15040 | + |
---|
14277 | 15041 | if((mod&SHIFT) == SHIFT) |
---|
14278 | | - manipCamera.RotatePosition(0, speed); |
---|
14279 | | - else |
---|
14280 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14281 | | - */ |
---|
14282 | | - if ((mod & SHIFT) == SHIFT) |
---|
14283 | 15042 | { |
---|
14284 | | - mouseMode = mouseMode; |
---|
14285 | | - } else |
---|
14286 | | - { |
---|
14287 | | - 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()); |
---|
14288 | 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 | +// } |
---|
14289 | 15067 | |
---|
| 15068 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15069 | + |
---|
14290 | 15070 | //prevX = X = anchorX; |
---|
14291 | 15071 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14292 | 15072 | } |
---|
.. | .. |
---|
14294 | 15074 | void GoLeft(int mod) |
---|
14295 | 15075 | { |
---|
14296 | 15076 | MODIFIERS |= COMMAND; |
---|
14297 | | - /* |
---|
| 15077 | + /**/ |
---|
14298 | 15078 | if((mod&SHIFT) == SHIFT) |
---|
14299 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 15079 | + manipCamera.Translate(speed, 0, getWidth()); |
---|
14300 | 15080 | else |
---|
14301 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14302 | | - */ |
---|
14303 | | - if ((mod & SHIFT) == SHIFT) |
---|
14304 | 15081 | { |
---|
14305 | | - mouseMode = mouseMode; |
---|
14306 | | - } else |
---|
14307 | | - { |
---|
14308 | | - mouseMode |= ROTATE; |
---|
14309 | | - } // 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; |
---|
14310 | 15096 | |
---|
| 15097 | + //System.err.println("lookAt = " + manipCamera.lookAt); |
---|
| 15098 | + //System.err.println("location = " + manipCamera.location); |
---|
| 15099 | + |
---|
| 15100 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15101 | + |
---|
14311 | 15102 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14312 | 15103 | prevY = Y = anchorY; |
---|
14313 | 15104 | } |
---|
.. | .. |
---|
14315 | 15106 | void GoRight(int mod) |
---|
14316 | 15107 | { |
---|
14317 | 15108 | MODIFIERS |= COMMAND; |
---|
14318 | | - /* |
---|
| 15109 | + /**/ |
---|
14319 | 15110 | if((mod&SHIFT) == SHIFT) |
---|
14320 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 15111 | + manipCamera.Translate(-speed, 0, getWidth()); |
---|
14321 | 15112 | else |
---|
14322 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14323 | | - */ |
---|
14324 | | - if ((mod & SHIFT) == SHIFT) |
---|
14325 | 15113 | { |
---|
14326 | | - mouseMode = mouseMode; |
---|
14327 | | - } else |
---|
14328 | | - { |
---|
14329 | | - mouseMode |= ROTATE; |
---|
14330 | | - } // 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; |
---|
14331 | 15128 | |
---|
| 15129 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15130 | + |
---|
14332 | 15131 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14333 | 15132 | prevY = Y = anchorY; |
---|
14334 | 15133 | } |
---|
.. | .. |
---|
14370 | 15169 | if (editObj) |
---|
14371 | 15170 | { |
---|
14372 | 15171 | drag = true; |
---|
14373 | | - ClickInfo info = new ClickInfo(); |
---|
14374 | | - info.bounds.setBounds(0, 0, |
---|
| 15172 | + //ClickInfo info = new ClickInfo(); |
---|
| 15173 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14375 | 15174 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14376 | | - info.pane = this; |
---|
14377 | | - info.camera = renderCamera; |
---|
14378 | | - info.x = x; |
---|
14379 | | - info.y = y; |
---|
14380 | | - object.GetWindow().copy |
---|
14381 | | - .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); |
---|
14382 | 15182 | } else |
---|
14383 | 15183 | { |
---|
14384 | 15184 | if (x < startX) |
---|
.. | .. |
---|
14461 | 15261 | if ((mouseMode & ZOOM) != 0) |
---|
14462 | 15262 | { |
---|
14463 | 15263 | //if ((mouseMode & BACKFORTH) != 0) |
---|
| 15264 | + if ((modifiersex & SHIFT) == SHIFT) |
---|
| 15265 | + { |
---|
| 15266 | + ViewAngle(dy); |
---|
| 15267 | + } |
---|
| 15268 | + else |
---|
14464 | 15269 | if ((mouseMode & VR) != 0) |
---|
14465 | 15270 | manipCamera.BackForth(dx, dy, getWidth()); |
---|
14466 | 15271 | else |
---|
.. | .. |
---|
14527 | 15332 | } |
---|
14528 | 15333 | } |
---|
14529 | 15334 | |
---|
| 15335 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15336 | + |
---|
14530 | 15337 | public void mouseMoved(MouseEvent e) |
---|
14531 | 15338 | { |
---|
| 15339 | +//object.editWindow.frame. |
---|
| 15340 | + setCursor(Cursor.getDefaultCursor()); |
---|
| 15341 | + |
---|
14532 | 15342 | //System.out.println("mouseMoved: " + e); |
---|
14533 | 15343 | if (isRenderer) |
---|
14534 | 15344 | return; |
---|
14535 | 15345 | |
---|
14536 | | - ClickInfo ci = new ClickInfo(); |
---|
14537 | | - ci.x = e.getX(); |
---|
14538 | | - ci.y = e.getY(); |
---|
14539 | | - ci.modifiers = e.getModifiersEx(); |
---|
14540 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14541 | | - ci.pane = this; |
---|
14542 | | - 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; |
---|
14543 | 15353 | if (!isRenderer) |
---|
14544 | 15354 | { |
---|
14545 | 15355 | //ObjEditor editWindow = object.editWindow; |
---|
14546 | 15356 | //Object3D copy = editWindow.copy; |
---|
14547 | | - if (object.doEditClick(ci, 0)) |
---|
| 15357 | + if (object.doEditClick(//clickInfo, |
---|
| 15358 | + 0)) |
---|
14548 | 15359 | { |
---|
14549 | 15360 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14550 | 15361 | } else |
---|
.. | .. |
---|
14559 | 15370 | Globals.MOUSEDRAGGED = false; |
---|
14560 | 15371 | |
---|
14561 | 15372 | movingcamera = false; |
---|
14562 | | - X = Y = 0; |
---|
| 15373 | + X = 0; // getBounds().width/2; |
---|
| 15374 | + Y = 0; // getBounds().height/2; |
---|
14563 | 15375 | //System.out.println("mouseReleased: " + e); |
---|
14564 | 15376 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14565 | 15377 | } |
---|
.. | .. |
---|
14711 | 15523 | mouseMode |= ZOOM; |
---|
14712 | 15524 | } |
---|
14713 | 15525 | |
---|
14714 | | - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14715 | | - 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) |
---|
14716 | 15530 | { |
---|
14717 | 15531 | mouseMode |= VR; // BACKFORTH; |
---|
14718 | 15532 | } |
---|
.. | .. |
---|
14724 | 15538 | { |
---|
14725 | 15539 | mouseMode |= SELECT; |
---|
14726 | 15540 | } |
---|
14727 | | - if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15541 | + if (//(modifiersex & SHIFT) == SHIFT || |
---|
| 15542 | + forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14728 | 15543 | { |
---|
14729 | 15544 | mouseMode &= ~VR; |
---|
14730 | 15545 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14768 | 15583 | float SATPOW = 1; // 2; // 0.5f; |
---|
14769 | 15584 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
14770 | 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 | + |
---|
14771 | 15592 | public void keyPressed(int key) |
---|
14772 | 15593 | { |
---|
| 15594 | +// Set the blank cursor to the JFrame. |
---|
| 15595 | +//object.editWindow.frame. |
---|
| 15596 | + setCursor(blankCursor); |
---|
| 15597 | + |
---|
14773 | 15598 | if (key >= '0' && key <= '5') |
---|
14774 | 15599 | clampbit = (key-'0'); |
---|
14775 | 15600 | |
---|
.. | .. |
---|
14815 | 15640 | // break; |
---|
14816 | 15641 | case 'T': |
---|
14817 | 15642 | CACHETEXTURE ^= true; |
---|
14818 | | - textures.clear(); |
---|
| 15643 | + texturepigment.clear(); |
---|
| 15644 | + texturebump.clear(); |
---|
14819 | 15645 | // repaint(); |
---|
14820 | 15646 | break; |
---|
14821 | 15647 | case 'Y': |
---|
.. | .. |
---|
14825 | 15651 | case 'K': |
---|
14826 | 15652 | KOMPACTTEXTURE ^= true; |
---|
14827 | 15653 | //textures.clear(); |
---|
14828 | | - break; |
---|
14829 | | - case 'P': // Texture Projection macros |
---|
| 15654 | + // break; |
---|
| 15655 | + //case 'P': // Texture Projection macros |
---|
14830 | 15656 | // SAVETEXTURE ^= true; |
---|
14831 | 15657 | macromode = true; |
---|
14832 | 15658 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
14900 | 15726 | case 'E' : COMPACT ^= true; |
---|
14901 | 15727 | repaint(); |
---|
14902 | 15728 | break; |
---|
14903 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15729 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15730 | + //DEBUGHSB ^= true; |
---|
| 15731 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14904 | 15732 | repaint(); |
---|
14905 | 15733 | break; |
---|
14906 | 15734 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14925 | 15753 | RevertCamera(); |
---|
14926 | 15754 | repaint(); |
---|
14927 | 15755 | break; |
---|
14928 | | - case 'l': |
---|
14929 | | - lightMode ^= true; |
---|
14930 | | - Globals.lighttouched = true; |
---|
14931 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14932 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14933 | | - repaint(); |
---|
14934 | | - break; |
---|
| 15756 | + //case 'l': |
---|
14935 | 15757 | case 'L': |
---|
14936 | 15758 | if (lightMode) |
---|
14937 | 15759 | { |
---|
.. | .. |
---|
14951 | 15773 | targetLookAt.set(manipCamera.lookAt); |
---|
14952 | 15774 | repaint(); |
---|
14953 | 15775 | break; |
---|
14954 | | - case 'p': |
---|
| 15776 | + case 'P': // p': |
---|
14955 | 15777 | // c'est quoi ca au juste? spherical ^= true; |
---|
14956 | 15778 | Skinshader ^= true; programInitialized = false; |
---|
14957 | 15779 | repaint(); |
---|
.. | .. |
---|
14962 | 15784 | break; |
---|
14963 | 15785 | case 'm': |
---|
14964 | 15786 | { |
---|
14965 | | - PrintMemory(); |
---|
| 15787 | + //PrintMemory(); |
---|
| 15788 | + ToggleImageFlip(); |
---|
14966 | 15789 | break; |
---|
14967 | 15790 | } |
---|
14968 | 15791 | case 'M': |
---|
.. | .. |
---|
14989 | 15812 | repaint(); |
---|
14990 | 15813 | break; |
---|
14991 | 15814 | case 'O': |
---|
14992 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
14993 | | - repaint(); |
---|
14994 | | - break; |
---|
| 15815 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15816 | + //repaint(); |
---|
| 15817 | + //break; |
---|
14995 | 15818 | case 'o': |
---|
14996 | 15819 | OCCLUSION_CULLING ^= true; |
---|
14997 | 15820 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14998 | 15821 | break; |
---|
14999 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15822 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15000 | 15823 | case '1': |
---|
15001 | 15824 | case '2': |
---|
15002 | 15825 | case '3': |
---|
15003 | 15826 | case '4': |
---|
15004 | 15827 | case '5': |
---|
15005 | | - newenvy = Character.getNumericValue(key); |
---|
15006 | | - repaint(); |
---|
15007 | | - break; |
---|
15008 | 15828 | case '6': |
---|
15009 | 15829 | case '7': |
---|
15010 | 15830 | case '8': |
---|
15011 | 15831 | case '9': |
---|
15012 | | - 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 | + } |
---|
15013 | 15840 | repaint(); |
---|
15014 | 15841 | break; |
---|
15015 | 15842 | case '!': |
---|
.. | .. |
---|
15075 | 15902 | case '_': |
---|
15076 | 15903 | kompactbit = 5; |
---|
15077 | 15904 | break; |
---|
15078 | | - case '+': |
---|
15079 | | - kompactbit = 6; |
---|
15080 | | - break; |
---|
| 15905 | +// case '+': |
---|
| 15906 | +// kompactbit = 6; |
---|
| 15907 | +// break; |
---|
15081 | 15908 | case ' ': |
---|
15082 | | - 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); |
---|
15083 | 15927 | repaint(); |
---|
15084 | 15928 | break; |
---|
15085 | 15929 | //case '`' : |
---|
15086 | 15930 | case ESC: |
---|
| 15931 | + if (FULLSCREEN) |
---|
| 15932 | + object.editWindow.ToggleFullScreen(); |
---|
| 15933 | + break; |
---|
| 15934 | + case 'p': |
---|
15087 | 15935 | RENDERPROGRAM += 1; |
---|
15088 | 15936 | RENDERPROGRAM %= 3; |
---|
15089 | 15937 | |
---|
.. | .. |
---|
15122 | 15970 | case ENTER: |
---|
15123 | 15971 | // object.editWindow.ScreenFit(); // Edit(); |
---|
15124 | 15972 | ToggleLive(); |
---|
| 15973 | + if (capsLocked) |
---|
| 15974 | + { |
---|
| 15975 | + Globals.WALK ^= true; |
---|
| 15976 | + } |
---|
15125 | 15977 | break; |
---|
15126 | 15978 | case DELETE: |
---|
15127 | 15979 | ClearSelection(); |
---|
15128 | 15980 | break; |
---|
15129 | | - /* |
---|
15130 | 15981 | case '+': |
---|
| 15982 | + |
---|
| 15983 | + /* |
---|
15131 | 15984 | //fontsize += 1; |
---|
15132 | 15985 | bbzoom *= 2; |
---|
15133 | 15986 | repaint(); |
---|
.. | .. |
---|
15144 | 15997 | case '=': |
---|
15145 | 15998 | IncDepth(); |
---|
15146 | 15999 | //fontsize += 1; |
---|
15147 | | - object.editWindow.refreshContents(true); |
---|
| 16000 | + object.GetWindow().refreshContents(true); |
---|
15148 | 16001 | maskbit = 6; |
---|
15149 | 16002 | break; |
---|
15150 | 16003 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15151 | 16004 | DecDepth(); |
---|
15152 | 16005 | maskbit = 5; |
---|
15153 | 16006 | //if(fontsize > 1) fontsize -= 1; |
---|
15154 | | - if (object.editWindow == null) |
---|
15155 | | - new Exception().printStackTrace(); |
---|
15156 | | - else |
---|
15157 | | - object.editWindow.refreshContents(true); |
---|
| 16007 | +// if (object.editWindow == null) |
---|
| 16008 | +// new Exception().printStackTrace(); |
---|
| 16009 | +// else |
---|
| 16010 | + object.GetWindow().refreshContents(true); |
---|
15158 | 16011 | break; |
---|
15159 | 16012 | case '{': |
---|
15160 | | - manipCamera.shaper_fovy /= 1.1; |
---|
| 16013 | + double factor = 1.1; |
---|
| 16014 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16015 | + manipCamera.shaper_fovy /= factor; |
---|
15161 | 16016 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15162 | 16017 | repaint(); |
---|
15163 | 16018 | break; |
---|
15164 | 16019 | case '}': |
---|
15165 | | - manipCamera.shaper_fovy *= 1.1; |
---|
| 16020 | + factor = 1.1; |
---|
| 16021 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16022 | + manipCamera.shaper_fovy *= factor; |
---|
15166 | 16023 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15167 | 16024 | repaint(); |
---|
15168 | 16025 | break; |
---|
15169 | 16026 | case '[': |
---|
15170 | | - manipCamera.shaper_fovy /= 1.01; |
---|
| 16027 | + factor = 1.01; |
---|
| 16028 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16029 | + manipCamera.shaper_fovy /= factor; |
---|
15171 | 16030 | if (false) //manipCamera.hAspect == 0) |
---|
15172 | 16031 | { |
---|
15173 | 16032 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15183 | 16042 | break; |
---|
15184 | 16043 | case ']': |
---|
15185 | 16044 | //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1; |
---|
15186 | | - manipCamera.shaper_fovy *= 1.01; |
---|
| 16045 | + factor = 1.01; |
---|
| 16046 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16047 | + manipCamera.shaper_fovy *= factor; |
---|
15187 | 16048 | if (false) //manipCamera.hAspect == 0) |
---|
15188 | 16049 | { |
---|
15189 | 16050 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15221 | 16082 | } |
---|
15222 | 16083 | } |
---|
15223 | 16084 | |
---|
| 16085 | + boolean keys[] = new boolean[256]; |
---|
| 16086 | + int speedkey[] = new int[256]; |
---|
| 16087 | + int modifiers = 0; |
---|
| 16088 | + |
---|
15224 | 16089 | public void processKeyEvent(KeyEvent e) |
---|
15225 | 16090 | { |
---|
15226 | 16091 | switch (e.getID()) |
---|
15227 | 16092 | { |
---|
15228 | 16093 | case KeyEvent.KEY_PRESSED: |
---|
15229 | | - if (!autorepeat) |
---|
15230 | | - { |
---|
15231 | | - //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); |
---|
15232 | | - keyPressed(e.getKeyChar(), e.getModifiersEx()); |
---|
15233 | | - } |
---|
15234 | | - if (manipCamera == lightCamera) |
---|
15235 | | - { |
---|
15236 | | - switch (e.getKeyCode()) |
---|
15237 | | - { |
---|
15238 | | - case DOWN_ARROW: |
---|
15239 | | - lightCamera.DECAL /= 2; |
---|
15240 | | - repaint(); |
---|
15241 | | - break; |
---|
15242 | | - case UP_ARROW: |
---|
15243 | | - lightCamera.DECAL *= 2; |
---|
15244 | | - repaint(); |
---|
15245 | | - break; |
---|
15246 | | - case LEFT_ARROW: |
---|
15247 | | - lightCamera.SCALE /= 2; |
---|
15248 | | - repaint(); |
---|
15249 | | - break; |
---|
15250 | | - case RIGHT_ARROW: |
---|
15251 | | - lightCamera.SCALE *= 2; |
---|
15252 | | - repaint(); |
---|
15253 | | - break; |
---|
15254 | | - default: |
---|
15255 | | - break; |
---|
15256 | | - } |
---|
15257 | | - |
---|
15258 | | - System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); |
---|
15259 | | - } else |
---|
15260 | | - { |
---|
15261 | | - if (true) // !autorepeat) |
---|
15262 | | - { |
---|
15263 | | - boolean reset = true; |
---|
15264 | | - |
---|
15265 | | - switch (e.getKeyCode()) |
---|
15266 | | - { |
---|
15267 | | - case DOWN_ARROW: |
---|
15268 | | - GoDown(e.getModifiersEx()); |
---|
15269 | | - repaint(); |
---|
15270 | | - break; |
---|
15271 | | - case UP_ARROW: |
---|
15272 | | - GoUp(e.getModifiersEx()); |
---|
15273 | | - repaint(); |
---|
15274 | | - break; |
---|
15275 | | - case LEFT_ARROW: |
---|
15276 | | - GoLeft(e.getModifiersEx()); |
---|
15277 | | - repaint(); |
---|
15278 | | - break; |
---|
15279 | | - case RIGHT_ARROW: |
---|
15280 | | - GoRight(e.getModifiersEx()); |
---|
15281 | | - repaint(); |
---|
15282 | | - break; |
---|
15283 | | - default: |
---|
15284 | | - reset = false; |
---|
15285 | | - break; |
---|
15286 | | - } |
---|
15287 | | - |
---|
15288 | | - if (reset) |
---|
15289 | | - { |
---|
15290 | | - autorepeat = true; |
---|
15291 | | - |
---|
15292 | | - targetLookAt.set(manipCamera.lookAt); |
---|
15293 | | - } |
---|
15294 | | - } |
---|
15295 | | - } |
---|
| 16094 | + keys[e.getKeyCode()] = true; |
---|
| 16095 | + modifiers = e.getModifiersEx(); |
---|
| 16096 | + keyPressed(e.getKeyChar(), modifiers); |
---|
| 16097 | + //Globals.theRenderer.keyPressed(e.getKeyChar()); |
---|
| 16098 | + repaint(); |
---|
15296 | 16099 | break; |
---|
15297 | | - case KeyEvent.KEY_TYPED: |
---|
15298 | | - 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; |
---|
15299 | 16170 | case KeyEvent.KEY_RELEASED: |
---|
15300 | | - { |
---|
15301 | | - switch (e.getKeyCode()) |
---|
15302 | | - { |
---|
15303 | | - case DOWN_ARROW: |
---|
15304 | | - case UP_ARROW: |
---|
15305 | | - case LEFT_ARROW: |
---|
15306 | | - case RIGHT_ARROW: |
---|
15307 | | - MODIFIERS &= ~COMMAND; |
---|
15308 | | - autorepeat = false; |
---|
15309 | | - break; |
---|
15310 | | - default: |
---|
15311 | | - break; |
---|
15312 | | - } |
---|
| 16171 | + keys[e.getKeyCode()] = false; |
---|
| 16172 | + modifiers = e.getModifiersEx(); |
---|
15313 | 16173 | keyReleased(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16174 | + repaint(); |
---|
15314 | 16175 | break; |
---|
15315 | | - } |
---|
| 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 | +// } |
---|
15316 | 16192 | default: |
---|
15317 | 16193 | break; |
---|
15318 | 16194 | } |
---|
.. | .. |
---|
15378 | 16254 | } |
---|
15379 | 16255 | */ |
---|
15380 | 16256 | |
---|
15381 | | - object.editWindow.EditSelection(false); |
---|
| 16257 | + object.GetWindow().EditSelection(false); |
---|
15382 | 16258 | } |
---|
15383 | 16259 | |
---|
15384 | 16260 | void SelectParent() |
---|
.. | .. |
---|
15395 | 16271 | { |
---|
15396 | 16272 | //selectees.remove(i); |
---|
15397 | 16273 | System.out.println("select parent of " + elem); |
---|
15398 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 16274 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15399 | 16275 | } else |
---|
15400 | 16276 | { |
---|
15401 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 16277 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15402 | 16278 | } |
---|
15403 | 16279 | |
---|
15404 | 16280 | first = false; |
---|
.. | .. |
---|
15440 | 16316 | for (int j = 0; j < group.children.size(); j++) |
---|
15441 | 16317 | { |
---|
15442 | 16318 | elem = (Object3D) group.children.elementAt(j); |
---|
15443 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 16319 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15444 | 16320 | first = false; |
---|
15445 | 16321 | } |
---|
15446 | 16322 | } else |
---|
15447 | 16323 | { |
---|
15448 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 16324 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15449 | 16325 | } |
---|
15450 | 16326 | |
---|
15451 | 16327 | first = false; |
---|
.. | .. |
---|
15456 | 16332 | { |
---|
15457 | 16333 | //Composite group = (Composite) object; |
---|
15458 | 16334 | Object3D group = object; |
---|
15459 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 16335 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15460 | 16336 | } |
---|
15461 | 16337 | |
---|
15462 | 16338 | void ResetTransform(int mask) |
---|
15463 | 16339 | { |
---|
15464 | 16340 | //Composite group = (Composite) object; |
---|
15465 | 16341 | Object3D group = object; |
---|
15466 | | - group.editWindow.ResetTransform(mask); |
---|
| 16342 | + group.GetWindow().ResetTransform(mask); |
---|
15467 | 16343 | } |
---|
15468 | 16344 | |
---|
15469 | 16345 | void FlipTransform() |
---|
15470 | 16346 | { |
---|
15471 | 16347 | //Composite group = (Composite) object; |
---|
15472 | 16348 | Object3D group = object; |
---|
15473 | | - group.editWindow.FlipTransform(); |
---|
| 16349 | + group.GetWindow().FlipTransform(); |
---|
15474 | 16350 | // group.editWindow.ReduceMesh(true); |
---|
15475 | 16351 | } |
---|
15476 | 16352 | |
---|
.. | .. |
---|
15478 | 16354 | { |
---|
15479 | 16355 | //Composite group = (Composite) object; |
---|
15480 | 16356 | Object3D group = object; |
---|
15481 | | - group.editWindow.PrintMemory(); |
---|
| 16357 | + group.GetWindow().PrintMemory(); |
---|
15482 | 16358 | // group.editWindow.ReduceMesh(true); |
---|
15483 | 16359 | } |
---|
15484 | 16360 | |
---|
.. | .. |
---|
15486 | 16362 | { |
---|
15487 | 16363 | //Composite group = (Composite) object; |
---|
15488 | 16364 | Object3D group = object; |
---|
15489 | | - group.editWindow.ResetCentroid(); |
---|
| 16365 | + group.GetWindow().ResetCentroid(); |
---|
15490 | 16366 | } |
---|
15491 | 16367 | |
---|
15492 | 16368 | void IncDepth() |
---|
.. | .. |
---|
15568 | 16444 | |
---|
15569 | 16445 | int width = getBounds().width; |
---|
15570 | 16446 | int height = getBounds().height; |
---|
15571 | | - ClickInfo info = new ClickInfo(); |
---|
15572 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15573 | 16447 | //Image img = CreateImage(width, height); |
---|
15574 | 16448 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15575 | 16449 | |
---|
.. | .. |
---|
15646 | 16520 | } |
---|
15647 | 16521 | if (object != null && !hasMarquee) |
---|
15648 | 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 | + |
---|
15649 | 16529 | if (isRenderer) |
---|
15650 | 16530 | { |
---|
15651 | | - info.flags++; |
---|
| 16531 | + object.clickInfo.flags++; |
---|
15652 | 16532 | double frameAspect = (double) width / (double) height; |
---|
15653 | 16533 | if (frameAspect > renderCamera.aspect) |
---|
15654 | 16534 | { |
---|
15655 | 16535 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15656 | | - info.bounds.width -= width - desired; |
---|
15657 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16536 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16537 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15658 | 16538 | } else |
---|
15659 | 16539 | { |
---|
15660 | 16540 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15661 | | - info.bounds.height -= height - desired; |
---|
15662 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16541 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16542 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15663 | 16543 | } |
---|
15664 | 16544 | } |
---|
15665 | | - info.g = gr; |
---|
15666 | | - info.camera = renderCamera; |
---|
| 16545 | + |
---|
| 16546 | + object.clickInfo.g = gr; |
---|
| 16547 | + object.clickInfo.camera = renderCamera; |
---|
15667 | 16548 | /* |
---|
15668 | 16549 | // Memory intensive (brep.verticescopy) |
---|
15669 | 16550 | if (!(object instanceof Composite)) |
---|
15670 | 16551 | object.draw(info, 0, false); // SLOW : |
---|
15671 | 16552 | */ |
---|
15672 | | - if (!isRenderer) |
---|
| 16553 | + if (!isRenderer) // && drag) |
---|
15673 | 16554 | { |
---|
15674 | | - object.drawEditHandles(info, 0); |
---|
15675 | | - |
---|
15676 | | - 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) |
---|
15677 | 16558 | { |
---|
15678 | | - 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) |
---|
15679 | 16565 | { |
---|
15680 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15681 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15682 | | - break; |
---|
15683 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15684 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15685 | | - break; |
---|
15686 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15687 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15688 | | - 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; |
---|
15689 | 16573 | } |
---|
15690 | | - |
---|
| 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 | + } |
---|
15691 | 16594 | } |
---|
15692 | 16595 | } |
---|
15693 | 16596 | } |
---|
.. | .. |
---|
15702 | 16605 | if (hasMarquee) |
---|
15703 | 16606 | { |
---|
15704 | 16607 | gr.setXORMode(Color.white); |
---|
15705 | | - gr.setColor(Color.red); |
---|
| 16608 | + gr.setColor(Color.white); |
---|
15706 | 16609 | if (!firstime) |
---|
15707 | 16610 | { |
---|
15708 | 16611 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
15861 | 16764 | |
---|
15862 | 16765 | public boolean mouseDrag(Event evt, int x, int y) |
---|
15863 | 16766 | { |
---|
15864 | | - //System.out.println("mouseDrag: " + evt); |
---|
| 16767 | + System.out.println("mouseDrag: " + evt); |
---|
| 16768 | + System.exit(0); |
---|
15865 | 16769 | /* |
---|
15866 | 16770 | drag = true; |
---|
15867 | 16771 | //System.out.println("Mouse DRAG"); |
---|
.. | .. |
---|
15980 | 16884 | public boolean mouseUp(Event evt, int x, int y) |
---|
15981 | 16885 | { |
---|
15982 | 16886 | System.out.println("mouseUp: " + evt); |
---|
| 16887 | + System.exit(0); |
---|
15983 | 16888 | /* |
---|
15984 | 16889 | locked = false; |
---|
15985 | 16890 | if (isRenderer) |
---|
.. | .. |
---|
16169 | 17074 | private /*static*/ boolean firstime; |
---|
16170 | 17075 | private /*static*/ cVector newView = new cVector(); |
---|
16171 | 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"}; |
---|
16172 | 17079 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16173 | 17080 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16174 | 17081 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16181 | 17088 | { |
---|
16182 | 17089 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16183 | 17090 | |
---|
| 17091 | + int usedsuf = 0; |
---|
| 17092 | + |
---|
16184 | 17093 | for (int i = 0; i < suffixes.length; i++) |
---|
16185 | 17094 | { |
---|
16186 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16187 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16188 | | - mipmapped, |
---|
16189 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16190 | | - if (data == null) |
---|
| 17095 | + String[] suffixe = suffixes; |
---|
| 17096 | + String[] fallback = suffixes2; |
---|
| 17097 | + String[] fallfallback = suffixes3; |
---|
| 17098 | + |
---|
| 17099 | + for (int c=usedsuf; --c>=0;) |
---|
16191 | 17100 | { |
---|
16192 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 17101 | +// String[] temp = suffixe; |
---|
| 17102 | +// suffixe = fallback; |
---|
| 17103 | +// fallback = fallfallback; |
---|
| 17104 | +// fallfallback = temp; |
---|
16193 | 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 | + |
---|
16194 | 17134 | //System.out.println("Target = " + targets[i]); |
---|
16195 | 17135 | cubemap.updateImage(data, targets[i]); |
---|
16196 | 17136 | } |
---|
16197 | 17137 | |
---|
16198 | 17138 | return cubemap; |
---|
16199 | 17139 | } |
---|
| 17140 | + |
---|
16200 | 17141 | int bigsphere = -1; |
---|
16201 | 17142 | |
---|
16202 | 17143 | float BGcolor = 0.5f; |
---|
16203 | 17144 | |
---|
16204 | | - private void DrawSkyBox(GL gl) |
---|
| 17145 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 17146 | + |
---|
| 17147 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16205 | 17148 | { |
---|
16206 | | - if (envyoff || cubemap == null) |
---|
| 17149 | + if (//envyoff || |
---|
| 17150 | + WIREFRAME || |
---|
| 17151 | + cubemap == null) |
---|
16207 | 17152 | { |
---|
16208 | 17153 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16209 | 17154 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16218 | 17163 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16219 | 17164 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16220 | 17165 | gl.glLoadIdentity(); |
---|
| 17166 | + gl.glScalef(1,ratio,1); |
---|
16221 | 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 | + |
---|
16222 | 17177 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16223 | 17178 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16224 | 17179 | |
---|
.. | .. |
---|
16250 | 17205 | { |
---|
16251 | 17206 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16252 | 17207 | } |
---|
| 17208 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16253 | 17209 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16254 | 17210 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16255 | 17211 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16290 | 17246 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16291 | 17247 | |
---|
16292 | 17248 | cubemap.disable(); |
---|
16293 | | - ////cubemap.unbind(); |
---|
| 17249 | + //cubemap.dispose(); |
---|
| 17250 | + |
---|
16294 | 17251 | if (CULLFACE) |
---|
16295 | 17252 | { |
---|
16296 | 17253 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16346 | 17303 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16347 | 17304 | } |
---|
16348 | 17305 | |
---|
16349 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 17306 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16350 | 17307 | |
---|
16351 | 17308 | float step = 2; // 0.1666f; //0.25f; |
---|
16352 | 17309 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16485 | 17442 | } |
---|
16486 | 17443 | } |
---|
16487 | 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 | + |
---|
16488 | 17453 | class SelectBuffer implements GLEventListener |
---|
16489 | 17454 | { |
---|
16490 | 17455 | |
---|
.. | .. |
---|
16500 | 17465 | //new Exception().printStackTrace(); |
---|
16501 | 17466 | System.out.println("select buffer init"); |
---|
16502 | 17467 | // Use debug pipeline |
---|
16503 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17468 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16504 | 17469 | |
---|
16505 | 17470 | GL gl = drawable.getGL(); |
---|
16506 | 17471 | |
---|
.. | .. |
---|
16564 | 17529 | |
---|
16565 | 17530 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16566 | 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 | + |
---|
16567 | 17543 | //int tmp = selection_view; |
---|
16568 | 17544 | //selection_view = -1; |
---|
16569 | 17545 | int temp = DrawMode(); |
---|
.. | .. |
---|
16575 | 17551 | // temp = DEFAULT; // patch for selection debug |
---|
16576 | 17552 | Globals.drawMode = temp; // WARNING |
---|
16577 | 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 | + |
---|
16578 | 17565 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16579 | 17566 | |
---|
16580 | 17567 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16605 | 17592 | |
---|
16606 | 17593 | float depth = depths[y * TEX_SIZE + x]; |
---|
16607 | 17594 | |
---|
16608 | | - if (pointselection && mouseMode == SELECT && depth != 0 && depth != 1) |
---|
| 17595 | + if (pointselection && (mouseMode & SELECT) == SELECT && depth != 0 && depth != 1) |
---|
16609 | 17596 | { |
---|
16610 | 17597 | pointselection = false; |
---|
16611 | 17598 | |
---|
.. | .. |
---|
16678 | 17665 | } |
---|
16679 | 17666 | |
---|
16680 | 17667 | if (!movingcamera && !PAINTMODE) |
---|
16681 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17668 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16682 | 17669 | |
---|
16683 | | - 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) |
---|
16684 | 17671 | { |
---|
16685 | | - 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); |
---|
16686 | 17673 | |
---|
16687 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17674 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17675 | + { |
---|
| 17676 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16688 | 17677 | |
---|
16689 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16690 | | - |
---|
16691 | | - group.add(paintobj); // link |
---|
16692 | | - |
---|
16693 | | - object.editWindow.SnapObject(group); |
---|
16694 | | - |
---|
16695 | | - Object3D folder = object.editWindow.copy; |
---|
16696 | | - |
---|
16697 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16698 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16699 | | - |
---|
16700 | | - folder.add(group); |
---|
16701 | | - |
---|
16702 | | - object.editWindow.ResetModel(); |
---|
16703 | | - 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 | + } |
---|
16704 | 17693 | } |
---|
16705 | 17694 | else |
---|
16706 | 17695 | paintcount = 0; |
---|
.. | .. |
---|
16739 | 17728 | //System.out.println("objects[color] = " + objects[color]); |
---|
16740 | 17729 | //objects[color].Select(); |
---|
16741 | 17730 | indexcount = 0; |
---|
| 17731 | + ObjEditor window = object.GetWindow(); |
---|
| 17732 | + if (window != null && deselect) |
---|
| 17733 | + { |
---|
| 17734 | + window.Select(null, deselect, true); |
---|
| 17735 | + } |
---|
16742 | 17736 | object.Select(color, deselect); |
---|
16743 | 17737 | } |
---|
16744 | 17738 | |
---|
.. | .. |
---|
16789 | 17783 | |
---|
16790 | 17784 | public void init(GLAutoDrawable drawable) |
---|
16791 | 17785 | { |
---|
| 17786 | + if (Globals.DEBUG) |
---|
16792 | 17787 | System.out.println("shadow buffer init"); |
---|
16793 | 17788 | |
---|
16794 | 17789 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17017 | 18012 | gl.glFlush(); |
---|
17018 | 18013 | |
---|
17019 | 18014 | /**/ |
---|
17020 | | - 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); |
---|
17021 | 18016 | |
---|
17022 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 18017 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17023 | 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 | + |
---|
17024 | 18023 | double r = 0, g = 0, b = 0; |
---|
17025 | 18024 | |
---|
17026 | 18025 | double count = 0; |
---|
.. | .. |
---|
17031 | 18030 | |
---|
17032 | 18031 | double FACTOR = 1; |
---|
17033 | 18032 | |
---|
17034 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 18033 | + for (int i = 0; i < depths.length; i++) |
---|
17035 | 18034 | { |
---|
17036 | 18035 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17037 | 18036 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17114 | 18113 | |
---|
17115 | 18114 | double scale = ray.z; // 1; // cos |
---|
17116 | 18115 | |
---|
17117 | | - float depth = pixels[newindex]; |
---|
| 18116 | + float depth = depths[newindex]; |
---|
17118 | 18117 | |
---|
17119 | 18118 | /* |
---|
17120 | 18119 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17257 | 18256 | static boolean DEBUG_SELECTION = false; |
---|
17258 | 18257 | boolean OCCLUSION_CULLING = false; //true; |
---|
17259 | 18258 | public boolean lightMode = false; |
---|
| 18259 | + |
---|
| 18260 | + private boolean keepshadow; |
---|
| 18261 | + |
---|
| 18262 | + static public boolean capsLocked = false; // VR |
---|
| 18263 | + |
---|
17260 | 18264 | static public int indexcount = 0; |
---|
17261 | 18265 | /*static*/ cColor vertexOcclusion = new cColor(); |
---|
17262 | 18266 | //private int selection_view = -1; |
---|
.. | .. |
---|
17311 | 18315 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17312 | 18316 | static IntBuffer bigAAbuffer; |
---|
17313 | 18317 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17314 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 18318 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17315 | 18319 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17316 | 18320 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17317 | 18321 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17318 | | - 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 | + |
---|
17319 | 18326 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17320 | 18327 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17321 | 18328 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|