.. | .. |
---|
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; |
---|
.. | .. |
---|
56 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 95 | |
---|
62 | 96 | boolean DISPLAYTEXT = false; |
---|
63 | 97 | //boolean REDUCETEXTURE = true; |
---|
64 | 98 | boolean CACHETEXTURE = true; |
---|
65 | 99 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
67 | 101 | boolean COMPRESSTEXTURE = false; |
---|
68 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
92 | 126 | |
---|
93 | 127 | static int tickcount = 0; // slow pose issue |
---|
94 | 128 | |
---|
| 129 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 130 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 131 | static boolean BOXMODE = false; |
---|
96 | 132 | static boolean IMAGEFLIP = false; |
---|
97 | 133 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 142 | static boolean OEIL = true; |
---|
107 | 143 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 144 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 145 | +static boolean SWITCH = true; // false; |
---|
110 | 146 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 147 | static boolean PAINTMODE = false; |
---|
112 | 148 | |
---|
.. | .. |
---|
149 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
152 | | - static CameraPane theRenderer; |
---|
153 | | - |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 190 | + |
---|
154 | 191 | void SetAsGLRenderer(boolean b) |
---|
155 | 192 | { |
---|
156 | 193 | isRenderer = b; |
---|
157 | | - theRenderer = this; |
---|
| 194 | + Globals.theRenderer = this; |
---|
158 | 195 | } |
---|
159 | 196 | |
---|
160 | 197 | CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
.. | .. |
---|
169 | 206 | |
---|
170 | 207 | SetCamera(cam); |
---|
171 | 208 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 209 | + // Warning: not used. |
---|
| 210 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 211 | |
---|
174 | 212 | object = o; |
---|
175 | 213 | |
---|
.. | .. |
---|
192 | 230 | |
---|
193 | 231 | /// INTERFACE |
---|
194 | 232 | |
---|
| 233 | + public javax.media.opengl.GL GetGL0() |
---|
| 234 | + { |
---|
| 235 | + return null; |
---|
| 236 | + } |
---|
| 237 | + |
---|
| 238 | + public int GenList() |
---|
| 239 | + { |
---|
| 240 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 241 | + return gl.glGenLists(1); |
---|
| 242 | + } |
---|
| 243 | + |
---|
| 244 | + public void NewList(int id) |
---|
| 245 | + { |
---|
| 246 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 247 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 248 | + } |
---|
| 249 | + |
---|
| 250 | + public void CallList(int id) |
---|
| 251 | + { |
---|
| 252 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 253 | + gl.glCallList(id); |
---|
| 254 | + } |
---|
| 255 | + |
---|
| 256 | + public void EndList() |
---|
| 257 | + { |
---|
| 258 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 259 | + gl.glEndList(); |
---|
| 260 | + } |
---|
| 261 | + |
---|
195 | 262 | public boolean IsBoxMode() |
---|
196 | 263 | { |
---|
197 | 264 | return BOXMODE; |
---|
| 265 | + } |
---|
| 266 | + |
---|
| 267 | + public boolean IsZoomBoxMode() |
---|
| 268 | + { |
---|
| 269 | + return ZOOMBOXMODE; |
---|
198 | 270 | } |
---|
199 | 271 | |
---|
200 | 272 | public void ClearDepth() |
---|
.. | .. |
---|
236 | 308 | return this.ambientOcclusion; |
---|
237 | 309 | } |
---|
238 | 310 | |
---|
| 311 | + public boolean IsDebugSelection() |
---|
| 312 | + { |
---|
| 313 | + return DEBUG_SELECTION; |
---|
| 314 | + } |
---|
| 315 | + |
---|
239 | 316 | public boolean IsFrozen() |
---|
240 | 317 | { |
---|
241 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 318 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
242 | 319 | |
---|
243 | 320 | return !selectmode && cameracount == 0; // != 0; |
---|
244 | 321 | } |
---|
.. | .. |
---|
259 | 336 | return lightCamera; |
---|
260 | 337 | } |
---|
261 | 338 | |
---|
| 339 | + public Camera ManipCamera() |
---|
| 340 | + { |
---|
| 341 | + return manipCamera; |
---|
| 342 | + } |
---|
| 343 | + |
---|
262 | 344 | public Camera RenderCamera() |
---|
263 | 345 | { |
---|
264 | 346 | return renderCamera; |
---|
| 347 | + } |
---|
| 348 | + |
---|
| 349 | + public Camera[] Cameras() |
---|
| 350 | + { |
---|
| 351 | + return cameras; |
---|
265 | 352 | } |
---|
266 | 353 | |
---|
267 | 354 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
277 | 364 | cStatic.objectstack[materialdepth++] = obj; |
---|
278 | 365 | //System.out.println("material " + material); |
---|
279 | 366 | //Applet3D.tracein(this, selected); |
---|
280 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 367 | + //display.vector2buffer = obj.projectedVertices; |
---|
281 | 368 | if (obj instanceof Camera) |
---|
282 | 369 | { |
---|
283 | 370 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
286 | 373 | display.options1[2] = material.shadowbias; |
---|
287 | 374 | display.options1[3] = material.aniso; |
---|
288 | 375 | display.options1[4] = material.anisoV; |
---|
| 376 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 377 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 378 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 379 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 380 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
289 | 381 | display.options2[0] = material.opacity; |
---|
290 | 382 | display.options2[1] = material.diffuse; |
---|
291 | 383 | display.options2[2] = material.factor; |
---|
| 384 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 385 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 386 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
292 | 387 | |
---|
293 | 388 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 389 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 390 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 391 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
294 | 392 | display.options4[0] = material.cameralight/0.2f; |
---|
295 | 393 | display.options4[1] = material.subsurface; |
---|
296 | 394 | display.options4[2] = material.sheen; |
---|
| 395 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 396 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 397 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
297 | 398 | |
---|
298 | 399 | // if (display.CURRENTANTIALIAS > 0) |
---|
299 | 400 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
309 | 410 | /**/ |
---|
310 | 411 | } else |
---|
311 | 412 | { |
---|
312 | | - DrawMaterial(material, selected); |
---|
| 413 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
313 | 414 | } |
---|
314 | 415 | } else |
---|
315 | 416 | { |
---|
.. | .. |
---|
333 | 434 | cStatic.objectstack[materialdepth++] = obj; |
---|
334 | 435 | //System.out.println("material " + material); |
---|
335 | 436 | //Applet3D.tracein("selected ", selected); |
---|
336 | | - display.vector2buffer = obj.projectedVertices; |
---|
337 | | - display.DrawMaterial(material, selected); |
---|
| 437 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 438 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
338 | 439 | } |
---|
339 | 440 | } |
---|
340 | 441 | |
---|
.. | .. |
---|
351 | 452 | materialdepth -= 1; |
---|
352 | 453 | if (materialdepth > 0) |
---|
353 | 454 | { |
---|
354 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
355 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 455 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 456 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
356 | 457 | } |
---|
357 | 458 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
358 | 459 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
372 | 473 | materialdepth -= 1; |
---|
373 | 474 | if (materialdepth > 0) |
---|
374 | 475 | { |
---|
375 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
376 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 476 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 477 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
377 | 478 | } |
---|
378 | 479 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
379 | 480 | //else |
---|
.. | .. |
---|
408 | 509 | |
---|
409 | 510 | javax.media.opengl.GL gl = display.GetGL(); |
---|
410 | 511 | |
---|
411 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 512 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
412 | 513 | |
---|
413 | 514 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
414 | 515 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
415 | 516 | { |
---|
416 | 517 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
417 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 518 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 519 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 520 | + ; |
---|
418 | 521 | if (!hasnorm) |
---|
419 | 522 | { |
---|
420 | | - // System.out.println("FUCK!!"); |
---|
| 523 | + // System.out.println("Mesh normal"); |
---|
421 | 524 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
422 | 525 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
423 | 526 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
760 | 863 | //// tris.postdraw(this); |
---|
761 | 864 | } |
---|
762 | 865 | |
---|
| 866 | + static Camera localcamera = new Camera(); |
---|
| 867 | + static cVector from = new cVector(); |
---|
| 868 | + static cVector to = new cVector(); |
---|
| 869 | + |
---|
| 870 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 871 | + { |
---|
| 872 | + CameraPane cp = this; |
---|
| 873 | + |
---|
| 874 | + Camera keep = cp.RenderCamera(); |
---|
| 875 | + cp.renderCamera = localcamera; |
---|
| 876 | + |
---|
| 877 | + if (br.trimmed) |
---|
| 878 | + { |
---|
| 879 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 880 | + |
---|
| 881 | + int i3 = 0; |
---|
| 882 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 883 | + { |
---|
| 884 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 885 | + continue; |
---|
| 886 | + |
---|
| 887 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 888 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 889 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 890 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 891 | + LA.xformPos(from, transform, from); |
---|
| 892 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 893 | + localcamera.setAim(from, to); |
---|
| 894 | + |
---|
| 895 | + CameraPane.occlusionbuffer.display(); |
---|
| 896 | + |
---|
| 897 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 898 | + cp.display(); // debug |
---|
| 899 | + |
---|
| 900 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 901 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 902 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 903 | + |
---|
| 904 | + if ((i % 100) == 0 && i != 0) |
---|
| 905 | + { |
---|
| 906 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 907 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 908 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 909 | + } |
---|
| 910 | + } |
---|
| 911 | + |
---|
| 912 | + br.colors = colors; |
---|
| 913 | + } |
---|
| 914 | + else |
---|
| 915 | + { |
---|
| 916 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 917 | + { |
---|
| 918 | + Vertex v = br.GetVertex(i); |
---|
| 919 | + |
---|
| 920 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 921 | + continue; |
---|
| 922 | + |
---|
| 923 | + from.set(v.x, v.y, v.z); |
---|
| 924 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 925 | + LA.xformPos(from, transform, from); |
---|
| 926 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 927 | + localcamera.setAim(from, to); |
---|
| 928 | + |
---|
| 929 | + CameraPane.occlusionbuffer.display(); |
---|
| 930 | + |
---|
| 931 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 932 | + cp.display(); // debug |
---|
| 933 | + |
---|
| 934 | + v.AO = cp.vertexOcclusion.r; |
---|
| 935 | + |
---|
| 936 | + if ((i % 100) == 0 && i != 0) |
---|
| 937 | + { |
---|
| 938 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 939 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 940 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 941 | + } |
---|
| 942 | + } |
---|
| 943 | + } |
---|
| 944 | + |
---|
| 945 | + //System.out.println("done."); |
---|
| 946 | + |
---|
| 947 | + cp.renderCamera = keep; |
---|
| 948 | + } |
---|
| 949 | + |
---|
| 950 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 951 | + { |
---|
| 952 | + CameraPane display = this; |
---|
| 953 | + pointFlow.CreateHT(); |
---|
| 954 | + |
---|
| 955 | + float r = display.modelParams0[0]; |
---|
| 956 | + float g = display.modelParams0[1]; |
---|
| 957 | + float b = display.modelParams0[2]; |
---|
| 958 | + float opacity = display.modelParams5[1]; |
---|
| 959 | + |
---|
| 960 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 961 | + GL gl = display.GetGL(); // getGL(); |
---|
| 962 | + |
---|
| 963 | + int s = pointFlow.points.size(); |
---|
| 964 | + |
---|
| 965 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 966 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 967 | + |
---|
| 968 | + for (int i=s; --i>=0;) |
---|
| 969 | + //for (int i=0; i<s; i++) |
---|
| 970 | + { |
---|
| 971 | + cVector v = pointFlow.points.get(i); |
---|
| 972 | + |
---|
| 973 | + double mindist = Double.MAX_VALUE; |
---|
| 974 | + |
---|
| 975 | + double size = pointFlow.minimumSize; |
---|
| 976 | + |
---|
| 977 | + double distancenext = 0; |
---|
| 978 | + |
---|
| 979 | + if (i > 0) |
---|
| 980 | + { |
---|
| 981 | + cVector w = pointFlow.points.get(i-1); |
---|
| 982 | + |
---|
| 983 | + double dist = w.distance(v); |
---|
| 984 | + |
---|
| 985 | + distancenext = dist; |
---|
| 986 | + |
---|
| 987 | + if (mindist > dist) |
---|
| 988 | + { |
---|
| 989 | + mindist = dist; |
---|
| 990 | + size = mindist*pointFlow.resizefactor; |
---|
| 991 | + } |
---|
| 992 | + } |
---|
| 993 | + |
---|
| 994 | + if (i < s-1) |
---|
| 995 | + { |
---|
| 996 | + cVector w = pointFlow.points.get(i+1); |
---|
| 997 | + |
---|
| 998 | + double dist = w.distance(v); |
---|
| 999 | + |
---|
| 1000 | + if (mindist > dist) |
---|
| 1001 | + { |
---|
| 1002 | + mindist = dist; |
---|
| 1003 | + size = mindist*pointFlow.resizefactor; |
---|
| 1004 | + } |
---|
| 1005 | + } |
---|
| 1006 | + |
---|
| 1007 | + if (size < pointFlow.minimumSize) |
---|
| 1008 | + size = pointFlow.minimumSize; |
---|
| 1009 | + if (size > pointFlow.maximumSize) |
---|
| 1010 | + size = pointFlow.maximumSize; |
---|
| 1011 | + |
---|
| 1012 | + double tx = v.x; |
---|
| 1013 | + double ty = v.y; |
---|
| 1014 | + double tz = v.z; |
---|
| 1015 | + |
---|
| 1016 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1017 | + // continue; |
---|
| 1018 | + |
---|
| 1019 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1020 | + gl.glPushMatrix(); |
---|
| 1021 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1022 | + |
---|
| 1023 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1024 | + |
---|
| 1025 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1026 | + gl.glPushMatrix(); |
---|
| 1027 | + |
---|
| 1028 | + gl.glTranslated(tx,ty,tz); |
---|
| 1029 | + |
---|
| 1030 | + gl.glScaled(size,size,size); |
---|
| 1031 | + |
---|
| 1032 | +// float cr = colorBuf.get(index4); |
---|
| 1033 | +// float cg = colorBuf.get(index4+1); |
---|
| 1034 | +// float cb = colorBuf.get(index4+2); |
---|
| 1035 | +// float ca = colorBuf.get(index4+3); |
---|
| 1036 | +// |
---|
| 1037 | +// display.modelParams0[0] = r * cr; |
---|
| 1038 | +// display.modelParams0[1] = g * cg; |
---|
| 1039 | +// display.modelParams0[2] = b * cb; |
---|
| 1040 | +// |
---|
| 1041 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1042 | +// |
---|
| 1043 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1044 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1045 | +// |
---|
| 1046 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1047 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1048 | +// |
---|
| 1049 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1050 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1051 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1052 | + |
---|
| 1053 | + gl.glPopMatrix(); |
---|
| 1054 | + |
---|
| 1055 | + double step = size/4; // |
---|
| 1056 | + |
---|
| 1057 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1058 | + continue; |
---|
| 1059 | + |
---|
| 1060 | + int nbsteps = (int)(distancenext/step); |
---|
| 1061 | + |
---|
| 1062 | + step = distancenext/nbsteps; |
---|
| 1063 | + |
---|
| 1064 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1065 | + |
---|
| 1066 | + tmp.set(next); |
---|
| 1067 | + tmp.sub(v); |
---|
| 1068 | + tmp.normalize(); |
---|
| 1069 | + tmp.mul(step); |
---|
| 1070 | + |
---|
| 1071 | + // calculate next size |
---|
| 1072 | + mindist = Double.MAX_VALUE; |
---|
| 1073 | + |
---|
| 1074 | + double nextsize = pointFlow.minimumSize; |
---|
| 1075 | + |
---|
| 1076 | + if (i > 1) |
---|
| 1077 | + { |
---|
| 1078 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1079 | + |
---|
| 1080 | + double dist = w.distance(next); |
---|
| 1081 | + |
---|
| 1082 | + if (mindist > dist) |
---|
| 1083 | + { |
---|
| 1084 | + mindist = dist; |
---|
| 1085 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1086 | + } |
---|
| 1087 | + } |
---|
| 1088 | + |
---|
| 1089 | + double dist = v.distance(next); |
---|
| 1090 | + |
---|
| 1091 | + if (mindist > dist) |
---|
| 1092 | + { |
---|
| 1093 | + mindist = dist; |
---|
| 1094 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1095 | + } |
---|
| 1096 | + |
---|
| 1097 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1098 | + nextsize = pointFlow.minimumSize; |
---|
| 1099 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1100 | + nextsize = pointFlow.maximumSize; |
---|
| 1101 | + // |
---|
| 1102 | + |
---|
| 1103 | + double count = 0; |
---|
| 1104 | + |
---|
| 1105 | + while (distancenext > 0.000000001) // step |
---|
| 1106 | + { |
---|
| 1107 | + gl.glPushMatrix(); |
---|
| 1108 | + |
---|
| 1109 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1110 | + |
---|
| 1111 | + double K = count/nbsteps; |
---|
| 1112 | + |
---|
| 1113 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1114 | + |
---|
| 1115 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1116 | + |
---|
| 1117 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1118 | + |
---|
| 1119 | + count++; |
---|
| 1120 | + |
---|
| 1121 | + distancenext -= step; |
---|
| 1122 | + |
---|
| 1123 | + gl.glPopMatrix(); |
---|
| 1124 | + } |
---|
| 1125 | + |
---|
| 1126 | + if (count != nbsteps) |
---|
| 1127 | + assert(count == nbsteps); |
---|
| 1128 | + |
---|
| 1129 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1130 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1131 | + |
---|
| 1132 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1133 | + gl.glPopMatrix(); |
---|
| 1134 | + } |
---|
| 1135 | + |
---|
| 1136 | + if (!cf) |
---|
| 1137 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1138 | + |
---|
| 1139 | +// display.modelParams0[0] = r; |
---|
| 1140 | +// display.modelParams0[1] = g; |
---|
| 1141 | +// display.modelParams0[2] = b; |
---|
| 1142 | +// |
---|
| 1143 | +// display.modelParams5[1] = opacity; |
---|
| 1144 | +// |
---|
| 1145 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1146 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1147 | + |
---|
| 1148 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1149 | + } |
---|
| 1150 | + |
---|
| 1151 | + public void DrawBox(cVector min, cVector max) |
---|
| 1152 | + { |
---|
| 1153 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1154 | + gl.glBegin(gl.GL_LINES); |
---|
| 1155 | + |
---|
| 1156 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1157 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1158 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1159 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1160 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1161 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1162 | + |
---|
| 1163 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1164 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1165 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1166 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1167 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1168 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1169 | + |
---|
| 1170 | + gl.glEnd(); |
---|
| 1171 | + } |
---|
| 1172 | + |
---|
| 1173 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1174 | + { |
---|
| 1175 | + int[] strips = bRep.getRawIndices(); |
---|
| 1176 | + |
---|
| 1177 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1178 | + |
---|
| 1179 | + // TRIANGLE STRIP ARRAY |
---|
| 1180 | + if (bRep.trimmed) |
---|
| 1181 | + { |
---|
| 1182 | + float[] v = bRep.getRawVertices(); |
---|
| 1183 | + float[] n = bRep.getRawNormals(); |
---|
| 1184 | + float[] c = bRep.getRawColors(); |
---|
| 1185 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1186 | + |
---|
| 1187 | + int count2 = 0; |
---|
| 1188 | + int count3 = 0; |
---|
| 1189 | + |
---|
| 1190 | + if (n.length > 0) |
---|
| 1191 | + { |
---|
| 1192 | + for (int i = 0; i < strips.length; i++) |
---|
| 1193 | + { |
---|
| 1194 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1195 | + |
---|
| 1196 | + /* |
---|
| 1197 | + boolean locked = false; |
---|
| 1198 | + float eps = 0.1f; |
---|
| 1199 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1200 | + |
---|
| 1201 | + int dot = 0; |
---|
| 1202 | + |
---|
| 1203 | + if ((dot&1) == 0) |
---|
| 1204 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1205 | + |
---|
| 1206 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1207 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1208 | + else |
---|
| 1209 | + { |
---|
| 1210 | + locked = true; |
---|
| 1211 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1212 | + } |
---|
| 1213 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1214 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1215 | + if (hasnorm) |
---|
| 1216 | + { |
---|
| 1217 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1218 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1219 | + } |
---|
| 1220 | + |
---|
| 1221 | + if ((dot&4) == 0) |
---|
| 1222 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1223 | + |
---|
| 1224 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1225 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1226 | + else |
---|
| 1227 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1228 | + |
---|
| 1229 | + f.dot = dot; |
---|
| 1230 | + */ |
---|
| 1231 | + |
---|
| 1232 | + if (!selectmode) |
---|
| 1233 | + { |
---|
| 1234 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1235 | + { |
---|
| 1236 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1237 | + } else |
---|
| 1238 | + { |
---|
| 1239 | + gl.glNormal3f(0, 0, 1); |
---|
| 1240 | + } |
---|
| 1241 | + |
---|
| 1242 | + if (c != null) |
---|
| 1243 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1244 | + { |
---|
| 1245 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1246 | + } |
---|
| 1247 | + } |
---|
| 1248 | + |
---|
| 1249 | + if (flipV) |
---|
| 1250 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1251 | + else |
---|
| 1252 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1253 | + |
---|
| 1254 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1255 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1256 | + |
---|
| 1257 | + count2 += 2; |
---|
| 1258 | + count3 += 3; |
---|
| 1259 | + if (!selectmode) |
---|
| 1260 | + { |
---|
| 1261 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1262 | + { |
---|
| 1263 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1264 | + } else |
---|
| 1265 | + { |
---|
| 1266 | + gl.glNormal3f(0, 0, 1); |
---|
| 1267 | + } |
---|
| 1268 | + if (c != null) |
---|
| 1269 | + { |
---|
| 1270 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1271 | + } |
---|
| 1272 | + } |
---|
| 1273 | + |
---|
| 1274 | + if (flipV) |
---|
| 1275 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1276 | + else |
---|
| 1277 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1278 | + |
---|
| 1279 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1280 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1281 | + |
---|
| 1282 | + count2 += 2; |
---|
| 1283 | + count3 += 3; |
---|
| 1284 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1285 | + { |
---|
| 1286 | + //gl.glTexCoord2d(...); |
---|
| 1287 | + if (!selectmode) |
---|
| 1288 | + { |
---|
| 1289 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1290 | + { |
---|
| 1291 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1292 | + } else |
---|
| 1293 | + { |
---|
| 1294 | + gl.glNormal3f(0, 0, 1); |
---|
| 1295 | + } |
---|
| 1296 | + if (c != null) |
---|
| 1297 | + { |
---|
| 1298 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1299 | + } |
---|
| 1300 | + } |
---|
| 1301 | + |
---|
| 1302 | + if (flipV) |
---|
| 1303 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1304 | + else |
---|
| 1305 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1306 | + |
---|
| 1307 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1308 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1309 | + |
---|
| 1310 | + count2 += 2; |
---|
| 1311 | + count3 += 3; |
---|
| 1312 | + } |
---|
| 1313 | + |
---|
| 1314 | + gl.glEnd(); |
---|
| 1315 | + } |
---|
| 1316 | + } |
---|
| 1317 | + |
---|
| 1318 | + assert count3 == v.length; |
---|
| 1319 | + } |
---|
| 1320 | + else // !trimmed |
---|
| 1321 | + { |
---|
| 1322 | + int count = 0; |
---|
| 1323 | + for (int i = 0; i < strips.length; i++) |
---|
| 1324 | + { |
---|
| 1325 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1326 | + |
---|
| 1327 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1328 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1329 | + |
---|
| 1330 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1331 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1332 | + |
---|
| 1333 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1334 | + { |
---|
| 1335 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1336 | + |
---|
| 1337 | + // if (j%2 == 0) |
---|
| 1338 | + // drawFace(p, q, r, display, null); |
---|
| 1339 | + // else |
---|
| 1340 | + // drawFace(p, r, q, display, null); |
---|
| 1341 | + |
---|
| 1342 | + // p = q; |
---|
| 1343 | + // q = r; |
---|
| 1344 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1345 | + } |
---|
| 1346 | + |
---|
| 1347 | + gl.glEnd(); |
---|
| 1348 | + } |
---|
| 1349 | + } |
---|
| 1350 | + } |
---|
| 1351 | + |
---|
| 1352 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1353 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1354 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1355 | + |
---|
| 1356 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1357 | + { |
---|
| 1358 | + GL gl = GetGL(); // getGL(); |
---|
| 1359 | + |
---|
| 1360 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1361 | + |
---|
| 1362 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1363 | + |
---|
| 1364 | + gl.glLineWidth(1); |
---|
| 1365 | + gl.glColor3f(1,1,1); |
---|
| 1366 | + gl.glBegin(gl.GL_LINES); |
---|
| 1367 | + double scale = 0; |
---|
| 1368 | + int count = 0; |
---|
| 1369 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1370 | + { |
---|
| 1371 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1372 | + if(s == 0) |
---|
| 1373 | + { |
---|
| 1374 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1375 | + } |
---|
| 1376 | + if (mesh.showsprings) |
---|
| 1377 | + { |
---|
| 1378 | + temp.set(spring.a.position); |
---|
| 1379 | + temp.add(spring.b.position); |
---|
| 1380 | + temp.mul(0.5); |
---|
| 1381 | + temp2.set(spring.a.position); |
---|
| 1382 | + temp2.sub(spring.b.position); |
---|
| 1383 | + temp2.mul(spring.restLength/2); |
---|
| 1384 | + temp.sub(temp2); |
---|
| 1385 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1386 | + temp.add(temp2); |
---|
| 1387 | + temp.add(temp2); |
---|
| 1388 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1389 | + } |
---|
| 1390 | + |
---|
| 1391 | + if (spring.isHandle) |
---|
| 1392 | + continue; |
---|
| 1393 | + |
---|
| 1394 | + //if (scale < spring.restLength) |
---|
| 1395 | + scale += spring.restLength; |
---|
| 1396 | + count++; |
---|
| 1397 | + } |
---|
| 1398 | + gl.glEnd(); |
---|
| 1399 | + |
---|
| 1400 | + if (count == 0) |
---|
| 1401 | + scale = 0.01; |
---|
| 1402 | + else |
---|
| 1403 | + scale /= count * 3; |
---|
| 1404 | + |
---|
| 1405 | + //scale = 0.25; |
---|
| 1406 | + |
---|
| 1407 | + if (mesh.ShowInfo()) |
---|
| 1408 | + { |
---|
| 1409 | + gl.glLineWidth(4); |
---|
| 1410 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1411 | + { |
---|
| 1412 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1413 | + if (node.mass == 0) |
---|
| 1414 | + continue; |
---|
| 1415 | + |
---|
| 1416 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1417 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1418 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1419 | + //temp.normalize(); |
---|
| 1420 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1421 | + gl.glBegin(gl.GL_LINES); |
---|
| 1422 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1423 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1424 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1425 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1426 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1427 | + gl.glEnd(); |
---|
| 1428 | + } |
---|
| 1429 | + |
---|
| 1430 | + gl.glLineWidth(8); |
---|
| 1431 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1432 | + { |
---|
| 1433 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1434 | + |
---|
| 1435 | + if (node.springs != null) |
---|
| 1436 | + { |
---|
| 1437 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1438 | + { |
---|
| 1439 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1440 | + |
---|
| 1441 | + int c = i+1; |
---|
| 1442 | + // c = node.springs.get(i).nbcopies; |
---|
| 1443 | + |
---|
| 1444 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1445 | + gl.glBegin(gl.GL_LINES); |
---|
| 1446 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1447 | + gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3); |
---|
| 1448 | + gl.glEnd(); |
---|
| 1449 | + } |
---|
| 1450 | + } |
---|
| 1451 | + } |
---|
| 1452 | + |
---|
| 1453 | + gl.glLineWidth(1); |
---|
| 1454 | + } |
---|
| 1455 | + |
---|
| 1456 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1457 | + } |
---|
| 1458 | + |
---|
763 | 1459 | /// INTERFACE |
---|
| 1460 | + |
---|
| 1461 | + public void StartTriangles() |
---|
| 1462 | + { |
---|
| 1463 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1464 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1465 | + } |
---|
| 1466 | + |
---|
| 1467 | + public void EndTriangles() |
---|
| 1468 | + { |
---|
| 1469 | + GetGL().glEnd(); |
---|
| 1470 | + } |
---|
| 1471 | + |
---|
| 1472 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1473 | + { |
---|
| 1474 | + if (!selectmode) |
---|
| 1475 | + { |
---|
| 1476 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1477 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1478 | + |
---|
| 1479 | + if (flipV) |
---|
| 1480 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1481 | + else |
---|
| 1482 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1483 | + } |
---|
| 1484 | + |
---|
| 1485 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1486 | + } |
---|
764 | 1487 | |
---|
765 | 1488 | void SetColor(Object3D obj, Vertex p0) |
---|
766 | 1489 | { |
---|
.. | .. |
---|
939 | 1662 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
940 | 1663 | } |
---|
941 | 1664 | |
---|
942 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1665 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
943 | 1666 | { |
---|
944 | 1667 | CameraPane display = this; |
---|
945 | 1668 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
955 | 1678 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
956 | 1679 | if (!material.multiply) |
---|
957 | 1680 | { |
---|
958 | | - display.color = color; |
---|
| 1681 | + display.color = material.color; |
---|
959 | 1682 | display.saturation = material.modulation; |
---|
960 | 1683 | } |
---|
961 | 1684 | else |
---|
962 | 1685 | { |
---|
963 | | - display.color *= color*2; |
---|
| 1686 | + display.color *= material.color*2; |
---|
964 | 1687 | display.saturation *= material.modulation*2; |
---|
965 | 1688 | } |
---|
966 | 1689 | |
---|
967 | 1690 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
968 | 1691 | |
---|
969 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1692 | + float[] colorV = Grafreed.colorV; |
---|
970 | 1693 | |
---|
971 | 1694 | /**/ |
---|
972 | 1695 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
974 | 1697 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
975 | 1698 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
976 | 1699 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
977 | | - colorV[3] = material.opacity; |
---|
| 1700 | + colorV[3] = 1; // material.opacity; |
---|
978 | 1701 | |
---|
979 | 1702 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
980 | 1703 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1082 | 1805 | display.modelParams7[2] = 0; |
---|
1083 | 1806 | display.modelParams7[3] = 0; |
---|
1084 | 1807 | |
---|
1085 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1808 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1086 | 1809 | |
---|
1087 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1810 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1088 | 1811 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1089 | 1812 | { |
---|
1090 | 1813 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1226 | 1949 | void PushMatrix(double[][] matrix) |
---|
1227 | 1950 | { |
---|
1228 | 1951 | // GrafreeD.tracein(matrix); |
---|
1229 | | - PushMatrix(matrix,1); |
---|
| 1952 | + PushMatrix(matrix, 1); |
---|
1230 | 1953 | } |
---|
1231 | 1954 | |
---|
1232 | 1955 | void PushMatrix() |
---|
.. | .. |
---|
1323 | 2046 | |
---|
1324 | 2047 | static int camerachangeframe; |
---|
1325 | 2048 | |
---|
1326 | | - boolean SetCamera(Camera cam) |
---|
| 2049 | + public boolean SetCamera(Camera cam) |
---|
1327 | 2050 | { |
---|
1328 | 2051 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1329 | 2052 | // return false; |
---|
.. | .. |
---|
1380 | 2103 | //System.err.println("Oeil on"); |
---|
1381 | 2104 | OEIL = true; |
---|
1382 | 2105 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1383 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2106 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1384 | 2107 | //pingthread.StepToTarget(true); |
---|
1385 | 2108 | } |
---|
1386 | 2109 | |
---|
.. | .. |
---|
1451 | 2174 | mainDL ^= true; |
---|
1452 | 2175 | } |
---|
1453 | 2176 | |
---|
1454 | | - void ToggleTexture() |
---|
1455 | | - { |
---|
1456 | | - textureon ^= true; |
---|
1457 | | - } |
---|
1458 | | - |
---|
1459 | | - void ToggleLive() |
---|
1460 | | - { |
---|
1461 | | - Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
1462 | | - |
---|
1463 | | - System.err.println("LIVE = " + Globals.isLIVE()); |
---|
1464 | | - |
---|
1465 | | - if (!Globals.isLIVE()) // save sound |
---|
1466 | | - GrafreeD.savesound = true; // wav.save(); |
---|
1467 | | - // else |
---|
1468 | | - repaint(); // start loop // may 2013 |
---|
1469 | | - } |
---|
1470 | | - |
---|
1471 | | - void ToggleSupport() |
---|
1472 | | - { |
---|
1473 | | - SUPPORT ^= true; |
---|
1474 | | - } |
---|
1475 | | - |
---|
1476 | | - void ToggleAbort() |
---|
1477 | | - { |
---|
1478 | | - ABORTMODE ^= true; |
---|
1479 | | - } |
---|
1480 | | - |
---|
1481 | 2177 | void ToggleFullScreen() |
---|
1482 | 2178 | { |
---|
1483 | 2179 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1488 | 2184 | Globals.CROWD ^= true; |
---|
1489 | 2185 | } |
---|
1490 | 2186 | |
---|
1491 | | - void ToggleInertia() |
---|
1492 | | - { |
---|
1493 | | - INERTIA ^= true; |
---|
1494 | | - } |
---|
1495 | | - |
---|
1496 | 2187 | void ToggleLocal() |
---|
1497 | 2188 | { |
---|
1498 | 2189 | LOCALTRANSFORM ^= true; |
---|
1499 | 2190 | } |
---|
1500 | 2191 | |
---|
1501 | | - void ToggleFast() |
---|
| 2192 | + public void ToggleTexture() |
---|
| 2193 | + { |
---|
| 2194 | + textureon ^= true; |
---|
| 2195 | + } |
---|
| 2196 | + |
---|
| 2197 | + public void ToggleLive() |
---|
| 2198 | + { |
---|
| 2199 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2200 | + |
---|
| 2201 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2202 | + |
---|
| 2203 | + if (!Globals.isLIVE()) // save sound |
---|
| 2204 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2205 | + // else |
---|
| 2206 | + repaint(); // start loop // may 2013 |
---|
| 2207 | + } |
---|
| 2208 | + |
---|
| 2209 | + public void ToggleSupport() |
---|
| 2210 | + { |
---|
| 2211 | + SUPPORT ^= true; |
---|
| 2212 | + } |
---|
| 2213 | + |
---|
| 2214 | + public void ToggleAbort() |
---|
| 2215 | + { |
---|
| 2216 | + ABORTMODE ^= true; |
---|
| 2217 | + } |
---|
| 2218 | + |
---|
| 2219 | + public void ToggleInertia() |
---|
| 2220 | + { |
---|
| 2221 | + INERTIA ^= true; |
---|
| 2222 | + } |
---|
| 2223 | + |
---|
| 2224 | + public void ToggleFast() |
---|
1502 | 2225 | { |
---|
1503 | 2226 | FAST ^= true; |
---|
1504 | 2227 | } |
---|
1505 | 2228 | |
---|
1506 | | - void ToggleSlowPose() |
---|
| 2229 | + public void ToggleSlowPose() |
---|
1507 | 2230 | { |
---|
1508 | 2231 | SLOWPOSE ^= true; |
---|
1509 | 2232 | } |
---|
1510 | 2233 | |
---|
1511 | | - void ToggleFootContact() |
---|
1512 | | - { |
---|
1513 | | - FOOTCONTACT ^= true; |
---|
1514 | | - } |
---|
1515 | | - |
---|
1516 | | - void ToggleBoxMode() |
---|
| 2234 | + public void ToggleBoxMode() |
---|
1517 | 2235 | { |
---|
1518 | 2236 | BOXMODE ^= true; |
---|
1519 | 2237 | } |
---|
1520 | 2238 | |
---|
1521 | | - void ToggleSmoothFocus() |
---|
| 2239 | + public void ToggleZoomBoxMode() |
---|
| 2240 | + { |
---|
| 2241 | + ZOOMBOXMODE ^= true; |
---|
| 2242 | + } |
---|
| 2243 | + |
---|
| 2244 | + public void ToggleSmoothFocus() |
---|
1522 | 2245 | { |
---|
1523 | 2246 | SMOOTHFOCUS ^= true; |
---|
1524 | 2247 | } |
---|
1525 | 2248 | |
---|
1526 | | - void ToggleImageFlip() |
---|
| 2249 | + public void ToggleImageFlip() |
---|
1527 | 2250 | { |
---|
1528 | 2251 | IMAGEFLIP ^= true; |
---|
1529 | 2252 | } |
---|
1530 | 2253 | |
---|
1531 | | - void ToggleSpeakerMocap() |
---|
| 2254 | + public void ToggleSpeakerMocap() |
---|
1532 | 2255 | { |
---|
1533 | 2256 | SPEAKERMOCAP ^= true; |
---|
1534 | 2257 | } |
---|
1535 | 2258 | |
---|
1536 | | - void ToggleSpeakerCamera() |
---|
| 2259 | + public void ToggleSpeakerCamera() |
---|
1537 | 2260 | { |
---|
1538 | 2261 | SPEAKERCAMERA ^= true; |
---|
1539 | 2262 | } |
---|
1540 | 2263 | |
---|
1541 | | - void ToggleSpeakerFocus() |
---|
| 2264 | + public void ToggleSpeakerFocus() |
---|
1542 | 2265 | { |
---|
1543 | 2266 | SPEAKERFOCUS ^= true; |
---|
1544 | 2267 | } |
---|
1545 | 2268 | |
---|
1546 | | - void ToggleDebug() |
---|
1547 | | - { |
---|
1548 | | - DEBUG ^= true; |
---|
1549 | | - } |
---|
1550 | | - |
---|
1551 | | - void ToggleFrustum() |
---|
| 2269 | + public void ToggleFrustum() |
---|
1552 | 2270 | { |
---|
1553 | 2271 | FRUSTUM ^= true; |
---|
1554 | 2272 | } |
---|
1555 | 2273 | |
---|
1556 | | - void ToggleTrack() |
---|
| 2274 | + public void ToggleTrack() |
---|
1557 | 2275 | { |
---|
1558 | 2276 | TRACK ^= true; |
---|
1559 | 2277 | if (TRACK) |
---|
.. | .. |
---|
1572 | 2290 | repaint(); |
---|
1573 | 2291 | } |
---|
1574 | 2292 | |
---|
1575 | | - void ToggleTrackOnce() |
---|
| 2293 | + public void ToggleTrackOnce() |
---|
1576 | 2294 | { |
---|
1577 | 2295 | TRACKONCE ^= true; |
---|
1578 | 2296 | } |
---|
1579 | 2297 | |
---|
1580 | | - void ToggleShadowTrack() |
---|
| 2298 | + public void ToggleShadowTrack() |
---|
1581 | 2299 | { |
---|
1582 | 2300 | SHADOWTRACK ^= true; |
---|
1583 | 2301 | repaint(); |
---|
1584 | 2302 | } |
---|
1585 | 2303 | |
---|
1586 | | - void ToggleOeil() |
---|
| 2304 | + public void ToggleOeil() |
---|
1587 | 2305 | { |
---|
1588 | 2306 | OEIL ^= true; |
---|
1589 | 2307 | } |
---|
1590 | 2308 | |
---|
1591 | | - void ToggleOeilOnce() |
---|
| 2309 | + public void ToggleOeilOnce() |
---|
1592 | 2310 | { |
---|
1593 | 2311 | OEILONCE ^= true; |
---|
| 2312 | + } |
---|
| 2313 | + |
---|
| 2314 | + void ToggleFootContact() |
---|
| 2315 | + { |
---|
| 2316 | + FOOTCONTACT ^= true; |
---|
| 2317 | + } |
---|
| 2318 | + |
---|
| 2319 | + void ToggleDebug() |
---|
| 2320 | + { |
---|
| 2321 | + Globals.DEBUG ^= true; |
---|
1594 | 2322 | } |
---|
1595 | 2323 | |
---|
1596 | 2324 | void ToggleLookAt() |
---|
.. | .. |
---|
1598 | 2326 | LOOKAT ^= true; |
---|
1599 | 2327 | } |
---|
1600 | 2328 | |
---|
1601 | | - void ToggleRandom() |
---|
| 2329 | + void ToggleSwitch() |
---|
1602 | 2330 | { |
---|
1603 | | - RANDOM ^= true; |
---|
| 2331 | + SWITCH ^= true; |
---|
1604 | 2332 | } |
---|
1605 | 2333 | |
---|
1606 | 2334 | void ToggleHandles() |
---|
.. | .. |
---|
1608 | 2336 | HANDLES ^= true; |
---|
1609 | 2337 | } |
---|
1610 | 2338 | |
---|
| 2339 | + Object3D paintFolder; |
---|
| 2340 | + |
---|
1611 | 2341 | void TogglePaint() |
---|
1612 | 2342 | { |
---|
1613 | 2343 | PAINTMODE ^= true; |
---|
1614 | 2344 | paintcount = 0; |
---|
| 2345 | + |
---|
| 2346 | + if (PAINTMODE) |
---|
| 2347 | + { |
---|
| 2348 | + paintFolder = GetFolder(); |
---|
| 2349 | + } |
---|
1615 | 2350 | } |
---|
1616 | 2351 | |
---|
1617 | 2352 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1707 | 2442 | { |
---|
1708 | 2443 | return currentGL; |
---|
1709 | 2444 | } |
---|
1710 | | - |
---|
| 2445 | + |
---|
| 2446 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2447 | + { |
---|
| 2448 | + Grafreed.Assert(texturedata != null); |
---|
| 2449 | + |
---|
| 2450 | + int width = texturedata.getWidth(); |
---|
| 2451 | + int height = texturedata.getHeight(); |
---|
| 2452 | + |
---|
| 2453 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2454 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2455 | + |
---|
| 2456 | + byte[] bytes = bytebuf.array(); |
---|
| 2457 | + |
---|
| 2458 | + return CreateBim(bytes, width, height); |
---|
| 2459 | + } |
---|
| 2460 | + |
---|
1711 | 2461 | /**/ |
---|
1712 | 2462 | class CacheTexture |
---|
1713 | 2463 | { |
---|
.. | .. |
---|
1716 | 2466 | |
---|
1717 | 2467 | int resolution; |
---|
1718 | 2468 | |
---|
1719 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2469 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1720 | 2470 | { |
---|
1721 | | - texture = tex; |
---|
| 2471 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2472 | + texturedata = texdata; |
---|
1722 | 2473 | resolution = res; |
---|
1723 | 2474 | } |
---|
1724 | 2475 | } |
---|
1725 | 2476 | /**/ |
---|
1726 | 2477 | |
---|
1727 | 2478 | // TEXTURE static Texture texture; |
---|
1728 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
1729 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
1730 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2481 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2482 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2483 | + |
---|
1731 | 2484 | int pigmentdepth = 0; |
---|
1732 | 2485 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1733 | 2486 | int bumpdepth = 0; |
---|
1734 | 2487 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1735 | 2488 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1736 | 2489 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1737 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2490 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1738 | 2491 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1739 | 2492 | |
---|
1740 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2493 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1741 | 2494 | { |
---|
1742 | 2495 | TextureData texturedata = null; |
---|
1743 | 2496 | |
---|
.. | .. |
---|
1756 | 2509 | if (bump) |
---|
1757 | 2510 | texturedata = ConvertBump(texturedata, false); |
---|
1758 | 2511 | |
---|
1759 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1760 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2512 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2513 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
1761 | 2514 | |
---|
1762 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
1763 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2516 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
1764 | 2517 | |
---|
1765 | | - return texture; |
---|
| 2518 | + return texturedata; |
---|
| 2519 | + } |
---|
| 2520 | + |
---|
| 2521 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2522 | + { |
---|
| 2523 | + TextureData texturedata = null; |
---|
| 2524 | + |
---|
| 2525 | + try |
---|
| 2526 | + { |
---|
| 2527 | + texturedata = |
---|
| 2528 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2529 | + bim, |
---|
| 2530 | + true); |
---|
| 2531 | + } catch (Exception e) |
---|
| 2532 | + { |
---|
| 2533 | + throw new javax.media.opengl.GLException(e); |
---|
| 2534 | + } |
---|
| 2535 | + |
---|
| 2536 | + if (bump) |
---|
| 2537 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2538 | + |
---|
| 2539 | + return texturedata; |
---|
1766 | 2540 | } |
---|
1767 | 2541 | |
---|
1768 | 2542 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2835 | 3609 | |
---|
2836 | 3610 | System.out.println("LOADING TEXTURE : " + name); |
---|
2837 | 3611 | |
---|
| 3612 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3613 | + |
---|
2838 | 3614 | // |
---|
2839 | 3615 | if (false) // compressbit > 0) |
---|
2840 | 3616 | { |
---|
.. | .. |
---|
3539 | 4315 | |
---|
3540 | 4316 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3541 | 4317 | { |
---|
| 4318 | + new Exception().printStackTrace(); |
---|
3542 | 4319 | System.exit(0); |
---|
3543 | 4320 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3544 | 4321 | |
---|
.. | .. |
---|
7232 | 8009 | String pigment = Object3D.GetPigment(tex); |
---|
7233 | 8010 | String bump = Object3D.GetBump(tex); |
---|
7234 | 8011 | |
---|
7235 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8012 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7236 | 8013 | { |
---|
7237 | 8014 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7238 | 8015 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7247 | 8024 | pigment = null; |
---|
7248 | 8025 | } |
---|
7249 | 8026 | |
---|
7250 | | - ReleaseTexture(bump, true); |
---|
7251 | | - ReleaseTexture(pigment, false); |
---|
| 8027 | + ReleaseTexture(tex, true); |
---|
| 8028 | + ReleaseTexture(tex, false); |
---|
7252 | 8029 | } |
---|
7253 | 8030 | |
---|
7254 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8031 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8032 | + { |
---|
| 8033 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8034 | + { |
---|
| 8035 | + return; |
---|
| 8036 | + } |
---|
| 8037 | + |
---|
| 8038 | + if (tex == null) |
---|
| 8039 | + { |
---|
| 8040 | + ReleaseTexture(null, false); |
---|
| 8041 | + return; |
---|
| 8042 | + } |
---|
| 8043 | + |
---|
| 8044 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8045 | + |
---|
| 8046 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8047 | + { |
---|
| 8048 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8049 | + // System.out.println("; bump = " + bump); |
---|
| 8050 | + } |
---|
| 8051 | + |
---|
| 8052 | + if (pigment.equals("")) |
---|
| 8053 | + { |
---|
| 8054 | + pigment = null; |
---|
| 8055 | + } |
---|
| 8056 | + |
---|
| 8057 | + ReleaseTexture(tex, false); |
---|
| 8058 | + } |
---|
| 8059 | + |
---|
| 8060 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8061 | + { |
---|
| 8062 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8063 | + { |
---|
| 8064 | + return; |
---|
| 8065 | + } |
---|
| 8066 | + |
---|
| 8067 | + if (tex == null) |
---|
| 8068 | + { |
---|
| 8069 | + ReleaseTexture(null, true); |
---|
| 8070 | + return; |
---|
| 8071 | + } |
---|
| 8072 | + |
---|
| 8073 | + String bump = Object3D.GetBump(tex); |
---|
| 8074 | + |
---|
| 8075 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8076 | + { |
---|
| 8077 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8078 | + // System.out.println("; bump = " + bump); |
---|
| 8079 | + } |
---|
| 8080 | + |
---|
| 8081 | + if (bump.equals("")) |
---|
| 8082 | + { |
---|
| 8083 | + bump = null; |
---|
| 8084 | + } |
---|
| 8085 | + |
---|
| 8086 | + ReleaseTexture(tex, true); |
---|
| 8087 | + } |
---|
| 8088 | + |
---|
| 8089 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7255 | 8090 | { |
---|
7256 | 8091 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7257 | 8092 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7262 | 8097 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7263 | 8098 | |
---|
7264 | 8099 | if (tex != null) |
---|
7265 | | - texture = textures.get(tex); |
---|
| 8100 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7266 | 8101 | |
---|
7267 | 8102 | // //assert( texture != null ); |
---|
7268 | 8103 | // if (texture == null) |
---|
.. | .. |
---|
7354 | 8189 | } |
---|
7355 | 8190 | } |
---|
7356 | 8191 | |
---|
7357 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8192 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8193 | + { |
---|
| 8194 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8195 | +// ambientOcclusion ) // || !textureon) |
---|
| 8196 | +// { |
---|
| 8197 | +// return; // false; |
---|
| 8198 | +// } |
---|
| 8199 | +// |
---|
| 8200 | +// if (tex == null) |
---|
| 8201 | +// { |
---|
| 8202 | +// BindTexture(null,false,resolution); |
---|
| 8203 | +// BindTexture(null,true,resolution); |
---|
| 8204 | +// return; |
---|
| 8205 | +// } |
---|
| 8206 | +// |
---|
| 8207 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8208 | +// String bump = Object3D.GetBump(tex); |
---|
| 8209 | +// |
---|
| 8210 | +// usedtextures.add(pigment); |
---|
| 8211 | +// usedtextures.add(bump); |
---|
| 8212 | +// |
---|
| 8213 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8214 | +// { |
---|
| 8215 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8216 | +// // System.out.println("; bump = " + bump); |
---|
| 8217 | +// } |
---|
| 8218 | +// |
---|
| 8219 | +// if (bump.equals("")) |
---|
| 8220 | +// { |
---|
| 8221 | +// bump = null; |
---|
| 8222 | +// } |
---|
| 8223 | +// if (pigment.equals("")) |
---|
| 8224 | +// { |
---|
| 8225 | +// pigment = null; |
---|
| 8226 | +// } |
---|
| 8227 | +// |
---|
| 8228 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8229 | +// BindTexture(pigment, false, resolution); |
---|
| 8230 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8231 | +// BindTexture(bump, true, resolution); |
---|
| 8232 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8233 | +// |
---|
| 8234 | +// return; // true; |
---|
| 8235 | + |
---|
| 8236 | + BindPigmentTexture(tex, resolution); |
---|
| 8237 | + BindBumpTexture(tex, resolution); |
---|
| 8238 | + } |
---|
| 8239 | + |
---|
| 8240 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7358 | 8241 | { |
---|
7359 | 8242 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7360 | 8243 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7365 | 8248 | if (tex == null) |
---|
7366 | 8249 | { |
---|
7367 | 8250 | BindTexture(null,false,resolution); |
---|
7368 | | - BindTexture(null,true,resolution); |
---|
7369 | 8251 | return; |
---|
7370 | 8252 | } |
---|
7371 | 8253 | |
---|
7372 | 8254 | String pigment = Object3D.GetPigment(tex); |
---|
| 8255 | + |
---|
| 8256 | + usedtextures.add(tex); |
---|
| 8257 | + |
---|
| 8258 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8259 | + { |
---|
| 8260 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8261 | + // System.out.println("; bump = " + bump); |
---|
| 8262 | + } |
---|
| 8263 | + |
---|
| 8264 | + if (pigment.equals("")) |
---|
| 8265 | + { |
---|
| 8266 | + pigment = null; |
---|
| 8267 | + } |
---|
| 8268 | + |
---|
| 8269 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8270 | + BindTexture(tex, false, resolution); |
---|
| 8271 | + } |
---|
| 8272 | + |
---|
| 8273 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8274 | + { |
---|
| 8275 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8276 | + ambientOcclusion ) // || !textureon) |
---|
| 8277 | + { |
---|
| 8278 | + return; // false; |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + if (tex == null) |
---|
| 8282 | + { |
---|
| 8283 | + BindTexture(null,true,resolution); |
---|
| 8284 | + return; |
---|
| 8285 | + } |
---|
| 8286 | + |
---|
7373 | 8287 | String bump = Object3D.GetBump(tex); |
---|
7374 | 8288 | |
---|
7375 | | - usedtextures.put(pigment, pigment); |
---|
7376 | | - usedtextures.put(bump, bump); |
---|
| 8289 | + usedtextures.add(tex); |
---|
7377 | 8290 | |
---|
7378 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8291 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7379 | 8292 | { |
---|
7380 | 8293 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7381 | 8294 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7385 | 8298 | { |
---|
7386 | 8299 | bump = null; |
---|
7387 | 8300 | } |
---|
7388 | | - if (pigment.equals("")) |
---|
7389 | | - { |
---|
7390 | | - pigment = null; |
---|
7391 | | - } |
---|
7392 | 8301 | |
---|
7393 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7394 | | - BindTexture(pigment, false, resolution); |
---|
7395 | 8302 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7396 | | - BindTexture(bump, true, resolution); |
---|
| 8303 | + BindTexture(tex, true, resolution); |
---|
7397 | 8304 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7398 | | - |
---|
7399 | | - return; // true; |
---|
7400 | 8305 | } |
---|
7401 | 8306 | |
---|
7402 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8307 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8308 | + |
---|
| 8309 | + private boolean FileExists(String tex) |
---|
7403 | 8310 | { |
---|
7404 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8311 | + if (missingTextures.contains(tex)) |
---|
| 8312 | + { |
---|
| 8313 | + return false; |
---|
| 8314 | + } |
---|
| 8315 | + |
---|
| 8316 | + boolean fileExists = new File(tex).exists(); |
---|
| 8317 | + |
---|
| 8318 | + if (!fileExists) |
---|
| 8319 | + { |
---|
| 8320 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8321 | + missingTextures.add(tex); |
---|
| 8322 | + } |
---|
| 8323 | + |
---|
| 8324 | + return fileExists; |
---|
| 8325 | + } |
---|
| 8326 | + |
---|
| 8327 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8328 | + { |
---|
| 8329 | + CacheTexture texturecache = null; |
---|
7405 | 8330 | |
---|
7406 | 8331 | if (tex != null) |
---|
7407 | 8332 | { |
---|
7408 | | - String texname = tex; |
---|
| 8333 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8334 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7409 | 8335 | |
---|
7410 | | - String[] split = tex.split("Textures"); |
---|
7411 | | - if (split.length > 1) |
---|
7412 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
7413 | | - else |
---|
7414 | | - if (!texname.startsWith("/")) |
---|
7415 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8336 | + if (texname.equals("") && texdata == null) |
---|
| 8337 | + { |
---|
| 8338 | + return null; |
---|
| 8339 | + } |
---|
| 8340 | + |
---|
| 8341 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8342 | + |
---|
| 8343 | +// String[] split = tex.split("Textures"); |
---|
| 8344 | +// if (split.length > 1) |
---|
| 8345 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8346 | +// else |
---|
| 8347 | +// if (!texname.startsWith("/")) |
---|
| 8348 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8349 | + if (!FileExists(texname)) |
---|
| 8350 | + { |
---|
| 8351 | + texname = fallbackTextureName; |
---|
| 8352 | + } |
---|
7416 | 8353 | |
---|
7417 | 8354 | if (CACHETEXTURE) |
---|
7418 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7419 | | - |
---|
7420 | | - TextureData texturedata = null; |
---|
7421 | | - |
---|
7422 | | - if (texture == null || texture.resolution < resolution) |
---|
7423 | 8355 | { |
---|
7424 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8356 | + if (texdata == null) |
---|
| 8357 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8358 | + else |
---|
| 8359 | + texturecache = bimtextures.get(texdata); |
---|
| 8360 | + } |
---|
| 8361 | + |
---|
| 8362 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8363 | + { |
---|
| 8364 | + TextureData texturedata = null; |
---|
| 8365 | + |
---|
| 8366 | + if (texdata != null && textureon) |
---|
| 8367 | + { |
---|
| 8368 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8369 | + |
---|
| 8370 | + try |
---|
| 8371 | + { |
---|
| 8372 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8373 | + } |
---|
| 8374 | + catch (Exception e) |
---|
| 8375 | + { |
---|
| 8376 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8377 | + } |
---|
| 8378 | + |
---|
| 8379 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8380 | + bimtextures.put(texdata, texturecache); |
---|
| 8381 | + |
---|
| 8382 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8383 | + |
---|
| 8384 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8385 | + //bim2 = bim; |
---|
| 8386 | + } |
---|
| 8387 | + else |
---|
| 8388 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
7425 | 8389 | { |
---|
7426 | 8390 | assert(!bump); |
---|
7427 | 8391 | // if (bump) |
---|
.. | .. |
---|
7432 | 8396 | // } |
---|
7433 | 8397 | // else |
---|
7434 | 8398 | // { |
---|
7435 | | - texture = textures.get(tex); |
---|
7436 | | - if (texture == null) |
---|
| 8399 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8400 | + if (texturecache == null) |
---|
7437 | 8401 | { |
---|
7438 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8402 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7439 | 8403 | } |
---|
| 8404 | + else |
---|
| 8405 | + new Exception().printStackTrace(); |
---|
7440 | 8406 | // } |
---|
7441 | 8407 | } else |
---|
7442 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8408 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7443 | 8409 | { |
---|
7444 | 8410 | assert(bump); |
---|
7445 | | - texture = textures.get(tex); |
---|
7446 | | - if (texture == null) |
---|
7447 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8411 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8412 | + if (texturecache == null) |
---|
| 8413 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8414 | + else |
---|
| 8415 | + new Exception().printStackTrace(); |
---|
7448 | 8416 | } else |
---|
7449 | 8417 | { |
---|
7450 | 8418 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7452 | 8420 | // texture = GetResourceTexture("default.png"); |
---|
7453 | 8421 | //} else |
---|
7454 | 8422 | //{ |
---|
7455 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8423 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7456 | 8424 | { |
---|
7457 | | - texture = textures.get(tex); |
---|
7458 | | - if (texture == null) |
---|
7459 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8425 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8426 | + if (texturecache == null) |
---|
| 8427 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8428 | + else |
---|
| 8429 | + new Exception().printStackTrace(); |
---|
7460 | 8430 | } else |
---|
7461 | 8431 | { |
---|
7462 | 8432 | if (textureon) |
---|
.. | .. |
---|
7481 | 8451 | } |
---|
7482 | 8452 | |
---|
7483 | 8453 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7484 | | - if (!new File(cachename).exists()) |
---|
| 8454 | + if (!FileExists(cachename)) |
---|
7485 | 8455 | cachename = texname; |
---|
7486 | 8456 | else |
---|
7487 | 8457 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7503 | 8473 | } |
---|
7504 | 8474 | |
---|
7505 | 8475 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7506 | | - if (!new File(cachename).exists()) |
---|
| 8476 | + if (!FileExists(cachename)) |
---|
7507 | 8477 | cachename = texname; |
---|
7508 | 8478 | else |
---|
7509 | 8479 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7512 | 8482 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7513 | 8483 | |
---|
7514 | 8484 | |
---|
7515 | | - if (texturedata != null) |
---|
7516 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8485 | + if (texturedata == null) |
---|
| 8486 | + throw new Exception(); |
---|
| 8487 | + |
---|
| 8488 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
7517 | 8489 | //texture = GetTexture(tex, bump); |
---|
7518 | 8490 | } |
---|
7519 | 8491 | } |
---|
7520 | 8492 | //} |
---|
7521 | 8493 | } |
---|
7522 | 8494 | |
---|
7523 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8495 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7524 | 8496 | { |
---|
7525 | 8497 | //return false; |
---|
7526 | 8498 | |
---|
7527 | 8499 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7528 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8500 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7529 | 8501 | { |
---|
7530 | 8502 | // String ext = "_highres"; |
---|
7531 | 8503 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7542 | 8514 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7543 | 8515 | if (!cachefile.exists()) |
---|
7544 | 8516 | { |
---|
7545 | | - // cache to disk |
---|
7546 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
7547 | | - //buffers[0]. |
---|
7548 | | - |
---|
7549 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
7550 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
7551 | | - |
---|
7552 | | - // squared size heuristic... |
---|
7553 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8517 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7554 | 8518 | { |
---|
7555 | | - for (int i=pixels.length; --i>=0;) |
---|
7556 | | - { |
---|
7557 | | - int i3 = i*3; |
---|
7558 | | - pixels[i] = 0xFF; |
---|
7559 | | - pixels[i] <<= 8; |
---|
7560 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
7561 | | - pixels[i] <<= 8; |
---|
7562 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
7563 | | - pixels[i] <<= 8; |
---|
7564 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
7565 | | - } |
---|
7566 | | - |
---|
7567 | | - /* |
---|
7568 | | - int r=0,g=0,b=0,a=0; |
---|
7569 | | - for (int i=0; i<width; i++) |
---|
7570 | | - for (int j=0; j<height; j++) |
---|
7571 | | - { |
---|
7572 | | - int index = j*width+i; |
---|
7573 | | - int p = pixels[index]; |
---|
7574 | | - a = ((p>>24) & 0xFF); |
---|
7575 | | - r = ((p>>16) & 0xFF); |
---|
7576 | | - g = ((p>>8) & 0xFF); |
---|
7577 | | - b = (p & 0xFF); |
---|
7578 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
7579 | | - } |
---|
7580 | | - /**/ |
---|
7581 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
7582 | | - int height = width; |
---|
7583 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
7584 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8519 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8520 | + |
---|
7585 | 8521 | ImageWriter writer = null; |
---|
7586 | 8522 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7587 | 8523 | if (iter.hasNext()) { |
---|
7588 | 8524 | writer = (ImageWriter)iter.next(); |
---|
7589 | 8525 | } |
---|
7590 | | - float compressionQuality = 0.9f; |
---|
| 8526 | + |
---|
| 8527 | + float compressionQuality = 0.85f; |
---|
7591 | 8528 | try |
---|
7592 | 8529 | { |
---|
7593 | 8530 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7604 | 8541 | } |
---|
7605 | 8542 | } |
---|
7606 | 8543 | } |
---|
7607 | | - |
---|
| 8544 | + |
---|
| 8545 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8546 | + |
---|
7608 | 8547 | //System.out.println("Texture = " + tex); |
---|
7609 | | - if (textures.containsKey(texname)) |
---|
| 8548 | + if (textures.containsKey(tex)) |
---|
7610 | 8549 | { |
---|
7611 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8550 | + CacheTexture thetex = textures.get(tex); |
---|
7612 | 8551 | thetex.texture.disable(); |
---|
7613 | 8552 | thetex.texture.dispose(); |
---|
7614 | | - textures.remove(texname); |
---|
| 8553 | + textures.remove(tex); |
---|
7615 | 8554 | } |
---|
7616 | 8555 | |
---|
7617 | | - texture.texturedata = texturedata; |
---|
7618 | | - textures.put(texname, texture); |
---|
| 8556 | + //texture.texturedata = texturedata; |
---|
| 8557 | + textures.put(tex, texturecache); |
---|
7619 | 8558 | |
---|
7620 | 8559 | // newtex = true; |
---|
7621 | 8560 | } |
---|
.. | .. |
---|
7631 | 8570 | } |
---|
7632 | 8571 | } |
---|
7633 | 8572 | |
---|
7634 | | - return texture; |
---|
| 8573 | + return texturecache; |
---|
7635 | 8574 | } |
---|
7636 | 8575 | |
---|
7637 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8576 | + static void EmbedTextures(cTexture tex) |
---|
| 8577 | + { |
---|
| 8578 | + if (tex.pigmentdata == null) |
---|
| 8579 | + { |
---|
| 8580 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8581 | + |
---|
| 8582 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8583 | + |
---|
| 8584 | + if (texturecache != null) |
---|
| 8585 | + { |
---|
| 8586 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8587 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8588 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8589 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8590 | + ; |
---|
| 8591 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8592 | + } |
---|
| 8593 | + } |
---|
| 8594 | + |
---|
| 8595 | + if (tex.bumpdata == null) |
---|
| 8596 | + { |
---|
| 8597 | + //String texname = Object3D.GetBump(tex); |
---|
| 8598 | + |
---|
| 8599 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8600 | + |
---|
| 8601 | + if (texturecache != null) |
---|
| 8602 | + { |
---|
| 8603 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8604 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8605 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + } |
---|
| 8609 | + |
---|
| 8610 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7638 | 8611 | { |
---|
7639 | 8612 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7640 | 8613 | |
---|
.. | .. |
---|
7652 | 8625 | return texture!=null?texture.texture:null; |
---|
7653 | 8626 | } |
---|
7654 | 8627 | |
---|
7655 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8628 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7656 | 8629 | { |
---|
7657 | 8630 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7658 | 8631 | |
---|
7659 | 8632 | return texture!=null?texture.texturedata:null; |
---|
7660 | 8633 | } |
---|
7661 | 8634 | |
---|
7662 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8635 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7663 | 8636 | { |
---|
7664 | 8637 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7665 | 8638 | { |
---|
7666 | 8639 | return false; |
---|
7667 | 8640 | } |
---|
7668 | 8641 | |
---|
7669 | | - boolean newtex = false; |
---|
| 8642 | + //boolean newtex = false; |
---|
7670 | 8643 | |
---|
7671 | 8644 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7672 | 8645 | |
---|
.. | .. |
---|
7698 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7699 | 8672 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7700 | 8673 | |
---|
7701 | | - return newtex; |
---|
| 8674 | + return true; // Warning: not used. |
---|
7702 | 8675 | } |
---|
7703 | 8676 | |
---|
| 8677 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8678 | + { |
---|
| 8679 | + try |
---|
| 8680 | + { |
---|
| 8681 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8682 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8683 | + ImageWriter writer = writers.next(); |
---|
| 8684 | + |
---|
| 8685 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8686 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8687 | + param.setCompressionQuality(quality); |
---|
| 8688 | + |
---|
| 8689 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8690 | + writer.setOutput(ios); |
---|
| 8691 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8692 | + |
---|
| 8693 | + byte[] data = baos.toByteArray(); |
---|
| 8694 | + writer.dispose(); |
---|
| 8695 | + return data; |
---|
| 8696 | + } |
---|
| 8697 | + catch (Exception e) |
---|
| 8698 | + { |
---|
| 8699 | + e.printStackTrace(); |
---|
| 8700 | + return null; |
---|
| 8701 | + } |
---|
| 8702 | + } |
---|
| 8703 | + |
---|
| 8704 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8705 | + { |
---|
| 8706 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8707 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8708 | + ImageReader reader = writers.next(); |
---|
| 8709 | + |
---|
| 8710 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8711 | + |
---|
| 8712 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8713 | + param.setDestination(bim); |
---|
| 8714 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8715 | + |
---|
| 8716 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8717 | + reader.setInput(ios); |
---|
| 8718 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8719 | + reader.dispose(); |
---|
| 8720 | + |
---|
| 8721 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8722 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8723 | +// byte[] bytes = data.getData(); |
---|
| 8724 | +// |
---|
| 8725 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8726 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8727 | +// { |
---|
| 8728 | +// int i3 = i*3; |
---|
| 8729 | +// pixels[i] = 0xFF; |
---|
| 8730 | +// pixels[i] <<= 8; |
---|
| 8731 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8732 | +// pixels[i] <<= 8; |
---|
| 8733 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8734 | +// pixels[i] <<= 8; |
---|
| 8735 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8736 | +// } |
---|
| 8737 | +// |
---|
| 8738 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8739 | + |
---|
| 8740 | + return bim; |
---|
| 8741 | + } |
---|
| 8742 | + |
---|
7704 | 8743 | ShadowBuffer shadowPBuf; |
---|
7705 | 8744 | AntialiasBuffer antialiasPBuf; |
---|
7706 | 8745 | int MAXSTACK; |
---|
.. | .. |
---|
8536 | 9575 | jy8[3] = 0.5f; |
---|
8537 | 9576 | } |
---|
8538 | 9577 | |
---|
8539 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9578 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
8540 | 9579 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8541 | 9580 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8542 | 9581 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8543 | 9582 | |
---|
| 9583 | + void ResetOptions() |
---|
| 9584 | + { |
---|
| 9585 | + options1[0] = 100; |
---|
| 9586 | + options1[1] = 0.025f; |
---|
| 9587 | + options1[2] = 0.01f; |
---|
| 9588 | + options1[3] = 0; |
---|
| 9589 | + options1[4] = 0; |
---|
| 9590 | + |
---|
| 9591 | + options2[0] = 0; |
---|
| 9592 | + options2[1] = 0.75f; |
---|
| 9593 | + options2[2] = 0; |
---|
| 9594 | + options2[3] = 0; |
---|
| 9595 | + |
---|
| 9596 | + options3[0] = 1; |
---|
| 9597 | + options3[1] = 1; |
---|
| 9598 | + options3[2] = 1; |
---|
| 9599 | + options3[3] = 0; |
---|
| 9600 | + |
---|
| 9601 | + options4[0] = 1; |
---|
| 9602 | + options4[1] = 0; |
---|
| 9603 | + options4[2] = 1; |
---|
| 9604 | + options4[3] = 0; |
---|
| 9605 | + } |
---|
| 9606 | + |
---|
8544 | 9607 | static int imagecount = 0; // movie generation |
---|
8545 | 9608 | |
---|
8546 | 9609 | static int jitter = 0; |
---|
.. | .. |
---|
8636 | 9699 | assert (parentcam != renderCamera); |
---|
8637 | 9700 | |
---|
8638 | 9701 | if (renderCamera != lightCamera) |
---|
8639 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8640 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9702 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9703 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8641 | 9704 | |
---|
8642 | 9705 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8643 | 9706 | |
---|
.. | .. |
---|
8652 | 9715 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8653 | 9716 | |
---|
8654 | 9717 | if (renderCamera != lightCamera) |
---|
8655 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8656 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9718 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9719 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8657 | 9720 | |
---|
8658 | 9721 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8659 | 9722 | |
---|
.. | .. |
---|
8725 | 9788 | //gl.glFlush(); |
---|
8726 | 9789 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8727 | 9790 | |
---|
8728 | | - if (ANIMATION && ABORTED) |
---|
| 9791 | + if (Globals.ANIMATION && ABORTED) |
---|
8729 | 9792 | { |
---|
8730 | 9793 | System.err.println(" ABORTED FRAME"); |
---|
8731 | 9794 | break; |
---|
.. | .. |
---|
8755 | 9818 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8756 | 9819 | |
---|
8757 | 9820 | // save image |
---|
8758 | | - if (ANIMATION && !ABORTED) |
---|
| 9821 | + if (Globals.ANIMATION && !ABORTED) |
---|
8759 | 9822 | { |
---|
8760 | 9823 | VPwidth = viewport[2]; |
---|
8761 | 9824 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8866 | 9929 | |
---|
8867 | 9930 | // imagecount++; |
---|
8868 | 9931 | |
---|
8869 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9932 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
8870 | 9933 | |
---|
8871 | 9934 | if (!BOXMODE) |
---|
8872 | 9935 | { |
---|
8873 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9936 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
8874 | 9937 | } |
---|
8875 | 9938 | |
---|
8876 | 9939 | if (!BOXMODE) |
---|
.. | .. |
---|
8908 | 9971 | ABORTED = false; |
---|
8909 | 9972 | } |
---|
8910 | 9973 | else |
---|
8911 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9974 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8912 | 9975 | |
---|
8913 | 9976 | if (false) |
---|
8914 | 9977 | { |
---|
.. | .. |
---|
9571 | 10634 | |
---|
9572 | 10635 | public void display(GLAutoDrawable drawable) |
---|
9573 | 10636 | { |
---|
9574 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10637 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9575 | 10638 | { |
---|
9576 | | - GrafreeD.wav.save(); |
---|
9577 | | - GrafreeD.savesound = false; |
---|
9578 | | - GrafreeD.hassound = false; |
---|
| 10639 | + Grafreed.wav.save(); |
---|
| 10640 | + Grafreed.savesound = false; |
---|
| 10641 | + Grafreed.hassound = false; |
---|
9579 | 10642 | } |
---|
9580 | 10643 | // if (DEBUG_SELECTION) |
---|
9581 | 10644 | // { |
---|
.. | .. |
---|
9651 | 10714 | ANTIALIAS = 0; |
---|
9652 | 10715 | //System.out.println("RESTART"); |
---|
9653 | 10716 | AAtimer.restart(); |
---|
| 10717 | + Globals.TIMERRUNNING = true; |
---|
9654 | 10718 | } |
---|
9655 | 10719 | } |
---|
9656 | 10720 | } |
---|
.. | .. |
---|
9705 | 10769 | Object3D theobject = object; |
---|
9706 | 10770 | Object3D theparent = object.parent; |
---|
9707 | 10771 | object.parent = null; |
---|
9708 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10772 | + object = (Object3D)Grafreed.clone(object); |
---|
9709 | 10773 | object.Stripify(); |
---|
9710 | 10774 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9711 | 10775 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9718 | 10782 | ambientOcclusion = false; |
---|
9719 | 10783 | } |
---|
9720 | 10784 | |
---|
9721 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10785 | + if (//Globals.lighttouched && |
---|
| 10786 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9722 | 10787 | { |
---|
9723 | 10788 | //if (RENDERSHADOW) // ? |
---|
9724 | 10789 | if (!IsFrozen()) |
---|
9725 | 10790 | { |
---|
9726 | 10791 | // dec 2012 |
---|
9727 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10792 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9728 | 10793 | { |
---|
9729 | 10794 | Globals.framecount++; |
---|
9730 | 10795 | shadowbuffer.display(); |
---|
.. | .. |
---|
9851 | 10916 | |
---|
9852 | 10917 | // if (parentcam != renderCamera) // not a light |
---|
9853 | 10918 | if (cam != lightCamera) |
---|
9854 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9855 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10919 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10920 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9856 | 10921 | |
---|
9857 | 10922 | for (int j = 0; j < 4; j++) |
---|
9858 | 10923 | { |
---|
.. | .. |
---|
9866 | 10931 | |
---|
9867 | 10932 | // if (parentcam != renderCamera) // not a light |
---|
9868 | 10933 | if (cam != lightCamera) |
---|
9869 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9870 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10934 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10935 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9871 | 10936 | |
---|
9872 | 10937 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9873 | 10938 | |
---|
.. | .. |
---|
10126 | 11191 | // Bump noise |
---|
10127 | 11192 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10128 | 11193 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10129 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11194 | + |
---|
| 11195 | + try |
---|
| 11196 | + { |
---|
| 11197 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11198 | + } |
---|
| 11199 | + catch (Exception e) |
---|
| 11200 | + { |
---|
| 11201 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11202 | + } |
---|
| 11203 | + |
---|
10130 | 11204 | |
---|
10131 | 11205 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10132 | 11206 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10149 | 11223 | |
---|
10150 | 11224 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10151 | 11225 | |
---|
10152 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10153 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10154 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11226 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11227 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11228 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10155 | 11229 | } else |
---|
10156 | 11230 | { |
---|
10157 | 11231 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10162 | 11236 | //System.out.println("BLENDING ON"); |
---|
10163 | 11237 | gl.glEnable(GL.GL_BLEND); |
---|
10164 | 11238 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10165 | | - |
---|
| 11239 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10166 | 11240 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10167 | 11241 | gl.glLoadIdentity(); |
---|
10168 | 11242 | |
---|
.. | .. |
---|
10251 | 11325 | System.err.println("parentcam != renderCamera"); |
---|
10252 | 11326 | |
---|
10253 | 11327 | // if (cam != lightCamera) |
---|
10254 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10255 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11328 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11329 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10256 | 11330 | } |
---|
10257 | 11331 | |
---|
10258 | 11332 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10273 | 11347 | if (true) // TODO |
---|
10274 | 11348 | { |
---|
10275 | 11349 | if (cam != lightCamera) |
---|
10276 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10277 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11350 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11351 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10278 | 11352 | } |
---|
10279 | 11353 | |
---|
10280 | 11354 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10340 | 11414 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10341 | 11415 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10342 | 11416 | |
---|
10343 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11417 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10344 | 11418 | { |
---|
10345 | 11419 | /* |
---|
10346 | 11420 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10411 | 11485 | } |
---|
10412 | 11486 | } |
---|
10413 | 11487 | |
---|
10414 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11488 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10415 | 11489 | { |
---|
10416 | 11490 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10417 | 11491 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10419 | 11493 | |
---|
10420 | 11494 | boolean texon = textureon; |
---|
10421 | 11495 | |
---|
10422 | | - if (RENDERPROGRAM > 0) |
---|
10423 | | - { |
---|
10424 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10425 | | - textureon = false; |
---|
10426 | | - } |
---|
| 11496 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11497 | + textureon = false; |
---|
| 11498 | + |
---|
10427 | 11499 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10428 | 11500 | //System.out.println("ALLO"); |
---|
10429 | 11501 | gl.glColorMask(false, false, false, false); |
---|
10430 | 11502 | DrawObject(gl); |
---|
10431 | | - if (RENDERPROGRAM > 0) |
---|
10432 | | - { |
---|
10433 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10434 | | - textureon = texon; |
---|
10435 | | - } |
---|
| 11503 | + |
---|
| 11504 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11505 | + textureon = texon; |
---|
| 11506 | + |
---|
10436 | 11507 | gl.glColorMask(true, true, true, true); |
---|
10437 | 11508 | |
---|
10438 | 11509 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10439 | | - //gl.glDepthMask(false); |
---|
| 11510 | + gl.glDepthMask(false); |
---|
10440 | 11511 | } |
---|
10441 | 11512 | |
---|
10442 | 11513 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10590 | 11661 | { |
---|
10591 | 11662 | renderpass++; |
---|
10592 | 11663 | // System.out.println("Draw object... "); |
---|
| 11664 | + STEP = 1; |
---|
10593 | 11665 | if (FAST) // in case there is no script |
---|
10594 | | - STEP = 16; |
---|
| 11666 | + STEP = 8; |
---|
| 11667 | + |
---|
| 11668 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11669 | + { |
---|
| 11670 | + STEP *= 4; |
---|
| 11671 | + } |
---|
10595 | 11672 | |
---|
10596 | 11673 | //object.FullInvariants(); |
---|
10597 | 11674 | |
---|
.. | .. |
---|
10605 | 11682 | e.printStackTrace(); |
---|
10606 | 11683 | } |
---|
10607 | 11684 | |
---|
10608 | | - if (GrafreeD.RENDERME > 0) |
---|
10609 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11685 | + if (Grafreed.RENDERME > 0) |
---|
| 11686 | + Grafreed.RENDERME--; // mechante magouille |
---|
10610 | 11687 | |
---|
10611 | 11688 | Globals.ONESTEP = false; |
---|
10612 | 11689 | } |
---|
10613 | 11690 | |
---|
10614 | 11691 | static boolean zoomonce = false; |
---|
10615 | 11692 | |
---|
| 11693 | + static void CreateSelectedPoint() |
---|
| 11694 | + { |
---|
| 11695 | + if (selectedpoint == null) |
---|
| 11696 | + { |
---|
| 11697 | + debugpointG = new Sphere(); |
---|
| 11698 | + debugpointP = new Sphere(); |
---|
| 11699 | + debugpointC = new Sphere(); |
---|
| 11700 | + debugpointR = new Sphere(); |
---|
| 11701 | + |
---|
| 11702 | + selectedpoint = new Superellipsoid(); |
---|
| 11703 | + |
---|
| 11704 | + for (int i=0; i<8; i++) |
---|
| 11705 | + { |
---|
| 11706 | + debugpoints[i] = new Sphere(); |
---|
| 11707 | + } |
---|
| 11708 | + } |
---|
| 11709 | + } |
---|
| 11710 | + |
---|
10616 | 11711 | void DrawObject(GL gl, boolean draw) |
---|
10617 | 11712 | { |
---|
| 11713 | + // To clear camera values |
---|
| 11714 | + ResetOptions(); |
---|
| 11715 | + |
---|
10618 | 11716 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10619 | 11717 | // DrawMode() = SELECTION; |
---|
10620 | 11718 | //GL gl = getGL(); |
---|
10621 | 11719 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10622 | 11720 | { |
---|
10623 | 11721 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10624 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11722 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10625 | 11723 | pingthread.StepToTarget(true); // true); |
---|
10626 | 11724 | // zoomonce = false; |
---|
10627 | 11725 | } |
---|
.. | .. |
---|
10641 | 11739 | callist = gl.glGenLists(1); |
---|
10642 | 11740 | } |
---|
10643 | 11741 | |
---|
10644 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11742 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10645 | 11743 | |
---|
10646 | 11744 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10647 | 11745 | |
---|
.. | .. |
---|
10676 | 11774 | |
---|
10677 | 11775 | usedtextures.clear(); |
---|
10678 | 11776 | |
---|
10679 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11777 | + try |
---|
| 11778 | + { |
---|
| 11779 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11780 | + } |
---|
| 11781 | + catch (Exception e) |
---|
| 11782 | + { |
---|
| 11783 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11784 | + } |
---|
10680 | 11785 | } |
---|
10681 | 11786 | //System.out.println("--> " + stackdepth); |
---|
10682 | 11787 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10686 | 11791 | |
---|
10687 | 11792 | if (DrawMode() == DEFAULT) |
---|
10688 | 11793 | { |
---|
10689 | | - if (DEBUG) |
---|
| 11794 | + if (Globals.DEBUG) |
---|
10690 | 11795 | { |
---|
| 11796 | + CreateSelectedPoint(); |
---|
10691 | 11797 | float radius = 0.05f; |
---|
10692 | 11798 | if (selectedpoint.radius != radius) |
---|
10693 | 11799 | { |
---|
.. | .. |
---|
10741 | 11847 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10742 | 11848 | |
---|
10743 | 11849 | if (CLEANCACHE) |
---|
10744 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11850 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10745 | 11851 | { |
---|
10746 | | - String tex = e.nextElement(); |
---|
| 11852 | + cTexture tex = e.nextElement(); |
---|
10747 | 11853 | |
---|
10748 | 11854 | // System.out.println("Texture --------- " + tex); |
---|
10749 | 11855 | |
---|
10750 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11856 | + if (tex.equals("WHITE_NOISE:")) |
---|
10751 | 11857 | continue; |
---|
10752 | 11858 | |
---|
10753 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11859 | + if (!usedtextures.contains(tex)) |
---|
10754 | 11860 | { |
---|
| 11861 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10755 | 11862 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10756 | | - textures.get(tex).texture.dispose(); |
---|
10757 | | - textures.remove(tex); |
---|
| 11863 | + if (gettex != null) |
---|
| 11864 | + { |
---|
| 11865 | + gettex.texture.dispose(); |
---|
| 11866 | + texturepigment.remove(tex); |
---|
| 11867 | + } |
---|
| 11868 | + |
---|
| 11869 | + gettex = texturebump.get(tex); |
---|
| 11870 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11871 | + if (gettex != null) |
---|
| 11872 | + { |
---|
| 11873 | + gettex.texture.dispose(); |
---|
| 11874 | + texturebump.remove(tex); |
---|
| 11875 | + } |
---|
10758 | 11876 | } |
---|
10759 | 11877 | } |
---|
10760 | 11878 | } |
---|
.. | .. |
---|
10767 | 11885 | if (checker != null && DrawMode() == DEFAULT) |
---|
10768 | 11886 | { |
---|
10769 | 11887 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10770 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11888 | + try |
---|
| 11889 | + { |
---|
| 11890 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11891 | + } |
---|
| 11892 | + catch (Exception e) |
---|
| 11893 | + { |
---|
| 11894 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11895 | + } |
---|
10771 | 11896 | // NEAREST |
---|
10772 | 11897 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10773 | 11898 | DrawChecker(gl); |
---|
.. | .. |
---|
10849 | 11974 | return; |
---|
10850 | 11975 | } |
---|
10851 | 11976 | |
---|
10852 | | - String string = obj.GetToolTip(); |
---|
| 11977 | + String string = obj.toString(); //.GetToolTip(); |
---|
10853 | 11978 | |
---|
10854 | 11979 | GL gl = GetGL(); |
---|
10855 | 11980 | |
---|
.. | .. |
---|
11166 | 12291 | //obj.TransformToWorld(light, light); |
---|
11167 | 12292 | for (int i = tp.size(); --i >= 0;) |
---|
11168 | 12293 | { |
---|
11169 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11170 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12294 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12295 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11171 | 12296 | } |
---|
11172 | 12297 | |
---|
11173 | 12298 | |
---|
.. | .. |
---|
11184 | 12309 | parentcam = cameras[0]; |
---|
11185 | 12310 | } |
---|
11186 | 12311 | |
---|
11187 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11188 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12312 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12313 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11189 | 12314 | |
---|
11190 | 12315 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11191 | 12316 | |
---|
.. | .. |
---|
11276 | 12401 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11277 | 12402 | |
---|
11278 | 12403 | String program = |
---|
| 12404 | + // Min shader |
---|
11279 | 12405 | "!!ARBfp1.0\n" + |
---|
| 12406 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12407 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12408 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12409 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12410 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12411 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12412 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12413 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12414 | + "TEMP temp;" + |
---|
| 12415 | + "TEMP light;" + |
---|
| 12416 | + "TEMP ndotl;" + |
---|
| 12417 | + "TEMP normal;" + |
---|
| 12418 | + "TEMP depth;" + |
---|
| 12419 | + "TEMP eye;" + |
---|
| 12420 | + "TEMP pos;" + |
---|
| 12421 | + |
---|
| 12422 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12423 | + Normalize("normal") + |
---|
| 12424 | + "MOV light, state.light[0].position;" + |
---|
| 12425 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12426 | + |
---|
| 12427 | + // shadow |
---|
| 12428 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12429 | + "MOV temp, pos;" + |
---|
| 12430 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12431 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12432 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12433 | + |
---|
| 12434 | + // No shadow when out of frustum |
---|
| 12435 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12436 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12437 | + |
---|
| 12438 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12439 | + |
---|
| 12440 | + // Backlit |
---|
| 12441 | + "MOV pos.w, zero123.y;" + |
---|
| 12442 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12443 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12444 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12445 | + Normalize("eye") + |
---|
| 12446 | + |
---|
| 12447 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12448 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12449 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12450 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12451 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12452 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12453 | + |
---|
| 12454 | + "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12455 | + |
---|
| 12456 | + // Pigment |
---|
| 12457 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12458 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12459 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12460 | + |
---|
| 12461 | + "MUL temp, temp, zero123.z;" + |
---|
| 12462 | + |
---|
| 12463 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12464 | + |
---|
| 12465 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12466 | + "MOV result.color, temp;" + |
---|
| 12467 | + "END"; |
---|
| 12468 | + |
---|
| 12469 | + String program2 = |
---|
| 12470 | + "!!ARBfp1.0\n" + |
---|
| 12471 | + |
---|
11280 | 12472 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11281 | 12473 | "PARAM light2cam0 = program.env[10];" + |
---|
11282 | 12474 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
11391 | 12583 | "TEMP shininess;" + |
---|
11392 | 12584 | "\n" + |
---|
11393 | 12585 | "MOV texSamp, one;" + |
---|
11394 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
11395 | | - |
---|
| 12586 | + |
---|
11396 | 12587 | "MOV mapgrid.x, one2048th.x;" + |
---|
11397 | 12588 | "MOV temp, fragment.texcoord[1];" + |
---|
11398 | 12589 | /* |
---|
.. | .. |
---|
11413 | 12604 | "MUL temp, floor, mapgrid.x;" + |
---|
11414 | 12605 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
11415 | 12606 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11416 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12607 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
11417 | 12608 | "") + |
---|
11418 | 12609 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
11419 | 12610 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
11420 | 12611 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11421 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12612 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
11422 | 12613 | "") + |
---|
11423 | 12614 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
11424 | 12615 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
11425 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12616 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
11426 | 12617 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
11427 | 12618 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
11428 | 12619 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11429 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12620 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
11430 | 12621 | "") + |
---|
11431 | 12622 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
11432 | 12623 | //"MOV params, material;" + |
---|
.. | .. |
---|
11797 | 12988 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
11798 | 12989 | "") + |
---|
11799 | 12990 | |
---|
11800 | | - // display shadow only (bump == 0) |
---|
| 12991 | + // display shadow only (fakedepth == 0) |
---|
11801 | 12992 | "SUB temp.x, half.x, shadow.x;" + |
---|
11802 | | - "MOV temp.y, -params6.x;" + |
---|
11803 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12993 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12994 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
11804 | 12995 | "SUB temp.y, one.x, temp.z;" + |
---|
11805 | 12996 | "MUL temp.x, temp.x, temp.y;" + |
---|
11806 | 12997 | "KIL temp.x;" + |
---|
.. | .. |
---|
11929 | 13120 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11930 | 13121 | |
---|
11931 | 13122 | "SUB temp.x, one.x, ndotl.x;" + |
---|
11932 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
11933 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13123 | + // Tuning for default skin |
---|
| 13124 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13125 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13126 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11934 | 13127 | "MUL temp.x, temp.x, temp.y;" + |
---|
11935 | 13128 | |
---|
11936 | 13129 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12129 | 13322 | //once = true; |
---|
12130 | 13323 | } |
---|
12131 | 13324 | |
---|
12132 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13325 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12133 | 13326 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12134 | 13327 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12135 | 13328 | |
---|
.. | .. |
---|
12222 | 13415 | return out; |
---|
12223 | 13416 | } |
---|
12224 | 13417 | |
---|
12225 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13418 | + // Also does frustum culling |
---|
| 13419 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12226 | 13420 | { |
---|
12227 | 13421 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12228 | 13422 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12229 | 13423 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13424 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13425 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12230 | 13426 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12231 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12232 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12233 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12234 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13427 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13428 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12235 | 13429 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12236 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13430 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12237 | 13431 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12238 | 13432 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12239 | 13433 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12240 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13434 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12241 | 13435 | |
---|
12242 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12243 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13436 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13437 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12244 | 13438 | } |
---|
12245 | 13439 | |
---|
12246 | 13440 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12262 | 13456 | |
---|
12263 | 13457 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12264 | 13458 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13459 | + |
---|
| 13460 | + // Compare fragment depth in light space with shadowmap. |
---|
12265 | 13461 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12266 | 13462 | "SGE temp.y, temp.x, zero.x;" + |
---|
12267 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13463 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13464 | + |
---|
| 13465 | + // Reverse comparison |
---|
12268 | 13466 | "SUB temp.x, one.x, temp.x;" + |
---|
12269 | 13467 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12270 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13468 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12271 | 13469 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12272 | 13470 | |
---|
12273 | 13471 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12281 | 13479 | // No shadow for backface |
---|
12282 | 13480 | "DP3 temp.x, normal, lightd;" + |
---|
12283 | 13481 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13482 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13483 | + |
---|
| 13484 | + // No shadow when out of frustum |
---|
| 13485 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12284 | 13486 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12285 | 13487 | ""; |
---|
12286 | 13488 | } |
---|
.. | .. |
---|
12427 | 13629 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12428 | 13630 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12429 | 13631 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12430 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13632 | + |
---|
| 13633 | + //Object3D.cVector2[] vector2buffer; |
---|
12431 | 13634 | |
---|
12432 | 13635 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12433 | 13636 | // OUT : diff, spec |
---|
.. | .. |
---|
12443 | 13646 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12444 | 13647 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12445 | 13648 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
12446 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
12447 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
12448 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13649 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13650 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13651 | + |
---|
| 13652 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12449 | 13653 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12450 | 13654 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12451 | 13655 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12839 | 14043 | public void mousePressed(MouseEvent e) |
---|
12840 | 14044 | { |
---|
12841 | 14045 | //System.out.println("mousePressed: " + e); |
---|
12842 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14046 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12843 | 14047 | } |
---|
12844 | 14048 | |
---|
12845 | 14049 | static long prevtime = 0; |
---|
.. | .. |
---|
12866 | 14070 | |
---|
12867 | 14071 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12868 | 14072 | |
---|
| 14073 | + if (BUTTONLESSWHEEL) |
---|
12869 | 14074 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12870 | 14075 | { |
---|
12871 | 14076 | return; |
---|
.. | .. |
---|
12874 | 14079 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12875 | 14080 | |
---|
12876 | 14081 | // TIMER |
---|
12877 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14082 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12878 | 14083 | { |
---|
12879 | 14084 | keepboxmode = BOXMODE; |
---|
12880 | 14085 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12914 | 14119 | // mode |= META; |
---|
12915 | 14120 | //} |
---|
12916 | 14121 | |
---|
12917 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12918 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14122 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14123 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12919 | 14124 | anchorX = ax; |
---|
12920 | 14125 | anchorY = ay; |
---|
12921 | 14126 | prevX = px; |
---|
.. | .. |
---|
12949 | 14154 | else |
---|
12950 | 14155 | if (evt.getSource() == AAtimer) |
---|
12951 | 14156 | { |
---|
| 14157 | + Globals.TIMERRUNNING = false; |
---|
12952 | 14158 | if (mouseDown) |
---|
12953 | 14159 | { |
---|
12954 | 14160 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12974 | 14180 | // LIVE = waslive; |
---|
12975 | 14181 | // wasliveok = true; |
---|
12976 | 14182 | // waslive = false; |
---|
| 14183 | + |
---|
| 14184 | + // May 2019 Forget it: |
---|
| 14185 | + if (true) |
---|
| 14186 | + return; |
---|
12977 | 14187 | |
---|
12978 | 14188 | // source == timer |
---|
12979 | 14189 | if (mouseDown) |
---|
.. | .. |
---|
13004 | 14214 | |
---|
13005 | 14215 | // fev 2014??? |
---|
13006 | 14216 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13007 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14217 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13008 | 14218 | pingthread.StepToTarget(true); // true); |
---|
13009 | 14219 | } |
---|
13010 | 14220 | // if (!LIVE) |
---|
.. | .. |
---|
13013 | 14223 | |
---|
13014 | 14224 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13015 | 14225 | |
---|
13016 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14226 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13017 | 14227 | { |
---|
13018 | 14228 | if (!wasliveok) |
---|
13019 | 14229 | return; |
---|
13020 | 14230 | |
---|
13021 | 14231 | AAtimer.restart(); // |
---|
| 14232 | + Globals.TIMERRUNNING = true; |
---|
13022 | 14233 | |
---|
13023 | 14234 | // waslive = LIVE; |
---|
13024 | 14235 | // LIVE = false; |
---|
.. | .. |
---|
13030 | 14241 | // touched = true; // main DL |
---|
13031 | 14242 | if (isRenderer) |
---|
13032 | 14243 | { |
---|
13033 | | - SetMouseMode(modifiers); |
---|
| 14244 | + SetMouseMode(modifiers, modifiersex); |
---|
13034 | 14245 | } |
---|
13035 | 14246 | |
---|
13036 | 14247 | selectX = anchorX = x; |
---|
.. | .. |
---|
13043 | 14254 | clicked = true; |
---|
13044 | 14255 | hold = false; |
---|
13045 | 14256 | |
---|
13046 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14257 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13047 | 14258 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13048 | 14259 | { |
---|
13049 | 14260 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13068 | 14279 | drag = false; |
---|
13069 | 14280 | //System.out.println("Mouse DOWN"); |
---|
13070 | 14281 | editObj = false; |
---|
13071 | | - ClickInfo info = new ClickInfo(); |
---|
13072 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13073 | | - info.pane = this; |
---|
13074 | | - info.camera = renderCamera; |
---|
13075 | | - info.x = x; |
---|
13076 | | - info.y = y; |
---|
13077 | | - info.modifiers = modifiers; |
---|
13078 | | - editObj = object.doEditClick(info, 0); |
---|
| 14282 | + //ClickInfo info = new ClickInfo(); |
---|
| 14283 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14284 | + object.clickInfo.pane = this; |
---|
| 14285 | + object.clickInfo.camera = renderCamera; |
---|
| 14286 | + object.clickInfo.x = x; |
---|
| 14287 | + object.clickInfo.y = y; |
---|
| 14288 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14289 | + editObj = object.doEditClick(//info, |
---|
| 14290 | + 0); |
---|
13079 | 14291 | if (!editObj) |
---|
13080 | 14292 | { |
---|
13081 | 14293 | hasMarquee = true; |
---|
.. | .. |
---|
13091 | 14303 | |
---|
13092 | 14304 | public void mouseDragged(MouseEvent e) |
---|
13093 | 14305 | { |
---|
| 14306 | + Globals.MOUSEDRAGGED = true; |
---|
| 14307 | + |
---|
| 14308 | + //System.out.println("mouseDragged: " + e); |
---|
13094 | 14309 | if (isRenderer) |
---|
13095 | 14310 | movingcamera = true; |
---|
| 14311 | + |
---|
13096 | 14312 | //if (drawing) |
---|
13097 | 14313 | //return; |
---|
13098 | | - //System.out.println("mouseDragged: " + e); |
---|
13099 | 14314 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13100 | 14315 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13101 | 14316 | { |
---|
.. | .. |
---|
13103 | 14318 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13104 | 14319 | } |
---|
13105 | 14320 | else |
---|
13106 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14321 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13107 | 14322 | |
---|
13108 | 14323 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13109 | 14324 | } |
---|
.. | .. |
---|
13115 | 14330 | cVector tmp = new cVector(); |
---|
13116 | 14331 | cVector tmp2 = new cVector(); |
---|
13117 | 14332 | boolean isMoving; |
---|
| 14333 | + |
---|
| 14334 | + public cVector TargetLookAt() |
---|
| 14335 | + { |
---|
| 14336 | + return targetLookAt; |
---|
| 14337 | + } |
---|
13118 | 14338 | |
---|
13119 | 14339 | class PingThread extends Thread |
---|
13120 | 14340 | { |
---|
.. | .. |
---|
13271 | 14491 | |
---|
13272 | 14492 | public void run() |
---|
13273 | 14493 | { |
---|
| 14494 | + new Exception().printStackTrace(); |
---|
13274 | 14495 | System.exit(0); |
---|
13275 | 14496 | for (;;) |
---|
13276 | 14497 | { |
---|
.. | .. |
---|
13334 | 14555 | { |
---|
13335 | 14556 | Globals.lighttouched = true; |
---|
13336 | 14557 | } |
---|
13337 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14558 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13338 | 14559 | } |
---|
13339 | 14560 | //else |
---|
13340 | 14561 | } |
---|
.. | .. |
---|
13348 | 14569 | void GoDown(int mod) |
---|
13349 | 14570 | { |
---|
13350 | 14571 | MODIFIERS |= COMMAND; |
---|
13351 | | - /* |
---|
| 14572 | + /**/ |
---|
13352 | 14573 | if((mod&SHIFT) == SHIFT) |
---|
13353 | 14574 | manipCamera.RotatePosition(0, -speed); |
---|
13354 | 14575 | else |
---|
13355 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13356 | | - */ |
---|
| 14576 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14577 | + /**/ |
---|
13357 | 14578 | if ((mod & SHIFT) == SHIFT) |
---|
13358 | 14579 | { |
---|
13359 | 14580 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13369 | 14590 | void GoUp(int mod) |
---|
13370 | 14591 | { |
---|
13371 | 14592 | MODIFIERS |= COMMAND; |
---|
13372 | | - /* |
---|
| 14593 | + /**/ |
---|
13373 | 14594 | if((mod&SHIFT) == SHIFT) |
---|
13374 | 14595 | manipCamera.RotatePosition(0, speed); |
---|
13375 | 14596 | else |
---|
13376 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13377 | | - */ |
---|
| 14597 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14598 | + /**/ |
---|
13378 | 14599 | if ((mod & SHIFT) == SHIFT) |
---|
13379 | 14600 | { |
---|
13380 | 14601 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13390 | 14611 | void GoLeft(int mod) |
---|
13391 | 14612 | { |
---|
13392 | 14613 | MODIFIERS |= COMMAND; |
---|
13393 | | - /* |
---|
| 14614 | + /**/ |
---|
13394 | 14615 | if((mod&SHIFT) == SHIFT) |
---|
13395 | | - manipCamera.RotatePosition(speed, 0); |
---|
13396 | | - else |
---|
13397 | 14616 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13398 | | - */ |
---|
| 14617 | + else |
---|
| 14618 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14619 | + /**/ |
---|
13399 | 14620 | if ((mod & SHIFT) == SHIFT) |
---|
13400 | 14621 | { |
---|
13401 | 14622 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13411 | 14632 | void GoRight(int mod) |
---|
13412 | 14633 | { |
---|
13413 | 14634 | MODIFIERS |= COMMAND; |
---|
13414 | | - /* |
---|
| 14635 | + /**/ |
---|
13415 | 14636 | if((mod&SHIFT) == SHIFT) |
---|
13416 | | - manipCamera.RotatePosition(-speed, 0); |
---|
13417 | | - else |
---|
13418 | 14637 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13419 | | - */ |
---|
| 14638 | + else |
---|
| 14639 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14640 | + /**/ |
---|
13420 | 14641 | if ((mod & SHIFT) == SHIFT) |
---|
13421 | 14642 | { |
---|
13422 | 14643 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13434 | 14655 | int X, Y; |
---|
13435 | 14656 | boolean SX, SY; |
---|
13436 | 14657 | |
---|
13437 | | - void drag(int x, int y, int modifiers) |
---|
| 14658 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13438 | 14659 | { |
---|
13439 | 14660 | if (IsFrozen()) |
---|
13440 | 14661 | { |
---|
.. | .. |
---|
13443 | 14664 | |
---|
13444 | 14665 | drag = true; // NEW |
---|
13445 | 14666 | |
---|
13446 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14667 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13447 | 14668 | |
---|
13448 | 14669 | X = x; |
---|
13449 | 14670 | Y = y; |
---|
13450 | 14671 | // floating state for animation |
---|
13451 | | - MODIFIERS = modifiers; |
---|
13452 | | - modifiers &= ~1024; |
---|
| 14672 | + MODIFIERS = modifiersex; |
---|
| 14673 | + modifiersex &= ~1024; |
---|
13453 | 14674 | if (false) // modifiers != 0) |
---|
13454 | 14675 | { |
---|
13455 | 14676 | //new Exception().printStackTrace(); |
---|
13456 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14677 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13457 | 14678 | System.out.println("SHIFT = " + SHIFT); |
---|
13458 | 14679 | System.out.println("CONTROL = " + COMMAND); |
---|
13459 | 14680 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13466 | 14687 | if (editObj) |
---|
13467 | 14688 | { |
---|
13468 | 14689 | drag = true; |
---|
13469 | | - ClickInfo info = new ClickInfo(); |
---|
13470 | | - info.bounds.setBounds(0, 0, |
---|
| 14690 | + //ClickInfo info = new ClickInfo(); |
---|
| 14691 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
13471 | 14692 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13472 | | - info.pane = this; |
---|
13473 | | - info.camera = renderCamera; |
---|
13474 | | - info.x = x; |
---|
13475 | | - info.y = y; |
---|
13476 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14693 | + object.clickInfo.pane = this; |
---|
| 14694 | + object.clickInfo.camera = renderCamera; |
---|
| 14695 | + object.clickInfo.x = x; |
---|
| 14696 | + object.clickInfo.y = y; |
---|
| 14697 | + object //.GetWindow().copy |
---|
| 14698 | + .doEditDrag(//info, |
---|
| 14699 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13477 | 14700 | } else |
---|
13478 | 14701 | { |
---|
13479 | 14702 | if (x < startX) |
---|
.. | .. |
---|
13622 | 14845 | } |
---|
13623 | 14846 | } |
---|
13624 | 14847 | |
---|
| 14848 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14849 | + |
---|
13625 | 14850 | public void mouseMoved(MouseEvent e) |
---|
13626 | 14851 | { |
---|
13627 | 14852 | //System.out.println("mouseMoved: " + e); |
---|
13628 | | - |
---|
13629 | 14853 | if (isRenderer) |
---|
13630 | 14854 | return; |
---|
13631 | 14855 | |
---|
13632 | | - ClickInfo ci = new ClickInfo(); |
---|
13633 | | - ci.x = e.getX(); |
---|
13634 | | - ci.y = e.getY(); |
---|
13635 | | - ci.modifiers = e.getModifiersEx(); |
---|
13636 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13637 | | - ci.pane = this; |
---|
13638 | | - ci.camera = renderCamera; |
---|
| 14856 | + // Mouse cursor feedback |
---|
| 14857 | + object.clickInfo.x = e.getX(); |
---|
| 14858 | + object.clickInfo.y = e.getY(); |
---|
| 14859 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14860 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14861 | + object.clickInfo.pane = this; |
---|
| 14862 | + object.clickInfo.camera = renderCamera; |
---|
13639 | 14863 | if (!isRenderer) |
---|
13640 | 14864 | { |
---|
13641 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14865 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14866 | + //Object3D copy = editWindow.copy; |
---|
| 14867 | + if (object.doEditClick(//clickInfo, |
---|
| 14868 | + 0)) |
---|
13642 | 14869 | { |
---|
13643 | 14870 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13644 | 14871 | } else |
---|
.. | .. |
---|
13650 | 14877 | |
---|
13651 | 14878 | public void mouseReleased(MouseEvent e) |
---|
13652 | 14879 | { |
---|
| 14880 | + Globals.MOUSEDRAGGED = false; |
---|
| 14881 | + |
---|
13653 | 14882 | movingcamera = false; |
---|
| 14883 | + X = 0; // getBounds().width/2; |
---|
| 14884 | + Y = 0; // getBounds().height/2; |
---|
13654 | 14885 | //System.out.println("mouseReleased: " + e); |
---|
13655 | 14886 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13656 | 14887 | } |
---|
.. | .. |
---|
13673 | 14904 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13674 | 14905 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13675 | 14906 | |
---|
13676 | | - if (control || command || IsFrozen()) |
---|
| 14907 | +// No delay if (control || command || IsFrozen()) |
---|
13677 | 14908 | timeout = true; |
---|
13678 | | - else |
---|
| 14909 | +// ?? May 2019 else |
---|
13679 | 14910 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13680 | 14911 | mouseDown = false; |
---|
13681 | 14912 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13785 | 15016 | System.out.println("keyReleased: " + e); |
---|
13786 | 15017 | } |
---|
13787 | 15018 | |
---|
13788 | | - void SetMouseMode(int modifiers) |
---|
| 15019 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13789 | 15020 | { |
---|
13790 | 15021 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13791 | 15022 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13797 | 15028 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13798 | 15029 | // return; |
---|
13799 | 15030 | //System.out.println("SetMode = " + modifiers); |
---|
13800 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15031 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13801 | 15032 | { |
---|
13802 | 15033 | mouseMode |= ZOOM; |
---|
13803 | 15034 | } |
---|
13804 | 15035 | |
---|
13805 | 15036 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13806 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15037 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13807 | 15038 | { |
---|
13808 | 15039 | mouseMode |= VR; // BACKFORTH; |
---|
13809 | 15040 | } |
---|
13810 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15041 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13811 | 15042 | { |
---|
13812 | 15043 | mouseMode |= SELECT; |
---|
13813 | 15044 | } |
---|
13814 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15045 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13815 | 15046 | { |
---|
13816 | 15047 | mouseMode |= SELECT; |
---|
13817 | 15048 | } |
---|
13818 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15049 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13819 | 15050 | { |
---|
13820 | 15051 | mouseMode &= ~VR; |
---|
13821 | 15052 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13844 | 15075 | |
---|
13845 | 15076 | if (isRenderer) // |
---|
13846 | 15077 | { |
---|
13847 | | - SetMouseMode(modifiers); |
---|
| 15078 | + SetMouseMode(0, modifiers); |
---|
13848 | 15079 | } |
---|
13849 | 15080 | |
---|
13850 | | - theRenderer.keyPressed(key); |
---|
| 15081 | + Globals.theRenderer.keyPressed(key); |
---|
13851 | 15082 | } |
---|
13852 | 15083 | |
---|
13853 | 15084 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13859 | 15090 | float SATPOW = 1; // 2; // 0.5f; |
---|
13860 | 15091 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13861 | 15092 | |
---|
13862 | | - void keyPressed(int key) |
---|
| 15093 | + public void keyPressed(int key) |
---|
13863 | 15094 | { |
---|
13864 | 15095 | if (key >= '0' && key <= '5') |
---|
13865 | 15096 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13906 | 15137 | // break; |
---|
13907 | 15138 | case 'T': |
---|
13908 | 15139 | CACHETEXTURE ^= true; |
---|
13909 | | - textures.clear(); |
---|
| 15140 | + texturepigment.clear(); |
---|
| 15141 | + texturebump.clear(); |
---|
13910 | 15142 | // repaint(); |
---|
13911 | 15143 | break; |
---|
13912 | 15144 | case 'Y': |
---|
.. | .. |
---|
13991 | 15223 | case 'E' : COMPACT ^= true; |
---|
13992 | 15224 | repaint(); |
---|
13993 | 15225 | break; |
---|
13994 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15226 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15227 | + //DEBUGHSB ^= true; |
---|
| 15228 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13995 | 15229 | repaint(); |
---|
13996 | 15230 | break; |
---|
13997 | 15231 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14016 | 15250 | RevertCamera(); |
---|
14017 | 15251 | repaint(); |
---|
14018 | 15252 | break; |
---|
14019 | | - case 'L': |
---|
14020 | 15253 | case 'l': |
---|
| 15254 | + //case 'L': |
---|
14021 | 15255 | if (lightMode) |
---|
14022 | 15256 | { |
---|
14023 | 15257 | lightMode = false; |
---|
.. | .. |
---|
14160 | 15394 | case '_': |
---|
14161 | 15395 | kompactbit = 5; |
---|
14162 | 15396 | break; |
---|
14163 | | - case '+': |
---|
14164 | | - kompactbit = 6; |
---|
14165 | | - break; |
---|
| 15397 | +// case '+': |
---|
| 15398 | +// kompactbit = 6; |
---|
| 15399 | +// break; |
---|
14166 | 15400 | case ' ': |
---|
14167 | 15401 | lightMode ^= true; |
---|
14168 | 15402 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14174 | 15408 | case ESC: |
---|
14175 | 15409 | RENDERPROGRAM += 1; |
---|
14176 | 15410 | RENDERPROGRAM %= 3; |
---|
| 15411 | + |
---|
14177 | 15412 | repaint(); |
---|
14178 | 15413 | break; |
---|
14179 | 15414 | case 'Z': |
---|
14180 | 15415 | //RESIZETEXTURE ^= true; |
---|
14181 | 15416 | //break; |
---|
14182 | 15417 | case 'z': |
---|
14183 | | - RENDERSHADOW ^= true; |
---|
| 15418 | + Globals.RENDERSHADOW ^= true; |
---|
14184 | 15419 | Globals.lighttouched = true; |
---|
14185 | 15420 | repaint(); |
---|
14186 | 15421 | break; |
---|
.. | .. |
---|
14213 | 15448 | case DELETE: |
---|
14214 | 15449 | ClearSelection(); |
---|
14215 | 15450 | break; |
---|
14216 | | - /* |
---|
14217 | 15451 | case '+': |
---|
| 15452 | + |
---|
| 15453 | + /* |
---|
14218 | 15454 | //fontsize += 1; |
---|
14219 | 15455 | bbzoom *= 2; |
---|
14220 | 15456 | repaint(); |
---|
.. | .. |
---|
14231 | 15467 | case '=': |
---|
14232 | 15468 | IncDepth(); |
---|
14233 | 15469 | //fontsize += 1; |
---|
14234 | | - object.editWindow.refreshContents(true); |
---|
| 15470 | + object.GetWindow().refreshContents(true); |
---|
14235 | 15471 | maskbit = 6; |
---|
14236 | 15472 | break; |
---|
14237 | 15473 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14238 | 15474 | DecDepth(); |
---|
14239 | 15475 | maskbit = 5; |
---|
14240 | 15476 | //if(fontsize > 1) fontsize -= 1; |
---|
14241 | | - if (object.editWindow == null) |
---|
14242 | | - new Exception().printStackTrace(); |
---|
14243 | | - else |
---|
14244 | | - object.editWindow.refreshContents(true); |
---|
| 15477 | +// if (object.editWindow == null) |
---|
| 15478 | +// new Exception().printStackTrace(); |
---|
| 15479 | +// else |
---|
| 15480 | + object.GetWindow().refreshContents(true); |
---|
14245 | 15481 | break; |
---|
14246 | 15482 | case '{': |
---|
14247 | 15483 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14296 | 15532 | } |
---|
14297 | 15533 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14298 | 15534 | } |
---|
| 15535 | + |
---|
14299 | 15536 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14300 | 15537 | |
---|
14301 | 15538 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14303 | 15540 | //mode = ROTATE; |
---|
14304 | 15541 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14305 | 15542 | { |
---|
14306 | | - SetMouseMode(modifiers); |
---|
| 15543 | + SetMouseMode(0, modifiers); |
---|
14307 | 15544 | } |
---|
14308 | 15545 | } |
---|
14309 | 15546 | |
---|
14310 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15547 | + public void processKeyEvent(KeyEvent e) |
---|
14311 | 15548 | { |
---|
14312 | 15549 | switch (e.getID()) |
---|
14313 | 15550 | { |
---|
.. | .. |
---|
14437 | 15674 | |
---|
14438 | 15675 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14439 | 15676 | { |
---|
14440 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14441 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15677 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15678 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15679 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14442 | 15680 | { |
---|
14443 | 15681 | mouseMoved(e); |
---|
14444 | 15682 | } else |
---|
.. | .. |
---|
14463 | 15701 | } |
---|
14464 | 15702 | */ |
---|
14465 | 15703 | |
---|
14466 | | - object.editWindow.EditSelection(); |
---|
| 15704 | + object.GetWindow().EditSelection(false); |
---|
14467 | 15705 | } |
---|
14468 | 15706 | |
---|
14469 | 15707 | void SelectParent() |
---|
14470 | 15708 | { |
---|
| 15709 | + new Exception().printStackTrace(); |
---|
14471 | 15710 | System.exit(0); |
---|
14472 | 15711 | Composite group = (Composite) object; |
---|
14473 | 15712 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14479 | 15718 | { |
---|
14480 | 15719 | //selectees.remove(i); |
---|
14481 | 15720 | System.out.println("select parent of " + elem); |
---|
14482 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15721 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14483 | 15722 | } else |
---|
14484 | 15723 | { |
---|
14485 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15724 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14486 | 15725 | } |
---|
14487 | 15726 | |
---|
14488 | 15727 | first = false; |
---|
.. | .. |
---|
14491 | 15730 | |
---|
14492 | 15731 | void SelectChildren() |
---|
14493 | 15732 | { |
---|
| 15733 | + new Exception().printStackTrace(); |
---|
14494 | 15734 | System.exit(0); |
---|
14495 | 15735 | /* |
---|
14496 | 15736 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14523 | 15763 | for (int j = 0; j < group.children.size(); j++) |
---|
14524 | 15764 | { |
---|
14525 | 15765 | elem = (Object3D) group.children.elementAt(j); |
---|
14526 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15766 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14527 | 15767 | first = false; |
---|
14528 | 15768 | } |
---|
14529 | 15769 | } else |
---|
14530 | 15770 | { |
---|
14531 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15771 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14532 | 15772 | } |
---|
14533 | 15773 | |
---|
14534 | 15774 | first = false; |
---|
.. | .. |
---|
14539 | 15779 | { |
---|
14540 | 15780 | //Composite group = (Composite) object; |
---|
14541 | 15781 | Object3D group = object; |
---|
14542 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15782 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14543 | 15783 | } |
---|
14544 | 15784 | |
---|
14545 | 15785 | void ResetTransform(int mask) |
---|
14546 | 15786 | { |
---|
14547 | 15787 | //Composite group = (Composite) object; |
---|
14548 | 15788 | Object3D group = object; |
---|
14549 | | - group.editWindow.ResetTransform(mask); |
---|
| 15789 | + group.GetWindow().ResetTransform(mask); |
---|
14550 | 15790 | } |
---|
14551 | 15791 | |
---|
14552 | 15792 | void FlipTransform() |
---|
14553 | 15793 | { |
---|
14554 | 15794 | //Composite group = (Composite) object; |
---|
14555 | 15795 | Object3D group = object; |
---|
14556 | | - group.editWindow.FlipTransform(); |
---|
| 15796 | + group.GetWindow().FlipTransform(); |
---|
14557 | 15797 | // group.editWindow.ReduceMesh(true); |
---|
14558 | 15798 | } |
---|
14559 | 15799 | |
---|
.. | .. |
---|
14561 | 15801 | { |
---|
14562 | 15802 | //Composite group = (Composite) object; |
---|
14563 | 15803 | Object3D group = object; |
---|
14564 | | - group.editWindow.PrintMemory(); |
---|
| 15804 | + group.GetWindow().PrintMemory(); |
---|
14565 | 15805 | // group.editWindow.ReduceMesh(true); |
---|
14566 | 15806 | } |
---|
14567 | 15807 | |
---|
.. | .. |
---|
14569 | 15809 | { |
---|
14570 | 15810 | //Composite group = (Composite) object; |
---|
14571 | 15811 | Object3D group = object; |
---|
14572 | | - group.editWindow.ResetCentroid(); |
---|
| 15812 | + group.GetWindow().ResetCentroid(); |
---|
14573 | 15813 | } |
---|
14574 | 15814 | |
---|
14575 | 15815 | void IncDepth() |
---|
.. | .. |
---|
14651 | 15891 | |
---|
14652 | 15892 | int width = getBounds().width; |
---|
14653 | 15893 | int height = getBounds().height; |
---|
14654 | | - ClickInfo info = new ClickInfo(); |
---|
14655 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14656 | 15894 | //Image img = CreateImage(width, height); |
---|
14657 | 15895 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15896 | + |
---|
14658 | 15897 | Graphics gr = g; // img.getGraphics(); |
---|
| 15898 | + |
---|
14659 | 15899 | if (!hasMarquee) |
---|
14660 | 15900 | { |
---|
14661 | 15901 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14727 | 15967 | } |
---|
14728 | 15968 | if (object != null && !hasMarquee) |
---|
14729 | 15969 | { |
---|
| 15970 | + if (object.clickInfo == null) |
---|
| 15971 | + object.clickInfo = new ClickInfo(); |
---|
| 15972 | + ClickInfo info = object.clickInfo; |
---|
| 15973 | + //ClickInfo info = new ClickInfo(); |
---|
| 15974 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15975 | + |
---|
14730 | 15976 | if (isRenderer) |
---|
14731 | 15977 | { |
---|
14732 | | - info.flags++; |
---|
| 15978 | + object.clickInfo.flags++; |
---|
14733 | 15979 | double frameAspect = (double) width / (double) height; |
---|
14734 | 15980 | if (frameAspect > renderCamera.aspect) |
---|
14735 | 15981 | { |
---|
14736 | 15982 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
14737 | | - info.bounds.width -= width - desired; |
---|
14738 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15983 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15984 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
14739 | 15985 | } else |
---|
14740 | 15986 | { |
---|
14741 | 15987 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
14742 | | - info.bounds.height -= height - desired; |
---|
14743 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15988 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15989 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
14744 | 15990 | } |
---|
14745 | 15991 | } |
---|
14746 | | - info.g = gr; |
---|
14747 | | - info.camera = renderCamera; |
---|
| 15992 | + |
---|
| 15993 | + object.clickInfo.g = gr; |
---|
| 15994 | + object.clickInfo.camera = renderCamera; |
---|
14748 | 15995 | /* |
---|
14749 | 15996 | // Memory intensive (brep.verticescopy) |
---|
14750 | 15997 | if (!(object instanceof Composite)) |
---|
14751 | 15998 | object.draw(info, 0, false); // SLOW : |
---|
14752 | 15999 | */ |
---|
14753 | | - if (!isRenderer) |
---|
| 16000 | + if (!isRenderer) // && drag) |
---|
14754 | 16001 | { |
---|
14755 | | - object.drawEditHandles(info, 0); |
---|
| 16002 | + Grafreed.Assert(object != null); |
---|
| 16003 | + Grafreed.Assert(object.selection != null); |
---|
| 16004 | + if (object.selection.Size() > 0) |
---|
| 16005 | + { |
---|
| 16006 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16007 | + |
---|
| 16008 | + object.clickInfo.DX = 0; |
---|
| 16009 | + object.clickInfo.DY = 0; |
---|
| 16010 | + object.clickInfo.W = 1; |
---|
| 16011 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16012 | + { |
---|
| 16013 | + info.DX = X; |
---|
| 16014 | + if (X != 0) |
---|
| 16015 | + info.DX -= info.bounds.width/2; |
---|
| 16016 | + |
---|
| 16017 | + info.DY = Y; |
---|
| 16018 | + if (Y != 0) |
---|
| 16019 | + info.DY -= info.bounds.height/2; |
---|
| 16020 | + } |
---|
| 16021 | + |
---|
| 16022 | + object.drawEditHandles(//info, |
---|
| 16023 | + 0); |
---|
| 16024 | + |
---|
| 16025 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16026 | + { |
---|
| 16027 | + switch (hitSomething) |
---|
| 16028 | + { |
---|
| 16029 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16030 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16031 | + break; |
---|
| 16032 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16033 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16034 | + break; |
---|
| 16035 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16036 | + gr.drawLine(X, Y, 0, 0); |
---|
| 16037 | + break; |
---|
| 16038 | + } |
---|
| 16039 | + |
---|
| 16040 | + } |
---|
| 16041 | + } |
---|
14756 | 16042 | } |
---|
14757 | 16043 | } |
---|
| 16044 | + |
---|
14758 | 16045 | if (isRenderer) |
---|
14759 | 16046 | { |
---|
14760 | 16047 | //gr.setColor(Color.black); |
---|
14761 | 16048 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14762 | 16049 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14763 | 16050 | } |
---|
| 16051 | + |
---|
14764 | 16052 | if (hasMarquee) |
---|
14765 | 16053 | { |
---|
14766 | 16054 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
14873 | 16161 | public boolean mouseDown(Event evt, int x, int y) |
---|
14874 | 16162 | { |
---|
14875 | 16163 | System.out.println("mouseDown: " + evt); |
---|
| 16164 | + System.exit(0); |
---|
14876 | 16165 | /* |
---|
14877 | 16166 | locked = true; |
---|
14878 | 16167 | drag = false; |
---|
.. | .. |
---|
14916 | 16205 | { |
---|
14917 | 16206 | keyPressed(0, modifiers); |
---|
14918 | 16207 | } |
---|
14919 | | - clickStart(x, y, modifiers); |
---|
| 16208 | + // clickStart(x, y, modifiers); |
---|
14920 | 16209 | return true; |
---|
14921 | 16210 | } |
---|
14922 | 16211 | |
---|
.. | .. |
---|
15034 | 16323 | { |
---|
15035 | 16324 | keyReleased(0, 0); |
---|
15036 | 16325 | } |
---|
15037 | | - drag(x, y, modifiers); |
---|
| 16326 | + drag(x, y, 0, modifiers); |
---|
15038 | 16327 | return true; |
---|
15039 | 16328 | } |
---|
15040 | 16329 | |
---|
.. | .. |
---|
15166 | 16455 | Object3D object; |
---|
15167 | 16456 | static Object3D trackedobject; |
---|
15168 | 16457 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15169 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16458 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15170 | 16459 | /*static*/ Camera eyeCamera; |
---|
15171 | 16460 | /*static*/ Camera lightCamera; |
---|
15172 | 16461 | int cameracount; |
---|
.. | .. |
---|
15451 | 16740 | cStatic.objectstack[materialdepth++] = checker; |
---|
15452 | 16741 | //System.out.println("material " + material); |
---|
15453 | 16742 | //Applet3D.tracein(this, selected); |
---|
15454 | | - vector2buffer = checker.projectedVertices; |
---|
| 16743 | + //vector2buffer = checker.projectedVertices; |
---|
15455 | 16744 | |
---|
15456 | 16745 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15457 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16746 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15458 | 16747 | |
---|
15459 | 16748 | materialdepth -= 1; |
---|
15460 | 16749 | if (materialdepth > 0) |
---|
15461 | 16750 | { |
---|
15462 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15463 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16751 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16752 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15464 | 16753 | } |
---|
15465 | 16754 | //checker.GetMaterial().opacity = 1f; |
---|
15466 | 16755 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15546 | 16835 | } |
---|
15547 | 16836 | } |
---|
15548 | 16837 | |
---|
| 16838 | + private Object3D GetFolder() |
---|
| 16839 | + { |
---|
| 16840 | + Object3D folder = object.GetWindow().copy; |
---|
| 16841 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16842 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16843 | + return folder; |
---|
| 16844 | + } |
---|
| 16845 | + |
---|
15549 | 16846 | class SelectBuffer implements GLEventListener |
---|
15550 | 16847 | { |
---|
15551 | 16848 | |
---|
.. | .. |
---|
15604 | 16901 | { |
---|
15605 | 16902 | if (!selection) |
---|
15606 | 16903 | { |
---|
| 16904 | + new Exception().printStackTrace(); |
---|
15607 | 16905 | System.exit(0); |
---|
15608 | 16906 | return; |
---|
15609 | 16907 | } |
---|
.. | .. |
---|
15624 | 16922 | |
---|
15625 | 16923 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15626 | 16924 | |
---|
| 16925 | + if (PAINTMODE) |
---|
| 16926 | + { |
---|
| 16927 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16928 | + { |
---|
| 16929 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16930 | + |
---|
| 16931 | + // Make what you paint not selectable. |
---|
| 16932 | + paintobj.ResetSelectable(); |
---|
| 16933 | + } |
---|
| 16934 | + } |
---|
| 16935 | + |
---|
15627 | 16936 | //int tmp = selection_view; |
---|
15628 | 16937 | //selection_view = -1; |
---|
15629 | 16938 | int temp = DrawMode(); |
---|
.. | .. |
---|
15635 | 16944 | // temp = DEFAULT; // patch for selection debug |
---|
15636 | 16945 | Globals.drawMode = temp; // WARNING |
---|
15637 | 16946 | |
---|
| 16947 | + if (PAINTMODE) |
---|
| 16948 | + { |
---|
| 16949 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16950 | + { |
---|
| 16951 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16952 | + |
---|
| 16953 | + // Revert. |
---|
| 16954 | + paintobj.RestoreSelectable(); |
---|
| 16955 | + } |
---|
| 16956 | + } |
---|
| 16957 | + |
---|
15638 | 16958 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15639 | 16959 | |
---|
15640 | 16960 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15682 | 17002 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15683 | 17003 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15684 | 17004 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17005 | + |
---|
| 17006 | + CreateSelectedPoint(); |
---|
15685 | 17007 | |
---|
15686 | 17008 | // Will fit the mesh !!! |
---|
15687 | 17009 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15731 | 17053 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
15732 | 17054 | } |
---|
15733 | 17055 | |
---|
15734 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17056 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15735 | 17057 | } |
---|
15736 | 17058 | } |
---|
15737 | 17059 | |
---|
15738 | 17060 | if (!movingcamera && !PAINTMODE) |
---|
15739 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17061 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15740 | 17062 | |
---|
15741 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17063 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15742 | 17064 | { |
---|
15743 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17065 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15744 | 17066 | |
---|
15745 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17067 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17068 | + { |
---|
| 17069 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15746 | 17070 | |
---|
15747 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
15748 | | - |
---|
15749 | | - group.add(paintobj); // link |
---|
15750 | | - |
---|
15751 | | - object.editWindow.SnapObject(group); |
---|
15752 | | - |
---|
15753 | | - Object3D folder = object.editWindow.copy; |
---|
15754 | | - |
---|
15755 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
15756 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
15757 | | - |
---|
15758 | | - folder.add(group); |
---|
15759 | | - |
---|
15760 | | - object.editWindow.ResetModel(); |
---|
15761 | | - object.editWindow.refreshContents(); |
---|
| 17071 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17072 | + |
---|
| 17073 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17074 | + |
---|
| 17075 | + inst.add(paintobj); // link |
---|
| 17076 | + |
---|
| 17077 | + object.GetWindow().SnapObject(inst); |
---|
| 17078 | + |
---|
| 17079 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17080 | + |
---|
| 17081 | + folder.add(inst); |
---|
| 17082 | + |
---|
| 17083 | + object.GetWindow().ResetModel(); |
---|
| 17084 | + object.GetWindow().refreshContents(); |
---|
| 17085 | + } |
---|
15762 | 17086 | } |
---|
15763 | 17087 | else |
---|
15764 | 17088 | paintcount = 0; |
---|
.. | .. |
---|
15797 | 17121 | //System.out.println("objects[color] = " + objects[color]); |
---|
15798 | 17122 | //objects[color].Select(); |
---|
15799 | 17123 | indexcount = 0; |
---|
| 17124 | + ObjEditor window = object.GetWindow(); |
---|
| 17125 | + if (window != null && deselect) |
---|
| 17126 | + { |
---|
| 17127 | + window.Select(null, deselect, true); |
---|
| 17128 | + } |
---|
15800 | 17129 | object.Select(color, deselect); |
---|
15801 | 17130 | } |
---|
15802 | 17131 | |
---|
.. | .. |
---|
15896 | 17225 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15897 | 17226 | } |
---|
15898 | 17227 | |
---|
15899 | | - if (!RENDERSHADOW) |
---|
| 17228 | + if (!Globals.RENDERSHADOW) |
---|
15900 | 17229 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15901 | 17230 | |
---|
15902 | 17231 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15906 | 17235 | //gl.glColorMask(false, false, false, false); |
---|
15907 | 17236 | |
---|
15908 | 17237 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15909 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17238 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15910 | 17239 | { |
---|
15911 | 17240 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15912 | 17241 | |
---|
.. | .. |
---|
15966 | 17295 | |
---|
15967 | 17296 | class AntialiasBuffer implements GLEventListener |
---|
15968 | 17297 | { |
---|
15969 | | - |
---|
15970 | 17298 | CameraPane parent = null; |
---|
15971 | 17299 | |
---|
15972 | 17300 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16323 | 17651 | int AAbuffersize = 0; |
---|
16324 | 17652 | |
---|
16325 | 17653 | //double[] selectedpoint = new double[3]; |
---|
16326 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17654 | + static Superellipsoid selectedpoint; |
---|
16327 | 17655 | static Sphere previousselectedpoint = null; |
---|
16328 | | - static Sphere debugpointG = new Sphere(); |
---|
16329 | | - static Sphere debugpointP = new Sphere(); |
---|
16330 | | - static Sphere debugpointC = new Sphere(); |
---|
16331 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17656 | + static Sphere debugpointG; |
---|
| 17657 | + static Sphere debugpointP; |
---|
| 17658 | + static Sphere debugpointC; |
---|
| 17659 | + static Sphere debugpointR; |
---|
16332 | 17660 | |
---|
16333 | 17661 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16334 | 17662 | |
---|
16335 | | - static |
---|
16336 | | - { |
---|
16337 | | - for (int i=0; i<8; i++) |
---|
16338 | | - { |
---|
16339 | | - debugpoints[i] = new Sphere(); |
---|
16340 | | - } |
---|
16341 | | - } |
---|
16342 | | - |
---|
16343 | 17663 | static void InitPoints(float radius) |
---|
16344 | 17664 | { |
---|
16345 | 17665 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16359 | 17679 | } |
---|
16360 | 17680 | } |
---|
16361 | 17681 | |
---|
16362 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17682 | + static void DrawPoints(iCameraPane cpane) |
---|
16363 | 17683 | { |
---|
16364 | 17684 | for (int i=0; i<8; i++) // first and last are red |
---|
16365 | 17685 | { |
---|
.. | .. |
---|
16391 | 17711 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16392 | 17712 | // Depth buffer format |
---|
16393 | 17713 | //private int depth_format; |
---|
16394 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17714 | + |
---|
| 17715 | + public void NextIndex() |
---|
16395 | 17716 | { |
---|
16396 | 17717 | indexcount+=16; |
---|
16397 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17718 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16398 | 17719 | //objects[indexcount] = o; |
---|
16399 | 17720 | //System.out.println("indexcount = " + indexcount); |
---|
16400 | 17721 | } |
---|