.. | .. |
---|
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) |
---|
.. | .. |
---|
192 | 229 | |
---|
193 | 230 | /// INTERFACE |
---|
194 | 231 | |
---|
| 232 | + public javax.media.opengl.GL GetGL0() |
---|
| 233 | + { |
---|
| 234 | + return null; |
---|
| 235 | + } |
---|
| 236 | + |
---|
| 237 | + public int GenList() |
---|
| 238 | + { |
---|
| 239 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 240 | + return gl.glGenLists(1); |
---|
| 241 | + } |
---|
| 242 | + |
---|
| 243 | + public void NewList(int id) |
---|
| 244 | + { |
---|
| 245 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 246 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 247 | + } |
---|
| 248 | + |
---|
| 249 | + public void CallList(int id) |
---|
| 250 | + { |
---|
| 251 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 252 | + gl.glCallList(id); |
---|
| 253 | + } |
---|
| 254 | + |
---|
| 255 | + public void EndList() |
---|
| 256 | + { |
---|
| 257 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 258 | + gl.glEndList(); |
---|
| 259 | + } |
---|
| 260 | + |
---|
195 | 261 | public boolean IsBoxMode() |
---|
196 | 262 | { |
---|
197 | 263 | return BOXMODE; |
---|
| 264 | + } |
---|
| 265 | + |
---|
| 266 | + public boolean IsZoomBoxMode() |
---|
| 267 | + { |
---|
| 268 | + return ZOOMBOXMODE; |
---|
198 | 269 | } |
---|
199 | 270 | |
---|
200 | 271 | public void ClearDepth() |
---|
.. | .. |
---|
236 | 307 | return this.ambientOcclusion; |
---|
237 | 308 | } |
---|
238 | 309 | |
---|
| 310 | + public boolean IsDebugSelection() |
---|
| 311 | + { |
---|
| 312 | + return DEBUG_SELECTION; |
---|
| 313 | + } |
---|
| 314 | + |
---|
239 | 315 | public boolean IsFrozen() |
---|
240 | 316 | { |
---|
241 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 317 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
242 | 318 | |
---|
243 | 319 | return !selectmode && cameracount == 0; // != 0; |
---|
244 | 320 | } |
---|
.. | .. |
---|
259 | 335 | return lightCamera; |
---|
260 | 336 | } |
---|
261 | 337 | |
---|
| 338 | + public Camera ManipCamera() |
---|
| 339 | + { |
---|
| 340 | + return manipCamera; |
---|
| 341 | + } |
---|
| 342 | + |
---|
262 | 343 | public Camera RenderCamera() |
---|
263 | 344 | { |
---|
264 | 345 | return renderCamera; |
---|
| 346 | + } |
---|
| 347 | + |
---|
| 348 | + public Camera[] Cameras() |
---|
| 349 | + { |
---|
| 350 | + return cameras; |
---|
265 | 351 | } |
---|
266 | 352 | |
---|
267 | 353 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
277 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
278 | 364 | //System.out.println("material " + material); |
---|
279 | 365 | //Applet3D.tracein(this, selected); |
---|
280 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
281 | 367 | if (obj instanceof Camera) |
---|
282 | 368 | { |
---|
283 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
286 | 372 | display.options1[2] = material.shadowbias; |
---|
287 | 373 | display.options1[3] = material.aniso; |
---|
288 | 374 | display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
289 | 380 | display.options2[0] = material.opacity; |
---|
290 | 381 | display.options2[1] = material.diffuse; |
---|
291 | 382 | display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
292 | 386 | |
---|
293 | 387 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
294 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
295 | 392 | display.options4[1] = material.subsurface; |
---|
296 | 393 | display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
297 | 397 | |
---|
298 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
299 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
309 | 409 | /**/ |
---|
310 | 410 | } else |
---|
311 | 411 | { |
---|
312 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
313 | 413 | } |
---|
314 | 414 | } else |
---|
315 | 415 | { |
---|
.. | .. |
---|
333 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
334 | 434 | //System.out.println("material " + material); |
---|
335 | 435 | //Applet3D.tracein("selected ", selected); |
---|
336 | | - display.vector2buffer = obj.projectedVertices; |
---|
337 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
338 | 438 | } |
---|
339 | 439 | } |
---|
340 | 440 | |
---|
.. | .. |
---|
351 | 451 | materialdepth -= 1; |
---|
352 | 452 | if (materialdepth > 0) |
---|
353 | 453 | { |
---|
354 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
355 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 454 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 455 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
356 | 456 | } |
---|
357 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
358 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
372 | 472 | materialdepth -= 1; |
---|
373 | 473 | if (materialdepth > 0) |
---|
374 | 474 | { |
---|
375 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
376 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 475 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 476 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
377 | 477 | } |
---|
378 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
379 | 479 | //else |
---|
.. | .. |
---|
408 | 508 | |
---|
409 | 509 | javax.media.opengl.GL gl = display.GetGL(); |
---|
410 | 510 | |
---|
411 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 511 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
412 | 512 | |
---|
413 | 513 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
414 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
415 | 515 | { |
---|
416 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
417 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 517 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 518 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 519 | + ; |
---|
418 | 520 | if (!hasnorm) |
---|
419 | 521 | { |
---|
420 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
421 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
422 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
423 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
760 | 862 | //// tris.postdraw(this); |
---|
761 | 863 | } |
---|
762 | 864 | |
---|
| 865 | + static Camera localcamera = new Camera(); |
---|
| 866 | + static cVector from = new cVector(); |
---|
| 867 | + static cVector to = new cVector(); |
---|
| 868 | + |
---|
| 869 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 870 | + { |
---|
| 871 | + CameraPane cp = this; |
---|
| 872 | + |
---|
| 873 | + Camera keep = cp.RenderCamera(); |
---|
| 874 | + cp.renderCamera = localcamera; |
---|
| 875 | + |
---|
| 876 | + if (br.trimmed) |
---|
| 877 | + { |
---|
| 878 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 879 | + |
---|
| 880 | + int i3 = 0; |
---|
| 881 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 882 | + { |
---|
| 883 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 884 | + continue; |
---|
| 885 | + |
---|
| 886 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 887 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 888 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 889 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 890 | + LA.xformPos(from, transform, from); |
---|
| 891 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 892 | + localcamera.setAim(from, to); |
---|
| 893 | + |
---|
| 894 | + CameraPane.occlusionbuffer.display(); |
---|
| 895 | + |
---|
| 896 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 897 | + cp.display(); // debug |
---|
| 898 | + |
---|
| 899 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 900 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 901 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 902 | + |
---|
| 903 | + if ((i % 100) == 0 && i != 0) |
---|
| 904 | + { |
---|
| 905 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 906 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 907 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 908 | + } |
---|
| 909 | + } |
---|
| 910 | + |
---|
| 911 | + br.colors = colors; |
---|
| 912 | + } |
---|
| 913 | + else |
---|
| 914 | + { |
---|
| 915 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 916 | + { |
---|
| 917 | + Vertex v = br.GetVertex(i); |
---|
| 918 | + |
---|
| 919 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 920 | + continue; |
---|
| 921 | + |
---|
| 922 | + from.set(v.x, v.y, v.z); |
---|
| 923 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 924 | + LA.xformPos(from, transform, from); |
---|
| 925 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 926 | + localcamera.setAim(from, to); |
---|
| 927 | + |
---|
| 928 | + CameraPane.occlusionbuffer.display(); |
---|
| 929 | + |
---|
| 930 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 931 | + cp.display(); // debug |
---|
| 932 | + |
---|
| 933 | + v.AO = cp.vertexOcclusion.r; |
---|
| 934 | + |
---|
| 935 | + if ((i % 100) == 0 && i != 0) |
---|
| 936 | + { |
---|
| 937 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 938 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 939 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 940 | + } |
---|
| 941 | + } |
---|
| 942 | + } |
---|
| 943 | + |
---|
| 944 | + //System.out.println("done."); |
---|
| 945 | + |
---|
| 946 | + cp.renderCamera = keep; |
---|
| 947 | + } |
---|
| 948 | + |
---|
| 949 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 950 | + { |
---|
| 951 | + CameraPane display = this; |
---|
| 952 | + pointFlow.CreateHT(); |
---|
| 953 | + |
---|
| 954 | + float r = display.modelParams0[0]; |
---|
| 955 | + float g = display.modelParams0[1]; |
---|
| 956 | + float b = display.modelParams0[2]; |
---|
| 957 | + float opacity = display.modelParams5[1]; |
---|
| 958 | + |
---|
| 959 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 960 | + GL gl = display.GetGL(); // getGL(); |
---|
| 961 | + |
---|
| 962 | + int s = pointFlow.points.size(); |
---|
| 963 | + |
---|
| 964 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 965 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 966 | + |
---|
| 967 | + for (int i=s; --i>=0;) |
---|
| 968 | + //for (int i=0; i<s; i++) |
---|
| 969 | + { |
---|
| 970 | + cVector v = pointFlow.points.get(i); |
---|
| 971 | + |
---|
| 972 | + double mindist = Double.MAX_VALUE; |
---|
| 973 | + |
---|
| 974 | + double size = pointFlow.minimumSize; |
---|
| 975 | + |
---|
| 976 | + double distancenext = 0; |
---|
| 977 | + |
---|
| 978 | + if (i > 0) |
---|
| 979 | + { |
---|
| 980 | + cVector w = pointFlow.points.get(i-1); |
---|
| 981 | + |
---|
| 982 | + double dist = w.distance(v); |
---|
| 983 | + |
---|
| 984 | + distancenext = dist; |
---|
| 985 | + |
---|
| 986 | + if (mindist > dist) |
---|
| 987 | + { |
---|
| 988 | + mindist = dist; |
---|
| 989 | + size = mindist*pointFlow.resizefactor; |
---|
| 990 | + } |
---|
| 991 | + } |
---|
| 992 | + |
---|
| 993 | + if (i < s-1) |
---|
| 994 | + { |
---|
| 995 | + cVector w = pointFlow.points.get(i+1); |
---|
| 996 | + |
---|
| 997 | + double dist = w.distance(v); |
---|
| 998 | + |
---|
| 999 | + if (mindist > dist) |
---|
| 1000 | + { |
---|
| 1001 | + mindist = dist; |
---|
| 1002 | + size = mindist*pointFlow.resizefactor; |
---|
| 1003 | + } |
---|
| 1004 | + } |
---|
| 1005 | + |
---|
| 1006 | + if (size < pointFlow.minimumSize) |
---|
| 1007 | + size = pointFlow.minimumSize; |
---|
| 1008 | + if (size > pointFlow.maximumSize) |
---|
| 1009 | + size = pointFlow.maximumSize; |
---|
| 1010 | + |
---|
| 1011 | + double tx = v.x; |
---|
| 1012 | + double ty = v.y; |
---|
| 1013 | + double tz = v.z; |
---|
| 1014 | + |
---|
| 1015 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1016 | + // continue; |
---|
| 1017 | + |
---|
| 1018 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1019 | + gl.glPushMatrix(); |
---|
| 1020 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1021 | + |
---|
| 1022 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1023 | + |
---|
| 1024 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1025 | + gl.glPushMatrix(); |
---|
| 1026 | + |
---|
| 1027 | + gl.glTranslated(tx,ty,tz); |
---|
| 1028 | + |
---|
| 1029 | + gl.glScaled(size,size,size); |
---|
| 1030 | + |
---|
| 1031 | +// float cr = colorBuf.get(index4); |
---|
| 1032 | +// float cg = colorBuf.get(index4+1); |
---|
| 1033 | +// float cb = colorBuf.get(index4+2); |
---|
| 1034 | +// float ca = colorBuf.get(index4+3); |
---|
| 1035 | +// |
---|
| 1036 | +// display.modelParams0[0] = r * cr; |
---|
| 1037 | +// display.modelParams0[1] = g * cg; |
---|
| 1038 | +// display.modelParams0[2] = b * cb; |
---|
| 1039 | +// |
---|
| 1040 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1041 | +// |
---|
| 1042 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1043 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1044 | +// |
---|
| 1045 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1046 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1047 | +// |
---|
| 1048 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1049 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1050 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1051 | + |
---|
| 1052 | + gl.glPopMatrix(); |
---|
| 1053 | + |
---|
| 1054 | + double step = size/4; // |
---|
| 1055 | + |
---|
| 1056 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1057 | + continue; |
---|
| 1058 | + |
---|
| 1059 | + int nbsteps = (int)(distancenext/step); |
---|
| 1060 | + |
---|
| 1061 | + step = distancenext/nbsteps; |
---|
| 1062 | + |
---|
| 1063 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1064 | + |
---|
| 1065 | + tmp.set(next); |
---|
| 1066 | + tmp.sub(v); |
---|
| 1067 | + tmp.normalize(); |
---|
| 1068 | + tmp.mul(step); |
---|
| 1069 | + |
---|
| 1070 | + // calculate next size |
---|
| 1071 | + mindist = Double.MAX_VALUE; |
---|
| 1072 | + |
---|
| 1073 | + double nextsize = pointFlow.minimumSize; |
---|
| 1074 | + |
---|
| 1075 | + if (i > 1) |
---|
| 1076 | + { |
---|
| 1077 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1078 | + |
---|
| 1079 | + double dist = w.distance(next); |
---|
| 1080 | + |
---|
| 1081 | + if (mindist > dist) |
---|
| 1082 | + { |
---|
| 1083 | + mindist = dist; |
---|
| 1084 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1085 | + } |
---|
| 1086 | + } |
---|
| 1087 | + |
---|
| 1088 | + double dist = v.distance(next); |
---|
| 1089 | + |
---|
| 1090 | + if (mindist > dist) |
---|
| 1091 | + { |
---|
| 1092 | + mindist = dist; |
---|
| 1093 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1094 | + } |
---|
| 1095 | + |
---|
| 1096 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1097 | + nextsize = pointFlow.minimumSize; |
---|
| 1098 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1099 | + nextsize = pointFlow.maximumSize; |
---|
| 1100 | + // |
---|
| 1101 | + |
---|
| 1102 | + double count = 0; |
---|
| 1103 | + |
---|
| 1104 | + while (distancenext > 0.000000001) // step |
---|
| 1105 | + { |
---|
| 1106 | + gl.glPushMatrix(); |
---|
| 1107 | + |
---|
| 1108 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1109 | + |
---|
| 1110 | + double K = count/nbsteps; |
---|
| 1111 | + |
---|
| 1112 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1113 | + |
---|
| 1114 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1115 | + |
---|
| 1116 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1117 | + |
---|
| 1118 | + count++; |
---|
| 1119 | + |
---|
| 1120 | + distancenext -= step; |
---|
| 1121 | + |
---|
| 1122 | + gl.glPopMatrix(); |
---|
| 1123 | + } |
---|
| 1124 | + |
---|
| 1125 | + if (count != nbsteps) |
---|
| 1126 | + assert(count == nbsteps); |
---|
| 1127 | + |
---|
| 1128 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1129 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1130 | + |
---|
| 1131 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1132 | + gl.glPopMatrix(); |
---|
| 1133 | + } |
---|
| 1134 | + |
---|
| 1135 | + if (!cf) |
---|
| 1136 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1137 | + |
---|
| 1138 | +// display.modelParams0[0] = r; |
---|
| 1139 | +// display.modelParams0[1] = g; |
---|
| 1140 | +// display.modelParams0[2] = b; |
---|
| 1141 | +// |
---|
| 1142 | +// display.modelParams5[1] = opacity; |
---|
| 1143 | +// |
---|
| 1144 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1145 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1146 | + |
---|
| 1147 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1148 | + } |
---|
| 1149 | + |
---|
| 1150 | + public void DrawBox(cVector min, cVector max) |
---|
| 1151 | + { |
---|
| 1152 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1153 | + gl.glBegin(gl.GL_LINES); |
---|
| 1154 | + |
---|
| 1155 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1156 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1157 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1158 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1159 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1160 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1161 | + |
---|
| 1162 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1163 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1164 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1165 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1166 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1167 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1168 | + |
---|
| 1169 | + gl.glEnd(); |
---|
| 1170 | + } |
---|
| 1171 | + |
---|
| 1172 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1173 | + { |
---|
| 1174 | + int[] strips = bRep.getRawIndices(); |
---|
| 1175 | + |
---|
| 1176 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1177 | + |
---|
| 1178 | + // TRIANGLE STRIP ARRAY |
---|
| 1179 | + if (bRep.trimmed) |
---|
| 1180 | + { |
---|
| 1181 | + float[] v = bRep.getRawVertices(); |
---|
| 1182 | + float[] n = bRep.getRawNormals(); |
---|
| 1183 | + float[] c = bRep.getRawColors(); |
---|
| 1184 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1185 | + |
---|
| 1186 | + int count2 = 0; |
---|
| 1187 | + int count3 = 0; |
---|
| 1188 | + |
---|
| 1189 | + if (n.length > 0) |
---|
| 1190 | + { |
---|
| 1191 | + for (int i = 0; i < strips.length; i++) |
---|
| 1192 | + { |
---|
| 1193 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1194 | + |
---|
| 1195 | + /* |
---|
| 1196 | + boolean locked = false; |
---|
| 1197 | + float eps = 0.1f; |
---|
| 1198 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1199 | + |
---|
| 1200 | + int dot = 0; |
---|
| 1201 | + |
---|
| 1202 | + if ((dot&1) == 0) |
---|
| 1203 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1204 | + |
---|
| 1205 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1206 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1207 | + else |
---|
| 1208 | + { |
---|
| 1209 | + locked = true; |
---|
| 1210 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1211 | + } |
---|
| 1212 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1213 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1214 | + if (hasnorm) |
---|
| 1215 | + { |
---|
| 1216 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1217 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1218 | + } |
---|
| 1219 | + |
---|
| 1220 | + if ((dot&4) == 0) |
---|
| 1221 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1222 | + |
---|
| 1223 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1224 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1225 | + else |
---|
| 1226 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1227 | + |
---|
| 1228 | + f.dot = dot; |
---|
| 1229 | + */ |
---|
| 1230 | + |
---|
| 1231 | + if (!selectmode) |
---|
| 1232 | + { |
---|
| 1233 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1234 | + { |
---|
| 1235 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1236 | + } else |
---|
| 1237 | + { |
---|
| 1238 | + gl.glNormal3f(0, 0, 1); |
---|
| 1239 | + } |
---|
| 1240 | + |
---|
| 1241 | + if (c != null) |
---|
| 1242 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1243 | + { |
---|
| 1244 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1245 | + } |
---|
| 1246 | + } |
---|
| 1247 | + |
---|
| 1248 | + if (flipV) |
---|
| 1249 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1250 | + else |
---|
| 1251 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
| 1253 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1254 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1255 | + |
---|
| 1256 | + count2 += 2; |
---|
| 1257 | + count3 += 3; |
---|
| 1258 | + if (!selectmode) |
---|
| 1259 | + { |
---|
| 1260 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1261 | + { |
---|
| 1262 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1263 | + } else |
---|
| 1264 | + { |
---|
| 1265 | + gl.glNormal3f(0, 0, 1); |
---|
| 1266 | + } |
---|
| 1267 | + if (c != null) |
---|
| 1268 | + { |
---|
| 1269 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1270 | + } |
---|
| 1271 | + } |
---|
| 1272 | + |
---|
| 1273 | + if (flipV) |
---|
| 1274 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1275 | + else |
---|
| 1276 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
| 1278 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1279 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1280 | + |
---|
| 1281 | + count2 += 2; |
---|
| 1282 | + count3 += 3; |
---|
| 1283 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1284 | + { |
---|
| 1285 | + //gl.glTexCoord2d(...); |
---|
| 1286 | + if (!selectmode) |
---|
| 1287 | + { |
---|
| 1288 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1289 | + { |
---|
| 1290 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1291 | + } else |
---|
| 1292 | + { |
---|
| 1293 | + gl.glNormal3f(0, 0, 1); |
---|
| 1294 | + } |
---|
| 1295 | + if (c != null) |
---|
| 1296 | + { |
---|
| 1297 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1298 | + } |
---|
| 1299 | + } |
---|
| 1300 | + |
---|
| 1301 | + if (flipV) |
---|
| 1302 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1303 | + else |
---|
| 1304 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
| 1306 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1307 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
| 1309 | + count2 += 2; |
---|
| 1310 | + count3 += 3; |
---|
| 1311 | + } |
---|
| 1312 | + |
---|
| 1313 | + gl.glEnd(); |
---|
| 1314 | + } |
---|
| 1315 | + } |
---|
| 1316 | + |
---|
| 1317 | + assert count3 == v.length; |
---|
| 1318 | + } |
---|
| 1319 | + else // !trimmed |
---|
| 1320 | + { |
---|
| 1321 | + int count = 0; |
---|
| 1322 | + for (int i = 0; i < strips.length; i++) |
---|
| 1323 | + { |
---|
| 1324 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1325 | + |
---|
| 1326 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1327 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1328 | + |
---|
| 1329 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1330 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1331 | + |
---|
| 1332 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1333 | + { |
---|
| 1334 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1335 | + |
---|
| 1336 | + // if (j%2 == 0) |
---|
| 1337 | + // drawFace(p, q, r, display, null); |
---|
| 1338 | + // else |
---|
| 1339 | + // drawFace(p, r, q, display, null); |
---|
| 1340 | + |
---|
| 1341 | + // p = q; |
---|
| 1342 | + // q = r; |
---|
| 1343 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1344 | + } |
---|
| 1345 | + |
---|
| 1346 | + gl.glEnd(); |
---|
| 1347 | + } |
---|
| 1348 | + } |
---|
| 1349 | + } |
---|
| 1350 | + |
---|
| 1351 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1352 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1353 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1354 | + |
---|
| 1355 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1356 | + { |
---|
| 1357 | + GL gl = GetGL(); // getGL(); |
---|
| 1358 | + |
---|
| 1359 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1360 | + |
---|
| 1361 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1362 | + |
---|
| 1363 | + gl.glLineWidth(1); |
---|
| 1364 | + gl.glColor3f(1,1,1); |
---|
| 1365 | + gl.glBegin(gl.GL_LINES); |
---|
| 1366 | + double scale = 0; |
---|
| 1367 | + int count = 0; |
---|
| 1368 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1369 | + { |
---|
| 1370 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1371 | + if(s == 0) |
---|
| 1372 | + { |
---|
| 1373 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1374 | + } |
---|
| 1375 | + if (mesh.showsprings) |
---|
| 1376 | + { |
---|
| 1377 | + temp.set(spring.a.position); |
---|
| 1378 | + temp.add(spring.b.position); |
---|
| 1379 | + temp.mul(0.5); |
---|
| 1380 | + temp2.set(spring.a.position); |
---|
| 1381 | + temp2.sub(spring.b.position); |
---|
| 1382 | + temp2.mul(spring.restLength/2); |
---|
| 1383 | + temp.sub(temp2); |
---|
| 1384 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1385 | + temp.add(temp2); |
---|
| 1386 | + temp.add(temp2); |
---|
| 1387 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1388 | + } |
---|
| 1389 | + |
---|
| 1390 | + if (spring.isHandle) |
---|
| 1391 | + continue; |
---|
| 1392 | + |
---|
| 1393 | + //if (scale < spring.restLength) |
---|
| 1394 | + scale += spring.restLength; |
---|
| 1395 | + count++; |
---|
| 1396 | + } |
---|
| 1397 | + gl.glEnd(); |
---|
| 1398 | + |
---|
| 1399 | + if (count == 0) |
---|
| 1400 | + scale = 0.01; |
---|
| 1401 | + else |
---|
| 1402 | + scale /= count * 3; |
---|
| 1403 | + |
---|
| 1404 | + //scale = 0.25; |
---|
| 1405 | + |
---|
| 1406 | + if (mesh.ShowInfo()) |
---|
| 1407 | + { |
---|
| 1408 | + gl.glLineWidth(4); |
---|
| 1409 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1410 | + { |
---|
| 1411 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1412 | + if (node.mass == 0) |
---|
| 1413 | + continue; |
---|
| 1414 | + |
---|
| 1415 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1416 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1417 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1418 | + //temp.normalize(); |
---|
| 1419 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1420 | + gl.glBegin(gl.GL_LINES); |
---|
| 1421 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1422 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1423 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1424 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1425 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1426 | + gl.glEnd(); |
---|
| 1427 | + } |
---|
| 1428 | + |
---|
| 1429 | + gl.glLineWidth(8); |
---|
| 1430 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1431 | + { |
---|
| 1432 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1433 | + |
---|
| 1434 | + if (node.springs != null) |
---|
| 1435 | + { |
---|
| 1436 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1437 | + { |
---|
| 1438 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1439 | + |
---|
| 1440 | + int c = i+1; |
---|
| 1441 | + // c = node.springs.get(i).nbcopies; |
---|
| 1442 | + |
---|
| 1443 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1444 | + gl.glBegin(gl.GL_LINES); |
---|
| 1445 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1446 | + 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); |
---|
| 1447 | + gl.glEnd(); |
---|
| 1448 | + } |
---|
| 1449 | + } |
---|
| 1450 | + } |
---|
| 1451 | + |
---|
| 1452 | + gl.glLineWidth(1); |
---|
| 1453 | + } |
---|
| 1454 | + |
---|
| 1455 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1456 | + } |
---|
| 1457 | + |
---|
763 | 1458 | /// INTERFACE |
---|
| 1459 | + |
---|
| 1460 | + public void StartTriangles() |
---|
| 1461 | + { |
---|
| 1462 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1463 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1464 | + } |
---|
| 1465 | + |
---|
| 1466 | + public void EndTriangles() |
---|
| 1467 | + { |
---|
| 1468 | + GetGL().glEnd(); |
---|
| 1469 | + } |
---|
| 1470 | + |
---|
| 1471 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1472 | + { |
---|
| 1473 | + if (!selectmode) |
---|
| 1474 | + { |
---|
| 1475 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1476 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1477 | + |
---|
| 1478 | + if (flipV) |
---|
| 1479 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1480 | + else |
---|
| 1481 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1485 | + } |
---|
764 | 1486 | |
---|
765 | 1487 | void SetColor(Object3D obj, Vertex p0) |
---|
766 | 1488 | { |
---|
.. | .. |
---|
939 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
940 | 1662 | } |
---|
941 | 1663 | |
---|
942 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
943 | 1665 | { |
---|
944 | 1666 | CameraPane display = this; |
---|
945 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
955 | 1677 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
956 | 1678 | if (!material.multiply) |
---|
957 | 1679 | { |
---|
958 | | - display.color = color; |
---|
| 1680 | + display.color = material.color; |
---|
959 | 1681 | display.saturation = material.modulation; |
---|
960 | 1682 | } |
---|
961 | 1683 | else |
---|
962 | 1684 | { |
---|
963 | | - display.color *= color*2; |
---|
| 1685 | + display.color *= material.color*2; |
---|
964 | 1686 | display.saturation *= material.modulation*2; |
---|
965 | 1687 | } |
---|
966 | 1688 | |
---|
967 | 1689 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
968 | 1690 | |
---|
969 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1691 | + float[] colorV = Grafreed.colorV; |
---|
970 | 1692 | |
---|
971 | 1693 | /**/ |
---|
972 | 1694 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
974 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
975 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
976 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
977 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
978 | 1700 | |
---|
979 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
980 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1082 | 1804 | display.modelParams7[2] = 0; |
---|
1083 | 1805 | display.modelParams7[3] = 0; |
---|
1084 | 1806 | |
---|
1085 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1086 | 1808 | |
---|
1087 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1088 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1089 | 1811 | { |
---|
1090 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1226 | 1948 | void PushMatrix(double[][] matrix) |
---|
1227 | 1949 | { |
---|
1228 | 1950 | // GrafreeD.tracein(matrix); |
---|
1229 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1230 | 1952 | } |
---|
1231 | 1953 | |
---|
1232 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
1323 | 2045 | |
---|
1324 | 2046 | static int camerachangeframe; |
---|
1325 | 2047 | |
---|
1326 | | - boolean SetCamera(Camera cam) |
---|
| 2048 | + public boolean SetCamera(Camera cam) |
---|
1327 | 2049 | { |
---|
1328 | 2050 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1329 | 2051 | // return false; |
---|
.. | .. |
---|
1380 | 2102 | //System.err.println("Oeil on"); |
---|
1381 | 2103 | OEIL = true; |
---|
1382 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1383 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1384 | 2106 | //pingthread.StepToTarget(true); |
---|
1385 | 2107 | } |
---|
1386 | 2108 | |
---|
.. | .. |
---|
1451 | 2173 | mainDL ^= true; |
---|
1452 | 2174 | } |
---|
1453 | 2175 | |
---|
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 | 2176 | void ToggleFullScreen() |
---|
1482 | 2177 | { |
---|
1483 | 2178 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1488 | 2183 | Globals.CROWD ^= true; |
---|
1489 | 2184 | } |
---|
1490 | 2185 | |
---|
1491 | | - void ToggleInertia() |
---|
1492 | | - { |
---|
1493 | | - INERTIA ^= true; |
---|
1494 | | - } |
---|
1495 | | - |
---|
1496 | 2186 | void ToggleLocal() |
---|
1497 | 2187 | { |
---|
1498 | 2188 | LOCALTRANSFORM ^= true; |
---|
1499 | 2189 | } |
---|
1500 | 2190 | |
---|
1501 | | - void ToggleFast() |
---|
| 2191 | + public void ToggleTexture() |
---|
| 2192 | + { |
---|
| 2193 | + textureon ^= true; |
---|
| 2194 | + } |
---|
| 2195 | + |
---|
| 2196 | + public void ToggleLive() |
---|
| 2197 | + { |
---|
| 2198 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2199 | + |
---|
| 2200 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2201 | + |
---|
| 2202 | + if (!Globals.isLIVE()) // save sound |
---|
| 2203 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2204 | + // else |
---|
| 2205 | + repaint(); // start loop // may 2013 |
---|
| 2206 | + } |
---|
| 2207 | + |
---|
| 2208 | + public void ToggleSupport() |
---|
| 2209 | + { |
---|
| 2210 | + SUPPORT ^= true; |
---|
| 2211 | + } |
---|
| 2212 | + |
---|
| 2213 | + public void ToggleAbort() |
---|
| 2214 | + { |
---|
| 2215 | + ABORTMODE ^= true; |
---|
| 2216 | + } |
---|
| 2217 | + |
---|
| 2218 | + public void ToggleInertia() |
---|
| 2219 | + { |
---|
| 2220 | + INERTIA ^= true; |
---|
| 2221 | + } |
---|
| 2222 | + |
---|
| 2223 | + public void ToggleFast() |
---|
1502 | 2224 | { |
---|
1503 | 2225 | FAST ^= true; |
---|
1504 | 2226 | } |
---|
1505 | 2227 | |
---|
1506 | | - void ToggleSlowPose() |
---|
| 2228 | + public void ToggleSlowPose() |
---|
1507 | 2229 | { |
---|
1508 | 2230 | SLOWPOSE ^= true; |
---|
1509 | 2231 | } |
---|
1510 | 2232 | |
---|
1511 | | - void ToggleFootContact() |
---|
1512 | | - { |
---|
1513 | | - FOOTCONTACT ^= true; |
---|
1514 | | - } |
---|
1515 | | - |
---|
1516 | | - void ToggleBoxMode() |
---|
| 2233 | + public void ToggleBoxMode() |
---|
1517 | 2234 | { |
---|
1518 | 2235 | BOXMODE ^= true; |
---|
1519 | 2236 | } |
---|
1520 | 2237 | |
---|
1521 | | - void ToggleSmoothFocus() |
---|
| 2238 | + public void ToggleZoomBoxMode() |
---|
| 2239 | + { |
---|
| 2240 | + ZOOMBOXMODE ^= true; |
---|
| 2241 | + } |
---|
| 2242 | + |
---|
| 2243 | + public void ToggleSmoothFocus() |
---|
1522 | 2244 | { |
---|
1523 | 2245 | SMOOTHFOCUS ^= true; |
---|
1524 | 2246 | } |
---|
1525 | 2247 | |
---|
1526 | | - void ToggleImageFlip() |
---|
| 2248 | + public void ToggleImageFlip() |
---|
1527 | 2249 | { |
---|
1528 | 2250 | IMAGEFLIP ^= true; |
---|
1529 | 2251 | } |
---|
1530 | 2252 | |
---|
1531 | | - void ToggleSpeakerMocap() |
---|
| 2253 | + public void ToggleSpeakerMocap() |
---|
1532 | 2254 | { |
---|
1533 | 2255 | SPEAKERMOCAP ^= true; |
---|
1534 | 2256 | } |
---|
1535 | 2257 | |
---|
1536 | | - void ToggleSpeakerCamera() |
---|
| 2258 | + public void ToggleSpeakerCamera() |
---|
1537 | 2259 | { |
---|
1538 | 2260 | SPEAKERCAMERA ^= true; |
---|
1539 | 2261 | } |
---|
1540 | 2262 | |
---|
1541 | | - void ToggleSpeakerFocus() |
---|
| 2263 | + public void ToggleSpeakerFocus() |
---|
1542 | 2264 | { |
---|
1543 | 2265 | SPEAKERFOCUS ^= true; |
---|
1544 | 2266 | } |
---|
1545 | 2267 | |
---|
1546 | | - void ToggleDebug() |
---|
1547 | | - { |
---|
1548 | | - DEBUG ^= true; |
---|
1549 | | - } |
---|
1550 | | - |
---|
1551 | | - void ToggleFrustum() |
---|
| 2268 | + public void ToggleFrustum() |
---|
1552 | 2269 | { |
---|
1553 | 2270 | FRUSTUM ^= true; |
---|
1554 | 2271 | } |
---|
1555 | 2272 | |
---|
1556 | | - void ToggleTrack() |
---|
| 2273 | + public void ToggleTrack() |
---|
1557 | 2274 | { |
---|
1558 | 2275 | TRACK ^= true; |
---|
1559 | 2276 | if (TRACK) |
---|
.. | .. |
---|
1572 | 2289 | repaint(); |
---|
1573 | 2290 | } |
---|
1574 | 2291 | |
---|
1575 | | - void ToggleTrackOnce() |
---|
| 2292 | + public void ToggleTrackOnce() |
---|
1576 | 2293 | { |
---|
1577 | 2294 | TRACKONCE ^= true; |
---|
1578 | 2295 | } |
---|
1579 | 2296 | |
---|
1580 | | - void ToggleShadowTrack() |
---|
| 2297 | + public void ToggleShadowTrack() |
---|
1581 | 2298 | { |
---|
1582 | 2299 | SHADOWTRACK ^= true; |
---|
1583 | 2300 | repaint(); |
---|
1584 | 2301 | } |
---|
1585 | 2302 | |
---|
1586 | | - void ToggleOeil() |
---|
| 2303 | + public void ToggleOeil() |
---|
1587 | 2304 | { |
---|
1588 | 2305 | OEIL ^= true; |
---|
1589 | 2306 | } |
---|
1590 | 2307 | |
---|
1591 | | - void ToggleOeilOnce() |
---|
| 2308 | + public void ToggleOeilOnce() |
---|
1592 | 2309 | { |
---|
1593 | 2310 | OEILONCE ^= true; |
---|
| 2311 | + } |
---|
| 2312 | + |
---|
| 2313 | + void ToggleFootContact() |
---|
| 2314 | + { |
---|
| 2315 | + FOOTCONTACT ^= true; |
---|
| 2316 | + } |
---|
| 2317 | + |
---|
| 2318 | + void ToggleDebug() |
---|
| 2319 | + { |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
1594 | 2321 | } |
---|
1595 | 2322 | |
---|
1596 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
1598 | 2325 | LOOKAT ^= true; |
---|
1599 | 2326 | } |
---|
1600 | 2327 | |
---|
1601 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
1602 | 2329 | { |
---|
1603 | | - RANDOM ^= true; |
---|
| 2330 | + SWITCH ^= true; |
---|
1604 | 2331 | } |
---|
1605 | 2332 | |
---|
1606 | 2333 | void ToggleHandles() |
---|
.. | .. |
---|
1608 | 2335 | HANDLES ^= true; |
---|
1609 | 2336 | } |
---|
1610 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
1611 | 2340 | void TogglePaint() |
---|
1612 | 2341 | { |
---|
1613 | 2342 | PAINTMODE ^= true; |
---|
1614 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
1615 | 2349 | } |
---|
1616 | 2350 | |
---|
1617 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1707 | 2441 | { |
---|
1708 | 2442 | return currentGL; |
---|
1709 | 2443 | } |
---|
1710 | | - |
---|
| 2444 | + |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
1711 | 2460 | /**/ |
---|
1712 | 2461 | class CacheTexture |
---|
1713 | 2462 | { |
---|
.. | .. |
---|
1716 | 2465 | |
---|
1717 | 2466 | int resolution; |
---|
1718 | 2467 | |
---|
1719 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1720 | 2469 | { |
---|
1721 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
1722 | 2472 | resolution = res; |
---|
1723 | 2473 | } |
---|
1724 | 2474 | } |
---|
1725 | 2475 | /**/ |
---|
1726 | 2476 | |
---|
1727 | 2477 | // 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>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
1731 | 2483 | int pigmentdepth = 0; |
---|
1732 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1733 | 2485 | int bumpdepth = 0; |
---|
1734 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1735 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1736 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1737 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1738 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1739 | 2491 | |
---|
1740 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1741 | 2493 | { |
---|
1742 | 2494 | TextureData texturedata = null; |
---|
1743 | 2495 | |
---|
.. | .. |
---|
1756 | 2508 | if (bump) |
---|
1757 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
1758 | 2510 | |
---|
1759 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1760 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
1761 | 2513 | |
---|
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); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
1764 | 2516 | |
---|
1765 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
1766 | 2539 | } |
---|
1767 | 2540 | |
---|
1768 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2835 | 3608 | |
---|
2836 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
2837 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
2838 | 3613 | // |
---|
2839 | 3614 | if (false) // compressbit > 0) |
---|
2840 | 3615 | { |
---|
.. | .. |
---|
3539 | 4314 | |
---|
3540 | 4315 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3541 | 4316 | { |
---|
| 4317 | + new Exception().printStackTrace(); |
---|
3542 | 4318 | System.exit(0); |
---|
3543 | 4319 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3544 | 4320 | |
---|
.. | .. |
---|
7232 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7233 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7234 | 8010 | |
---|
7235 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7236 | 8012 | { |
---|
7237 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7238 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7247 | 8023 | pigment = null; |
---|
7248 | 8024 | } |
---|
7249 | 8025 | |
---|
7250 | | - ReleaseTexture(bump, true); |
---|
7251 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7252 | 8028 | } |
---|
7253 | 8029 | |
---|
7254 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8030 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8031 | + { |
---|
| 8032 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8033 | + { |
---|
| 8034 | + return; |
---|
| 8035 | + } |
---|
| 8036 | + |
---|
| 8037 | + if (tex == null) |
---|
| 8038 | + { |
---|
| 8039 | + ReleaseTexture(null, false); |
---|
| 8040 | + return; |
---|
| 8041 | + } |
---|
| 8042 | + |
---|
| 8043 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8044 | + |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + { |
---|
| 8047 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8048 | + // System.out.println("; bump = " + bump); |
---|
| 8049 | + } |
---|
| 8050 | + |
---|
| 8051 | + if (pigment.equals("")) |
---|
| 8052 | + { |
---|
| 8053 | + pigment = null; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
| 8057 | + } |
---|
| 8058 | + |
---|
| 8059 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8060 | + { |
---|
| 8061 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8062 | + { |
---|
| 8063 | + return; |
---|
| 8064 | + } |
---|
| 8065 | + |
---|
| 8066 | + if (tex == null) |
---|
| 8067 | + { |
---|
| 8068 | + ReleaseTexture(null, true); |
---|
| 8069 | + return; |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + String bump = Object3D.GetBump(tex); |
---|
| 8073 | + |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + { |
---|
| 8076 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8077 | + // System.out.println("; bump = " + bump); |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + if (bump.equals("")) |
---|
| 8081 | + { |
---|
| 8082 | + bump = null; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7255 | 8089 | { |
---|
7256 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7257 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7262 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7263 | 8097 | |
---|
7264 | 8098 | if (tex != null) |
---|
7265 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7266 | 8100 | |
---|
7267 | 8101 | // //assert( texture != null ); |
---|
7268 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
7354 | 8188 | } |
---|
7355 | 8189 | } |
---|
7356 | 8190 | |
---|
7357 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8191 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8192 | + { |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
| 8234 | + |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
| 8237 | + } |
---|
| 8238 | + |
---|
| 8239 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7358 | 8240 | { |
---|
7359 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7360 | 8242 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7365 | 8247 | if (tex == null) |
---|
7366 | 8248 | { |
---|
7367 | 8249 | BindTexture(null,false,resolution); |
---|
7368 | | - BindTexture(null,true,resolution); |
---|
7369 | 8250 | return; |
---|
7370 | 8251 | } |
---|
7371 | 8252 | |
---|
7372 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
| 8254 | + |
---|
| 8255 | + usedtextures.add(tex); |
---|
| 8256 | + |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + { |
---|
| 8259 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8260 | + // System.out.println("; bump = " + bump); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + if (pigment.equals("")) |
---|
| 8264 | + { |
---|
| 8265 | + pigment = null; |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
| 8270 | + } |
---|
| 8271 | + |
---|
| 8272 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8273 | + { |
---|
| 8274 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8275 | + ambientOcclusion ) // || !textureon) |
---|
| 8276 | + { |
---|
| 8277 | + return; // false; |
---|
| 8278 | + } |
---|
| 8279 | + |
---|
| 8280 | + if (tex == null) |
---|
| 8281 | + { |
---|
| 8282 | + BindTexture(null,true,resolution); |
---|
| 8283 | + return; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
7373 | 8286 | String bump = Object3D.GetBump(tex); |
---|
7374 | 8287 | |
---|
7375 | | - usedtextures.put(pigment, pigment); |
---|
7376 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
7377 | 8289 | |
---|
7378 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7379 | 8291 | { |
---|
7380 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7381 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7385 | 8297 | { |
---|
7386 | 8298 | bump = null; |
---|
7387 | 8299 | } |
---|
7388 | | - if (pigment.equals("")) |
---|
7389 | | - { |
---|
7390 | | - pigment = null; |
---|
7391 | | - } |
---|
7392 | 8300 | |
---|
7393 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7394 | | - BindTexture(pigment, false, resolution); |
---|
7395 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7396 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
7397 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7398 | | - |
---|
7399 | | - return; // true; |
---|
7400 | 8304 | } |
---|
7401 | 8305 | |
---|
7402 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8306 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8307 | + |
---|
| 8308 | + private boolean FileExists(String tex) |
---|
7403 | 8309 | { |
---|
7404 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8310 | + if (missingTextures.contains(tex)) |
---|
| 8311 | + { |
---|
| 8312 | + return false; |
---|
| 8313 | + } |
---|
| 8314 | + |
---|
| 8315 | + boolean fileExists = new File(tex).exists(); |
---|
| 8316 | + |
---|
| 8317 | + if (!fileExists) |
---|
| 8318 | + { |
---|
| 8319 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8320 | + missingTextures.add(tex); |
---|
| 8321 | + } |
---|
| 8322 | + |
---|
| 8323 | + return fileExists; |
---|
| 8324 | + } |
---|
| 8325 | + |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + { |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
7405 | 8329 | |
---|
7406 | 8330 | if (tex != null) |
---|
7407 | 8331 | { |
---|
7408 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7409 | 8334 | |
---|
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; |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8341 | + |
---|
| 8342 | +// String[] split = tex.split("Textures"); |
---|
| 8343 | +// if (split.length > 1) |
---|
| 8344 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8345 | +// else |
---|
| 8346 | +// if (!texname.startsWith("/")) |
---|
| 8347 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8348 | + if (!FileExists(texname)) |
---|
| 8349 | + { |
---|
| 8350 | + texname = fallbackTextureName; |
---|
| 8351 | + } |
---|
7416 | 8352 | |
---|
7417 | 8353 | if (CACHETEXTURE) |
---|
7418 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7419 | | - |
---|
7420 | | - TextureData texturedata = null; |
---|
7421 | | - |
---|
7422 | | - if (texture == null || texture.resolution < resolution) |
---|
7423 | 8354 | { |
---|
7424 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
7425 | 8388 | { |
---|
7426 | 8389 | assert(!bump); |
---|
7427 | 8390 | // if (bump) |
---|
.. | .. |
---|
7432 | 8395 | // } |
---|
7433 | 8396 | // else |
---|
7434 | 8397 | // { |
---|
7435 | | - texture = textures.get(tex); |
---|
7436 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
7437 | 8400 | { |
---|
7438 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7439 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
7440 | 8405 | // } |
---|
7441 | 8406 | } else |
---|
7442 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7443 | 8408 | { |
---|
7444 | 8409 | assert(bump); |
---|
7445 | | - texture = textures.get(tex); |
---|
7446 | | - if (texture == null) |
---|
7447 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
7448 | 8415 | } else |
---|
7449 | 8416 | { |
---|
7450 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7452 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
7453 | 8420 | //} else |
---|
7454 | 8421 | //{ |
---|
7455 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7456 | 8423 | { |
---|
7457 | | - texture = textures.get(tex); |
---|
7458 | | - if (texture == null) |
---|
7459 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
7460 | 8429 | } else |
---|
7461 | 8430 | { |
---|
7462 | 8431 | if (textureon) |
---|
.. | .. |
---|
7481 | 8450 | } |
---|
7482 | 8451 | |
---|
7483 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7484 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
7485 | 8454 | cachename = texname; |
---|
7486 | 8455 | else |
---|
7487 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7503 | 8472 | } |
---|
7504 | 8473 | |
---|
7505 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7506 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
7507 | 8476 | cachename = texname; |
---|
7508 | 8477 | else |
---|
7509 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7512 | 8481 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7513 | 8482 | |
---|
7514 | 8483 | |
---|
7515 | | - if (texturedata != null) |
---|
7516 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8484 | + if (texturedata == null) |
---|
| 8485 | + throw new Exception(); |
---|
| 8486 | + |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
7517 | 8488 | //texture = GetTexture(tex, bump); |
---|
7518 | 8489 | } |
---|
7519 | 8490 | } |
---|
7520 | 8491 | //} |
---|
7521 | 8492 | } |
---|
7522 | 8493 | |
---|
7523 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7524 | 8495 | { |
---|
7525 | 8496 | //return false; |
---|
7526 | 8497 | |
---|
7527 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7528 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7529 | 8500 | { |
---|
7530 | 8501 | // String ext = "_highres"; |
---|
7531 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7542 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7543 | 8514 | if (!cachefile.exists()) |
---|
7544 | 8515 | { |
---|
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)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7554 | 8517 | { |
---|
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); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
7585 | 8520 | ImageWriter writer = null; |
---|
7586 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7587 | 8522 | if (iter.hasNext()) { |
---|
7588 | 8523 | writer = (ImageWriter)iter.next(); |
---|
7589 | 8524 | } |
---|
7590 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
7591 | 8527 | try |
---|
7592 | 8528 | { |
---|
7593 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7604 | 8540 | } |
---|
7605 | 8541 | } |
---|
7606 | 8542 | } |
---|
7607 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
7608 | 8546 | //System.out.println("Texture = " + tex); |
---|
7609 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
7610 | 8548 | { |
---|
7611 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
7612 | 8550 | thetex.texture.disable(); |
---|
7613 | 8551 | thetex.texture.dispose(); |
---|
7614 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
7615 | 8553 | } |
---|
7616 | 8554 | |
---|
7617 | | - texture.texturedata = texturedata; |
---|
7618 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
7619 | 8557 | |
---|
7620 | 8558 | // newtex = true; |
---|
7621 | 8559 | } |
---|
.. | .. |
---|
7631 | 8569 | } |
---|
7632 | 8570 | } |
---|
7633 | 8571 | |
---|
7634 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
7635 | 8573 | } |
---|
7636 | 8574 | |
---|
7637 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7638 | 8610 | { |
---|
7639 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7640 | 8612 | |
---|
.. | .. |
---|
7652 | 8624 | return texture!=null?texture.texture:null; |
---|
7653 | 8625 | } |
---|
7654 | 8626 | |
---|
7655 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7656 | 8628 | { |
---|
7657 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7658 | 8630 | |
---|
7659 | 8631 | return texture!=null?texture.texturedata:null; |
---|
7660 | 8632 | } |
---|
7661 | 8633 | |
---|
7662 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7663 | 8635 | { |
---|
7664 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7665 | 8637 | { |
---|
7666 | 8638 | return false; |
---|
7667 | 8639 | } |
---|
7668 | 8640 | |
---|
7669 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
7670 | 8642 | |
---|
7671 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7672 | 8644 | |
---|
.. | .. |
---|
7698 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7699 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7700 | 8672 | |
---|
7701 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
7702 | 8674 | } |
---|
7703 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
7704 | 8742 | ShadowBuffer shadowPBuf; |
---|
7705 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
7706 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
8536 | 9574 | jy8[3] = 0.5f; |
---|
8537 | 9575 | } |
---|
8538 | 9576 | |
---|
8539 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9577 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
8540 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8541 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8542 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8543 | 9581 | |
---|
| 9582 | + void ResetOptions() |
---|
| 9583 | + { |
---|
| 9584 | + options1[0] = 100; |
---|
| 9585 | + options1[1] = 0.025f; |
---|
| 9586 | + options1[2] = 0.01f; |
---|
| 9587 | + options1[3] = 0; |
---|
| 9588 | + options1[4] = 0; |
---|
| 9589 | + |
---|
| 9590 | + options2[0] = 0; |
---|
| 9591 | + options2[1] = 0.75f; |
---|
| 9592 | + options2[2] = 0; |
---|
| 9593 | + options2[3] = 0; |
---|
| 9594 | + |
---|
| 9595 | + options3[0] = 1; |
---|
| 9596 | + options3[1] = 1; |
---|
| 9597 | + options3[2] = 1; |
---|
| 9598 | + options3[3] = 0; |
---|
| 9599 | + |
---|
| 9600 | + options4[0] = 1; |
---|
| 9601 | + options4[1] = 0; |
---|
| 9602 | + options4[2] = 1; |
---|
| 9603 | + options4[3] = 0; |
---|
| 9604 | + } |
---|
| 9605 | + |
---|
8544 | 9606 | static int imagecount = 0; // movie generation |
---|
8545 | 9607 | |
---|
8546 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
8636 | 9698 | assert (parentcam != renderCamera); |
---|
8637 | 9699 | |
---|
8638 | 9700 | if (renderCamera != lightCamera) |
---|
8639 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8640 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8641 | 9703 | |
---|
8642 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8643 | 9705 | |
---|
.. | .. |
---|
8652 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8653 | 9715 | |
---|
8654 | 9716 | if (renderCamera != lightCamera) |
---|
8655 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8656 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8657 | 9719 | |
---|
8658 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8659 | 9721 | |
---|
.. | .. |
---|
8725 | 9787 | //gl.glFlush(); |
---|
8726 | 9788 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8727 | 9789 | |
---|
8728 | | - if (ANIMATION && ABORTED) |
---|
| 9790 | + if (Globals.ANIMATION && ABORTED) |
---|
8729 | 9791 | { |
---|
8730 | 9792 | System.err.println(" ABORTED FRAME"); |
---|
8731 | 9793 | break; |
---|
.. | .. |
---|
8755 | 9817 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8756 | 9818 | |
---|
8757 | 9819 | // save image |
---|
8758 | | - if (ANIMATION && !ABORTED) |
---|
| 9820 | + if (Globals.ANIMATION && !ABORTED) |
---|
8759 | 9821 | { |
---|
8760 | 9822 | VPwidth = viewport[2]; |
---|
8761 | 9823 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8866 | 9928 | |
---|
8867 | 9929 | // imagecount++; |
---|
8868 | 9930 | |
---|
8869 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9931 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
8870 | 9932 | |
---|
8871 | 9933 | if (!BOXMODE) |
---|
8872 | 9934 | { |
---|
8873 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9935 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
8874 | 9936 | } |
---|
8875 | 9937 | |
---|
8876 | 9938 | if (!BOXMODE) |
---|
.. | .. |
---|
8908 | 9970 | ABORTED = false; |
---|
8909 | 9971 | } |
---|
8910 | 9972 | else |
---|
8911 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9973 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8912 | 9974 | |
---|
8913 | 9975 | if (false) |
---|
8914 | 9976 | { |
---|
.. | .. |
---|
9571 | 10633 | |
---|
9572 | 10634 | public void display(GLAutoDrawable drawable) |
---|
9573 | 10635 | { |
---|
9574 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10636 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9575 | 10637 | { |
---|
9576 | | - GrafreeD.wav.save(); |
---|
9577 | | - GrafreeD.savesound = false; |
---|
9578 | | - GrafreeD.hassound = false; |
---|
| 10638 | + Grafreed.wav.save(); |
---|
| 10639 | + Grafreed.savesound = false; |
---|
| 10640 | + Grafreed.hassound = false; |
---|
9579 | 10641 | } |
---|
9580 | 10642 | // if (DEBUG_SELECTION) |
---|
9581 | 10643 | // { |
---|
.. | .. |
---|
9651 | 10713 | ANTIALIAS = 0; |
---|
9652 | 10714 | //System.out.println("RESTART"); |
---|
9653 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
9654 | 10717 | } |
---|
9655 | 10718 | } |
---|
9656 | 10719 | } |
---|
.. | .. |
---|
9705 | 10768 | Object3D theobject = object; |
---|
9706 | 10769 | Object3D theparent = object.parent; |
---|
9707 | 10770 | object.parent = null; |
---|
9708 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10771 | + object = (Object3D)Grafreed.clone(object); |
---|
9709 | 10772 | object.Stripify(); |
---|
9710 | 10773 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9711 | 10774 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9718 | 10781 | ambientOcclusion = false; |
---|
9719 | 10782 | } |
---|
9720 | 10783 | |
---|
9721 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9722 | 10786 | { |
---|
9723 | 10787 | //if (RENDERSHADOW) // ? |
---|
9724 | 10788 | if (!IsFrozen()) |
---|
9725 | 10789 | { |
---|
9726 | 10790 | // dec 2012 |
---|
9727 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9728 | 10792 | { |
---|
9729 | 10793 | Globals.framecount++; |
---|
9730 | 10794 | shadowbuffer.display(); |
---|
.. | .. |
---|
9851 | 10915 | |
---|
9852 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
9853 | 10917 | if (cam != lightCamera) |
---|
9854 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9855 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9856 | 10920 | |
---|
9857 | 10921 | for (int j = 0; j < 4; j++) |
---|
9858 | 10922 | { |
---|
.. | .. |
---|
9866 | 10930 | |
---|
9867 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
9868 | 10932 | if (cam != lightCamera) |
---|
9869 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9870 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9871 | 10935 | |
---|
9872 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9873 | 10937 | |
---|
.. | .. |
---|
10126 | 11190 | // Bump noise |
---|
10127 | 11191 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10128 | 11192 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10129 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11193 | + |
---|
| 11194 | + try |
---|
| 11195 | + { |
---|
| 11196 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11197 | + } |
---|
| 11198 | + catch (Exception e) |
---|
| 11199 | + { |
---|
| 11200 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11201 | + } |
---|
| 11202 | + |
---|
10130 | 11203 | |
---|
10131 | 11204 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10132 | 11205 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10149 | 11222 | |
---|
10150 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10151 | 11224 | |
---|
10152 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10153 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10154 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11225 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11226 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11227 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10155 | 11228 | } else |
---|
10156 | 11229 | { |
---|
10157 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10162 | 11235 | //System.out.println("BLENDING ON"); |
---|
10163 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
10164 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10165 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10166 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10167 | 11240 | gl.glLoadIdentity(); |
---|
10168 | 11241 | |
---|
.. | .. |
---|
10251 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
10252 | 11325 | |
---|
10253 | 11326 | // if (cam != lightCamera) |
---|
10254 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10255 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11327 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10256 | 11329 | } |
---|
10257 | 11330 | |
---|
10258 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10273 | 11346 | if (true) // TODO |
---|
10274 | 11347 | { |
---|
10275 | 11348 | if (cam != lightCamera) |
---|
10276 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10277 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11349 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10278 | 11351 | } |
---|
10279 | 11352 | |
---|
10280 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10340 | 11413 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10341 | 11414 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10342 | 11415 | |
---|
10343 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11416 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10344 | 11417 | { |
---|
10345 | 11418 | /* |
---|
10346 | 11419 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10411 | 11484 | } |
---|
10412 | 11485 | } |
---|
10413 | 11486 | |
---|
10414 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10415 | 11488 | { |
---|
10416 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10417 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10419 | 11492 | |
---|
10420 | 11493 | boolean texon = textureon; |
---|
10421 | 11494 | |
---|
10422 | | - if (RENDERPROGRAM > 0) |
---|
10423 | | - { |
---|
10424 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10425 | | - textureon = false; |
---|
10426 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
10427 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10428 | 11499 | //System.out.println("ALLO"); |
---|
10429 | 11500 | gl.glColorMask(false, false, false, false); |
---|
10430 | 11501 | DrawObject(gl); |
---|
10431 | | - if (RENDERPROGRAM > 0) |
---|
10432 | | - { |
---|
10433 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10434 | | - textureon = texon; |
---|
10435 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
10436 | 11506 | gl.glColorMask(true, true, true, true); |
---|
10437 | 11507 | |
---|
10438 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10439 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
10440 | 11510 | } |
---|
10441 | 11511 | |
---|
10442 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10590 | 11660 | { |
---|
10591 | 11661 | renderpass++; |
---|
10592 | 11662 | // System.out.println("Draw object... "); |
---|
| 11663 | + STEP = 1; |
---|
10593 | 11664 | if (FAST) // in case there is no script |
---|
10594 | | - STEP = 16; |
---|
| 11665 | + STEP = 8; |
---|
| 11666 | + |
---|
| 11667 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11668 | + { |
---|
| 11669 | + STEP *= 4; |
---|
| 11670 | + } |
---|
10595 | 11671 | |
---|
10596 | 11672 | //object.FullInvariants(); |
---|
10597 | 11673 | |
---|
.. | .. |
---|
10605 | 11681 | e.printStackTrace(); |
---|
10606 | 11682 | } |
---|
10607 | 11683 | |
---|
10608 | | - if (GrafreeD.RENDERME > 0) |
---|
10609 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11684 | + if (Grafreed.RENDERME > 0) |
---|
| 11685 | + Grafreed.RENDERME--; // mechante magouille |
---|
10610 | 11686 | |
---|
10611 | 11687 | Globals.ONESTEP = false; |
---|
10612 | 11688 | } |
---|
10613 | 11689 | |
---|
10614 | 11690 | static boolean zoomonce = false; |
---|
10615 | 11691 | |
---|
| 11692 | + static void CreateSelectedPoint() |
---|
| 11693 | + { |
---|
| 11694 | + if (selectedpoint == null) |
---|
| 11695 | + { |
---|
| 11696 | + debugpointG = new Sphere(); |
---|
| 11697 | + debugpointP = new Sphere(); |
---|
| 11698 | + debugpointC = new Sphere(); |
---|
| 11699 | + debugpointR = new Sphere(); |
---|
| 11700 | + |
---|
| 11701 | + selectedpoint = new Superellipsoid(); |
---|
| 11702 | + |
---|
| 11703 | + for (int i=0; i<8; i++) |
---|
| 11704 | + { |
---|
| 11705 | + debugpoints[i] = new Sphere(); |
---|
| 11706 | + } |
---|
| 11707 | + } |
---|
| 11708 | + } |
---|
| 11709 | + |
---|
10616 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
10617 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
10618 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10619 | 11716 | // DrawMode() = SELECTION; |
---|
10620 | 11717 | //GL gl = getGL(); |
---|
10621 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10622 | 11719 | { |
---|
10623 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10624 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10625 | 11722 | pingthread.StepToTarget(true); // true); |
---|
10626 | 11723 | // zoomonce = false; |
---|
10627 | 11724 | } |
---|
.. | .. |
---|
10641 | 11738 | callist = gl.glGenLists(1); |
---|
10642 | 11739 | } |
---|
10643 | 11740 | |
---|
10644 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11741 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10645 | 11742 | |
---|
10646 | 11743 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10647 | 11744 | |
---|
.. | .. |
---|
10676 | 11773 | |
---|
10677 | 11774 | usedtextures.clear(); |
---|
10678 | 11775 | |
---|
10679 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11776 | + try |
---|
| 11777 | + { |
---|
| 11778 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11779 | + } |
---|
| 11780 | + catch (Exception e) |
---|
| 11781 | + { |
---|
| 11782 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11783 | + } |
---|
10680 | 11784 | } |
---|
10681 | 11785 | //System.out.println("--> " + stackdepth); |
---|
10682 | 11786 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10686 | 11790 | |
---|
10687 | 11791 | if (DrawMode() == DEFAULT) |
---|
10688 | 11792 | { |
---|
10689 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
10690 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
10691 | 11796 | float radius = 0.05f; |
---|
10692 | 11797 | if (selectedpoint.radius != radius) |
---|
10693 | 11798 | { |
---|
.. | .. |
---|
10741 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10742 | 11847 | |
---|
10743 | 11848 | if (CLEANCACHE) |
---|
10744 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10745 | 11850 | { |
---|
10746 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
10747 | 11852 | |
---|
10748 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
10749 | 11854 | |
---|
10750 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
10751 | 11856 | continue; |
---|
10752 | 11857 | |
---|
10753 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
10754 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10755 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10756 | | - textures.get(tex).texture.dispose(); |
---|
10757 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
10758 | 11875 | } |
---|
10759 | 11876 | } |
---|
10760 | 11877 | } |
---|
.. | .. |
---|
10767 | 11884 | if (checker != null && DrawMode() == DEFAULT) |
---|
10768 | 11885 | { |
---|
10769 | 11886 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10770 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11887 | + try |
---|
| 11888 | + { |
---|
| 11889 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11890 | + } |
---|
| 11891 | + catch (Exception e) |
---|
| 11892 | + { |
---|
| 11893 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11894 | + } |
---|
10771 | 11895 | // NEAREST |
---|
10772 | 11896 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10773 | 11897 | DrawChecker(gl); |
---|
.. | .. |
---|
10849 | 11973 | return; |
---|
10850 | 11974 | } |
---|
10851 | 11975 | |
---|
10852 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
10853 | 11977 | |
---|
10854 | 11978 | GL gl = GetGL(); |
---|
10855 | 11979 | |
---|
.. | .. |
---|
11166 | 12290 | //obj.TransformToWorld(light, light); |
---|
11167 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
11168 | 12292 | { |
---|
11169 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11170 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12293 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11171 | 12295 | } |
---|
11172 | 12296 | |
---|
11173 | 12297 | |
---|
.. | .. |
---|
11184 | 12308 | parentcam = cameras[0]; |
---|
11185 | 12309 | } |
---|
11186 | 12310 | |
---|
11187 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11188 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12311 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11189 | 12313 | |
---|
11190 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11191 | 12315 | |
---|
.. | .. |
---|
11276 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11277 | 12401 | |
---|
11278 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
11279 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
11280 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11281 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
11282 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
11391 | 12560 | "TEMP shininess;" + |
---|
11392 | 12561 | "\n" + |
---|
11393 | 12562 | "MOV texSamp, one;" + |
---|
11394 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
11395 | | - |
---|
| 12563 | + |
---|
11396 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
11397 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
11398 | 12566 | /* |
---|
.. | .. |
---|
11797 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
11798 | 12966 | "") + |
---|
11799 | 12967 | |
---|
11800 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
11801 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
11802 | | - "MOV temp.y, -params6.x;" + |
---|
11803 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12970 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12971 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
11804 | 12972 | "SUB temp.y, one.x, temp.z;" + |
---|
11805 | 12973 | "MUL temp.x, temp.x, temp.y;" + |
---|
11806 | 12974 | "KIL temp.x;" + |
---|
.. | .. |
---|
11929 | 13097 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11930 | 13098 | |
---|
11931 | 13099 | "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 |
---|
| 13100 | + // Tuning for default skin |
---|
| 13101 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13102 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13103 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11934 | 13104 | "MUL temp.x, temp.x, temp.y;" + |
---|
11935 | 13105 | |
---|
11936 | 13106 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12129 | 13299 | //once = true; |
---|
12130 | 13300 | } |
---|
12131 | 13301 | |
---|
12132 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13302 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12133 | 13303 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12134 | 13304 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12135 | 13305 | |
---|
.. | .. |
---|
12227 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12228 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12229 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12230 | 13402 | "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;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12235 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12236 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12237 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12238 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12239 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12240 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12241 | 13411 | |
---|
12242 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12243 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12244 | 13414 | } |
---|
12245 | 13415 | |
---|
12246 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12262 | 13432 | |
---|
12263 | 13433 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12264 | 13434 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13435 | + |
---|
| 13436 | + // Compare fragment depth in light space with shadowmap. |
---|
12265 | 13437 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12266 | 13438 | "SGE temp.y, temp.x, zero.x;" + |
---|
12267 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13439 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13440 | + |
---|
| 13441 | + // Reverse comparison |
---|
12268 | 13442 | "SUB temp.x, one.x, temp.x;" + |
---|
12269 | 13443 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12270 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13444 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12271 | 13445 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12272 | 13446 | |
---|
12273 | 13447 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12281 | 13455 | // No shadow for backface |
---|
12282 | 13456 | "DP3 temp.x, normal, lightd;" + |
---|
12283 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13458 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13459 | + |
---|
| 13460 | + // No shadow when out of frustum |
---|
| 13461 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12284 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12285 | 13463 | ""; |
---|
12286 | 13464 | } |
---|
.. | .. |
---|
12427 | 13605 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12428 | 13606 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12429 | 13607 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12430 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13608 | + |
---|
| 13609 | + //Object3D.cVector2[] vector2buffer; |
---|
12431 | 13610 | |
---|
12432 | 13611 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12433 | 13612 | // OUT : diff, spec |
---|
.. | .. |
---|
12443 | 13622 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12444 | 13623 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12445 | 13624 | //"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;" + |
---|
| 13625 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13626 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13627 | + |
---|
| 13628 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12449 | 13629 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12450 | 13630 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12451 | 13631 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12839 | 14019 | public void mousePressed(MouseEvent e) |
---|
12840 | 14020 | { |
---|
12841 | 14021 | //System.out.println("mousePressed: " + e); |
---|
12842 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14022 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12843 | 14023 | } |
---|
12844 | 14024 | |
---|
12845 | 14025 | static long prevtime = 0; |
---|
.. | .. |
---|
12866 | 14046 | |
---|
12867 | 14047 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12868 | 14048 | |
---|
| 14049 | + if (BUTTONLESSWHEEL) |
---|
12869 | 14050 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12870 | 14051 | { |
---|
12871 | 14052 | return; |
---|
.. | .. |
---|
12874 | 14055 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12875 | 14056 | |
---|
12876 | 14057 | // TIMER |
---|
12877 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14058 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12878 | 14059 | { |
---|
12879 | 14060 | keepboxmode = BOXMODE; |
---|
12880 | 14061 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12914 | 14095 | // mode |= META; |
---|
12915 | 14096 | //} |
---|
12916 | 14097 | |
---|
12917 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12918 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14098 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14099 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12919 | 14100 | anchorX = ax; |
---|
12920 | 14101 | anchorY = ay; |
---|
12921 | 14102 | prevX = px; |
---|
.. | .. |
---|
12949 | 14130 | else |
---|
12950 | 14131 | if (evt.getSource() == AAtimer) |
---|
12951 | 14132 | { |
---|
| 14133 | + Globals.TIMERRUNNING = false; |
---|
12952 | 14134 | if (mouseDown) |
---|
12953 | 14135 | { |
---|
12954 | 14136 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12974 | 14156 | // LIVE = waslive; |
---|
12975 | 14157 | // wasliveok = true; |
---|
12976 | 14158 | // waslive = false; |
---|
| 14159 | + |
---|
| 14160 | + // May 2019 Forget it: |
---|
| 14161 | + if (true) |
---|
| 14162 | + return; |
---|
12977 | 14163 | |
---|
12978 | 14164 | // source == timer |
---|
12979 | 14165 | if (mouseDown) |
---|
.. | .. |
---|
13004 | 14190 | |
---|
13005 | 14191 | // fev 2014??? |
---|
13006 | 14192 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13007 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14193 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13008 | 14194 | pingthread.StepToTarget(true); // true); |
---|
13009 | 14195 | } |
---|
13010 | 14196 | // if (!LIVE) |
---|
.. | .. |
---|
13013 | 14199 | |
---|
13014 | 14200 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13015 | 14201 | |
---|
13016 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14202 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13017 | 14203 | { |
---|
13018 | 14204 | if (!wasliveok) |
---|
13019 | 14205 | return; |
---|
13020 | 14206 | |
---|
13021 | 14207 | AAtimer.restart(); // |
---|
| 14208 | + Globals.TIMERRUNNING = true; |
---|
13022 | 14209 | |
---|
13023 | 14210 | // waslive = LIVE; |
---|
13024 | 14211 | // LIVE = false; |
---|
.. | .. |
---|
13030 | 14217 | // touched = true; // main DL |
---|
13031 | 14218 | if (isRenderer) |
---|
13032 | 14219 | { |
---|
13033 | | - SetMouseMode(modifiers); |
---|
| 14220 | + SetMouseMode(modifiers, modifiersex); |
---|
13034 | 14221 | } |
---|
13035 | 14222 | |
---|
13036 | 14223 | selectX = anchorX = x; |
---|
.. | .. |
---|
13043 | 14230 | clicked = true; |
---|
13044 | 14231 | hold = false; |
---|
13045 | 14232 | |
---|
13046 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14233 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13047 | 14234 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13048 | 14235 | { |
---|
13049 | 14236 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13074 | 14261 | info.camera = renderCamera; |
---|
13075 | 14262 | info.x = x; |
---|
13076 | 14263 | info.y = y; |
---|
13077 | | - info.modifiers = modifiers; |
---|
| 14264 | + info.modifiers = modifiersex; |
---|
13078 | 14265 | editObj = object.doEditClick(info, 0); |
---|
13079 | 14266 | if (!editObj) |
---|
13080 | 14267 | { |
---|
.. | .. |
---|
13091 | 14278 | |
---|
13092 | 14279 | public void mouseDragged(MouseEvent e) |
---|
13093 | 14280 | { |
---|
| 14281 | + Globals.MOUSEDRAGGED = true; |
---|
| 14282 | + |
---|
| 14283 | + //System.out.println("mouseDragged: " + e); |
---|
13094 | 14284 | if (isRenderer) |
---|
13095 | 14285 | movingcamera = true; |
---|
| 14286 | + |
---|
13096 | 14287 | //if (drawing) |
---|
13097 | 14288 | //return; |
---|
13098 | | - //System.out.println("mouseDragged: " + e); |
---|
13099 | 14289 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13100 | 14290 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13101 | 14291 | { |
---|
.. | .. |
---|
13103 | 14293 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13104 | 14294 | } |
---|
13105 | 14295 | else |
---|
13106 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14296 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13107 | 14297 | |
---|
13108 | 14298 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13109 | 14299 | } |
---|
.. | .. |
---|
13115 | 14305 | cVector tmp = new cVector(); |
---|
13116 | 14306 | cVector tmp2 = new cVector(); |
---|
13117 | 14307 | boolean isMoving; |
---|
| 14308 | + |
---|
| 14309 | + public cVector TargetLookAt() |
---|
| 14310 | + { |
---|
| 14311 | + return targetLookAt; |
---|
| 14312 | + } |
---|
13118 | 14313 | |
---|
13119 | 14314 | class PingThread extends Thread |
---|
13120 | 14315 | { |
---|
.. | .. |
---|
13271 | 14466 | |
---|
13272 | 14467 | public void run() |
---|
13273 | 14468 | { |
---|
| 14469 | + new Exception().printStackTrace(); |
---|
13274 | 14470 | System.exit(0); |
---|
13275 | 14471 | for (;;) |
---|
13276 | 14472 | { |
---|
.. | .. |
---|
13334 | 14530 | { |
---|
13335 | 14531 | Globals.lighttouched = true; |
---|
13336 | 14532 | } |
---|
13337 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14533 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13338 | 14534 | } |
---|
13339 | 14535 | //else |
---|
13340 | 14536 | } |
---|
.. | .. |
---|
13348 | 14544 | void GoDown(int mod) |
---|
13349 | 14545 | { |
---|
13350 | 14546 | MODIFIERS |= COMMAND; |
---|
13351 | | - /* |
---|
| 14547 | + /**/ |
---|
13352 | 14548 | if((mod&SHIFT) == SHIFT) |
---|
13353 | 14549 | manipCamera.RotatePosition(0, -speed); |
---|
13354 | 14550 | else |
---|
13355 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13356 | | - */ |
---|
| 14551 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14552 | + /**/ |
---|
13357 | 14553 | if ((mod & SHIFT) == SHIFT) |
---|
13358 | 14554 | { |
---|
13359 | 14555 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13369 | 14565 | void GoUp(int mod) |
---|
13370 | 14566 | { |
---|
13371 | 14567 | MODIFIERS |= COMMAND; |
---|
13372 | | - /* |
---|
| 14568 | + /**/ |
---|
13373 | 14569 | if((mod&SHIFT) == SHIFT) |
---|
13374 | 14570 | manipCamera.RotatePosition(0, speed); |
---|
13375 | 14571 | else |
---|
13376 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13377 | | - */ |
---|
| 14572 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14573 | + /**/ |
---|
13378 | 14574 | if ((mod & SHIFT) == SHIFT) |
---|
13379 | 14575 | { |
---|
13380 | 14576 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13390 | 14586 | void GoLeft(int mod) |
---|
13391 | 14587 | { |
---|
13392 | 14588 | MODIFIERS |= COMMAND; |
---|
13393 | | - /* |
---|
| 14589 | + /**/ |
---|
13394 | 14590 | if((mod&SHIFT) == SHIFT) |
---|
13395 | | - manipCamera.RotatePosition(speed, 0); |
---|
13396 | | - else |
---|
13397 | 14591 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13398 | | - */ |
---|
| 14592 | + else |
---|
| 14593 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14594 | + /**/ |
---|
13399 | 14595 | if ((mod & SHIFT) == SHIFT) |
---|
13400 | 14596 | { |
---|
13401 | 14597 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13411 | 14607 | void GoRight(int mod) |
---|
13412 | 14608 | { |
---|
13413 | 14609 | MODIFIERS |= COMMAND; |
---|
13414 | | - /* |
---|
| 14610 | + /**/ |
---|
13415 | 14611 | if((mod&SHIFT) == SHIFT) |
---|
13416 | | - manipCamera.RotatePosition(-speed, 0); |
---|
13417 | | - else |
---|
13418 | 14612 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13419 | | - */ |
---|
| 14613 | + else |
---|
| 14614 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14615 | + /**/ |
---|
13420 | 14616 | if ((mod & SHIFT) == SHIFT) |
---|
13421 | 14617 | { |
---|
13422 | 14618 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13434 | 14630 | int X, Y; |
---|
13435 | 14631 | boolean SX, SY; |
---|
13436 | 14632 | |
---|
13437 | | - void drag(int x, int y, int modifiers) |
---|
| 14633 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13438 | 14634 | { |
---|
13439 | 14635 | if (IsFrozen()) |
---|
13440 | 14636 | { |
---|
.. | .. |
---|
13443 | 14639 | |
---|
13444 | 14640 | drag = true; // NEW |
---|
13445 | 14641 | |
---|
13446 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14642 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13447 | 14643 | |
---|
13448 | 14644 | X = x; |
---|
13449 | 14645 | Y = y; |
---|
13450 | 14646 | // floating state for animation |
---|
13451 | | - MODIFIERS = modifiers; |
---|
13452 | | - modifiers &= ~1024; |
---|
| 14647 | + MODIFIERS = modifiersex; |
---|
| 14648 | + modifiersex &= ~1024; |
---|
13453 | 14649 | if (false) // modifiers != 0) |
---|
13454 | 14650 | { |
---|
13455 | 14651 | //new Exception().printStackTrace(); |
---|
13456 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14652 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13457 | 14653 | System.out.println("SHIFT = " + SHIFT); |
---|
13458 | 14654 | System.out.println("CONTROL = " + COMMAND); |
---|
13459 | 14655 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13473 | 14669 | info.camera = renderCamera; |
---|
13474 | 14670 | info.x = x; |
---|
13475 | 14671 | info.y = y; |
---|
13476 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14672 | + object.GetWindow().copy |
---|
| 14673 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13477 | 14674 | } else |
---|
13478 | 14675 | { |
---|
13479 | 14676 | if (x < startX) |
---|
.. | .. |
---|
13625 | 14822 | public void mouseMoved(MouseEvent e) |
---|
13626 | 14823 | { |
---|
13627 | 14824 | //System.out.println("mouseMoved: " + e); |
---|
13628 | | - |
---|
13629 | 14825 | if (isRenderer) |
---|
13630 | 14826 | return; |
---|
13631 | 14827 | |
---|
.. | .. |
---|
13638 | 14834 | ci.camera = renderCamera; |
---|
13639 | 14835 | if (!isRenderer) |
---|
13640 | 14836 | { |
---|
13641 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14837 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14838 | + //Object3D copy = editWindow.copy; |
---|
| 14839 | + if (object.doEditClick(ci, 0)) |
---|
13642 | 14840 | { |
---|
13643 | 14841 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13644 | 14842 | } else |
---|
.. | .. |
---|
13650 | 14848 | |
---|
13651 | 14849 | public void mouseReleased(MouseEvent e) |
---|
13652 | 14850 | { |
---|
| 14851 | + Globals.MOUSEDRAGGED = false; |
---|
| 14852 | + |
---|
13653 | 14853 | movingcamera = false; |
---|
| 14854 | + X = 0; // getBounds().width/2; |
---|
| 14855 | + Y = 0; // getBounds().height/2; |
---|
13654 | 14856 | //System.out.println("mouseReleased: " + e); |
---|
13655 | 14857 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13656 | 14858 | } |
---|
.. | .. |
---|
13673 | 14875 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13674 | 14876 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13675 | 14877 | |
---|
13676 | | - if (control || command || IsFrozen()) |
---|
| 14878 | +// No delay if (control || command || IsFrozen()) |
---|
13677 | 14879 | timeout = true; |
---|
13678 | | - else |
---|
| 14880 | +// ?? May 2019 else |
---|
13679 | 14881 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13680 | 14882 | mouseDown = false; |
---|
13681 | 14883 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13785 | 14987 | System.out.println("keyReleased: " + e); |
---|
13786 | 14988 | } |
---|
13787 | 14989 | |
---|
13788 | | - void SetMouseMode(int modifiers) |
---|
| 14990 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13789 | 14991 | { |
---|
13790 | 14992 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13791 | 14993 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13797 | 14999 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13798 | 15000 | // return; |
---|
13799 | 15001 | //System.out.println("SetMode = " + modifiers); |
---|
13800 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15002 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13801 | 15003 | { |
---|
13802 | 15004 | mouseMode |= ZOOM; |
---|
13803 | 15005 | } |
---|
13804 | 15006 | |
---|
13805 | 15007 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13806 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15008 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13807 | 15009 | { |
---|
13808 | 15010 | mouseMode |= VR; // BACKFORTH; |
---|
13809 | 15011 | } |
---|
13810 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15012 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13811 | 15013 | { |
---|
13812 | 15014 | mouseMode |= SELECT; |
---|
13813 | 15015 | } |
---|
13814 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15016 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13815 | 15017 | { |
---|
13816 | 15018 | mouseMode |= SELECT; |
---|
13817 | 15019 | } |
---|
13818 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15020 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13819 | 15021 | { |
---|
13820 | 15022 | mouseMode &= ~VR; |
---|
13821 | 15023 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13844 | 15046 | |
---|
13845 | 15047 | if (isRenderer) // |
---|
13846 | 15048 | { |
---|
13847 | | - SetMouseMode(modifiers); |
---|
| 15049 | + SetMouseMode(0, modifiers); |
---|
13848 | 15050 | } |
---|
13849 | 15051 | |
---|
13850 | | - theRenderer.keyPressed(key); |
---|
| 15052 | + Globals.theRenderer.keyPressed(key); |
---|
13851 | 15053 | } |
---|
13852 | 15054 | |
---|
13853 | 15055 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13859 | 15061 | float SATPOW = 1; // 2; // 0.5f; |
---|
13860 | 15062 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13861 | 15063 | |
---|
13862 | | - void keyPressed(int key) |
---|
| 15064 | + public void keyPressed(int key) |
---|
13863 | 15065 | { |
---|
13864 | 15066 | if (key >= '0' && key <= '5') |
---|
13865 | 15067 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13906 | 15108 | // break; |
---|
13907 | 15109 | case 'T': |
---|
13908 | 15110 | CACHETEXTURE ^= true; |
---|
13909 | | - textures.clear(); |
---|
| 15111 | + texturepigment.clear(); |
---|
| 15112 | + texturebump.clear(); |
---|
13910 | 15113 | // repaint(); |
---|
13911 | 15114 | break; |
---|
13912 | 15115 | case 'Y': |
---|
.. | .. |
---|
13991 | 15194 | case 'E' : COMPACT ^= true; |
---|
13992 | 15195 | repaint(); |
---|
13993 | 15196 | break; |
---|
13994 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15197 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15198 | + //DEBUGHSB ^= true; |
---|
| 15199 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13995 | 15200 | repaint(); |
---|
13996 | 15201 | break; |
---|
13997 | 15202 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14016 | 15221 | RevertCamera(); |
---|
14017 | 15222 | repaint(); |
---|
14018 | 15223 | break; |
---|
14019 | | - case 'L': |
---|
14020 | 15224 | case 'l': |
---|
| 15225 | + //case 'L': |
---|
14021 | 15226 | if (lightMode) |
---|
14022 | 15227 | { |
---|
14023 | 15228 | lightMode = false; |
---|
.. | .. |
---|
14160 | 15365 | case '_': |
---|
14161 | 15366 | kompactbit = 5; |
---|
14162 | 15367 | break; |
---|
14163 | | - case '+': |
---|
14164 | | - kompactbit = 6; |
---|
14165 | | - break; |
---|
| 15368 | +// case '+': |
---|
| 15369 | +// kompactbit = 6; |
---|
| 15370 | +// break; |
---|
14166 | 15371 | case ' ': |
---|
14167 | 15372 | lightMode ^= true; |
---|
14168 | 15373 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14174 | 15379 | case ESC: |
---|
14175 | 15380 | RENDERPROGRAM += 1; |
---|
14176 | 15381 | RENDERPROGRAM %= 3; |
---|
| 15382 | + |
---|
14177 | 15383 | repaint(); |
---|
14178 | 15384 | break; |
---|
14179 | 15385 | case 'Z': |
---|
14180 | 15386 | //RESIZETEXTURE ^= true; |
---|
14181 | 15387 | //break; |
---|
14182 | 15388 | case 'z': |
---|
14183 | | - RENDERSHADOW ^= true; |
---|
| 15389 | + Globals.RENDERSHADOW ^= true; |
---|
14184 | 15390 | Globals.lighttouched = true; |
---|
14185 | 15391 | repaint(); |
---|
14186 | 15392 | break; |
---|
.. | .. |
---|
14213 | 15419 | case DELETE: |
---|
14214 | 15420 | ClearSelection(); |
---|
14215 | 15421 | break; |
---|
14216 | | - /* |
---|
14217 | 15422 | case '+': |
---|
| 15423 | + |
---|
| 15424 | + /* |
---|
14218 | 15425 | //fontsize += 1; |
---|
14219 | 15426 | bbzoom *= 2; |
---|
14220 | 15427 | repaint(); |
---|
.. | .. |
---|
14231 | 15438 | case '=': |
---|
14232 | 15439 | IncDepth(); |
---|
14233 | 15440 | //fontsize += 1; |
---|
14234 | | - object.editWindow.refreshContents(true); |
---|
| 15441 | + object.GetWindow().refreshContents(true); |
---|
14235 | 15442 | maskbit = 6; |
---|
14236 | 15443 | break; |
---|
14237 | 15444 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14238 | 15445 | DecDepth(); |
---|
14239 | 15446 | maskbit = 5; |
---|
14240 | 15447 | //if(fontsize > 1) fontsize -= 1; |
---|
14241 | | - if (object.editWindow == null) |
---|
14242 | | - new Exception().printStackTrace(); |
---|
14243 | | - else |
---|
14244 | | - object.editWindow.refreshContents(true); |
---|
| 15448 | +// if (object.editWindow == null) |
---|
| 15449 | +// new Exception().printStackTrace(); |
---|
| 15450 | +// else |
---|
| 15451 | + object.GetWindow().refreshContents(true); |
---|
14245 | 15452 | break; |
---|
14246 | 15453 | case '{': |
---|
14247 | 15454 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14296 | 15503 | } |
---|
14297 | 15504 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14298 | 15505 | } |
---|
| 15506 | + |
---|
14299 | 15507 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14300 | 15508 | |
---|
14301 | 15509 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14303 | 15511 | //mode = ROTATE; |
---|
14304 | 15512 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14305 | 15513 | { |
---|
14306 | | - SetMouseMode(modifiers); |
---|
| 15514 | + SetMouseMode(0, modifiers); |
---|
14307 | 15515 | } |
---|
14308 | 15516 | } |
---|
14309 | 15517 | |
---|
14310 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15518 | + public void processKeyEvent(KeyEvent e) |
---|
14311 | 15519 | { |
---|
14312 | 15520 | switch (e.getID()) |
---|
14313 | 15521 | { |
---|
.. | .. |
---|
14437 | 15645 | |
---|
14438 | 15646 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14439 | 15647 | { |
---|
14440 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14441 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15648 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15649 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15650 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14442 | 15651 | { |
---|
14443 | 15652 | mouseMoved(e); |
---|
14444 | 15653 | } else |
---|
.. | .. |
---|
14463 | 15672 | } |
---|
14464 | 15673 | */ |
---|
14465 | 15674 | |
---|
14466 | | - object.editWindow.EditSelection(); |
---|
| 15675 | + object.GetWindow().EditSelection(false); |
---|
14467 | 15676 | } |
---|
14468 | 15677 | |
---|
14469 | 15678 | void SelectParent() |
---|
14470 | 15679 | { |
---|
| 15680 | + new Exception().printStackTrace(); |
---|
14471 | 15681 | System.exit(0); |
---|
14472 | 15682 | Composite group = (Composite) object; |
---|
14473 | 15683 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14479 | 15689 | { |
---|
14480 | 15690 | //selectees.remove(i); |
---|
14481 | 15691 | System.out.println("select parent of " + elem); |
---|
14482 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15692 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14483 | 15693 | } else |
---|
14484 | 15694 | { |
---|
14485 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15695 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14486 | 15696 | } |
---|
14487 | 15697 | |
---|
14488 | 15698 | first = false; |
---|
.. | .. |
---|
14491 | 15701 | |
---|
14492 | 15702 | void SelectChildren() |
---|
14493 | 15703 | { |
---|
| 15704 | + new Exception().printStackTrace(); |
---|
14494 | 15705 | System.exit(0); |
---|
14495 | 15706 | /* |
---|
14496 | 15707 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14523 | 15734 | for (int j = 0; j < group.children.size(); j++) |
---|
14524 | 15735 | { |
---|
14525 | 15736 | elem = (Object3D) group.children.elementAt(j); |
---|
14526 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15737 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14527 | 15738 | first = false; |
---|
14528 | 15739 | } |
---|
14529 | 15740 | } else |
---|
14530 | 15741 | { |
---|
14531 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15742 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14532 | 15743 | } |
---|
14533 | 15744 | |
---|
14534 | 15745 | first = false; |
---|
.. | .. |
---|
14539 | 15750 | { |
---|
14540 | 15751 | //Composite group = (Composite) object; |
---|
14541 | 15752 | Object3D group = object; |
---|
14542 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15753 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14543 | 15754 | } |
---|
14544 | 15755 | |
---|
14545 | 15756 | void ResetTransform(int mask) |
---|
14546 | 15757 | { |
---|
14547 | 15758 | //Composite group = (Composite) object; |
---|
14548 | 15759 | Object3D group = object; |
---|
14549 | | - group.editWindow.ResetTransform(mask); |
---|
| 15760 | + group.GetWindow().ResetTransform(mask); |
---|
14550 | 15761 | } |
---|
14551 | 15762 | |
---|
14552 | 15763 | void FlipTransform() |
---|
14553 | 15764 | { |
---|
14554 | 15765 | //Composite group = (Composite) object; |
---|
14555 | 15766 | Object3D group = object; |
---|
14556 | | - group.editWindow.FlipTransform(); |
---|
| 15767 | + group.GetWindow().FlipTransform(); |
---|
14557 | 15768 | // group.editWindow.ReduceMesh(true); |
---|
14558 | 15769 | } |
---|
14559 | 15770 | |
---|
.. | .. |
---|
14561 | 15772 | { |
---|
14562 | 15773 | //Composite group = (Composite) object; |
---|
14563 | 15774 | Object3D group = object; |
---|
14564 | | - group.editWindow.PrintMemory(); |
---|
| 15775 | + group.GetWindow().PrintMemory(); |
---|
14565 | 15776 | // group.editWindow.ReduceMesh(true); |
---|
14566 | 15777 | } |
---|
14567 | 15778 | |
---|
.. | .. |
---|
14569 | 15780 | { |
---|
14570 | 15781 | //Composite group = (Composite) object; |
---|
14571 | 15782 | Object3D group = object; |
---|
14572 | | - group.editWindow.ResetCentroid(); |
---|
| 15783 | + group.GetWindow().ResetCentroid(); |
---|
14573 | 15784 | } |
---|
14574 | 15785 | |
---|
14575 | 15786 | void IncDepth() |
---|
.. | .. |
---|
14655 | 15866 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14656 | 15867 | //Image img = CreateImage(width, height); |
---|
14657 | 15868 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15869 | + |
---|
14658 | 15870 | Graphics gr = g; // img.getGraphics(); |
---|
| 15871 | + |
---|
14659 | 15872 | if (!hasMarquee) |
---|
14660 | 15873 | { |
---|
14661 | 15874 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14743 | 15956 | info.bounds.y += (height - desired) / 2; |
---|
14744 | 15957 | } |
---|
14745 | 15958 | } |
---|
| 15959 | + |
---|
14746 | 15960 | info.g = gr; |
---|
14747 | 15961 | info.camera = renderCamera; |
---|
14748 | 15962 | /* |
---|
.. | .. |
---|
14752 | 15966 | */ |
---|
14753 | 15967 | if (!isRenderer) |
---|
14754 | 15968 | { |
---|
14755 | | - object.drawEditHandles(info, 0); |
---|
| 15969 | + Grafreed.Assert(object != null); |
---|
| 15970 | + Grafreed.Assert(object.selection != null); |
---|
| 15971 | + if (object.selection.Size() > 0) |
---|
| 15972 | + { |
---|
| 15973 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15974 | + |
---|
| 15975 | + info.DX = 0; |
---|
| 15976 | + info.DY = 0; |
---|
| 15977 | + info.W = 1; |
---|
| 15978 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15979 | + { |
---|
| 15980 | + info.DX = X; |
---|
| 15981 | + if (X != 0) |
---|
| 15982 | + info.DX -= info.bounds.width/2; |
---|
| 15983 | + |
---|
| 15984 | + info.DY = Y; |
---|
| 15985 | + if (Y != 0) |
---|
| 15986 | + info.DY -= info.bounds.height/2; |
---|
| 15987 | + } |
---|
| 15988 | + |
---|
| 15989 | + object.drawEditHandles(info, 0); |
---|
| 15990 | + |
---|
| 15991 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15992 | + { |
---|
| 15993 | + switch (hitSomething) |
---|
| 15994 | + { |
---|
| 15995 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15996 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15997 | + break; |
---|
| 15998 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15999 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16000 | + break; |
---|
| 16001 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16002 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16003 | + break; |
---|
| 16004 | + } |
---|
| 16005 | + |
---|
| 16006 | + } |
---|
| 16007 | + } |
---|
14756 | 16008 | } |
---|
14757 | 16009 | } |
---|
| 16010 | + |
---|
14758 | 16011 | if (isRenderer) |
---|
14759 | 16012 | { |
---|
14760 | 16013 | //gr.setColor(Color.black); |
---|
14761 | 16014 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14762 | 16015 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14763 | 16016 | } |
---|
| 16017 | + |
---|
14764 | 16018 | if (hasMarquee) |
---|
14765 | 16019 | { |
---|
14766 | 16020 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
14873 | 16127 | public boolean mouseDown(Event evt, int x, int y) |
---|
14874 | 16128 | { |
---|
14875 | 16129 | System.out.println("mouseDown: " + evt); |
---|
| 16130 | + System.exit(0); |
---|
14876 | 16131 | /* |
---|
14877 | 16132 | locked = true; |
---|
14878 | 16133 | drag = false; |
---|
.. | .. |
---|
14916 | 16171 | { |
---|
14917 | 16172 | keyPressed(0, modifiers); |
---|
14918 | 16173 | } |
---|
14919 | | - clickStart(x, y, modifiers); |
---|
| 16174 | + // clickStart(x, y, modifiers); |
---|
14920 | 16175 | return true; |
---|
14921 | 16176 | } |
---|
14922 | 16177 | |
---|
.. | .. |
---|
15034 | 16289 | { |
---|
15035 | 16290 | keyReleased(0, 0); |
---|
15036 | 16291 | } |
---|
15037 | | - drag(x, y, modifiers); |
---|
| 16292 | + drag(x, y, 0, modifiers); |
---|
15038 | 16293 | return true; |
---|
15039 | 16294 | } |
---|
15040 | 16295 | |
---|
.. | .. |
---|
15166 | 16421 | Object3D object; |
---|
15167 | 16422 | static Object3D trackedobject; |
---|
15168 | 16423 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15169 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16424 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15170 | 16425 | /*static*/ Camera eyeCamera; |
---|
15171 | 16426 | /*static*/ Camera lightCamera; |
---|
15172 | 16427 | int cameracount; |
---|
.. | .. |
---|
15451 | 16706 | cStatic.objectstack[materialdepth++] = checker; |
---|
15452 | 16707 | //System.out.println("material " + material); |
---|
15453 | 16708 | //Applet3D.tracein(this, selected); |
---|
15454 | | - vector2buffer = checker.projectedVertices; |
---|
| 16709 | + //vector2buffer = checker.projectedVertices; |
---|
15455 | 16710 | |
---|
15456 | 16711 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15457 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16712 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15458 | 16713 | |
---|
15459 | 16714 | materialdepth -= 1; |
---|
15460 | 16715 | if (materialdepth > 0) |
---|
15461 | 16716 | { |
---|
15462 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15463 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16717 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16718 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15464 | 16719 | } |
---|
15465 | 16720 | //checker.GetMaterial().opacity = 1f; |
---|
15466 | 16721 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15546 | 16801 | } |
---|
15547 | 16802 | } |
---|
15548 | 16803 | |
---|
| 16804 | + private Object3D GetFolder() |
---|
| 16805 | + { |
---|
| 16806 | + Object3D folder = object.GetWindow().copy; |
---|
| 16807 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16808 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16809 | + return folder; |
---|
| 16810 | + } |
---|
| 16811 | + |
---|
15549 | 16812 | class SelectBuffer implements GLEventListener |
---|
15550 | 16813 | { |
---|
15551 | 16814 | |
---|
.. | .. |
---|
15604 | 16867 | { |
---|
15605 | 16868 | if (!selection) |
---|
15606 | 16869 | { |
---|
| 16870 | + new Exception().printStackTrace(); |
---|
15607 | 16871 | System.exit(0); |
---|
15608 | 16872 | return; |
---|
15609 | 16873 | } |
---|
.. | .. |
---|
15624 | 16888 | |
---|
15625 | 16889 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15626 | 16890 | |
---|
| 16891 | + if (PAINTMODE) |
---|
| 16892 | + { |
---|
| 16893 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16894 | + { |
---|
| 16895 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16896 | + |
---|
| 16897 | + // Make what you paint not selectable. |
---|
| 16898 | + paintobj.ResetSelectable(); |
---|
| 16899 | + } |
---|
| 16900 | + } |
---|
| 16901 | + |
---|
15627 | 16902 | //int tmp = selection_view; |
---|
15628 | 16903 | //selection_view = -1; |
---|
15629 | 16904 | int temp = DrawMode(); |
---|
.. | .. |
---|
15635 | 16910 | // temp = DEFAULT; // patch for selection debug |
---|
15636 | 16911 | Globals.drawMode = temp; // WARNING |
---|
15637 | 16912 | |
---|
| 16913 | + if (PAINTMODE) |
---|
| 16914 | + { |
---|
| 16915 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16916 | + { |
---|
| 16917 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16918 | + |
---|
| 16919 | + // Revert. |
---|
| 16920 | + paintobj.RestoreSelectable(); |
---|
| 16921 | + } |
---|
| 16922 | + } |
---|
| 16923 | + |
---|
15638 | 16924 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15639 | 16925 | |
---|
15640 | 16926 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15682 | 16968 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15683 | 16969 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15684 | 16970 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16971 | + |
---|
| 16972 | + CreateSelectedPoint(); |
---|
15685 | 16973 | |
---|
15686 | 16974 | // Will fit the mesh !!! |
---|
15687 | 16975 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15731 | 17019 | 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 | 17020 | } |
---|
15733 | 17021 | |
---|
15734 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17022 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15735 | 17023 | } |
---|
15736 | 17024 | } |
---|
15737 | 17025 | |
---|
15738 | 17026 | if (!movingcamera && !PAINTMODE) |
---|
15739 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17027 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15740 | 17028 | |
---|
15741 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17029 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15742 | 17030 | { |
---|
15743 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17031 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15744 | 17032 | |
---|
15745 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17033 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17034 | + { |
---|
| 17035 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15746 | 17036 | |
---|
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(); |
---|
| 17037 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17038 | + |
---|
| 17039 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17040 | + |
---|
| 17041 | + inst.add(paintobj); // link |
---|
| 17042 | + |
---|
| 17043 | + object.GetWindow().SnapObject(inst); |
---|
| 17044 | + |
---|
| 17045 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17046 | + |
---|
| 17047 | + folder.add(inst); |
---|
| 17048 | + |
---|
| 17049 | + object.GetWindow().ResetModel(); |
---|
| 17050 | + object.GetWindow().refreshContents(); |
---|
| 17051 | + } |
---|
15762 | 17052 | } |
---|
15763 | 17053 | else |
---|
15764 | 17054 | paintcount = 0; |
---|
.. | .. |
---|
15797 | 17087 | //System.out.println("objects[color] = " + objects[color]); |
---|
15798 | 17088 | //objects[color].Select(); |
---|
15799 | 17089 | indexcount = 0; |
---|
| 17090 | + ObjEditor window = object.GetWindow(); |
---|
| 17091 | + if (window != null && deselect) |
---|
| 17092 | + { |
---|
| 17093 | + window.Select(null, deselect, true); |
---|
| 17094 | + } |
---|
15800 | 17095 | object.Select(color, deselect); |
---|
15801 | 17096 | } |
---|
15802 | 17097 | |
---|
.. | .. |
---|
15896 | 17191 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15897 | 17192 | } |
---|
15898 | 17193 | |
---|
15899 | | - if (!RENDERSHADOW) |
---|
| 17194 | + if (!Globals.RENDERSHADOW) |
---|
15900 | 17195 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15901 | 17196 | |
---|
15902 | 17197 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15906 | 17201 | //gl.glColorMask(false, false, false, false); |
---|
15907 | 17202 | |
---|
15908 | 17203 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15909 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17204 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15910 | 17205 | { |
---|
15911 | 17206 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15912 | 17207 | |
---|
.. | .. |
---|
15966 | 17261 | |
---|
15967 | 17262 | class AntialiasBuffer implements GLEventListener |
---|
15968 | 17263 | { |
---|
15969 | | - |
---|
15970 | 17264 | CameraPane parent = null; |
---|
15971 | 17265 | |
---|
15972 | 17266 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16323 | 17617 | int AAbuffersize = 0; |
---|
16324 | 17618 | |
---|
16325 | 17619 | //double[] selectedpoint = new double[3]; |
---|
16326 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17620 | + static Superellipsoid selectedpoint; |
---|
16327 | 17621 | 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(); |
---|
| 17622 | + static Sphere debugpointG; |
---|
| 17623 | + static Sphere debugpointP; |
---|
| 17624 | + static Sphere debugpointC; |
---|
| 17625 | + static Sphere debugpointR; |
---|
16332 | 17626 | |
---|
16333 | 17627 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16334 | 17628 | |
---|
16335 | | - static |
---|
16336 | | - { |
---|
16337 | | - for (int i=0; i<8; i++) |
---|
16338 | | - { |
---|
16339 | | - debugpoints[i] = new Sphere(); |
---|
16340 | | - } |
---|
16341 | | - } |
---|
16342 | | - |
---|
16343 | 17629 | static void InitPoints(float radius) |
---|
16344 | 17630 | { |
---|
16345 | 17631 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16359 | 17645 | } |
---|
16360 | 17646 | } |
---|
16361 | 17647 | |
---|
16362 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17648 | + static void DrawPoints(iCameraPane cpane) |
---|
16363 | 17649 | { |
---|
16364 | 17650 | for (int i=0; i<8; i++) // first and last are red |
---|
16365 | 17651 | { |
---|
.. | .. |
---|
16391 | 17677 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16392 | 17678 | // Depth buffer format |
---|
16393 | 17679 | //private int depth_format; |
---|
16394 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17680 | + |
---|
| 17681 | + public void NextIndex() |
---|
16395 | 17682 | { |
---|
16396 | 17683 | indexcount+=16; |
---|
16397 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17684 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16398 | 17685 | //objects[indexcount] = o; |
---|
16399 | 17686 | //System.out.println("indexcount = " + indexcount); |
---|
16400 | 17687 | } |
---|