.. | .. |
---|
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) |
---|
.. | .. |
---|
191 | 228 | } |
---|
192 | 229 | |
---|
193 | 230 | /// INTERFACE |
---|
| 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 | + |
---|
| 261 | + public boolean IsBoxMode() |
---|
| 262 | + { |
---|
| 263 | + return BOXMODE; |
---|
| 264 | + } |
---|
| 265 | + |
---|
| 266 | + public boolean IsZoomBoxMode() |
---|
| 267 | + { |
---|
| 268 | + return ZOOMBOXMODE; |
---|
| 269 | + } |
---|
194 | 270 | |
---|
195 | 271 | public void ClearDepth() |
---|
196 | 272 | { |
---|
.. | .. |
---|
231 | 307 | return this.ambientOcclusion; |
---|
232 | 308 | } |
---|
233 | 309 | |
---|
| 310 | + public boolean IsDebugSelection() |
---|
| 311 | + { |
---|
| 312 | + return DEBUG_SELECTION; |
---|
| 313 | + } |
---|
| 314 | + |
---|
234 | 315 | public boolean IsFrozen() |
---|
235 | 316 | { |
---|
236 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 317 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
237 | 318 | |
---|
238 | 319 | return !selectmode && cameracount == 0; // != 0; |
---|
239 | 320 | } |
---|
.. | .. |
---|
254 | 335 | return lightCamera; |
---|
255 | 336 | } |
---|
256 | 337 | |
---|
| 338 | + public Camera ManipCamera() |
---|
| 339 | + { |
---|
| 340 | + return manipCamera; |
---|
| 341 | + } |
---|
| 342 | + |
---|
257 | 343 | public Camera RenderCamera() |
---|
258 | 344 | { |
---|
259 | 345 | return renderCamera; |
---|
| 346 | + } |
---|
| 347 | + |
---|
| 348 | + public Camera[] Cameras() |
---|
| 349 | + { |
---|
| 350 | + return cameras; |
---|
260 | 351 | } |
---|
261 | 352 | |
---|
262 | 353 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
272 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
273 | 364 | //System.out.println("material " + material); |
---|
274 | 365 | //Applet3D.tracein(this, selected); |
---|
275 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
276 | 367 | if (obj instanceof Camera) |
---|
277 | 368 | { |
---|
278 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
281 | 372 | display.options1[2] = material.shadowbias; |
---|
282 | 373 | display.options1[3] = material.aniso; |
---|
283 | 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]); |
---|
284 | 380 | display.options2[0] = material.opacity; |
---|
285 | 381 | display.options2[1] = material.diffuse; |
---|
286 | 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]); |
---|
287 | 386 | |
---|
288 | 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]); |
---|
289 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
290 | 392 | display.options4[1] = material.subsurface; |
---|
291 | 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]); |
---|
292 | 397 | |
---|
293 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
294 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
304 | 409 | /**/ |
---|
305 | 410 | } else |
---|
306 | 411 | { |
---|
307 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
308 | 413 | } |
---|
309 | 414 | } else |
---|
310 | 415 | { |
---|
.. | .. |
---|
328 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
329 | 434 | //System.out.println("material " + material); |
---|
330 | 435 | //Applet3D.tracein("selected ", selected); |
---|
331 | | - display.vector2buffer = obj.projectedVertices; |
---|
332 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
333 | 438 | } |
---|
334 | 439 | } |
---|
335 | 440 | |
---|
.. | .. |
---|
346 | 451 | materialdepth -= 1; |
---|
347 | 452 | if (materialdepth > 0) |
---|
348 | 453 | { |
---|
349 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
350 | | - 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); |
---|
351 | 456 | } |
---|
352 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
353 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
367 | 472 | materialdepth -= 1; |
---|
368 | 473 | if (materialdepth > 0) |
---|
369 | 474 | { |
---|
370 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
371 | | - 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); |
---|
372 | 477 | } |
---|
373 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
374 | 479 | //else |
---|
.. | .. |
---|
403 | 508 | |
---|
404 | 509 | javax.media.opengl.GL gl = display.GetGL(); |
---|
405 | 510 | |
---|
406 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 511 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
407 | 512 | |
---|
408 | 513 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
409 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
410 | 515 | { |
---|
411 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
412 | | - 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 | + ; |
---|
413 | 520 | if (!hasnorm) |
---|
414 | 521 | { |
---|
415 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
416 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
417 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
418 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
566 | 673 | } |
---|
567 | 674 | } |
---|
568 | 675 | |
---|
| 676 | + /** |
---|
| 677 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 678 | + * it's normals, colors, textures and vertices. |
---|
| 679 | + * |
---|
| 680 | + * @see Renderer#draw(TriMesh) |
---|
| 681 | + * @param tris |
---|
| 682 | + * the mesh to render. |
---|
| 683 | + */ |
---|
| 684 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 685 | + { |
---|
| 686 | + CameraPane display = this; |
---|
| 687 | + |
---|
| 688 | + float r = display.modelParams0[0]; |
---|
| 689 | + float g = display.modelParams0[1]; |
---|
| 690 | + float b = display.modelParams0[2]; |
---|
| 691 | + float opacity = display.modelParams5[1]; |
---|
| 692 | + |
---|
| 693 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 694 | + GL gl = display.GetGL(); // getGL(); |
---|
| 695 | + |
---|
| 696 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 697 | + |
---|
| 698 | + int v = vertBuf.capacity(); |
---|
| 699 | + |
---|
| 700 | + int count = 0; |
---|
| 701 | + |
---|
| 702 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 703 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 704 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 705 | + for (int i=0; i<v/3; i++) |
---|
| 706 | + { |
---|
| 707 | + int index3 = i*3; |
---|
| 708 | + |
---|
| 709 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 710 | + continue; |
---|
| 711 | + |
---|
| 712 | + count++; |
---|
| 713 | + |
---|
| 714 | + int index4 = i*4; |
---|
| 715 | + |
---|
| 716 | + float tx = vertBuf.get(index3); |
---|
| 717 | + float ty = vertBuf.get(index3+1); |
---|
| 718 | + float tz = vertBuf.get(index3+2); |
---|
| 719 | + |
---|
| 720 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 721 | + // continue; |
---|
| 722 | + |
---|
| 723 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 724 | + gl.glPushMatrix(); |
---|
| 725 | + |
---|
| 726 | + float[] texmat = geo.texmat; |
---|
| 727 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 728 | + |
---|
| 729 | + gl.glMultMatrixf(texmat, 0); |
---|
| 730 | + |
---|
| 731 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 732 | + gl.glPushMatrix(); |
---|
| 733 | + |
---|
| 734 | + gl.glTranslatef(tx,ty,tz); |
---|
| 735 | + |
---|
| 736 | + if (rotate) |
---|
| 737 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 738 | + |
---|
| 739 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 740 | + gl.glScalef(size,size,size); |
---|
| 741 | + |
---|
| 742 | + float cr = geo.colorBuf.get(index4); |
---|
| 743 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 744 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 745 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 746 | + |
---|
| 747 | + display.modelParams0[0] = r * cr; |
---|
| 748 | + display.modelParams0[1] = g * cg; |
---|
| 749 | + display.modelParams0[2] = b * cb; |
---|
| 750 | + |
---|
| 751 | + display.modelParams5[1] = opacity * ca; |
---|
| 752 | + |
---|
| 753 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 754 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 755 | + |
---|
| 756 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 757 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 758 | + |
---|
| 759 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 760 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 761 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 762 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 763 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 764 | + gl.glPopMatrix(); |
---|
| 765 | + |
---|
| 766 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 767 | + gl.glPopMatrix(); |
---|
| 768 | + } |
---|
| 769 | + // gl.glScalef(1024,1024,1024); |
---|
| 770 | + if (!cf) |
---|
| 771 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 772 | + |
---|
| 773 | + display.modelParams0[0] = r; |
---|
| 774 | + display.modelParams0[1] = g; |
---|
| 775 | + display.modelParams0[2] = b; |
---|
| 776 | + |
---|
| 777 | + display.modelParams5[1] = opacity; |
---|
| 778 | + |
---|
| 779 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 780 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 781 | + |
---|
| 782 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 783 | + |
---|
| 784 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 785 | + if (true) |
---|
| 786 | + return; |
---|
| 787 | + |
---|
| 788 | +//// if (!tris.predraw(this)) |
---|
| 789 | +//// { |
---|
| 790 | +//// return; |
---|
| 791 | +//// } |
---|
| 792 | +//// if (Debug.stats) |
---|
| 793 | +//// { |
---|
| 794 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 795 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 796 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 797 | +//// } |
---|
| 798 | +//// |
---|
| 799 | +//// if (tris.getDisplayListID() != -1) |
---|
| 800 | +//// { |
---|
| 801 | +//// renderDisplayList(tris); |
---|
| 802 | +//// return; |
---|
| 803 | +//// } |
---|
| 804 | +//// |
---|
| 805 | +//// if (!generatingDisplayList) |
---|
| 806 | +//// { |
---|
| 807 | +//// applyStates(tris.states, tris); |
---|
| 808 | +//// } |
---|
| 809 | +//// if (Debug.stats) |
---|
| 810 | +//// { |
---|
| 811 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 812 | +//// } |
---|
| 813 | +//// boolean transformed = doTransforms(tris); |
---|
| 814 | +// |
---|
| 815 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 816 | +// switch (getMode()) |
---|
| 817 | +// { |
---|
| 818 | +// case Triangles: |
---|
| 819 | +// glMode = GL.GL_TRIANGLES; |
---|
| 820 | +// break; |
---|
| 821 | +// case Strip: |
---|
| 822 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 823 | +// break; |
---|
| 824 | +// case Fan: |
---|
| 825 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 826 | +// break; |
---|
| 827 | +// } |
---|
| 828 | +// |
---|
| 829 | +// if (!predrawGeometry(gl)) |
---|
| 830 | +// { |
---|
| 831 | +// // make sure only the necessary indices are sent through on old |
---|
| 832 | +// // cards. |
---|
| 833 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 834 | +// if (indices == null) |
---|
| 835 | +// { |
---|
| 836 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 837 | +// } else |
---|
| 838 | +// { |
---|
| 839 | +// indices.rewind(); |
---|
| 840 | +// indices.limit(this.getMaxIndex()); |
---|
| 841 | +// |
---|
| 842 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 843 | +// |
---|
| 844 | +// indices.clear(); |
---|
| 845 | +// } |
---|
| 846 | +// } else |
---|
| 847 | +// { |
---|
| 848 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 849 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 850 | +// } |
---|
| 851 | +// |
---|
| 852 | +//// postdrawGeometry(tris); |
---|
| 853 | +//// if (transformed) |
---|
| 854 | +//// { |
---|
| 855 | +//// undoTransforms(tris); |
---|
| 856 | +//// } |
---|
| 857 | +//// |
---|
| 858 | +//// if (Debug.stats) |
---|
| 859 | +//// { |
---|
| 860 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 861 | +//// } |
---|
| 862 | +//// tris.postdraw(this); |
---|
| 863 | + } |
---|
| 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 | + |
---|
569 | 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 | + } |
---|
570 | 1486 | |
---|
571 | 1487 | void SetColor(Object3D obj, Vertex p0) |
---|
572 | 1488 | { |
---|
.. | .. |
---|
745 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
746 | 1662 | } |
---|
747 | 1663 | |
---|
748 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
749 | 1665 | { |
---|
750 | 1666 | CameraPane display = this; |
---|
751 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
761 | 1677 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
762 | 1678 | if (!material.multiply) |
---|
763 | 1679 | { |
---|
764 | | - display.color = color; |
---|
| 1680 | + display.color = material.color; |
---|
765 | 1681 | display.saturation = material.modulation; |
---|
766 | 1682 | } |
---|
767 | 1683 | else |
---|
768 | 1684 | { |
---|
769 | | - display.color *= color*2; |
---|
| 1685 | + display.color *= material.color*2; |
---|
770 | 1686 | display.saturation *= material.modulation*2; |
---|
771 | 1687 | } |
---|
772 | 1688 | |
---|
773 | 1689 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
774 | 1690 | |
---|
775 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1691 | + float[] colorV = Grafreed.colorV; |
---|
776 | 1692 | |
---|
777 | 1693 | /**/ |
---|
778 | 1694 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
780 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
781 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
782 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
783 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
784 | 1700 | |
---|
785 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
786 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
888 | 1804 | display.modelParams7[2] = 0; |
---|
889 | 1805 | display.modelParams7[3] = 0; |
---|
890 | 1806 | |
---|
891 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
892 | 1808 | |
---|
893 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
894 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
895 | 1811 | { |
---|
896 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1032 | 1948 | void PushMatrix(double[][] matrix) |
---|
1033 | 1949 | { |
---|
1034 | 1950 | // GrafreeD.tracein(matrix); |
---|
1035 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1036 | 1952 | } |
---|
1037 | 1953 | |
---|
1038 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
1129 | 2045 | |
---|
1130 | 2046 | static int camerachangeframe; |
---|
1131 | 2047 | |
---|
1132 | | - boolean SetCamera(Camera cam) |
---|
| 2048 | + public boolean SetCamera(Camera cam) |
---|
1133 | 2049 | { |
---|
1134 | 2050 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1135 | 2051 | // return false; |
---|
.. | .. |
---|
1186 | 2102 | //System.err.println("Oeil on"); |
---|
1187 | 2103 | OEIL = true; |
---|
1188 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1189 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1190 | 2106 | //pingthread.StepToTarget(true); |
---|
1191 | 2107 | } |
---|
1192 | 2108 | |
---|
.. | .. |
---|
1257 | 2173 | mainDL ^= true; |
---|
1258 | 2174 | } |
---|
1259 | 2175 | |
---|
1260 | | - void ToggleTexture() |
---|
1261 | | - { |
---|
1262 | | - textureon ^= true; |
---|
1263 | | - } |
---|
1264 | | - |
---|
1265 | | - void ToggleLive() |
---|
1266 | | - { |
---|
1267 | | - Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
1268 | | - |
---|
1269 | | - System.err.println("LIVE = " + Globals.isLIVE()); |
---|
1270 | | - |
---|
1271 | | - if (!Globals.isLIVE()) // save sound |
---|
1272 | | - GrafreeD.savesound = true; // wav.save(); |
---|
1273 | | - // else |
---|
1274 | | - repaint(); // start loop // may 2013 |
---|
1275 | | - } |
---|
1276 | | - |
---|
1277 | | - void ToggleSupport() |
---|
1278 | | - { |
---|
1279 | | - SUPPORT ^= true; |
---|
1280 | | - } |
---|
1281 | | - |
---|
1282 | | - void ToggleAbort() |
---|
1283 | | - { |
---|
1284 | | - ABORTMODE ^= true; |
---|
1285 | | - } |
---|
1286 | | - |
---|
1287 | 2176 | void ToggleFullScreen() |
---|
1288 | 2177 | { |
---|
1289 | 2178 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1294 | 2183 | Globals.CROWD ^= true; |
---|
1295 | 2184 | } |
---|
1296 | 2185 | |
---|
1297 | | - void ToggleInertia() |
---|
1298 | | - { |
---|
1299 | | - INERTIA ^= true; |
---|
1300 | | - } |
---|
1301 | | - |
---|
1302 | 2186 | void ToggleLocal() |
---|
1303 | 2187 | { |
---|
1304 | 2188 | LOCALTRANSFORM ^= true; |
---|
1305 | 2189 | } |
---|
1306 | 2190 | |
---|
1307 | | - 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() |
---|
1308 | 2224 | { |
---|
1309 | 2225 | FAST ^= true; |
---|
1310 | 2226 | } |
---|
1311 | 2227 | |
---|
1312 | | - void ToggleSlowPose() |
---|
| 2228 | + public void ToggleSlowPose() |
---|
1313 | 2229 | { |
---|
1314 | 2230 | SLOWPOSE ^= true; |
---|
1315 | 2231 | } |
---|
1316 | 2232 | |
---|
1317 | | - void ToggleFootContact() |
---|
1318 | | - { |
---|
1319 | | - FOOTCONTACT ^= true; |
---|
1320 | | - } |
---|
1321 | | - |
---|
1322 | | - void ToggleBoxMode() |
---|
| 2233 | + public void ToggleBoxMode() |
---|
1323 | 2234 | { |
---|
1324 | 2235 | BOXMODE ^= true; |
---|
1325 | 2236 | } |
---|
1326 | 2237 | |
---|
1327 | | - void ToggleSmoothFocus() |
---|
| 2238 | + public void ToggleZoomBoxMode() |
---|
| 2239 | + { |
---|
| 2240 | + ZOOMBOXMODE ^= true; |
---|
| 2241 | + } |
---|
| 2242 | + |
---|
| 2243 | + public void ToggleSmoothFocus() |
---|
1328 | 2244 | { |
---|
1329 | 2245 | SMOOTHFOCUS ^= true; |
---|
1330 | 2246 | } |
---|
1331 | 2247 | |
---|
1332 | | - void ToggleImageFlip() |
---|
| 2248 | + public void ToggleImageFlip() |
---|
1333 | 2249 | { |
---|
1334 | 2250 | IMAGEFLIP ^= true; |
---|
1335 | 2251 | } |
---|
1336 | 2252 | |
---|
1337 | | - void ToggleSpeakerMocap() |
---|
| 2253 | + public void ToggleSpeakerMocap() |
---|
1338 | 2254 | { |
---|
1339 | 2255 | SPEAKERMOCAP ^= true; |
---|
1340 | 2256 | } |
---|
1341 | 2257 | |
---|
1342 | | - void ToggleSpeakerCamera() |
---|
| 2258 | + public void ToggleSpeakerCamera() |
---|
1343 | 2259 | { |
---|
1344 | 2260 | SPEAKERCAMERA ^= true; |
---|
1345 | 2261 | } |
---|
1346 | 2262 | |
---|
1347 | | - void ToggleSpeakerFocus() |
---|
| 2263 | + public void ToggleSpeakerFocus() |
---|
1348 | 2264 | { |
---|
1349 | 2265 | SPEAKERFOCUS ^= true; |
---|
1350 | 2266 | } |
---|
1351 | 2267 | |
---|
1352 | | - void ToggleDebug() |
---|
1353 | | - { |
---|
1354 | | - DEBUG ^= true; |
---|
1355 | | - } |
---|
1356 | | - |
---|
1357 | | - void ToggleFrustum() |
---|
| 2268 | + public void ToggleFrustum() |
---|
1358 | 2269 | { |
---|
1359 | 2270 | FRUSTUM ^= true; |
---|
1360 | 2271 | } |
---|
1361 | 2272 | |
---|
1362 | | - void ToggleTrack() |
---|
| 2273 | + public void ToggleTrack() |
---|
1363 | 2274 | { |
---|
1364 | 2275 | TRACK ^= true; |
---|
1365 | 2276 | if (TRACK) |
---|
.. | .. |
---|
1378 | 2289 | repaint(); |
---|
1379 | 2290 | } |
---|
1380 | 2291 | |
---|
1381 | | - void ToggleTrackOnce() |
---|
| 2292 | + public void ToggleTrackOnce() |
---|
1382 | 2293 | { |
---|
1383 | 2294 | TRACKONCE ^= true; |
---|
1384 | 2295 | } |
---|
1385 | 2296 | |
---|
1386 | | - void ToggleShadowTrack() |
---|
| 2297 | + public void ToggleShadowTrack() |
---|
1387 | 2298 | { |
---|
1388 | 2299 | SHADOWTRACK ^= true; |
---|
1389 | 2300 | repaint(); |
---|
1390 | 2301 | } |
---|
1391 | 2302 | |
---|
1392 | | - void ToggleOeil() |
---|
| 2303 | + public void ToggleOeil() |
---|
1393 | 2304 | { |
---|
1394 | 2305 | OEIL ^= true; |
---|
1395 | 2306 | } |
---|
1396 | 2307 | |
---|
1397 | | - void ToggleOeilOnce() |
---|
| 2308 | + public void ToggleOeilOnce() |
---|
1398 | 2309 | { |
---|
1399 | 2310 | OEILONCE ^= true; |
---|
| 2311 | + } |
---|
| 2312 | + |
---|
| 2313 | + void ToggleFootContact() |
---|
| 2314 | + { |
---|
| 2315 | + FOOTCONTACT ^= true; |
---|
| 2316 | + } |
---|
| 2317 | + |
---|
| 2318 | + void ToggleDebug() |
---|
| 2319 | + { |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
1400 | 2321 | } |
---|
1401 | 2322 | |
---|
1402 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
1404 | 2325 | LOOKAT ^= true; |
---|
1405 | 2326 | } |
---|
1406 | 2327 | |
---|
1407 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
1408 | 2329 | { |
---|
1409 | | - RANDOM ^= true; |
---|
| 2330 | + SWITCH ^= true; |
---|
1410 | 2331 | } |
---|
1411 | 2332 | |
---|
1412 | 2333 | void ToggleHandles() |
---|
.. | .. |
---|
1414 | 2335 | HANDLES ^= true; |
---|
1415 | 2336 | } |
---|
1416 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
1417 | 2340 | void TogglePaint() |
---|
1418 | 2341 | { |
---|
1419 | 2342 | PAINTMODE ^= true; |
---|
1420 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
1421 | 2349 | } |
---|
1422 | 2350 | |
---|
1423 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1513 | 2441 | { |
---|
1514 | 2442 | return currentGL; |
---|
1515 | 2443 | } |
---|
1516 | | - |
---|
| 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 | + |
---|
1517 | 2460 | /**/ |
---|
1518 | 2461 | class CacheTexture |
---|
1519 | 2462 | { |
---|
.. | .. |
---|
1522 | 2465 | |
---|
1523 | 2466 | int resolution; |
---|
1524 | 2467 | |
---|
1525 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1526 | 2469 | { |
---|
1527 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
1528 | 2472 | resolution = res; |
---|
1529 | 2473 | } |
---|
1530 | 2474 | } |
---|
1531 | 2475 | /**/ |
---|
1532 | 2476 | |
---|
1533 | 2477 | // TEXTURE static Texture texture; |
---|
1534 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
1535 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
1536 | | - 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 | + |
---|
1537 | 2483 | int pigmentdepth = 0; |
---|
1538 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1539 | 2485 | int bumpdepth = 0; |
---|
1540 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1541 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1542 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1543 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1544 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1545 | 2491 | |
---|
1546 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1547 | 2493 | { |
---|
1548 | 2494 | TextureData texturedata = null; |
---|
1549 | 2495 | |
---|
.. | .. |
---|
1562 | 2508 | if (bump) |
---|
1563 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
1564 | 2510 | |
---|
1565 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1566 | | - 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); |
---|
1567 | 2513 | |
---|
1568 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
1569 | | - 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); |
---|
1570 | 2516 | |
---|
1571 | | - 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; |
---|
1572 | 2539 | } |
---|
1573 | 2540 | |
---|
1574 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2641 | 3608 | |
---|
2642 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
2643 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
2644 | 3613 | // |
---|
2645 | 3614 | if (false) // compressbit > 0) |
---|
2646 | 3615 | { |
---|
.. | .. |
---|
3345 | 4314 | |
---|
3346 | 4315 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3347 | 4316 | { |
---|
| 4317 | + new Exception().printStackTrace(); |
---|
3348 | 4318 | System.exit(0); |
---|
3349 | 4319 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3350 | 4320 | |
---|
.. | .. |
---|
7038 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7039 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7040 | 8010 | |
---|
7041 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7042 | 8012 | { |
---|
7043 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7044 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7053 | 8023 | pigment = null; |
---|
7054 | 8024 | } |
---|
7055 | 8025 | |
---|
7056 | | - ReleaseTexture(bump, true); |
---|
7057 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7058 | 8028 | } |
---|
7059 | 8029 | |
---|
7060 | | - 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) |
---|
7061 | 8089 | { |
---|
7062 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7063 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7068 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7069 | 8097 | |
---|
7070 | 8098 | if (tex != null) |
---|
7071 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7072 | 8100 | |
---|
7073 | 8101 | // //assert( texture != null ); |
---|
7074 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
7160 | 8188 | } |
---|
7161 | 8189 | } |
---|
7162 | 8190 | |
---|
7163 | | - /*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 |
---|
7164 | 8240 | { |
---|
7165 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7166 | 8242 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7171 | 8247 | if (tex == null) |
---|
7172 | 8248 | { |
---|
7173 | 8249 | BindTexture(null,false,resolution); |
---|
7174 | | - BindTexture(null,true,resolution); |
---|
7175 | 8250 | return; |
---|
7176 | 8251 | } |
---|
7177 | 8252 | |
---|
7178 | 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 | + |
---|
7179 | 8286 | String bump = Object3D.GetBump(tex); |
---|
7180 | 8287 | |
---|
7181 | | - usedtextures.put(pigment, pigment); |
---|
7182 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
7183 | 8289 | |
---|
7184 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7185 | 8291 | { |
---|
7186 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7187 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7191 | 8297 | { |
---|
7192 | 8298 | bump = null; |
---|
7193 | 8299 | } |
---|
7194 | | - if (pigment.equals("")) |
---|
7195 | | - { |
---|
7196 | | - pigment = null; |
---|
7197 | | - } |
---|
7198 | 8300 | |
---|
7199 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7200 | | - BindTexture(pigment, false, resolution); |
---|
7201 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7202 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
7203 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7204 | | - |
---|
7205 | | - return; // true; |
---|
7206 | 8304 | } |
---|
7207 | 8305 | |
---|
7208 | | - 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) |
---|
7209 | 8309 | { |
---|
7210 | | - 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; |
---|
7211 | 8329 | |
---|
7212 | 8330 | if (tex != null) |
---|
7213 | 8331 | { |
---|
7214 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7215 | 8334 | |
---|
7216 | | - String[] split = tex.split("Textures"); |
---|
7217 | | - if (split.length > 1) |
---|
7218 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
7219 | | - else |
---|
7220 | | - if (!texname.startsWith("/")) |
---|
7221 | | - 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 | + } |
---|
7222 | 8352 | |
---|
7223 | 8353 | if (CACHETEXTURE) |
---|
7224 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7225 | | - |
---|
7226 | | - TextureData texturedata = null; |
---|
7227 | | - |
---|
7228 | | - if (texture == null || texture.resolution < resolution) |
---|
7229 | 8354 | { |
---|
7230 | | - 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("")) |
---|
7231 | 8388 | { |
---|
7232 | 8389 | assert(!bump); |
---|
7233 | 8390 | // if (bump) |
---|
.. | .. |
---|
7238 | 8395 | // } |
---|
7239 | 8396 | // else |
---|
7240 | 8397 | // { |
---|
7241 | | - texture = textures.get(tex); |
---|
7242 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
7243 | 8400 | { |
---|
7244 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7245 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
7246 | 8405 | // } |
---|
7247 | 8406 | } else |
---|
7248 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7249 | 8408 | { |
---|
7250 | 8409 | assert(bump); |
---|
7251 | | - texture = textures.get(tex); |
---|
7252 | | - if (texture == null) |
---|
7253 | | - 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(); |
---|
7254 | 8415 | } else |
---|
7255 | 8416 | { |
---|
7256 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7258 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
7259 | 8420 | //} else |
---|
7260 | 8421 | //{ |
---|
7261 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7262 | 8423 | { |
---|
7263 | | - texture = textures.get(tex); |
---|
7264 | | - if (texture == null) |
---|
7265 | | - 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(); |
---|
7266 | 8429 | } else |
---|
7267 | 8430 | { |
---|
7268 | 8431 | if (textureon) |
---|
.. | .. |
---|
7287 | 8450 | } |
---|
7288 | 8451 | |
---|
7289 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7290 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
7291 | 8454 | cachename = texname; |
---|
7292 | 8455 | else |
---|
7293 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7309 | 8472 | } |
---|
7310 | 8473 | |
---|
7311 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7312 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
7313 | 8476 | cachename = texname; |
---|
7314 | 8477 | else |
---|
7315 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7318 | 8481 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7319 | 8482 | |
---|
7320 | 8483 | |
---|
7321 | | - if (texturedata != null) |
---|
7322 | | - 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); |
---|
7323 | 8488 | //texture = GetTexture(tex, bump); |
---|
7324 | 8489 | } |
---|
7325 | 8490 | } |
---|
7326 | 8491 | //} |
---|
7327 | 8492 | } |
---|
7328 | 8493 | |
---|
7329 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7330 | 8495 | { |
---|
7331 | 8496 | //return false; |
---|
7332 | 8497 | |
---|
7333 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7334 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7335 | 8500 | { |
---|
7336 | 8501 | // String ext = "_highres"; |
---|
7337 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7348 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7349 | 8514 | if (!cachefile.exists()) |
---|
7350 | 8515 | { |
---|
7351 | | - // cache to disk |
---|
7352 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
7353 | | - //buffers[0]. |
---|
7354 | | - |
---|
7355 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
7356 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
7357 | | - |
---|
7358 | | - // squared size heuristic... |
---|
7359 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7360 | 8517 | { |
---|
7361 | | - for (int i=pixels.length; --i>=0;) |
---|
7362 | | - { |
---|
7363 | | - int i3 = i*3; |
---|
7364 | | - pixels[i] = 0xFF; |
---|
7365 | | - pixels[i] <<= 8; |
---|
7366 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
7367 | | - pixels[i] <<= 8; |
---|
7368 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
7369 | | - pixels[i] <<= 8; |
---|
7370 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
7371 | | - } |
---|
7372 | | - |
---|
7373 | | - /* |
---|
7374 | | - int r=0,g=0,b=0,a=0; |
---|
7375 | | - for (int i=0; i<width; i++) |
---|
7376 | | - for (int j=0; j<height; j++) |
---|
7377 | | - { |
---|
7378 | | - int index = j*width+i; |
---|
7379 | | - int p = pixels[index]; |
---|
7380 | | - a = ((p>>24) & 0xFF); |
---|
7381 | | - r = ((p>>16) & 0xFF); |
---|
7382 | | - g = ((p>>8) & 0xFF); |
---|
7383 | | - b = (p & 0xFF); |
---|
7384 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
7385 | | - } |
---|
7386 | | - /**/ |
---|
7387 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
7388 | | - int height = width; |
---|
7389 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
7390 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
7391 | 8520 | ImageWriter writer = null; |
---|
7392 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7393 | 8522 | if (iter.hasNext()) { |
---|
7394 | 8523 | writer = (ImageWriter)iter.next(); |
---|
7395 | 8524 | } |
---|
7396 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
7397 | 8527 | try |
---|
7398 | 8528 | { |
---|
7399 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7410 | 8540 | } |
---|
7411 | 8541 | } |
---|
7412 | 8542 | } |
---|
7413 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
7414 | 8546 | //System.out.println("Texture = " + tex); |
---|
7415 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
7416 | 8548 | { |
---|
7417 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
7418 | 8550 | thetex.texture.disable(); |
---|
7419 | 8551 | thetex.texture.dispose(); |
---|
7420 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
7421 | 8553 | } |
---|
7422 | 8554 | |
---|
7423 | | - texture.texturedata = texturedata; |
---|
7424 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
7425 | 8557 | |
---|
7426 | 8558 | // newtex = true; |
---|
7427 | 8559 | } |
---|
.. | .. |
---|
7437 | 8569 | } |
---|
7438 | 8570 | } |
---|
7439 | 8571 | |
---|
7440 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
7441 | 8573 | } |
---|
7442 | 8574 | |
---|
7443 | | - 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 |
---|
7444 | 8610 | { |
---|
7445 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7446 | 8612 | |
---|
.. | .. |
---|
7458 | 8624 | return texture!=null?texture.texture:null; |
---|
7459 | 8625 | } |
---|
7460 | 8626 | |
---|
7461 | | - 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 |
---|
7462 | 8628 | { |
---|
7463 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7464 | 8630 | |
---|
7465 | 8631 | return texture!=null?texture.texturedata:null; |
---|
7466 | 8632 | } |
---|
7467 | 8633 | |
---|
7468 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7469 | 8635 | { |
---|
7470 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7471 | 8637 | { |
---|
7472 | 8638 | return false; |
---|
7473 | 8639 | } |
---|
7474 | 8640 | |
---|
7475 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
7476 | 8642 | |
---|
7477 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7478 | 8644 | |
---|
.. | .. |
---|
7504 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7505 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7506 | 8672 | |
---|
7507 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
7508 | 8674 | } |
---|
7509 | 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 | + |
---|
7510 | 8742 | ShadowBuffer shadowPBuf; |
---|
7511 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
7512 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
8342 | 9574 | jy8[3] = 0.5f; |
---|
8343 | 9575 | } |
---|
8344 | 9576 | |
---|
8345 | | - 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 |
---|
8346 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8347 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8348 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8349 | 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 | + |
---|
8350 | 9606 | static int imagecount = 0; // movie generation |
---|
8351 | 9607 | |
---|
8352 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
8442 | 9698 | assert (parentcam != renderCamera); |
---|
8443 | 9699 | |
---|
8444 | 9700 | if (renderCamera != lightCamera) |
---|
8445 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8446 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8447 | 9703 | |
---|
8448 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8449 | 9705 | |
---|
.. | .. |
---|
8458 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8459 | 9715 | |
---|
8460 | 9716 | if (renderCamera != lightCamera) |
---|
8461 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8462 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8463 | 9719 | |
---|
8464 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8465 | 9721 | |
---|
.. | .. |
---|
8531 | 9787 | //gl.glFlush(); |
---|
8532 | 9788 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8533 | 9789 | |
---|
8534 | | - if (ANIMATION && ABORTED) |
---|
| 9790 | + if (Globals.ANIMATION && ABORTED) |
---|
8535 | 9791 | { |
---|
8536 | 9792 | System.err.println(" ABORTED FRAME"); |
---|
8537 | 9793 | break; |
---|
.. | .. |
---|
8561 | 9817 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8562 | 9818 | |
---|
8563 | 9819 | // save image |
---|
8564 | | - if (ANIMATION && !ABORTED) |
---|
| 9820 | + if (Globals.ANIMATION && !ABORTED) |
---|
8565 | 9821 | { |
---|
8566 | 9822 | VPwidth = viewport[2]; |
---|
8567 | 9823 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8672 | 9928 | |
---|
8673 | 9929 | // imagecount++; |
---|
8674 | 9930 | |
---|
8675 | | - 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; |
---|
8676 | 9932 | |
---|
8677 | 9933 | if (!BOXMODE) |
---|
8678 | 9934 | { |
---|
8679 | | - 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) + ")"); |
---|
8680 | 9936 | } |
---|
8681 | 9937 | |
---|
8682 | 9938 | if (!BOXMODE) |
---|
.. | .. |
---|
8714 | 9970 | ABORTED = false; |
---|
8715 | 9971 | } |
---|
8716 | 9972 | else |
---|
8717 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9973 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8718 | 9974 | |
---|
8719 | 9975 | if (false) |
---|
8720 | 9976 | { |
---|
.. | .. |
---|
9377 | 10633 | |
---|
9378 | 10634 | public void display(GLAutoDrawable drawable) |
---|
9379 | 10635 | { |
---|
9380 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10636 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9381 | 10637 | { |
---|
9382 | | - GrafreeD.wav.save(); |
---|
9383 | | - GrafreeD.savesound = false; |
---|
9384 | | - GrafreeD.hassound = false; |
---|
| 10638 | + Grafreed.wav.save(); |
---|
| 10639 | + Grafreed.savesound = false; |
---|
| 10640 | + Grafreed.hassound = false; |
---|
9385 | 10641 | } |
---|
9386 | 10642 | // if (DEBUG_SELECTION) |
---|
9387 | 10643 | // { |
---|
.. | .. |
---|
9457 | 10713 | ANTIALIAS = 0; |
---|
9458 | 10714 | //System.out.println("RESTART"); |
---|
9459 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
9460 | 10717 | } |
---|
9461 | 10718 | } |
---|
9462 | 10719 | } |
---|
.. | .. |
---|
9511 | 10768 | Object3D theobject = object; |
---|
9512 | 10769 | Object3D theparent = object.parent; |
---|
9513 | 10770 | object.parent = null; |
---|
9514 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10771 | + object = (Object3D)Grafreed.clone(object); |
---|
9515 | 10772 | object.Stripify(); |
---|
9516 | 10773 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9517 | 10774 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9524 | 10781 | ambientOcclusion = false; |
---|
9525 | 10782 | } |
---|
9526 | 10783 | |
---|
9527 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9528 | 10786 | { |
---|
9529 | 10787 | //if (RENDERSHADOW) // ? |
---|
9530 | 10788 | if (!IsFrozen()) |
---|
9531 | 10789 | { |
---|
9532 | 10790 | // dec 2012 |
---|
9533 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9534 | 10792 | { |
---|
9535 | 10793 | Globals.framecount++; |
---|
9536 | 10794 | shadowbuffer.display(); |
---|
.. | .. |
---|
9657 | 10915 | |
---|
9658 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
9659 | 10917 | if (cam != lightCamera) |
---|
9660 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9661 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9662 | 10920 | |
---|
9663 | 10921 | for (int j = 0; j < 4; j++) |
---|
9664 | 10922 | { |
---|
.. | .. |
---|
9672 | 10930 | |
---|
9673 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
9674 | 10932 | if (cam != lightCamera) |
---|
9675 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9676 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9677 | 10935 | |
---|
9678 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9679 | 10937 | |
---|
.. | .. |
---|
9932 | 11190 | // Bump noise |
---|
9933 | 11191 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9934 | 11192 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9935 | | - 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 | + |
---|
9936 | 11203 | |
---|
9937 | 11204 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9938 | 11205 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9955 | 11222 | |
---|
9956 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9957 | 11224 | |
---|
9958 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9959 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9960 | | -//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); |
---|
9961 | 11228 | } else |
---|
9962 | 11229 | { |
---|
9963 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9968 | 11235 | //System.out.println("BLENDING ON"); |
---|
9969 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
9970 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9971 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9972 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9973 | 11240 | gl.glLoadIdentity(); |
---|
9974 | 11241 | |
---|
.. | .. |
---|
10057 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
10058 | 11325 | |
---|
10059 | 11326 | // if (cam != lightCamera) |
---|
10060 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10061 | | - 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 |
---|
10062 | 11329 | } |
---|
10063 | 11330 | |
---|
10064 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10079 | 11346 | if (true) // TODO |
---|
10080 | 11347 | { |
---|
10081 | 11348 | if (cam != lightCamera) |
---|
10082 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10083 | | - 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 |
---|
10084 | 11351 | } |
---|
10085 | 11352 | |
---|
10086 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10146 | 11413 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10147 | 11414 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10148 | 11415 | |
---|
10149 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11416 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10150 | 11417 | { |
---|
10151 | 11418 | /* |
---|
10152 | 11419 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10217 | 11484 | } |
---|
10218 | 11485 | } |
---|
10219 | 11486 | |
---|
10220 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10221 | 11488 | { |
---|
10222 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10223 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10225 | 11492 | |
---|
10226 | 11493 | boolean texon = textureon; |
---|
10227 | 11494 | |
---|
10228 | | - if (RENDERPROGRAM > 0) |
---|
10229 | | - { |
---|
10230 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10231 | | - textureon = false; |
---|
10232 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
10233 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10234 | 11499 | //System.out.println("ALLO"); |
---|
10235 | 11500 | gl.glColorMask(false, false, false, false); |
---|
10236 | 11501 | DrawObject(gl); |
---|
10237 | | - if (RENDERPROGRAM > 0) |
---|
10238 | | - { |
---|
10239 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10240 | | - textureon = texon; |
---|
10241 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
10242 | 11506 | gl.glColorMask(true, true, true, true); |
---|
10243 | 11507 | |
---|
10244 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10245 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
10246 | 11510 | } |
---|
10247 | 11511 | |
---|
10248 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10396 | 11660 | { |
---|
10397 | 11661 | renderpass++; |
---|
10398 | 11662 | // System.out.println("Draw object... "); |
---|
| 11663 | + STEP = 1; |
---|
10399 | 11664 | if (FAST) // in case there is no script |
---|
10400 | | - STEP = 16; |
---|
| 11665 | + STEP = 8; |
---|
| 11666 | + |
---|
| 11667 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11668 | + { |
---|
| 11669 | + STEP *= 4; |
---|
| 11670 | + } |
---|
10401 | 11671 | |
---|
10402 | 11672 | //object.FullInvariants(); |
---|
10403 | 11673 | |
---|
.. | .. |
---|
10411 | 11681 | e.printStackTrace(); |
---|
10412 | 11682 | } |
---|
10413 | 11683 | |
---|
10414 | | - if (GrafreeD.RENDERME > 0) |
---|
10415 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11684 | + if (Grafreed.RENDERME > 0) |
---|
| 11685 | + Grafreed.RENDERME--; // mechante magouille |
---|
10416 | 11686 | |
---|
10417 | 11687 | Globals.ONESTEP = false; |
---|
10418 | 11688 | } |
---|
10419 | 11689 | |
---|
10420 | 11690 | static boolean zoomonce = false; |
---|
10421 | 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 | + |
---|
10422 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
10423 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
10424 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10425 | 11716 | // DrawMode() = SELECTION; |
---|
10426 | 11717 | //GL gl = getGL(); |
---|
10427 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10428 | 11719 | { |
---|
10429 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10430 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10431 | 11722 | pingthread.StepToTarget(true); // true); |
---|
10432 | 11723 | // zoomonce = false; |
---|
10433 | 11724 | } |
---|
.. | .. |
---|
10447 | 11738 | callist = gl.glGenLists(1); |
---|
10448 | 11739 | } |
---|
10449 | 11740 | |
---|
10450 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11741 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10451 | 11742 | |
---|
10452 | 11743 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10453 | 11744 | |
---|
.. | .. |
---|
10482 | 11773 | |
---|
10483 | 11774 | usedtextures.clear(); |
---|
10484 | 11775 | |
---|
10485 | | - 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 | + } |
---|
10486 | 11784 | } |
---|
10487 | 11785 | //System.out.println("--> " + stackdepth); |
---|
10488 | 11786 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10492 | 11790 | |
---|
10493 | 11791 | if (DrawMode() == DEFAULT) |
---|
10494 | 11792 | { |
---|
10495 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
10496 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
10497 | 11796 | float radius = 0.05f; |
---|
10498 | 11797 | if (selectedpoint.radius != radius) |
---|
10499 | 11798 | { |
---|
.. | .. |
---|
10547 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10548 | 11847 | |
---|
10549 | 11848 | if (CLEANCACHE) |
---|
10550 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10551 | 11850 | { |
---|
10552 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
10553 | 11852 | |
---|
10554 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
10555 | 11854 | |
---|
10556 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
10557 | 11856 | continue; |
---|
10558 | 11857 | |
---|
10559 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
10560 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10561 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10562 | | - textures.get(tex).texture.dispose(); |
---|
10563 | | - 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 | + } |
---|
10564 | 11875 | } |
---|
10565 | 11876 | } |
---|
10566 | 11877 | } |
---|
.. | .. |
---|
10573 | 11884 | if (checker != null && DrawMode() == DEFAULT) |
---|
10574 | 11885 | { |
---|
10575 | 11886 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10576 | | - 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 | + } |
---|
10577 | 11895 | // NEAREST |
---|
10578 | 11896 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10579 | 11897 | DrawChecker(gl); |
---|
.. | .. |
---|
10655 | 11973 | return; |
---|
10656 | 11974 | } |
---|
10657 | 11975 | |
---|
10658 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
10659 | 11977 | |
---|
10660 | 11978 | GL gl = GetGL(); |
---|
10661 | 11979 | |
---|
.. | .. |
---|
10972 | 12290 | //obj.TransformToWorld(light, light); |
---|
10973 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
10974 | 12292 | { |
---|
10975 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10976 | | - 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); |
---|
10977 | 12295 | } |
---|
10978 | 12296 | |
---|
10979 | 12297 | |
---|
.. | .. |
---|
10990 | 12308 | parentcam = cameras[0]; |
---|
10991 | 12309 | } |
---|
10992 | 12310 | |
---|
10993 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10994 | | - 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 |
---|
10995 | 12313 | |
---|
10996 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10997 | 12315 | |
---|
.. | .. |
---|
11605 | 12923 | |
---|
11606 | 12924 | // display shadow only (bump == 0) |
---|
11607 | 12925 | "SUB temp.x, half.x, shadow.x;" + |
---|
11608 | | - "MOV temp.y, -params6.x;" + |
---|
11609 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12926 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12927 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
11610 | 12928 | "SUB temp.y, one.x, temp.z;" + |
---|
11611 | 12929 | "MUL temp.x, temp.x, temp.y;" + |
---|
11612 | 12930 | "KIL temp.x;" + |
---|
.. | .. |
---|
11735 | 13053 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11736 | 13054 | |
---|
11737 | 13055 | "SUB temp.x, one.x, ndotl.x;" + |
---|
11738 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
11739 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13056 | + // Tuning for default skin |
---|
| 13057 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13058 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13059 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11740 | 13060 | "MUL temp.x, temp.x, temp.y;" + |
---|
11741 | 13061 | |
---|
11742 | 13062 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11935 | 13255 | //once = true; |
---|
11936 | 13256 | } |
---|
11937 | 13257 | |
---|
11938 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13258 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11939 | 13259 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11940 | 13260 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11941 | 13261 | |
---|
.. | .. |
---|
12068 | 13388 | |
---|
12069 | 13389 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12070 | 13390 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13391 | + |
---|
| 13392 | + // Compare fragment depth in light space with shadowmap. |
---|
12071 | 13393 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12072 | 13394 | "SGE temp.y, temp.x, zero.x;" + |
---|
12073 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13395 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13396 | + |
---|
| 13397 | + // Reverse comparison |
---|
12074 | 13398 | "SUB temp.x, one.x, temp.x;" + |
---|
12075 | 13399 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12076 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13400 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12077 | 13401 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12078 | 13402 | |
---|
12079 | 13403 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12087 | 13411 | // No shadow for backface |
---|
12088 | 13412 | "DP3 temp.x, normal, lightd;" + |
---|
12089 | 13413 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13414 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13415 | + |
---|
| 13416 | + // No shadow when out of frustrum |
---|
| 13417 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12090 | 13418 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12091 | 13419 | ""; |
---|
12092 | 13420 | } |
---|
.. | .. |
---|
12233 | 13561 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12234 | 13562 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12235 | 13563 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12236 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13564 | + |
---|
| 13565 | + //Object3D.cVector2[] vector2buffer; |
---|
12237 | 13566 | |
---|
12238 | 13567 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12239 | 13568 | // OUT : diff, spec |
---|
.. | .. |
---|
12249 | 13578 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12250 | 13579 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12251 | 13580 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
12252 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
12253 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
12254 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13581 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13582 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13583 | + |
---|
| 13584 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12255 | 13585 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12256 | 13586 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12257 | 13587 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12645 | 13975 | public void mousePressed(MouseEvent e) |
---|
12646 | 13976 | { |
---|
12647 | 13977 | //System.out.println("mousePressed: " + e); |
---|
12648 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13978 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12649 | 13979 | } |
---|
12650 | 13980 | |
---|
12651 | 13981 | static long prevtime = 0; |
---|
.. | .. |
---|
12672 | 14002 | |
---|
12673 | 14003 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12674 | 14004 | |
---|
| 14005 | + if (BUTTONLESSWHEEL) |
---|
12675 | 14006 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12676 | 14007 | { |
---|
12677 | 14008 | return; |
---|
.. | .. |
---|
12680 | 14011 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12681 | 14012 | |
---|
12682 | 14013 | // TIMER |
---|
12683 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14014 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12684 | 14015 | { |
---|
12685 | 14016 | keepboxmode = BOXMODE; |
---|
12686 | 14017 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12720 | 14051 | // mode |= META; |
---|
12721 | 14052 | //} |
---|
12722 | 14053 | |
---|
12723 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12724 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14054 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14055 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12725 | 14056 | anchorX = ax; |
---|
12726 | 14057 | anchorY = ay; |
---|
12727 | 14058 | prevX = px; |
---|
.. | .. |
---|
12755 | 14086 | else |
---|
12756 | 14087 | if (evt.getSource() == AAtimer) |
---|
12757 | 14088 | { |
---|
| 14089 | + Globals.TIMERRUNNING = false; |
---|
12758 | 14090 | if (mouseDown) |
---|
12759 | 14091 | { |
---|
12760 | 14092 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12780 | 14112 | // LIVE = waslive; |
---|
12781 | 14113 | // wasliveok = true; |
---|
12782 | 14114 | // waslive = false; |
---|
| 14115 | + |
---|
| 14116 | + // May 2019 Forget it: |
---|
| 14117 | + if (true) |
---|
| 14118 | + return; |
---|
12783 | 14119 | |
---|
12784 | 14120 | // source == timer |
---|
12785 | 14121 | if (mouseDown) |
---|
.. | .. |
---|
12810 | 14146 | |
---|
12811 | 14147 | // fev 2014??? |
---|
12812 | 14148 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12813 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14149 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12814 | 14150 | pingthread.StepToTarget(true); // true); |
---|
12815 | 14151 | } |
---|
12816 | 14152 | // if (!LIVE) |
---|
.. | .. |
---|
12819 | 14155 | |
---|
12820 | 14156 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12821 | 14157 | |
---|
12822 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14158 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12823 | 14159 | { |
---|
12824 | 14160 | if (!wasliveok) |
---|
12825 | 14161 | return; |
---|
12826 | 14162 | |
---|
12827 | 14163 | AAtimer.restart(); // |
---|
| 14164 | + Globals.TIMERRUNNING = true; |
---|
12828 | 14165 | |
---|
12829 | 14166 | // waslive = LIVE; |
---|
12830 | 14167 | // LIVE = false; |
---|
.. | .. |
---|
12836 | 14173 | // touched = true; // main DL |
---|
12837 | 14174 | if (isRenderer) |
---|
12838 | 14175 | { |
---|
12839 | | - SetMouseMode(modifiers); |
---|
| 14176 | + SetMouseMode(modifiers, modifiersex); |
---|
12840 | 14177 | } |
---|
12841 | 14178 | |
---|
12842 | 14179 | selectX = anchorX = x; |
---|
.. | .. |
---|
12849 | 14186 | clicked = true; |
---|
12850 | 14187 | hold = false; |
---|
12851 | 14188 | |
---|
12852 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14189 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12853 | 14190 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12854 | 14191 | { |
---|
12855 | 14192 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12880 | 14217 | info.camera = renderCamera; |
---|
12881 | 14218 | info.x = x; |
---|
12882 | 14219 | info.y = y; |
---|
12883 | | - info.modifiers = modifiers; |
---|
| 14220 | + info.modifiers = modifiersex; |
---|
12884 | 14221 | editObj = object.doEditClick(info, 0); |
---|
12885 | 14222 | if (!editObj) |
---|
12886 | 14223 | { |
---|
.. | .. |
---|
12897 | 14234 | |
---|
12898 | 14235 | public void mouseDragged(MouseEvent e) |
---|
12899 | 14236 | { |
---|
| 14237 | + Globals.MOUSEDRAGGED = true; |
---|
| 14238 | + |
---|
| 14239 | + //System.out.println("mouseDragged: " + e); |
---|
12900 | 14240 | if (isRenderer) |
---|
12901 | 14241 | movingcamera = true; |
---|
| 14242 | + |
---|
12902 | 14243 | //if (drawing) |
---|
12903 | 14244 | //return; |
---|
12904 | | - //System.out.println("mouseDragged: " + e); |
---|
12905 | 14245 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12906 | 14246 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12907 | 14247 | { |
---|
.. | .. |
---|
12909 | 14249 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12910 | 14250 | } |
---|
12911 | 14251 | else |
---|
12912 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14252 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12913 | 14253 | |
---|
12914 | 14254 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12915 | 14255 | } |
---|
.. | .. |
---|
12921 | 14261 | cVector tmp = new cVector(); |
---|
12922 | 14262 | cVector tmp2 = new cVector(); |
---|
12923 | 14263 | boolean isMoving; |
---|
| 14264 | + |
---|
| 14265 | + public cVector TargetLookAt() |
---|
| 14266 | + { |
---|
| 14267 | + return targetLookAt; |
---|
| 14268 | + } |
---|
12924 | 14269 | |
---|
12925 | 14270 | class PingThread extends Thread |
---|
12926 | 14271 | { |
---|
.. | .. |
---|
13077 | 14422 | |
---|
13078 | 14423 | public void run() |
---|
13079 | 14424 | { |
---|
| 14425 | + new Exception().printStackTrace(); |
---|
13080 | 14426 | System.exit(0); |
---|
13081 | 14427 | for (;;) |
---|
13082 | 14428 | { |
---|
.. | .. |
---|
13140 | 14486 | { |
---|
13141 | 14487 | Globals.lighttouched = true; |
---|
13142 | 14488 | } |
---|
13143 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14489 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13144 | 14490 | } |
---|
13145 | 14491 | //else |
---|
13146 | 14492 | } |
---|
.. | .. |
---|
13154 | 14500 | void GoDown(int mod) |
---|
13155 | 14501 | { |
---|
13156 | 14502 | MODIFIERS |= COMMAND; |
---|
13157 | | - /* |
---|
| 14503 | + /**/ |
---|
13158 | 14504 | if((mod&SHIFT) == SHIFT) |
---|
13159 | 14505 | manipCamera.RotatePosition(0, -speed); |
---|
13160 | 14506 | else |
---|
13161 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13162 | | - */ |
---|
| 14507 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14508 | + /**/ |
---|
13163 | 14509 | if ((mod & SHIFT) == SHIFT) |
---|
13164 | 14510 | { |
---|
13165 | 14511 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13175 | 14521 | void GoUp(int mod) |
---|
13176 | 14522 | { |
---|
13177 | 14523 | MODIFIERS |= COMMAND; |
---|
13178 | | - /* |
---|
| 14524 | + /**/ |
---|
13179 | 14525 | if((mod&SHIFT) == SHIFT) |
---|
13180 | 14526 | manipCamera.RotatePosition(0, speed); |
---|
13181 | 14527 | else |
---|
13182 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13183 | | - */ |
---|
| 14528 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14529 | + /**/ |
---|
13184 | 14530 | if ((mod & SHIFT) == SHIFT) |
---|
13185 | 14531 | { |
---|
13186 | 14532 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13196 | 14542 | void GoLeft(int mod) |
---|
13197 | 14543 | { |
---|
13198 | 14544 | MODIFIERS |= COMMAND; |
---|
13199 | | - /* |
---|
| 14545 | + /**/ |
---|
13200 | 14546 | if((mod&SHIFT) == SHIFT) |
---|
13201 | | - manipCamera.RotatePosition(speed, 0); |
---|
13202 | | - else |
---|
13203 | 14547 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13204 | | - */ |
---|
| 14548 | + else |
---|
| 14549 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14550 | + /**/ |
---|
13205 | 14551 | if ((mod & SHIFT) == SHIFT) |
---|
13206 | 14552 | { |
---|
13207 | 14553 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13217 | 14563 | void GoRight(int mod) |
---|
13218 | 14564 | { |
---|
13219 | 14565 | MODIFIERS |= COMMAND; |
---|
13220 | | - /* |
---|
| 14566 | + /**/ |
---|
13221 | 14567 | if((mod&SHIFT) == SHIFT) |
---|
13222 | | - manipCamera.RotatePosition(-speed, 0); |
---|
13223 | | - else |
---|
13224 | 14568 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13225 | | - */ |
---|
| 14569 | + else |
---|
| 14570 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14571 | + /**/ |
---|
13226 | 14572 | if ((mod & SHIFT) == SHIFT) |
---|
13227 | 14573 | { |
---|
13228 | 14574 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13240 | 14586 | int X, Y; |
---|
13241 | 14587 | boolean SX, SY; |
---|
13242 | 14588 | |
---|
13243 | | - void drag(int x, int y, int modifiers) |
---|
| 14589 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13244 | 14590 | { |
---|
13245 | 14591 | if (IsFrozen()) |
---|
13246 | 14592 | { |
---|
.. | .. |
---|
13249 | 14595 | |
---|
13250 | 14596 | drag = true; // NEW |
---|
13251 | 14597 | |
---|
13252 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14598 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13253 | 14599 | |
---|
13254 | 14600 | X = x; |
---|
13255 | 14601 | Y = y; |
---|
13256 | 14602 | // floating state for animation |
---|
13257 | | - MODIFIERS = modifiers; |
---|
13258 | | - modifiers &= ~1024; |
---|
| 14603 | + MODIFIERS = modifiersex; |
---|
| 14604 | + modifiersex &= ~1024; |
---|
13259 | 14605 | if (false) // modifiers != 0) |
---|
13260 | 14606 | { |
---|
13261 | 14607 | //new Exception().printStackTrace(); |
---|
13262 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14608 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13263 | 14609 | System.out.println("SHIFT = " + SHIFT); |
---|
13264 | 14610 | System.out.println("CONTROL = " + COMMAND); |
---|
13265 | 14611 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13279 | 14625 | info.camera = renderCamera; |
---|
13280 | 14626 | info.x = x; |
---|
13281 | 14627 | info.y = y; |
---|
13282 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14628 | + object.GetWindow().copy |
---|
| 14629 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13283 | 14630 | } else |
---|
13284 | 14631 | { |
---|
13285 | 14632 | if (x < startX) |
---|
.. | .. |
---|
13431 | 14778 | public void mouseMoved(MouseEvent e) |
---|
13432 | 14779 | { |
---|
13433 | 14780 | //System.out.println("mouseMoved: " + e); |
---|
13434 | | - |
---|
13435 | 14781 | if (isRenderer) |
---|
13436 | 14782 | return; |
---|
13437 | 14783 | |
---|
.. | .. |
---|
13444 | 14790 | ci.camera = renderCamera; |
---|
13445 | 14791 | if (!isRenderer) |
---|
13446 | 14792 | { |
---|
13447 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14793 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14794 | + //Object3D copy = editWindow.copy; |
---|
| 14795 | + if (object.doEditClick(ci, 0)) |
---|
13448 | 14796 | { |
---|
13449 | 14797 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13450 | 14798 | } else |
---|
.. | .. |
---|
13456 | 14804 | |
---|
13457 | 14805 | public void mouseReleased(MouseEvent e) |
---|
13458 | 14806 | { |
---|
| 14807 | + Globals.MOUSEDRAGGED = false; |
---|
| 14808 | + |
---|
13459 | 14809 | movingcamera = false; |
---|
| 14810 | + X = 0; // getBounds().width/2; |
---|
| 14811 | + Y = 0; // getBounds().height/2; |
---|
13460 | 14812 | //System.out.println("mouseReleased: " + e); |
---|
13461 | 14813 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13462 | 14814 | } |
---|
.. | .. |
---|
13479 | 14831 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13480 | 14832 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13481 | 14833 | |
---|
13482 | | - if (control || command || IsFrozen()) |
---|
| 14834 | +// No delay if (control || command || IsFrozen()) |
---|
13483 | 14835 | timeout = true; |
---|
13484 | | - else |
---|
| 14836 | +// ?? May 2019 else |
---|
13485 | 14837 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13486 | 14838 | mouseDown = false; |
---|
13487 | 14839 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13591 | 14943 | System.out.println("keyReleased: " + e); |
---|
13592 | 14944 | } |
---|
13593 | 14945 | |
---|
13594 | | - void SetMouseMode(int modifiers) |
---|
| 14946 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13595 | 14947 | { |
---|
13596 | 14948 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13597 | 14949 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13603 | 14955 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13604 | 14956 | // return; |
---|
13605 | 14957 | //System.out.println("SetMode = " + modifiers); |
---|
13606 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14958 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13607 | 14959 | { |
---|
13608 | 14960 | mouseMode |= ZOOM; |
---|
13609 | 14961 | } |
---|
13610 | 14962 | |
---|
13611 | 14963 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13612 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14964 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13613 | 14965 | { |
---|
13614 | 14966 | mouseMode |= VR; // BACKFORTH; |
---|
13615 | 14967 | } |
---|
13616 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14968 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13617 | 14969 | { |
---|
13618 | 14970 | mouseMode |= SELECT; |
---|
13619 | 14971 | } |
---|
13620 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14972 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13621 | 14973 | { |
---|
13622 | 14974 | mouseMode |= SELECT; |
---|
13623 | 14975 | } |
---|
13624 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14976 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13625 | 14977 | { |
---|
13626 | 14978 | mouseMode &= ~VR; |
---|
13627 | 14979 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13650 | 15002 | |
---|
13651 | 15003 | if (isRenderer) // |
---|
13652 | 15004 | { |
---|
13653 | | - SetMouseMode(modifiers); |
---|
| 15005 | + SetMouseMode(0, modifiers); |
---|
13654 | 15006 | } |
---|
13655 | 15007 | |
---|
13656 | | - theRenderer.keyPressed(key); |
---|
| 15008 | + Globals.theRenderer.keyPressed(key); |
---|
13657 | 15009 | } |
---|
13658 | 15010 | |
---|
13659 | 15011 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13665 | 15017 | float SATPOW = 1; // 2; // 0.5f; |
---|
13666 | 15018 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13667 | 15019 | |
---|
13668 | | - void keyPressed(int key) |
---|
| 15020 | + public void keyPressed(int key) |
---|
13669 | 15021 | { |
---|
13670 | 15022 | if (key >= '0' && key <= '5') |
---|
13671 | 15023 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13712 | 15064 | // break; |
---|
13713 | 15065 | case 'T': |
---|
13714 | 15066 | CACHETEXTURE ^= true; |
---|
13715 | | - textures.clear(); |
---|
| 15067 | + texturepigment.clear(); |
---|
| 15068 | + texturebump.clear(); |
---|
13716 | 15069 | // repaint(); |
---|
13717 | 15070 | break; |
---|
13718 | 15071 | case 'Y': |
---|
.. | .. |
---|
13797 | 15150 | case 'E' : COMPACT ^= true; |
---|
13798 | 15151 | repaint(); |
---|
13799 | 15152 | break; |
---|
13800 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15153 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15154 | + //DEBUGHSB ^= true; |
---|
| 15155 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13801 | 15156 | repaint(); |
---|
13802 | 15157 | break; |
---|
13803 | 15158 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13822 | 15177 | RevertCamera(); |
---|
13823 | 15178 | repaint(); |
---|
13824 | 15179 | break; |
---|
13825 | | - case 'L': |
---|
13826 | 15180 | case 'l': |
---|
| 15181 | + //case 'L': |
---|
13827 | 15182 | if (lightMode) |
---|
13828 | 15183 | { |
---|
13829 | 15184 | lightMode = false; |
---|
.. | .. |
---|
13966 | 15321 | case '_': |
---|
13967 | 15322 | kompactbit = 5; |
---|
13968 | 15323 | break; |
---|
13969 | | - case '+': |
---|
13970 | | - kompactbit = 6; |
---|
13971 | | - break; |
---|
| 15324 | +// case '+': |
---|
| 15325 | +// kompactbit = 6; |
---|
| 15326 | +// break; |
---|
13972 | 15327 | case ' ': |
---|
13973 | 15328 | lightMode ^= true; |
---|
13974 | 15329 | Globals.lighttouched = true; |
---|
.. | .. |
---|
13980 | 15335 | case ESC: |
---|
13981 | 15336 | RENDERPROGRAM += 1; |
---|
13982 | 15337 | RENDERPROGRAM %= 3; |
---|
| 15338 | + |
---|
13983 | 15339 | repaint(); |
---|
13984 | 15340 | break; |
---|
13985 | 15341 | case 'Z': |
---|
13986 | 15342 | //RESIZETEXTURE ^= true; |
---|
13987 | 15343 | //break; |
---|
13988 | 15344 | case 'z': |
---|
13989 | | - RENDERSHADOW ^= true; |
---|
| 15345 | + Globals.RENDERSHADOW ^= true; |
---|
13990 | 15346 | Globals.lighttouched = true; |
---|
13991 | 15347 | repaint(); |
---|
13992 | 15348 | break; |
---|
.. | .. |
---|
14019 | 15375 | case DELETE: |
---|
14020 | 15376 | ClearSelection(); |
---|
14021 | 15377 | break; |
---|
14022 | | - /* |
---|
14023 | 15378 | case '+': |
---|
| 15379 | + |
---|
| 15380 | + /* |
---|
14024 | 15381 | //fontsize += 1; |
---|
14025 | 15382 | bbzoom *= 2; |
---|
14026 | 15383 | repaint(); |
---|
.. | .. |
---|
14037 | 15394 | case '=': |
---|
14038 | 15395 | IncDepth(); |
---|
14039 | 15396 | //fontsize += 1; |
---|
14040 | | - object.editWindow.refreshContents(true); |
---|
| 15397 | + object.GetWindow().refreshContents(true); |
---|
14041 | 15398 | maskbit = 6; |
---|
14042 | 15399 | break; |
---|
14043 | 15400 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14044 | 15401 | DecDepth(); |
---|
14045 | 15402 | maskbit = 5; |
---|
14046 | 15403 | //if(fontsize > 1) fontsize -= 1; |
---|
14047 | | - if (object.editWindow == null) |
---|
14048 | | - new Exception().printStackTrace(); |
---|
14049 | | - else |
---|
14050 | | - object.editWindow.refreshContents(true); |
---|
| 15404 | +// if (object.editWindow == null) |
---|
| 15405 | +// new Exception().printStackTrace(); |
---|
| 15406 | +// else |
---|
| 15407 | + object.GetWindow().refreshContents(true); |
---|
14051 | 15408 | break; |
---|
14052 | 15409 | case '{': |
---|
14053 | 15410 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14102 | 15459 | } |
---|
14103 | 15460 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14104 | 15461 | } |
---|
| 15462 | + |
---|
14105 | 15463 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14106 | 15464 | |
---|
14107 | 15465 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14109 | 15467 | //mode = ROTATE; |
---|
14110 | 15468 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14111 | 15469 | { |
---|
14112 | | - SetMouseMode(modifiers); |
---|
| 15470 | + SetMouseMode(0, modifiers); |
---|
14113 | 15471 | } |
---|
14114 | 15472 | } |
---|
14115 | 15473 | |
---|
14116 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15474 | + public void processKeyEvent(KeyEvent e) |
---|
14117 | 15475 | { |
---|
14118 | 15476 | switch (e.getID()) |
---|
14119 | 15477 | { |
---|
.. | .. |
---|
14243 | 15601 | |
---|
14244 | 15602 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14245 | 15603 | { |
---|
14246 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14247 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15604 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15605 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15606 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14248 | 15607 | { |
---|
14249 | 15608 | mouseMoved(e); |
---|
14250 | 15609 | } else |
---|
.. | .. |
---|
14269 | 15628 | } |
---|
14270 | 15629 | */ |
---|
14271 | 15630 | |
---|
14272 | | - object.editWindow.EditSelection(); |
---|
| 15631 | + object.GetWindow().EditSelection(false); |
---|
14273 | 15632 | } |
---|
14274 | 15633 | |
---|
14275 | 15634 | void SelectParent() |
---|
14276 | 15635 | { |
---|
| 15636 | + new Exception().printStackTrace(); |
---|
14277 | 15637 | System.exit(0); |
---|
14278 | 15638 | Composite group = (Composite) object; |
---|
14279 | 15639 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14285 | 15645 | { |
---|
14286 | 15646 | //selectees.remove(i); |
---|
14287 | 15647 | System.out.println("select parent of " + elem); |
---|
14288 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15648 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14289 | 15649 | } else |
---|
14290 | 15650 | { |
---|
14291 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15651 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14292 | 15652 | } |
---|
14293 | 15653 | |
---|
14294 | 15654 | first = false; |
---|
.. | .. |
---|
14297 | 15657 | |
---|
14298 | 15658 | void SelectChildren() |
---|
14299 | 15659 | { |
---|
| 15660 | + new Exception().printStackTrace(); |
---|
14300 | 15661 | System.exit(0); |
---|
14301 | 15662 | /* |
---|
14302 | 15663 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14329 | 15690 | for (int j = 0; j < group.children.size(); j++) |
---|
14330 | 15691 | { |
---|
14331 | 15692 | elem = (Object3D) group.children.elementAt(j); |
---|
14332 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15693 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14333 | 15694 | first = false; |
---|
14334 | 15695 | } |
---|
14335 | 15696 | } else |
---|
14336 | 15697 | { |
---|
14337 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15698 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14338 | 15699 | } |
---|
14339 | 15700 | |
---|
14340 | 15701 | first = false; |
---|
.. | .. |
---|
14345 | 15706 | { |
---|
14346 | 15707 | //Composite group = (Composite) object; |
---|
14347 | 15708 | Object3D group = object; |
---|
14348 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15709 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14349 | 15710 | } |
---|
14350 | 15711 | |
---|
14351 | 15712 | void ResetTransform(int mask) |
---|
14352 | 15713 | { |
---|
14353 | 15714 | //Composite group = (Composite) object; |
---|
14354 | 15715 | Object3D group = object; |
---|
14355 | | - group.editWindow.ResetTransform(mask); |
---|
| 15716 | + group.GetWindow().ResetTransform(mask); |
---|
14356 | 15717 | } |
---|
14357 | 15718 | |
---|
14358 | 15719 | void FlipTransform() |
---|
14359 | 15720 | { |
---|
14360 | 15721 | //Composite group = (Composite) object; |
---|
14361 | 15722 | Object3D group = object; |
---|
14362 | | - group.editWindow.FlipTransform(); |
---|
| 15723 | + group.GetWindow().FlipTransform(); |
---|
14363 | 15724 | // group.editWindow.ReduceMesh(true); |
---|
14364 | 15725 | } |
---|
14365 | 15726 | |
---|
.. | .. |
---|
14367 | 15728 | { |
---|
14368 | 15729 | //Composite group = (Composite) object; |
---|
14369 | 15730 | Object3D group = object; |
---|
14370 | | - group.editWindow.PrintMemory(); |
---|
| 15731 | + group.GetWindow().PrintMemory(); |
---|
14371 | 15732 | // group.editWindow.ReduceMesh(true); |
---|
14372 | 15733 | } |
---|
14373 | 15734 | |
---|
.. | .. |
---|
14375 | 15736 | { |
---|
14376 | 15737 | //Composite group = (Composite) object; |
---|
14377 | 15738 | Object3D group = object; |
---|
14378 | | - group.editWindow.ResetCentroid(); |
---|
| 15739 | + group.GetWindow().ResetCentroid(); |
---|
14379 | 15740 | } |
---|
14380 | 15741 | |
---|
14381 | 15742 | void IncDepth() |
---|
.. | .. |
---|
14461 | 15822 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14462 | 15823 | //Image img = CreateImage(width, height); |
---|
14463 | 15824 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15825 | + |
---|
14464 | 15826 | Graphics gr = g; // img.getGraphics(); |
---|
| 15827 | + |
---|
14465 | 15828 | if (!hasMarquee) |
---|
14466 | 15829 | { |
---|
14467 | 15830 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14549 | 15912 | info.bounds.y += (height - desired) / 2; |
---|
14550 | 15913 | } |
---|
14551 | 15914 | } |
---|
| 15915 | + |
---|
14552 | 15916 | info.g = gr; |
---|
14553 | 15917 | info.camera = renderCamera; |
---|
14554 | 15918 | /* |
---|
.. | .. |
---|
14558 | 15922 | */ |
---|
14559 | 15923 | if (!isRenderer) |
---|
14560 | 15924 | { |
---|
14561 | | - object.drawEditHandles(info, 0); |
---|
| 15925 | + Grafreed.Assert(object != null); |
---|
| 15926 | + Grafreed.Assert(object.selection != null); |
---|
| 15927 | + if (object.selection.Size() > 0) |
---|
| 15928 | + { |
---|
| 15929 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15930 | + |
---|
| 15931 | + info.DX = 0; |
---|
| 15932 | + info.DY = 0; |
---|
| 15933 | + info.W = 1; |
---|
| 15934 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15935 | + { |
---|
| 15936 | + info.DX = X; |
---|
| 15937 | + if (X != 0) |
---|
| 15938 | + info.DX -= info.bounds.width/2; |
---|
| 15939 | + |
---|
| 15940 | + info.DY = Y; |
---|
| 15941 | + if (Y != 0) |
---|
| 15942 | + info.DY -= info.bounds.height/2; |
---|
| 15943 | + } |
---|
| 15944 | + |
---|
| 15945 | + object.drawEditHandles(info, 0); |
---|
| 15946 | + |
---|
| 15947 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15948 | + { |
---|
| 15949 | + switch (hitSomething) |
---|
| 15950 | + { |
---|
| 15951 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15952 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15953 | + break; |
---|
| 15954 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15955 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15956 | + break; |
---|
| 15957 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15958 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15959 | + break; |
---|
| 15960 | + } |
---|
| 15961 | + |
---|
| 15962 | + } |
---|
| 15963 | + } |
---|
14562 | 15964 | } |
---|
14563 | 15965 | } |
---|
| 15966 | + |
---|
14564 | 15967 | if (isRenderer) |
---|
14565 | 15968 | { |
---|
14566 | 15969 | //gr.setColor(Color.black); |
---|
14567 | 15970 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14568 | 15971 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14569 | 15972 | } |
---|
| 15973 | + |
---|
14570 | 15974 | if (hasMarquee) |
---|
14571 | 15975 | { |
---|
14572 | 15976 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
14679 | 16083 | public boolean mouseDown(Event evt, int x, int y) |
---|
14680 | 16084 | { |
---|
14681 | 16085 | System.out.println("mouseDown: " + evt); |
---|
| 16086 | + System.exit(0); |
---|
14682 | 16087 | /* |
---|
14683 | 16088 | locked = true; |
---|
14684 | 16089 | drag = false; |
---|
.. | .. |
---|
14722 | 16127 | { |
---|
14723 | 16128 | keyPressed(0, modifiers); |
---|
14724 | 16129 | } |
---|
14725 | | - clickStart(x, y, modifiers); |
---|
| 16130 | + // clickStart(x, y, modifiers); |
---|
14726 | 16131 | return true; |
---|
14727 | 16132 | } |
---|
14728 | 16133 | |
---|
.. | .. |
---|
14840 | 16245 | { |
---|
14841 | 16246 | keyReleased(0, 0); |
---|
14842 | 16247 | } |
---|
14843 | | - drag(x, y, modifiers); |
---|
| 16248 | + drag(x, y, 0, modifiers); |
---|
14844 | 16249 | return true; |
---|
14845 | 16250 | } |
---|
14846 | 16251 | |
---|
.. | .. |
---|
14972 | 16377 | Object3D object; |
---|
14973 | 16378 | static Object3D trackedobject; |
---|
14974 | 16379 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14975 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16380 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14976 | 16381 | /*static*/ Camera eyeCamera; |
---|
14977 | 16382 | /*static*/ Camera lightCamera; |
---|
14978 | 16383 | int cameracount; |
---|
.. | .. |
---|
15257 | 16662 | cStatic.objectstack[materialdepth++] = checker; |
---|
15258 | 16663 | //System.out.println("material " + material); |
---|
15259 | 16664 | //Applet3D.tracein(this, selected); |
---|
15260 | | - vector2buffer = checker.projectedVertices; |
---|
| 16665 | + //vector2buffer = checker.projectedVertices; |
---|
15261 | 16666 | |
---|
15262 | 16667 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15263 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16668 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15264 | 16669 | |
---|
15265 | 16670 | materialdepth -= 1; |
---|
15266 | 16671 | if (materialdepth > 0) |
---|
15267 | 16672 | { |
---|
15268 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15269 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16673 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16674 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15270 | 16675 | } |
---|
15271 | 16676 | //checker.GetMaterial().opacity = 1f; |
---|
15272 | 16677 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15352 | 16757 | } |
---|
15353 | 16758 | } |
---|
15354 | 16759 | |
---|
| 16760 | + private Object3D GetFolder() |
---|
| 16761 | + { |
---|
| 16762 | + Object3D folder = object.GetWindow().copy; |
---|
| 16763 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16764 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16765 | + return folder; |
---|
| 16766 | + } |
---|
| 16767 | + |
---|
15355 | 16768 | class SelectBuffer implements GLEventListener |
---|
15356 | 16769 | { |
---|
15357 | 16770 | |
---|
.. | .. |
---|
15410 | 16823 | { |
---|
15411 | 16824 | if (!selection) |
---|
15412 | 16825 | { |
---|
| 16826 | + new Exception().printStackTrace(); |
---|
15413 | 16827 | System.exit(0); |
---|
15414 | 16828 | return; |
---|
15415 | 16829 | } |
---|
.. | .. |
---|
15430 | 16844 | |
---|
15431 | 16845 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15432 | 16846 | |
---|
| 16847 | + if (PAINTMODE) |
---|
| 16848 | + { |
---|
| 16849 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16850 | + { |
---|
| 16851 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16852 | + |
---|
| 16853 | + // Make what you paint not selectable. |
---|
| 16854 | + paintobj.ResetSelectable(); |
---|
| 16855 | + } |
---|
| 16856 | + } |
---|
| 16857 | + |
---|
15433 | 16858 | //int tmp = selection_view; |
---|
15434 | 16859 | //selection_view = -1; |
---|
15435 | 16860 | int temp = DrawMode(); |
---|
.. | .. |
---|
15441 | 16866 | // temp = DEFAULT; // patch for selection debug |
---|
15442 | 16867 | Globals.drawMode = temp; // WARNING |
---|
15443 | 16868 | |
---|
| 16869 | + if (PAINTMODE) |
---|
| 16870 | + { |
---|
| 16871 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16872 | + { |
---|
| 16873 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16874 | + |
---|
| 16875 | + // Revert. |
---|
| 16876 | + paintobj.RestoreSelectable(); |
---|
| 16877 | + } |
---|
| 16878 | + } |
---|
| 16879 | + |
---|
15444 | 16880 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15445 | 16881 | |
---|
15446 | 16882 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15488 | 16924 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15489 | 16925 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15490 | 16926 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16927 | + |
---|
| 16928 | + CreateSelectedPoint(); |
---|
15491 | 16929 | |
---|
15492 | 16930 | // Will fit the mesh !!! |
---|
15493 | 16931 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15537 | 16975 | 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])); |
---|
15538 | 16976 | } |
---|
15539 | 16977 | |
---|
15540 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16978 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15541 | 16979 | } |
---|
15542 | 16980 | } |
---|
15543 | 16981 | |
---|
15544 | 16982 | if (!movingcamera && !PAINTMODE) |
---|
15545 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16983 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15546 | 16984 | |
---|
15547 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16985 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15548 | 16986 | { |
---|
15549 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16987 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15550 | 16988 | |
---|
15551 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16989 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16990 | + { |
---|
| 16991 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15552 | 16992 | |
---|
15553 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
15554 | | - |
---|
15555 | | - group.add(paintobj); // link |
---|
15556 | | - |
---|
15557 | | - object.editWindow.SnapObject(group); |
---|
15558 | | - |
---|
15559 | | - Object3D folder = object.editWindow.copy; |
---|
15560 | | - |
---|
15561 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
15562 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
15563 | | - |
---|
15564 | | - folder.add(group); |
---|
15565 | | - |
---|
15566 | | - object.editWindow.ResetModel(); |
---|
15567 | | - object.editWindow.refreshContents(); |
---|
| 16993 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16994 | + |
---|
| 16995 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16996 | + |
---|
| 16997 | + inst.add(paintobj); // link |
---|
| 16998 | + |
---|
| 16999 | + object.GetWindow().SnapObject(inst); |
---|
| 17000 | + |
---|
| 17001 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17002 | + |
---|
| 17003 | + folder.add(inst); |
---|
| 17004 | + |
---|
| 17005 | + object.GetWindow().ResetModel(); |
---|
| 17006 | + object.GetWindow().refreshContents(); |
---|
| 17007 | + } |
---|
15568 | 17008 | } |
---|
15569 | 17009 | else |
---|
15570 | 17010 | paintcount = 0; |
---|
.. | .. |
---|
15603 | 17043 | //System.out.println("objects[color] = " + objects[color]); |
---|
15604 | 17044 | //objects[color].Select(); |
---|
15605 | 17045 | indexcount = 0; |
---|
| 17046 | + ObjEditor window = object.GetWindow(); |
---|
| 17047 | + if (window != null && deselect) |
---|
| 17048 | + { |
---|
| 17049 | + window.Select(null, deselect, true); |
---|
| 17050 | + } |
---|
15606 | 17051 | object.Select(color, deselect); |
---|
15607 | 17052 | } |
---|
15608 | 17053 | |
---|
.. | .. |
---|
15702 | 17147 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15703 | 17148 | } |
---|
15704 | 17149 | |
---|
15705 | | - if (!RENDERSHADOW) |
---|
| 17150 | + if (!Globals.RENDERSHADOW) |
---|
15706 | 17151 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15707 | 17152 | |
---|
15708 | 17153 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15712 | 17157 | //gl.glColorMask(false, false, false, false); |
---|
15713 | 17158 | |
---|
15714 | 17159 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15715 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17160 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15716 | 17161 | { |
---|
15717 | 17162 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15718 | 17163 | |
---|
.. | .. |
---|
15772 | 17217 | |
---|
15773 | 17218 | class AntialiasBuffer implements GLEventListener |
---|
15774 | 17219 | { |
---|
15775 | | - |
---|
15776 | 17220 | CameraPane parent = null; |
---|
15777 | 17221 | |
---|
15778 | 17222 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16129 | 17573 | int AAbuffersize = 0; |
---|
16130 | 17574 | |
---|
16131 | 17575 | //double[] selectedpoint = new double[3]; |
---|
16132 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17576 | + static Superellipsoid selectedpoint; |
---|
16133 | 17577 | static Sphere previousselectedpoint = null; |
---|
16134 | | - static Sphere debugpointG = new Sphere(); |
---|
16135 | | - static Sphere debugpointP = new Sphere(); |
---|
16136 | | - static Sphere debugpointC = new Sphere(); |
---|
16137 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17578 | + static Sphere debugpointG; |
---|
| 17579 | + static Sphere debugpointP; |
---|
| 17580 | + static Sphere debugpointC; |
---|
| 17581 | + static Sphere debugpointR; |
---|
16138 | 17582 | |
---|
16139 | 17583 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16140 | 17584 | |
---|
16141 | | - static |
---|
16142 | | - { |
---|
16143 | | - for (int i=0; i<8; i++) |
---|
16144 | | - { |
---|
16145 | | - debugpoints[i] = new Sphere(); |
---|
16146 | | - } |
---|
16147 | | - } |
---|
16148 | | - |
---|
16149 | 17585 | static void InitPoints(float radius) |
---|
16150 | 17586 | { |
---|
16151 | 17587 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16165 | 17601 | } |
---|
16166 | 17602 | } |
---|
16167 | 17603 | |
---|
16168 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17604 | + static void DrawPoints(iCameraPane cpane) |
---|
16169 | 17605 | { |
---|
16170 | 17606 | for (int i=0; i<8; i++) // first and last are red |
---|
16171 | 17607 | { |
---|
.. | .. |
---|
16197 | 17633 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16198 | 17634 | // Depth buffer format |
---|
16199 | 17635 | //private int depth_format; |
---|
16200 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17636 | + |
---|
| 17637 | + public void NextIndex() |
---|
16201 | 17638 | { |
---|
16202 | 17639 | indexcount+=16; |
---|
16203 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17640 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16204 | 17641 | //objects[indexcount] = o; |
---|
16205 | 17642 | //System.out.println("indexcount = " + indexcount); |
---|
16206 | 17643 | } |
---|