.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
37 | 41 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 42 | static int materialdepth = 0; |
---|
39 | 43 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 45 | |
---|
43 | 46 | // camera change fix |
---|
.. | .. |
---|
45 | 48 | static boolean ABORTED = false; |
---|
46 | 49 | |
---|
47 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
48 | 84 | |
---|
49 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
56 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 95 | |
---|
62 | 96 | boolean DISPLAYTEXT = false; |
---|
63 | 97 | //boolean REDUCETEXTURE = true; |
---|
64 | 98 | boolean CACHETEXTURE = true; |
---|
65 | 99 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
67 | 101 | boolean COMPRESSTEXTURE = false; |
---|
68 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
92 | 126 | |
---|
93 | 127 | static int tickcount = 0; // slow pose issue |
---|
94 | 128 | |
---|
| 129 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 130 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 131 | static boolean BOXMODE = false; |
---|
96 | 132 | static boolean IMAGEFLIP = false; |
---|
97 | 133 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 142 | static boolean OEIL = true; |
---|
107 | 143 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 144 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 145 | +static boolean SWITCH = true; // false; |
---|
110 | 146 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 147 | static boolean PAINTMODE = false; |
---|
112 | 148 | |
---|
.. | .. |
---|
149 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
152 | | - static CameraPane theRenderer; |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
153 | 190 | |
---|
| 191 | + public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 192 | + { |
---|
| 193 | + try |
---|
| 194 | + { |
---|
| 195 | + cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 196 | + } catch (IOException e) |
---|
| 197 | + { |
---|
| 198 | + System.out.println("NAME = " + name); |
---|
| 199 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 200 | + } |
---|
| 201 | + } |
---|
| 202 | + |
---|
154 | 203 | void SetAsGLRenderer(boolean b) |
---|
155 | 204 | { |
---|
156 | 205 | isRenderer = b; |
---|
157 | | - theRenderer = this; |
---|
| 206 | + Globals.theRenderer = this; |
---|
158 | 207 | } |
---|
159 | 208 | |
---|
160 | 209 | CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
.. | .. |
---|
169 | 218 | |
---|
170 | 219 | SetCamera(cam); |
---|
171 | 220 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 221 | + // Warning: not used. |
---|
| 222 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 223 | |
---|
174 | 224 | object = o; |
---|
175 | 225 | |
---|
.. | .. |
---|
191 | 241 | } |
---|
192 | 242 | |
---|
193 | 243 | /// INTERFACE |
---|
| 244 | + |
---|
| 245 | + public javax.media.opengl.GL GetGL0() |
---|
| 246 | + { |
---|
| 247 | + return null; |
---|
| 248 | + } |
---|
| 249 | + |
---|
| 250 | + public int GenList() |
---|
| 251 | + { |
---|
| 252 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 253 | + return gl.glGenLists(1); |
---|
| 254 | + } |
---|
| 255 | + |
---|
| 256 | + public void NewList(int id) |
---|
| 257 | + { |
---|
| 258 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 259 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 260 | + } |
---|
| 261 | + |
---|
| 262 | + public void CallList(int id) |
---|
| 263 | + { |
---|
| 264 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 265 | + gl.glCallList(id); |
---|
| 266 | + } |
---|
| 267 | + |
---|
| 268 | + public void EndList() |
---|
| 269 | + { |
---|
| 270 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 271 | + gl.glEndList(); |
---|
| 272 | + } |
---|
| 273 | + |
---|
| 274 | + public boolean IsBoxMode() |
---|
| 275 | + { |
---|
| 276 | + return BOXMODE; |
---|
| 277 | + } |
---|
| 278 | + |
---|
| 279 | + public boolean IsZoomBoxMode() |
---|
| 280 | + { |
---|
| 281 | + return ZOOMBOXMODE; |
---|
| 282 | + } |
---|
194 | 283 | |
---|
195 | 284 | public void ClearDepth() |
---|
196 | 285 | { |
---|
.. | .. |
---|
231 | 320 | return this.ambientOcclusion; |
---|
232 | 321 | } |
---|
233 | 322 | |
---|
| 323 | + public boolean IsDebugSelection() |
---|
| 324 | + { |
---|
| 325 | + return DEBUG_SELECTION; |
---|
| 326 | + } |
---|
| 327 | + |
---|
234 | 328 | public boolean IsFrozen() |
---|
235 | 329 | { |
---|
236 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 330 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
237 | 331 | |
---|
238 | 332 | return !selectmode && cameracount == 0; // != 0; |
---|
239 | 333 | } |
---|
.. | .. |
---|
254 | 348 | return lightCamera; |
---|
255 | 349 | } |
---|
256 | 350 | |
---|
| 351 | + public Camera ManipCamera() |
---|
| 352 | + { |
---|
| 353 | + return manipCamera; |
---|
| 354 | + } |
---|
| 355 | + |
---|
257 | 356 | public Camera RenderCamera() |
---|
258 | 357 | { |
---|
259 | 358 | return renderCamera; |
---|
| 359 | + } |
---|
| 360 | + |
---|
| 361 | + public Camera[] Cameras() |
---|
| 362 | + { |
---|
| 363 | + return cameras; |
---|
260 | 364 | } |
---|
261 | 365 | |
---|
262 | 366 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
272 | 376 | cStatic.objectstack[materialdepth++] = obj; |
---|
273 | 377 | //System.out.println("material " + material); |
---|
274 | 378 | //Applet3D.tracein(this, selected); |
---|
275 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 379 | + //display.vector2buffer = obj.projectedVertices; |
---|
276 | 380 | if (obj instanceof Camera) |
---|
277 | 381 | { |
---|
278 | 382 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
281 | 385 | display.options1[2] = material.shadowbias; |
---|
282 | 386 | display.options1[3] = material.aniso; |
---|
283 | 387 | display.options1[4] = material.anisoV; |
---|
| 388 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 389 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 390 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 391 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 392 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
284 | 393 | display.options2[0] = material.opacity; |
---|
285 | 394 | display.options2[1] = material.diffuse; |
---|
286 | 395 | display.options2[2] = material.factor; |
---|
| 396 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 397 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 398 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
287 | 399 | |
---|
288 | 400 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 401 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 402 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 403 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
289 | 404 | display.options4[0] = material.cameralight/0.2f; |
---|
290 | 405 | display.options4[1] = material.subsurface; |
---|
291 | 406 | display.options4[2] = material.sheen; |
---|
| 407 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 408 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 409 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
292 | 410 | |
---|
293 | 411 | // if (display.CURRENTANTIALIAS > 0) |
---|
294 | 412 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
304 | 422 | /**/ |
---|
305 | 423 | } else |
---|
306 | 424 | { |
---|
307 | | - DrawMaterial(material, selected); |
---|
| 425 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
308 | 426 | } |
---|
309 | 427 | } else |
---|
310 | 428 | { |
---|
.. | .. |
---|
328 | 446 | cStatic.objectstack[materialdepth++] = obj; |
---|
329 | 447 | //System.out.println("material " + material); |
---|
330 | 448 | //Applet3D.tracein("selected ", selected); |
---|
331 | | - display.vector2buffer = obj.projectedVertices; |
---|
332 | | - display.DrawMaterial(material, selected); |
---|
| 449 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 450 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
333 | 451 | } |
---|
334 | 452 | } |
---|
335 | 453 | |
---|
.. | .. |
---|
346 | 464 | materialdepth -= 1; |
---|
347 | 465 | if (materialdepth > 0) |
---|
348 | 466 | { |
---|
349 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
350 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 467 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 468 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
351 | 469 | } |
---|
352 | 470 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
353 | 471 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
367 | 485 | materialdepth -= 1; |
---|
368 | 486 | if (materialdepth > 0) |
---|
369 | 487 | { |
---|
370 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
371 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 488 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 489 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
372 | 490 | } |
---|
373 | 491 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
374 | 492 | //else |
---|
.. | .. |
---|
403 | 521 | |
---|
404 | 522 | javax.media.opengl.GL gl = display.GetGL(); |
---|
405 | 523 | |
---|
406 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 524 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
407 | 525 | |
---|
408 | 526 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
409 | 527 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
410 | 528 | { |
---|
411 | 529 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
412 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 530 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 531 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 532 | + ; |
---|
413 | 533 | if (!hasnorm) |
---|
414 | 534 | { |
---|
415 | | - // System.out.println("FUCK!!"); |
---|
| 535 | + // System.out.println("Mesh normal"); |
---|
416 | 536 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
417 | 537 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
418 | 538 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
566 | 686 | } |
---|
567 | 687 | } |
---|
568 | 688 | |
---|
| 689 | + /** |
---|
| 690 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 691 | + * it's normals, colors, textures and vertices. |
---|
| 692 | + * |
---|
| 693 | + * @see Renderer#draw(TriMesh) |
---|
| 694 | + * @param tris |
---|
| 695 | + * the mesh to render. |
---|
| 696 | + */ |
---|
| 697 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 698 | + { |
---|
| 699 | + CameraPane display = this; |
---|
| 700 | + |
---|
| 701 | + float r = display.modelParams0[0]; |
---|
| 702 | + float g = display.modelParams0[1]; |
---|
| 703 | + float b = display.modelParams0[2]; |
---|
| 704 | + float opacity = display.modelParams5[1]; |
---|
| 705 | + |
---|
| 706 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 707 | + GL gl = display.GetGL(); // getGL(); |
---|
| 708 | + |
---|
| 709 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 710 | + |
---|
| 711 | + int v = vertBuf.capacity(); |
---|
| 712 | + |
---|
| 713 | + int count = 0; |
---|
| 714 | + |
---|
| 715 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 716 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 717 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 718 | + for (int i=0; i<v/3; i++) |
---|
| 719 | + { |
---|
| 720 | + int index3 = i*3; |
---|
| 721 | + |
---|
| 722 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 723 | + continue; |
---|
| 724 | + |
---|
| 725 | + count++; |
---|
| 726 | + |
---|
| 727 | + int index4 = i*4; |
---|
| 728 | + |
---|
| 729 | + float tx = vertBuf.get(index3); |
---|
| 730 | + float ty = vertBuf.get(index3+1); |
---|
| 731 | + float tz = vertBuf.get(index3+2); |
---|
| 732 | + |
---|
| 733 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 734 | + // continue; |
---|
| 735 | + |
---|
| 736 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 737 | + gl.glPushMatrix(); |
---|
| 738 | + |
---|
| 739 | + float[] texmat = geo.texmat; |
---|
| 740 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 741 | + |
---|
| 742 | + gl.glMultMatrixf(texmat, 0); |
---|
| 743 | + |
---|
| 744 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 745 | + gl.glPushMatrix(); |
---|
| 746 | + |
---|
| 747 | + gl.glTranslatef(tx,ty,tz); |
---|
| 748 | + |
---|
| 749 | + if (rotate) |
---|
| 750 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 751 | + |
---|
| 752 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 753 | + gl.glScalef(size,size,size); |
---|
| 754 | + |
---|
| 755 | + float cr = geo.colorBuf.get(index4); |
---|
| 756 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 757 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 758 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 759 | + |
---|
| 760 | + display.modelParams0[0] = r * cr; |
---|
| 761 | + display.modelParams0[1] = g * cg; |
---|
| 762 | + display.modelParams0[2] = b * cb; |
---|
| 763 | + |
---|
| 764 | + display.modelParams5[1] = opacity * ca; |
---|
| 765 | + |
---|
| 766 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 767 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 768 | + |
---|
| 769 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 770 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 771 | + |
---|
| 772 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 773 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 774 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 775 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 776 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 777 | + gl.glPopMatrix(); |
---|
| 778 | + |
---|
| 779 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 780 | + gl.glPopMatrix(); |
---|
| 781 | + } |
---|
| 782 | + // gl.glScalef(1024,1024,1024); |
---|
| 783 | + if (!cf) |
---|
| 784 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 785 | + |
---|
| 786 | + display.modelParams0[0] = r; |
---|
| 787 | + display.modelParams0[1] = g; |
---|
| 788 | + display.modelParams0[2] = b; |
---|
| 789 | + |
---|
| 790 | + display.modelParams5[1] = opacity; |
---|
| 791 | + |
---|
| 792 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 793 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 794 | + |
---|
| 795 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 796 | + |
---|
| 797 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 798 | + if (true) |
---|
| 799 | + return; |
---|
| 800 | + |
---|
| 801 | +//// if (!tris.predraw(this)) |
---|
| 802 | +//// { |
---|
| 803 | +//// return; |
---|
| 804 | +//// } |
---|
| 805 | +//// if (Debug.stats) |
---|
| 806 | +//// { |
---|
| 807 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 808 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 809 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 810 | +//// } |
---|
| 811 | +//// |
---|
| 812 | +//// if (tris.getDisplayListID() != -1) |
---|
| 813 | +//// { |
---|
| 814 | +//// renderDisplayList(tris); |
---|
| 815 | +//// return; |
---|
| 816 | +//// } |
---|
| 817 | +//// |
---|
| 818 | +//// if (!generatingDisplayList) |
---|
| 819 | +//// { |
---|
| 820 | +//// applyStates(tris.states, tris); |
---|
| 821 | +//// } |
---|
| 822 | +//// if (Debug.stats) |
---|
| 823 | +//// { |
---|
| 824 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 825 | +//// } |
---|
| 826 | +//// boolean transformed = doTransforms(tris); |
---|
| 827 | +// |
---|
| 828 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 829 | +// switch (getMode()) |
---|
| 830 | +// { |
---|
| 831 | +// case Triangles: |
---|
| 832 | +// glMode = GL.GL_TRIANGLES; |
---|
| 833 | +// break; |
---|
| 834 | +// case Strip: |
---|
| 835 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 836 | +// break; |
---|
| 837 | +// case Fan: |
---|
| 838 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 839 | +// break; |
---|
| 840 | +// } |
---|
| 841 | +// |
---|
| 842 | +// if (!predrawGeometry(gl)) |
---|
| 843 | +// { |
---|
| 844 | +// // make sure only the necessary indices are sent through on old |
---|
| 845 | +// // cards. |
---|
| 846 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 847 | +// if (indices == null) |
---|
| 848 | +// { |
---|
| 849 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 850 | +// } else |
---|
| 851 | +// { |
---|
| 852 | +// indices.rewind(); |
---|
| 853 | +// indices.limit(this.getMaxIndex()); |
---|
| 854 | +// |
---|
| 855 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 856 | +// |
---|
| 857 | +// indices.clear(); |
---|
| 858 | +// } |
---|
| 859 | +// } else |
---|
| 860 | +// { |
---|
| 861 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 862 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 863 | +// } |
---|
| 864 | +// |
---|
| 865 | +//// postdrawGeometry(tris); |
---|
| 866 | +//// if (transformed) |
---|
| 867 | +//// { |
---|
| 868 | +//// undoTransforms(tris); |
---|
| 869 | +//// } |
---|
| 870 | +//// |
---|
| 871 | +//// if (Debug.stats) |
---|
| 872 | +//// { |
---|
| 873 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 874 | +//// } |
---|
| 875 | +//// tris.postdraw(this); |
---|
| 876 | + } |
---|
| 877 | + |
---|
| 878 | + static Camera localcamera = new Camera(); |
---|
| 879 | + static cVector from = new cVector(); |
---|
| 880 | + static cVector to = new cVector(); |
---|
| 881 | + |
---|
| 882 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 883 | + { |
---|
| 884 | + CameraPane cp = this; |
---|
| 885 | + |
---|
| 886 | + Camera keep = cp.RenderCamera(); |
---|
| 887 | + cp.renderCamera = localcamera; |
---|
| 888 | + |
---|
| 889 | + if (br.trimmed) |
---|
| 890 | + { |
---|
| 891 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 892 | + |
---|
| 893 | + int i3 = 0; |
---|
| 894 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 895 | + { |
---|
| 896 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 897 | + continue; |
---|
| 898 | + |
---|
| 899 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 900 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 901 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 902 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 903 | + LA.xformPos(from, transform, from); |
---|
| 904 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 905 | + localcamera.setAim(from, to); |
---|
| 906 | + |
---|
| 907 | + CameraPane.occlusionbuffer.display(); |
---|
| 908 | + |
---|
| 909 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 910 | + cp.display(); // debug |
---|
| 911 | + |
---|
| 912 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 913 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 914 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 915 | + |
---|
| 916 | + if ((i % 100) == 0 && i != 0) |
---|
| 917 | + { |
---|
| 918 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 919 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 920 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 921 | + } |
---|
| 922 | + } |
---|
| 923 | + |
---|
| 924 | + br.colors = colors; |
---|
| 925 | + } |
---|
| 926 | + else |
---|
| 927 | + { |
---|
| 928 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 929 | + { |
---|
| 930 | + Vertex v = br.GetVertex(i); |
---|
| 931 | + |
---|
| 932 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 933 | + continue; |
---|
| 934 | + |
---|
| 935 | + from.set(v.x, v.y, v.z); |
---|
| 936 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 937 | + LA.xformPos(from, transform, from); |
---|
| 938 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 939 | + localcamera.setAim(from, to); |
---|
| 940 | + |
---|
| 941 | + CameraPane.occlusionbuffer.display(); |
---|
| 942 | + |
---|
| 943 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 944 | + cp.display(); // debug |
---|
| 945 | + |
---|
| 946 | + v.AO = cp.vertexOcclusion.r; |
---|
| 947 | + |
---|
| 948 | + if ((i % 100) == 0 && i != 0) |
---|
| 949 | + { |
---|
| 950 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 951 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 952 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 953 | + } |
---|
| 954 | + } |
---|
| 955 | + } |
---|
| 956 | + |
---|
| 957 | + //System.out.println("done."); |
---|
| 958 | + |
---|
| 959 | + cp.renderCamera = keep; |
---|
| 960 | + } |
---|
| 961 | + |
---|
| 962 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 963 | + { |
---|
| 964 | + CameraPane display = this; |
---|
| 965 | + pointFlow.CreateHT(); |
---|
| 966 | + |
---|
| 967 | + float r = display.modelParams0[0]; |
---|
| 968 | + float g = display.modelParams0[1]; |
---|
| 969 | + float b = display.modelParams0[2]; |
---|
| 970 | + float opacity = display.modelParams5[1]; |
---|
| 971 | + |
---|
| 972 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 973 | + GL gl = display.GetGL(); // getGL(); |
---|
| 974 | + |
---|
| 975 | + int s = pointFlow.points.size(); |
---|
| 976 | + |
---|
| 977 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 978 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 979 | + |
---|
| 980 | + for (int i=s; --i>=0;) |
---|
| 981 | + //for (int i=0; i<s; i++) |
---|
| 982 | + { |
---|
| 983 | + cVector v = pointFlow.points.get(i); |
---|
| 984 | + |
---|
| 985 | + double mindist = Double.MAX_VALUE; |
---|
| 986 | + |
---|
| 987 | + double size = pointFlow.minimumSize; |
---|
| 988 | + |
---|
| 989 | + double distancenext = 0; |
---|
| 990 | + |
---|
| 991 | + if (i > 0) |
---|
| 992 | + { |
---|
| 993 | + cVector w = pointFlow.points.get(i-1); |
---|
| 994 | + |
---|
| 995 | + double dist = w.distance(v); |
---|
| 996 | + |
---|
| 997 | + distancenext = dist; |
---|
| 998 | + |
---|
| 999 | + if (mindist > dist) |
---|
| 1000 | + { |
---|
| 1001 | + mindist = dist; |
---|
| 1002 | + size = mindist*pointFlow.resizefactor; |
---|
| 1003 | + } |
---|
| 1004 | + } |
---|
| 1005 | + |
---|
| 1006 | + if (i < s-1) |
---|
| 1007 | + { |
---|
| 1008 | + cVector w = pointFlow.points.get(i+1); |
---|
| 1009 | + |
---|
| 1010 | + double dist = w.distance(v); |
---|
| 1011 | + |
---|
| 1012 | + if (mindist > dist) |
---|
| 1013 | + { |
---|
| 1014 | + mindist = dist; |
---|
| 1015 | + size = mindist*pointFlow.resizefactor; |
---|
| 1016 | + } |
---|
| 1017 | + } |
---|
| 1018 | + |
---|
| 1019 | + if (size < pointFlow.minimumSize) |
---|
| 1020 | + size = pointFlow.minimumSize; |
---|
| 1021 | + if (size > pointFlow.maximumSize) |
---|
| 1022 | + size = pointFlow.maximumSize; |
---|
| 1023 | + |
---|
| 1024 | + double tx = v.x; |
---|
| 1025 | + double ty = v.y; |
---|
| 1026 | + double tz = v.z; |
---|
| 1027 | + |
---|
| 1028 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1029 | + // continue; |
---|
| 1030 | + |
---|
| 1031 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1032 | + gl.glPushMatrix(); |
---|
| 1033 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1034 | + |
---|
| 1035 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1036 | + |
---|
| 1037 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1038 | + gl.glPushMatrix(); |
---|
| 1039 | + |
---|
| 1040 | + gl.glTranslated(tx,ty,tz); |
---|
| 1041 | + |
---|
| 1042 | + gl.glScaled(size,size,size); |
---|
| 1043 | + |
---|
| 1044 | +// float cr = colorBuf.get(index4); |
---|
| 1045 | +// float cg = colorBuf.get(index4+1); |
---|
| 1046 | +// float cb = colorBuf.get(index4+2); |
---|
| 1047 | +// float ca = colorBuf.get(index4+3); |
---|
| 1048 | +// |
---|
| 1049 | +// display.modelParams0[0] = r * cr; |
---|
| 1050 | +// display.modelParams0[1] = g * cg; |
---|
| 1051 | +// display.modelParams0[2] = b * cb; |
---|
| 1052 | +// |
---|
| 1053 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1054 | +// |
---|
| 1055 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1056 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1057 | +// |
---|
| 1058 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1059 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1060 | +// |
---|
| 1061 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1062 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1063 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1064 | + |
---|
| 1065 | + gl.glPopMatrix(); |
---|
| 1066 | + |
---|
| 1067 | + double step = size/4; // |
---|
| 1068 | + |
---|
| 1069 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1070 | + continue; |
---|
| 1071 | + |
---|
| 1072 | + int nbsteps = (int)(distancenext/step); |
---|
| 1073 | + |
---|
| 1074 | + step = distancenext/nbsteps; |
---|
| 1075 | + |
---|
| 1076 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1077 | + |
---|
| 1078 | + tmp.set(next); |
---|
| 1079 | + tmp.sub(v); |
---|
| 1080 | + tmp.normalize(); |
---|
| 1081 | + tmp.mul(step); |
---|
| 1082 | + |
---|
| 1083 | + // calculate next size |
---|
| 1084 | + mindist = Double.MAX_VALUE; |
---|
| 1085 | + |
---|
| 1086 | + double nextsize = pointFlow.minimumSize; |
---|
| 1087 | + |
---|
| 1088 | + if (i > 1) |
---|
| 1089 | + { |
---|
| 1090 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1091 | + |
---|
| 1092 | + double dist = w.distance(next); |
---|
| 1093 | + |
---|
| 1094 | + if (mindist > dist) |
---|
| 1095 | + { |
---|
| 1096 | + mindist = dist; |
---|
| 1097 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1098 | + } |
---|
| 1099 | + } |
---|
| 1100 | + |
---|
| 1101 | + double dist = v.distance(next); |
---|
| 1102 | + |
---|
| 1103 | + if (mindist > dist) |
---|
| 1104 | + { |
---|
| 1105 | + mindist = dist; |
---|
| 1106 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1107 | + } |
---|
| 1108 | + |
---|
| 1109 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1110 | + nextsize = pointFlow.minimumSize; |
---|
| 1111 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1112 | + nextsize = pointFlow.maximumSize; |
---|
| 1113 | + // |
---|
| 1114 | + |
---|
| 1115 | + double count = 0; |
---|
| 1116 | + |
---|
| 1117 | + while (distancenext > 0.000000001) // step |
---|
| 1118 | + { |
---|
| 1119 | + gl.glPushMatrix(); |
---|
| 1120 | + |
---|
| 1121 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1122 | + |
---|
| 1123 | + double K = count/nbsteps; |
---|
| 1124 | + |
---|
| 1125 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1126 | + |
---|
| 1127 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1128 | + |
---|
| 1129 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1130 | + |
---|
| 1131 | + count++; |
---|
| 1132 | + |
---|
| 1133 | + distancenext -= step; |
---|
| 1134 | + |
---|
| 1135 | + gl.glPopMatrix(); |
---|
| 1136 | + } |
---|
| 1137 | + |
---|
| 1138 | + if (count != nbsteps) |
---|
| 1139 | + assert(count == nbsteps); |
---|
| 1140 | + |
---|
| 1141 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1142 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1143 | + |
---|
| 1144 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1145 | + gl.glPopMatrix(); |
---|
| 1146 | + } |
---|
| 1147 | + |
---|
| 1148 | + if (!cf) |
---|
| 1149 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1150 | + |
---|
| 1151 | +// display.modelParams0[0] = r; |
---|
| 1152 | +// display.modelParams0[1] = g; |
---|
| 1153 | +// display.modelParams0[2] = b; |
---|
| 1154 | +// |
---|
| 1155 | +// display.modelParams5[1] = opacity; |
---|
| 1156 | +// |
---|
| 1157 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1158 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1159 | + |
---|
| 1160 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1161 | + } |
---|
| 1162 | + |
---|
| 1163 | + public void DrawBox(cVector min, cVector max) |
---|
| 1164 | + { |
---|
| 1165 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1166 | + gl.glBegin(gl.GL_LINES); |
---|
| 1167 | + |
---|
| 1168 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1169 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1170 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1171 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1172 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1173 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1174 | + |
---|
| 1175 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1176 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1177 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1178 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1179 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1180 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1181 | + |
---|
| 1182 | + gl.glEnd(); |
---|
| 1183 | + } |
---|
| 1184 | + |
---|
| 1185 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1186 | + { |
---|
| 1187 | + int[] strips = bRep.getRawIndices(); |
---|
| 1188 | + |
---|
| 1189 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1190 | + |
---|
| 1191 | + // TRIANGLE STRIP ARRAY |
---|
| 1192 | + if (bRep.trimmed) |
---|
| 1193 | + { |
---|
| 1194 | + float[] v = bRep.getRawVertices(); |
---|
| 1195 | + float[] n = bRep.getRawNormals(); |
---|
| 1196 | + float[] c = bRep.getRawColors(); |
---|
| 1197 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1198 | + |
---|
| 1199 | + int count2 = 0; |
---|
| 1200 | + int count3 = 0; |
---|
| 1201 | + |
---|
| 1202 | + if (n.length > 0) |
---|
| 1203 | + { |
---|
| 1204 | + for (int i = 0; i < strips.length; i++) |
---|
| 1205 | + { |
---|
| 1206 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1207 | + |
---|
| 1208 | + /* |
---|
| 1209 | + boolean locked = false; |
---|
| 1210 | + float eps = 0.1f; |
---|
| 1211 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1212 | + |
---|
| 1213 | + int dot = 0; |
---|
| 1214 | + |
---|
| 1215 | + if ((dot&1) == 0) |
---|
| 1216 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1217 | + |
---|
| 1218 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1219 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1220 | + else |
---|
| 1221 | + { |
---|
| 1222 | + locked = true; |
---|
| 1223 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1224 | + } |
---|
| 1225 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1226 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1227 | + if (hasnorm) |
---|
| 1228 | + { |
---|
| 1229 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1230 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1231 | + } |
---|
| 1232 | + |
---|
| 1233 | + if ((dot&4) == 0) |
---|
| 1234 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1235 | + |
---|
| 1236 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1237 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1238 | + else |
---|
| 1239 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1240 | + |
---|
| 1241 | + f.dot = dot; |
---|
| 1242 | + */ |
---|
| 1243 | + |
---|
| 1244 | + if (!selectmode) |
---|
| 1245 | + { |
---|
| 1246 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1247 | + { |
---|
| 1248 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1249 | + } else |
---|
| 1250 | + { |
---|
| 1251 | + gl.glNormal3f(0, 0, 1); |
---|
| 1252 | + } |
---|
| 1253 | + |
---|
| 1254 | + if (c != null) |
---|
| 1255 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1256 | + { |
---|
| 1257 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1258 | + } |
---|
| 1259 | + } |
---|
| 1260 | + |
---|
| 1261 | + if (flipV) |
---|
| 1262 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1263 | + else |
---|
| 1264 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1265 | + |
---|
| 1266 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1267 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1268 | + |
---|
| 1269 | + count2 += 2; |
---|
| 1270 | + count3 += 3; |
---|
| 1271 | + if (!selectmode) |
---|
| 1272 | + { |
---|
| 1273 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1274 | + { |
---|
| 1275 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1276 | + } else |
---|
| 1277 | + { |
---|
| 1278 | + gl.glNormal3f(0, 0, 1); |
---|
| 1279 | + } |
---|
| 1280 | + if (c != null) |
---|
| 1281 | + { |
---|
| 1282 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1283 | + } |
---|
| 1284 | + } |
---|
| 1285 | + |
---|
| 1286 | + if (flipV) |
---|
| 1287 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1288 | + else |
---|
| 1289 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1290 | + |
---|
| 1291 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1292 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1293 | + |
---|
| 1294 | + count2 += 2; |
---|
| 1295 | + count3 += 3; |
---|
| 1296 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1297 | + { |
---|
| 1298 | + //gl.glTexCoord2d(...); |
---|
| 1299 | + if (!selectmode) |
---|
| 1300 | + { |
---|
| 1301 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1302 | + { |
---|
| 1303 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1304 | + } else |
---|
| 1305 | + { |
---|
| 1306 | + gl.glNormal3f(0, 0, 1); |
---|
| 1307 | + } |
---|
| 1308 | + if (c != null) |
---|
| 1309 | + { |
---|
| 1310 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1311 | + } |
---|
| 1312 | + } |
---|
| 1313 | + |
---|
| 1314 | + if (flipV) |
---|
| 1315 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1316 | + else |
---|
| 1317 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1318 | + |
---|
| 1319 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1320 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1321 | + |
---|
| 1322 | + count2 += 2; |
---|
| 1323 | + count3 += 3; |
---|
| 1324 | + } |
---|
| 1325 | + |
---|
| 1326 | + gl.glEnd(); |
---|
| 1327 | + } |
---|
| 1328 | + } |
---|
| 1329 | + |
---|
| 1330 | + assert count3 == v.length; |
---|
| 1331 | + } |
---|
| 1332 | + else // !trimmed |
---|
| 1333 | + { |
---|
| 1334 | + int count = 0; |
---|
| 1335 | + for (int i = 0; i < strips.length; i++) |
---|
| 1336 | + { |
---|
| 1337 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1338 | + |
---|
| 1339 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1340 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1341 | + |
---|
| 1342 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1343 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1344 | + |
---|
| 1345 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1346 | + { |
---|
| 1347 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1348 | + |
---|
| 1349 | + // if (j%2 == 0) |
---|
| 1350 | + // drawFace(p, q, r, display, null); |
---|
| 1351 | + // else |
---|
| 1352 | + // drawFace(p, r, q, display, null); |
---|
| 1353 | + |
---|
| 1354 | + // p = q; |
---|
| 1355 | + // q = r; |
---|
| 1356 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1357 | + } |
---|
| 1358 | + |
---|
| 1359 | + gl.glEnd(); |
---|
| 1360 | + } |
---|
| 1361 | + } |
---|
| 1362 | + } |
---|
| 1363 | + |
---|
| 1364 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1365 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1366 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1367 | + |
---|
| 1368 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1369 | + { |
---|
| 1370 | + GL gl = GetGL(); // getGL(); |
---|
| 1371 | + |
---|
| 1372 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1373 | + |
---|
| 1374 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1375 | + |
---|
| 1376 | + gl.glLineWidth(1); |
---|
| 1377 | + gl.glColor3f(1,1,1); |
---|
| 1378 | + gl.glBegin(gl.GL_LINES); |
---|
| 1379 | + double scale = 0; |
---|
| 1380 | + int count = 0; |
---|
| 1381 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1382 | + { |
---|
| 1383 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1384 | + if(s == 0) |
---|
| 1385 | + { |
---|
| 1386 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1387 | + } |
---|
| 1388 | + if (mesh.showsprings) |
---|
| 1389 | + { |
---|
| 1390 | + temp.set(spring.a.position); |
---|
| 1391 | + temp.add(spring.b.position); |
---|
| 1392 | + temp.mul(0.5); |
---|
| 1393 | + temp2.set(spring.a.position); |
---|
| 1394 | + temp2.sub(spring.b.position); |
---|
| 1395 | + temp2.mul(spring.restLength/2); |
---|
| 1396 | + temp.sub(temp2); |
---|
| 1397 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1398 | + temp.add(temp2); |
---|
| 1399 | + temp.add(temp2); |
---|
| 1400 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1401 | + } |
---|
| 1402 | + |
---|
| 1403 | + if (spring.isHandle) |
---|
| 1404 | + continue; |
---|
| 1405 | + |
---|
| 1406 | + //if (scale < spring.restLength) |
---|
| 1407 | + scale += spring.restLength; |
---|
| 1408 | + count++; |
---|
| 1409 | + } |
---|
| 1410 | + gl.glEnd(); |
---|
| 1411 | + |
---|
| 1412 | + if (count == 0) |
---|
| 1413 | + scale = 0.01; |
---|
| 1414 | + else |
---|
| 1415 | + scale /= count * 3; |
---|
| 1416 | + |
---|
| 1417 | + //scale = 0.25; |
---|
| 1418 | + |
---|
| 1419 | + if (mesh.ShowInfo()) |
---|
| 1420 | + { |
---|
| 1421 | + gl.glLineWidth(4); |
---|
| 1422 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1423 | + { |
---|
| 1424 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1425 | + if (node.mass == 0) |
---|
| 1426 | + continue; |
---|
| 1427 | + |
---|
| 1428 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1429 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1430 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1431 | + //temp.normalize(); |
---|
| 1432 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1433 | + gl.glBegin(gl.GL_LINES); |
---|
| 1434 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1435 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1436 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1437 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1438 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1439 | + gl.glEnd(); |
---|
| 1440 | + } |
---|
| 1441 | + |
---|
| 1442 | + gl.glLineWidth(8); |
---|
| 1443 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1444 | + { |
---|
| 1445 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1446 | + |
---|
| 1447 | + if (node.springs != null) |
---|
| 1448 | + { |
---|
| 1449 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1450 | + { |
---|
| 1451 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1452 | + |
---|
| 1453 | + int c = i+1; |
---|
| 1454 | + // c = node.springs.get(i).nbcopies; |
---|
| 1455 | + |
---|
| 1456 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1457 | + gl.glBegin(gl.GL_LINES); |
---|
| 1458 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1459 | + 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); |
---|
| 1460 | + gl.glEnd(); |
---|
| 1461 | + } |
---|
| 1462 | + } |
---|
| 1463 | + } |
---|
| 1464 | + |
---|
| 1465 | + gl.glLineWidth(1); |
---|
| 1466 | + } |
---|
| 1467 | + |
---|
| 1468 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1469 | + } |
---|
| 1470 | + |
---|
569 | 1471 | /// INTERFACE |
---|
570 | 1472 | |
---|
| 1473 | + public void StartTriangles() |
---|
| 1474 | + { |
---|
| 1475 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1476 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1477 | + } |
---|
| 1478 | + |
---|
| 1479 | + public void EndTriangles() |
---|
| 1480 | + { |
---|
| 1481 | + GetGL().glEnd(); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1485 | + { |
---|
| 1486 | + if (!selectmode) |
---|
| 1487 | + { |
---|
| 1488 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1489 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1490 | + |
---|
| 1491 | + if (flipV) |
---|
| 1492 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1493 | + else |
---|
| 1494 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1495 | + } |
---|
| 1496 | + |
---|
| 1497 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1498 | + } |
---|
| 1499 | + |
---|
| 1500 | + float[] colorV = new float[4]; |
---|
| 1501 | + |
---|
571 | 1502 | void SetColor(Object3D obj, Vertex p0) |
---|
572 | 1503 | { |
---|
573 | 1504 | CameraPane display = this; |
---|
.. | .. |
---|
635 | 1566 | { |
---|
636 | 1567 | return; |
---|
637 | 1568 | } |
---|
638 | | - |
---|
639 | | - float[] colorV = new float[3]; |
---|
640 | 1569 | |
---|
641 | 1570 | if (false) // marked) |
---|
642 | 1571 | { |
---|
.. | .. |
---|
745 | 1674 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
746 | 1675 | } |
---|
747 | 1676 | |
---|
748 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1677 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
749 | 1678 | { |
---|
750 | 1679 | CameraPane display = this; |
---|
751 | 1680 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
761 | 1690 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
762 | 1691 | if (!material.multiply) |
---|
763 | 1692 | { |
---|
764 | | - display.color = color; |
---|
| 1693 | + display.color = material.color; |
---|
765 | 1694 | display.saturation = material.modulation; |
---|
766 | 1695 | } |
---|
767 | 1696 | else |
---|
768 | 1697 | { |
---|
769 | | - display.color *= color*2; |
---|
| 1698 | + display.color *= material.color*2; |
---|
770 | 1699 | display.saturation *= material.modulation*2; |
---|
771 | 1700 | } |
---|
772 | 1701 | |
---|
773 | 1702 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
774 | 1703 | |
---|
775 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1704 | + float[] colorV = Grafreed.colorV; |
---|
776 | 1705 | |
---|
777 | 1706 | /**/ |
---|
778 | 1707 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
780 | 1709 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
781 | 1710 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
782 | 1711 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
783 | | - colorV[3] = material.opacity; |
---|
| 1712 | + colorV[3] = 1; // material.opacity; |
---|
784 | 1713 | |
---|
785 | 1714 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
786 | 1715 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
888 | 1817 | display.modelParams7[2] = 0; |
---|
889 | 1818 | display.modelParams7[3] = 0; |
---|
890 | 1819 | |
---|
891 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1820 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
892 | 1821 | |
---|
893 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1822 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
894 | 1823 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
895 | 1824 | { |
---|
896 | 1825 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1032 | 1961 | void PushMatrix(double[][] matrix) |
---|
1033 | 1962 | { |
---|
1034 | 1963 | // GrafreeD.tracein(matrix); |
---|
1035 | | - PushMatrix(matrix,1); |
---|
| 1964 | + PushMatrix(matrix, 1); |
---|
1036 | 1965 | } |
---|
1037 | 1966 | |
---|
1038 | 1967 | void PushMatrix() |
---|
.. | .. |
---|
1129 | 2058 | |
---|
1130 | 2059 | static int camerachangeframe; |
---|
1131 | 2060 | |
---|
1132 | | - boolean SetCamera(Camera cam) |
---|
| 2061 | + public boolean SetCamera(Camera cam) |
---|
1133 | 2062 | { |
---|
1134 | 2063 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1135 | 2064 | // return false; |
---|
.. | .. |
---|
1186 | 2115 | //System.err.println("Oeil on"); |
---|
1187 | 2116 | OEIL = true; |
---|
1188 | 2117 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1189 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2118 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1190 | 2119 | //pingthread.StepToTarget(true); |
---|
1191 | 2120 | } |
---|
1192 | 2121 | |
---|
.. | .. |
---|
1257 | 2186 | mainDL ^= true; |
---|
1258 | 2187 | } |
---|
1259 | 2188 | |
---|
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 | 2189 | void ToggleFullScreen() |
---|
1288 | 2190 | { |
---|
1289 | 2191 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1294 | 2196 | Globals.CROWD ^= true; |
---|
1295 | 2197 | } |
---|
1296 | 2198 | |
---|
1297 | | - void ToggleInertia() |
---|
1298 | | - { |
---|
1299 | | - INERTIA ^= true; |
---|
1300 | | - } |
---|
1301 | | - |
---|
1302 | 2199 | void ToggleLocal() |
---|
1303 | 2200 | { |
---|
1304 | 2201 | LOCALTRANSFORM ^= true; |
---|
1305 | 2202 | } |
---|
1306 | 2203 | |
---|
1307 | | - void ToggleFast() |
---|
| 2204 | + public void ToggleTexture() |
---|
| 2205 | + { |
---|
| 2206 | + textureon ^= true; |
---|
| 2207 | + } |
---|
| 2208 | + |
---|
| 2209 | + public void ToggleLive() |
---|
| 2210 | + { |
---|
| 2211 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2212 | + |
---|
| 2213 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2214 | + |
---|
| 2215 | + if (!Globals.isLIVE()) // save sound |
---|
| 2216 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2217 | + // else |
---|
| 2218 | + repaint(); // start loop // may 2013 |
---|
| 2219 | + } |
---|
| 2220 | + |
---|
| 2221 | + public void ToggleSupport() |
---|
| 2222 | + { |
---|
| 2223 | + SUPPORT ^= true; |
---|
| 2224 | + } |
---|
| 2225 | + |
---|
| 2226 | + public void ToggleAbort() |
---|
| 2227 | + { |
---|
| 2228 | + ABORTMODE ^= true; |
---|
| 2229 | + } |
---|
| 2230 | + |
---|
| 2231 | + public void ToggleInertia() |
---|
| 2232 | + { |
---|
| 2233 | + INERTIA ^= true; |
---|
| 2234 | + } |
---|
| 2235 | + |
---|
| 2236 | + public void ToggleFast() |
---|
1308 | 2237 | { |
---|
1309 | 2238 | FAST ^= true; |
---|
1310 | 2239 | } |
---|
1311 | 2240 | |
---|
1312 | | - void ToggleSlowPose() |
---|
| 2241 | + public void ToggleSlowPose() |
---|
1313 | 2242 | { |
---|
1314 | 2243 | SLOWPOSE ^= true; |
---|
1315 | 2244 | } |
---|
1316 | 2245 | |
---|
1317 | | - void ToggleFootContact() |
---|
1318 | | - { |
---|
1319 | | - FOOTCONTACT ^= true; |
---|
1320 | | - } |
---|
1321 | | - |
---|
1322 | | - void ToggleBoxMode() |
---|
| 2246 | + public void ToggleBoxMode() |
---|
1323 | 2247 | { |
---|
1324 | 2248 | BOXMODE ^= true; |
---|
1325 | 2249 | } |
---|
1326 | 2250 | |
---|
1327 | | - void ToggleSmoothFocus() |
---|
| 2251 | + public void ToggleZoomBoxMode() |
---|
| 2252 | + { |
---|
| 2253 | + ZOOMBOXMODE ^= true; |
---|
| 2254 | + } |
---|
| 2255 | + |
---|
| 2256 | + public void ToggleSmoothFocus() |
---|
1328 | 2257 | { |
---|
1329 | 2258 | SMOOTHFOCUS ^= true; |
---|
1330 | 2259 | } |
---|
1331 | 2260 | |
---|
1332 | | - void ToggleImageFlip() |
---|
| 2261 | + public void ToggleImageFlip() |
---|
1333 | 2262 | { |
---|
1334 | 2263 | IMAGEFLIP ^= true; |
---|
1335 | 2264 | } |
---|
1336 | 2265 | |
---|
1337 | | - void ToggleSpeakerMocap() |
---|
| 2266 | + public void ToggleSpeakerMocap() |
---|
1338 | 2267 | { |
---|
1339 | 2268 | SPEAKERMOCAP ^= true; |
---|
1340 | 2269 | } |
---|
1341 | 2270 | |
---|
1342 | | - void ToggleSpeakerCamera() |
---|
| 2271 | + public void ToggleSpeakerCamera() |
---|
1343 | 2272 | { |
---|
1344 | 2273 | SPEAKERCAMERA ^= true; |
---|
1345 | 2274 | } |
---|
1346 | 2275 | |
---|
1347 | | - void ToggleSpeakerFocus() |
---|
| 2276 | + public void ToggleSpeakerFocus() |
---|
1348 | 2277 | { |
---|
1349 | 2278 | SPEAKERFOCUS ^= true; |
---|
1350 | 2279 | } |
---|
1351 | 2280 | |
---|
1352 | | - void ToggleDebug() |
---|
1353 | | - { |
---|
1354 | | - DEBUG ^= true; |
---|
1355 | | - } |
---|
1356 | | - |
---|
1357 | | - void ToggleFrustum() |
---|
| 2281 | + public void ToggleFrustum() |
---|
1358 | 2282 | { |
---|
1359 | 2283 | FRUSTUM ^= true; |
---|
1360 | 2284 | } |
---|
1361 | 2285 | |
---|
1362 | | - void ToggleTrack() |
---|
| 2286 | + public void ToggleTrack() |
---|
1363 | 2287 | { |
---|
1364 | 2288 | TRACK ^= true; |
---|
1365 | 2289 | if (TRACK) |
---|
.. | .. |
---|
1378 | 2302 | repaint(); |
---|
1379 | 2303 | } |
---|
1380 | 2304 | |
---|
1381 | | - void ToggleTrackOnce() |
---|
| 2305 | + public void ToggleTrackOnce() |
---|
1382 | 2306 | { |
---|
1383 | 2307 | TRACKONCE ^= true; |
---|
1384 | 2308 | } |
---|
1385 | 2309 | |
---|
1386 | | - void ToggleShadowTrack() |
---|
| 2310 | + public void ToggleShadowTrack() |
---|
1387 | 2311 | { |
---|
1388 | 2312 | SHADOWTRACK ^= true; |
---|
1389 | 2313 | repaint(); |
---|
1390 | 2314 | } |
---|
1391 | 2315 | |
---|
1392 | | - void ToggleOeil() |
---|
| 2316 | + public void ToggleOeil() |
---|
1393 | 2317 | { |
---|
1394 | 2318 | OEIL ^= true; |
---|
1395 | 2319 | } |
---|
1396 | 2320 | |
---|
1397 | | - void ToggleOeilOnce() |
---|
| 2321 | + public void ToggleOeilOnce() |
---|
1398 | 2322 | { |
---|
1399 | 2323 | OEILONCE ^= true; |
---|
| 2324 | + } |
---|
| 2325 | + |
---|
| 2326 | + void ToggleFootContact() |
---|
| 2327 | + { |
---|
| 2328 | + FOOTCONTACT ^= true; |
---|
| 2329 | + } |
---|
| 2330 | + |
---|
| 2331 | + void ToggleDebug() |
---|
| 2332 | + { |
---|
| 2333 | + Globals.DEBUG ^= true; |
---|
1400 | 2334 | } |
---|
1401 | 2335 | |
---|
1402 | 2336 | void ToggleLookAt() |
---|
.. | .. |
---|
1404 | 2338 | LOOKAT ^= true; |
---|
1405 | 2339 | } |
---|
1406 | 2340 | |
---|
1407 | | - void ToggleRandom() |
---|
| 2341 | + void ToggleSwitch() |
---|
1408 | 2342 | { |
---|
1409 | | - RANDOM ^= true; |
---|
| 2343 | + SWITCH ^= true; |
---|
1410 | 2344 | } |
---|
1411 | 2345 | |
---|
1412 | 2346 | void ToggleHandles() |
---|
.. | .. |
---|
1414 | 2348 | HANDLES ^= true; |
---|
1415 | 2349 | } |
---|
1416 | 2350 | |
---|
| 2351 | + Object3D paintFolder; |
---|
| 2352 | + |
---|
1417 | 2353 | void TogglePaint() |
---|
1418 | 2354 | { |
---|
1419 | 2355 | PAINTMODE ^= true; |
---|
1420 | 2356 | paintcount = 0; |
---|
| 2357 | + |
---|
| 2358 | + if (PAINTMODE) |
---|
| 2359 | + { |
---|
| 2360 | + paintFolder = GetFolder(); |
---|
| 2361 | + } |
---|
1421 | 2362 | } |
---|
1422 | 2363 | |
---|
1423 | 2364 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1513 | 2454 | { |
---|
1514 | 2455 | return currentGL; |
---|
1515 | 2456 | } |
---|
1516 | | - |
---|
| 2457 | + |
---|
| 2458 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2459 | + { |
---|
| 2460 | + Grafreed.Assert(texturedata != null); |
---|
| 2461 | + |
---|
| 2462 | + int width = texturedata.getWidth(); |
---|
| 2463 | + int height = texturedata.getHeight(); |
---|
| 2464 | + |
---|
| 2465 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2466 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2467 | + |
---|
| 2468 | + byte[] bytes = bytebuf.array(); |
---|
| 2469 | + |
---|
| 2470 | + return CreateBim(bytes, width, height); |
---|
| 2471 | + } |
---|
| 2472 | + |
---|
1517 | 2473 | /**/ |
---|
1518 | 2474 | class CacheTexture |
---|
1519 | 2475 | { |
---|
.. | .. |
---|
1522 | 2478 | |
---|
1523 | 2479 | int resolution; |
---|
1524 | 2480 | |
---|
1525 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2481 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1526 | 2482 | { |
---|
1527 | | - texture = tex; |
---|
| 2483 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2484 | + texturedata = texdata; |
---|
1528 | 2485 | resolution = res; |
---|
1529 | 2486 | } |
---|
1530 | 2487 | } |
---|
1531 | 2488 | /**/ |
---|
1532 | 2489 | |
---|
1533 | 2490 | // 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>(); |
---|
| 2491 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2492 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2493 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2494 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2495 | + |
---|
1537 | 2496 | int pigmentdepth = 0; |
---|
1538 | 2497 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1539 | 2498 | int bumpdepth = 0; |
---|
1540 | 2499 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1541 | 2500 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1542 | 2501 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1543 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2502 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1544 | 2503 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1545 | 2504 | |
---|
1546 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2505 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1547 | 2506 | { |
---|
1548 | 2507 | TextureData texturedata = null; |
---|
1549 | 2508 | |
---|
.. | .. |
---|
1562 | 2521 | if (bump) |
---|
1563 | 2522 | texturedata = ConvertBump(texturedata, false); |
---|
1564 | 2523 | |
---|
1565 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1566 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2524 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2525 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
1567 | 2526 | |
---|
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); |
---|
| 2527 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2528 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
1570 | 2529 | |
---|
1571 | | - return texture; |
---|
| 2530 | + return texturedata; |
---|
| 2531 | + } |
---|
| 2532 | + |
---|
| 2533 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2534 | + { |
---|
| 2535 | + TextureData texturedata = null; |
---|
| 2536 | + |
---|
| 2537 | + try |
---|
| 2538 | + { |
---|
| 2539 | + texturedata = |
---|
| 2540 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2541 | + bim, |
---|
| 2542 | + true); |
---|
| 2543 | + } catch (Exception e) |
---|
| 2544 | + { |
---|
| 2545 | + throw new javax.media.opengl.GLException(e); |
---|
| 2546 | + } |
---|
| 2547 | + |
---|
| 2548 | + if (bump) |
---|
| 2549 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2550 | + |
---|
| 2551 | + return texturedata; |
---|
1572 | 2552 | } |
---|
1573 | 2553 | |
---|
1574 | 2554 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2641 | 3621 | |
---|
2642 | 3622 | System.out.println("LOADING TEXTURE : " + name); |
---|
2643 | 3623 | |
---|
| 3624 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3625 | + |
---|
2644 | 3626 | // |
---|
2645 | 3627 | if (false) // compressbit > 0) |
---|
2646 | 3628 | { |
---|
.. | .. |
---|
3345 | 4327 | |
---|
3346 | 4328 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3347 | 4329 | { |
---|
| 4330 | + new Exception().printStackTrace(); |
---|
3348 | 4331 | System.exit(0); |
---|
3349 | 4332 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3350 | 4333 | |
---|
.. | .. |
---|
7038 | 8021 | String pigment = Object3D.GetPigment(tex); |
---|
7039 | 8022 | String bump = Object3D.GetBump(tex); |
---|
7040 | 8023 | |
---|
7041 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8024 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7042 | 8025 | { |
---|
7043 | 8026 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7044 | 8027 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7053 | 8036 | pigment = null; |
---|
7054 | 8037 | } |
---|
7055 | 8038 | |
---|
7056 | | - ReleaseTexture(bump, true); |
---|
7057 | | - ReleaseTexture(pigment, false); |
---|
| 8039 | + ReleaseTexture(tex, true); |
---|
| 8040 | + ReleaseTexture(tex, false); |
---|
7058 | 8041 | } |
---|
7059 | 8042 | |
---|
7060 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8043 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8044 | + { |
---|
| 8045 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8046 | + { |
---|
| 8047 | + return; |
---|
| 8048 | + } |
---|
| 8049 | + |
---|
| 8050 | + if (tex == null) |
---|
| 8051 | + { |
---|
| 8052 | + ReleaseTexture(null, false); |
---|
| 8053 | + return; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8057 | + |
---|
| 8058 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8059 | + { |
---|
| 8060 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8061 | + // System.out.println("; bump = " + bump); |
---|
| 8062 | + } |
---|
| 8063 | + |
---|
| 8064 | + if (pigment.equals("")) |
---|
| 8065 | + { |
---|
| 8066 | + pigment = null; |
---|
| 8067 | + } |
---|
| 8068 | + |
---|
| 8069 | + ReleaseTexture(tex, false); |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8073 | + { |
---|
| 8074 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8075 | + { |
---|
| 8076 | + return; |
---|
| 8077 | + } |
---|
| 8078 | + |
---|
| 8079 | + if (tex == null) |
---|
| 8080 | + { |
---|
| 8081 | + ReleaseTexture(null, true); |
---|
| 8082 | + return; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + String bump = Object3D.GetBump(tex); |
---|
| 8086 | + |
---|
| 8087 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8088 | + { |
---|
| 8089 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8090 | + // System.out.println("; bump = " + bump); |
---|
| 8091 | + } |
---|
| 8092 | + |
---|
| 8093 | + if (bump.equals("")) |
---|
| 8094 | + { |
---|
| 8095 | + bump = null; |
---|
| 8096 | + } |
---|
| 8097 | + |
---|
| 8098 | + ReleaseTexture(tex, true); |
---|
| 8099 | + } |
---|
| 8100 | + |
---|
| 8101 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7061 | 8102 | { |
---|
7062 | 8103 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7063 | 8104 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7068 | 8109 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7069 | 8110 | |
---|
7070 | 8111 | if (tex != null) |
---|
7071 | | - texture = textures.get(tex); |
---|
| 8112 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7072 | 8113 | |
---|
7073 | 8114 | // //assert( texture != null ); |
---|
7074 | 8115 | // if (texture == null) |
---|
.. | .. |
---|
7160 | 8201 | } |
---|
7161 | 8202 | } |
---|
7162 | 8203 | |
---|
7163 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8204 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8205 | + { |
---|
| 8206 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8207 | +// ambientOcclusion ) // || !textureon) |
---|
| 8208 | +// { |
---|
| 8209 | +// return; // false; |
---|
| 8210 | +// } |
---|
| 8211 | +// |
---|
| 8212 | +// if (tex == null) |
---|
| 8213 | +// { |
---|
| 8214 | +// BindTexture(null,false,resolution); |
---|
| 8215 | +// BindTexture(null,true,resolution); |
---|
| 8216 | +// return; |
---|
| 8217 | +// } |
---|
| 8218 | +// |
---|
| 8219 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8220 | +// String bump = Object3D.GetBump(tex); |
---|
| 8221 | +// |
---|
| 8222 | +// usedtextures.add(pigment); |
---|
| 8223 | +// usedtextures.add(bump); |
---|
| 8224 | +// |
---|
| 8225 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8226 | +// { |
---|
| 8227 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8228 | +// // System.out.println("; bump = " + bump); |
---|
| 8229 | +// } |
---|
| 8230 | +// |
---|
| 8231 | +// if (bump.equals("")) |
---|
| 8232 | +// { |
---|
| 8233 | +// bump = null; |
---|
| 8234 | +// } |
---|
| 8235 | +// if (pigment.equals("")) |
---|
| 8236 | +// { |
---|
| 8237 | +// pigment = null; |
---|
| 8238 | +// } |
---|
| 8239 | +// |
---|
| 8240 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8241 | +// BindTexture(pigment, false, resolution); |
---|
| 8242 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8243 | +// BindTexture(bump, true, resolution); |
---|
| 8244 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8245 | +// |
---|
| 8246 | +// return; // true; |
---|
| 8247 | + |
---|
| 8248 | + BindPigmentTexture(tex, resolution); |
---|
| 8249 | + BindBumpTexture(tex, resolution); |
---|
| 8250 | + } |
---|
| 8251 | + |
---|
| 8252 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7164 | 8253 | { |
---|
7165 | 8254 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7166 | 8255 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7171 | 8260 | if (tex == null) |
---|
7172 | 8261 | { |
---|
7173 | 8262 | BindTexture(null,false,resolution); |
---|
7174 | | - BindTexture(null,true,resolution); |
---|
7175 | 8263 | return; |
---|
7176 | 8264 | } |
---|
7177 | 8265 | |
---|
7178 | 8266 | String pigment = Object3D.GetPigment(tex); |
---|
| 8267 | + |
---|
| 8268 | + usedtextures.add(tex); |
---|
| 8269 | + |
---|
| 8270 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8271 | + { |
---|
| 8272 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8273 | + // System.out.println("; bump = " + bump); |
---|
| 8274 | + } |
---|
| 8275 | + |
---|
| 8276 | + if (pigment.equals("")) |
---|
| 8277 | + { |
---|
| 8278 | + pigment = null; |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8282 | + BindTexture(tex, false, resolution); |
---|
| 8283 | + } |
---|
| 8284 | + |
---|
| 8285 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8286 | + { |
---|
| 8287 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8288 | + ambientOcclusion ) // || !textureon) |
---|
| 8289 | + { |
---|
| 8290 | + return; // false; |
---|
| 8291 | + } |
---|
| 8292 | + |
---|
| 8293 | + if (tex == null) |
---|
| 8294 | + { |
---|
| 8295 | + BindTexture(null,true,resolution); |
---|
| 8296 | + return; |
---|
| 8297 | + } |
---|
| 8298 | + |
---|
7179 | 8299 | String bump = Object3D.GetBump(tex); |
---|
7180 | 8300 | |
---|
7181 | | - usedtextures.put(pigment, pigment); |
---|
7182 | | - usedtextures.put(bump, bump); |
---|
| 8301 | + usedtextures.add(tex); |
---|
7183 | 8302 | |
---|
7184 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8303 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7185 | 8304 | { |
---|
7186 | 8305 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7187 | 8306 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7191 | 8310 | { |
---|
7192 | 8311 | bump = null; |
---|
7193 | 8312 | } |
---|
7194 | | - if (pigment.equals("")) |
---|
7195 | | - { |
---|
7196 | | - pigment = null; |
---|
7197 | | - } |
---|
7198 | 8313 | |
---|
7199 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7200 | | - BindTexture(pigment, false, resolution); |
---|
7201 | 8314 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7202 | | - BindTexture(bump, true, resolution); |
---|
| 8315 | + BindTexture(tex, true, resolution); |
---|
7203 | 8316 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7204 | | - |
---|
7205 | | - return; // true; |
---|
7206 | 8317 | } |
---|
7207 | 8318 | |
---|
7208 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8319 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8320 | + |
---|
| 8321 | + private boolean FileExists(String tex) |
---|
7209 | 8322 | { |
---|
7210 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8323 | + if (missingTextures.contains(tex)) |
---|
| 8324 | + { |
---|
| 8325 | + return false; |
---|
| 8326 | + } |
---|
| 8327 | + |
---|
| 8328 | + boolean fileExists = new File(tex).exists(); |
---|
| 8329 | + |
---|
| 8330 | + if (!fileExists) |
---|
| 8331 | + { |
---|
| 8332 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8333 | + missingTextures.add(tex); |
---|
| 8334 | + } |
---|
| 8335 | + |
---|
| 8336 | + return fileExists; |
---|
| 8337 | + } |
---|
| 8338 | + |
---|
| 8339 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8340 | + { |
---|
| 8341 | + CacheTexture texturecache = null; |
---|
7211 | 8342 | |
---|
7212 | 8343 | if (tex != null) |
---|
7213 | 8344 | { |
---|
7214 | | - String texname = tex; |
---|
| 8345 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8346 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7215 | 8347 | |
---|
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; |
---|
| 8348 | + if (texname.equals("") && texdata == null) |
---|
| 8349 | + { |
---|
| 8350 | + return null; |
---|
| 8351 | + } |
---|
| 8352 | + |
---|
| 8353 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8354 | + |
---|
| 8355 | +// String[] split = tex.split("Textures"); |
---|
| 8356 | +// if (split.length > 1) |
---|
| 8357 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8358 | +// else |
---|
| 8359 | +// if (!texname.startsWith("/")) |
---|
| 8360 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8361 | + if (!FileExists(texname)) |
---|
| 8362 | + { |
---|
| 8363 | + texname = fallbackTextureName; |
---|
| 8364 | + } |
---|
7222 | 8365 | |
---|
7223 | 8366 | if (CACHETEXTURE) |
---|
7224 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7225 | | - |
---|
7226 | | - TextureData texturedata = null; |
---|
7227 | | - |
---|
7228 | | - if (texture == null || texture.resolution < resolution) |
---|
7229 | 8367 | { |
---|
7230 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8368 | + if (texdata == null) |
---|
| 8369 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8370 | + else |
---|
| 8371 | + texturecache = bimtextures.get(texdata); |
---|
| 8372 | + } |
---|
| 8373 | + |
---|
| 8374 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8375 | + { |
---|
| 8376 | + TextureData texturedata = null; |
---|
| 8377 | + |
---|
| 8378 | + if (texdata != null && textureon) |
---|
| 8379 | + { |
---|
| 8380 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8381 | + |
---|
| 8382 | + try |
---|
| 8383 | + { |
---|
| 8384 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8385 | + } |
---|
| 8386 | + catch (Exception e) |
---|
| 8387 | + { |
---|
| 8388 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8389 | + } |
---|
| 8390 | + |
---|
| 8391 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8392 | + bimtextures.put(texdata, texturecache); |
---|
| 8393 | + |
---|
| 8394 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8395 | + |
---|
| 8396 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8397 | + //bim2 = bim; |
---|
| 8398 | + } |
---|
| 8399 | + else |
---|
| 8400 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
7231 | 8401 | { |
---|
7232 | 8402 | assert(!bump); |
---|
7233 | 8403 | // if (bump) |
---|
.. | .. |
---|
7238 | 8408 | // } |
---|
7239 | 8409 | // else |
---|
7240 | 8410 | // { |
---|
7241 | | - texture = textures.get(tex); |
---|
7242 | | - if (texture == null) |
---|
| 8411 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8412 | + if (texturecache == null) |
---|
7243 | 8413 | { |
---|
7244 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8414 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7245 | 8415 | } |
---|
| 8416 | + else |
---|
| 8417 | + new Exception().printStackTrace(); |
---|
7246 | 8418 | // } |
---|
7247 | 8419 | } else |
---|
7248 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8420 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7249 | 8421 | { |
---|
7250 | 8422 | assert(bump); |
---|
7251 | | - texture = textures.get(tex); |
---|
7252 | | - if (texture == null) |
---|
7253 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8423 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8424 | + if (texturecache == null) |
---|
| 8425 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8426 | + else |
---|
| 8427 | + new Exception().printStackTrace(); |
---|
7254 | 8428 | } else |
---|
7255 | 8429 | { |
---|
7256 | 8430 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7258 | 8432 | // texture = GetResourceTexture("default.png"); |
---|
7259 | 8433 | //} else |
---|
7260 | 8434 | //{ |
---|
7261 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8435 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7262 | 8436 | { |
---|
7263 | | - texture = textures.get(tex); |
---|
7264 | | - if (texture == null) |
---|
7265 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8437 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8438 | + if (texturecache == null) |
---|
| 8439 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8440 | + else |
---|
| 8441 | + new Exception().printStackTrace(); |
---|
7266 | 8442 | } else |
---|
7267 | 8443 | { |
---|
7268 | 8444 | if (textureon) |
---|
.. | .. |
---|
7287 | 8463 | } |
---|
7288 | 8464 | |
---|
7289 | 8465 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7290 | | - if (!new File(cachename).exists()) |
---|
| 8466 | + if (!FileExists(cachename)) |
---|
7291 | 8467 | cachename = texname; |
---|
7292 | 8468 | else |
---|
7293 | 8469 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7309 | 8485 | } |
---|
7310 | 8486 | |
---|
7311 | 8487 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7312 | | - if (!new File(cachename).exists()) |
---|
| 8488 | + if (!FileExists(cachename)) |
---|
7313 | 8489 | cachename = texname; |
---|
7314 | 8490 | else |
---|
7315 | 8491 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7318 | 8494 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7319 | 8495 | |
---|
7320 | 8496 | |
---|
7321 | | - if (texturedata != null) |
---|
7322 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8497 | + if (texturedata == null) |
---|
| 8498 | + throw new Exception(); |
---|
| 8499 | + |
---|
| 8500 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
7323 | 8501 | //texture = GetTexture(tex, bump); |
---|
7324 | 8502 | } |
---|
7325 | 8503 | } |
---|
7326 | 8504 | //} |
---|
7327 | 8505 | } |
---|
7328 | 8506 | |
---|
7329 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8507 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7330 | 8508 | { |
---|
7331 | 8509 | //return false; |
---|
7332 | 8510 | |
---|
7333 | 8511 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7334 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8512 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7335 | 8513 | { |
---|
7336 | 8514 | // String ext = "_highres"; |
---|
7337 | 8515 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7348 | 8526 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7349 | 8527 | if (!cachefile.exists()) |
---|
7350 | 8528 | { |
---|
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)) |
---|
| 8529 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7360 | 8530 | { |
---|
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); |
---|
| 8531 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8532 | + |
---|
7391 | 8533 | ImageWriter writer = null; |
---|
7392 | 8534 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7393 | 8535 | if (iter.hasNext()) { |
---|
7394 | 8536 | writer = (ImageWriter)iter.next(); |
---|
7395 | 8537 | } |
---|
7396 | | - float compressionQuality = 0.9f; |
---|
| 8538 | + |
---|
| 8539 | + float compressionQuality = 0.85f; |
---|
7397 | 8540 | try |
---|
7398 | 8541 | { |
---|
7399 | 8542 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7410 | 8553 | } |
---|
7411 | 8554 | } |
---|
7412 | 8555 | } |
---|
7413 | | - |
---|
| 8556 | + |
---|
| 8557 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8558 | + |
---|
7414 | 8559 | //System.out.println("Texture = " + tex); |
---|
7415 | | - if (textures.containsKey(texname)) |
---|
| 8560 | + if (textures.containsKey(tex)) |
---|
7416 | 8561 | { |
---|
7417 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8562 | + CacheTexture thetex = textures.get(tex); |
---|
7418 | 8563 | thetex.texture.disable(); |
---|
7419 | 8564 | thetex.texture.dispose(); |
---|
7420 | | - textures.remove(texname); |
---|
| 8565 | + textures.remove(tex); |
---|
7421 | 8566 | } |
---|
7422 | 8567 | |
---|
7423 | | - texture.texturedata = texturedata; |
---|
7424 | | - textures.put(texname, texture); |
---|
| 8568 | + //texture.texturedata = texturedata; |
---|
| 8569 | + textures.put(tex, texturecache); |
---|
7425 | 8570 | |
---|
7426 | 8571 | // newtex = true; |
---|
7427 | 8572 | } |
---|
.. | .. |
---|
7437 | 8582 | } |
---|
7438 | 8583 | } |
---|
7439 | 8584 | |
---|
7440 | | - return texture; |
---|
| 8585 | + return texturecache; |
---|
7441 | 8586 | } |
---|
7442 | 8587 | |
---|
7443 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8588 | + static void EmbedTextures(cTexture tex) |
---|
| 8589 | + { |
---|
| 8590 | + if (tex.pigmentdata == null) |
---|
| 8591 | + { |
---|
| 8592 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8593 | + |
---|
| 8594 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8595 | + |
---|
| 8596 | + if (texturecache != null) |
---|
| 8597 | + { |
---|
| 8598 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8599 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8600 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8601 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8602 | + ; |
---|
| 8603 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8604 | + } |
---|
| 8605 | + } |
---|
| 8606 | + |
---|
| 8607 | + if (tex.bumpdata == null) |
---|
| 8608 | + { |
---|
| 8609 | + //String texname = Object3D.GetBump(tex); |
---|
| 8610 | + |
---|
| 8611 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8612 | + |
---|
| 8613 | + if (texturecache != null) |
---|
| 8614 | + { |
---|
| 8615 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8616 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8617 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8618 | + } |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7444 | 8623 | { |
---|
7445 | 8624 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7446 | 8625 | |
---|
.. | .. |
---|
7458 | 8637 | return texture!=null?texture.texture:null; |
---|
7459 | 8638 | } |
---|
7460 | 8639 | |
---|
7461 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8640 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7462 | 8641 | { |
---|
7463 | 8642 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7464 | 8643 | |
---|
7465 | 8644 | return texture!=null?texture.texturedata:null; |
---|
7466 | 8645 | } |
---|
7467 | 8646 | |
---|
7468 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8647 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7469 | 8648 | { |
---|
7470 | 8649 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7471 | 8650 | { |
---|
7472 | 8651 | return false; |
---|
7473 | 8652 | } |
---|
7474 | 8653 | |
---|
7475 | | - boolean newtex = false; |
---|
| 8654 | + //boolean newtex = false; |
---|
7476 | 8655 | |
---|
7477 | 8656 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7478 | 8657 | |
---|
.. | .. |
---|
7504 | 8683 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7505 | 8684 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7506 | 8685 | |
---|
7507 | | - return newtex; |
---|
| 8686 | + return true; // Warning: not used. |
---|
7508 | 8687 | } |
---|
7509 | 8688 | |
---|
| 8689 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8690 | + { |
---|
| 8691 | + try |
---|
| 8692 | + { |
---|
| 8693 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8694 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8695 | + ImageWriter writer = writers.next(); |
---|
| 8696 | + |
---|
| 8697 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8698 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8699 | + param.setCompressionQuality(quality); |
---|
| 8700 | + |
---|
| 8701 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8702 | + writer.setOutput(ios); |
---|
| 8703 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8704 | + |
---|
| 8705 | + byte[] data = baos.toByteArray(); |
---|
| 8706 | + writer.dispose(); |
---|
| 8707 | + return data; |
---|
| 8708 | + } |
---|
| 8709 | + catch (Exception e) |
---|
| 8710 | + { |
---|
| 8711 | + e.printStackTrace(); |
---|
| 8712 | + return null; |
---|
| 8713 | + } |
---|
| 8714 | + } |
---|
| 8715 | + |
---|
| 8716 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8717 | + { |
---|
| 8718 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8719 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8720 | + ImageReader reader = writers.next(); |
---|
| 8721 | + |
---|
| 8722 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8723 | + |
---|
| 8724 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8725 | + param.setDestination(bim); |
---|
| 8726 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8727 | + |
---|
| 8728 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8729 | + reader.setInput(ios); |
---|
| 8730 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8731 | + reader.dispose(); |
---|
| 8732 | + |
---|
| 8733 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8734 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8735 | +// byte[] bytes = data.getData(); |
---|
| 8736 | +// |
---|
| 8737 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8738 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8739 | +// { |
---|
| 8740 | +// int i3 = i*3; |
---|
| 8741 | +// pixels[i] = 0xFF; |
---|
| 8742 | +// pixels[i] <<= 8; |
---|
| 8743 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8744 | +// pixels[i] <<= 8; |
---|
| 8745 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8746 | +// pixels[i] <<= 8; |
---|
| 8747 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8748 | +// } |
---|
| 8749 | +// |
---|
| 8750 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8751 | + |
---|
| 8752 | + return bim; |
---|
| 8753 | + } |
---|
| 8754 | + |
---|
7510 | 8755 | ShadowBuffer shadowPBuf; |
---|
7511 | 8756 | AntialiasBuffer antialiasPBuf; |
---|
7512 | 8757 | int MAXSTACK; |
---|
.. | .. |
---|
7699 | 8944 | |
---|
7700 | 8945 | if (cubemap == null) |
---|
7701 | 8946 | { |
---|
7702 | | - LoadEnvy(5); |
---|
| 8947 | + //LoadEnvy(1); |
---|
7703 | 8948 | } |
---|
7704 | 8949 | |
---|
7705 | 8950 | //cubemap.enable(); |
---|
.. | .. |
---|
7986 | 9231 | cubemap = null; |
---|
7987 | 9232 | return; |
---|
7988 | 9233 | case 1: |
---|
7989 | | - name = "cubemaps/box_"; |
---|
7990 | | - ext = "png"; |
---|
| 9234 | + name = "cubemaps/rgb/"; |
---|
| 9235 | + ext = "jpg"; |
---|
7991 | 9236 | reverseUP = false; |
---|
7992 | 9237 | break; |
---|
7993 | 9238 | case 2: |
---|
7994 | | - name = "cubemaps/uffizi_"; |
---|
7995 | | - ext = "png"; |
---|
7996 | | - break; // reverseUP = true; break; |
---|
| 9239 | + name = "cubemaps/uffizi/"; |
---|
| 9240 | + ext = "jpg"; |
---|
| 9241 | + reverseUP = false; |
---|
| 9242 | + break; |
---|
7997 | 9243 | case 3: |
---|
7998 | | - name = "cubemaps/CloudyHills_"; |
---|
7999 | | - ext = "tga"; |
---|
| 9244 | + name = "cubemaps/CloudyHills/"; |
---|
| 9245 | + ext = "jpg"; |
---|
8000 | 9246 | reverseUP = false; |
---|
8001 | 9247 | break; |
---|
8002 | 9248 | case 4: |
---|
8003 | | - name = "cubemaps/cornell_"; |
---|
| 9249 | + name = "cubemaps/cornell/"; |
---|
8004 | 9250 | ext = "png"; |
---|
8005 | 9251 | reverseUP = false; |
---|
8006 | 9252 | break; |
---|
| 9253 | + case 5: |
---|
| 9254 | + name = "cubemaps/skycube/"; |
---|
| 9255 | + ext = "jpg"; |
---|
| 9256 | + reverseUP = false; |
---|
| 9257 | + break; |
---|
| 9258 | + case 6: |
---|
| 9259 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
| 9263 | + case 7: |
---|
| 9264 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 8: |
---|
| 9269 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 9: |
---|
| 9274 | + name = "cubemaps/UnionSquare/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
8007 | 9278 | default: |
---|
8008 | | - name = "cubemaps/rgb_"; |
---|
8009 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9279 | + name = "cubemaps/box/"; |
---|
| 9280 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9281 | + reverseUP = false; |
---|
8010 | 9282 | break; |
---|
8011 | 9283 | } |
---|
8012 | | - |
---|
8013 | | - try |
---|
8014 | | - { |
---|
8015 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8016 | | - } catch (IOException e) |
---|
8017 | | - { |
---|
8018 | | - throw new RuntimeException(e); |
---|
8019 | | - } |
---|
| 9284 | + |
---|
| 9285 | + LoadSkybox(name, ext, mipmap); |
---|
8020 | 9286 | } |
---|
8021 | 9287 | |
---|
8022 | 9288 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8048 | 9314 | static double[] model = new double[16]; |
---|
8049 | 9315 | double[] camera2light = new double[16]; |
---|
8050 | 9316 | double[] light2camera = new double[16]; |
---|
8051 | | - int newenvy = -1; |
---|
8052 | | - boolean envyoff = true; // false; |
---|
| 9317 | + |
---|
| 9318 | + //int newenvy = -1; |
---|
| 9319 | + //boolean envyoff = false; |
---|
| 9320 | + |
---|
| 9321 | + String loadedskyboxname; |
---|
| 9322 | + |
---|
8053 | 9323 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8054 | 9324 | //float[] light0 = { 0,0,0 }; |
---|
8055 | 9325 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
8342 | 9612 | jy8[3] = 0.5f; |
---|
8343 | 9613 | } |
---|
8344 | 9614 | |
---|
8345 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9615 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
8346 | 9616 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8347 | 9617 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8348 | 9618 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8349 | 9619 | |
---|
| 9620 | + void ResetOptions() |
---|
| 9621 | + { |
---|
| 9622 | + options1[0] = 100; |
---|
| 9623 | + options1[1] = 0.025f; |
---|
| 9624 | + options1[2] = 0.01f; |
---|
| 9625 | + options1[3] = 0; |
---|
| 9626 | + options1[4] = 0; |
---|
| 9627 | + |
---|
| 9628 | + options2[0] = 0; |
---|
| 9629 | + options2[1] = 0.75f; |
---|
| 9630 | + options2[2] = 0; |
---|
| 9631 | + options2[3] = 0; |
---|
| 9632 | + |
---|
| 9633 | + options3[0] = 1; |
---|
| 9634 | + options3[1] = 1; |
---|
| 9635 | + options3[2] = 1; |
---|
| 9636 | + options3[3] = 0; |
---|
| 9637 | + |
---|
| 9638 | + options4[0] = 1; |
---|
| 9639 | + options4[1] = 0; |
---|
| 9640 | + options4[2] = 1; |
---|
| 9641 | + options4[3] = 0; |
---|
| 9642 | + } |
---|
| 9643 | + |
---|
8350 | 9644 | static int imagecount = 0; // movie generation |
---|
8351 | 9645 | |
---|
8352 | 9646 | static int jitter = 0; |
---|
.. | .. |
---|
8442 | 9736 | assert (parentcam != renderCamera); |
---|
8443 | 9737 | |
---|
8444 | 9738 | if (renderCamera != lightCamera) |
---|
8445 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8446 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9739 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9740 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8447 | 9741 | |
---|
8448 | 9742 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8449 | 9743 | |
---|
.. | .. |
---|
8458 | 9752 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8459 | 9753 | |
---|
8460 | 9754 | if (renderCamera != lightCamera) |
---|
8461 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8462 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9755 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9756 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8463 | 9757 | |
---|
8464 | 9758 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8465 | 9759 | |
---|
.. | .. |
---|
8505 | 9799 | rati = 1 / rati; |
---|
8506 | 9800 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
8507 | 9801 | } |
---|
8508 | | - assert (newenvy == -1); |
---|
| 9802 | + |
---|
| 9803 | + //assert (newenvy == -1); |
---|
| 9804 | + |
---|
8509 | 9805 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
8510 | 9806 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
8511 | | - DrawSkyBox(gl); |
---|
| 9807 | + DrawSkyBox(gl, (float)rati); |
---|
8512 | 9808 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
8513 | 9809 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
8514 | 9810 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
8531 | 9827 | //gl.glFlush(); |
---|
8532 | 9828 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8533 | 9829 | |
---|
8534 | | - if (ANIMATION && ABORTED) |
---|
| 9830 | + if (Globals.ANIMATION && ABORTED) |
---|
8535 | 9831 | { |
---|
8536 | 9832 | System.err.println(" ABORTED FRAME"); |
---|
8537 | 9833 | break; |
---|
.. | .. |
---|
8561 | 9857 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8562 | 9858 | |
---|
8563 | 9859 | // save image |
---|
8564 | | - if (ANIMATION && !ABORTED) |
---|
| 9860 | + if (Globals.ANIMATION && !ABORTED) |
---|
8565 | 9861 | { |
---|
8566 | 9862 | VPwidth = viewport[2]; |
---|
8567 | 9863 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8672 | 9968 | |
---|
8673 | 9969 | // imagecount++; |
---|
8674 | 9970 | |
---|
8675 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9971 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
8676 | 9972 | |
---|
8677 | 9973 | if (!BOXMODE) |
---|
8678 | 9974 | { |
---|
8679 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9975 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
8680 | 9976 | } |
---|
8681 | 9977 | |
---|
8682 | 9978 | if (!BOXMODE) |
---|
.. | .. |
---|
8714 | 10010 | ABORTED = false; |
---|
8715 | 10011 | } |
---|
8716 | 10012 | else |
---|
8717 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10013 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8718 | 10014 | |
---|
8719 | 10015 | if (false) |
---|
8720 | 10016 | { |
---|
.. | .. |
---|
9377 | 10673 | |
---|
9378 | 10674 | public void display(GLAutoDrawable drawable) |
---|
9379 | 10675 | { |
---|
9380 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10676 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9381 | 10677 | { |
---|
9382 | | - GrafreeD.wav.save(); |
---|
9383 | | - GrafreeD.savesound = false; |
---|
9384 | | - GrafreeD.hassound = false; |
---|
| 10678 | + Grafreed.wav.save(); |
---|
| 10679 | + Grafreed.savesound = false; |
---|
| 10680 | + Grafreed.hassound = false; |
---|
9385 | 10681 | } |
---|
9386 | 10682 | // if (DEBUG_SELECTION) |
---|
9387 | 10683 | // { |
---|
.. | .. |
---|
9457 | 10753 | ANTIALIAS = 0; |
---|
9458 | 10754 | //System.out.println("RESTART"); |
---|
9459 | 10755 | AAtimer.restart(); |
---|
| 10756 | + Globals.TIMERRUNNING = true; |
---|
9460 | 10757 | } |
---|
9461 | 10758 | } |
---|
9462 | 10759 | } |
---|
.. | .. |
---|
9511 | 10808 | Object3D theobject = object; |
---|
9512 | 10809 | Object3D theparent = object.parent; |
---|
9513 | 10810 | object.parent = null; |
---|
9514 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10811 | + object = (Object3D)Grafreed.clone(object); |
---|
9515 | 10812 | object.Stripify(); |
---|
9516 | 10813 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9517 | 10814 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9524 | 10821 | ambientOcclusion = false; |
---|
9525 | 10822 | } |
---|
9526 | 10823 | |
---|
9527 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10824 | + if (//Globals.lighttouched && |
---|
| 10825 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9528 | 10826 | { |
---|
9529 | 10827 | //if (RENDERSHADOW) // ? |
---|
9530 | 10828 | if (!IsFrozen()) |
---|
9531 | 10829 | { |
---|
9532 | 10830 | // dec 2012 |
---|
9533 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10831 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9534 | 10832 | { |
---|
9535 | 10833 | Globals.framecount++; |
---|
9536 | 10834 | shadowbuffer.display(); |
---|
.. | .. |
---|
9657 | 10955 | |
---|
9658 | 10956 | // if (parentcam != renderCamera) // not a light |
---|
9659 | 10957 | if (cam != lightCamera) |
---|
9660 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9661 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10958 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10959 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9662 | 10960 | |
---|
9663 | 10961 | for (int j = 0; j < 4; j++) |
---|
9664 | 10962 | { |
---|
.. | .. |
---|
9672 | 10970 | |
---|
9673 | 10971 | // if (parentcam != renderCamera) // not a light |
---|
9674 | 10972 | if (cam != lightCamera) |
---|
9675 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9676 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10973 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10974 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9677 | 10975 | |
---|
9678 | 10976 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9679 | 10977 | |
---|
.. | .. |
---|
9759 | 11057 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
9760 | 11058 | } |
---|
9761 | 11059 | |
---|
9762 | | - if (newenvy > -1) |
---|
| 11060 | +// if (newenvy > -1) |
---|
| 11061 | +// { |
---|
| 11062 | +// LoadEnvy(newenvy); |
---|
| 11063 | +// } |
---|
| 11064 | +// |
---|
| 11065 | +// newenvy = -1; |
---|
| 11066 | + |
---|
| 11067 | + if (object.skyboxname != null) |
---|
9763 | 11068 | { |
---|
9764 | | - LoadEnvy(newenvy); |
---|
| 11069 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11070 | + { |
---|
| 11071 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11072 | + loadedskyboxname = object.skyboxname; |
---|
| 11073 | + } |
---|
9765 | 11074 | } |
---|
9766 | | - |
---|
9767 | | - newenvy = -1; |
---|
9768 | | - |
---|
| 11075 | + else |
---|
| 11076 | + { |
---|
| 11077 | + cubemap = null; |
---|
| 11078 | + loadedskyboxname = null; |
---|
| 11079 | + } |
---|
| 11080 | + |
---|
9769 | 11081 | ratio = ((double) getWidth()) / getHeight(); |
---|
9770 | 11082 | //System.out.println("ratio = " + ratio); |
---|
9771 | 11083 | |
---|
.. | .. |
---|
9781 | 11093 | |
---|
9782 | 11094 | if (!IsFrozen() && !ambientOcclusion) |
---|
9783 | 11095 | { |
---|
9784 | | - DrawSkyBox(gl); |
---|
| 11096 | + DrawSkyBox(gl, (float)ratio); |
---|
9785 | 11097 | } |
---|
9786 | 11098 | |
---|
9787 | 11099 | //if (selection_view == -1) |
---|
.. | .. |
---|
9932 | 11244 | // Bump noise |
---|
9933 | 11245 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9934 | 11246 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9935 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11247 | + |
---|
| 11248 | + try |
---|
| 11249 | + { |
---|
| 11250 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11251 | + } |
---|
| 11252 | + catch (Exception e) |
---|
| 11253 | + { |
---|
| 11254 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11255 | + } |
---|
| 11256 | + |
---|
9936 | 11257 | |
---|
9937 | 11258 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9938 | 11259 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9955 | 11276 | |
---|
9956 | 11277 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9957 | 11278 | |
---|
9958 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9959 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9960 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11279 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11280 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11281 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9961 | 11282 | } else |
---|
9962 | 11283 | { |
---|
9963 | 11284 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9968 | 11289 | //System.out.println("BLENDING ON"); |
---|
9969 | 11290 | gl.glEnable(GL.GL_BLEND); |
---|
9970 | 11291 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9971 | | - |
---|
| 11292 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9972 | 11293 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9973 | 11294 | gl.glLoadIdentity(); |
---|
9974 | 11295 | |
---|
.. | .. |
---|
10057 | 11378 | System.err.println("parentcam != renderCamera"); |
---|
10058 | 11379 | |
---|
10059 | 11380 | // if (cam != lightCamera) |
---|
10060 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10061 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11381 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11382 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10062 | 11383 | } |
---|
10063 | 11384 | |
---|
10064 | 11385 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10079 | 11400 | if (true) // TODO |
---|
10080 | 11401 | { |
---|
10081 | 11402 | if (cam != lightCamera) |
---|
10082 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10083 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11403 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11404 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10084 | 11405 | } |
---|
10085 | 11406 | |
---|
10086 | 11407 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10146 | 11467 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10147 | 11468 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10148 | 11469 | |
---|
10149 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11470 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10150 | 11471 | { |
---|
10151 | 11472 | /* |
---|
10152 | 11473 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10217 | 11538 | } |
---|
10218 | 11539 | } |
---|
10219 | 11540 | |
---|
10220 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11541 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10221 | 11542 | { |
---|
10222 | 11543 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10223 | 11544 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10225 | 11546 | |
---|
10226 | 11547 | boolean texon = textureon; |
---|
10227 | 11548 | |
---|
10228 | | - if (RENDERPROGRAM > 0) |
---|
10229 | | - { |
---|
10230 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10231 | | - textureon = false; |
---|
10232 | | - } |
---|
| 11549 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11550 | + textureon = false; |
---|
| 11551 | + |
---|
10233 | 11552 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10234 | 11553 | //System.out.println("ALLO"); |
---|
10235 | 11554 | gl.glColorMask(false, false, false, false); |
---|
10236 | 11555 | DrawObject(gl); |
---|
10237 | | - if (RENDERPROGRAM > 0) |
---|
10238 | | - { |
---|
10239 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10240 | | - textureon = texon; |
---|
10241 | | - } |
---|
| 11556 | + |
---|
| 11557 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11558 | + textureon = texon; |
---|
| 11559 | + |
---|
10242 | 11560 | gl.glColorMask(true, true, true, true); |
---|
10243 | 11561 | |
---|
10244 | 11562 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10245 | | - //gl.glDepthMask(false); |
---|
| 11563 | + gl.glDepthMask(false); |
---|
10246 | 11564 | } |
---|
10247 | 11565 | |
---|
10248 | 11566 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10396 | 11714 | { |
---|
10397 | 11715 | renderpass++; |
---|
10398 | 11716 | // System.out.println("Draw object... "); |
---|
| 11717 | + STEP = 1; |
---|
10399 | 11718 | if (FAST) // in case there is no script |
---|
10400 | | - STEP = 16; |
---|
| 11719 | + STEP = 8; |
---|
| 11720 | + |
---|
| 11721 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11722 | + { |
---|
| 11723 | + STEP *= 4; |
---|
| 11724 | + } |
---|
10401 | 11725 | |
---|
10402 | 11726 | //object.FullInvariants(); |
---|
10403 | 11727 | |
---|
.. | .. |
---|
10411 | 11735 | e.printStackTrace(); |
---|
10412 | 11736 | } |
---|
10413 | 11737 | |
---|
10414 | | - if (GrafreeD.RENDERME > 0) |
---|
10415 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11738 | + if (Grafreed.RENDERME > 0) |
---|
| 11739 | + Grafreed.RENDERME--; // mechante magouille |
---|
10416 | 11740 | |
---|
10417 | 11741 | Globals.ONESTEP = false; |
---|
10418 | 11742 | } |
---|
10419 | 11743 | |
---|
10420 | 11744 | static boolean zoomonce = false; |
---|
10421 | 11745 | |
---|
| 11746 | + static void CreateSelectedPoint() |
---|
| 11747 | + { |
---|
| 11748 | + if (selectedpoint == null) |
---|
| 11749 | + { |
---|
| 11750 | + debugpointG = new Sphere(); |
---|
| 11751 | + debugpointP = new Sphere(); |
---|
| 11752 | + debugpointC = new Sphere(); |
---|
| 11753 | + debugpointR = new Sphere(); |
---|
| 11754 | + |
---|
| 11755 | + selectedpoint = new Superellipsoid(); |
---|
| 11756 | + |
---|
| 11757 | + for (int i=0; i<8; i++) |
---|
| 11758 | + { |
---|
| 11759 | + debugpoints[i] = new Sphere(); |
---|
| 11760 | + } |
---|
| 11761 | + } |
---|
| 11762 | + } |
---|
| 11763 | + |
---|
10422 | 11764 | void DrawObject(GL gl, boolean draw) |
---|
10423 | 11765 | { |
---|
| 11766 | + // To clear camera values |
---|
| 11767 | + ResetOptions(); |
---|
| 11768 | + |
---|
10424 | 11769 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10425 | 11770 | // DrawMode() = SELECTION; |
---|
10426 | 11771 | //GL gl = getGL(); |
---|
10427 | 11772 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10428 | 11773 | { |
---|
10429 | 11774 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10430 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11775 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10431 | 11776 | pingthread.StepToTarget(true); // true); |
---|
10432 | 11777 | // zoomonce = false; |
---|
10433 | 11778 | } |
---|
.. | .. |
---|
10447 | 11792 | callist = gl.glGenLists(1); |
---|
10448 | 11793 | } |
---|
10449 | 11794 | |
---|
10450 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11795 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10451 | 11796 | |
---|
10452 | 11797 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10453 | 11798 | |
---|
.. | .. |
---|
10482 | 11827 | |
---|
10483 | 11828 | usedtextures.clear(); |
---|
10484 | 11829 | |
---|
10485 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11830 | + try |
---|
| 11831 | + { |
---|
| 11832 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11833 | + } |
---|
| 11834 | + catch (Exception e) |
---|
| 11835 | + { |
---|
| 11836 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11837 | + } |
---|
10486 | 11838 | } |
---|
10487 | 11839 | //System.out.println("--> " + stackdepth); |
---|
10488 | 11840 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10492 | 11844 | |
---|
10493 | 11845 | if (DrawMode() == DEFAULT) |
---|
10494 | 11846 | { |
---|
10495 | | - if (DEBUG) |
---|
| 11847 | + if (Globals.DEBUG) |
---|
10496 | 11848 | { |
---|
| 11849 | + CreateSelectedPoint(); |
---|
10497 | 11850 | float radius = 0.05f; |
---|
10498 | 11851 | if (selectedpoint.radius != radius) |
---|
10499 | 11852 | { |
---|
.. | .. |
---|
10547 | 11900 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10548 | 11901 | |
---|
10549 | 11902 | if (CLEANCACHE) |
---|
10550 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11903 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10551 | 11904 | { |
---|
10552 | | - String tex = e.nextElement(); |
---|
| 11905 | + cTexture tex = e.nextElement(); |
---|
10553 | 11906 | |
---|
10554 | 11907 | // System.out.println("Texture --------- " + tex); |
---|
10555 | 11908 | |
---|
10556 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11909 | + if (tex.equals("WHITE_NOISE:")) |
---|
10557 | 11910 | continue; |
---|
10558 | 11911 | |
---|
10559 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11912 | + if (!usedtextures.contains(tex)) |
---|
10560 | 11913 | { |
---|
| 11914 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10561 | 11915 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10562 | | - textures.get(tex).texture.dispose(); |
---|
10563 | | - textures.remove(tex); |
---|
| 11916 | + if (gettex != null) |
---|
| 11917 | + { |
---|
| 11918 | + gettex.texture.dispose(); |
---|
| 11919 | + texturepigment.remove(tex); |
---|
| 11920 | + } |
---|
| 11921 | + |
---|
| 11922 | + gettex = texturebump.get(tex); |
---|
| 11923 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11924 | + if (gettex != null) |
---|
| 11925 | + { |
---|
| 11926 | + gettex.texture.dispose(); |
---|
| 11927 | + texturebump.remove(tex); |
---|
| 11928 | + } |
---|
10564 | 11929 | } |
---|
10565 | 11930 | } |
---|
10566 | 11931 | } |
---|
.. | .. |
---|
10573 | 11938 | if (checker != null && DrawMode() == DEFAULT) |
---|
10574 | 11939 | { |
---|
10575 | 11940 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10576 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11941 | + try |
---|
| 11942 | + { |
---|
| 11943 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11944 | + } |
---|
| 11945 | + catch (Exception e) |
---|
| 11946 | + { |
---|
| 11947 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11948 | + } |
---|
10577 | 11949 | // NEAREST |
---|
10578 | 11950 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10579 | 11951 | DrawChecker(gl); |
---|
.. | .. |
---|
10655 | 12027 | return; |
---|
10656 | 12028 | } |
---|
10657 | 12029 | |
---|
10658 | | - String string = obj.GetToolTip(); |
---|
| 12030 | + String string = obj.toString(); //.GetToolTip(); |
---|
10659 | 12031 | |
---|
10660 | 12032 | GL gl = GetGL(); |
---|
10661 | 12033 | |
---|
.. | .. |
---|
10972 | 12344 | //obj.TransformToWorld(light, light); |
---|
10973 | 12345 | for (int i = tp.size(); --i >= 0;) |
---|
10974 | 12346 | { |
---|
10975 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10976 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12347 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12348 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10977 | 12349 | } |
---|
10978 | 12350 | |
---|
10979 | 12351 | |
---|
.. | .. |
---|
10990 | 12362 | parentcam = cameras[0]; |
---|
10991 | 12363 | } |
---|
10992 | 12364 | |
---|
10993 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10994 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12365 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12366 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10995 | 12367 | |
---|
10996 | 12368 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10997 | 12369 | |
---|
.. | .. |
---|
11081 | 12453 | |
---|
11082 | 12454 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11083 | 12455 | |
---|
11084 | | - String program = |
---|
| 12456 | + String programmin = |
---|
| 12457 | + // Min shader |
---|
11085 | 12458 | "!!ARBfp1.0\n" + |
---|
| 12459 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12460 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12461 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12462 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12463 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12464 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12465 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12466 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12467 | + "TEMP temp;" + |
---|
| 12468 | + "TEMP light;" + |
---|
| 12469 | + "TEMP ndotl;" + |
---|
| 12470 | + "TEMP normal;" + |
---|
| 12471 | + "TEMP depth;" + |
---|
| 12472 | + "TEMP eye;" + |
---|
| 12473 | + "TEMP pos;" + |
---|
| 12474 | + |
---|
| 12475 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12476 | + Normalize("normal") + |
---|
| 12477 | + "MOV light, state.light[0].position;" + |
---|
| 12478 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12479 | + |
---|
| 12480 | + // shadow |
---|
| 12481 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12482 | + "MOV temp, pos;" + |
---|
| 12483 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12484 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12485 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12486 | + |
---|
| 12487 | + // No shadow when out of frustum |
---|
| 12488 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12489 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12490 | + |
---|
| 12491 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12492 | + |
---|
| 12493 | + // Backlit |
---|
| 12494 | + "MOV pos.w, zero123.y;" + |
---|
| 12495 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12496 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12497 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12498 | + Normalize("eye") + |
---|
| 12499 | + |
---|
| 12500 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12501 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12502 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12503 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12504 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12505 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12506 | + |
---|
| 12507 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12508 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12509 | + |
---|
| 12510 | + // Pigment |
---|
| 12511 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12512 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12513 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12514 | + |
---|
| 12515 | + "MUL temp, temp, zero123.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12518 | + |
---|
| 12519 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12520 | + "MOV result.color, temp;" + |
---|
| 12521 | + "END"; |
---|
| 12522 | + |
---|
| 12523 | + String programmax = |
---|
| 12524 | + "!!ARBfp1.0\n" + |
---|
| 12525 | + |
---|
11086 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11087 | 12527 | "PARAM light2cam0 = program.env[10];" + |
---|
11088 | 12528 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
11197 | 12637 | "TEMP shininess;" + |
---|
11198 | 12638 | "\n" + |
---|
11199 | 12639 | "MOV texSamp, one;" + |
---|
11200 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
11201 | | - |
---|
| 12640 | + |
---|
11202 | 12641 | "MOV mapgrid.x, one2048th.x;" + |
---|
11203 | 12642 | "MOV temp, fragment.texcoord[1];" + |
---|
11204 | 12643 | /* |
---|
.. | .. |
---|
11219 | 12658 | "MUL temp, floor, mapgrid.x;" + |
---|
11220 | 12659 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
11221 | 12660 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11222 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12661 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
11223 | 12662 | "") + |
---|
11224 | 12663 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
11225 | 12664 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
11226 | 12665 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11227 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12666 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
11228 | 12667 | "") + |
---|
11229 | 12668 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
11230 | 12669 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
11231 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12670 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
11232 | 12671 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
11233 | 12672 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
11234 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11235 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
11236 | 12675 | "") + |
---|
11237 | 12676 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
11238 | 12677 | //"MOV params, material;" + |
---|
.. | .. |
---|
11603 | 13042 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
11604 | 13043 | "") + |
---|
11605 | 13044 | |
---|
11606 | | - // display shadow only (bump == 0) |
---|
| 13045 | + // display shadow only (fakedepth == 0) |
---|
11607 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
11608 | | - "MOV temp.y, -params6.x;" + |
---|
11609 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13047 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
11610 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
11611 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
11612 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
11735 | 13174 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11736 | 13175 | |
---|
11737 | 13176 | "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 |
---|
| 13177 | + // Tuning for default skin |
---|
| 13178 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13179 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13180 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11740 | 13181 | "MUL temp.x, temp.x, temp.y;" + |
---|
11741 | 13182 | |
---|
11742 | 13183 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11935 | 13376 | //once = true; |
---|
11936 | 13377 | } |
---|
11937 | 13378 | |
---|
11938 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
| 13386 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
11939 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
11940 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11941 | 13389 | |
---|
.. | .. |
---|
12028 | 13476 | return out; |
---|
12029 | 13477 | } |
---|
12030 | 13478 | |
---|
12031 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13479 | + // Also does frustum culling |
---|
| 13480 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12032 | 13481 | { |
---|
12033 | 13482 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12034 | 13483 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12035 | 13484 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13485 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13486 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12036 | 13487 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12037 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12038 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12039 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12040 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13488 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13489 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12041 | 13490 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12042 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13491 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12043 | 13492 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12044 | 13493 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12045 | 13494 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12046 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13495 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12047 | 13496 | |
---|
12048 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12049 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13497 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13498 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12050 | 13499 | } |
---|
12051 | 13500 | |
---|
12052 | 13501 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12068 | 13517 | |
---|
12069 | 13518 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12070 | 13519 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13520 | + |
---|
| 13521 | + // Compare fragment depth in light space with shadowmap. |
---|
12071 | 13522 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12072 | 13523 | "SGE temp.y, temp.x, zero.x;" + |
---|
12073 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13524 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13525 | + |
---|
| 13526 | + // Reverse comparison |
---|
12074 | 13527 | "SUB temp.x, one.x, temp.x;" + |
---|
12075 | 13528 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12076 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13529 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12077 | 13530 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12078 | 13531 | |
---|
12079 | 13532 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12087 | 13540 | // No shadow for backface |
---|
12088 | 13541 | "DP3 temp.x, normal, lightd;" + |
---|
12089 | 13542 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13543 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13544 | + |
---|
| 13545 | + // No shadow when out of frustum |
---|
| 13546 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12090 | 13547 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12091 | 13548 | ""; |
---|
12092 | 13549 | } |
---|
.. | .. |
---|
12233 | 13690 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12234 | 13691 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12235 | 13692 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12236 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13693 | + |
---|
| 13694 | + //Object3D.cVector2[] vector2buffer; |
---|
12237 | 13695 | |
---|
12238 | 13696 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12239 | 13697 | // OUT : diff, spec |
---|
.. | .. |
---|
12249 | 13707 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12250 | 13708 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12251 | 13709 | //"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;" + |
---|
| 13710 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13711 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13712 | + |
---|
| 13713 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12255 | 13714 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12256 | 13715 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12257 | 13716 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12645 | 14104 | public void mousePressed(MouseEvent e) |
---|
12646 | 14105 | { |
---|
12647 | 14106 | //System.out.println("mousePressed: " + e); |
---|
12648 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14107 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12649 | 14108 | } |
---|
12650 | 14109 | |
---|
12651 | 14110 | static long prevtime = 0; |
---|
.. | .. |
---|
12672 | 14131 | |
---|
12673 | 14132 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12674 | 14133 | |
---|
| 14134 | + if (BUTTONLESSWHEEL) |
---|
12675 | 14135 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12676 | 14136 | { |
---|
12677 | 14137 | return; |
---|
.. | .. |
---|
12680 | 14140 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12681 | 14141 | |
---|
12682 | 14142 | // TIMER |
---|
12683 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14143 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12684 | 14144 | { |
---|
12685 | 14145 | keepboxmode = BOXMODE; |
---|
12686 | 14146 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12720 | 14180 | // mode |= META; |
---|
12721 | 14181 | //} |
---|
12722 | 14182 | |
---|
12723 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12724 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14183 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14184 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12725 | 14185 | anchorX = ax; |
---|
12726 | 14186 | anchorY = ay; |
---|
12727 | 14187 | prevX = px; |
---|
.. | .. |
---|
12755 | 14215 | else |
---|
12756 | 14216 | if (evt.getSource() == AAtimer) |
---|
12757 | 14217 | { |
---|
| 14218 | + Globals.TIMERRUNNING = false; |
---|
12758 | 14219 | if (mouseDown) |
---|
12759 | 14220 | { |
---|
12760 | 14221 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12780 | 14241 | // LIVE = waslive; |
---|
12781 | 14242 | // wasliveok = true; |
---|
12782 | 14243 | // waslive = false; |
---|
| 14244 | + |
---|
| 14245 | + // May 2019 Forget it: |
---|
| 14246 | + if (true) |
---|
| 14247 | + return; |
---|
12783 | 14248 | |
---|
12784 | 14249 | // source == timer |
---|
12785 | 14250 | if (mouseDown) |
---|
.. | .. |
---|
12810 | 14275 | |
---|
12811 | 14276 | // fev 2014??? |
---|
12812 | 14277 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12813 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14278 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12814 | 14279 | pingthread.StepToTarget(true); // true); |
---|
12815 | 14280 | } |
---|
12816 | 14281 | // if (!LIVE) |
---|
.. | .. |
---|
12819 | 14284 | |
---|
12820 | 14285 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12821 | 14286 | |
---|
12822 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14287 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12823 | 14288 | { |
---|
12824 | 14289 | if (!wasliveok) |
---|
12825 | 14290 | return; |
---|
12826 | 14291 | |
---|
12827 | 14292 | AAtimer.restart(); // |
---|
| 14293 | + Globals.TIMERRUNNING = true; |
---|
12828 | 14294 | |
---|
12829 | 14295 | // waslive = LIVE; |
---|
12830 | 14296 | // LIVE = false; |
---|
.. | .. |
---|
12836 | 14302 | // touched = true; // main DL |
---|
12837 | 14303 | if (isRenderer) |
---|
12838 | 14304 | { |
---|
12839 | | - SetMouseMode(modifiers); |
---|
| 14305 | + SetMouseMode(modifiers, modifiersex); |
---|
12840 | 14306 | } |
---|
12841 | 14307 | |
---|
12842 | 14308 | selectX = anchorX = x; |
---|
.. | .. |
---|
12849 | 14315 | clicked = true; |
---|
12850 | 14316 | hold = false; |
---|
12851 | 14317 | |
---|
12852 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14318 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12853 | 14319 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12854 | 14320 | { |
---|
12855 | 14321 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12874 | 14340 | drag = false; |
---|
12875 | 14341 | //System.out.println("Mouse DOWN"); |
---|
12876 | 14342 | editObj = false; |
---|
12877 | | - ClickInfo info = new ClickInfo(); |
---|
12878 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12879 | | - info.pane = this; |
---|
12880 | | - info.camera = renderCamera; |
---|
12881 | | - info.x = x; |
---|
12882 | | - info.y = y; |
---|
12883 | | - info.modifiers = modifiers; |
---|
12884 | | - editObj = object.doEditClick(info, 0); |
---|
| 14343 | + //ClickInfo info = new ClickInfo(); |
---|
| 14344 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14345 | + object.clickInfo.pane = this; |
---|
| 14346 | + object.clickInfo.camera = renderCamera; |
---|
| 14347 | + object.clickInfo.x = x; |
---|
| 14348 | + object.clickInfo.y = y; |
---|
| 14349 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14350 | + editObj = object.doEditClick(//info, |
---|
| 14351 | + 0); |
---|
12885 | 14352 | if (!editObj) |
---|
12886 | 14353 | { |
---|
12887 | 14354 | hasMarquee = true; |
---|
.. | .. |
---|
12897 | 14364 | |
---|
12898 | 14365 | public void mouseDragged(MouseEvent e) |
---|
12899 | 14366 | { |
---|
| 14367 | + Globals.MOUSEDRAGGED = true; |
---|
| 14368 | + |
---|
| 14369 | + //System.out.println("mouseDragged: " + e); |
---|
12900 | 14370 | if (isRenderer) |
---|
12901 | 14371 | movingcamera = true; |
---|
| 14372 | + |
---|
12902 | 14373 | //if (drawing) |
---|
12903 | 14374 | //return; |
---|
12904 | | - //System.out.println("mouseDragged: " + e); |
---|
12905 | 14375 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12906 | 14376 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12907 | 14377 | { |
---|
.. | .. |
---|
12909 | 14379 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12910 | 14380 | } |
---|
12911 | 14381 | else |
---|
12912 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14382 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12913 | 14383 | |
---|
12914 | 14384 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12915 | 14385 | } |
---|
.. | .. |
---|
12921 | 14391 | cVector tmp = new cVector(); |
---|
12922 | 14392 | cVector tmp2 = new cVector(); |
---|
12923 | 14393 | boolean isMoving; |
---|
| 14394 | + |
---|
| 14395 | + public cVector TargetLookAt() |
---|
| 14396 | + { |
---|
| 14397 | + return targetLookAt; |
---|
| 14398 | + } |
---|
12924 | 14399 | |
---|
12925 | 14400 | class PingThread extends Thread |
---|
12926 | 14401 | { |
---|
.. | .. |
---|
13077 | 14552 | |
---|
13078 | 14553 | public void run() |
---|
13079 | 14554 | { |
---|
| 14555 | + new Exception().printStackTrace(); |
---|
13080 | 14556 | System.exit(0); |
---|
13081 | 14557 | for (;;) |
---|
13082 | 14558 | { |
---|
.. | .. |
---|
13140 | 14616 | { |
---|
13141 | 14617 | Globals.lighttouched = true; |
---|
13142 | 14618 | } |
---|
13143 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14619 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13144 | 14620 | } |
---|
13145 | 14621 | //else |
---|
13146 | 14622 | } |
---|
.. | .. |
---|
13154 | 14630 | void GoDown(int mod) |
---|
13155 | 14631 | { |
---|
13156 | 14632 | MODIFIERS |= COMMAND; |
---|
13157 | | - /* |
---|
| 14633 | + /**/ |
---|
13158 | 14634 | if((mod&SHIFT) == SHIFT) |
---|
13159 | 14635 | manipCamera.RotatePosition(0, -speed); |
---|
13160 | 14636 | else |
---|
13161 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13162 | | - */ |
---|
| 14637 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14638 | + /**/ |
---|
13163 | 14639 | if ((mod & SHIFT) == SHIFT) |
---|
13164 | 14640 | { |
---|
13165 | 14641 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13175 | 14651 | void GoUp(int mod) |
---|
13176 | 14652 | { |
---|
13177 | 14653 | MODIFIERS |= COMMAND; |
---|
13178 | | - /* |
---|
| 14654 | + /**/ |
---|
13179 | 14655 | if((mod&SHIFT) == SHIFT) |
---|
13180 | 14656 | manipCamera.RotatePosition(0, speed); |
---|
13181 | 14657 | else |
---|
13182 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13183 | | - */ |
---|
| 14658 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14659 | + /**/ |
---|
13184 | 14660 | if ((mod & SHIFT) == SHIFT) |
---|
13185 | 14661 | { |
---|
13186 | 14662 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13196 | 14672 | void GoLeft(int mod) |
---|
13197 | 14673 | { |
---|
13198 | 14674 | MODIFIERS |= COMMAND; |
---|
13199 | | - /* |
---|
| 14675 | + /**/ |
---|
13200 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
13201 | | - manipCamera.RotatePosition(speed, 0); |
---|
13202 | | - else |
---|
13203 | 14677 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13204 | | - */ |
---|
| 14678 | + else |
---|
| 14679 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14680 | + /**/ |
---|
13205 | 14681 | if ((mod & SHIFT) == SHIFT) |
---|
13206 | 14682 | { |
---|
13207 | 14683 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13217 | 14693 | void GoRight(int mod) |
---|
13218 | 14694 | { |
---|
13219 | 14695 | MODIFIERS |= COMMAND; |
---|
13220 | | - /* |
---|
| 14696 | + /**/ |
---|
13221 | 14697 | if((mod&SHIFT) == SHIFT) |
---|
13222 | | - manipCamera.RotatePosition(-speed, 0); |
---|
13223 | | - else |
---|
13224 | 14698 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13225 | | - */ |
---|
| 14699 | + else |
---|
| 14700 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14701 | + /**/ |
---|
13226 | 14702 | if ((mod & SHIFT) == SHIFT) |
---|
13227 | 14703 | { |
---|
13228 | 14704 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13240 | 14716 | int X, Y; |
---|
13241 | 14717 | boolean SX, SY; |
---|
13242 | 14718 | |
---|
13243 | | - void drag(int x, int y, int modifiers) |
---|
| 14719 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13244 | 14720 | { |
---|
13245 | 14721 | if (IsFrozen()) |
---|
13246 | 14722 | { |
---|
.. | .. |
---|
13249 | 14725 | |
---|
13250 | 14726 | drag = true; // NEW |
---|
13251 | 14727 | |
---|
13252 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14728 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13253 | 14729 | |
---|
13254 | 14730 | X = x; |
---|
13255 | 14731 | Y = y; |
---|
13256 | 14732 | // floating state for animation |
---|
13257 | | - MODIFIERS = modifiers; |
---|
13258 | | - modifiers &= ~1024; |
---|
| 14733 | + MODIFIERS = modifiersex; |
---|
| 14734 | + modifiersex &= ~1024; |
---|
13259 | 14735 | if (false) // modifiers != 0) |
---|
13260 | 14736 | { |
---|
13261 | 14737 | //new Exception().printStackTrace(); |
---|
13262 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14738 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13263 | 14739 | System.out.println("SHIFT = " + SHIFT); |
---|
13264 | 14740 | System.out.println("CONTROL = " + COMMAND); |
---|
13265 | 14741 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13272 | 14748 | if (editObj) |
---|
13273 | 14749 | { |
---|
13274 | 14750 | drag = true; |
---|
13275 | | - ClickInfo info = new ClickInfo(); |
---|
13276 | | - info.bounds.setBounds(0, 0, |
---|
| 14751 | + //ClickInfo info = new ClickInfo(); |
---|
| 14752 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
13277 | 14753 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13278 | | - info.pane = this; |
---|
13279 | | - info.camera = renderCamera; |
---|
13280 | | - info.x = x; |
---|
13281 | | - info.y = y; |
---|
13282 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14754 | + object.clickInfo.pane = this; |
---|
| 14755 | + object.clickInfo.camera = renderCamera; |
---|
| 14756 | + object.clickInfo.x = x; |
---|
| 14757 | + object.clickInfo.y = y; |
---|
| 14758 | + object //.GetWindow().copy |
---|
| 14759 | + .doEditDrag(//info, |
---|
| 14760 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13283 | 14761 | } else |
---|
13284 | 14762 | { |
---|
13285 | 14763 | if (x < startX) |
---|
.. | .. |
---|
13428 | 14906 | } |
---|
13429 | 14907 | } |
---|
13430 | 14908 | |
---|
| 14909 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14910 | + |
---|
13431 | 14911 | public void mouseMoved(MouseEvent e) |
---|
13432 | 14912 | { |
---|
13433 | 14913 | //System.out.println("mouseMoved: " + e); |
---|
13434 | | - |
---|
13435 | 14914 | if (isRenderer) |
---|
13436 | 14915 | return; |
---|
13437 | 14916 | |
---|
13438 | | - ClickInfo ci = new ClickInfo(); |
---|
13439 | | - ci.x = e.getX(); |
---|
13440 | | - ci.y = e.getY(); |
---|
13441 | | - ci.modifiers = e.getModifiersEx(); |
---|
13442 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13443 | | - ci.pane = this; |
---|
13444 | | - ci.camera = renderCamera; |
---|
| 14917 | + // Mouse cursor feedback |
---|
| 14918 | + object.clickInfo.x = e.getX(); |
---|
| 14919 | + object.clickInfo.y = e.getY(); |
---|
| 14920 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14921 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14922 | + object.clickInfo.pane = this; |
---|
| 14923 | + object.clickInfo.camera = renderCamera; |
---|
13445 | 14924 | if (!isRenderer) |
---|
13446 | 14925 | { |
---|
13447 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14926 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14927 | + //Object3D copy = editWindow.copy; |
---|
| 14928 | + if (object.doEditClick(//clickInfo, |
---|
| 14929 | + 0)) |
---|
13448 | 14930 | { |
---|
13449 | 14931 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13450 | 14932 | } else |
---|
.. | .. |
---|
13456 | 14938 | |
---|
13457 | 14939 | public void mouseReleased(MouseEvent e) |
---|
13458 | 14940 | { |
---|
| 14941 | + Globals.MOUSEDRAGGED = false; |
---|
| 14942 | + |
---|
13459 | 14943 | movingcamera = false; |
---|
| 14944 | + X = 0; // getBounds().width/2; |
---|
| 14945 | + Y = 0; // getBounds().height/2; |
---|
13460 | 14946 | //System.out.println("mouseReleased: " + e); |
---|
13461 | 14947 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13462 | 14948 | } |
---|
.. | .. |
---|
13479 | 14965 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13480 | 14966 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13481 | 14967 | |
---|
13482 | | - if (control || command || IsFrozen()) |
---|
| 14968 | +// No delay if (control || command || IsFrozen()) |
---|
13483 | 14969 | timeout = true; |
---|
13484 | | - else |
---|
| 14970 | +// ?? May 2019 else |
---|
13485 | 14971 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13486 | 14972 | mouseDown = false; |
---|
13487 | 14973 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13591 | 15077 | System.out.println("keyReleased: " + e); |
---|
13592 | 15078 | } |
---|
13593 | 15079 | |
---|
13594 | | - void SetMouseMode(int modifiers) |
---|
| 15080 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13595 | 15081 | { |
---|
13596 | 15082 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13597 | 15083 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13603 | 15089 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13604 | 15090 | // return; |
---|
13605 | 15091 | //System.out.println("SetMode = " + modifiers); |
---|
13606 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15092 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13607 | 15093 | { |
---|
13608 | 15094 | mouseMode |= ZOOM; |
---|
13609 | 15095 | } |
---|
13610 | 15096 | |
---|
13611 | 15097 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13612 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15098 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13613 | 15099 | { |
---|
13614 | 15100 | mouseMode |= VR; // BACKFORTH; |
---|
13615 | 15101 | } |
---|
13616 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15102 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13617 | 15103 | { |
---|
13618 | 15104 | mouseMode |= SELECT; |
---|
13619 | 15105 | } |
---|
13620 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15106 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13621 | 15107 | { |
---|
13622 | 15108 | mouseMode |= SELECT; |
---|
13623 | 15109 | } |
---|
13624 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15110 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13625 | 15111 | { |
---|
13626 | 15112 | mouseMode &= ~VR; |
---|
13627 | 15113 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13650 | 15136 | |
---|
13651 | 15137 | if (isRenderer) // |
---|
13652 | 15138 | { |
---|
13653 | | - SetMouseMode(modifiers); |
---|
| 15139 | + SetMouseMode(0, modifiers); |
---|
13654 | 15140 | } |
---|
13655 | 15141 | |
---|
13656 | | - theRenderer.keyPressed(key); |
---|
| 15142 | + Globals.theRenderer.keyPressed(key); |
---|
13657 | 15143 | } |
---|
13658 | 15144 | |
---|
13659 | 15145 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13665 | 15151 | float SATPOW = 1; // 2; // 0.5f; |
---|
13666 | 15152 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13667 | 15153 | |
---|
13668 | | - void keyPressed(int key) |
---|
| 15154 | + public void keyPressed(int key) |
---|
13669 | 15155 | { |
---|
13670 | 15156 | if (key >= '0' && key <= '5') |
---|
13671 | 15157 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13712 | 15198 | // break; |
---|
13713 | 15199 | case 'T': |
---|
13714 | 15200 | CACHETEXTURE ^= true; |
---|
13715 | | - textures.clear(); |
---|
| 15201 | + texturepigment.clear(); |
---|
| 15202 | + texturebump.clear(); |
---|
13716 | 15203 | // repaint(); |
---|
13717 | 15204 | break; |
---|
13718 | 15205 | case 'Y': |
---|
.. | .. |
---|
13797 | 15284 | case 'E' : COMPACT ^= true; |
---|
13798 | 15285 | repaint(); |
---|
13799 | 15286 | break; |
---|
13800 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15287 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15288 | + //DEBUGHSB ^= true; |
---|
| 15289 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13801 | 15290 | repaint(); |
---|
13802 | 15291 | break; |
---|
13803 | 15292 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13822 | 15311 | RevertCamera(); |
---|
13823 | 15312 | repaint(); |
---|
13824 | 15313 | break; |
---|
13825 | | - case 'L': |
---|
13826 | 15314 | case 'l': |
---|
| 15315 | + //case 'L': |
---|
13827 | 15316 | if (lightMode) |
---|
13828 | 15317 | { |
---|
13829 | 15318 | lightMode = false; |
---|
.. | .. |
---|
13887 | 15376 | OCCLUSION_CULLING ^= true; |
---|
13888 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
13889 | 15378 | break; |
---|
13890 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
13891 | 15380 | case '1': |
---|
13892 | 15381 | case '2': |
---|
13893 | 15382 | case '3': |
---|
13894 | 15383 | case '4': |
---|
13895 | 15384 | case '5': |
---|
13896 | | - newenvy = Character.getNumericValue(key); |
---|
13897 | | - repaint(); |
---|
13898 | | - break; |
---|
13899 | 15385 | case '6': |
---|
13900 | 15386 | case '7': |
---|
13901 | 15387 | case '8': |
---|
13902 | 15388 | case '9': |
---|
13903 | | - BGcolor = (key - '6')/3.f; |
---|
| 15389 | + if (true) // envyoff) |
---|
| 15390 | + { |
---|
| 15391 | + BGcolor = (key - '1')/8.f; |
---|
| 15392 | + } |
---|
| 15393 | + else |
---|
| 15394 | + { |
---|
| 15395 | + //newenvy = Character.getNumericValue(key); |
---|
| 15396 | + } |
---|
13904 | 15397 | repaint(); |
---|
13905 | 15398 | break; |
---|
13906 | 15399 | case '!': |
---|
.. | .. |
---|
13966 | 15459 | case '_': |
---|
13967 | 15460 | kompactbit = 5; |
---|
13968 | 15461 | break; |
---|
13969 | | - case '+': |
---|
13970 | | - kompactbit = 6; |
---|
13971 | | - break; |
---|
| 15462 | +// case '+': |
---|
| 15463 | +// kompactbit = 6; |
---|
| 15464 | +// break; |
---|
13972 | 15465 | case ' ': |
---|
13973 | 15466 | lightMode ^= true; |
---|
13974 | 15467 | Globals.lighttouched = true; |
---|
.. | .. |
---|
13980 | 15473 | case ESC: |
---|
13981 | 15474 | RENDERPROGRAM += 1; |
---|
13982 | 15475 | RENDERPROGRAM %= 3; |
---|
| 15476 | + |
---|
13983 | 15477 | repaint(); |
---|
13984 | 15478 | break; |
---|
13985 | 15479 | case 'Z': |
---|
13986 | 15480 | //RESIZETEXTURE ^= true; |
---|
13987 | 15481 | //break; |
---|
13988 | 15482 | case 'z': |
---|
13989 | | - RENDERSHADOW ^= true; |
---|
| 15483 | + Globals.RENDERSHADOW ^= true; |
---|
13990 | 15484 | Globals.lighttouched = true; |
---|
13991 | 15485 | repaint(); |
---|
13992 | 15486 | break; |
---|
.. | .. |
---|
14019 | 15513 | case DELETE: |
---|
14020 | 15514 | ClearSelection(); |
---|
14021 | 15515 | break; |
---|
14022 | | - /* |
---|
14023 | 15516 | case '+': |
---|
| 15517 | + |
---|
| 15518 | + /* |
---|
14024 | 15519 | //fontsize += 1; |
---|
14025 | 15520 | bbzoom *= 2; |
---|
14026 | 15521 | repaint(); |
---|
.. | .. |
---|
14037 | 15532 | case '=': |
---|
14038 | 15533 | IncDepth(); |
---|
14039 | 15534 | //fontsize += 1; |
---|
14040 | | - object.editWindow.refreshContents(true); |
---|
| 15535 | + object.GetWindow().refreshContents(true); |
---|
14041 | 15536 | maskbit = 6; |
---|
14042 | 15537 | break; |
---|
14043 | 15538 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14044 | 15539 | DecDepth(); |
---|
14045 | 15540 | maskbit = 5; |
---|
14046 | 15541 | //if(fontsize > 1) fontsize -= 1; |
---|
14047 | | - if (object.editWindow == null) |
---|
14048 | | - new Exception().printStackTrace(); |
---|
14049 | | - else |
---|
14050 | | - object.editWindow.refreshContents(true); |
---|
| 15542 | +// if (object.editWindow == null) |
---|
| 15543 | +// new Exception().printStackTrace(); |
---|
| 15544 | +// else |
---|
| 15545 | + object.GetWindow().refreshContents(true); |
---|
14051 | 15546 | break; |
---|
14052 | 15547 | case '{': |
---|
14053 | 15548 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14102 | 15597 | } |
---|
14103 | 15598 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14104 | 15599 | } |
---|
| 15600 | + |
---|
14105 | 15601 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14106 | 15602 | |
---|
14107 | 15603 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14109 | 15605 | //mode = ROTATE; |
---|
14110 | 15606 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14111 | 15607 | { |
---|
14112 | | - SetMouseMode(modifiers); |
---|
| 15608 | + SetMouseMode(0, modifiers); |
---|
14113 | 15609 | } |
---|
14114 | 15610 | } |
---|
14115 | 15611 | |
---|
14116 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15612 | + public void processKeyEvent(KeyEvent e) |
---|
14117 | 15613 | { |
---|
14118 | 15614 | switch (e.getID()) |
---|
14119 | 15615 | { |
---|
.. | .. |
---|
14243 | 15739 | |
---|
14244 | 15740 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14245 | 15741 | { |
---|
14246 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14247 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15742 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15743 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15744 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14248 | 15745 | { |
---|
14249 | 15746 | mouseMoved(e); |
---|
14250 | 15747 | } else |
---|
.. | .. |
---|
14269 | 15766 | } |
---|
14270 | 15767 | */ |
---|
14271 | 15768 | |
---|
14272 | | - object.editWindow.EditSelection(); |
---|
| 15769 | + object.GetWindow().EditSelection(false); |
---|
14273 | 15770 | } |
---|
14274 | 15771 | |
---|
14275 | 15772 | void SelectParent() |
---|
14276 | 15773 | { |
---|
| 15774 | + new Exception().printStackTrace(); |
---|
14277 | 15775 | System.exit(0); |
---|
14278 | 15776 | Composite group = (Composite) object; |
---|
14279 | 15777 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14285 | 15783 | { |
---|
14286 | 15784 | //selectees.remove(i); |
---|
14287 | 15785 | System.out.println("select parent of " + elem); |
---|
14288 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15786 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14289 | 15787 | } else |
---|
14290 | 15788 | { |
---|
14291 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15789 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14292 | 15790 | } |
---|
14293 | 15791 | |
---|
14294 | 15792 | first = false; |
---|
.. | .. |
---|
14297 | 15795 | |
---|
14298 | 15796 | void SelectChildren() |
---|
14299 | 15797 | { |
---|
| 15798 | + new Exception().printStackTrace(); |
---|
14300 | 15799 | System.exit(0); |
---|
14301 | 15800 | /* |
---|
14302 | 15801 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14329 | 15828 | for (int j = 0; j < group.children.size(); j++) |
---|
14330 | 15829 | { |
---|
14331 | 15830 | elem = (Object3D) group.children.elementAt(j); |
---|
14332 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15831 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14333 | 15832 | first = false; |
---|
14334 | 15833 | } |
---|
14335 | 15834 | } else |
---|
14336 | 15835 | { |
---|
14337 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15836 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14338 | 15837 | } |
---|
14339 | 15838 | |
---|
14340 | 15839 | first = false; |
---|
.. | .. |
---|
14345 | 15844 | { |
---|
14346 | 15845 | //Composite group = (Composite) object; |
---|
14347 | 15846 | Object3D group = object; |
---|
14348 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15847 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14349 | 15848 | } |
---|
14350 | 15849 | |
---|
14351 | 15850 | void ResetTransform(int mask) |
---|
14352 | 15851 | { |
---|
14353 | 15852 | //Composite group = (Composite) object; |
---|
14354 | 15853 | Object3D group = object; |
---|
14355 | | - group.editWindow.ResetTransform(mask); |
---|
| 15854 | + group.GetWindow().ResetTransform(mask); |
---|
14356 | 15855 | } |
---|
14357 | 15856 | |
---|
14358 | 15857 | void FlipTransform() |
---|
14359 | 15858 | { |
---|
14360 | 15859 | //Composite group = (Composite) object; |
---|
14361 | 15860 | Object3D group = object; |
---|
14362 | | - group.editWindow.FlipTransform(); |
---|
| 15861 | + group.GetWindow().FlipTransform(); |
---|
14363 | 15862 | // group.editWindow.ReduceMesh(true); |
---|
14364 | 15863 | } |
---|
14365 | 15864 | |
---|
.. | .. |
---|
14367 | 15866 | { |
---|
14368 | 15867 | //Composite group = (Composite) object; |
---|
14369 | 15868 | Object3D group = object; |
---|
14370 | | - group.editWindow.PrintMemory(); |
---|
| 15869 | + group.GetWindow().PrintMemory(); |
---|
14371 | 15870 | // group.editWindow.ReduceMesh(true); |
---|
14372 | 15871 | } |
---|
14373 | 15872 | |
---|
.. | .. |
---|
14375 | 15874 | { |
---|
14376 | 15875 | //Composite group = (Composite) object; |
---|
14377 | 15876 | Object3D group = object; |
---|
14378 | | - group.editWindow.ResetCentroid(); |
---|
| 15877 | + group.GetWindow().ResetCentroid(); |
---|
14379 | 15878 | } |
---|
14380 | 15879 | |
---|
14381 | 15880 | void IncDepth() |
---|
.. | .. |
---|
14457 | 15956 | |
---|
14458 | 15957 | int width = getBounds().width; |
---|
14459 | 15958 | int height = getBounds().height; |
---|
14460 | | - ClickInfo info = new ClickInfo(); |
---|
14461 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14462 | 15959 | //Image img = CreateImage(width, height); |
---|
14463 | 15960 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15961 | + |
---|
14464 | 15962 | Graphics gr = g; // img.getGraphics(); |
---|
| 15963 | + |
---|
14465 | 15964 | if (!hasMarquee) |
---|
14466 | 15965 | { |
---|
14467 | 15966 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14533 | 16032 | } |
---|
14534 | 16033 | if (object != null && !hasMarquee) |
---|
14535 | 16034 | { |
---|
| 16035 | + if (object.clickInfo == null) |
---|
| 16036 | + object.clickInfo = new ClickInfo(); |
---|
| 16037 | + ClickInfo info = object.clickInfo; |
---|
| 16038 | + //ClickInfo info = new ClickInfo(); |
---|
| 16039 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16040 | + |
---|
14536 | 16041 | if (isRenderer) |
---|
14537 | 16042 | { |
---|
14538 | | - info.flags++; |
---|
| 16043 | + object.clickInfo.flags++; |
---|
14539 | 16044 | double frameAspect = (double) width / (double) height; |
---|
14540 | 16045 | if (frameAspect > renderCamera.aspect) |
---|
14541 | 16046 | { |
---|
14542 | 16047 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
14543 | | - info.bounds.width -= width - desired; |
---|
14544 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16048 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16049 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
14545 | 16050 | } else |
---|
14546 | 16051 | { |
---|
14547 | 16052 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
14548 | | - info.bounds.height -= height - desired; |
---|
14549 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16053 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16054 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
14550 | 16055 | } |
---|
14551 | 16056 | } |
---|
14552 | | - info.g = gr; |
---|
14553 | | - info.camera = renderCamera; |
---|
| 16057 | + |
---|
| 16058 | + object.clickInfo.g = gr; |
---|
| 16059 | + object.clickInfo.camera = renderCamera; |
---|
14554 | 16060 | /* |
---|
14555 | 16061 | // Memory intensive (brep.verticescopy) |
---|
14556 | 16062 | if (!(object instanceof Composite)) |
---|
14557 | 16063 | object.draw(info, 0, false); // SLOW : |
---|
14558 | 16064 | */ |
---|
14559 | | - if (!isRenderer) |
---|
| 16065 | + if (!isRenderer) // && drag) |
---|
14560 | 16066 | { |
---|
14561 | | - object.drawEditHandles(info, 0); |
---|
| 16067 | + Grafreed.Assert(object != null); |
---|
| 16068 | + Grafreed.Assert(object.selection != null); |
---|
| 16069 | + if (object.selection.Size() > 0) |
---|
| 16070 | + { |
---|
| 16071 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16072 | + |
---|
| 16073 | + object.clickInfo.DX = 0; |
---|
| 16074 | + object.clickInfo.DY = 0; |
---|
| 16075 | + object.clickInfo.W = 1; |
---|
| 16076 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16077 | + { |
---|
| 16078 | + info.DX = X; |
---|
| 16079 | + if (X != 0) |
---|
| 16080 | + info.DX -= info.bounds.width/2; |
---|
| 16081 | + |
---|
| 16082 | + info.DY = Y; |
---|
| 16083 | + if (Y != 0) |
---|
| 16084 | + info.DY -= info.bounds.height/2; |
---|
| 16085 | + } |
---|
| 16086 | + |
---|
| 16087 | + object.drawEditHandles(//info, |
---|
| 16088 | + 0); |
---|
| 16089 | + |
---|
| 16090 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16091 | + { |
---|
| 16092 | + switch (hitSomething) |
---|
| 16093 | + { |
---|
| 16094 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16095 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16096 | + break; |
---|
| 16097 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16098 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16099 | + break; |
---|
| 16100 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16101 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16102 | + break; |
---|
| 16103 | + } |
---|
| 16104 | + |
---|
| 16105 | + } |
---|
| 16106 | + } |
---|
14562 | 16107 | } |
---|
14563 | 16108 | } |
---|
| 16109 | + |
---|
14564 | 16110 | if (isRenderer) |
---|
14565 | 16111 | { |
---|
14566 | 16112 | //gr.setColor(Color.black); |
---|
14567 | 16113 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14568 | 16114 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14569 | 16115 | } |
---|
| 16116 | + |
---|
14570 | 16117 | if (hasMarquee) |
---|
14571 | 16118 | { |
---|
14572 | 16119 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
14679 | 16226 | public boolean mouseDown(Event evt, int x, int y) |
---|
14680 | 16227 | { |
---|
14681 | 16228 | System.out.println("mouseDown: " + evt); |
---|
| 16229 | + System.exit(0); |
---|
14682 | 16230 | /* |
---|
14683 | 16231 | locked = true; |
---|
14684 | 16232 | drag = false; |
---|
.. | .. |
---|
14722 | 16270 | { |
---|
14723 | 16271 | keyPressed(0, modifiers); |
---|
14724 | 16272 | } |
---|
14725 | | - clickStart(x, y, modifiers); |
---|
| 16273 | + // clickStart(x, y, modifiers); |
---|
14726 | 16274 | return true; |
---|
14727 | 16275 | } |
---|
14728 | 16276 | |
---|
.. | .. |
---|
14840 | 16388 | { |
---|
14841 | 16389 | keyReleased(0, 0); |
---|
14842 | 16390 | } |
---|
14843 | | - drag(x, y, modifiers); |
---|
| 16391 | + drag(x, y, 0, modifiers); |
---|
14844 | 16392 | return true; |
---|
14845 | 16393 | } |
---|
14846 | 16394 | |
---|
.. | .. |
---|
14972 | 16520 | Object3D object; |
---|
14973 | 16521 | static Object3D trackedobject; |
---|
14974 | 16522 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14975 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16523 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14976 | 16524 | /*static*/ Camera eyeCamera; |
---|
14977 | 16525 | /*static*/ Camera lightCamera; |
---|
14978 | 16526 | int cameracount; |
---|
.. | .. |
---|
15036 | 16584 | private /*static*/ boolean firstime; |
---|
15037 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
15038 | 16586 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16587 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16588 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15039 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15040 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15041 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15048 | 16598 | { |
---|
15049 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15050 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
15051 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
15052 | 16604 | { |
---|
15053 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15054 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15055 | | - mipmapped, |
---|
15056 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15057 | | - if (data == null) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
15058 | 16610 | { |
---|
15059 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
15060 | 16615 | } |
---|
| 16616 | + |
---|
| 16617 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16618 | + TextureData data; |
---|
| 16619 | + |
---|
| 16620 | + try |
---|
| 16621 | + { |
---|
| 16622 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16623 | + mipmapped, |
---|
| 16624 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16625 | + } |
---|
| 16626 | + catch (Exception e) |
---|
| 16627 | + { |
---|
| 16628 | + try |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + catch (Exception e2) |
---|
| 16636 | + { |
---|
| 16637 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16638 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16639 | + mipmapped, |
---|
| 16640 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16641 | + } |
---|
| 16642 | + } |
---|
| 16643 | + |
---|
15061 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
15062 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
15063 | 16646 | } |
---|
15064 | 16647 | |
---|
15065 | 16648 | return cubemap; |
---|
15066 | 16649 | } |
---|
| 16650 | + |
---|
15067 | 16651 | int bigsphere = -1; |
---|
15068 | 16652 | |
---|
15069 | 16653 | float BGcolor = 0.5f; |
---|
15070 | 16654 | |
---|
15071 | | - private void DrawSkyBox(GL gl) |
---|
| 16655 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16656 | + |
---|
| 16657 | + private void DrawSkyBox(GL gl, float ratio) |
---|
15072 | 16658 | { |
---|
15073 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
15074 | 16661 | { |
---|
15075 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
15076 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
15085 | 16672 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
15086 | 16673 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
15087 | 16674 | gl.glLoadIdentity(); |
---|
| 16675 | + gl.glScalef(1,ratio,1); |
---|
15088 | 16676 | |
---|
| 16677 | +// colorV[0] = 2; |
---|
| 16678 | +// colorV[1] = 2; |
---|
| 16679 | +// colorV[2] = 2; |
---|
| 16680 | +// colorV[3] = 1; |
---|
| 16681 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16682 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16683 | +// |
---|
| 16684 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16685 | + |
---|
15089 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
15090 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
15091 | 16688 | |
---|
.. | .. |
---|
15117 | 16714 | { |
---|
15118 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
15119 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
15120 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
15121 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
15122 | 16720 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
15257 | 16855 | cStatic.objectstack[materialdepth++] = checker; |
---|
15258 | 16856 | //System.out.println("material " + material); |
---|
15259 | 16857 | //Applet3D.tracein(this, selected); |
---|
15260 | | - vector2buffer = checker.projectedVertices; |
---|
| 16858 | + //vector2buffer = checker.projectedVertices; |
---|
15261 | 16859 | |
---|
15262 | 16860 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15263 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16861 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15264 | 16862 | |
---|
15265 | 16863 | materialdepth -= 1; |
---|
15266 | 16864 | if (materialdepth > 0) |
---|
15267 | 16865 | { |
---|
15268 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15269 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16866 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16867 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15270 | 16868 | } |
---|
15271 | 16869 | //checker.GetMaterial().opacity = 1f; |
---|
15272 | 16870 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15352 | 16950 | } |
---|
15353 | 16951 | } |
---|
15354 | 16952 | |
---|
| 16953 | + private Object3D GetFolder() |
---|
| 16954 | + { |
---|
| 16955 | + Object3D folder = object.GetWindow().copy; |
---|
| 16956 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16957 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16958 | + return folder; |
---|
| 16959 | + } |
---|
| 16960 | + |
---|
15355 | 16961 | class SelectBuffer implements GLEventListener |
---|
15356 | 16962 | { |
---|
15357 | 16963 | |
---|
.. | .. |
---|
15367 | 16973 | //new Exception().printStackTrace(); |
---|
15368 | 16974 | System.out.println("select buffer init"); |
---|
15369 | 16975 | // Use debug pipeline |
---|
15370 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16976 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
15371 | 16977 | |
---|
15372 | 16978 | GL gl = drawable.getGL(); |
---|
15373 | 16979 | |
---|
.. | .. |
---|
15410 | 17016 | { |
---|
15411 | 17017 | if (!selection) |
---|
15412 | 17018 | { |
---|
| 17019 | + new Exception().printStackTrace(); |
---|
15413 | 17020 | System.exit(0); |
---|
15414 | 17021 | return; |
---|
15415 | 17022 | } |
---|
.. | .. |
---|
15430 | 17037 | |
---|
15431 | 17038 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15432 | 17039 | |
---|
| 17040 | + if (PAINTMODE) |
---|
| 17041 | + { |
---|
| 17042 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17043 | + { |
---|
| 17044 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17045 | + |
---|
| 17046 | + // Make what you paint not selectable. |
---|
| 17047 | + paintobj.ResetSelectable(); |
---|
| 17048 | + } |
---|
| 17049 | + } |
---|
| 17050 | + |
---|
15433 | 17051 | //int tmp = selection_view; |
---|
15434 | 17052 | //selection_view = -1; |
---|
15435 | 17053 | int temp = DrawMode(); |
---|
.. | .. |
---|
15441 | 17059 | // temp = DEFAULT; // patch for selection debug |
---|
15442 | 17060 | Globals.drawMode = temp; // WARNING |
---|
15443 | 17061 | |
---|
| 17062 | + if (PAINTMODE) |
---|
| 17063 | + { |
---|
| 17064 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17065 | + { |
---|
| 17066 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17067 | + |
---|
| 17068 | + // Revert. |
---|
| 17069 | + paintobj.RestoreSelectable(); |
---|
| 17070 | + } |
---|
| 17071 | + } |
---|
| 17072 | + |
---|
15444 | 17073 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15445 | 17074 | |
---|
15446 | 17075 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15488 | 17117 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15489 | 17118 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15490 | 17119 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17120 | + |
---|
| 17121 | + CreateSelectedPoint(); |
---|
15491 | 17122 | |
---|
15492 | 17123 | // Will fit the mesh !!! |
---|
15493 | 17124 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15537 | 17168 | 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 | 17169 | } |
---|
15539 | 17170 | |
---|
15540 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17171 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15541 | 17172 | } |
---|
15542 | 17173 | } |
---|
15543 | 17174 | |
---|
15544 | 17175 | if (!movingcamera && !PAINTMODE) |
---|
15545 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17176 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15546 | 17177 | |
---|
15547 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17178 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15548 | 17179 | { |
---|
15549 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17180 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15550 | 17181 | |
---|
15551 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17182 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17183 | + { |
---|
| 17184 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15552 | 17185 | |
---|
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(); |
---|
| 17186 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17187 | + |
---|
| 17188 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17189 | + |
---|
| 17190 | + inst.add(paintobj); // link |
---|
| 17191 | + |
---|
| 17192 | + object.GetWindow().SnapObject(inst); |
---|
| 17193 | + |
---|
| 17194 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17195 | + |
---|
| 17196 | + folder.add(inst); |
---|
| 17197 | + |
---|
| 17198 | + object.GetWindow().ResetModel(); |
---|
| 17199 | + object.GetWindow().refreshContents(); |
---|
| 17200 | + } |
---|
15568 | 17201 | } |
---|
15569 | 17202 | else |
---|
15570 | 17203 | paintcount = 0; |
---|
.. | .. |
---|
15603 | 17236 | //System.out.println("objects[color] = " + objects[color]); |
---|
15604 | 17237 | //objects[color].Select(); |
---|
15605 | 17238 | indexcount = 0; |
---|
| 17239 | + ObjEditor window = object.GetWindow(); |
---|
| 17240 | + if (window != null && deselect) |
---|
| 17241 | + { |
---|
| 17242 | + window.Select(null, deselect, true); |
---|
| 17243 | + } |
---|
15606 | 17244 | object.Select(color, deselect); |
---|
15607 | 17245 | } |
---|
15608 | 17246 | |
---|
.. | .. |
---|
15702 | 17340 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15703 | 17341 | } |
---|
15704 | 17342 | |
---|
15705 | | - if (!RENDERSHADOW) |
---|
| 17343 | + if (!Globals.RENDERSHADOW) |
---|
15706 | 17344 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15707 | 17345 | |
---|
15708 | 17346 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15712 | 17350 | //gl.glColorMask(false, false, false, false); |
---|
15713 | 17351 | |
---|
15714 | 17352 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15715 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17353 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15716 | 17354 | { |
---|
15717 | 17355 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15718 | 17356 | |
---|
.. | .. |
---|
15772 | 17410 | |
---|
15773 | 17411 | class AntialiasBuffer implements GLEventListener |
---|
15774 | 17412 | { |
---|
15775 | | - |
---|
15776 | 17413 | CameraPane parent = null; |
---|
15777 | 17414 | |
---|
15778 | 17415 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16129 | 17766 | int AAbuffersize = 0; |
---|
16130 | 17767 | |
---|
16131 | 17768 | //double[] selectedpoint = new double[3]; |
---|
16132 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17769 | + static Superellipsoid selectedpoint; |
---|
16133 | 17770 | 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(); |
---|
| 17771 | + static Sphere debugpointG; |
---|
| 17772 | + static Sphere debugpointP; |
---|
| 17773 | + static Sphere debugpointC; |
---|
| 17774 | + static Sphere debugpointR; |
---|
16138 | 17775 | |
---|
16139 | 17776 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16140 | 17777 | |
---|
16141 | | - static |
---|
16142 | | - { |
---|
16143 | | - for (int i=0; i<8; i++) |
---|
16144 | | - { |
---|
16145 | | - debugpoints[i] = new Sphere(); |
---|
16146 | | - } |
---|
16147 | | - } |
---|
16148 | | - |
---|
16149 | 17778 | static void InitPoints(float radius) |
---|
16150 | 17779 | { |
---|
16151 | 17780 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16165 | 17794 | } |
---|
16166 | 17795 | } |
---|
16167 | 17796 | |
---|
16168 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17797 | + static void DrawPoints(iCameraPane cpane) |
---|
16169 | 17798 | { |
---|
16170 | 17799 | for (int i=0; i<8; i++) // first and last are red |
---|
16171 | 17800 | { |
---|
.. | .. |
---|
16197 | 17826 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16198 | 17827 | // Depth buffer format |
---|
16199 | 17828 | //private int depth_format; |
---|
16200 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17829 | + |
---|
| 17830 | + public void NextIndex() |
---|
16201 | 17831 | { |
---|
16202 | 17832 | indexcount+=16; |
---|
16203 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17833 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16204 | 17834 | //objects[indexcount] = o; |
---|
16205 | 17835 | //System.out.println("indexcount = " + indexcount); |
---|
16206 | 17836 | } |
---|