.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
37 | 41 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 42 | static int materialdepth = 0; |
---|
39 | 43 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 45 | |
---|
43 | 46 | // camera change fix |
---|
.. | .. |
---|
45 | 48 | static boolean ABORTED = false; |
---|
46 | 49 | |
---|
47 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
48 | 84 | |
---|
49 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
61 | 97 | //boolean REDUCETEXTURE = true; |
---|
62 | 98 | boolean CACHETEXTURE = true; |
---|
63 | 99 | boolean CLEANCACHE = false; // true; |
---|
64 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
65 | 101 | boolean COMPRESSTEXTURE = false; |
---|
66 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
67 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
74 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
75 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
76 | 112 | static GLContext glcontext = null; |
---|
77 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 113 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
78 | 118 | boolean reverseUP = false; |
---|
79 | 119 | static boolean frozen = false; |
---|
80 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
128 | 168 | |
---|
129 | 169 | |
---|
130 | 170 | // OPTIONS |
---|
131 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
132 | 172 | boolean cameraLight = false; |
---|
133 | 173 | boolean UVdebug = false; |
---|
134 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
137 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
138 | 178 | boolean anisotropy = true; |
---|
139 | 179 | boolean softshadow = true; // slower but better false; |
---|
140 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
141 | 181 | |
---|
142 | 182 | boolean macromode = false; |
---|
143 | 183 | |
---|
.. | .. |
---|
151 | 191 | } |
---|
152 | 192 | |
---|
153 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 194 | + |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 196 | + { |
---|
| 197 | + try |
---|
| 198 | + { |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 200 | + } catch (IOException e) |
---|
| 201 | + { |
---|
| 202 | + System.out.println("NAME = " + name); |
---|
| 203 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
| 205 | + } |
---|
| 206 | + } |
---|
154 | 207 | |
---|
155 | 208 | void SetAsGLRenderer(boolean b) |
---|
156 | 209 | { |
---|
.. | .. |
---|
170 | 223 | |
---|
171 | 224 | SetCamera(cam); |
---|
172 | 225 | |
---|
173 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
174 | 228 | |
---|
175 | 229 | object = o; |
---|
176 | 230 | |
---|
.. | .. |
---|
327 | 381 | cStatic.objectstack[materialdepth++] = obj; |
---|
328 | 382 | //System.out.println("material " + material); |
---|
329 | 383 | //Applet3D.tracein(this, selected); |
---|
330 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 384 | + //display.vector2buffer = obj.projectedVertices; |
---|
331 | 385 | if (obj instanceof Camera) |
---|
332 | 386 | { |
---|
333 | 387 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
336 | 390 | display.options1[2] = material.shadowbias; |
---|
337 | 391 | display.options1[3] = material.aniso; |
---|
338 | 392 | display.options1[4] = material.anisoV; |
---|
| 393 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 394 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 395 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 396 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 397 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
339 | 398 | display.options2[0] = material.opacity; |
---|
340 | 399 | display.options2[1] = material.diffuse; |
---|
341 | 400 | display.options2[2] = material.factor; |
---|
| 401 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 402 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 403 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
342 | 404 | |
---|
343 | 405 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 406 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 407 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 408 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
344 | 409 | display.options4[0] = material.cameralight/0.2f; |
---|
345 | 410 | display.options4[1] = material.subsurface; |
---|
346 | 411 | display.options4[2] = material.sheen; |
---|
| 412 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 413 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 414 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
347 | 415 | |
---|
348 | 416 | // if (display.CURRENTANTIALIAS > 0) |
---|
349 | 417 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
359 | 427 | /**/ |
---|
360 | 428 | } else |
---|
361 | 429 | { |
---|
362 | | - DrawMaterial(material, selected); |
---|
| 430 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
363 | 431 | } |
---|
364 | 432 | } else |
---|
365 | 433 | { |
---|
.. | .. |
---|
383 | 451 | cStatic.objectstack[materialdepth++] = obj; |
---|
384 | 452 | //System.out.println("material " + material); |
---|
385 | 453 | //Applet3D.tracein("selected ", selected); |
---|
386 | | - display.vector2buffer = obj.projectedVertices; |
---|
387 | | - display.DrawMaterial(material, selected); |
---|
| 454 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 455 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
388 | 456 | } |
---|
389 | 457 | } |
---|
390 | 458 | |
---|
.. | .. |
---|
401 | 469 | materialdepth -= 1; |
---|
402 | 470 | if (materialdepth > 0) |
---|
403 | 471 | { |
---|
404 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
405 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 472 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 473 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
406 | 474 | } |
---|
407 | 475 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
408 | 476 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
422 | 490 | materialdepth -= 1; |
---|
423 | 491 | if (materialdepth > 0) |
---|
424 | 492 | { |
---|
425 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
426 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 493 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 494 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
427 | 495 | } |
---|
428 | 496 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
429 | 497 | //else |
---|
.. | .. |
---|
464 | 532 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
465 | 533 | { |
---|
466 | 534 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
467 | | - boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 535 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 536 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 537 | + ; |
---|
468 | 538 | if (!hasnorm) |
---|
469 | 539 | { |
---|
470 | | - // System.out.println("FUCK!!"); |
---|
| 540 | + // System.out.println("Mesh normal"); |
---|
471 | 541 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
472 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
473 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
474 | 544 | LA.vecNormalize(obj.v2); |
---|
475 | | - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 545 | + |
---|
| 546 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
476 | 547 | } |
---|
477 | 548 | |
---|
478 | 549 | // P |
---|
.. | .. |
---|
494 | 565 | y += ny * obj.NORMALPUSH; |
---|
495 | 566 | z += nz * obj.NORMALPUSH; |
---|
496 | 567 | |
---|
497 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
498 | 569 | } |
---|
499 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
500 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
526 | 597 | y += ny * obj.NORMALPUSH; |
---|
527 | 598 | z += nz * obj.NORMALPUSH; |
---|
528 | 599 | |
---|
529 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
530 | 601 | } |
---|
531 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
532 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
574 | 645 | y += ny * obj.NORMALPUSH; |
---|
575 | 646 | z += nz * obj.NORMALPUSH; |
---|
576 | 647 | |
---|
577 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
578 | 649 | } |
---|
579 | 650 | |
---|
580 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
1180 | 1251 | { |
---|
1181 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1182 | 1253 | { |
---|
1183 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1184 | 1255 | } else |
---|
1185 | 1256 | { |
---|
1186 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1187 | 1258 | } |
---|
1188 | 1259 | |
---|
1189 | 1260 | if (c != null) |
---|
.. | .. |
---|
1192 | 1263 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1193 | 1264 | } |
---|
1194 | 1265 | } |
---|
| 1266 | + |
---|
1195 | 1267 | if (flipV) |
---|
1196 | 1268 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1197 | 1269 | else |
---|
1198 | 1270 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1271 | + |
---|
1199 | 1272 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1200 | 1273 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1201 | 1274 | |
---|
.. | .. |
---|
1205 | 1278 | { |
---|
1206 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1207 | 1280 | { |
---|
1208 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1209 | 1282 | } else |
---|
1210 | 1283 | { |
---|
1211 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1212 | 1285 | } |
---|
1213 | 1286 | if (c != null) |
---|
1214 | 1287 | { |
---|
1215 | 1288 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1216 | 1289 | } |
---|
1217 | 1290 | } |
---|
| 1291 | + |
---|
1218 | 1292 | if (flipV) |
---|
1219 | 1293 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1220 | 1294 | else |
---|
1221 | 1295 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1296 | + |
---|
1222 | 1297 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1223 | 1298 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1224 | 1299 | |
---|
.. | .. |
---|
1231 | 1306 | { |
---|
1232 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1233 | 1308 | { |
---|
1234 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1235 | 1310 | } else |
---|
1236 | 1311 | { |
---|
1237 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1238 | 1313 | } |
---|
1239 | 1314 | if (c != null) |
---|
1240 | 1315 | { |
---|
.. | .. |
---|
1246 | 1321 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1247 | 1322 | else |
---|
1248 | 1323 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1324 | + |
---|
1249 | 1325 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1250 | 1326 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1327 | + |
---|
1251 | 1328 | count2 += 2; |
---|
1252 | 1329 | count3 += 3; |
---|
1253 | 1330 | } |
---|
.. | .. |
---|
1414 | 1491 | { |
---|
1415 | 1492 | if (!selectmode) |
---|
1416 | 1493 | { |
---|
1417 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1494 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
1418 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1419 | 1496 | |
---|
1420 | 1497 | if (flipV) |
---|
.. | .. |
---|
1426 | 1503 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1427 | 1504 | } |
---|
1428 | 1505 | |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
1429 | 1508 | void SetColor(Object3D obj, Vertex p0) |
---|
1430 | 1509 | { |
---|
1431 | 1510 | CameraPane display = this; |
---|
.. | .. |
---|
1493 | 1572 | { |
---|
1494 | 1573 | return; |
---|
1495 | 1574 | } |
---|
1496 | | - |
---|
1497 | | - float[] colorV = new float[3]; |
---|
1498 | 1575 | |
---|
1499 | 1576 | if (false) // marked) |
---|
1500 | 1577 | { |
---|
.. | .. |
---|
1603 | 1680 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1604 | 1681 | } |
---|
1605 | 1682 | |
---|
1606 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1683 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1607 | 1684 | { |
---|
1608 | 1685 | CameraPane display = this; |
---|
1609 | 1686 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1638 | 1715 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1639 | 1716 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1640 | 1717 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1641 | | - colorV[3] = material.opacity; |
---|
| 1718 | + colorV[3] = 1; // material.opacity; |
---|
1642 | 1719 | |
---|
1643 | 1720 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1644 | 1721 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1743 | 1820 | |
---|
1744 | 1821 | display.modelParams7[0] = 0; |
---|
1745 | 1822 | display.modelParams7[1] = 1000; |
---|
1746 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1747 | 1824 | display.modelParams7[3] = 0; |
---|
1748 | 1825 | |
---|
1749 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1826 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1750 | 1827 | |
---|
1751 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1828 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1752 | 1829 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1753 | 1830 | { |
---|
1754 | 1831 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1976 | 2053 | switch(viewcode) |
---|
1977 | 2054 | { |
---|
1978 | 2055 | case 0: return "main"; |
---|
1979 | | - case 1: return "one"; |
---|
1980 | | - case 2: return "two"; |
---|
1981 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
1982 | 2059 | case 4: return "light"; |
---|
1983 | 2060 | } |
---|
1984 | 2061 | |
---|
.. | .. |
---|
2044 | 2121 | //System.err.println("Oeil on"); |
---|
2045 | 2122 | OEIL = true; |
---|
2046 | 2123 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2047 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2124 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2048 | 2125 | //pingthread.StepToTarget(true); |
---|
2049 | 2126 | } |
---|
2050 | 2127 | |
---|
.. | .. |
---|
2259 | 2336 | |
---|
2260 | 2337 | void ToggleDebug() |
---|
2261 | 2338 | { |
---|
2262 | | - DEBUG ^= true; |
---|
| 2339 | + Globals.DEBUG ^= true; |
---|
2263 | 2340 | } |
---|
2264 | 2341 | |
---|
2265 | 2342 | void ToggleLookAt() |
---|
.. | .. |
---|
2277 | 2354 | HANDLES ^= true; |
---|
2278 | 2355 | } |
---|
2279 | 2356 | |
---|
| 2357 | + Object3D paintFolder; |
---|
| 2358 | + |
---|
2280 | 2359 | void TogglePaint() |
---|
2281 | 2360 | { |
---|
2282 | 2361 | PAINTMODE ^= true; |
---|
2283 | 2362 | paintcount = 0; |
---|
| 2363 | + |
---|
| 2364 | + if (PAINTMODE) |
---|
| 2365 | + { |
---|
| 2366 | + paintFolder = GetFolder(); |
---|
| 2367 | + } |
---|
2284 | 2368 | } |
---|
2285 | 2369 | |
---|
2286 | 2370 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2377 | 2461 | return currentGL; |
---|
2378 | 2462 | } |
---|
2379 | 2463 | |
---|
| 2464 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2465 | + { |
---|
| 2466 | + Grafreed.Assert(texturedata != null); |
---|
| 2467 | + |
---|
| 2468 | + int width = texturedata.getWidth(); |
---|
| 2469 | + int height = texturedata.getHeight(); |
---|
| 2470 | + |
---|
| 2471 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2472 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2473 | + |
---|
| 2474 | + byte[] bytes = bytebuf.array(); |
---|
| 2475 | + |
---|
| 2476 | + return CreateBim(bytes, width, height); |
---|
| 2477 | + } |
---|
| 2478 | + |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2482 | + |
---|
| 2483 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2484 | + // Ground or ceiling |
---|
| 2485 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2486 | + else |
---|
| 2487 | + // Walls |
---|
| 2488 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2380 | 2491 | /**/ |
---|
2381 | 2492 | class CacheTexture |
---|
2382 | 2493 | { |
---|
.. | .. |
---|
2385 | 2496 | |
---|
2386 | 2497 | int resolution; |
---|
2387 | 2498 | |
---|
2388 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2499 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2389 | 2500 | { |
---|
2390 | | - texture = tex; |
---|
| 2501 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2502 | + texturedata = texdata; |
---|
2391 | 2503 | resolution = res; |
---|
2392 | 2504 | } |
---|
2393 | 2505 | } |
---|
2394 | 2506 | /**/ |
---|
2395 | 2507 | |
---|
2396 | 2508 | // TEXTURE static Texture texture; |
---|
2397 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2398 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2399 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2509 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2510 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2511 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2512 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2513 | + |
---|
2400 | 2514 | int pigmentdepth = 0; |
---|
2401 | 2515 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2516 | int bumpdepth = 0; |
---|
2403 | 2517 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2404 | 2518 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2405 | 2519 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2406 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2520 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2407 | 2521 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2408 | 2522 | |
---|
2409 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2523 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2410 | 2524 | { |
---|
2411 | 2525 | TextureData texturedata = null; |
---|
2412 | 2526 | |
---|
.. | .. |
---|
2416 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2417 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2418 | 2532 | true, |
---|
2419 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2420 | 2534 | } catch (java.io.IOException e) |
---|
2421 | 2535 | { |
---|
2422 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2425 | 2539 | if (bump) |
---|
2426 | 2540 | texturedata = ConvertBump(texturedata, false); |
---|
2427 | 2541 | |
---|
2428 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2429 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2542 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2543 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2430 | 2544 | |
---|
2431 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2432 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2545 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2546 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2433 | 2547 | |
---|
2434 | | - return texture; |
---|
| 2548 | + return texturedata; |
---|
| 2549 | + } |
---|
| 2550 | + |
---|
| 2551 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2552 | + { |
---|
| 2553 | + TextureData texturedata = null; |
---|
| 2554 | + |
---|
| 2555 | + try |
---|
| 2556 | + { |
---|
| 2557 | + texturedata = |
---|
| 2558 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2559 | + bim, |
---|
| 2560 | + true); |
---|
| 2561 | + } catch (Exception e) |
---|
| 2562 | + { |
---|
| 2563 | + throw new javax.media.opengl.GLException(e); |
---|
| 2564 | + } |
---|
| 2565 | + |
---|
| 2566 | + if (bump) |
---|
| 2567 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2568 | + |
---|
| 2569 | + return texturedata; |
---|
2435 | 2570 | } |
---|
2436 | 2571 | |
---|
2437 | 2572 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3504 | 3639 | |
---|
3505 | 3640 | System.out.println("LOADING TEXTURE : " + name); |
---|
3506 | 3641 | |
---|
| 3642 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3643 | + |
---|
3507 | 3644 | // |
---|
3508 | 3645 | if (false) // compressbit > 0) |
---|
3509 | 3646 | { |
---|
.. | .. |
---|
7902 | 8039 | String pigment = Object3D.GetPigment(tex); |
---|
7903 | 8040 | String bump = Object3D.GetBump(tex); |
---|
7904 | 8041 | |
---|
7905 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7906 | 8043 | { |
---|
7907 | 8044 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7908 | 8045 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7917 | 8054 | pigment = null; |
---|
7918 | 8055 | } |
---|
7919 | 8056 | |
---|
7920 | | - ReleaseTexture(bump, true); |
---|
7921 | | - ReleaseTexture(pigment, false); |
---|
| 8057 | + ReleaseTexture(tex, true); |
---|
| 8058 | + ReleaseTexture(tex, false); |
---|
7922 | 8059 | } |
---|
7923 | 8060 | |
---|
7924 | 8061 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7936 | 8073 | |
---|
7937 | 8074 | String pigment = Object3D.GetPigment(tex); |
---|
7938 | 8075 | |
---|
7939 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8076 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7940 | 8077 | { |
---|
7941 | 8078 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7942 | 8079 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7947 | 8084 | pigment = null; |
---|
7948 | 8085 | } |
---|
7949 | 8086 | |
---|
7950 | | - ReleaseTexture(pigment, false); |
---|
| 8087 | + ReleaseTexture(tex, false); |
---|
7951 | 8088 | } |
---|
7952 | 8089 | |
---|
7953 | 8090 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7965 | 8102 | |
---|
7966 | 8103 | String bump = Object3D.GetBump(tex); |
---|
7967 | 8104 | |
---|
7968 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8105 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7969 | 8106 | { |
---|
7970 | 8107 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7971 | 8108 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7976 | 8113 | bump = null; |
---|
7977 | 8114 | } |
---|
7978 | 8115 | |
---|
7979 | | - ReleaseTexture(bump, true); |
---|
| 8116 | + ReleaseTexture(tex, true); |
---|
7980 | 8117 | } |
---|
7981 | 8118 | |
---|
7982 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8119 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7983 | 8120 | { |
---|
7984 | 8121 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7985 | 8122 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7990 | 8127 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7991 | 8128 | |
---|
7992 | 8129 | if (tex != null) |
---|
7993 | | - texture = textures.get(tex); |
---|
| 8130 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7994 | 8131 | |
---|
7995 | 8132 | // //assert( texture != null ); |
---|
7996 | 8133 | // if (texture == null) |
---|
.. | .. |
---|
8084 | 8221 | |
---|
8085 | 8222 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8086 | 8223 | { |
---|
8087 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8088 | | - ambientOcclusion ) // || !textureon) |
---|
8089 | | - { |
---|
8090 | | - return; // false; |
---|
8091 | | - } |
---|
8092 | | - |
---|
8093 | | - if (tex == null) |
---|
8094 | | - { |
---|
8095 | | - BindTexture(null,false,resolution); |
---|
8096 | | - BindTexture(null,true,resolution); |
---|
8097 | | - return; |
---|
8098 | | - } |
---|
| 8224 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8225 | +// ambientOcclusion ) // || !textureon) |
---|
| 8226 | +// { |
---|
| 8227 | +// return; // false; |
---|
| 8228 | +// } |
---|
| 8229 | +// |
---|
| 8230 | +// if (tex == null) |
---|
| 8231 | +// { |
---|
| 8232 | +// BindTexture(null,false,resolution); |
---|
| 8233 | +// BindTexture(null,true,resolution); |
---|
| 8234 | +// return; |
---|
| 8235 | +// } |
---|
| 8236 | +// |
---|
| 8237 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8238 | +// String bump = Object3D.GetBump(tex); |
---|
| 8239 | +// |
---|
| 8240 | +// usedtextures.add(pigment); |
---|
| 8241 | +// usedtextures.add(bump); |
---|
| 8242 | +// |
---|
| 8243 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8244 | +// { |
---|
| 8245 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8246 | +// // System.out.println("; bump = " + bump); |
---|
| 8247 | +// } |
---|
| 8248 | +// |
---|
| 8249 | +// if (bump.equals("")) |
---|
| 8250 | +// { |
---|
| 8251 | +// bump = null; |
---|
| 8252 | +// } |
---|
| 8253 | +// if (pigment.equals("")) |
---|
| 8254 | +// { |
---|
| 8255 | +// pigment = null; |
---|
| 8256 | +// } |
---|
| 8257 | +// |
---|
| 8258 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8259 | +// BindTexture(pigment, false, resolution); |
---|
| 8260 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8261 | +// BindTexture(bump, true, resolution); |
---|
| 8262 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8263 | +// |
---|
| 8264 | +// return; // true; |
---|
8099 | 8265 | |
---|
8100 | | - String pigment = Object3D.GetPigment(tex); |
---|
8101 | | - String bump = Object3D.GetBump(tex); |
---|
8102 | | - |
---|
8103 | | - usedtextures.put(pigment, pigment); |
---|
8104 | | - usedtextures.put(bump, bump); |
---|
8105 | | - |
---|
8106 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8107 | | - { |
---|
8108 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8109 | | - // System.out.println("; bump = " + bump); |
---|
8110 | | - } |
---|
8111 | | - |
---|
8112 | | - if (bump.equals("")) |
---|
8113 | | - { |
---|
8114 | | - bump = null; |
---|
8115 | | - } |
---|
8116 | | - if (pigment.equals("")) |
---|
8117 | | - { |
---|
8118 | | - pigment = null; |
---|
8119 | | - } |
---|
8120 | | - |
---|
8121 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8122 | | - BindTexture(pigment, false, resolution); |
---|
8123 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8124 | | - BindTexture(bump, true, resolution); |
---|
8125 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8126 | | - |
---|
8127 | | - return; // true; |
---|
| 8266 | + BindPigmentTexture(tex, resolution); |
---|
| 8267 | + BindBumpTexture(tex, resolution); |
---|
8128 | 8268 | } |
---|
8129 | 8269 | |
---|
8130 | 8270 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8143 | 8283 | |
---|
8144 | 8284 | String pigment = Object3D.GetPigment(tex); |
---|
8145 | 8285 | |
---|
8146 | | - usedtextures.put(pigment, pigment); |
---|
| 8286 | + usedtextures.add(tex); |
---|
8147 | 8287 | |
---|
8148 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8288 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8149 | 8289 | { |
---|
8150 | 8290 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8151 | 8291 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8157 | 8297 | } |
---|
8158 | 8298 | |
---|
8159 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8160 | | - BindTexture(pigment, false, resolution); |
---|
| 8300 | + BindTexture(tex, false, resolution); |
---|
8161 | 8301 | } |
---|
8162 | 8302 | |
---|
8163 | 8303 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8176 | 8316 | |
---|
8177 | 8317 | String bump = Object3D.GetBump(tex); |
---|
8178 | 8318 | |
---|
8179 | | - usedtextures.put(bump, bump); |
---|
| 8319 | + usedtextures.add(tex); |
---|
8180 | 8320 | |
---|
8181 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8321 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8182 | 8322 | { |
---|
8183 | 8323 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8184 | 8324 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8190 | 8330 | } |
---|
8191 | 8331 | |
---|
8192 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8193 | | - BindTexture(bump, true, resolution); |
---|
| 8333 | + BindTexture(tex, true, resolution); |
---|
8194 | 8334 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8195 | 8335 | } |
---|
8196 | 8336 | |
---|
.. | .. |
---|
8214 | 8354 | return fileExists; |
---|
8215 | 8355 | } |
---|
8216 | 8356 | |
---|
8217 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8357 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8218 | 8358 | { |
---|
8219 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8359 | + CacheTexture texturecache = null; |
---|
8220 | 8360 | |
---|
8221 | 8361 | if (tex != null) |
---|
8222 | 8362 | { |
---|
8223 | | - String texname = tex; |
---|
| 8363 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8364 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8365 | + |
---|
| 8366 | + if (texname.equals("") && texdata == null) |
---|
| 8367 | + { |
---|
| 8368 | + return null; |
---|
| 8369 | + } |
---|
8224 | 8370 | |
---|
8225 | 8371 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8226 | 8372 | |
---|
.. | .. |
---|
8230 | 8376 | // else |
---|
8231 | 8377 | // if (!texname.startsWith("/")) |
---|
8232 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8233 | | - if (!FileExists(tex)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8234 | 8380 | { |
---|
8235 | 8381 | texname = fallbackTextureName; |
---|
8236 | 8382 | } |
---|
8237 | 8383 | |
---|
8238 | 8384 | if (CACHETEXTURE) |
---|
8239 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8240 | | - |
---|
8241 | | - TextureData texturedata = null; |
---|
8242 | | - |
---|
8243 | | - if (texture == null || texture.resolution < resolution) |
---|
8244 | 8385 | { |
---|
8245 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8386 | + if (texdata == null) |
---|
| 8387 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8388 | + else |
---|
| 8389 | + texturecache = bimtextures.get(texdata); |
---|
| 8390 | + } |
---|
| 8391 | + |
---|
| 8392 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8393 | + { |
---|
| 8394 | + TextureData texturedata = null; |
---|
| 8395 | + |
---|
| 8396 | + if (texdata != null && textureon) |
---|
| 8397 | + { |
---|
| 8398 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8399 | + |
---|
| 8400 | + try |
---|
| 8401 | + { |
---|
| 8402 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8403 | + } |
---|
| 8404 | + catch (Exception e) |
---|
| 8405 | + { |
---|
| 8406 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8407 | + } |
---|
| 8408 | + |
---|
| 8409 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8410 | + bimtextures.put(texdata, texturecache); |
---|
| 8411 | + |
---|
| 8412 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8413 | + |
---|
| 8414 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8415 | + //bim2 = bim; |
---|
| 8416 | + } |
---|
| 8417 | + else |
---|
| 8418 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8246 | 8419 | { |
---|
8247 | 8420 | assert(!bump); |
---|
8248 | 8421 | // if (bump) |
---|
.. | .. |
---|
8253 | 8426 | // } |
---|
8254 | 8427 | // else |
---|
8255 | 8428 | // { |
---|
8256 | | - texture = textures.get(tex); |
---|
8257 | | - if (texture == null) |
---|
| 8429 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8430 | + if (texturecache == null) |
---|
8258 | 8431 | { |
---|
8259 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8432 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8260 | 8433 | } |
---|
| 8434 | + else |
---|
| 8435 | + new Exception().printStackTrace(); |
---|
8261 | 8436 | // } |
---|
8262 | 8437 | } else |
---|
8263 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8438 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8264 | 8439 | { |
---|
8265 | 8440 | assert(bump); |
---|
8266 | | - texture = textures.get(tex); |
---|
8267 | | - if (texture == null) |
---|
8268 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8441 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8442 | + if (texturecache == null) |
---|
| 8443 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8444 | + else |
---|
| 8445 | + new Exception().printStackTrace(); |
---|
8269 | 8446 | } else |
---|
8270 | 8447 | { |
---|
8271 | 8448 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8273 | 8450 | // texture = GetResourceTexture("default.png"); |
---|
8274 | 8451 | //} else |
---|
8275 | 8452 | //{ |
---|
8276 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8453 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8277 | 8454 | { |
---|
8278 | | - texture = textures.get(tex); |
---|
8279 | | - if (texture == null) |
---|
8280 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8455 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8456 | + if (texturecache == null) |
---|
| 8457 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8458 | + else |
---|
| 8459 | + new Exception().printStackTrace(); |
---|
| 8460 | + } else |
---|
| 8461 | + { |
---|
| 8462 | + if (texname.startsWith("@")) |
---|
| 8463 | + { |
---|
| 8464 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8465 | + if (texturecache == null) |
---|
| 8466 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8467 | + else |
---|
| 8468 | + new Exception().printStackTrace(); |
---|
8281 | 8469 | } else |
---|
8282 | 8470 | { |
---|
8283 | 8471 | if (textureon) |
---|
.. | .. |
---|
8336 | 8524 | if (texturedata == null) |
---|
8337 | 8525 | throw new Exception(); |
---|
8338 | 8526 | |
---|
8339 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8527 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8340 | 8528 | //texture = GetTexture(tex, bump); |
---|
8341 | 8529 | } |
---|
| 8530 | + } |
---|
8342 | 8531 | } |
---|
8343 | 8532 | //} |
---|
8344 | 8533 | } |
---|
8345 | 8534 | |
---|
8346 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8535 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8347 | 8536 | { |
---|
8348 | 8537 | //return false; |
---|
8349 | 8538 | |
---|
8350 | 8539 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8351 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8540 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8352 | 8541 | { |
---|
8353 | 8542 | // String ext = "_highres"; |
---|
8354 | 8543 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8365 | 8554 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8366 | 8555 | if (!cachefile.exists()) |
---|
8367 | 8556 | { |
---|
8368 | | - // cache to disk |
---|
8369 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8370 | | - //buffers[0]. |
---|
8371 | | - |
---|
8372 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8373 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8374 | | - |
---|
8375 | | - // squared size heuristic... |
---|
8376 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8557 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8377 | 8558 | { |
---|
8378 | | - for (int i=pixels.length; --i>=0;) |
---|
8379 | | - { |
---|
8380 | | - int i3 = i*3; |
---|
8381 | | - pixels[i] = 0xFF; |
---|
8382 | | - pixels[i] <<= 8; |
---|
8383 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8384 | | - pixels[i] <<= 8; |
---|
8385 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8386 | | - pixels[i] <<= 8; |
---|
8387 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8388 | | - } |
---|
8389 | | - |
---|
8390 | | - /* |
---|
8391 | | - int r=0,g=0,b=0,a=0; |
---|
8392 | | - for (int i=0; i<width; i++) |
---|
8393 | | - for (int j=0; j<height; j++) |
---|
8394 | | - { |
---|
8395 | | - int index = j*width+i; |
---|
8396 | | - int p = pixels[index]; |
---|
8397 | | - a = ((p>>24) & 0xFF); |
---|
8398 | | - r = ((p>>16) & 0xFF); |
---|
8399 | | - g = ((p>>8) & 0xFF); |
---|
8400 | | - b = (p & 0xFF); |
---|
8401 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8402 | | - } |
---|
8403 | | - /**/ |
---|
8404 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8405 | | - int height = width; |
---|
8406 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8407 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8559 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8560 | + |
---|
8408 | 8561 | ImageWriter writer = null; |
---|
8409 | 8562 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8410 | 8563 | if (iter.hasNext()) { |
---|
8411 | 8564 | writer = (ImageWriter)iter.next(); |
---|
8412 | 8565 | } |
---|
8413 | | - float compressionQuality = 0.9f; |
---|
| 8566 | + |
---|
| 8567 | + float compressionQuality = 0.85f; |
---|
8414 | 8568 | try |
---|
8415 | 8569 | { |
---|
8416 | 8570 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8427 | 8581 | } |
---|
8428 | 8582 | } |
---|
8429 | 8583 | } |
---|
8430 | | - |
---|
| 8584 | + |
---|
| 8585 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8586 | + |
---|
8431 | 8587 | //System.out.println("Texture = " + tex); |
---|
8432 | | - if (textures.containsKey(texname)) |
---|
| 8588 | + if (textures.containsKey(tex)) |
---|
8433 | 8589 | { |
---|
8434 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8590 | + CacheTexture thetex = textures.get(tex); |
---|
8435 | 8591 | thetex.texture.disable(); |
---|
8436 | 8592 | thetex.texture.dispose(); |
---|
8437 | | - textures.remove(texname); |
---|
| 8593 | + textures.remove(tex); |
---|
8438 | 8594 | } |
---|
8439 | 8595 | |
---|
8440 | | - texture.texturedata = texturedata; |
---|
8441 | | - textures.put(texname, texture); |
---|
| 8596 | + //texture.texturedata = texturedata; |
---|
| 8597 | + textures.put(tex, texturecache); |
---|
8442 | 8598 | |
---|
8443 | 8599 | // newtex = true; |
---|
8444 | 8600 | } |
---|
.. | .. |
---|
8454 | 8610 | } |
---|
8455 | 8611 | } |
---|
8456 | 8612 | |
---|
8457 | | - return texture; |
---|
| 8613 | + return texturecache; |
---|
8458 | 8614 | } |
---|
8459 | 8615 | |
---|
8460 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8616 | + static void EmbedTextures(cTexture tex) |
---|
| 8617 | + { |
---|
| 8618 | + if (tex.pigmentdata == null) |
---|
| 8619 | + { |
---|
| 8620 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8621 | + |
---|
| 8622 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8623 | + |
---|
| 8624 | + if (texturecache != null) |
---|
| 8625 | + { |
---|
| 8626 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8627 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8628 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8629 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8630 | + ; |
---|
| 8631 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8632 | + } |
---|
| 8633 | + } |
---|
| 8634 | + |
---|
| 8635 | + if (tex.bumpdata == null) |
---|
| 8636 | + { |
---|
| 8637 | + //String texname = Object3D.GetBump(tex); |
---|
| 8638 | + |
---|
| 8639 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8640 | + |
---|
| 8641 | + if (texturecache != null) |
---|
| 8642 | + { |
---|
| 8643 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8644 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8645 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), 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 |
---|
8461 | 8651 | { |
---|
8462 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8463 | 8653 | |
---|
.. | .. |
---|
8475 | 8665 | return texture!=null?texture.texture:null; |
---|
8476 | 8666 | } |
---|
8477 | 8667 | |
---|
8478 | | - 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 |
---|
8479 | 8669 | { |
---|
8480 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8481 | 8671 | |
---|
8482 | 8672 | return texture!=null?texture.texturedata:null; |
---|
8483 | 8673 | } |
---|
8484 | 8674 | |
---|
8485 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8486 | 8676 | { |
---|
8487 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8488 | 8678 | { |
---|
8489 | 8679 | return false; |
---|
8490 | 8680 | } |
---|
8491 | 8681 | |
---|
8492 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
8493 | 8683 | |
---|
8494 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8495 | 8685 | |
---|
.. | .. |
---|
8521 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8522 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8523 | 8713 | |
---|
8524 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
8525 | 8715 | } |
---|
8526 | 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 | + |
---|
8527 | 8783 | ShadowBuffer shadowPBuf; |
---|
8528 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8529 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8540 | 8796 | |
---|
8541 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8542 | 8798 | MAXSTACK = temp[0]; |
---|
8543 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8544 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8545 | 8802 | MAXSTACK = temp[0]; |
---|
8546 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8547 | 8805 | |
---|
8548 | 8806 | // Use debug pipeline |
---|
8549 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8551 | 8809 | gl = drawable.getGL(); // |
---|
8552 | 8810 | |
---|
8553 | 8811 | GL gl3 = getGL(); |
---|
8554 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8555 | 8814 | |
---|
8556 | 8815 | |
---|
8557 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8716 | 8975 | |
---|
8717 | 8976 | if (cubemap == null) |
---|
8718 | 8977 | { |
---|
8719 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8720 | 8979 | } |
---|
8721 | 8980 | |
---|
8722 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
8992 | 9251 | |
---|
8993 | 9252 | void LoadEnvy(int which) |
---|
8994 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
8995 | 9256 | String name; |
---|
8996 | 9257 | String ext; |
---|
8997 | 9258 | |
---|
.. | .. |
---|
9003 | 9264 | cubemap = null; |
---|
9004 | 9265 | return; |
---|
9005 | 9266 | case 1: |
---|
9006 | | - name = "cubemaps/box_"; |
---|
9007 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9008 | 9269 | reverseUP = false; |
---|
9009 | 9270 | break; |
---|
9010 | 9271 | case 2: |
---|
9011 | | - name = "cubemaps/uffizi_"; |
---|
9012 | | - ext = "png"; |
---|
9013 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9014 | 9276 | case 3: |
---|
9015 | | - name = "cubemaps/CloudyHills_"; |
---|
9016 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9017 | 9279 | reverseUP = false; |
---|
9018 | 9280 | break; |
---|
9019 | 9281 | case 4: |
---|
9020 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9021 | 9283 | ext = "png"; |
---|
9022 | 9284 | reverseUP = false; |
---|
9023 | 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; |
---|
9024 | 9311 | default: |
---|
9025 | | - name = "cubemaps/rgb_"; |
---|
9026 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9027 | 9315 | break; |
---|
9028 | 9316 | } |
---|
9029 | | - |
---|
9030 | | - try |
---|
9031 | | - { |
---|
9032 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9033 | | - } catch (IOException e) |
---|
9034 | | - { |
---|
9035 | | - throw new RuntimeException(e); |
---|
9036 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9037 | 9319 | } |
---|
9038 | 9320 | |
---|
9039 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9065 | 9347 | static double[] model = new double[16]; |
---|
9066 | 9348 | double[] camera2light = new double[16]; |
---|
9067 | 9349 | double[] light2camera = new double[16]; |
---|
9068 | | - int newenvy = -1; |
---|
9069 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9070 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9071 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9072 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9359 | 9645 | jy8[3] = 0.5f; |
---|
9360 | 9646 | } |
---|
9361 | 9647 | |
---|
9362 | | - 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 |
---|
9363 | 9649 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9364 | 9650 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9365 | 9651 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9366 | 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 | + |
---|
9367 | 9677 | static int imagecount = 0; // movie generation |
---|
9368 | 9678 | |
---|
9369 | 9679 | static int jitter = 0; |
---|
.. | .. |
---|
9460 | 9770 | |
---|
9461 | 9771 | if (renderCamera != lightCamera) |
---|
9462 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9463 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9464 | 9774 | |
---|
9465 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9466 | 9776 | |
---|
.. | .. |
---|
9476 | 9786 | |
---|
9477 | 9787 | if (renderCamera != lightCamera) |
---|
9478 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9479 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9480 | 9790 | |
---|
9481 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9482 | 9792 | |
---|
.. | .. |
---|
9522 | 9832 | rati = 1 / rati; |
---|
9523 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9524 | 9834 | } |
---|
9525 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9526 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9527 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9528 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9529 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9530 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9531 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10391 | 10703 | static boolean init = false; |
---|
10392 | 10704 | |
---|
10393 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10394 | 10709 | |
---|
10395 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10396 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10397 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10398 | 10719 | { |
---|
10399 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10474 | 10795 | ANTIALIAS = 0; |
---|
10475 | 10796 | //System.out.println("RESTART"); |
---|
10476 | 10797 | AAtimer.restart(); |
---|
| 10798 | + Globals.TIMERRUNNING = true; |
---|
10477 | 10799 | } |
---|
10478 | 10800 | } |
---|
10479 | 10801 | } |
---|
.. | .. |
---|
10541 | 10863 | ambientOcclusion = false; |
---|
10542 | 10864 | } |
---|
10543 | 10865 | |
---|
10544 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10866 | + if (//Globals.lighttouched && |
---|
| 10867 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10545 | 10868 | { |
---|
10546 | 10869 | //if (RENDERSHADOW) // ? |
---|
10547 | 10870 | if (!IsFrozen()) |
---|
.. | .. |
---|
10560 | 10883 | |
---|
10561 | 10884 | if (wait) |
---|
10562 | 10885 | { |
---|
10563 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10564 | 10887 | |
---|
10565 | 10888 | wait = false; |
---|
10566 | 10889 | } |
---|
.. | .. |
---|
10675 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
10676 | 10999 | if (cam != lightCamera) |
---|
10677 | 11000 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10678 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10679 | 11002 | |
---|
10680 | 11003 | for (int j = 0; j < 4; j++) |
---|
10681 | 11004 | { |
---|
.. | .. |
---|
10690 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
10691 | 11014 | if (cam != lightCamera) |
---|
10692 | 11015 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10693 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10694 | 11017 | |
---|
10695 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10696 | 11019 | |
---|
.. | .. |
---|
10776 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10777 | 11100 | } |
---|
10778 | 11101 | |
---|
10779 | | - if (newenvy > -1) |
---|
| 11102 | +// if (newenvy > -1) |
---|
| 11103 | +// { |
---|
| 11104 | +// LoadEnvy(newenvy); |
---|
| 11105 | +// } |
---|
| 11106 | +// |
---|
| 11107 | +// newenvy = -1; |
---|
| 11108 | + |
---|
| 11109 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
10780 | 11110 | { |
---|
10781 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
10782 | 11117 | } |
---|
10783 | | - |
---|
10784 | | - newenvy = -1; |
---|
10785 | | - |
---|
| 11118 | + else |
---|
| 11119 | + { |
---|
| 11120 | + if (object.skyboxname != null) |
---|
| 11121 | + { |
---|
| 11122 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11123 | + { |
---|
| 11124 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11125 | + cubemap.dispose(); |
---|
| 11126 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11127 | + loadedskyboxname = object.skyboxname; |
---|
| 11128 | + } |
---|
| 11129 | + } |
---|
| 11130 | + else |
---|
| 11131 | + { |
---|
| 11132 | + cubemapcustom = null; |
---|
| 11133 | + loadedskyboxname = null; |
---|
| 11134 | + } |
---|
| 11135 | + |
---|
| 11136 | + cubemap = cubemapcustom; |
---|
| 11137 | + } |
---|
| 11138 | + |
---|
10786 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
10787 | 11140 | //System.out.println("ratio = " + ratio); |
---|
10788 | 11141 | |
---|
.. | .. |
---|
10798 | 11151 | |
---|
10799 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
10800 | 11153 | { |
---|
10801 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
10802 | 11155 | } |
---|
10803 | 11156 | |
---|
10804 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
10981 | 11334 | |
---|
10982 | 11335 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10983 | 11336 | |
---|
10984 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10985 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10986 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11337 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11338 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11339 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10987 | 11340 | } else |
---|
10988 | 11341 | { |
---|
10989 | 11342 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10994 | 11347 | //System.out.println("BLENDING ON"); |
---|
10995 | 11348 | gl.glEnable(GL.GL_BLEND); |
---|
10996 | 11349 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10997 | | - |
---|
| 11350 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10998 | 11351 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10999 | 11352 | gl.glLoadIdentity(); |
---|
11000 | 11353 | |
---|
.. | .. |
---|
11084 | 11437 | |
---|
11085 | 11438 | // if (cam != lightCamera) |
---|
11086 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11087 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11088 | 11441 | } |
---|
11089 | 11442 | |
---|
11090 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11243 | 11596 | } |
---|
11244 | 11597 | } |
---|
11245 | 11598 | |
---|
11246 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11599 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11247 | 11600 | { |
---|
11248 | 11601 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11249 | 11602 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11251 | 11604 | |
---|
11252 | 11605 | boolean texon = textureon; |
---|
11253 | 11606 | |
---|
11254 | | - if (RENDERPROGRAM > 0) |
---|
11255 | | - { |
---|
11256 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11257 | | - textureon = false; |
---|
11258 | | - } |
---|
| 11607 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11608 | + textureon = false; |
---|
| 11609 | + |
---|
11259 | 11610 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11260 | 11611 | //System.out.println("ALLO"); |
---|
11261 | 11612 | gl.glColorMask(false, false, false, false); |
---|
11262 | 11613 | DrawObject(gl); |
---|
11263 | | - if (RENDERPROGRAM > 0) |
---|
11264 | | - { |
---|
11265 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11266 | | - textureon = texon; |
---|
11267 | | - } |
---|
| 11614 | + |
---|
| 11615 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11616 | + textureon = texon; |
---|
| 11617 | + |
---|
11268 | 11618 | gl.glColorMask(true, true, true, true); |
---|
11269 | 11619 | |
---|
11270 | 11620 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11271 | | - //gl.glDepthMask(false); |
---|
| 11621 | + gl.glDepthMask(false); |
---|
11272 | 11622 | } |
---|
11273 | 11623 | |
---|
11274 | 11624 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11451 | 11801 | |
---|
11452 | 11802 | static boolean zoomonce = false; |
---|
11453 | 11803 | |
---|
| 11804 | + static void CreateSelectedPoint() |
---|
| 11805 | + { |
---|
| 11806 | + if (selectedpoint == null) |
---|
| 11807 | + { |
---|
| 11808 | + debugpointG = new Sphere(); |
---|
| 11809 | + debugpointP = new Sphere(); |
---|
| 11810 | + debugpointC = new Sphere(); |
---|
| 11811 | + debugpointR = new Sphere(); |
---|
| 11812 | + |
---|
| 11813 | + selectedpoint = new Superellipsoid(); |
---|
| 11814 | + |
---|
| 11815 | + for (int i=0; i<8; i++) |
---|
| 11816 | + { |
---|
| 11817 | + debugpoints[i] = new Sphere(); |
---|
| 11818 | + } |
---|
| 11819 | + } |
---|
| 11820 | + } |
---|
| 11821 | + |
---|
11454 | 11822 | void DrawObject(GL gl, boolean draw) |
---|
11455 | 11823 | { |
---|
| 11824 | + // To clear camera values |
---|
| 11825 | + ResetOptions(); |
---|
| 11826 | + |
---|
11456 | 11827 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11457 | 11828 | // DrawMode() = SELECTION; |
---|
11458 | 11829 | //GL gl = getGL(); |
---|
11459 | 11830 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11460 | 11831 | { |
---|
11461 | 11832 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11462 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11833 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11463 | 11834 | pingthread.StepToTarget(true); // true); |
---|
11464 | 11835 | // zoomonce = false; |
---|
11465 | 11836 | } |
---|
.. | .. |
---|
11531 | 11902 | |
---|
11532 | 11903 | if (DrawMode() == DEFAULT) |
---|
11533 | 11904 | { |
---|
11534 | | - if (DEBUG) |
---|
| 11905 | + if (Globals.DEBUG) |
---|
11535 | 11906 | { |
---|
| 11907 | + CreateSelectedPoint(); |
---|
11536 | 11908 | float radius = 0.05f; |
---|
11537 | 11909 | if (selectedpoint.radius != radius) |
---|
11538 | 11910 | { |
---|
.. | .. |
---|
11586 | 11958 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11587 | 11959 | |
---|
11588 | 11960 | if (CLEANCACHE) |
---|
11589 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11961 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11590 | 11962 | { |
---|
11591 | | - String tex = e.nextElement(); |
---|
| 11963 | + cTexture tex = e.nextElement(); |
---|
11592 | 11964 | |
---|
11593 | 11965 | // System.out.println("Texture --------- " + tex); |
---|
11594 | 11966 | |
---|
11595 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11967 | + if (tex.equals("WHITE_NOISE:")) |
---|
11596 | 11968 | continue; |
---|
11597 | 11969 | |
---|
11598 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11970 | + if (!usedtextures.contains(tex)) |
---|
11599 | 11971 | { |
---|
| 11972 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11600 | 11973 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11601 | | - textures.get(tex).texture.dispose(); |
---|
11602 | | - textures.remove(tex); |
---|
| 11974 | + if (gettex != null) |
---|
| 11975 | + { |
---|
| 11976 | + gettex.texture.dispose(); |
---|
| 11977 | + texturepigment.remove(tex); |
---|
| 11978 | + } |
---|
| 11979 | + |
---|
| 11980 | + gettex = texturebump.get(tex); |
---|
| 11981 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11982 | + if (gettex != null) |
---|
| 11983 | + { |
---|
| 11984 | + gettex.texture.dispose(); |
---|
| 11985 | + texturebump.remove(tex); |
---|
| 11986 | + } |
---|
11603 | 11987 | } |
---|
11604 | 11988 | } |
---|
11605 | 11989 | } |
---|
.. | .. |
---|
12019 | 12403 | for (int i = tp.size(); --i >= 0;) |
---|
12020 | 12404 | { |
---|
12021 | 12405 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12022 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12406 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12023 | 12407 | } |
---|
12024 | 12408 | |
---|
12025 | 12409 | |
---|
.. | .. |
---|
12127 | 12511 | |
---|
12128 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12129 | 12513 | |
---|
12130 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
12131 | 12516 | "!!ARBfp1.0\n" + |
---|
| 12517 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12520 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12521 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12522 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12523 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12524 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12525 | + "TEMP temp;" + |
---|
| 12526 | + "TEMP light;" + |
---|
| 12527 | + "TEMP ndotl;" + |
---|
| 12528 | + "TEMP normal;" + |
---|
| 12529 | + "TEMP depth;" + |
---|
| 12530 | + "TEMP eye;" + |
---|
| 12531 | + "TEMP pos;" + |
---|
| 12532 | + |
---|
| 12533 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12534 | + Normalize("normal") + |
---|
| 12535 | + "MOV light, state.light[0].position;" + |
---|
| 12536 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12537 | + |
---|
| 12538 | + // shadow |
---|
| 12539 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12540 | + "MOV temp, pos;" + |
---|
| 12541 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12542 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12543 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12544 | + |
---|
| 12545 | + // No shadow when out of frustum |
---|
| 12546 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12547 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12548 | + |
---|
| 12549 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12550 | + |
---|
| 12551 | + // Backlit |
---|
| 12552 | + "MOV pos.w, zero123.y;" + |
---|
| 12553 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12554 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12555 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12556 | + Normalize("eye") + |
---|
| 12557 | + |
---|
| 12558 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12559 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12560 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12561 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12562 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12563 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12564 | + |
---|
| 12565 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12566 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12567 | + |
---|
| 12568 | + // Pigment |
---|
| 12569 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12570 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12571 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12572 | + |
---|
| 12573 | + "MUL temp, temp, zero123.z;" + |
---|
| 12574 | + |
---|
| 12575 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12576 | + |
---|
| 12577 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12578 | + "MOV result.color, temp;" + |
---|
| 12579 | + "END"; |
---|
| 12580 | + |
---|
| 12581 | + String programmax = |
---|
| 12582 | + "!!ARBfp1.0\n" + |
---|
| 12583 | + |
---|
12132 | 12584 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12133 | 12585 | "PARAM light2cam0 = program.env[10];" + |
---|
12134 | 12586 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12154 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12155 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12156 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12157 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12158 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12159 | 12611 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12160 | 12612 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12243 | 12695 | "TEMP shininess;" + |
---|
12244 | 12696 | "\n" + |
---|
12245 | 12697 | "MOV texSamp, one;" + |
---|
12246 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12247 | | - |
---|
| 12698 | + |
---|
12248 | 12699 | "MOV mapgrid.x, one2048th.x;" + |
---|
12249 | 12700 | "MOV temp, fragment.texcoord[1];" + |
---|
12250 | 12701 | /* |
---|
.. | .. |
---|
12265 | 12716 | "MUL temp, floor, mapgrid.x;" + |
---|
12266 | 12717 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12267 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12268 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12269 | 12720 | "") + |
---|
12270 | 12721 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12271 | 12722 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12272 | 12723 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12273 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12724 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12274 | 12725 | "") + |
---|
12275 | 12726 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12276 | 12727 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12277 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12728 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12278 | 12729 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12279 | 12730 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12280 | 12731 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12281 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12732 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12282 | 12733 | "") + |
---|
12283 | 12734 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12284 | 12735 | //"MOV params, material;" + |
---|
.. | .. |
---|
12400 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12401 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12402 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12403 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12404 | 12855 | /* |
---|
12405 | 12856 | "MUL temp.xy, temp, two;" + |
---|
12406 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12486 | 12937 | "SUB bump0, bump0, half;" + |
---|
12487 | 12938 | "ADD bump, bump, bump0;" + |
---|
12488 | 12939 | |
---|
12489 | | - "MOV temp.x, texSamp.a;" + |
---|
12490 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12491 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12492 | | - "MOV texSamp.a, temp.x;" + |
---|
12493 | | - |
---|
12494 | 12940 | // double-sided |
---|
12495 | 12941 | /**/ |
---|
12496 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12507 | 12953 | "MOV normald, normal;" + |
---|
12508 | 12954 | "MOV normals, normal;" + |
---|
12509 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
12510 | 12958 | // UV base |
---|
12511 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12512 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12513 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12514 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12515 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12516 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12962 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12963 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12964 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12965 | + Normalize("UP") + |
---|
| 12966 | + |
---|
12517 | 12967 | "XPD V, normal, UP;" + |
---|
12518 | 12968 | Normalize("V") + |
---|
12519 | 12969 | "XPD U, V, normal;" + |
---|
12520 | 12970 | Normalize("U") + |
---|
12521 | 12971 | |
---|
12522 | 12972 | // parallax mapping |
---|
| 12973 | + |
---|
| 12974 | + "DP3 temp2.x, V, eye;" + |
---|
| 12975 | + "DP3 temp2.y, U, eye;" + |
---|
| 12976 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12977 | + "RCP temp2.z, temp2.z;" + |
---|
| 12978 | + |
---|
| 12979 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12980 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12981 | + "RCP temp2.w, temp2.w;" + |
---|
| 12982 | + |
---|
| 12983 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12984 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12985 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12986 | + |
---|
| 12987 | + //"MOV texSamp, U;" + |
---|
| 12988 | + |
---|
| 12989 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12990 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12991 | + |
---|
| 12992 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12993 | + |
---|
| 12994 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12995 | + |
---|
| 12996 | + "SUB temp, temp, temp2;" + |
---|
| 12997 | + |
---|
| 12998 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 12999 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13000 | + |
---|
| 13001 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13002 | + "MUL temp.xyz, half, texSamp;" + |
---|
| 13003 | + |
---|
| 13004 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13005 | + |
---|
| 13006 | +// parallax mapping |
---|
| 13007 | + |
---|
| 13008 | + "MOV temp.x, texSamp.a;" + |
---|
| 13009 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13010 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13011 | + "MOV texSamp.a, temp.x;" + |
---|
12523 | 13012 | |
---|
12524 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
12525 | 13014 | // |
---|
.. | .. |
---|
12649 | 13138 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12650 | 13139 | "") + |
---|
12651 | 13140 | |
---|
12652 | | - // display shadow only (bump == 0) |
---|
| 13141 | + // display shadow only (fakedepth == 0) |
---|
12653 | 13142 | "SUB temp.x, half.x, shadow.x;" + |
---|
12654 | 13143 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12655 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13144 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12656 | 13145 | "SUB temp.y, one.x, temp.z;" + |
---|
12657 | 13146 | "MUL temp.x, temp.x, temp.y;" + |
---|
12658 | 13147 | "KIL temp.x;" + |
---|
.. | .. |
---|
12983 | 13472 | //once = true; |
---|
12984 | 13473 | } |
---|
12985 | 13474 | |
---|
12986 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12987 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13475 | + String program = programmax; |
---|
| 13476 | + |
---|
| 13477 | + if (Globals.MINSHADER) |
---|
| 13478 | + { |
---|
| 13479 | + program = programmin; |
---|
| 13480 | + } |
---|
| 13481 | + |
---|
| 13482 | + if (Globals.DEBUG) |
---|
| 13483 | + { |
---|
| 13484 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13485 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13486 | + } |
---|
| 13487 | + |
---|
12988 | 13488 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12989 | 13489 | |
---|
12990 | 13490 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13031 | 13531 | "\n" + |
---|
13032 | 13532 | "END\n"; |
---|
13033 | 13533 | |
---|
13034 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13534 | + if (Globals.DEBUG) |
---|
| 13535 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13035 | 13536 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13036 | 13537 | |
---|
13037 | 13538 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13076 | 13577 | return out; |
---|
13077 | 13578 | } |
---|
13078 | 13579 | |
---|
13079 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13580 | + // Also does frustum culling |
---|
| 13581 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13080 | 13582 | { |
---|
13081 | 13583 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13082 | 13584 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13083 | 13585 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13586 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13587 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13084 | 13588 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13085 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13086 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13087 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13088 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13589 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13590 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13089 | 13591 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13090 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13592 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13091 | 13593 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13092 | 13594 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13093 | 13595 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13094 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13596 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13095 | 13597 | |
---|
13096 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13097 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13598 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13599 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13098 | 13600 | } |
---|
13099 | 13601 | |
---|
13100 | 13602 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13141 | 13643 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13142 | 13644 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13143 | 13645 | |
---|
13144 | | - // No shadow when out of frustrum |
---|
| 13646 | + // No shadow when out of frustum |
---|
13145 | 13647 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13146 | 13648 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13147 | 13649 | ""; |
---|
.. | .. |
---|
13288 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13289 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13290 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13291 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13292 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13793 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
| 13794 | + |
---|
| 13795 | + //Object3D.cVector2[] vector2buffer; |
---|
13293 | 13796 | |
---|
13294 | 13797 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13295 | 13798 | // OUT : diff, spec |
---|
.. | .. |
---|
13305 | 13808 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13306 | 13809 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13307 | 13810 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13308 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13309 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13310 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13811 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13812 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13813 | + |
---|
| 13814 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13311 | 13815 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13312 | 13816 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13313 | 13817 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13453 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13454 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13455 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13456 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13457 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13458 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13459 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13514 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13515 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13516 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13517 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13518 | 14022 | "MOV result.texcoord, temp;" + |
---|
13519 | 14023 | // border fade |
---|
13520 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13561 | 14065 | |
---|
13562 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
13563 | 14067 | |
---|
13564 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
13565 | 14071 | : "MOV result.color, vertex.color;") + |
---|
13566 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13567 | 14073 | : "") + |
---|
.. | .. |
---|
13812 | 14318 | else |
---|
13813 | 14319 | if (evt.getSource() == AAtimer) |
---|
13814 | 14320 | { |
---|
| 14321 | + Globals.TIMERRUNNING = false; |
---|
13815 | 14322 | if (mouseDown) |
---|
13816 | 14323 | { |
---|
13817 | 14324 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13871 | 14378 | |
---|
13872 | 14379 | // fev 2014??? |
---|
13873 | 14380 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13874 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14381 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13875 | 14382 | pingthread.StepToTarget(true); // true); |
---|
13876 | 14383 | } |
---|
13877 | 14384 | // if (!LIVE) |
---|
.. | .. |
---|
13886 | 14393 | return; |
---|
13887 | 14394 | |
---|
13888 | 14395 | AAtimer.restart(); // |
---|
| 14396 | + Globals.TIMERRUNNING = true; |
---|
13889 | 14397 | |
---|
13890 | 14398 | // waslive = LIVE; |
---|
13891 | 14399 | // LIVE = false; |
---|
.. | .. |
---|
13935 | 14443 | drag = false; |
---|
13936 | 14444 | //System.out.println("Mouse DOWN"); |
---|
13937 | 14445 | editObj = false; |
---|
13938 | | - ClickInfo info = new ClickInfo(); |
---|
13939 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13940 | | - info.pane = this; |
---|
13941 | | - info.camera = renderCamera; |
---|
13942 | | - info.x = x; |
---|
13943 | | - info.y = y; |
---|
13944 | | - info.modifiers = modifiersex; |
---|
13945 | | - editObj = object.doEditClick(info, 0); |
---|
| 14446 | + //ClickInfo info = new ClickInfo(); |
---|
| 14447 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14448 | + object.clickInfo.pane = this; |
---|
| 14449 | + object.clickInfo.camera = renderCamera; |
---|
| 14450 | + object.clickInfo.x = x; |
---|
| 14451 | + object.clickInfo.y = y; |
---|
| 14452 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14453 | + editObj = object.doEditClick(//info, |
---|
| 14454 | + 0); |
---|
13946 | 14455 | if (!editObj) |
---|
13947 | 14456 | { |
---|
13948 | 14457 | hasMarquee = true; |
---|
.. | .. |
---|
14224 | 14733 | void GoDown(int mod) |
---|
14225 | 14734 | { |
---|
14226 | 14735 | MODIFIERS |= COMMAND; |
---|
14227 | | - /* |
---|
| 14736 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14737 | + /**/ |
---|
14228 | 14738 | if((mod&SHIFT) == SHIFT) |
---|
14229 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14739 | + { |
---|
| 14740 | + if (isVR) |
---|
| 14741 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14742 | + else |
---|
| 14743 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14744 | + } |
---|
14230 | 14745 | else |
---|
14231 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14232 | | - */ |
---|
| 14746 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14747 | + /**/ |
---|
14233 | 14748 | if ((mod & SHIFT) == SHIFT) |
---|
14234 | 14749 | { |
---|
14235 | 14750 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14238 | 14753 | mouseMode |= BACKFORTH; |
---|
14239 | 14754 | } |
---|
14240 | 14755 | |
---|
| 14756 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14757 | + |
---|
14241 | 14758 | //prevX = X = anchorX; |
---|
14242 | 14759 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14243 | 14760 | } |
---|
.. | .. |
---|
14245 | 14762 | void GoUp(int mod) |
---|
14246 | 14763 | { |
---|
14247 | 14764 | MODIFIERS |= COMMAND; |
---|
14248 | | - /* |
---|
| 14765 | + /**/ |
---|
| 14766 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14767 | + |
---|
14249 | 14768 | if((mod&SHIFT) == SHIFT) |
---|
14250 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14769 | + { |
---|
| 14770 | + if (isVR) |
---|
| 14771 | + manipCamera.RotateInterest(0, speed); |
---|
| 14772 | + else |
---|
| 14773 | + manipCamera.RotatePosition(0, speed); |
---|
| 14774 | + } |
---|
14251 | 14775 | else |
---|
14252 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14253 | | - */ |
---|
| 14776 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14777 | + /**/ |
---|
14254 | 14778 | if ((mod & SHIFT) == SHIFT) |
---|
14255 | 14779 | { |
---|
14256 | 14780 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14259 | 14783 | mouseMode |= BACKFORTH; |
---|
14260 | 14784 | } |
---|
14261 | 14785 | |
---|
| 14786 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14787 | + |
---|
14262 | 14788 | //prevX = X = anchorX; |
---|
14263 | 14789 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14264 | 14790 | } |
---|
.. | .. |
---|
14266 | 14792 | void GoLeft(int mod) |
---|
14267 | 14793 | { |
---|
14268 | 14794 | MODIFIERS |= COMMAND; |
---|
14269 | | - /* |
---|
| 14795 | + /**/ |
---|
14270 | 14796 | if((mod&SHIFT) == SHIFT) |
---|
14271 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14797 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14272 | 14798 | else |
---|
14273 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14274 | | - */ |
---|
| 14799 | + { |
---|
| 14800 | + if ((mouseMode&VR)!=0) |
---|
| 14801 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14802 | + else |
---|
| 14803 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14804 | + } |
---|
| 14805 | + /**/ |
---|
14275 | 14806 | if ((mod & SHIFT) == SHIFT) |
---|
14276 | 14807 | { |
---|
14277 | 14808 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14280 | 14811 | mouseMode |= ROTATE; |
---|
14281 | 14812 | } // TRANSLATE; |
---|
14282 | 14813 | |
---|
| 14814 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14815 | + |
---|
14283 | 14816 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14284 | 14817 | prevY = Y = anchorY; |
---|
14285 | 14818 | } |
---|
.. | .. |
---|
14287 | 14820 | void GoRight(int mod) |
---|
14288 | 14821 | { |
---|
14289 | 14822 | MODIFIERS |= COMMAND; |
---|
14290 | | - /* |
---|
| 14823 | + /**/ |
---|
14291 | 14824 | if((mod&SHIFT) == SHIFT) |
---|
14292 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14825 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14293 | 14826 | else |
---|
14294 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14295 | | - */ |
---|
| 14827 | + { |
---|
| 14828 | + if ((mouseMode&VR)!=0) |
---|
| 14829 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14830 | + else |
---|
| 14831 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14832 | + } |
---|
| 14833 | + |
---|
| 14834 | + /**/ |
---|
14296 | 14835 | if ((mod & SHIFT) == SHIFT) |
---|
14297 | 14836 | { |
---|
14298 | 14837 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14301 | 14840 | mouseMode |= ROTATE; |
---|
14302 | 14841 | } // TRANSLATE; |
---|
14303 | 14842 | |
---|
| 14843 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14844 | + |
---|
14304 | 14845 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14305 | 14846 | prevY = Y = anchorY; |
---|
14306 | 14847 | } |
---|
.. | .. |
---|
14342 | 14883 | if (editObj) |
---|
14343 | 14884 | { |
---|
14344 | 14885 | drag = true; |
---|
14345 | | - ClickInfo info = new ClickInfo(); |
---|
14346 | | - info.bounds.setBounds(0, 0, |
---|
| 14886 | + //ClickInfo info = new ClickInfo(); |
---|
| 14887 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14347 | 14888 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14348 | | - info.pane = this; |
---|
14349 | | - info.camera = renderCamera; |
---|
14350 | | - info.x = x; |
---|
14351 | | - info.y = y; |
---|
14352 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14889 | + object.clickInfo.pane = this; |
---|
| 14890 | + object.clickInfo.camera = renderCamera; |
---|
| 14891 | + object.clickInfo.x = x; |
---|
| 14892 | + object.clickInfo.y = y; |
---|
| 14893 | + object //.GetWindow().copy |
---|
| 14894 | + .doEditDrag(//info, |
---|
| 14895 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14353 | 14896 | } else |
---|
14354 | 14897 | { |
---|
14355 | 14898 | if (x < startX) |
---|
.. | .. |
---|
14498 | 15041 | } |
---|
14499 | 15042 | } |
---|
14500 | 15043 | |
---|
| 15044 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15045 | + |
---|
14501 | 15046 | public void mouseMoved(MouseEvent e) |
---|
14502 | 15047 | { |
---|
14503 | 15048 | //System.out.println("mouseMoved: " + e); |
---|
14504 | 15049 | if (isRenderer) |
---|
14505 | 15050 | return; |
---|
14506 | 15051 | |
---|
14507 | | - ClickInfo ci = new ClickInfo(); |
---|
14508 | | - ci.x = e.getX(); |
---|
14509 | | - ci.y = e.getY(); |
---|
14510 | | - ci.modifiers = e.getModifiersEx(); |
---|
14511 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14512 | | - ci.pane = this; |
---|
14513 | | - ci.camera = renderCamera; |
---|
| 15052 | + // Mouse cursor feedback |
---|
| 15053 | + object.clickInfo.x = e.getX(); |
---|
| 15054 | + object.clickInfo.y = e.getY(); |
---|
| 15055 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15056 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15057 | + object.clickInfo.pane = this; |
---|
| 15058 | + object.clickInfo.camera = renderCamera; |
---|
14514 | 15059 | if (!isRenderer) |
---|
14515 | 15060 | { |
---|
14516 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 15061 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15062 | + //Object3D copy = editWindow.copy; |
---|
| 15063 | + if (object.doEditClick(//clickInfo, |
---|
| 15064 | + 0)) |
---|
14517 | 15065 | { |
---|
14518 | 15066 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14519 | 15067 | } else |
---|
.. | .. |
---|
14528 | 15076 | Globals.MOUSEDRAGGED = false; |
---|
14529 | 15077 | |
---|
14530 | 15078 | movingcamera = false; |
---|
14531 | | - X = Y = 0; |
---|
| 15079 | + X = 0; // getBounds().width/2; |
---|
| 15080 | + Y = 0; // getBounds().height/2; |
---|
14532 | 15081 | //System.out.println("mouseReleased: " + e); |
---|
14533 | 15082 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14534 | 15083 | } |
---|
.. | .. |
---|
14784 | 15333 | // break; |
---|
14785 | 15334 | case 'T': |
---|
14786 | 15335 | CACHETEXTURE ^= true; |
---|
14787 | | - textures.clear(); |
---|
| 15336 | + texturepigment.clear(); |
---|
| 15337 | + texturebump.clear(); |
---|
14788 | 15338 | // repaint(); |
---|
14789 | 15339 | break; |
---|
14790 | 15340 | case 'Y': |
---|
.. | .. |
---|
14794 | 15344 | case 'K': |
---|
14795 | 15345 | KOMPACTTEXTURE ^= true; |
---|
14796 | 15346 | //textures.clear(); |
---|
14797 | | - break; |
---|
14798 | | - case 'P': // Texture Projection macros |
---|
| 15347 | + // break; |
---|
| 15348 | + //case 'P': // Texture Projection macros |
---|
14799 | 15349 | // SAVETEXTURE ^= true; |
---|
14800 | 15350 | macromode = true; |
---|
14801 | 15351 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
14869 | 15419 | case 'E' : COMPACT ^= true; |
---|
14870 | 15420 | repaint(); |
---|
14871 | 15421 | break; |
---|
14872 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15422 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15423 | + //DEBUGHSB ^= true; |
---|
| 15424 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14873 | 15425 | repaint(); |
---|
14874 | 15426 | break; |
---|
14875 | 15427 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14894 | 15446 | RevertCamera(); |
---|
14895 | 15447 | repaint(); |
---|
14896 | 15448 | break; |
---|
14897 | | - case 'L': |
---|
14898 | 15449 | case 'l': |
---|
| 15450 | + //case 'L': |
---|
14899 | 15451 | if (lightMode) |
---|
14900 | 15452 | { |
---|
14901 | 15453 | lightMode = false; |
---|
.. | .. |
---|
14914 | 15466 | targetLookAt.set(manipCamera.lookAt); |
---|
14915 | 15467 | repaint(); |
---|
14916 | 15468 | break; |
---|
14917 | | - case 'p': |
---|
| 15469 | + case 'P': // p': |
---|
14918 | 15470 | // c'est quoi ca au juste? spherical ^= true; |
---|
14919 | 15471 | Skinshader ^= true; programInitialized = false; |
---|
14920 | 15472 | repaint(); |
---|
.. | .. |
---|
14959 | 15511 | OCCLUSION_CULLING ^= true; |
---|
14960 | 15512 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14961 | 15513 | break; |
---|
14962 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15514 | + //case '0': envyoff ^= true; repaint(); break; |
---|
14963 | 15515 | case '1': |
---|
14964 | 15516 | case '2': |
---|
14965 | 15517 | case '3': |
---|
14966 | 15518 | case '4': |
---|
14967 | 15519 | case '5': |
---|
14968 | | - newenvy = Character.getNumericValue(key); |
---|
14969 | | - repaint(); |
---|
14970 | | - break; |
---|
14971 | 15520 | case '6': |
---|
14972 | 15521 | case '7': |
---|
14973 | 15522 | case '8': |
---|
14974 | 15523 | case '9': |
---|
14975 | | - BGcolor = (key - '6')/3.f; |
---|
| 15524 | + if (true) // envyoff) |
---|
| 15525 | + { |
---|
| 15526 | + BGcolor = (key - '1')/8.f; |
---|
| 15527 | + } |
---|
| 15528 | + else |
---|
| 15529 | + { |
---|
| 15530 | + //newenvy = Character.getNumericValue(key); |
---|
| 15531 | + } |
---|
14976 | 15532 | repaint(); |
---|
14977 | 15533 | break; |
---|
14978 | 15534 | case '!': |
---|
.. | .. |
---|
15038 | 15594 | case '_': |
---|
15039 | 15595 | kompactbit = 5; |
---|
15040 | 15596 | break; |
---|
15041 | | - case '+': |
---|
15042 | | - kompactbit = 6; |
---|
15043 | | - break; |
---|
| 15597 | +// case '+': |
---|
| 15598 | +// kompactbit = 6; |
---|
| 15599 | +// break; |
---|
15044 | 15600 | case ' ': |
---|
15045 | 15601 | lightMode ^= true; |
---|
15046 | 15602 | Globals.lighttouched = true; |
---|
.. | .. |
---|
15052 | 15608 | case ESC: |
---|
15053 | 15609 | RENDERPROGRAM += 1; |
---|
15054 | 15610 | RENDERPROGRAM %= 3; |
---|
| 15611 | + |
---|
15055 | 15612 | repaint(); |
---|
15056 | 15613 | break; |
---|
15057 | 15614 | case 'Z': |
---|
.. | .. |
---|
15091 | 15648 | case DELETE: |
---|
15092 | 15649 | ClearSelection(); |
---|
15093 | 15650 | break; |
---|
15094 | | - /* |
---|
15095 | 15651 | case '+': |
---|
| 15652 | + |
---|
| 15653 | + /* |
---|
15096 | 15654 | //fontsize += 1; |
---|
15097 | 15655 | bbzoom *= 2; |
---|
15098 | 15656 | repaint(); |
---|
.. | .. |
---|
15109 | 15667 | case '=': |
---|
15110 | 15668 | IncDepth(); |
---|
15111 | 15669 | //fontsize += 1; |
---|
15112 | | - object.editWindow.refreshContents(true); |
---|
| 15670 | + object.GetWindow().refreshContents(true); |
---|
15113 | 15671 | maskbit = 6; |
---|
15114 | 15672 | break; |
---|
15115 | 15673 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15116 | 15674 | DecDepth(); |
---|
15117 | 15675 | maskbit = 5; |
---|
15118 | 15676 | //if(fontsize > 1) fontsize -= 1; |
---|
15119 | | - if (object.editWindow == null) |
---|
15120 | | - new Exception().printStackTrace(); |
---|
15121 | | - else |
---|
15122 | | - object.editWindow.refreshContents(true); |
---|
| 15677 | +// if (object.editWindow == null) |
---|
| 15678 | +// new Exception().printStackTrace(); |
---|
| 15679 | +// else |
---|
| 15680 | + object.GetWindow().refreshContents(true); |
---|
15123 | 15681 | break; |
---|
15124 | 15682 | case '{': |
---|
15125 | 15683 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15343 | 15901 | } |
---|
15344 | 15902 | */ |
---|
15345 | 15903 | |
---|
15346 | | - object.editWindow.EditSelection(); |
---|
| 15904 | + object.GetWindow().EditSelection(false); |
---|
15347 | 15905 | } |
---|
15348 | 15906 | |
---|
15349 | 15907 | void SelectParent() |
---|
.. | .. |
---|
15360 | 15918 | { |
---|
15361 | 15919 | //selectees.remove(i); |
---|
15362 | 15920 | System.out.println("select parent of " + elem); |
---|
15363 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15921 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15364 | 15922 | } else |
---|
15365 | 15923 | { |
---|
15366 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15924 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15367 | 15925 | } |
---|
15368 | 15926 | |
---|
15369 | 15927 | first = false; |
---|
.. | .. |
---|
15405 | 15963 | for (int j = 0; j < group.children.size(); j++) |
---|
15406 | 15964 | { |
---|
15407 | 15965 | elem = (Object3D) group.children.elementAt(j); |
---|
15408 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15966 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15409 | 15967 | first = false; |
---|
15410 | 15968 | } |
---|
15411 | 15969 | } else |
---|
15412 | 15970 | { |
---|
15413 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15971 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15414 | 15972 | } |
---|
15415 | 15973 | |
---|
15416 | 15974 | first = false; |
---|
.. | .. |
---|
15421 | 15979 | { |
---|
15422 | 15980 | //Composite group = (Composite) object; |
---|
15423 | 15981 | Object3D group = object; |
---|
15424 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15982 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15425 | 15983 | } |
---|
15426 | 15984 | |
---|
15427 | 15985 | void ResetTransform(int mask) |
---|
15428 | 15986 | { |
---|
15429 | 15987 | //Composite group = (Composite) object; |
---|
15430 | 15988 | Object3D group = object; |
---|
15431 | | - group.editWindow.ResetTransform(mask); |
---|
| 15989 | + group.GetWindow().ResetTransform(mask); |
---|
15432 | 15990 | } |
---|
15433 | 15991 | |
---|
15434 | 15992 | void FlipTransform() |
---|
15435 | 15993 | { |
---|
15436 | 15994 | //Composite group = (Composite) object; |
---|
15437 | 15995 | Object3D group = object; |
---|
15438 | | - group.editWindow.FlipTransform(); |
---|
| 15996 | + group.GetWindow().FlipTransform(); |
---|
15439 | 15997 | // group.editWindow.ReduceMesh(true); |
---|
15440 | 15998 | } |
---|
15441 | 15999 | |
---|
.. | .. |
---|
15443 | 16001 | { |
---|
15444 | 16002 | //Composite group = (Composite) object; |
---|
15445 | 16003 | Object3D group = object; |
---|
15446 | | - group.editWindow.PrintMemory(); |
---|
| 16004 | + group.GetWindow().PrintMemory(); |
---|
15447 | 16005 | // group.editWindow.ReduceMesh(true); |
---|
15448 | 16006 | } |
---|
15449 | 16007 | |
---|
.. | .. |
---|
15451 | 16009 | { |
---|
15452 | 16010 | //Composite group = (Composite) object; |
---|
15453 | 16011 | Object3D group = object; |
---|
15454 | | - group.editWindow.ResetCentroid(); |
---|
| 16012 | + group.GetWindow().ResetCentroid(); |
---|
15455 | 16013 | } |
---|
15456 | 16014 | |
---|
15457 | 16015 | void IncDepth() |
---|
.. | .. |
---|
15533 | 16091 | |
---|
15534 | 16092 | int width = getBounds().width; |
---|
15535 | 16093 | int height = getBounds().height; |
---|
15536 | | - ClickInfo info = new ClickInfo(); |
---|
15537 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15538 | 16094 | //Image img = CreateImage(width, height); |
---|
15539 | 16095 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15540 | 16096 | |
---|
.. | .. |
---|
15611 | 16167 | } |
---|
15612 | 16168 | if (object != null && !hasMarquee) |
---|
15613 | 16169 | { |
---|
| 16170 | + if (object.clickInfo == null) |
---|
| 16171 | + object.clickInfo = new ClickInfo(); |
---|
| 16172 | + ClickInfo info = object.clickInfo; |
---|
| 16173 | + //ClickInfo info = new ClickInfo(); |
---|
| 16174 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16175 | + |
---|
15614 | 16176 | if (isRenderer) |
---|
15615 | 16177 | { |
---|
15616 | | - info.flags++; |
---|
| 16178 | + object.clickInfo.flags++; |
---|
15617 | 16179 | double frameAspect = (double) width / (double) height; |
---|
15618 | 16180 | if (frameAspect > renderCamera.aspect) |
---|
15619 | 16181 | { |
---|
15620 | 16182 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15621 | | - info.bounds.width -= width - desired; |
---|
15622 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16183 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16184 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15623 | 16185 | } else |
---|
15624 | 16186 | { |
---|
15625 | 16187 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15626 | | - info.bounds.height -= height - desired; |
---|
15627 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16188 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16189 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15628 | 16190 | } |
---|
15629 | 16191 | } |
---|
15630 | | - info.g = gr; |
---|
15631 | | - info.camera = renderCamera; |
---|
| 16192 | + |
---|
| 16193 | + object.clickInfo.g = gr; |
---|
| 16194 | + object.clickInfo.camera = renderCamera; |
---|
15632 | 16195 | /* |
---|
15633 | 16196 | // Memory intensive (brep.verticescopy) |
---|
15634 | 16197 | if (!(object instanceof Composite)) |
---|
15635 | 16198 | object.draw(info, 0, false); // SLOW : |
---|
15636 | 16199 | */ |
---|
15637 | | - if (!isRenderer) |
---|
| 16200 | + if (!isRenderer) // && drag) |
---|
15638 | 16201 | { |
---|
15639 | | - object.drawEditHandles(info, 0); |
---|
15640 | | - |
---|
15641 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16202 | + Grafreed.Assert(object != null); |
---|
| 16203 | + Grafreed.Assert(object.selection != null); |
---|
| 16204 | + if (object.selection.Size() > 0) |
---|
15642 | 16205 | { |
---|
15643 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16206 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16207 | + |
---|
| 16208 | + object.clickInfo.DX = 0; |
---|
| 16209 | + object.clickInfo.DY = 0; |
---|
| 16210 | + object.clickInfo.W = 1; |
---|
| 16211 | + if (hitSomething == Object3D.hitCenter) |
---|
15644 | 16212 | { |
---|
15645 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15646 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15647 | | - break; |
---|
15648 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15649 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15650 | | - break; |
---|
15651 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15652 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15653 | | - break; |
---|
| 16213 | + info.DX = X; |
---|
| 16214 | + if (X != 0) |
---|
| 16215 | + info.DX -= info.bounds.width/2; |
---|
| 16216 | + |
---|
| 16217 | + info.DY = Y; |
---|
| 16218 | + if (Y != 0) |
---|
| 16219 | + info.DY -= info.bounds.height/2; |
---|
15654 | 16220 | } |
---|
15655 | | - |
---|
| 16221 | + |
---|
| 16222 | + object.drawEditHandles(//info, |
---|
| 16223 | + 0); |
---|
| 16224 | + |
---|
| 16225 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16226 | + { |
---|
| 16227 | + switch (hitSomething) |
---|
| 16228 | + { |
---|
| 16229 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16230 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16231 | + break; |
---|
| 16232 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16233 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16234 | + break; |
---|
| 16235 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16236 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16237 | + break; |
---|
| 16238 | + } |
---|
| 16239 | + |
---|
| 16240 | + } |
---|
15656 | 16241 | } |
---|
15657 | 16242 | } |
---|
15658 | 16243 | } |
---|
.. | .. |
---|
15667 | 16252 | if (hasMarquee) |
---|
15668 | 16253 | { |
---|
15669 | 16254 | gr.setXORMode(Color.white); |
---|
15670 | | - gr.setColor(Color.red); |
---|
| 16255 | + gr.setColor(Color.white); |
---|
15671 | 16256 | if (!firstime) |
---|
15672 | 16257 | { |
---|
15673 | 16258 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16134 | 16719 | private /*static*/ boolean firstime; |
---|
16135 | 16720 | private /*static*/ cVector newView = new cVector(); |
---|
16136 | 16721 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16722 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16723 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16137 | 16724 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16138 | 16725 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16139 | 16726 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16146 | 16733 | { |
---|
16147 | 16734 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16148 | 16735 | |
---|
| 16736 | + int usedsuf = 0; |
---|
| 16737 | + |
---|
16149 | 16738 | for (int i = 0; i < suffixes.length; i++) |
---|
16150 | 16739 | { |
---|
16151 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16152 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16153 | | - mipmapped, |
---|
16154 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16155 | | - if (data == null) |
---|
| 16740 | + String[] suffixe = suffixes; |
---|
| 16741 | + String[] fallback = suffixes2; |
---|
| 16742 | + String[] fallfallback = suffixes3; |
---|
| 16743 | + |
---|
| 16744 | + for (int c=usedsuf; --c>=0;) |
---|
16156 | 16745 | { |
---|
16157 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16746 | +// String[] temp = suffixe; |
---|
| 16747 | +// suffixe = fallback; |
---|
| 16748 | +// fallback = fallfallback; |
---|
| 16749 | +// fallfallback = temp; |
---|
16158 | 16750 | } |
---|
| 16751 | + |
---|
| 16752 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16753 | + TextureData data; |
---|
| 16754 | + |
---|
| 16755 | + try |
---|
| 16756 | + { |
---|
| 16757 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16758 | + mipmapped, |
---|
| 16759 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16760 | + } |
---|
| 16761 | + catch (Exception e) |
---|
| 16762 | + { |
---|
| 16763 | + try |
---|
| 16764 | + { |
---|
| 16765 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16766 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16767 | + mipmapped, |
---|
| 16768 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16769 | + } |
---|
| 16770 | + catch (Exception e2) |
---|
| 16771 | + { |
---|
| 16772 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16773 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16774 | + mipmapped, |
---|
| 16775 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16776 | + } |
---|
| 16777 | + } |
---|
| 16778 | + |
---|
16159 | 16779 | //System.out.println("Target = " + targets[i]); |
---|
16160 | 16780 | cubemap.updateImage(data, targets[i]); |
---|
16161 | 16781 | } |
---|
16162 | 16782 | |
---|
16163 | 16783 | return cubemap; |
---|
16164 | 16784 | } |
---|
| 16785 | + |
---|
16165 | 16786 | int bigsphere = -1; |
---|
16166 | 16787 | |
---|
16167 | 16788 | float BGcolor = 0.5f; |
---|
16168 | 16789 | |
---|
16169 | | - private void DrawSkyBox(GL gl) |
---|
| 16790 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16791 | + |
---|
| 16792 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16170 | 16793 | { |
---|
16171 | | - if (envyoff || cubemap == null) |
---|
| 16794 | + if (//envyoff || |
---|
| 16795 | + WIREFRAME || |
---|
| 16796 | + cubemap == null) |
---|
16172 | 16797 | { |
---|
16173 | 16798 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16174 | 16799 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16183 | 16808 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16184 | 16809 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16185 | 16810 | gl.glLoadIdentity(); |
---|
| 16811 | + gl.glScalef(1,ratio,1); |
---|
16186 | 16812 | |
---|
| 16813 | +// colorV[0] = 2; |
---|
| 16814 | +// colorV[1] = 2; |
---|
| 16815 | +// colorV[2] = 2; |
---|
| 16816 | +// colorV[3] = 1; |
---|
| 16817 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16818 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16819 | +// |
---|
| 16820 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16821 | + |
---|
16187 | 16822 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16188 | 16823 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16189 | 16824 | |
---|
.. | .. |
---|
16215 | 16850 | { |
---|
16216 | 16851 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16217 | 16852 | } |
---|
| 16853 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16218 | 16854 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16219 | 16855 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16220 | 16856 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16255 | 16891 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16256 | 16892 | |
---|
16257 | 16893 | cubemap.disable(); |
---|
16258 | | - ////cubemap.unbind(); |
---|
| 16894 | + //cubemap.dispose(); |
---|
| 16895 | + |
---|
16259 | 16896 | if (CULLFACE) |
---|
16260 | 16897 | { |
---|
16261 | 16898 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16311 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16312 | 16949 | } |
---|
16313 | 16950 | |
---|
16314 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16315 | 16952 | |
---|
16316 | 16953 | float step = 2; // 0.1666f; //0.25f; |
---|
16317 | 16954 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16355 | 16992 | cStatic.objectstack[materialdepth++] = checker; |
---|
16356 | 16993 | //System.out.println("material " + material); |
---|
16357 | 16994 | //Applet3D.tracein(this, selected); |
---|
16358 | | - vector2buffer = checker.projectedVertices; |
---|
| 16995 | + //vector2buffer = checker.projectedVertices; |
---|
16359 | 16996 | |
---|
16360 | 16997 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16361 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16998 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16362 | 16999 | |
---|
16363 | 17000 | materialdepth -= 1; |
---|
16364 | 17001 | if (materialdepth > 0) |
---|
16365 | 17002 | { |
---|
16366 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16367 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 17003 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 17004 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16368 | 17005 | } |
---|
16369 | 17006 | //checker.GetMaterial().opacity = 1f; |
---|
16370 | 17007 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16450 | 17087 | } |
---|
16451 | 17088 | } |
---|
16452 | 17089 | |
---|
| 17090 | + private Object3D GetFolder() |
---|
| 17091 | + { |
---|
| 17092 | + Object3D folder = object.GetWindow().copy; |
---|
| 17093 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17094 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17095 | + return folder; |
---|
| 17096 | + } |
---|
| 17097 | + |
---|
16453 | 17098 | class SelectBuffer implements GLEventListener |
---|
16454 | 17099 | { |
---|
16455 | 17100 | |
---|
.. | .. |
---|
16465 | 17110 | //new Exception().printStackTrace(); |
---|
16466 | 17111 | System.out.println("select buffer init"); |
---|
16467 | 17112 | // Use debug pipeline |
---|
16468 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17113 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16469 | 17114 | |
---|
16470 | 17115 | GL gl = drawable.getGL(); |
---|
16471 | 17116 | |
---|
.. | .. |
---|
16529 | 17174 | |
---|
16530 | 17175 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16531 | 17176 | |
---|
| 17177 | + if (PAINTMODE) |
---|
| 17178 | + { |
---|
| 17179 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17180 | + { |
---|
| 17181 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17182 | + |
---|
| 17183 | + // Make what you paint not selectable. |
---|
| 17184 | + paintobj.ResetSelectable(); |
---|
| 17185 | + } |
---|
| 17186 | + } |
---|
| 17187 | + |
---|
16532 | 17188 | //int tmp = selection_view; |
---|
16533 | 17189 | //selection_view = -1; |
---|
16534 | 17190 | int temp = DrawMode(); |
---|
.. | .. |
---|
16540 | 17196 | // temp = DEFAULT; // patch for selection debug |
---|
16541 | 17197 | Globals.drawMode = temp; // WARNING |
---|
16542 | 17198 | |
---|
| 17199 | + if (PAINTMODE) |
---|
| 17200 | + { |
---|
| 17201 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17202 | + { |
---|
| 17203 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17204 | + |
---|
| 17205 | + // Revert. |
---|
| 17206 | + paintobj.RestoreSelectable(); |
---|
| 17207 | + } |
---|
| 17208 | + } |
---|
| 17209 | + |
---|
16543 | 17210 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16544 | 17211 | |
---|
16545 | 17212 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16587 | 17254 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16588 | 17255 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16589 | 17256 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17257 | + |
---|
| 17258 | + CreateSelectedPoint(); |
---|
16590 | 17259 | |
---|
16591 | 17260 | // Will fit the mesh !!! |
---|
16592 | 17261 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16641 | 17310 | } |
---|
16642 | 17311 | |
---|
16643 | 17312 | if (!movingcamera && !PAINTMODE) |
---|
16644 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17313 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16645 | 17314 | |
---|
16646 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17315 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16647 | 17316 | { |
---|
16648 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17317 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16649 | 17318 | |
---|
16650 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17319 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17320 | + { |
---|
| 17321 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16651 | 17322 | |
---|
16652 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16653 | | - |
---|
16654 | | - group.add(paintobj); // link |
---|
16655 | | - |
---|
16656 | | - object.editWindow.SnapObject(group); |
---|
16657 | | - |
---|
16658 | | - Object3D folder = object.editWindow.copy; |
---|
16659 | | - |
---|
16660 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16661 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16662 | | - |
---|
16663 | | - folder.add(group); |
---|
16664 | | - |
---|
16665 | | - object.editWindow.ResetModel(); |
---|
16666 | | - object.editWindow.refreshContents(); |
---|
| 17323 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17324 | + |
---|
| 17325 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17326 | + |
---|
| 17327 | + inst.add(paintobj); // link |
---|
| 17328 | + |
---|
| 17329 | + object.GetWindow().SnapObject(inst); |
---|
| 17330 | + |
---|
| 17331 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17332 | + |
---|
| 17333 | + folder.add(inst); |
---|
| 17334 | + |
---|
| 17335 | + object.GetWindow().ResetModel(); |
---|
| 17336 | + object.GetWindow().refreshContents(); |
---|
| 17337 | + } |
---|
16667 | 17338 | } |
---|
16668 | 17339 | else |
---|
16669 | 17340 | paintcount = 0; |
---|
.. | .. |
---|
16702 | 17373 | //System.out.println("objects[color] = " + objects[color]); |
---|
16703 | 17374 | //objects[color].Select(); |
---|
16704 | 17375 | indexcount = 0; |
---|
| 17376 | + ObjEditor window = object.GetWindow(); |
---|
| 17377 | + if (window != null && deselect) |
---|
| 17378 | + { |
---|
| 17379 | + window.Select(null, deselect, true); |
---|
| 17380 | + } |
---|
16705 | 17381 | object.Select(color, deselect); |
---|
16706 | 17382 | } |
---|
16707 | 17383 | |
---|
.. | .. |
---|
16752 | 17428 | |
---|
16753 | 17429 | public void init(GLAutoDrawable drawable) |
---|
16754 | 17430 | { |
---|
| 17431 | + if (Globals.DEBUG) |
---|
16755 | 17432 | System.out.println("shadow buffer init"); |
---|
16756 | 17433 | |
---|
16757 | 17434 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
16980 | 17657 | gl.glFlush(); |
---|
16981 | 17658 | |
---|
16982 | 17659 | /**/ |
---|
16983 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17660 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
16984 | 17661 | |
---|
16985 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17662 | + float[] depths = occlusiondepthbuffer.array(); |
---|
16986 | 17663 | |
---|
| 17664 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17665 | + |
---|
| 17666 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17667 | + |
---|
16987 | 17668 | double r = 0, g = 0, b = 0; |
---|
16988 | 17669 | |
---|
16989 | 17670 | double count = 0; |
---|
.. | .. |
---|
16994 | 17675 | |
---|
16995 | 17676 | double FACTOR = 1; |
---|
16996 | 17677 | |
---|
16997 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17678 | + for (int i = 0; i < depths.length; i++) |
---|
16998 | 17679 | { |
---|
16999 | 17680 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17000 | 17681 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17077 | 17758 | |
---|
17078 | 17759 | double scale = ray.z; // 1; // cos |
---|
17079 | 17760 | |
---|
17080 | | - float depth = pixels[newindex]; |
---|
| 17761 | + float depth = depths[newindex]; |
---|
17081 | 17762 | |
---|
17082 | 17763 | /* |
---|
17083 | 17764 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17227 | 17908 | int AAbuffersize = 0; |
---|
17228 | 17909 | |
---|
17229 | 17910 | //double[] selectedpoint = new double[3]; |
---|
17230 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17911 | + static Superellipsoid selectedpoint; |
---|
17231 | 17912 | static Sphere previousselectedpoint = null; |
---|
17232 | | - static Sphere debugpointG = new Sphere(); |
---|
17233 | | - static Sphere debugpointP = new Sphere(); |
---|
17234 | | - static Sphere debugpointC = new Sphere(); |
---|
17235 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17913 | + static Sphere debugpointG; |
---|
| 17914 | + static Sphere debugpointP; |
---|
| 17915 | + static Sphere debugpointC; |
---|
| 17916 | + static Sphere debugpointR; |
---|
17236 | 17917 | |
---|
17237 | 17918 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17238 | 17919 | |
---|
17239 | | - static |
---|
17240 | | - { |
---|
17241 | | - for (int i=0; i<8; i++) |
---|
17242 | | - { |
---|
17243 | | - debugpoints[i] = new Sphere(); |
---|
17244 | | - } |
---|
17245 | | - } |
---|
17246 | | - |
---|
17247 | 17920 | static void InitPoints(float radius) |
---|
17248 | 17921 | { |
---|
17249 | 17922 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
17282 | 17955 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17283 | 17956 | static IntBuffer bigAAbuffer; |
---|
17284 | 17957 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17285 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17958 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17286 | 17959 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17287 | 17960 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17288 | 17961 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17289 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17962 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17963 | + |
---|
| 17964 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17965 | + |
---|
17290 | 17966 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17291 | 17967 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17292 | 17968 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|