.. | .. |
---|
37 | 37 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 38 | static int materialdepth = 0; |
---|
39 | 39 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 40 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 41 | |
---|
43 | 42 | // camera change fix |
---|
.. | .. |
---|
45 | 44 | static boolean ABORTED = false; |
---|
46 | 45 | |
---|
47 | 46 | static int STEP = 1; |
---|
| 47 | + |
---|
| 48 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 49 | + { |
---|
| 50 | + int[] pixels = new int[bytes.length/3]; |
---|
| 51 | + for (int i=pixels.length; --i>=0;) |
---|
| 52 | + { |
---|
| 53 | + int i3 = i*3; |
---|
| 54 | + pixels[i] = 0xFF; |
---|
| 55 | + pixels[i] <<= 8; |
---|
| 56 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 57 | + pixels[i] <<= 8; |
---|
| 58 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 61 | + } |
---|
| 62 | + /* |
---|
| 63 | + int r=0,g=0,b=0,a=0; |
---|
| 64 | + for (int i=0; i<width; i++) |
---|
| 65 | + for (int j=0; j<height; j++) |
---|
| 66 | + { |
---|
| 67 | + int index = j*width+i; |
---|
| 68 | + int p = pixels[index]; |
---|
| 69 | + a = ((p>>24) & 0xFF); |
---|
| 70 | + r = ((p>>16) & 0xFF); |
---|
| 71 | + g = ((p>>8) & 0xFF); |
---|
| 72 | + b = (p & 0xFF); |
---|
| 73 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 74 | + } |
---|
| 75 | + /**/ |
---|
| 76 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 77 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 78 | + return rendImage; |
---|
| 79 | + } |
---|
48 | 80 | |
---|
49 | 81 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 82 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
56 | 88 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 89 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 90 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 91 | |
---|
62 | 92 | boolean DISPLAYTEXT = false; |
---|
63 | 93 | //boolean REDUCETEXTURE = true; |
---|
64 | 94 | boolean CACHETEXTURE = true; |
---|
65 | 95 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 96 | + boolean MIPMAP = true; // false; // true; |
---|
67 | 97 | boolean COMPRESSTEXTURE = false; |
---|
68 | 98 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 99 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
92 | 122 | |
---|
93 | 123 | static int tickcount = 0; // slow pose issue |
---|
94 | 124 | |
---|
| 125 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 126 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 127 | static boolean BOXMODE = false; |
---|
96 | 128 | static boolean IMAGEFLIP = false; |
---|
97 | 129 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 138 | static boolean OEIL = true; |
---|
107 | 139 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 140 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 141 | +static boolean SWITCH = true; // false; |
---|
110 | 142 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 143 | static boolean PAINTMODE = false; |
---|
112 | 144 | |
---|
.. | .. |
---|
149 | 181 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 182 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 183 | } |
---|
152 | | - static CameraPane theRenderer; |
---|
153 | | - |
---|
| 184 | + |
---|
| 185 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 186 | + |
---|
154 | 187 | void SetAsGLRenderer(boolean b) |
---|
155 | 188 | { |
---|
156 | 189 | isRenderer = b; |
---|
157 | | - theRenderer = this; |
---|
| 190 | + Globals.theRenderer = this; |
---|
158 | 191 | } |
---|
159 | 192 | |
---|
160 | 193 | CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
.. | .. |
---|
191 | 224 | } |
---|
192 | 225 | |
---|
193 | 226 | /// INTERFACE |
---|
| 227 | + |
---|
| 228 | + public javax.media.opengl.GL GetGL0() |
---|
| 229 | + { |
---|
| 230 | + return null; |
---|
| 231 | + } |
---|
| 232 | + |
---|
| 233 | + public int GenList() |
---|
| 234 | + { |
---|
| 235 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 236 | + return gl.glGenLists(1); |
---|
| 237 | + } |
---|
| 238 | + |
---|
| 239 | + public void NewList(int id) |
---|
| 240 | + { |
---|
| 241 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 242 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 243 | + } |
---|
| 244 | + |
---|
| 245 | + public void CallList(int id) |
---|
| 246 | + { |
---|
| 247 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 248 | + gl.glCallList(id); |
---|
| 249 | + } |
---|
| 250 | + |
---|
| 251 | + public void EndList() |
---|
| 252 | + { |
---|
| 253 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 254 | + gl.glEndList(); |
---|
| 255 | + } |
---|
| 256 | + |
---|
| 257 | + public boolean IsBoxMode() |
---|
| 258 | + { |
---|
| 259 | + return BOXMODE; |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public boolean IsZoomBoxMode() |
---|
| 263 | + { |
---|
| 264 | + return ZOOMBOXMODE; |
---|
| 265 | + } |
---|
194 | 266 | |
---|
195 | 267 | public void ClearDepth() |
---|
196 | 268 | { |
---|
.. | .. |
---|
231 | 303 | return this.ambientOcclusion; |
---|
232 | 304 | } |
---|
233 | 305 | |
---|
| 306 | + public boolean IsDebugSelection() |
---|
| 307 | + { |
---|
| 308 | + return DEBUG_SELECTION; |
---|
| 309 | + } |
---|
| 310 | + |
---|
234 | 311 | public boolean IsFrozen() |
---|
235 | 312 | { |
---|
236 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 313 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
237 | 314 | |
---|
238 | 315 | return !selectmode && cameracount == 0; // != 0; |
---|
239 | 316 | } |
---|
.. | .. |
---|
254 | 331 | return lightCamera; |
---|
255 | 332 | } |
---|
256 | 333 | |
---|
| 334 | + public Camera ManipCamera() |
---|
| 335 | + { |
---|
| 336 | + return manipCamera; |
---|
| 337 | + } |
---|
| 338 | + |
---|
257 | 339 | public Camera RenderCamera() |
---|
258 | 340 | { |
---|
259 | 341 | return renderCamera; |
---|
| 342 | + } |
---|
| 343 | + |
---|
| 344 | + public Camera[] Cameras() |
---|
| 345 | + { |
---|
| 346 | + return cameras; |
---|
260 | 347 | } |
---|
261 | 348 | |
---|
262 | 349 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
272 | 359 | cStatic.objectstack[materialdepth++] = obj; |
---|
273 | 360 | //System.out.println("material " + material); |
---|
274 | 361 | //Applet3D.tracein(this, selected); |
---|
275 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 362 | + //display.vector2buffer = obj.projectedVertices; |
---|
276 | 363 | if (obj instanceof Camera) |
---|
277 | 364 | { |
---|
278 | 365 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
281 | 368 | display.options1[2] = material.shadowbias; |
---|
282 | 369 | display.options1[3] = material.aniso; |
---|
283 | 370 | display.options1[4] = material.anisoV; |
---|
| 371 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 372 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 373 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 374 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 375 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
284 | 376 | display.options2[0] = material.opacity; |
---|
285 | 377 | display.options2[1] = material.diffuse; |
---|
286 | 378 | display.options2[2] = material.factor; |
---|
| 379 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 380 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 381 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
287 | 382 | |
---|
288 | 383 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 384 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 385 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 386 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
289 | 387 | display.options4[0] = material.cameralight/0.2f; |
---|
290 | 388 | display.options4[1] = material.subsurface; |
---|
291 | 389 | display.options4[2] = material.sheen; |
---|
| 390 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 391 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 392 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
292 | 393 | |
---|
293 | 394 | // if (display.CURRENTANTIALIAS > 0) |
---|
294 | 395 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
304 | 405 | /**/ |
---|
305 | 406 | } else |
---|
306 | 407 | { |
---|
307 | | - DrawMaterial(material, selected); |
---|
| 408 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
308 | 409 | } |
---|
309 | 410 | } else |
---|
310 | 411 | { |
---|
.. | .. |
---|
328 | 429 | cStatic.objectstack[materialdepth++] = obj; |
---|
329 | 430 | //System.out.println("material " + material); |
---|
330 | 431 | //Applet3D.tracein("selected ", selected); |
---|
331 | | - display.vector2buffer = obj.projectedVertices; |
---|
332 | | - display.DrawMaterial(material, selected); |
---|
| 432 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 433 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
333 | 434 | } |
---|
334 | 435 | } |
---|
335 | 436 | |
---|
.. | .. |
---|
346 | 447 | materialdepth -= 1; |
---|
347 | 448 | if (materialdepth > 0) |
---|
348 | 449 | { |
---|
349 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
350 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 450 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 451 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
351 | 452 | } |
---|
352 | 453 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
353 | 454 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
367 | 468 | materialdepth -= 1; |
---|
368 | 469 | if (materialdepth > 0) |
---|
369 | 470 | { |
---|
370 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
371 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 471 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 472 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
372 | 473 | } |
---|
373 | 474 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
374 | 475 | //else |
---|
.. | .. |
---|
403 | 504 | |
---|
404 | 505 | javax.media.opengl.GL gl = display.GetGL(); |
---|
405 | 506 | |
---|
406 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 507 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
407 | 508 | |
---|
408 | 509 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
409 | 510 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
410 | 511 | { |
---|
411 | 512 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
412 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 513 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 514 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 515 | + ; |
---|
413 | 516 | if (!hasnorm) |
---|
414 | 517 | { |
---|
415 | | - // System.out.println("FUCK!!"); |
---|
| 518 | + // System.out.println("Mesh normal"); |
---|
416 | 519 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
417 | 520 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
418 | 521 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
566 | 669 | } |
---|
567 | 670 | } |
---|
568 | 671 | |
---|
| 672 | + /** |
---|
| 673 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 674 | + * it's normals, colors, textures and vertices. |
---|
| 675 | + * |
---|
| 676 | + * @see Renderer#draw(TriMesh) |
---|
| 677 | + * @param tris |
---|
| 678 | + * the mesh to render. |
---|
| 679 | + */ |
---|
| 680 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 681 | + { |
---|
| 682 | + CameraPane display = this; |
---|
| 683 | + |
---|
| 684 | + float r = display.modelParams0[0]; |
---|
| 685 | + float g = display.modelParams0[1]; |
---|
| 686 | + float b = display.modelParams0[2]; |
---|
| 687 | + float opacity = display.modelParams5[1]; |
---|
| 688 | + |
---|
| 689 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 690 | + GL gl = display.GetGL(); // getGL(); |
---|
| 691 | + |
---|
| 692 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 693 | + |
---|
| 694 | + int v = vertBuf.capacity(); |
---|
| 695 | + |
---|
| 696 | + int count = 0; |
---|
| 697 | + |
---|
| 698 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 699 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 700 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 701 | + for (int i=0; i<v/3; i++) |
---|
| 702 | + { |
---|
| 703 | + int index3 = i*3; |
---|
| 704 | + |
---|
| 705 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 706 | + continue; |
---|
| 707 | + |
---|
| 708 | + count++; |
---|
| 709 | + |
---|
| 710 | + int index4 = i*4; |
---|
| 711 | + |
---|
| 712 | + float tx = vertBuf.get(index3); |
---|
| 713 | + float ty = vertBuf.get(index3+1); |
---|
| 714 | + float tz = vertBuf.get(index3+2); |
---|
| 715 | + |
---|
| 716 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 717 | + // continue; |
---|
| 718 | + |
---|
| 719 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 720 | + gl.glPushMatrix(); |
---|
| 721 | + |
---|
| 722 | + float[] texmat = geo.texmat; |
---|
| 723 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 724 | + |
---|
| 725 | + gl.glMultMatrixf(texmat, 0); |
---|
| 726 | + |
---|
| 727 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 728 | + gl.glPushMatrix(); |
---|
| 729 | + |
---|
| 730 | + gl.glTranslatef(tx,ty,tz); |
---|
| 731 | + |
---|
| 732 | + if (rotate) |
---|
| 733 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 734 | + |
---|
| 735 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 736 | + gl.glScalef(size,size,size); |
---|
| 737 | + |
---|
| 738 | + float cr = geo.colorBuf.get(index4); |
---|
| 739 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 740 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 741 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 742 | + |
---|
| 743 | + display.modelParams0[0] = r * cr; |
---|
| 744 | + display.modelParams0[1] = g * cg; |
---|
| 745 | + display.modelParams0[2] = b * cb; |
---|
| 746 | + |
---|
| 747 | + display.modelParams5[1] = opacity * ca; |
---|
| 748 | + |
---|
| 749 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 750 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 751 | + |
---|
| 752 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 753 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 754 | + |
---|
| 755 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 756 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 757 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 758 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 759 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 760 | + gl.glPopMatrix(); |
---|
| 761 | + |
---|
| 762 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 763 | + gl.glPopMatrix(); |
---|
| 764 | + } |
---|
| 765 | + // gl.glScalef(1024,1024,1024); |
---|
| 766 | + if (!cf) |
---|
| 767 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 768 | + |
---|
| 769 | + display.modelParams0[0] = r; |
---|
| 770 | + display.modelParams0[1] = g; |
---|
| 771 | + display.modelParams0[2] = b; |
---|
| 772 | + |
---|
| 773 | + display.modelParams5[1] = opacity; |
---|
| 774 | + |
---|
| 775 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 776 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 777 | + |
---|
| 778 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 779 | + |
---|
| 780 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 781 | + if (true) |
---|
| 782 | + return; |
---|
| 783 | + |
---|
| 784 | +//// if (!tris.predraw(this)) |
---|
| 785 | +//// { |
---|
| 786 | +//// return; |
---|
| 787 | +//// } |
---|
| 788 | +//// if (Debug.stats) |
---|
| 789 | +//// { |
---|
| 790 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 791 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 792 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 793 | +//// } |
---|
| 794 | +//// |
---|
| 795 | +//// if (tris.getDisplayListID() != -1) |
---|
| 796 | +//// { |
---|
| 797 | +//// renderDisplayList(tris); |
---|
| 798 | +//// return; |
---|
| 799 | +//// } |
---|
| 800 | +//// |
---|
| 801 | +//// if (!generatingDisplayList) |
---|
| 802 | +//// { |
---|
| 803 | +//// applyStates(tris.states, tris); |
---|
| 804 | +//// } |
---|
| 805 | +//// if (Debug.stats) |
---|
| 806 | +//// { |
---|
| 807 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 808 | +//// } |
---|
| 809 | +//// boolean transformed = doTransforms(tris); |
---|
| 810 | +// |
---|
| 811 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 812 | +// switch (getMode()) |
---|
| 813 | +// { |
---|
| 814 | +// case Triangles: |
---|
| 815 | +// glMode = GL.GL_TRIANGLES; |
---|
| 816 | +// break; |
---|
| 817 | +// case Strip: |
---|
| 818 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 819 | +// break; |
---|
| 820 | +// case Fan: |
---|
| 821 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 822 | +// break; |
---|
| 823 | +// } |
---|
| 824 | +// |
---|
| 825 | +// if (!predrawGeometry(gl)) |
---|
| 826 | +// { |
---|
| 827 | +// // make sure only the necessary indices are sent through on old |
---|
| 828 | +// // cards. |
---|
| 829 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 830 | +// if (indices == null) |
---|
| 831 | +// { |
---|
| 832 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 833 | +// } else |
---|
| 834 | +// { |
---|
| 835 | +// indices.rewind(); |
---|
| 836 | +// indices.limit(this.getMaxIndex()); |
---|
| 837 | +// |
---|
| 838 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 839 | +// |
---|
| 840 | +// indices.clear(); |
---|
| 841 | +// } |
---|
| 842 | +// } else |
---|
| 843 | +// { |
---|
| 844 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 845 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 846 | +// } |
---|
| 847 | +// |
---|
| 848 | +//// postdrawGeometry(tris); |
---|
| 849 | +//// if (transformed) |
---|
| 850 | +//// { |
---|
| 851 | +//// undoTransforms(tris); |
---|
| 852 | +//// } |
---|
| 853 | +//// |
---|
| 854 | +//// if (Debug.stats) |
---|
| 855 | +//// { |
---|
| 856 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 857 | +//// } |
---|
| 858 | +//// tris.postdraw(this); |
---|
| 859 | + } |
---|
| 860 | + |
---|
| 861 | + static Camera localcamera = new Camera(); |
---|
| 862 | + static cVector from = new cVector(); |
---|
| 863 | + static cVector to = new cVector(); |
---|
| 864 | + |
---|
| 865 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 866 | + { |
---|
| 867 | + CameraPane cp = this; |
---|
| 868 | + |
---|
| 869 | + Camera keep = cp.RenderCamera(); |
---|
| 870 | + cp.renderCamera = localcamera; |
---|
| 871 | + |
---|
| 872 | + if (br.trimmed) |
---|
| 873 | + { |
---|
| 874 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 875 | + |
---|
| 876 | + int i3 = 0; |
---|
| 877 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 878 | + { |
---|
| 879 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 880 | + continue; |
---|
| 881 | + |
---|
| 882 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 883 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 884 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 885 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 886 | + LA.xformPos(from, transform, from); |
---|
| 887 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 888 | + localcamera.setAim(from, to); |
---|
| 889 | + |
---|
| 890 | + CameraPane.occlusionbuffer.display(); |
---|
| 891 | + |
---|
| 892 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 893 | + cp.display(); // debug |
---|
| 894 | + |
---|
| 895 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 896 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 897 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 898 | + |
---|
| 899 | + if ((i % 100) == 0 && i != 0) |
---|
| 900 | + { |
---|
| 901 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 902 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 903 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 904 | + } |
---|
| 905 | + } |
---|
| 906 | + |
---|
| 907 | + br.colors = colors; |
---|
| 908 | + } |
---|
| 909 | + else |
---|
| 910 | + { |
---|
| 911 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 912 | + { |
---|
| 913 | + Vertex v = br.GetVertex(i); |
---|
| 914 | + |
---|
| 915 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 916 | + continue; |
---|
| 917 | + |
---|
| 918 | + from.set(v.x, v.y, v.z); |
---|
| 919 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 920 | + LA.xformPos(from, transform, from); |
---|
| 921 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 922 | + localcamera.setAim(from, to); |
---|
| 923 | + |
---|
| 924 | + CameraPane.occlusionbuffer.display(); |
---|
| 925 | + |
---|
| 926 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 927 | + cp.display(); // debug |
---|
| 928 | + |
---|
| 929 | + v.AO = cp.vertexOcclusion.r; |
---|
| 930 | + |
---|
| 931 | + if ((i % 100) == 0 && i != 0) |
---|
| 932 | + { |
---|
| 933 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 934 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 935 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 936 | + } |
---|
| 937 | + } |
---|
| 938 | + } |
---|
| 939 | + |
---|
| 940 | + //System.out.println("done."); |
---|
| 941 | + |
---|
| 942 | + cp.renderCamera = keep; |
---|
| 943 | + } |
---|
| 944 | + |
---|
| 945 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 946 | + { |
---|
| 947 | + CameraPane display = this; |
---|
| 948 | + pointFlow.CreateHT(); |
---|
| 949 | + |
---|
| 950 | + float r = display.modelParams0[0]; |
---|
| 951 | + float g = display.modelParams0[1]; |
---|
| 952 | + float b = display.modelParams0[2]; |
---|
| 953 | + float opacity = display.modelParams5[1]; |
---|
| 954 | + |
---|
| 955 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 956 | + GL gl = display.GetGL(); // getGL(); |
---|
| 957 | + |
---|
| 958 | + int s = pointFlow.points.size(); |
---|
| 959 | + |
---|
| 960 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 961 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 962 | + |
---|
| 963 | + for (int i=s; --i>=0;) |
---|
| 964 | + //for (int i=0; i<s; i++) |
---|
| 965 | + { |
---|
| 966 | + cVector v = pointFlow.points.get(i); |
---|
| 967 | + |
---|
| 968 | + double mindist = Double.MAX_VALUE; |
---|
| 969 | + |
---|
| 970 | + double size = pointFlow.minimumSize; |
---|
| 971 | + |
---|
| 972 | + double distancenext = 0; |
---|
| 973 | + |
---|
| 974 | + if (i > 0) |
---|
| 975 | + { |
---|
| 976 | + cVector w = pointFlow.points.get(i-1); |
---|
| 977 | + |
---|
| 978 | + double dist = w.distance(v); |
---|
| 979 | + |
---|
| 980 | + distancenext = dist; |
---|
| 981 | + |
---|
| 982 | + if (mindist > dist) |
---|
| 983 | + { |
---|
| 984 | + mindist = dist; |
---|
| 985 | + size = mindist*pointFlow.resizefactor; |
---|
| 986 | + } |
---|
| 987 | + } |
---|
| 988 | + |
---|
| 989 | + if (i < s-1) |
---|
| 990 | + { |
---|
| 991 | + cVector w = pointFlow.points.get(i+1); |
---|
| 992 | + |
---|
| 993 | + double dist = w.distance(v); |
---|
| 994 | + |
---|
| 995 | + if (mindist > dist) |
---|
| 996 | + { |
---|
| 997 | + mindist = dist; |
---|
| 998 | + size = mindist*pointFlow.resizefactor; |
---|
| 999 | + } |
---|
| 1000 | + } |
---|
| 1001 | + |
---|
| 1002 | + if (size < pointFlow.minimumSize) |
---|
| 1003 | + size = pointFlow.minimumSize; |
---|
| 1004 | + if (size > pointFlow.maximumSize) |
---|
| 1005 | + size = pointFlow.maximumSize; |
---|
| 1006 | + |
---|
| 1007 | + double tx = v.x; |
---|
| 1008 | + double ty = v.y; |
---|
| 1009 | + double tz = v.z; |
---|
| 1010 | + |
---|
| 1011 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1012 | + // continue; |
---|
| 1013 | + |
---|
| 1014 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1015 | + gl.glPushMatrix(); |
---|
| 1016 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1017 | + |
---|
| 1018 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1019 | + |
---|
| 1020 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1021 | + gl.glPushMatrix(); |
---|
| 1022 | + |
---|
| 1023 | + gl.glTranslated(tx,ty,tz); |
---|
| 1024 | + |
---|
| 1025 | + gl.glScaled(size,size,size); |
---|
| 1026 | + |
---|
| 1027 | +// float cr = colorBuf.get(index4); |
---|
| 1028 | +// float cg = colorBuf.get(index4+1); |
---|
| 1029 | +// float cb = colorBuf.get(index4+2); |
---|
| 1030 | +// float ca = colorBuf.get(index4+3); |
---|
| 1031 | +// |
---|
| 1032 | +// display.modelParams0[0] = r * cr; |
---|
| 1033 | +// display.modelParams0[1] = g * cg; |
---|
| 1034 | +// display.modelParams0[2] = b * cb; |
---|
| 1035 | +// |
---|
| 1036 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1037 | +// |
---|
| 1038 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1039 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1040 | +// |
---|
| 1041 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1042 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1043 | +// |
---|
| 1044 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1045 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1046 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1047 | + |
---|
| 1048 | + gl.glPopMatrix(); |
---|
| 1049 | + |
---|
| 1050 | + double step = size/4; // |
---|
| 1051 | + |
---|
| 1052 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1053 | + continue; |
---|
| 1054 | + |
---|
| 1055 | + int nbsteps = (int)(distancenext/step); |
---|
| 1056 | + |
---|
| 1057 | + step = distancenext/nbsteps; |
---|
| 1058 | + |
---|
| 1059 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1060 | + |
---|
| 1061 | + tmp.set(next); |
---|
| 1062 | + tmp.sub(v); |
---|
| 1063 | + tmp.normalize(); |
---|
| 1064 | + tmp.mul(step); |
---|
| 1065 | + |
---|
| 1066 | + // calculate next size |
---|
| 1067 | + mindist = Double.MAX_VALUE; |
---|
| 1068 | + |
---|
| 1069 | + double nextsize = pointFlow.minimumSize; |
---|
| 1070 | + |
---|
| 1071 | + if (i > 1) |
---|
| 1072 | + { |
---|
| 1073 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1074 | + |
---|
| 1075 | + double dist = w.distance(next); |
---|
| 1076 | + |
---|
| 1077 | + if (mindist > dist) |
---|
| 1078 | + { |
---|
| 1079 | + mindist = dist; |
---|
| 1080 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1081 | + } |
---|
| 1082 | + } |
---|
| 1083 | + |
---|
| 1084 | + double dist = v.distance(next); |
---|
| 1085 | + |
---|
| 1086 | + if (mindist > dist) |
---|
| 1087 | + { |
---|
| 1088 | + mindist = dist; |
---|
| 1089 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1090 | + } |
---|
| 1091 | + |
---|
| 1092 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1093 | + nextsize = pointFlow.minimumSize; |
---|
| 1094 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1095 | + nextsize = pointFlow.maximumSize; |
---|
| 1096 | + // |
---|
| 1097 | + |
---|
| 1098 | + double count = 0; |
---|
| 1099 | + |
---|
| 1100 | + while (distancenext > 0.000000001) // step |
---|
| 1101 | + { |
---|
| 1102 | + gl.glPushMatrix(); |
---|
| 1103 | + |
---|
| 1104 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1105 | + |
---|
| 1106 | + double K = count/nbsteps; |
---|
| 1107 | + |
---|
| 1108 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1109 | + |
---|
| 1110 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1111 | + |
---|
| 1112 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1113 | + |
---|
| 1114 | + count++; |
---|
| 1115 | + |
---|
| 1116 | + distancenext -= step; |
---|
| 1117 | + |
---|
| 1118 | + gl.glPopMatrix(); |
---|
| 1119 | + } |
---|
| 1120 | + |
---|
| 1121 | + if (count != nbsteps) |
---|
| 1122 | + assert(count == nbsteps); |
---|
| 1123 | + |
---|
| 1124 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1125 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1126 | + |
---|
| 1127 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1128 | + gl.glPopMatrix(); |
---|
| 1129 | + } |
---|
| 1130 | + |
---|
| 1131 | + if (!cf) |
---|
| 1132 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1133 | + |
---|
| 1134 | +// display.modelParams0[0] = r; |
---|
| 1135 | +// display.modelParams0[1] = g; |
---|
| 1136 | +// display.modelParams0[2] = b; |
---|
| 1137 | +// |
---|
| 1138 | +// display.modelParams5[1] = opacity; |
---|
| 1139 | +// |
---|
| 1140 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1141 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1142 | + |
---|
| 1143 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1144 | + } |
---|
| 1145 | + |
---|
| 1146 | + public void DrawBox(cVector min, cVector max) |
---|
| 1147 | + { |
---|
| 1148 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1149 | + gl.glBegin(gl.GL_LINES); |
---|
| 1150 | + |
---|
| 1151 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1152 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1153 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1154 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1155 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1156 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1157 | + |
---|
| 1158 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1159 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1160 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1161 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1162 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1163 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1164 | + |
---|
| 1165 | + gl.glEnd(); |
---|
| 1166 | + } |
---|
| 1167 | + |
---|
| 1168 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1169 | + { |
---|
| 1170 | + int[] strips = bRep.getRawIndices(); |
---|
| 1171 | + |
---|
| 1172 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1173 | + |
---|
| 1174 | + // TRIANGLE STRIP ARRAY |
---|
| 1175 | + if (bRep.trimmed) |
---|
| 1176 | + { |
---|
| 1177 | + float[] v = bRep.getRawVertices(); |
---|
| 1178 | + float[] n = bRep.getRawNormals(); |
---|
| 1179 | + float[] c = bRep.getRawColors(); |
---|
| 1180 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1181 | + |
---|
| 1182 | + int count2 = 0; |
---|
| 1183 | + int count3 = 0; |
---|
| 1184 | + |
---|
| 1185 | + if (n.length > 0) |
---|
| 1186 | + { |
---|
| 1187 | + for (int i = 0; i < strips.length; i++) |
---|
| 1188 | + { |
---|
| 1189 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1190 | + |
---|
| 1191 | + /* |
---|
| 1192 | + boolean locked = false; |
---|
| 1193 | + float eps = 0.1f; |
---|
| 1194 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1195 | + |
---|
| 1196 | + int dot = 0; |
---|
| 1197 | + |
---|
| 1198 | + if ((dot&1) == 0) |
---|
| 1199 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1200 | + |
---|
| 1201 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1202 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1203 | + else |
---|
| 1204 | + { |
---|
| 1205 | + locked = true; |
---|
| 1206 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1207 | + } |
---|
| 1208 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1209 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1210 | + if (hasnorm) |
---|
| 1211 | + { |
---|
| 1212 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1213 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1214 | + } |
---|
| 1215 | + |
---|
| 1216 | + if ((dot&4) == 0) |
---|
| 1217 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1218 | + |
---|
| 1219 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1220 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1221 | + else |
---|
| 1222 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1223 | + |
---|
| 1224 | + f.dot = dot; |
---|
| 1225 | + */ |
---|
| 1226 | + |
---|
| 1227 | + if (!selectmode) |
---|
| 1228 | + { |
---|
| 1229 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1230 | + { |
---|
| 1231 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1232 | + } else |
---|
| 1233 | + { |
---|
| 1234 | + gl.glNormal3f(0, 0, 1); |
---|
| 1235 | + } |
---|
| 1236 | + |
---|
| 1237 | + if (c != null) |
---|
| 1238 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1239 | + { |
---|
| 1240 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1241 | + } |
---|
| 1242 | + } |
---|
| 1243 | + |
---|
| 1244 | + if (flipV) |
---|
| 1245 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1246 | + else |
---|
| 1247 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1248 | + |
---|
| 1249 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1250 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1251 | + |
---|
| 1252 | + count2 += 2; |
---|
| 1253 | + count3 += 3; |
---|
| 1254 | + if (!selectmode) |
---|
| 1255 | + { |
---|
| 1256 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1257 | + { |
---|
| 1258 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1259 | + } else |
---|
| 1260 | + { |
---|
| 1261 | + gl.glNormal3f(0, 0, 1); |
---|
| 1262 | + } |
---|
| 1263 | + if (c != null) |
---|
| 1264 | + { |
---|
| 1265 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1266 | + } |
---|
| 1267 | + } |
---|
| 1268 | + |
---|
| 1269 | + if (flipV) |
---|
| 1270 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1271 | + else |
---|
| 1272 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1273 | + |
---|
| 1274 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1275 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1276 | + |
---|
| 1277 | + count2 += 2; |
---|
| 1278 | + count3 += 3; |
---|
| 1279 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1280 | + { |
---|
| 1281 | + //gl.glTexCoord2d(...); |
---|
| 1282 | + if (!selectmode) |
---|
| 1283 | + { |
---|
| 1284 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1285 | + { |
---|
| 1286 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1287 | + } else |
---|
| 1288 | + { |
---|
| 1289 | + gl.glNormal3f(0, 0, 1); |
---|
| 1290 | + } |
---|
| 1291 | + if (c != null) |
---|
| 1292 | + { |
---|
| 1293 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1294 | + } |
---|
| 1295 | + } |
---|
| 1296 | + |
---|
| 1297 | + if (flipV) |
---|
| 1298 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1299 | + else |
---|
| 1300 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1301 | + |
---|
| 1302 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1303 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1304 | + |
---|
| 1305 | + count2 += 2; |
---|
| 1306 | + count3 += 3; |
---|
| 1307 | + } |
---|
| 1308 | + |
---|
| 1309 | + gl.glEnd(); |
---|
| 1310 | + } |
---|
| 1311 | + } |
---|
| 1312 | + |
---|
| 1313 | + assert count3 == v.length; |
---|
| 1314 | + } |
---|
| 1315 | + else // !trimmed |
---|
| 1316 | + { |
---|
| 1317 | + int count = 0; |
---|
| 1318 | + for (int i = 0; i < strips.length; i++) |
---|
| 1319 | + { |
---|
| 1320 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1321 | + |
---|
| 1322 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1323 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1324 | + |
---|
| 1325 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1326 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1327 | + |
---|
| 1328 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1329 | + { |
---|
| 1330 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1331 | + |
---|
| 1332 | + // if (j%2 == 0) |
---|
| 1333 | + // drawFace(p, q, r, display, null); |
---|
| 1334 | + // else |
---|
| 1335 | + // drawFace(p, r, q, display, null); |
---|
| 1336 | + |
---|
| 1337 | + // p = q; |
---|
| 1338 | + // q = r; |
---|
| 1339 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1340 | + } |
---|
| 1341 | + |
---|
| 1342 | + gl.glEnd(); |
---|
| 1343 | + } |
---|
| 1344 | + } |
---|
| 1345 | + } |
---|
| 1346 | + |
---|
| 1347 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1348 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1349 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1350 | + |
---|
| 1351 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1352 | + { |
---|
| 1353 | + GL gl = GetGL(); // getGL(); |
---|
| 1354 | + |
---|
| 1355 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1356 | + |
---|
| 1357 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1358 | + |
---|
| 1359 | + gl.glLineWidth(1); |
---|
| 1360 | + gl.glColor3f(1,1,1); |
---|
| 1361 | + gl.glBegin(gl.GL_LINES); |
---|
| 1362 | + double scale = 0; |
---|
| 1363 | + int count = 0; |
---|
| 1364 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1365 | + { |
---|
| 1366 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1367 | + if(s == 0) |
---|
| 1368 | + { |
---|
| 1369 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1370 | + } |
---|
| 1371 | + if (mesh.showsprings) |
---|
| 1372 | + { |
---|
| 1373 | + temp.set(spring.a.position); |
---|
| 1374 | + temp.add(spring.b.position); |
---|
| 1375 | + temp.mul(0.5); |
---|
| 1376 | + temp2.set(spring.a.position); |
---|
| 1377 | + temp2.sub(spring.b.position); |
---|
| 1378 | + temp2.mul(spring.restLength/2); |
---|
| 1379 | + temp.sub(temp2); |
---|
| 1380 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1381 | + temp.add(temp2); |
---|
| 1382 | + temp.add(temp2); |
---|
| 1383 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1384 | + } |
---|
| 1385 | + |
---|
| 1386 | + if (spring.isHandle) |
---|
| 1387 | + continue; |
---|
| 1388 | + |
---|
| 1389 | + //if (scale < spring.restLength) |
---|
| 1390 | + scale += spring.restLength; |
---|
| 1391 | + count++; |
---|
| 1392 | + } |
---|
| 1393 | + gl.glEnd(); |
---|
| 1394 | + |
---|
| 1395 | + if (count == 0) |
---|
| 1396 | + scale = 0.01; |
---|
| 1397 | + else |
---|
| 1398 | + scale /= count * 3; |
---|
| 1399 | + |
---|
| 1400 | + //scale = 0.25; |
---|
| 1401 | + |
---|
| 1402 | + if (mesh.ShowInfo()) |
---|
| 1403 | + { |
---|
| 1404 | + gl.glLineWidth(4); |
---|
| 1405 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1406 | + { |
---|
| 1407 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1408 | + if (node.mass == 0) |
---|
| 1409 | + continue; |
---|
| 1410 | + |
---|
| 1411 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1412 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1413 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1414 | + //temp.normalize(); |
---|
| 1415 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1416 | + gl.glBegin(gl.GL_LINES); |
---|
| 1417 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1418 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1419 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1420 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1421 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1422 | + gl.glEnd(); |
---|
| 1423 | + } |
---|
| 1424 | + |
---|
| 1425 | + gl.glLineWidth(8); |
---|
| 1426 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1427 | + { |
---|
| 1428 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1429 | + |
---|
| 1430 | + if (node.springs != null) |
---|
| 1431 | + { |
---|
| 1432 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1433 | + { |
---|
| 1434 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1435 | + |
---|
| 1436 | + int c = i+1; |
---|
| 1437 | + // c = node.springs.get(i).nbcopies; |
---|
| 1438 | + |
---|
| 1439 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1440 | + gl.glBegin(gl.GL_LINES); |
---|
| 1441 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1442 | + 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); |
---|
| 1443 | + gl.glEnd(); |
---|
| 1444 | + } |
---|
| 1445 | + } |
---|
| 1446 | + } |
---|
| 1447 | + |
---|
| 1448 | + gl.glLineWidth(1); |
---|
| 1449 | + } |
---|
| 1450 | + |
---|
| 1451 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1452 | + } |
---|
| 1453 | + |
---|
569 | 1454 | /// INTERFACE |
---|
| 1455 | + |
---|
| 1456 | + public void StartTriangles() |
---|
| 1457 | + { |
---|
| 1458 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1459 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1460 | + } |
---|
| 1461 | + |
---|
| 1462 | + public void EndTriangles() |
---|
| 1463 | + { |
---|
| 1464 | + GetGL().glEnd(); |
---|
| 1465 | + } |
---|
| 1466 | + |
---|
| 1467 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1468 | + { |
---|
| 1469 | + if (!selectmode) |
---|
| 1470 | + { |
---|
| 1471 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1472 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1473 | + |
---|
| 1474 | + if (flipV) |
---|
| 1475 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1476 | + else |
---|
| 1477 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1478 | + } |
---|
| 1479 | + |
---|
| 1480 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1481 | + } |
---|
570 | 1482 | |
---|
571 | 1483 | void SetColor(Object3D obj, Vertex p0) |
---|
572 | 1484 | { |
---|
.. | .. |
---|
745 | 1657 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
746 | 1658 | } |
---|
747 | 1659 | |
---|
748 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1660 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
749 | 1661 | { |
---|
750 | 1662 | CameraPane display = this; |
---|
751 | 1663 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
761 | 1673 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
762 | 1674 | if (!material.multiply) |
---|
763 | 1675 | { |
---|
764 | | - display.color = color; |
---|
| 1676 | + display.color = material.color; |
---|
765 | 1677 | display.saturation = material.modulation; |
---|
766 | 1678 | } |
---|
767 | 1679 | else |
---|
768 | 1680 | { |
---|
769 | | - display.color *= color*2; |
---|
| 1681 | + display.color *= material.color*2; |
---|
770 | 1682 | display.saturation *= material.modulation*2; |
---|
771 | 1683 | } |
---|
772 | 1684 | |
---|
773 | 1685 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
774 | 1686 | |
---|
775 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1687 | + float[] colorV = Grafreed.colorV; |
---|
776 | 1688 | |
---|
777 | 1689 | /**/ |
---|
778 | 1690 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
780 | 1692 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
781 | 1693 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
782 | 1694 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
783 | | - colorV[3] = material.opacity; |
---|
| 1695 | + colorV[3] = 1; // material.opacity; |
---|
784 | 1696 | |
---|
785 | 1697 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
786 | 1698 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
888 | 1800 | display.modelParams7[2] = 0; |
---|
889 | 1801 | display.modelParams7[3] = 0; |
---|
890 | 1802 | |
---|
891 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1803 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
892 | 1804 | |
---|
893 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1805 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
894 | 1806 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
895 | 1807 | { |
---|
896 | 1808 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1032 | 1944 | void PushMatrix(double[][] matrix) |
---|
1033 | 1945 | { |
---|
1034 | 1946 | // GrafreeD.tracein(matrix); |
---|
1035 | | - PushMatrix(matrix,1); |
---|
| 1947 | + PushMatrix(matrix, 1); |
---|
1036 | 1948 | } |
---|
1037 | 1949 | |
---|
1038 | 1950 | void PushMatrix() |
---|
.. | .. |
---|
1129 | 2041 | |
---|
1130 | 2042 | static int camerachangeframe; |
---|
1131 | 2043 | |
---|
1132 | | - boolean SetCamera(Camera cam) |
---|
| 2044 | + public boolean SetCamera(Camera cam) |
---|
1133 | 2045 | { |
---|
1134 | 2046 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1135 | 2047 | // return false; |
---|
.. | .. |
---|
1186 | 2098 | //System.err.println("Oeil on"); |
---|
1187 | 2099 | OEIL = true; |
---|
1188 | 2100 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1189 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2101 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1190 | 2102 | //pingthread.StepToTarget(true); |
---|
1191 | 2103 | } |
---|
1192 | 2104 | |
---|
.. | .. |
---|
1257 | 2169 | mainDL ^= true; |
---|
1258 | 2170 | } |
---|
1259 | 2171 | |
---|
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 | 2172 | void ToggleFullScreen() |
---|
1288 | 2173 | { |
---|
1289 | 2174 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1294 | 2179 | Globals.CROWD ^= true; |
---|
1295 | 2180 | } |
---|
1296 | 2181 | |
---|
1297 | | - void ToggleInertia() |
---|
1298 | | - { |
---|
1299 | | - INERTIA ^= true; |
---|
1300 | | - } |
---|
1301 | | - |
---|
1302 | 2182 | void ToggleLocal() |
---|
1303 | 2183 | { |
---|
1304 | 2184 | LOCALTRANSFORM ^= true; |
---|
1305 | 2185 | } |
---|
1306 | 2186 | |
---|
1307 | | - void ToggleFast() |
---|
| 2187 | + public void ToggleTexture() |
---|
| 2188 | + { |
---|
| 2189 | + textureon ^= true; |
---|
| 2190 | + } |
---|
| 2191 | + |
---|
| 2192 | + public void ToggleLive() |
---|
| 2193 | + { |
---|
| 2194 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2195 | + |
---|
| 2196 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2197 | + |
---|
| 2198 | + if (!Globals.isLIVE()) // save sound |
---|
| 2199 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2200 | + // else |
---|
| 2201 | + repaint(); // start loop // may 2013 |
---|
| 2202 | + } |
---|
| 2203 | + |
---|
| 2204 | + public void ToggleSupport() |
---|
| 2205 | + { |
---|
| 2206 | + SUPPORT ^= true; |
---|
| 2207 | + } |
---|
| 2208 | + |
---|
| 2209 | + public void ToggleAbort() |
---|
| 2210 | + { |
---|
| 2211 | + ABORTMODE ^= true; |
---|
| 2212 | + } |
---|
| 2213 | + |
---|
| 2214 | + public void ToggleInertia() |
---|
| 2215 | + { |
---|
| 2216 | + INERTIA ^= true; |
---|
| 2217 | + } |
---|
| 2218 | + |
---|
| 2219 | + public void ToggleFast() |
---|
1308 | 2220 | { |
---|
1309 | 2221 | FAST ^= true; |
---|
1310 | 2222 | } |
---|
1311 | 2223 | |
---|
1312 | | - void ToggleSlowPose() |
---|
| 2224 | + public void ToggleSlowPose() |
---|
1313 | 2225 | { |
---|
1314 | 2226 | SLOWPOSE ^= true; |
---|
1315 | 2227 | } |
---|
1316 | 2228 | |
---|
1317 | | - void ToggleFootContact() |
---|
1318 | | - { |
---|
1319 | | - FOOTCONTACT ^= true; |
---|
1320 | | - } |
---|
1321 | | - |
---|
1322 | | - void ToggleBoxMode() |
---|
| 2229 | + public void ToggleBoxMode() |
---|
1323 | 2230 | { |
---|
1324 | 2231 | BOXMODE ^= true; |
---|
1325 | 2232 | } |
---|
1326 | 2233 | |
---|
1327 | | - void ToggleSmoothFocus() |
---|
| 2234 | + public void ToggleZoomBoxMode() |
---|
| 2235 | + { |
---|
| 2236 | + ZOOMBOXMODE ^= true; |
---|
| 2237 | + } |
---|
| 2238 | + |
---|
| 2239 | + public void ToggleSmoothFocus() |
---|
1328 | 2240 | { |
---|
1329 | 2241 | SMOOTHFOCUS ^= true; |
---|
1330 | 2242 | } |
---|
1331 | 2243 | |
---|
1332 | | - void ToggleImageFlip() |
---|
| 2244 | + public void ToggleImageFlip() |
---|
1333 | 2245 | { |
---|
1334 | 2246 | IMAGEFLIP ^= true; |
---|
1335 | 2247 | } |
---|
1336 | 2248 | |
---|
1337 | | - void ToggleSpeakerMocap() |
---|
| 2249 | + public void ToggleSpeakerMocap() |
---|
1338 | 2250 | { |
---|
1339 | 2251 | SPEAKERMOCAP ^= true; |
---|
1340 | 2252 | } |
---|
1341 | 2253 | |
---|
1342 | | - void ToggleSpeakerCamera() |
---|
| 2254 | + public void ToggleSpeakerCamera() |
---|
1343 | 2255 | { |
---|
1344 | 2256 | SPEAKERCAMERA ^= true; |
---|
1345 | 2257 | } |
---|
1346 | 2258 | |
---|
1347 | | - void ToggleSpeakerFocus() |
---|
| 2259 | + public void ToggleSpeakerFocus() |
---|
1348 | 2260 | { |
---|
1349 | 2261 | SPEAKERFOCUS ^= true; |
---|
1350 | 2262 | } |
---|
1351 | 2263 | |
---|
1352 | | - void ToggleDebug() |
---|
1353 | | - { |
---|
1354 | | - DEBUG ^= true; |
---|
1355 | | - } |
---|
1356 | | - |
---|
1357 | | - void ToggleFrustum() |
---|
| 2264 | + public void ToggleFrustum() |
---|
1358 | 2265 | { |
---|
1359 | 2266 | FRUSTUM ^= true; |
---|
1360 | 2267 | } |
---|
1361 | 2268 | |
---|
1362 | | - void ToggleTrack() |
---|
| 2269 | + public void ToggleTrack() |
---|
1363 | 2270 | { |
---|
1364 | 2271 | TRACK ^= true; |
---|
1365 | 2272 | if (TRACK) |
---|
.. | .. |
---|
1378 | 2285 | repaint(); |
---|
1379 | 2286 | } |
---|
1380 | 2287 | |
---|
1381 | | - void ToggleTrackOnce() |
---|
| 2288 | + public void ToggleTrackOnce() |
---|
1382 | 2289 | { |
---|
1383 | 2290 | TRACKONCE ^= true; |
---|
1384 | 2291 | } |
---|
1385 | 2292 | |
---|
1386 | | - void ToggleShadowTrack() |
---|
| 2293 | + public void ToggleShadowTrack() |
---|
1387 | 2294 | { |
---|
1388 | 2295 | SHADOWTRACK ^= true; |
---|
1389 | 2296 | repaint(); |
---|
1390 | 2297 | } |
---|
1391 | 2298 | |
---|
1392 | | - void ToggleOeil() |
---|
| 2299 | + public void ToggleOeil() |
---|
1393 | 2300 | { |
---|
1394 | 2301 | OEIL ^= true; |
---|
1395 | 2302 | } |
---|
1396 | 2303 | |
---|
1397 | | - void ToggleOeilOnce() |
---|
| 2304 | + public void ToggleOeilOnce() |
---|
1398 | 2305 | { |
---|
1399 | 2306 | OEILONCE ^= true; |
---|
| 2307 | + } |
---|
| 2308 | + |
---|
| 2309 | + void ToggleFootContact() |
---|
| 2310 | + { |
---|
| 2311 | + FOOTCONTACT ^= true; |
---|
| 2312 | + } |
---|
| 2313 | + |
---|
| 2314 | + void ToggleDebug() |
---|
| 2315 | + { |
---|
| 2316 | + Globals.DEBUG ^= true; |
---|
1400 | 2317 | } |
---|
1401 | 2318 | |
---|
1402 | 2319 | void ToggleLookAt() |
---|
.. | .. |
---|
1404 | 2321 | LOOKAT ^= true; |
---|
1405 | 2322 | } |
---|
1406 | 2323 | |
---|
1407 | | - void ToggleRandom() |
---|
| 2324 | + void ToggleSwitch() |
---|
1408 | 2325 | { |
---|
1409 | | - RANDOM ^= true; |
---|
| 2326 | + SWITCH ^= true; |
---|
1410 | 2327 | } |
---|
1411 | 2328 | |
---|
1412 | 2329 | void ToggleHandles() |
---|
.. | .. |
---|
1414 | 2331 | HANDLES ^= true; |
---|
1415 | 2332 | } |
---|
1416 | 2333 | |
---|
| 2334 | + Object3D paintFolder; |
---|
| 2335 | + |
---|
1417 | 2336 | void TogglePaint() |
---|
1418 | 2337 | { |
---|
1419 | 2338 | PAINTMODE ^= true; |
---|
1420 | 2339 | paintcount = 0; |
---|
| 2340 | + |
---|
| 2341 | + if (PAINTMODE) |
---|
| 2342 | + { |
---|
| 2343 | + paintFolder = GetFolder(); |
---|
| 2344 | + } |
---|
1421 | 2345 | } |
---|
1422 | 2346 | |
---|
1423 | 2347 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1513 | 2437 | { |
---|
1514 | 2438 | return currentGL; |
---|
1515 | 2439 | } |
---|
1516 | | - |
---|
| 2440 | + |
---|
| 2441 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2442 | + { |
---|
| 2443 | + Grafreed.Assert(texturedata != null); |
---|
| 2444 | + |
---|
| 2445 | + int width = texturedata.getWidth(); |
---|
| 2446 | + int height = texturedata.getHeight(); |
---|
| 2447 | + |
---|
| 2448 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2449 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2450 | + |
---|
| 2451 | + byte[] bytes = bytebuf.array(); |
---|
| 2452 | + |
---|
| 2453 | + return CreateBim(bytes, width, height); |
---|
| 2454 | + } |
---|
| 2455 | + |
---|
1517 | 2456 | /**/ |
---|
1518 | 2457 | class CacheTexture |
---|
1519 | 2458 | { |
---|
.. | .. |
---|
1522 | 2461 | |
---|
1523 | 2462 | int resolution; |
---|
1524 | 2463 | |
---|
1525 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2464 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1526 | 2465 | { |
---|
1527 | | - texture = tex; |
---|
| 2466 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2467 | + texturedata = texdata; |
---|
1528 | 2468 | resolution = res; |
---|
1529 | 2469 | } |
---|
1530 | 2470 | } |
---|
1531 | 2471 | /**/ |
---|
1532 | 2472 | |
---|
1533 | 2473 | // 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>(); |
---|
| 2474 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2475 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2476 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2477 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2478 | + |
---|
1537 | 2479 | int pigmentdepth = 0; |
---|
1538 | 2480 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1539 | 2481 | int bumpdepth = 0; |
---|
1540 | 2482 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1541 | 2483 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1542 | 2484 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1543 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2485 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1544 | 2486 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1545 | 2487 | |
---|
1546 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2488 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1547 | 2489 | { |
---|
1548 | 2490 | TextureData texturedata = null; |
---|
1549 | 2491 | |
---|
.. | .. |
---|
1562 | 2504 | if (bump) |
---|
1563 | 2505 | texturedata = ConvertBump(texturedata, false); |
---|
1564 | 2506 | |
---|
1565 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1566 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2507 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2508 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
1567 | 2509 | |
---|
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); |
---|
| 2510 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2511 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
1570 | 2512 | |
---|
1571 | | - return texture; |
---|
| 2513 | + return texturedata; |
---|
| 2514 | + } |
---|
| 2515 | + |
---|
| 2516 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2517 | + { |
---|
| 2518 | + TextureData texturedata = null; |
---|
| 2519 | + |
---|
| 2520 | + try |
---|
| 2521 | + { |
---|
| 2522 | + texturedata = |
---|
| 2523 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2524 | + bim, |
---|
| 2525 | + true); |
---|
| 2526 | + } catch (Exception e) |
---|
| 2527 | + { |
---|
| 2528 | + throw new javax.media.opengl.GLException(e); |
---|
| 2529 | + } |
---|
| 2530 | + |
---|
| 2531 | + if (bump) |
---|
| 2532 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2533 | + |
---|
| 2534 | + return texturedata; |
---|
1572 | 2535 | } |
---|
1573 | 2536 | |
---|
1574 | 2537 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2641 | 3604 | |
---|
2642 | 3605 | System.out.println("LOADING TEXTURE : " + name); |
---|
2643 | 3606 | |
---|
| 3607 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3608 | + |
---|
2644 | 3609 | // |
---|
2645 | 3610 | if (false) // compressbit > 0) |
---|
2646 | 3611 | { |
---|
.. | .. |
---|
3345 | 4310 | |
---|
3346 | 4311 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3347 | 4312 | { |
---|
| 4313 | + new Exception().printStackTrace(); |
---|
3348 | 4314 | System.exit(0); |
---|
3349 | 4315 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3350 | 4316 | |
---|
.. | .. |
---|
7038 | 8004 | String pigment = Object3D.GetPigment(tex); |
---|
7039 | 8005 | String bump = Object3D.GetBump(tex); |
---|
7040 | 8006 | |
---|
7041 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8007 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7042 | 8008 | { |
---|
7043 | 8009 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7044 | 8010 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7053 | 8019 | pigment = null; |
---|
7054 | 8020 | } |
---|
7055 | 8021 | |
---|
7056 | | - ReleaseTexture(bump, true); |
---|
7057 | | - ReleaseTexture(pigment, false); |
---|
| 8022 | + ReleaseTexture(tex, true); |
---|
| 8023 | + ReleaseTexture(tex, false); |
---|
7058 | 8024 | } |
---|
7059 | 8025 | |
---|
7060 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8026 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8027 | + { |
---|
| 8028 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8029 | + { |
---|
| 8030 | + return; |
---|
| 8031 | + } |
---|
| 8032 | + |
---|
| 8033 | + if (tex == null) |
---|
| 8034 | + { |
---|
| 8035 | + ReleaseTexture(null, false); |
---|
| 8036 | + return; |
---|
| 8037 | + } |
---|
| 8038 | + |
---|
| 8039 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8040 | + |
---|
| 8041 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + { |
---|
| 8043 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8044 | + // System.out.println("; bump = " + bump); |
---|
| 8045 | + } |
---|
| 8046 | + |
---|
| 8047 | + if (pigment.equals("")) |
---|
| 8048 | + { |
---|
| 8049 | + pigment = null; |
---|
| 8050 | + } |
---|
| 8051 | + |
---|
| 8052 | + ReleaseTexture(tex, false); |
---|
| 8053 | + } |
---|
| 8054 | + |
---|
| 8055 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8056 | + { |
---|
| 8057 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8058 | + { |
---|
| 8059 | + return; |
---|
| 8060 | + } |
---|
| 8061 | + |
---|
| 8062 | + if (tex == null) |
---|
| 8063 | + { |
---|
| 8064 | + ReleaseTexture(null, true); |
---|
| 8065 | + return; |
---|
| 8066 | + } |
---|
| 8067 | + |
---|
| 8068 | + String bump = Object3D.GetBump(tex); |
---|
| 8069 | + |
---|
| 8070 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8071 | + { |
---|
| 8072 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8073 | + // System.out.println("; bump = " + bump); |
---|
| 8074 | + } |
---|
| 8075 | + |
---|
| 8076 | + if (bump.equals("")) |
---|
| 8077 | + { |
---|
| 8078 | + bump = null; |
---|
| 8079 | + } |
---|
| 8080 | + |
---|
| 8081 | + ReleaseTexture(tex, true); |
---|
| 8082 | + } |
---|
| 8083 | + |
---|
| 8084 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7061 | 8085 | { |
---|
7062 | 8086 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7063 | 8087 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7068 | 8092 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7069 | 8093 | |
---|
7070 | 8094 | if (tex != null) |
---|
7071 | | - texture = textures.get(tex); |
---|
| 8095 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7072 | 8096 | |
---|
7073 | 8097 | // //assert( texture != null ); |
---|
7074 | 8098 | // if (texture == null) |
---|
.. | .. |
---|
7160 | 8184 | } |
---|
7161 | 8185 | } |
---|
7162 | 8186 | |
---|
7163 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8187 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8188 | + { |
---|
| 8189 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8190 | +// ambientOcclusion ) // || !textureon) |
---|
| 8191 | +// { |
---|
| 8192 | +// return; // false; |
---|
| 8193 | +// } |
---|
| 8194 | +// |
---|
| 8195 | +// if (tex == null) |
---|
| 8196 | +// { |
---|
| 8197 | +// BindTexture(null,false,resolution); |
---|
| 8198 | +// BindTexture(null,true,resolution); |
---|
| 8199 | +// return; |
---|
| 8200 | +// } |
---|
| 8201 | +// |
---|
| 8202 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8203 | +// String bump = Object3D.GetBump(tex); |
---|
| 8204 | +// |
---|
| 8205 | +// usedtextures.add(pigment); |
---|
| 8206 | +// usedtextures.add(bump); |
---|
| 8207 | +// |
---|
| 8208 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8209 | +// { |
---|
| 8210 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8211 | +// // System.out.println("; bump = " + bump); |
---|
| 8212 | +// } |
---|
| 8213 | +// |
---|
| 8214 | +// if (bump.equals("")) |
---|
| 8215 | +// { |
---|
| 8216 | +// bump = null; |
---|
| 8217 | +// } |
---|
| 8218 | +// if (pigment.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// pigment = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// |
---|
| 8223 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8224 | +// BindTexture(pigment, false, resolution); |
---|
| 8225 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8226 | +// BindTexture(bump, true, resolution); |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// |
---|
| 8229 | +// return; // true; |
---|
| 8230 | + |
---|
| 8231 | + BindPigmentTexture(tex, resolution); |
---|
| 8232 | + BindBumpTexture(tex, resolution); |
---|
| 8233 | + } |
---|
| 8234 | + |
---|
| 8235 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7164 | 8236 | { |
---|
7165 | 8237 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7166 | 8238 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7171 | 8243 | if (tex == null) |
---|
7172 | 8244 | { |
---|
7173 | 8245 | BindTexture(null,false,resolution); |
---|
7174 | | - BindTexture(null,true,resolution); |
---|
7175 | 8246 | return; |
---|
7176 | 8247 | } |
---|
7177 | 8248 | |
---|
7178 | 8249 | String pigment = Object3D.GetPigment(tex); |
---|
| 8250 | + |
---|
| 8251 | + usedtextures.add(tex); |
---|
| 8252 | + |
---|
| 8253 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8254 | + { |
---|
| 8255 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8256 | + // System.out.println("; bump = " + bump); |
---|
| 8257 | + } |
---|
| 8258 | + |
---|
| 8259 | + if (pigment.equals("")) |
---|
| 8260 | + { |
---|
| 8261 | + pigment = null; |
---|
| 8262 | + } |
---|
| 8263 | + |
---|
| 8264 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8265 | + BindTexture(tex, false, resolution); |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8269 | + { |
---|
| 8270 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8271 | + ambientOcclusion ) // || !textureon) |
---|
| 8272 | + { |
---|
| 8273 | + return; // false; |
---|
| 8274 | + } |
---|
| 8275 | + |
---|
| 8276 | + if (tex == null) |
---|
| 8277 | + { |
---|
| 8278 | + BindTexture(null,true,resolution); |
---|
| 8279 | + return; |
---|
| 8280 | + } |
---|
| 8281 | + |
---|
7179 | 8282 | String bump = Object3D.GetBump(tex); |
---|
7180 | 8283 | |
---|
7181 | | - usedtextures.put(pigment, pigment); |
---|
7182 | | - usedtextures.put(bump, bump); |
---|
| 8284 | + usedtextures.add(tex); |
---|
7183 | 8285 | |
---|
7184 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8286 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7185 | 8287 | { |
---|
7186 | 8288 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7187 | 8289 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7191 | 8293 | { |
---|
7192 | 8294 | bump = null; |
---|
7193 | 8295 | } |
---|
7194 | | - if (pigment.equals("")) |
---|
7195 | | - { |
---|
7196 | | - pigment = null; |
---|
7197 | | - } |
---|
7198 | 8296 | |
---|
7199 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7200 | | - BindTexture(pigment, false, resolution); |
---|
7201 | 8297 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7202 | | - BindTexture(bump, true, resolution); |
---|
| 8298 | + BindTexture(tex, true, resolution); |
---|
7203 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7204 | | - |
---|
7205 | | - return; // true; |
---|
7206 | 8300 | } |
---|
7207 | 8301 | |
---|
7208 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8302 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8303 | + |
---|
| 8304 | + private boolean FileExists(String tex) |
---|
7209 | 8305 | { |
---|
7210 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8306 | + if (missingTextures.contains(tex)) |
---|
| 8307 | + { |
---|
| 8308 | + return false; |
---|
| 8309 | + } |
---|
| 8310 | + |
---|
| 8311 | + boolean fileExists = new File(tex).exists(); |
---|
| 8312 | + |
---|
| 8313 | + if (!fileExists) |
---|
| 8314 | + { |
---|
| 8315 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8316 | + missingTextures.add(tex); |
---|
| 8317 | + } |
---|
| 8318 | + |
---|
| 8319 | + return fileExists; |
---|
| 8320 | + } |
---|
| 8321 | + |
---|
| 8322 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8323 | + { |
---|
| 8324 | + CacheTexture texturecache = null; |
---|
7211 | 8325 | |
---|
7212 | 8326 | if (tex != null) |
---|
7213 | 8327 | { |
---|
7214 | | - String texname = tex; |
---|
| 8328 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8329 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7215 | 8330 | |
---|
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; |
---|
| 8331 | + if (texname.equals("") && texdata == null) |
---|
| 8332 | + { |
---|
| 8333 | + return null; |
---|
| 8334 | + } |
---|
| 8335 | + |
---|
| 8336 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8337 | + |
---|
| 8338 | +// String[] split = tex.split("Textures"); |
---|
| 8339 | +// if (split.length > 1) |
---|
| 8340 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8341 | +// else |
---|
| 8342 | +// if (!texname.startsWith("/")) |
---|
| 8343 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8344 | + if (!FileExists(texname)) |
---|
| 8345 | + { |
---|
| 8346 | + texname = fallbackTextureName; |
---|
| 8347 | + } |
---|
7222 | 8348 | |
---|
7223 | 8349 | if (CACHETEXTURE) |
---|
7224 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7225 | | - |
---|
7226 | | - TextureData texturedata = null; |
---|
7227 | | - |
---|
7228 | | - if (texture == null || texture.resolution < resolution) |
---|
7229 | 8350 | { |
---|
7230 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8351 | + if (texdata == null) |
---|
| 8352 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8353 | + else |
---|
| 8354 | + texturecache = bimtextures.get(texdata); |
---|
| 8355 | + } |
---|
| 8356 | + |
---|
| 8357 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8358 | + { |
---|
| 8359 | + TextureData texturedata = null; |
---|
| 8360 | + |
---|
| 8361 | + if (texdata != null) |
---|
| 8362 | + { |
---|
| 8363 | + BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8364 | + |
---|
| 8365 | + CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8366 | + |
---|
| 8367 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8368 | + bimtextures.put(texdata, texturecache); |
---|
| 8369 | + } |
---|
| 8370 | + else |
---|
| 8371 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
7231 | 8372 | { |
---|
7232 | 8373 | assert(!bump); |
---|
7233 | 8374 | // if (bump) |
---|
.. | .. |
---|
7238 | 8379 | // } |
---|
7239 | 8380 | // else |
---|
7240 | 8381 | // { |
---|
7241 | | - texture = textures.get(tex); |
---|
7242 | | - if (texture == null) |
---|
| 8382 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8383 | + if (texturecache == null) |
---|
7243 | 8384 | { |
---|
7244 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8385 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7245 | 8386 | } |
---|
| 8387 | + else |
---|
| 8388 | + new Exception().printStackTrace(); |
---|
7246 | 8389 | // } |
---|
7247 | 8390 | } else |
---|
7248 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8391 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7249 | 8392 | { |
---|
7250 | 8393 | assert(bump); |
---|
7251 | | - texture = textures.get(tex); |
---|
7252 | | - if (texture == null) |
---|
7253 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8394 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8395 | + if (texturecache == null) |
---|
| 8396 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8397 | + else |
---|
| 8398 | + new Exception().printStackTrace(); |
---|
7254 | 8399 | } else |
---|
7255 | 8400 | { |
---|
7256 | 8401 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7258 | 8403 | // texture = GetResourceTexture("default.png"); |
---|
7259 | 8404 | //} else |
---|
7260 | 8405 | //{ |
---|
7261 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8406 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7262 | 8407 | { |
---|
7263 | | - texture = textures.get(tex); |
---|
7264 | | - if (texture == null) |
---|
7265 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8408 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8409 | + if (texturecache == null) |
---|
| 8410 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8411 | + else |
---|
| 8412 | + new Exception().printStackTrace(); |
---|
7266 | 8413 | } else |
---|
7267 | 8414 | { |
---|
7268 | 8415 | if (textureon) |
---|
.. | .. |
---|
7287 | 8434 | } |
---|
7288 | 8435 | |
---|
7289 | 8436 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7290 | | - if (!new File(cachename).exists()) |
---|
| 8437 | + if (!FileExists(cachename)) |
---|
7291 | 8438 | cachename = texname; |
---|
7292 | 8439 | else |
---|
7293 | 8440 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7309 | 8456 | } |
---|
7310 | 8457 | |
---|
7311 | 8458 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7312 | | - if (!new File(cachename).exists()) |
---|
| 8459 | + if (!FileExists(cachename)) |
---|
7313 | 8460 | cachename = texname; |
---|
7314 | 8461 | else |
---|
7315 | 8462 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7318 | 8465 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7319 | 8466 | |
---|
7320 | 8467 | |
---|
7321 | | - if (texturedata != null) |
---|
7322 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8468 | + if (texturedata == null) |
---|
| 8469 | + throw new Exception(); |
---|
| 8470 | + |
---|
| 8471 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
7323 | 8472 | //texture = GetTexture(tex, bump); |
---|
7324 | 8473 | } |
---|
7325 | 8474 | } |
---|
7326 | 8475 | //} |
---|
7327 | 8476 | } |
---|
7328 | 8477 | |
---|
7329 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8478 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7330 | 8479 | { |
---|
7331 | 8480 | //return false; |
---|
7332 | 8481 | |
---|
7333 | 8482 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7334 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8483 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7335 | 8484 | { |
---|
7336 | 8485 | // String ext = "_highres"; |
---|
7337 | 8486 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7348 | 8497 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7349 | 8498 | if (!cachefile.exists()) |
---|
7350 | 8499 | { |
---|
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)) |
---|
| 8500 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7360 | 8501 | { |
---|
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); |
---|
| 8502 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8503 | + |
---|
7391 | 8504 | ImageWriter writer = null; |
---|
7392 | 8505 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7393 | 8506 | if (iter.hasNext()) { |
---|
7394 | 8507 | writer = (ImageWriter)iter.next(); |
---|
7395 | 8508 | } |
---|
7396 | | - float compressionQuality = 0.9f; |
---|
| 8509 | + |
---|
| 8510 | + float compressionQuality = 0.85f; |
---|
7397 | 8511 | try |
---|
7398 | 8512 | { |
---|
7399 | 8513 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7410 | 8524 | } |
---|
7411 | 8525 | } |
---|
7412 | 8526 | } |
---|
7413 | | - |
---|
| 8527 | + |
---|
| 8528 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8529 | + |
---|
7414 | 8530 | //System.out.println("Texture = " + tex); |
---|
7415 | | - if (textures.containsKey(texname)) |
---|
| 8531 | + if (textures.containsKey(tex)) |
---|
7416 | 8532 | { |
---|
7417 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8533 | + CacheTexture thetex = textures.get(tex); |
---|
7418 | 8534 | thetex.texture.disable(); |
---|
7419 | 8535 | thetex.texture.dispose(); |
---|
7420 | | - textures.remove(texname); |
---|
| 8536 | + textures.remove(tex); |
---|
7421 | 8537 | } |
---|
7422 | 8538 | |
---|
7423 | | - texture.texturedata = texturedata; |
---|
7424 | | - textures.put(texname, texture); |
---|
| 8539 | + //texture.texturedata = texturedata; |
---|
| 8540 | + textures.put(tex, texturecache); |
---|
7425 | 8541 | |
---|
7426 | 8542 | // newtex = true; |
---|
7427 | 8543 | } |
---|
.. | .. |
---|
7437 | 8553 | } |
---|
7438 | 8554 | } |
---|
7439 | 8555 | |
---|
7440 | | - return texture; |
---|
| 8556 | + return texturecache; |
---|
7441 | 8557 | } |
---|
7442 | 8558 | |
---|
7443 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8559 | + static void EmbedTextures(cTexture tex) |
---|
| 8560 | + { |
---|
| 8561 | + if (tex.pigmentdata == null) |
---|
| 8562 | + { |
---|
| 8563 | + String texname = Object3D.GetPigment(tex); |
---|
| 8564 | + |
---|
| 8565 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8566 | + |
---|
| 8567 | + if (texturecache != null) |
---|
| 8568 | + { |
---|
| 8569 | + tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8570 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8571 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8572 | + } |
---|
| 8573 | + } |
---|
| 8574 | + |
---|
| 8575 | + if (tex.bumpdata == null) |
---|
| 8576 | + { |
---|
| 8577 | + String texname = Object3D.GetBump(tex); |
---|
| 8578 | + |
---|
| 8579 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8580 | + |
---|
| 8581 | + if (texturecache != null) |
---|
| 8582 | + { |
---|
| 8583 | + tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8584 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8585 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8586 | + } |
---|
| 8587 | + } |
---|
| 8588 | + } |
---|
| 8589 | + |
---|
| 8590 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7444 | 8591 | { |
---|
7445 | 8592 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7446 | 8593 | |
---|
.. | .. |
---|
7458 | 8605 | return texture!=null?texture.texture:null; |
---|
7459 | 8606 | } |
---|
7460 | 8607 | |
---|
7461 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8608 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7462 | 8609 | { |
---|
7463 | 8610 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7464 | 8611 | |
---|
7465 | 8612 | return texture!=null?texture.texturedata:null; |
---|
7466 | 8613 | } |
---|
7467 | 8614 | |
---|
7468 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8615 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7469 | 8616 | { |
---|
7470 | 8617 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7471 | 8618 | { |
---|
7472 | 8619 | return false; |
---|
7473 | 8620 | } |
---|
7474 | 8621 | |
---|
7475 | | - boolean newtex = false; |
---|
| 8622 | + //boolean newtex = false; |
---|
7476 | 8623 | |
---|
7477 | 8624 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7478 | 8625 | |
---|
.. | .. |
---|
7504 | 8651 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7505 | 8652 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7506 | 8653 | |
---|
7507 | | - return newtex; |
---|
| 8654 | + return true; // Warning: not used. |
---|
7508 | 8655 | } |
---|
7509 | 8656 | |
---|
7510 | 8657 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
8342 | 9489 | jy8[3] = 0.5f; |
---|
8343 | 9490 | } |
---|
8344 | 9491 | |
---|
8345 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9492 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
8346 | 9493 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8347 | 9494 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8348 | 9495 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8349 | 9496 | |
---|
| 9497 | + void ResetOptions() |
---|
| 9498 | + { |
---|
| 9499 | + options1[0] = 100; |
---|
| 9500 | + options1[1] = 0.025f; |
---|
| 9501 | + options1[2] = 0.01f; |
---|
| 9502 | + options1[3] = 0; |
---|
| 9503 | + options1[4] = 0; |
---|
| 9504 | + |
---|
| 9505 | + options2[0] = 0; |
---|
| 9506 | + options2[1] = 0.75f; |
---|
| 9507 | + options2[2] = 0; |
---|
| 9508 | + options2[3] = 0; |
---|
| 9509 | + |
---|
| 9510 | + options3[0] = 1; |
---|
| 9511 | + options3[1] = 1; |
---|
| 9512 | + options3[2] = 1; |
---|
| 9513 | + options3[3] = 0; |
---|
| 9514 | + |
---|
| 9515 | + options4[0] = 1; |
---|
| 9516 | + options4[1] = 0; |
---|
| 9517 | + options4[2] = 1; |
---|
| 9518 | + options4[3] = 0; |
---|
| 9519 | + } |
---|
| 9520 | + |
---|
8350 | 9521 | static int imagecount = 0; // movie generation |
---|
8351 | 9522 | |
---|
8352 | 9523 | static int jitter = 0; |
---|
.. | .. |
---|
8442 | 9613 | assert (parentcam != renderCamera); |
---|
8443 | 9614 | |
---|
8444 | 9615 | if (renderCamera != lightCamera) |
---|
8445 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8446 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9616 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9617 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8447 | 9618 | |
---|
8448 | 9619 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8449 | 9620 | |
---|
.. | .. |
---|
8458 | 9629 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8459 | 9630 | |
---|
8460 | 9631 | if (renderCamera != lightCamera) |
---|
8461 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8462 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9632 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9633 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8463 | 9634 | |
---|
8464 | 9635 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8465 | 9636 | |
---|
.. | .. |
---|
8531 | 9702 | //gl.glFlush(); |
---|
8532 | 9703 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8533 | 9704 | |
---|
8534 | | - if (ANIMATION && ABORTED) |
---|
| 9705 | + if (Globals.ANIMATION && ABORTED) |
---|
8535 | 9706 | { |
---|
8536 | 9707 | System.err.println(" ABORTED FRAME"); |
---|
8537 | 9708 | break; |
---|
.. | .. |
---|
8561 | 9732 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8562 | 9733 | |
---|
8563 | 9734 | // save image |
---|
8564 | | - if (ANIMATION && !ABORTED) |
---|
| 9735 | + if (Globals.ANIMATION && !ABORTED) |
---|
8565 | 9736 | { |
---|
8566 | 9737 | VPwidth = viewport[2]; |
---|
8567 | 9738 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8672 | 9843 | |
---|
8673 | 9844 | // imagecount++; |
---|
8674 | 9845 | |
---|
8675 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9846 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
8676 | 9847 | |
---|
8677 | 9848 | if (!BOXMODE) |
---|
8678 | 9849 | { |
---|
8679 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9850 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
8680 | 9851 | } |
---|
8681 | 9852 | |
---|
8682 | 9853 | if (!BOXMODE) |
---|
.. | .. |
---|
8714 | 9885 | ABORTED = false; |
---|
8715 | 9886 | } |
---|
8716 | 9887 | else |
---|
8717 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9888 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8718 | 9889 | |
---|
8719 | 9890 | if (false) |
---|
8720 | 9891 | { |
---|
.. | .. |
---|
9377 | 10548 | |
---|
9378 | 10549 | public void display(GLAutoDrawable drawable) |
---|
9379 | 10550 | { |
---|
9380 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10551 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9381 | 10552 | { |
---|
9382 | | - GrafreeD.wav.save(); |
---|
9383 | | - GrafreeD.savesound = false; |
---|
9384 | | - GrafreeD.hassound = false; |
---|
| 10553 | + Grafreed.wav.save(); |
---|
| 10554 | + Grafreed.savesound = false; |
---|
| 10555 | + Grafreed.hassound = false; |
---|
9385 | 10556 | } |
---|
9386 | 10557 | // if (DEBUG_SELECTION) |
---|
9387 | 10558 | // { |
---|
.. | .. |
---|
9457 | 10628 | ANTIALIAS = 0; |
---|
9458 | 10629 | //System.out.println("RESTART"); |
---|
9459 | 10630 | AAtimer.restart(); |
---|
| 10631 | + Globals.TIMERRUNNING = true; |
---|
9460 | 10632 | } |
---|
9461 | 10633 | } |
---|
9462 | 10634 | } |
---|
.. | .. |
---|
9511 | 10683 | Object3D theobject = object; |
---|
9512 | 10684 | Object3D theparent = object.parent; |
---|
9513 | 10685 | object.parent = null; |
---|
9514 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10686 | + object = (Object3D)Grafreed.clone(object); |
---|
9515 | 10687 | object.Stripify(); |
---|
9516 | 10688 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9517 | 10689 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9524 | 10696 | ambientOcclusion = false; |
---|
9525 | 10697 | } |
---|
9526 | 10698 | |
---|
9527 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10699 | + if (//Globals.lighttouched && |
---|
| 10700 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9528 | 10701 | { |
---|
9529 | 10702 | //if (RENDERSHADOW) // ? |
---|
9530 | 10703 | if (!IsFrozen()) |
---|
9531 | 10704 | { |
---|
9532 | 10705 | // dec 2012 |
---|
9533 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10706 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9534 | 10707 | { |
---|
9535 | 10708 | Globals.framecount++; |
---|
9536 | 10709 | shadowbuffer.display(); |
---|
.. | .. |
---|
9657 | 10830 | |
---|
9658 | 10831 | // if (parentcam != renderCamera) // not a light |
---|
9659 | 10832 | if (cam != lightCamera) |
---|
9660 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9661 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10833 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10834 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9662 | 10835 | |
---|
9663 | 10836 | for (int j = 0; j < 4; j++) |
---|
9664 | 10837 | { |
---|
.. | .. |
---|
9672 | 10845 | |
---|
9673 | 10846 | // if (parentcam != renderCamera) // not a light |
---|
9674 | 10847 | if (cam != lightCamera) |
---|
9675 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9676 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10848 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10849 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9677 | 10850 | |
---|
9678 | 10851 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9679 | 10852 | |
---|
.. | .. |
---|
9932 | 11105 | // Bump noise |
---|
9933 | 11106 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9934 | 11107 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9935 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11108 | + |
---|
| 11109 | + try |
---|
| 11110 | + { |
---|
| 11111 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11112 | + } |
---|
| 11113 | + catch (Exception e) |
---|
| 11114 | + { |
---|
| 11115 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11116 | + } |
---|
| 11117 | + |
---|
9936 | 11118 | |
---|
9937 | 11119 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9938 | 11120 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9955 | 11137 | |
---|
9956 | 11138 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9957 | 11139 | |
---|
9958 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9959 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9960 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11140 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11141 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11142 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9961 | 11143 | } else |
---|
9962 | 11144 | { |
---|
9963 | 11145 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9968 | 11150 | //System.out.println("BLENDING ON"); |
---|
9969 | 11151 | gl.glEnable(GL.GL_BLEND); |
---|
9970 | 11152 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9971 | | - |
---|
| 11153 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9972 | 11154 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9973 | 11155 | gl.glLoadIdentity(); |
---|
9974 | 11156 | |
---|
.. | .. |
---|
10057 | 11239 | System.err.println("parentcam != renderCamera"); |
---|
10058 | 11240 | |
---|
10059 | 11241 | // if (cam != lightCamera) |
---|
10060 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10061 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11242 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11243 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10062 | 11244 | } |
---|
10063 | 11245 | |
---|
10064 | 11246 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10079 | 11261 | if (true) // TODO |
---|
10080 | 11262 | { |
---|
10081 | 11263 | if (cam != lightCamera) |
---|
10082 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10083 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11264 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11265 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10084 | 11266 | } |
---|
10085 | 11267 | |
---|
10086 | 11268 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10146 | 11328 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10147 | 11329 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10148 | 11330 | |
---|
10149 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11331 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10150 | 11332 | { |
---|
10151 | 11333 | /* |
---|
10152 | 11334 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10396 | 11578 | { |
---|
10397 | 11579 | renderpass++; |
---|
10398 | 11580 | // System.out.println("Draw object... "); |
---|
| 11581 | + STEP = 1; |
---|
10399 | 11582 | if (FAST) // in case there is no script |
---|
10400 | | - STEP = 16; |
---|
| 11583 | + STEP = 8; |
---|
| 11584 | + |
---|
| 11585 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11586 | + { |
---|
| 11587 | + STEP *= 4; |
---|
| 11588 | + } |
---|
10401 | 11589 | |
---|
10402 | 11590 | //object.FullInvariants(); |
---|
10403 | 11591 | |
---|
.. | .. |
---|
10411 | 11599 | e.printStackTrace(); |
---|
10412 | 11600 | } |
---|
10413 | 11601 | |
---|
10414 | | - if (GrafreeD.RENDERME > 0) |
---|
10415 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11602 | + if (Grafreed.RENDERME > 0) |
---|
| 11603 | + Grafreed.RENDERME--; // mechante magouille |
---|
10416 | 11604 | |
---|
10417 | 11605 | Globals.ONESTEP = false; |
---|
10418 | 11606 | } |
---|
10419 | 11607 | |
---|
10420 | 11608 | static boolean zoomonce = false; |
---|
10421 | 11609 | |
---|
| 11610 | + static void CreateSelectedPoint() |
---|
| 11611 | + { |
---|
| 11612 | + if (selectedpoint == null) |
---|
| 11613 | + { |
---|
| 11614 | + debugpointG = new Sphere(); |
---|
| 11615 | + debugpointP = new Sphere(); |
---|
| 11616 | + debugpointC = new Sphere(); |
---|
| 11617 | + debugpointR = new Sphere(); |
---|
| 11618 | + |
---|
| 11619 | + selectedpoint = new Superellipsoid(); |
---|
| 11620 | + |
---|
| 11621 | + for (int i=0; i<8; i++) |
---|
| 11622 | + { |
---|
| 11623 | + debugpoints[i] = new Sphere(); |
---|
| 11624 | + } |
---|
| 11625 | + } |
---|
| 11626 | + } |
---|
| 11627 | + |
---|
10422 | 11628 | void DrawObject(GL gl, boolean draw) |
---|
10423 | 11629 | { |
---|
| 11630 | + // To clear camera values |
---|
| 11631 | + ResetOptions(); |
---|
| 11632 | + |
---|
10424 | 11633 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10425 | 11634 | // DrawMode() = SELECTION; |
---|
10426 | 11635 | //GL gl = getGL(); |
---|
10427 | 11636 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10428 | 11637 | { |
---|
10429 | 11638 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10430 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11639 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10431 | 11640 | pingthread.StepToTarget(true); // true); |
---|
10432 | 11641 | // zoomonce = false; |
---|
10433 | 11642 | } |
---|
.. | .. |
---|
10447 | 11656 | callist = gl.glGenLists(1); |
---|
10448 | 11657 | } |
---|
10449 | 11658 | |
---|
10450 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11659 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10451 | 11660 | |
---|
10452 | 11661 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10453 | 11662 | |
---|
.. | .. |
---|
10482 | 11691 | |
---|
10483 | 11692 | usedtextures.clear(); |
---|
10484 | 11693 | |
---|
10485 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11694 | + try |
---|
| 11695 | + { |
---|
| 11696 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11697 | + } |
---|
| 11698 | + catch (Exception e) |
---|
| 11699 | + { |
---|
| 11700 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11701 | + } |
---|
10486 | 11702 | } |
---|
10487 | 11703 | //System.out.println("--> " + stackdepth); |
---|
10488 | 11704 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10492 | 11708 | |
---|
10493 | 11709 | if (DrawMode() == DEFAULT) |
---|
10494 | 11710 | { |
---|
10495 | | - if (DEBUG) |
---|
| 11711 | + if (Globals.DEBUG) |
---|
10496 | 11712 | { |
---|
| 11713 | + CreateSelectedPoint(); |
---|
10497 | 11714 | float radius = 0.05f; |
---|
10498 | 11715 | if (selectedpoint.radius != radius) |
---|
10499 | 11716 | { |
---|
.. | .. |
---|
10547 | 11764 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10548 | 11765 | |
---|
10549 | 11766 | if (CLEANCACHE) |
---|
10550 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11767 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10551 | 11768 | { |
---|
10552 | | - String tex = e.nextElement(); |
---|
| 11769 | + cTexture tex = e.nextElement(); |
---|
10553 | 11770 | |
---|
10554 | 11771 | // System.out.println("Texture --------- " + tex); |
---|
10555 | 11772 | |
---|
10556 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11773 | + if (tex.equals("WHITE_NOISE:")) |
---|
10557 | 11774 | continue; |
---|
10558 | 11775 | |
---|
10559 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11776 | + if (!usedtextures.contains(tex)) |
---|
10560 | 11777 | { |
---|
| 11778 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10561 | 11779 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10562 | | - textures.get(tex).texture.dispose(); |
---|
10563 | | - textures.remove(tex); |
---|
| 11780 | + if (gettex != null) |
---|
| 11781 | + { |
---|
| 11782 | + gettex.texture.dispose(); |
---|
| 11783 | + texturepigment.remove(tex); |
---|
| 11784 | + } |
---|
| 11785 | + |
---|
| 11786 | + gettex = texturebump.get(tex); |
---|
| 11787 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11788 | + if (gettex != null) |
---|
| 11789 | + { |
---|
| 11790 | + gettex.texture.dispose(); |
---|
| 11791 | + texturebump.remove(tex); |
---|
| 11792 | + } |
---|
10564 | 11793 | } |
---|
10565 | 11794 | } |
---|
10566 | 11795 | } |
---|
.. | .. |
---|
10573 | 11802 | if (checker != null && DrawMode() == DEFAULT) |
---|
10574 | 11803 | { |
---|
10575 | 11804 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10576 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11805 | + try |
---|
| 11806 | + { |
---|
| 11807 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11808 | + } |
---|
| 11809 | + catch (Exception e) |
---|
| 11810 | + { |
---|
| 11811 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11812 | + } |
---|
10577 | 11813 | // NEAREST |
---|
10578 | 11814 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10579 | 11815 | DrawChecker(gl); |
---|
.. | .. |
---|
10655 | 11891 | return; |
---|
10656 | 11892 | } |
---|
10657 | 11893 | |
---|
10658 | | - String string = obj.GetToolTip(); |
---|
| 11894 | + String string = obj.toString(); //.GetToolTip(); |
---|
10659 | 11895 | |
---|
10660 | 11896 | GL gl = GetGL(); |
---|
10661 | 11897 | |
---|
.. | .. |
---|
10972 | 12208 | //obj.TransformToWorld(light, light); |
---|
10973 | 12209 | for (int i = tp.size(); --i >= 0;) |
---|
10974 | 12210 | { |
---|
10975 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10976 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12211 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12212 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10977 | 12213 | } |
---|
10978 | 12214 | |
---|
10979 | 12215 | |
---|
.. | .. |
---|
10990 | 12226 | parentcam = cameras[0]; |
---|
10991 | 12227 | } |
---|
10992 | 12228 | |
---|
10993 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10994 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12229 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12230 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10995 | 12231 | |
---|
10996 | 12232 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10997 | 12233 | |
---|
.. | .. |
---|
11605 | 12841 | |
---|
11606 | 12842 | // display shadow only (bump == 0) |
---|
11607 | 12843 | "SUB temp.x, half.x, shadow.x;" + |
---|
11608 | | - "MOV temp.y, -params6.x;" + |
---|
11609 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12844 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12845 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
11610 | 12846 | "SUB temp.y, one.x, temp.z;" + |
---|
11611 | 12847 | "MUL temp.x, temp.x, temp.y;" + |
---|
11612 | 12848 | "KIL temp.x;" + |
---|
.. | .. |
---|
11735 | 12971 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11736 | 12972 | |
---|
11737 | 12973 | "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 |
---|
| 12974 | + // Tuning for default skin |
---|
| 12975 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12976 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 12977 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11740 | 12978 | "MUL temp.x, temp.x, temp.y;" + |
---|
11741 | 12979 | |
---|
11742 | 12980 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11935 | 13173 | //once = true; |
---|
11936 | 13174 | } |
---|
11937 | 13175 | |
---|
11938 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13176 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11939 | 13177 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11940 | 13178 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11941 | 13179 | |
---|
.. | .. |
---|
12068 | 13306 | |
---|
12069 | 13307 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12070 | 13308 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13309 | + |
---|
| 13310 | + // Compare fragment depth in light space with shadowmap. |
---|
12071 | 13311 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12072 | 13312 | "SGE temp.y, temp.x, zero.x;" + |
---|
12073 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13313 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13314 | + |
---|
| 13315 | + // Reverse comparison |
---|
12074 | 13316 | "SUB temp.x, one.x, temp.x;" + |
---|
12075 | 13317 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12076 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13318 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12077 | 13319 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12078 | 13320 | |
---|
12079 | 13321 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12087 | 13329 | // No shadow for backface |
---|
12088 | 13330 | "DP3 temp.x, normal, lightd;" + |
---|
12089 | 13331 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13332 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13333 | + |
---|
| 13334 | + // No shadow when out of frustrum |
---|
| 13335 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12090 | 13336 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12091 | 13337 | ""; |
---|
12092 | 13338 | } |
---|
.. | .. |
---|
12233 | 13479 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12234 | 13480 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12235 | 13481 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12236 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13482 | + |
---|
| 13483 | + //Object3D.cVector2[] vector2buffer; |
---|
12237 | 13484 | |
---|
12238 | 13485 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12239 | 13486 | // OUT : diff, spec |
---|
.. | .. |
---|
12249 | 13496 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12250 | 13497 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12251 | 13498 | //"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;" + |
---|
| 13499 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13500 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13501 | + |
---|
| 13502 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12255 | 13503 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12256 | 13504 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12257 | 13505 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12645 | 13893 | public void mousePressed(MouseEvent e) |
---|
12646 | 13894 | { |
---|
12647 | 13895 | //System.out.println("mousePressed: " + e); |
---|
12648 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13896 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12649 | 13897 | } |
---|
12650 | 13898 | |
---|
12651 | 13899 | static long prevtime = 0; |
---|
.. | .. |
---|
12672 | 13920 | |
---|
12673 | 13921 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12674 | 13922 | |
---|
| 13923 | + if (BUTTONLESSWHEEL) |
---|
12675 | 13924 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12676 | 13925 | { |
---|
12677 | 13926 | return; |
---|
.. | .. |
---|
12680 | 13929 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12681 | 13930 | |
---|
12682 | 13931 | // TIMER |
---|
12683 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 13932 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12684 | 13933 | { |
---|
12685 | 13934 | keepboxmode = BOXMODE; |
---|
12686 | 13935 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12720 | 13969 | // mode |= META; |
---|
12721 | 13970 | //} |
---|
12722 | 13971 | |
---|
12723 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12724 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 13972 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 13973 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12725 | 13974 | anchorX = ax; |
---|
12726 | 13975 | anchorY = ay; |
---|
12727 | 13976 | prevX = px; |
---|
.. | .. |
---|
12755 | 14004 | else |
---|
12756 | 14005 | if (evt.getSource() == AAtimer) |
---|
12757 | 14006 | { |
---|
| 14007 | + Globals.TIMERRUNNING = false; |
---|
12758 | 14008 | if (mouseDown) |
---|
12759 | 14009 | { |
---|
12760 | 14010 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12780 | 14030 | // LIVE = waslive; |
---|
12781 | 14031 | // wasliveok = true; |
---|
12782 | 14032 | // waslive = false; |
---|
| 14033 | + |
---|
| 14034 | + // May 2019 Forget it: |
---|
| 14035 | + if (true) |
---|
| 14036 | + return; |
---|
12783 | 14037 | |
---|
12784 | 14038 | // source == timer |
---|
12785 | 14039 | if (mouseDown) |
---|
.. | .. |
---|
12810 | 14064 | |
---|
12811 | 14065 | // fev 2014??? |
---|
12812 | 14066 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12813 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14067 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12814 | 14068 | pingthread.StepToTarget(true); // true); |
---|
12815 | 14069 | } |
---|
12816 | 14070 | // if (!LIVE) |
---|
.. | .. |
---|
12819 | 14073 | |
---|
12820 | 14074 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12821 | 14075 | |
---|
12822 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14076 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12823 | 14077 | { |
---|
12824 | 14078 | if (!wasliveok) |
---|
12825 | 14079 | return; |
---|
12826 | 14080 | |
---|
12827 | 14081 | AAtimer.restart(); // |
---|
| 14082 | + Globals.TIMERRUNNING = true; |
---|
12828 | 14083 | |
---|
12829 | 14084 | // waslive = LIVE; |
---|
12830 | 14085 | // LIVE = false; |
---|
.. | .. |
---|
12836 | 14091 | // touched = true; // main DL |
---|
12837 | 14092 | if (isRenderer) |
---|
12838 | 14093 | { |
---|
12839 | | - SetMouseMode(modifiers); |
---|
| 14094 | + SetMouseMode(modifiers, modifiersex); |
---|
12840 | 14095 | } |
---|
12841 | 14096 | |
---|
12842 | 14097 | selectX = anchorX = x; |
---|
.. | .. |
---|
12849 | 14104 | clicked = true; |
---|
12850 | 14105 | hold = false; |
---|
12851 | 14106 | |
---|
12852 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14107 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12853 | 14108 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12854 | 14109 | { |
---|
12855 | 14110 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12880 | 14135 | info.camera = renderCamera; |
---|
12881 | 14136 | info.x = x; |
---|
12882 | 14137 | info.y = y; |
---|
12883 | | - info.modifiers = modifiers; |
---|
| 14138 | + info.modifiers = modifiersex; |
---|
12884 | 14139 | editObj = object.doEditClick(info, 0); |
---|
12885 | 14140 | if (!editObj) |
---|
12886 | 14141 | { |
---|
.. | .. |
---|
12897 | 14152 | |
---|
12898 | 14153 | public void mouseDragged(MouseEvent e) |
---|
12899 | 14154 | { |
---|
| 14155 | + Globals.MOUSEDRAGGED = true; |
---|
| 14156 | + |
---|
| 14157 | + //System.out.println("mouseDragged: " + e); |
---|
12900 | 14158 | if (isRenderer) |
---|
12901 | 14159 | movingcamera = true; |
---|
| 14160 | + |
---|
12902 | 14161 | //if (drawing) |
---|
12903 | 14162 | //return; |
---|
12904 | | - //System.out.println("mouseDragged: " + e); |
---|
12905 | 14163 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12906 | 14164 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12907 | 14165 | { |
---|
.. | .. |
---|
12909 | 14167 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12910 | 14168 | } |
---|
12911 | 14169 | else |
---|
12912 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14170 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12913 | 14171 | |
---|
12914 | 14172 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12915 | 14173 | } |
---|
.. | .. |
---|
12921 | 14179 | cVector tmp = new cVector(); |
---|
12922 | 14180 | cVector tmp2 = new cVector(); |
---|
12923 | 14181 | boolean isMoving; |
---|
| 14182 | + |
---|
| 14183 | + public cVector TargetLookAt() |
---|
| 14184 | + { |
---|
| 14185 | + return targetLookAt; |
---|
| 14186 | + } |
---|
12924 | 14187 | |
---|
12925 | 14188 | class PingThread extends Thread |
---|
12926 | 14189 | { |
---|
.. | .. |
---|
13077 | 14340 | |
---|
13078 | 14341 | public void run() |
---|
13079 | 14342 | { |
---|
| 14343 | + new Exception().printStackTrace(); |
---|
13080 | 14344 | System.exit(0); |
---|
13081 | 14345 | for (;;) |
---|
13082 | 14346 | { |
---|
.. | .. |
---|
13140 | 14404 | { |
---|
13141 | 14405 | Globals.lighttouched = true; |
---|
13142 | 14406 | } |
---|
13143 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14407 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13144 | 14408 | } |
---|
13145 | 14409 | //else |
---|
13146 | 14410 | } |
---|
.. | .. |
---|
13154 | 14418 | void GoDown(int mod) |
---|
13155 | 14419 | { |
---|
13156 | 14420 | MODIFIERS |= COMMAND; |
---|
13157 | | - /* |
---|
| 14421 | + /**/ |
---|
13158 | 14422 | if((mod&SHIFT) == SHIFT) |
---|
13159 | 14423 | manipCamera.RotatePosition(0, -speed); |
---|
13160 | 14424 | else |
---|
13161 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13162 | | - */ |
---|
| 14425 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14426 | + /**/ |
---|
13163 | 14427 | if ((mod & SHIFT) == SHIFT) |
---|
13164 | 14428 | { |
---|
13165 | 14429 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13175 | 14439 | void GoUp(int mod) |
---|
13176 | 14440 | { |
---|
13177 | 14441 | MODIFIERS |= COMMAND; |
---|
13178 | | - /* |
---|
| 14442 | + /**/ |
---|
13179 | 14443 | if((mod&SHIFT) == SHIFT) |
---|
13180 | 14444 | manipCamera.RotatePosition(0, speed); |
---|
13181 | 14445 | else |
---|
13182 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13183 | | - */ |
---|
| 14446 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14447 | + /**/ |
---|
13184 | 14448 | if ((mod & SHIFT) == SHIFT) |
---|
13185 | 14449 | { |
---|
13186 | 14450 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13196 | 14460 | void GoLeft(int mod) |
---|
13197 | 14461 | { |
---|
13198 | 14462 | MODIFIERS |= COMMAND; |
---|
13199 | | - /* |
---|
| 14463 | + /**/ |
---|
13200 | 14464 | if((mod&SHIFT) == SHIFT) |
---|
13201 | | - manipCamera.RotatePosition(speed, 0); |
---|
13202 | | - else |
---|
13203 | 14465 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13204 | | - */ |
---|
| 14466 | + else |
---|
| 14467 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14468 | + /**/ |
---|
13205 | 14469 | if ((mod & SHIFT) == SHIFT) |
---|
13206 | 14470 | { |
---|
13207 | 14471 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13217 | 14481 | void GoRight(int mod) |
---|
13218 | 14482 | { |
---|
13219 | 14483 | MODIFIERS |= COMMAND; |
---|
13220 | | - /* |
---|
| 14484 | + /**/ |
---|
13221 | 14485 | if((mod&SHIFT) == SHIFT) |
---|
13222 | | - manipCamera.RotatePosition(-speed, 0); |
---|
13223 | | - else |
---|
13224 | 14486 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13225 | | - */ |
---|
| 14487 | + else |
---|
| 14488 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14489 | + /**/ |
---|
13226 | 14490 | if ((mod & SHIFT) == SHIFT) |
---|
13227 | 14491 | { |
---|
13228 | 14492 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13240 | 14504 | int X, Y; |
---|
13241 | 14505 | boolean SX, SY; |
---|
13242 | 14506 | |
---|
13243 | | - void drag(int x, int y, int modifiers) |
---|
| 14507 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13244 | 14508 | { |
---|
13245 | 14509 | if (IsFrozen()) |
---|
13246 | 14510 | { |
---|
.. | .. |
---|
13249 | 14513 | |
---|
13250 | 14514 | drag = true; // NEW |
---|
13251 | 14515 | |
---|
13252 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14516 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13253 | 14517 | |
---|
13254 | 14518 | X = x; |
---|
13255 | 14519 | Y = y; |
---|
13256 | 14520 | // floating state for animation |
---|
13257 | | - MODIFIERS = modifiers; |
---|
13258 | | - modifiers &= ~1024; |
---|
| 14521 | + MODIFIERS = modifiersex; |
---|
| 14522 | + modifiersex &= ~1024; |
---|
13259 | 14523 | if (false) // modifiers != 0) |
---|
13260 | 14524 | { |
---|
13261 | 14525 | //new Exception().printStackTrace(); |
---|
13262 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14526 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13263 | 14527 | System.out.println("SHIFT = " + SHIFT); |
---|
13264 | 14528 | System.out.println("CONTROL = " + COMMAND); |
---|
13265 | 14529 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13279 | 14543 | info.camera = renderCamera; |
---|
13280 | 14544 | info.x = x; |
---|
13281 | 14545 | info.y = y; |
---|
13282 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14546 | + object.GetWindow().copy |
---|
| 14547 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13283 | 14548 | } else |
---|
13284 | 14549 | { |
---|
13285 | 14550 | if (x < startX) |
---|
.. | .. |
---|
13431 | 14696 | public void mouseMoved(MouseEvent e) |
---|
13432 | 14697 | { |
---|
13433 | 14698 | //System.out.println("mouseMoved: " + e); |
---|
13434 | | - |
---|
13435 | 14699 | if (isRenderer) |
---|
13436 | 14700 | return; |
---|
13437 | 14701 | |
---|
.. | .. |
---|
13444 | 14708 | ci.camera = renderCamera; |
---|
13445 | 14709 | if (!isRenderer) |
---|
13446 | 14710 | { |
---|
13447 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14711 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14712 | + //Object3D copy = editWindow.copy; |
---|
| 14713 | + if (object.doEditClick(ci, 0)) |
---|
13448 | 14714 | { |
---|
13449 | 14715 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13450 | 14716 | } else |
---|
.. | .. |
---|
13456 | 14722 | |
---|
13457 | 14723 | public void mouseReleased(MouseEvent e) |
---|
13458 | 14724 | { |
---|
| 14725 | + Globals.MOUSEDRAGGED = false; |
---|
| 14726 | + |
---|
13459 | 14727 | movingcamera = false; |
---|
| 14728 | + X = 0; // getBounds().width/2; |
---|
| 14729 | + Y = 0; // getBounds().height/2; |
---|
13460 | 14730 | //System.out.println("mouseReleased: " + e); |
---|
13461 | 14731 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13462 | 14732 | } |
---|
.. | .. |
---|
13479 | 14749 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13480 | 14750 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13481 | 14751 | |
---|
13482 | | - if (control || command || IsFrozen()) |
---|
| 14752 | +// No delay if (control || command || IsFrozen()) |
---|
13483 | 14753 | timeout = true; |
---|
13484 | | - else |
---|
| 14754 | +// ?? May 2019 else |
---|
13485 | 14755 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13486 | 14756 | mouseDown = false; |
---|
13487 | 14757 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13591 | 14861 | System.out.println("keyReleased: " + e); |
---|
13592 | 14862 | } |
---|
13593 | 14863 | |
---|
13594 | | - void SetMouseMode(int modifiers) |
---|
| 14864 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13595 | 14865 | { |
---|
13596 | 14866 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13597 | 14867 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13603 | 14873 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13604 | 14874 | // return; |
---|
13605 | 14875 | //System.out.println("SetMode = " + modifiers); |
---|
13606 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14876 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13607 | 14877 | { |
---|
13608 | 14878 | mouseMode |= ZOOM; |
---|
13609 | 14879 | } |
---|
13610 | 14880 | |
---|
13611 | 14881 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13612 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14882 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13613 | 14883 | { |
---|
13614 | 14884 | mouseMode |= VR; // BACKFORTH; |
---|
13615 | 14885 | } |
---|
13616 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14886 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13617 | 14887 | { |
---|
13618 | 14888 | mouseMode |= SELECT; |
---|
13619 | 14889 | } |
---|
13620 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14890 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13621 | 14891 | { |
---|
13622 | 14892 | mouseMode |= SELECT; |
---|
13623 | 14893 | } |
---|
13624 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14894 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13625 | 14895 | { |
---|
13626 | 14896 | mouseMode &= ~VR; |
---|
13627 | 14897 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13650 | 14920 | |
---|
13651 | 14921 | if (isRenderer) // |
---|
13652 | 14922 | { |
---|
13653 | | - SetMouseMode(modifiers); |
---|
| 14923 | + SetMouseMode(0, modifiers); |
---|
13654 | 14924 | } |
---|
13655 | 14925 | |
---|
13656 | | - theRenderer.keyPressed(key); |
---|
| 14926 | + Globals.theRenderer.keyPressed(key); |
---|
13657 | 14927 | } |
---|
13658 | 14928 | |
---|
13659 | 14929 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13665 | 14935 | float SATPOW = 1; // 2; // 0.5f; |
---|
13666 | 14936 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13667 | 14937 | |
---|
13668 | | - void keyPressed(int key) |
---|
| 14938 | + public void keyPressed(int key) |
---|
13669 | 14939 | { |
---|
13670 | 14940 | if (key >= '0' && key <= '5') |
---|
13671 | 14941 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13712 | 14982 | // break; |
---|
13713 | 14983 | case 'T': |
---|
13714 | 14984 | CACHETEXTURE ^= true; |
---|
13715 | | - textures.clear(); |
---|
| 14985 | + texturepigment.clear(); |
---|
| 14986 | + texturebump.clear(); |
---|
13716 | 14987 | // repaint(); |
---|
13717 | 14988 | break; |
---|
13718 | 14989 | case 'Y': |
---|
.. | .. |
---|
13797 | 15068 | case 'E' : COMPACT ^= true; |
---|
13798 | 15069 | repaint(); |
---|
13799 | 15070 | break; |
---|
13800 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15071 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15072 | + //DEBUGHSB ^= true; |
---|
| 15073 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13801 | 15074 | repaint(); |
---|
13802 | 15075 | break; |
---|
13803 | 15076 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13822 | 15095 | RevertCamera(); |
---|
13823 | 15096 | repaint(); |
---|
13824 | 15097 | break; |
---|
13825 | | - case 'L': |
---|
13826 | 15098 | case 'l': |
---|
| 15099 | + //case 'L': |
---|
13827 | 15100 | if (lightMode) |
---|
13828 | 15101 | { |
---|
13829 | 15102 | lightMode = false; |
---|
.. | .. |
---|
13966 | 15239 | case '_': |
---|
13967 | 15240 | kompactbit = 5; |
---|
13968 | 15241 | break; |
---|
13969 | | - case '+': |
---|
13970 | | - kompactbit = 6; |
---|
13971 | | - break; |
---|
| 15242 | +// case '+': |
---|
| 15243 | +// kompactbit = 6; |
---|
| 15244 | +// break; |
---|
13972 | 15245 | case ' ': |
---|
13973 | 15246 | lightMode ^= true; |
---|
13974 | 15247 | Globals.lighttouched = true; |
---|
.. | .. |
---|
13980 | 15253 | case ESC: |
---|
13981 | 15254 | RENDERPROGRAM += 1; |
---|
13982 | 15255 | RENDERPROGRAM %= 3; |
---|
| 15256 | + |
---|
13983 | 15257 | repaint(); |
---|
13984 | 15258 | break; |
---|
13985 | 15259 | case 'Z': |
---|
13986 | 15260 | //RESIZETEXTURE ^= true; |
---|
13987 | 15261 | //break; |
---|
13988 | 15262 | case 'z': |
---|
13989 | | - RENDERSHADOW ^= true; |
---|
| 15263 | + Globals.RENDERSHADOW ^= true; |
---|
13990 | 15264 | Globals.lighttouched = true; |
---|
13991 | 15265 | repaint(); |
---|
13992 | 15266 | break; |
---|
.. | .. |
---|
14019 | 15293 | case DELETE: |
---|
14020 | 15294 | ClearSelection(); |
---|
14021 | 15295 | break; |
---|
14022 | | - /* |
---|
14023 | 15296 | case '+': |
---|
| 15297 | + |
---|
| 15298 | + /* |
---|
14024 | 15299 | //fontsize += 1; |
---|
14025 | 15300 | bbzoom *= 2; |
---|
14026 | 15301 | repaint(); |
---|
.. | .. |
---|
14037 | 15312 | case '=': |
---|
14038 | 15313 | IncDepth(); |
---|
14039 | 15314 | //fontsize += 1; |
---|
14040 | | - object.editWindow.refreshContents(true); |
---|
| 15315 | + object.GetWindow().refreshContents(true); |
---|
14041 | 15316 | maskbit = 6; |
---|
14042 | 15317 | break; |
---|
14043 | 15318 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14044 | 15319 | DecDepth(); |
---|
14045 | 15320 | maskbit = 5; |
---|
14046 | 15321 | //if(fontsize > 1) fontsize -= 1; |
---|
14047 | | - if (object.editWindow == null) |
---|
14048 | | - new Exception().printStackTrace(); |
---|
14049 | | - else |
---|
14050 | | - object.editWindow.refreshContents(true); |
---|
| 15322 | +// if (object.editWindow == null) |
---|
| 15323 | +// new Exception().printStackTrace(); |
---|
| 15324 | +// else |
---|
| 15325 | + object.GetWindow().refreshContents(true); |
---|
14051 | 15326 | break; |
---|
14052 | 15327 | case '{': |
---|
14053 | 15328 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14102 | 15377 | } |
---|
14103 | 15378 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14104 | 15379 | } |
---|
| 15380 | + |
---|
14105 | 15381 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14106 | 15382 | |
---|
14107 | 15383 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14109 | 15385 | //mode = ROTATE; |
---|
14110 | 15386 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14111 | 15387 | { |
---|
14112 | | - SetMouseMode(modifiers); |
---|
| 15388 | + SetMouseMode(0, modifiers); |
---|
14113 | 15389 | } |
---|
14114 | 15390 | } |
---|
14115 | 15391 | |
---|
14116 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15392 | + public void processKeyEvent(KeyEvent e) |
---|
14117 | 15393 | { |
---|
14118 | 15394 | switch (e.getID()) |
---|
14119 | 15395 | { |
---|
.. | .. |
---|
14243 | 15519 | |
---|
14244 | 15520 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14245 | 15521 | { |
---|
14246 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14247 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15522 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15523 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15524 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14248 | 15525 | { |
---|
14249 | 15526 | mouseMoved(e); |
---|
14250 | 15527 | } else |
---|
.. | .. |
---|
14269 | 15546 | } |
---|
14270 | 15547 | */ |
---|
14271 | 15548 | |
---|
14272 | | - object.editWindow.EditSelection(); |
---|
| 15549 | + object.GetWindow().EditSelection(false); |
---|
14273 | 15550 | } |
---|
14274 | 15551 | |
---|
14275 | 15552 | void SelectParent() |
---|
14276 | 15553 | { |
---|
| 15554 | + new Exception().printStackTrace(); |
---|
14277 | 15555 | System.exit(0); |
---|
14278 | 15556 | Composite group = (Composite) object; |
---|
14279 | 15557 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14285 | 15563 | { |
---|
14286 | 15564 | //selectees.remove(i); |
---|
14287 | 15565 | System.out.println("select parent of " + elem); |
---|
14288 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15566 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14289 | 15567 | } else |
---|
14290 | 15568 | { |
---|
14291 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15569 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14292 | 15570 | } |
---|
14293 | 15571 | |
---|
14294 | 15572 | first = false; |
---|
.. | .. |
---|
14297 | 15575 | |
---|
14298 | 15576 | void SelectChildren() |
---|
14299 | 15577 | { |
---|
| 15578 | + new Exception().printStackTrace(); |
---|
14300 | 15579 | System.exit(0); |
---|
14301 | 15580 | /* |
---|
14302 | 15581 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14329 | 15608 | for (int j = 0; j < group.children.size(); j++) |
---|
14330 | 15609 | { |
---|
14331 | 15610 | elem = (Object3D) group.children.elementAt(j); |
---|
14332 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15611 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14333 | 15612 | first = false; |
---|
14334 | 15613 | } |
---|
14335 | 15614 | } else |
---|
14336 | 15615 | { |
---|
14337 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15616 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14338 | 15617 | } |
---|
14339 | 15618 | |
---|
14340 | 15619 | first = false; |
---|
.. | .. |
---|
14345 | 15624 | { |
---|
14346 | 15625 | //Composite group = (Composite) object; |
---|
14347 | 15626 | Object3D group = object; |
---|
14348 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15627 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14349 | 15628 | } |
---|
14350 | 15629 | |
---|
14351 | 15630 | void ResetTransform(int mask) |
---|
14352 | 15631 | { |
---|
14353 | 15632 | //Composite group = (Composite) object; |
---|
14354 | 15633 | Object3D group = object; |
---|
14355 | | - group.editWindow.ResetTransform(mask); |
---|
| 15634 | + group.GetWindow().ResetTransform(mask); |
---|
14356 | 15635 | } |
---|
14357 | 15636 | |
---|
14358 | 15637 | void FlipTransform() |
---|
14359 | 15638 | { |
---|
14360 | 15639 | //Composite group = (Composite) object; |
---|
14361 | 15640 | Object3D group = object; |
---|
14362 | | - group.editWindow.FlipTransform(); |
---|
| 15641 | + group.GetWindow().FlipTransform(); |
---|
14363 | 15642 | // group.editWindow.ReduceMesh(true); |
---|
14364 | 15643 | } |
---|
14365 | 15644 | |
---|
.. | .. |
---|
14367 | 15646 | { |
---|
14368 | 15647 | //Composite group = (Composite) object; |
---|
14369 | 15648 | Object3D group = object; |
---|
14370 | | - group.editWindow.PrintMemory(); |
---|
| 15649 | + group.GetWindow().PrintMemory(); |
---|
14371 | 15650 | // group.editWindow.ReduceMesh(true); |
---|
14372 | 15651 | } |
---|
14373 | 15652 | |
---|
.. | .. |
---|
14375 | 15654 | { |
---|
14376 | 15655 | //Composite group = (Composite) object; |
---|
14377 | 15656 | Object3D group = object; |
---|
14378 | | - group.editWindow.ResetCentroid(); |
---|
| 15657 | + group.GetWindow().ResetCentroid(); |
---|
14379 | 15658 | } |
---|
14380 | 15659 | |
---|
14381 | 15660 | void IncDepth() |
---|
.. | .. |
---|
14461 | 15740 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14462 | 15741 | //Image img = CreateImage(width, height); |
---|
14463 | 15742 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15743 | + |
---|
14464 | 15744 | Graphics gr = g; // img.getGraphics(); |
---|
| 15745 | + |
---|
14465 | 15746 | if (!hasMarquee) |
---|
14466 | 15747 | { |
---|
14467 | 15748 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14549 | 15830 | info.bounds.y += (height - desired) / 2; |
---|
14550 | 15831 | } |
---|
14551 | 15832 | } |
---|
| 15833 | + |
---|
14552 | 15834 | info.g = gr; |
---|
14553 | 15835 | info.camera = renderCamera; |
---|
14554 | 15836 | /* |
---|
.. | .. |
---|
14558 | 15840 | */ |
---|
14559 | 15841 | if (!isRenderer) |
---|
14560 | 15842 | { |
---|
14561 | | - object.drawEditHandles(info, 0); |
---|
| 15843 | + Grafreed.Assert(object != null); |
---|
| 15844 | + Grafreed.Assert(object.selection != null); |
---|
| 15845 | + if (object.selection.Size() > 0) |
---|
| 15846 | + { |
---|
| 15847 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15848 | + |
---|
| 15849 | + info.DX = 0; |
---|
| 15850 | + info.DY = 0; |
---|
| 15851 | + info.W = 1; |
---|
| 15852 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15853 | + { |
---|
| 15854 | + info.DX = X; |
---|
| 15855 | + if (X != 0) |
---|
| 15856 | + info.DX -= info.bounds.width/2; |
---|
| 15857 | + |
---|
| 15858 | + info.DY = Y; |
---|
| 15859 | + if (Y != 0) |
---|
| 15860 | + info.DY -= info.bounds.height/2; |
---|
| 15861 | + } |
---|
| 15862 | + |
---|
| 15863 | + object.drawEditHandles(info, 0); |
---|
| 15864 | + |
---|
| 15865 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15866 | + { |
---|
| 15867 | + switch (hitSomething) |
---|
| 15868 | + { |
---|
| 15869 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15870 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15871 | + break; |
---|
| 15872 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15873 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15874 | + break; |
---|
| 15875 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15876 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15877 | + break; |
---|
| 15878 | + } |
---|
| 15879 | + |
---|
| 15880 | + } |
---|
| 15881 | + } |
---|
14562 | 15882 | } |
---|
14563 | 15883 | } |
---|
| 15884 | + |
---|
14564 | 15885 | if (isRenderer) |
---|
14565 | 15886 | { |
---|
14566 | 15887 | //gr.setColor(Color.black); |
---|
14567 | 15888 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14568 | 15889 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14569 | 15890 | } |
---|
| 15891 | + |
---|
14570 | 15892 | if (hasMarquee) |
---|
14571 | 15893 | { |
---|
14572 | 15894 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
14679 | 16001 | public boolean mouseDown(Event evt, int x, int y) |
---|
14680 | 16002 | { |
---|
14681 | 16003 | System.out.println("mouseDown: " + evt); |
---|
| 16004 | + System.exit(0); |
---|
14682 | 16005 | /* |
---|
14683 | 16006 | locked = true; |
---|
14684 | 16007 | drag = false; |
---|
.. | .. |
---|
14722 | 16045 | { |
---|
14723 | 16046 | keyPressed(0, modifiers); |
---|
14724 | 16047 | } |
---|
14725 | | - clickStart(x, y, modifiers); |
---|
| 16048 | + // clickStart(x, y, modifiers); |
---|
14726 | 16049 | return true; |
---|
14727 | 16050 | } |
---|
14728 | 16051 | |
---|
.. | .. |
---|
14840 | 16163 | { |
---|
14841 | 16164 | keyReleased(0, 0); |
---|
14842 | 16165 | } |
---|
14843 | | - drag(x, y, modifiers); |
---|
| 16166 | + drag(x, y, 0, modifiers); |
---|
14844 | 16167 | return true; |
---|
14845 | 16168 | } |
---|
14846 | 16169 | |
---|
.. | .. |
---|
14972 | 16295 | Object3D object; |
---|
14973 | 16296 | static Object3D trackedobject; |
---|
14974 | 16297 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14975 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16298 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14976 | 16299 | /*static*/ Camera eyeCamera; |
---|
14977 | 16300 | /*static*/ Camera lightCamera; |
---|
14978 | 16301 | int cameracount; |
---|
.. | .. |
---|
15257 | 16580 | cStatic.objectstack[materialdepth++] = checker; |
---|
15258 | 16581 | //System.out.println("material " + material); |
---|
15259 | 16582 | //Applet3D.tracein(this, selected); |
---|
15260 | | - vector2buffer = checker.projectedVertices; |
---|
| 16583 | + //vector2buffer = checker.projectedVertices; |
---|
15261 | 16584 | |
---|
15262 | 16585 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15263 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16586 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15264 | 16587 | |
---|
15265 | 16588 | materialdepth -= 1; |
---|
15266 | 16589 | if (materialdepth > 0) |
---|
15267 | 16590 | { |
---|
15268 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15269 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16591 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16592 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15270 | 16593 | } |
---|
15271 | 16594 | //checker.GetMaterial().opacity = 1f; |
---|
15272 | 16595 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15352 | 16675 | } |
---|
15353 | 16676 | } |
---|
15354 | 16677 | |
---|
| 16678 | + private Object3D GetFolder() |
---|
| 16679 | + { |
---|
| 16680 | + Object3D folder = object.GetWindow().copy; |
---|
| 16681 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16682 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16683 | + return folder; |
---|
| 16684 | + } |
---|
| 16685 | + |
---|
15355 | 16686 | class SelectBuffer implements GLEventListener |
---|
15356 | 16687 | { |
---|
15357 | 16688 | |
---|
.. | .. |
---|
15410 | 16741 | { |
---|
15411 | 16742 | if (!selection) |
---|
15412 | 16743 | { |
---|
| 16744 | + new Exception().printStackTrace(); |
---|
15413 | 16745 | System.exit(0); |
---|
15414 | 16746 | return; |
---|
15415 | 16747 | } |
---|
.. | .. |
---|
15430 | 16762 | |
---|
15431 | 16763 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15432 | 16764 | |
---|
| 16765 | + if (PAINTMODE) |
---|
| 16766 | + { |
---|
| 16767 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16768 | + { |
---|
| 16769 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16770 | + |
---|
| 16771 | + // Make what you paint not selectable. |
---|
| 16772 | + paintobj.ResetSelectable(); |
---|
| 16773 | + } |
---|
| 16774 | + } |
---|
| 16775 | + |
---|
15433 | 16776 | //int tmp = selection_view; |
---|
15434 | 16777 | //selection_view = -1; |
---|
15435 | 16778 | int temp = DrawMode(); |
---|
.. | .. |
---|
15441 | 16784 | // temp = DEFAULT; // patch for selection debug |
---|
15442 | 16785 | Globals.drawMode = temp; // WARNING |
---|
15443 | 16786 | |
---|
| 16787 | + if (PAINTMODE) |
---|
| 16788 | + { |
---|
| 16789 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16790 | + { |
---|
| 16791 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16792 | + |
---|
| 16793 | + // Revert. |
---|
| 16794 | + paintobj.RestoreSelectable(); |
---|
| 16795 | + } |
---|
| 16796 | + } |
---|
| 16797 | + |
---|
15444 | 16798 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15445 | 16799 | |
---|
15446 | 16800 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15488 | 16842 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15489 | 16843 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15490 | 16844 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16845 | + |
---|
| 16846 | + CreateSelectedPoint(); |
---|
15491 | 16847 | |
---|
15492 | 16848 | // Will fit the mesh !!! |
---|
15493 | 16849 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15537 | 16893 | 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 | 16894 | } |
---|
15539 | 16895 | |
---|
15540 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16896 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15541 | 16897 | } |
---|
15542 | 16898 | } |
---|
15543 | 16899 | |
---|
15544 | 16900 | if (!movingcamera && !PAINTMODE) |
---|
15545 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16901 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15546 | 16902 | |
---|
15547 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16903 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15548 | 16904 | { |
---|
15549 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16905 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15550 | 16906 | |
---|
15551 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16907 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16908 | + { |
---|
| 16909 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15552 | 16910 | |
---|
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(); |
---|
| 16911 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16912 | + |
---|
| 16913 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16914 | + |
---|
| 16915 | + inst.add(paintobj); // link |
---|
| 16916 | + |
---|
| 16917 | + object.GetWindow().SnapObject(inst); |
---|
| 16918 | + |
---|
| 16919 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16920 | + |
---|
| 16921 | + folder.add(inst); |
---|
| 16922 | + |
---|
| 16923 | + object.GetWindow().ResetModel(); |
---|
| 16924 | + object.GetWindow().refreshContents(); |
---|
| 16925 | + } |
---|
15568 | 16926 | } |
---|
15569 | 16927 | else |
---|
15570 | 16928 | paintcount = 0; |
---|
.. | .. |
---|
15603 | 16961 | //System.out.println("objects[color] = " + objects[color]); |
---|
15604 | 16962 | //objects[color].Select(); |
---|
15605 | 16963 | indexcount = 0; |
---|
| 16964 | + ObjEditor window = object.GetWindow(); |
---|
| 16965 | + if (window != null && deselect) |
---|
| 16966 | + { |
---|
| 16967 | + window.Select(null, deselect, true); |
---|
| 16968 | + } |
---|
15606 | 16969 | object.Select(color, deselect); |
---|
15607 | 16970 | } |
---|
15608 | 16971 | |
---|
.. | .. |
---|
15702 | 17065 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15703 | 17066 | } |
---|
15704 | 17067 | |
---|
15705 | | - if (!RENDERSHADOW) |
---|
| 17068 | + if (!Globals.RENDERSHADOW) |
---|
15706 | 17069 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15707 | 17070 | |
---|
15708 | 17071 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15712 | 17075 | //gl.glColorMask(false, false, false, false); |
---|
15713 | 17076 | |
---|
15714 | 17077 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15715 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17078 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15716 | 17079 | { |
---|
15717 | 17080 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15718 | 17081 | |
---|
.. | .. |
---|
15772 | 17135 | |
---|
15773 | 17136 | class AntialiasBuffer implements GLEventListener |
---|
15774 | 17137 | { |
---|
15775 | | - |
---|
15776 | 17138 | CameraPane parent = null; |
---|
15777 | 17139 | |
---|
15778 | 17140 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16129 | 17491 | int AAbuffersize = 0; |
---|
16130 | 17492 | |
---|
16131 | 17493 | //double[] selectedpoint = new double[3]; |
---|
16132 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17494 | + static Superellipsoid selectedpoint; |
---|
16133 | 17495 | 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(); |
---|
| 17496 | + static Sphere debugpointG; |
---|
| 17497 | + static Sphere debugpointP; |
---|
| 17498 | + static Sphere debugpointC; |
---|
| 17499 | + static Sphere debugpointR; |
---|
16138 | 17500 | |
---|
16139 | 17501 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16140 | 17502 | |
---|
16141 | | - static |
---|
16142 | | - { |
---|
16143 | | - for (int i=0; i<8; i++) |
---|
16144 | | - { |
---|
16145 | | - debugpoints[i] = new Sphere(); |
---|
16146 | | - } |
---|
16147 | | - } |
---|
16148 | | - |
---|
16149 | 17503 | static void InitPoints(float radius) |
---|
16150 | 17504 | { |
---|
16151 | 17505 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16165 | 17519 | } |
---|
16166 | 17520 | } |
---|
16167 | 17521 | |
---|
16168 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17522 | + static void DrawPoints(iCameraPane cpane) |
---|
16169 | 17523 | { |
---|
16170 | 17524 | for (int i=0; i<8; i++) // first and last are red |
---|
16171 | 17525 | { |
---|
.. | .. |
---|
16197 | 17551 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16198 | 17552 | // Depth buffer format |
---|
16199 | 17553 | //private int depth_format; |
---|
16200 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17554 | + |
---|
| 17555 | + public void NextIndex() |
---|
16201 | 17556 | { |
---|
16202 | 17557 | indexcount+=16; |
---|
16203 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17558 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16204 | 17559 | //objects[indexcount] = o; |
---|
16205 | 17560 | //System.out.println("indexcount = " + indexcount); |
---|
16206 | 17561 | } |
---|