.. | .. |
---|
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; |
---|
.. | .. |
---|
76 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
77 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
78 | 112 | static GLContext glcontext = null; |
---|
79 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 113 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
80 | 118 | boolean reverseUP = false; |
---|
81 | 119 | static boolean frozen = false; |
---|
82 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
92 | 130 | |
---|
93 | 131 | static int tickcount = 0; // slow pose issue |
---|
94 | 132 | |
---|
| 133 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 134 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 135 | static boolean BOXMODE = false; |
---|
96 | 136 | static boolean IMAGEFLIP = false; |
---|
97 | 137 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 146 | static boolean OEIL = true; |
---|
107 | 147 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 148 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 149 | +static boolean SWITCH = true; // false; |
---|
110 | 150 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 151 | static boolean PAINTMODE = false; |
---|
112 | 152 | |
---|
.. | .. |
---|
137 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
138 | 178 | boolean anisotropy = true; |
---|
139 | 179 | boolean softshadow = true; // slower but better false; |
---|
140 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
141 | 181 | |
---|
142 | 182 | boolean macromode = false; |
---|
143 | 183 | |
---|
.. | .. |
---|
149 | 189 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 190 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 191 | } |
---|
152 | | - static CameraPane theRenderer; |
---|
| 192 | + |
---|
| 193 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
153 | 194 | |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 196 | + { |
---|
| 197 | + try |
---|
| 198 | + { |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 200 | + } catch (IOException e) |
---|
| 201 | + { |
---|
| 202 | + System.out.println("NAME = " + name); |
---|
| 203 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
| 205 | + } |
---|
| 206 | + } |
---|
| 207 | + |
---|
154 | 208 | void SetAsGLRenderer(boolean b) |
---|
155 | 209 | { |
---|
156 | 210 | isRenderer = b; |
---|
157 | | - theRenderer = this; |
---|
| 211 | + Globals.theRenderer = this; |
---|
158 | 212 | } |
---|
159 | 213 | |
---|
160 | 214 | CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
.. | .. |
---|
169 | 223 | |
---|
170 | 224 | SetCamera(cam); |
---|
171 | 225 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 228 | |
---|
174 | 229 | object = o; |
---|
175 | 230 | |
---|
.. | .. |
---|
192 | 247 | |
---|
193 | 248 | /// INTERFACE |
---|
194 | 249 | |
---|
| 250 | + public javax.media.opengl.GL GetGL0() |
---|
| 251 | + { |
---|
| 252 | + return null; |
---|
| 253 | + } |
---|
| 254 | + |
---|
| 255 | + public int GenList() |
---|
| 256 | + { |
---|
| 257 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 258 | + return gl.glGenLists(1); |
---|
| 259 | + } |
---|
| 260 | + |
---|
| 261 | + public void NewList(int id) |
---|
| 262 | + { |
---|
| 263 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 264 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 265 | + } |
---|
| 266 | + |
---|
| 267 | + public void CallList(int id) |
---|
| 268 | + { |
---|
| 269 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 270 | + gl.glCallList(id); |
---|
| 271 | + } |
---|
| 272 | + |
---|
| 273 | + public void EndList() |
---|
| 274 | + { |
---|
| 275 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 276 | + gl.glEndList(); |
---|
| 277 | + } |
---|
| 278 | + |
---|
195 | 279 | public boolean IsBoxMode() |
---|
196 | 280 | { |
---|
197 | 281 | return BOXMODE; |
---|
| 282 | + } |
---|
| 283 | + |
---|
| 284 | + public boolean IsZoomBoxMode() |
---|
| 285 | + { |
---|
| 286 | + return ZOOMBOXMODE; |
---|
198 | 287 | } |
---|
199 | 288 | |
---|
200 | 289 | public void ClearDepth() |
---|
.. | .. |
---|
236 | 325 | return this.ambientOcclusion; |
---|
237 | 326 | } |
---|
238 | 327 | |
---|
| 328 | + public boolean IsDebugSelection() |
---|
| 329 | + { |
---|
| 330 | + return DEBUG_SELECTION; |
---|
| 331 | + } |
---|
| 332 | + |
---|
239 | 333 | public boolean IsFrozen() |
---|
240 | 334 | { |
---|
241 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 335 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
242 | 336 | |
---|
243 | 337 | return !selectmode && cameracount == 0; // != 0; |
---|
244 | 338 | } |
---|
.. | .. |
---|
259 | 353 | return lightCamera; |
---|
260 | 354 | } |
---|
261 | 355 | |
---|
| 356 | + public Camera ManipCamera() |
---|
| 357 | + { |
---|
| 358 | + return manipCamera; |
---|
| 359 | + } |
---|
| 360 | + |
---|
262 | 361 | public Camera RenderCamera() |
---|
263 | 362 | { |
---|
264 | 363 | return renderCamera; |
---|
| 364 | + } |
---|
| 365 | + |
---|
| 366 | + public Camera[] Cameras() |
---|
| 367 | + { |
---|
| 368 | + return cameras; |
---|
265 | 369 | } |
---|
266 | 370 | |
---|
267 | 371 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
277 | 381 | cStatic.objectstack[materialdepth++] = obj; |
---|
278 | 382 | //System.out.println("material " + material); |
---|
279 | 383 | //Applet3D.tracein(this, selected); |
---|
280 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 384 | + //display.vector2buffer = obj.projectedVertices; |
---|
281 | 385 | if (obj instanceof Camera) |
---|
282 | 386 | { |
---|
283 | 387 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
286 | 390 | display.options1[2] = material.shadowbias; |
---|
287 | 391 | display.options1[3] = material.aniso; |
---|
288 | 392 | display.options1[4] = material.anisoV; |
---|
| 393 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 394 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 395 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 396 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 397 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
289 | 398 | display.options2[0] = material.opacity; |
---|
290 | 399 | display.options2[1] = material.diffuse; |
---|
291 | 400 | display.options2[2] = material.factor; |
---|
| 401 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 402 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 403 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
292 | 404 | |
---|
293 | 405 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 406 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 407 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 408 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
294 | 409 | display.options4[0] = material.cameralight/0.2f; |
---|
295 | 410 | display.options4[1] = material.subsurface; |
---|
296 | 411 | display.options4[2] = material.sheen; |
---|
| 412 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 413 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 414 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
297 | 415 | |
---|
298 | 416 | // if (display.CURRENTANTIALIAS > 0) |
---|
299 | 417 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
309 | 427 | /**/ |
---|
310 | 428 | } else |
---|
311 | 429 | { |
---|
312 | | - DrawMaterial(material, selected); |
---|
| 430 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
313 | 431 | } |
---|
314 | 432 | } else |
---|
315 | 433 | { |
---|
.. | .. |
---|
333 | 451 | cStatic.objectstack[materialdepth++] = obj; |
---|
334 | 452 | //System.out.println("material " + material); |
---|
335 | 453 | //Applet3D.tracein("selected ", selected); |
---|
336 | | - display.vector2buffer = obj.projectedVertices; |
---|
337 | | - display.DrawMaterial(material, selected); |
---|
| 454 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 455 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
338 | 456 | } |
---|
339 | 457 | } |
---|
340 | 458 | |
---|
.. | .. |
---|
351 | 469 | materialdepth -= 1; |
---|
352 | 470 | if (materialdepth > 0) |
---|
353 | 471 | { |
---|
354 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
355 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 472 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 473 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
356 | 474 | } |
---|
357 | 475 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
358 | 476 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
372 | 490 | materialdepth -= 1; |
---|
373 | 491 | if (materialdepth > 0) |
---|
374 | 492 | { |
---|
375 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
376 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 493 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 494 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
377 | 495 | } |
---|
378 | 496 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
379 | 497 | //else |
---|
.. | .. |
---|
408 | 526 | |
---|
409 | 527 | javax.media.opengl.GL gl = display.GetGL(); |
---|
410 | 528 | |
---|
411 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 529 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
412 | 530 | |
---|
413 | 531 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
414 | 532 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
415 | 533 | { |
---|
416 | 534 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
417 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 535 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 536 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 537 | + ; |
---|
418 | 538 | if (!hasnorm) |
---|
419 | 539 | { |
---|
420 | | - // System.out.println("FUCK!!"); |
---|
| 540 | + // System.out.println("Mesh normal"); |
---|
421 | 541 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
422 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
423 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
760 | 880 | //// tris.postdraw(this); |
---|
761 | 881 | } |
---|
762 | 882 | |
---|
| 883 | + static Camera localcamera = new Camera(); |
---|
| 884 | + static cVector from = new cVector(); |
---|
| 885 | + static cVector to = new cVector(); |
---|
| 886 | + |
---|
| 887 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 888 | + { |
---|
| 889 | + CameraPane cp = this; |
---|
| 890 | + |
---|
| 891 | + Camera keep = cp.RenderCamera(); |
---|
| 892 | + cp.renderCamera = localcamera; |
---|
| 893 | + |
---|
| 894 | + if (br.trimmed) |
---|
| 895 | + { |
---|
| 896 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 897 | + |
---|
| 898 | + int i3 = 0; |
---|
| 899 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 900 | + { |
---|
| 901 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 902 | + continue; |
---|
| 903 | + |
---|
| 904 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 905 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 906 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 907 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 908 | + LA.xformPos(from, transform, from); |
---|
| 909 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 910 | + localcamera.setAim(from, to); |
---|
| 911 | + |
---|
| 912 | + CameraPane.occlusionbuffer.display(); |
---|
| 913 | + |
---|
| 914 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 915 | + cp.display(); // debug |
---|
| 916 | + |
---|
| 917 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 918 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 919 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 920 | + |
---|
| 921 | + if ((i % 100) == 0 && i != 0) |
---|
| 922 | + { |
---|
| 923 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 924 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 925 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 926 | + } |
---|
| 927 | + } |
---|
| 928 | + |
---|
| 929 | + br.colors = colors; |
---|
| 930 | + } |
---|
| 931 | + else |
---|
| 932 | + { |
---|
| 933 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 934 | + { |
---|
| 935 | + Vertex v = br.GetVertex(i); |
---|
| 936 | + |
---|
| 937 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 938 | + continue; |
---|
| 939 | + |
---|
| 940 | + from.set(v.x, v.y, v.z); |
---|
| 941 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 942 | + LA.xformPos(from, transform, from); |
---|
| 943 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 944 | + localcamera.setAim(from, to); |
---|
| 945 | + |
---|
| 946 | + CameraPane.occlusionbuffer.display(); |
---|
| 947 | + |
---|
| 948 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 949 | + cp.display(); // debug |
---|
| 950 | + |
---|
| 951 | + v.AO = cp.vertexOcclusion.r; |
---|
| 952 | + |
---|
| 953 | + if ((i % 100) == 0 && i != 0) |
---|
| 954 | + { |
---|
| 955 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 956 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 957 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 958 | + } |
---|
| 959 | + } |
---|
| 960 | + } |
---|
| 961 | + |
---|
| 962 | + //System.out.println("done."); |
---|
| 963 | + |
---|
| 964 | + cp.renderCamera = keep; |
---|
| 965 | + } |
---|
| 966 | + |
---|
| 967 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 968 | + { |
---|
| 969 | + CameraPane display = this; |
---|
| 970 | + pointFlow.CreateHT(); |
---|
| 971 | + |
---|
| 972 | + float r = display.modelParams0[0]; |
---|
| 973 | + float g = display.modelParams0[1]; |
---|
| 974 | + float b = display.modelParams0[2]; |
---|
| 975 | + float opacity = display.modelParams5[1]; |
---|
| 976 | + |
---|
| 977 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 978 | + GL gl = display.GetGL(); // getGL(); |
---|
| 979 | + |
---|
| 980 | + int s = pointFlow.points.size(); |
---|
| 981 | + |
---|
| 982 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 983 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 984 | + |
---|
| 985 | + for (int i=s; --i>=0;) |
---|
| 986 | + //for (int i=0; i<s; i++) |
---|
| 987 | + { |
---|
| 988 | + cVector v = pointFlow.points.get(i); |
---|
| 989 | + |
---|
| 990 | + double mindist = Double.MAX_VALUE; |
---|
| 991 | + |
---|
| 992 | + double size = pointFlow.minimumSize; |
---|
| 993 | + |
---|
| 994 | + double distancenext = 0; |
---|
| 995 | + |
---|
| 996 | + if (i > 0) |
---|
| 997 | + { |
---|
| 998 | + cVector w = pointFlow.points.get(i-1); |
---|
| 999 | + |
---|
| 1000 | + double dist = w.distance(v); |
---|
| 1001 | + |
---|
| 1002 | + distancenext = dist; |
---|
| 1003 | + |
---|
| 1004 | + if (mindist > dist) |
---|
| 1005 | + { |
---|
| 1006 | + mindist = dist; |
---|
| 1007 | + size = mindist*pointFlow.resizefactor; |
---|
| 1008 | + } |
---|
| 1009 | + } |
---|
| 1010 | + |
---|
| 1011 | + if (i < s-1) |
---|
| 1012 | + { |
---|
| 1013 | + cVector w = pointFlow.points.get(i+1); |
---|
| 1014 | + |
---|
| 1015 | + double dist = w.distance(v); |
---|
| 1016 | + |
---|
| 1017 | + if (mindist > dist) |
---|
| 1018 | + { |
---|
| 1019 | + mindist = dist; |
---|
| 1020 | + size = mindist*pointFlow.resizefactor; |
---|
| 1021 | + } |
---|
| 1022 | + } |
---|
| 1023 | + |
---|
| 1024 | + if (size < pointFlow.minimumSize) |
---|
| 1025 | + size = pointFlow.minimumSize; |
---|
| 1026 | + if (size > pointFlow.maximumSize) |
---|
| 1027 | + size = pointFlow.maximumSize; |
---|
| 1028 | + |
---|
| 1029 | + double tx = v.x; |
---|
| 1030 | + double ty = v.y; |
---|
| 1031 | + double tz = v.z; |
---|
| 1032 | + |
---|
| 1033 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 1034 | + // continue; |
---|
| 1035 | + |
---|
| 1036 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1037 | + gl.glPushMatrix(); |
---|
| 1038 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 1039 | + |
---|
| 1040 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 1041 | + |
---|
| 1042 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1043 | + gl.glPushMatrix(); |
---|
| 1044 | + |
---|
| 1045 | + gl.glTranslated(tx,ty,tz); |
---|
| 1046 | + |
---|
| 1047 | + gl.glScaled(size,size,size); |
---|
| 1048 | + |
---|
| 1049 | +// float cr = colorBuf.get(index4); |
---|
| 1050 | +// float cg = colorBuf.get(index4+1); |
---|
| 1051 | +// float cb = colorBuf.get(index4+2); |
---|
| 1052 | +// float ca = colorBuf.get(index4+3); |
---|
| 1053 | +// |
---|
| 1054 | +// display.modelParams0[0] = r * cr; |
---|
| 1055 | +// display.modelParams0[1] = g * cg; |
---|
| 1056 | +// display.modelParams0[2] = b * cb; |
---|
| 1057 | +// |
---|
| 1058 | +// display.modelParams5[1] = opacity * ca; |
---|
| 1059 | +// |
---|
| 1060 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1061 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1062 | +// |
---|
| 1063 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 1064 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 1065 | +// |
---|
| 1066 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 1067 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 1068 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 1069 | + |
---|
| 1070 | + gl.glPopMatrix(); |
---|
| 1071 | + |
---|
| 1072 | + double step = size/4; // |
---|
| 1073 | + |
---|
| 1074 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1075 | + continue; |
---|
| 1076 | + |
---|
| 1077 | + int nbsteps = (int)(distancenext/step); |
---|
| 1078 | + |
---|
| 1079 | + step = distancenext/nbsteps; |
---|
| 1080 | + |
---|
| 1081 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1082 | + |
---|
| 1083 | + tmp.set(next); |
---|
| 1084 | + tmp.sub(v); |
---|
| 1085 | + tmp.normalize(); |
---|
| 1086 | + tmp.mul(step); |
---|
| 1087 | + |
---|
| 1088 | + // calculate next size |
---|
| 1089 | + mindist = Double.MAX_VALUE; |
---|
| 1090 | + |
---|
| 1091 | + double nextsize = pointFlow.minimumSize; |
---|
| 1092 | + |
---|
| 1093 | + if (i > 1) |
---|
| 1094 | + { |
---|
| 1095 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1096 | + |
---|
| 1097 | + double dist = w.distance(next); |
---|
| 1098 | + |
---|
| 1099 | + if (mindist > dist) |
---|
| 1100 | + { |
---|
| 1101 | + mindist = dist; |
---|
| 1102 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1103 | + } |
---|
| 1104 | + } |
---|
| 1105 | + |
---|
| 1106 | + double dist = v.distance(next); |
---|
| 1107 | + |
---|
| 1108 | + if (mindist > dist) |
---|
| 1109 | + { |
---|
| 1110 | + mindist = dist; |
---|
| 1111 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1112 | + } |
---|
| 1113 | + |
---|
| 1114 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1115 | + nextsize = pointFlow.minimumSize; |
---|
| 1116 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1117 | + nextsize = pointFlow.maximumSize; |
---|
| 1118 | + // |
---|
| 1119 | + |
---|
| 1120 | + double count = 0; |
---|
| 1121 | + |
---|
| 1122 | + while (distancenext > 0.000000001) // step |
---|
| 1123 | + { |
---|
| 1124 | + gl.glPushMatrix(); |
---|
| 1125 | + |
---|
| 1126 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1127 | + |
---|
| 1128 | + double K = count/nbsteps; |
---|
| 1129 | + |
---|
| 1130 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1131 | + |
---|
| 1132 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1133 | + |
---|
| 1134 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1135 | + |
---|
| 1136 | + count++; |
---|
| 1137 | + |
---|
| 1138 | + distancenext -= step; |
---|
| 1139 | + |
---|
| 1140 | + gl.glPopMatrix(); |
---|
| 1141 | + } |
---|
| 1142 | + |
---|
| 1143 | + if (count != nbsteps) |
---|
| 1144 | + assert(count == nbsteps); |
---|
| 1145 | + |
---|
| 1146 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1147 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1148 | + |
---|
| 1149 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1150 | + gl.glPopMatrix(); |
---|
| 1151 | + } |
---|
| 1152 | + |
---|
| 1153 | + if (!cf) |
---|
| 1154 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1155 | + |
---|
| 1156 | +// display.modelParams0[0] = r; |
---|
| 1157 | +// display.modelParams0[1] = g; |
---|
| 1158 | +// display.modelParams0[2] = b; |
---|
| 1159 | +// |
---|
| 1160 | +// display.modelParams5[1] = opacity; |
---|
| 1161 | +// |
---|
| 1162 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1163 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1164 | + |
---|
| 1165 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1166 | + } |
---|
| 1167 | + |
---|
| 1168 | + public void DrawBox(cVector min, cVector max) |
---|
| 1169 | + { |
---|
| 1170 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1171 | + gl.glBegin(gl.GL_LINES); |
---|
| 1172 | + |
---|
| 1173 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1174 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1175 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1176 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1177 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1178 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1179 | + |
---|
| 1180 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1181 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1182 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1183 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1184 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1185 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1186 | + |
---|
| 1187 | + gl.glEnd(); |
---|
| 1188 | + } |
---|
| 1189 | + |
---|
| 1190 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1191 | + { |
---|
| 1192 | + int[] strips = bRep.getRawIndices(); |
---|
| 1193 | + |
---|
| 1194 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1195 | + |
---|
| 1196 | + // TRIANGLE STRIP ARRAY |
---|
| 1197 | + if (bRep.trimmed) |
---|
| 1198 | + { |
---|
| 1199 | + float[] v = bRep.getRawVertices(); |
---|
| 1200 | + float[] n = bRep.getRawNormals(); |
---|
| 1201 | + float[] c = bRep.getRawColors(); |
---|
| 1202 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1203 | + |
---|
| 1204 | + int count2 = 0; |
---|
| 1205 | + int count3 = 0; |
---|
| 1206 | + |
---|
| 1207 | + if (n.length > 0) |
---|
| 1208 | + { |
---|
| 1209 | + for (int i = 0; i < strips.length; i++) |
---|
| 1210 | + { |
---|
| 1211 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1212 | + |
---|
| 1213 | + /* |
---|
| 1214 | + boolean locked = false; |
---|
| 1215 | + float eps = 0.1f; |
---|
| 1216 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1217 | + |
---|
| 1218 | + int dot = 0; |
---|
| 1219 | + |
---|
| 1220 | + if ((dot&1) == 0) |
---|
| 1221 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1222 | + |
---|
| 1223 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1224 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1225 | + else |
---|
| 1226 | + { |
---|
| 1227 | + locked = true; |
---|
| 1228 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1229 | + } |
---|
| 1230 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1231 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1232 | + if (hasnorm) |
---|
| 1233 | + { |
---|
| 1234 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1235 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1236 | + } |
---|
| 1237 | + |
---|
| 1238 | + if ((dot&4) == 0) |
---|
| 1239 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1240 | + |
---|
| 1241 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1242 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1243 | + else |
---|
| 1244 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1245 | + |
---|
| 1246 | + f.dot = dot; |
---|
| 1247 | + */ |
---|
| 1248 | + |
---|
| 1249 | + if (!selectmode) |
---|
| 1250 | + { |
---|
| 1251 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1252 | + { |
---|
| 1253 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + } else |
---|
| 1255 | + { |
---|
| 1256 | + gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + } |
---|
| 1258 | + |
---|
| 1259 | + if (c != null) |
---|
| 1260 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1261 | + { |
---|
| 1262 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1263 | + } |
---|
| 1264 | + } |
---|
| 1265 | + |
---|
| 1266 | + if (flipV) |
---|
| 1267 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1268 | + else |
---|
| 1269 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1270 | + |
---|
| 1271 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1272 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1273 | + |
---|
| 1274 | + count2 += 2; |
---|
| 1275 | + count3 += 3; |
---|
| 1276 | + if (!selectmode) |
---|
| 1277 | + { |
---|
| 1278 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1279 | + { |
---|
| 1280 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + } else |
---|
| 1282 | + { |
---|
| 1283 | + gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + } |
---|
| 1285 | + if (c != null) |
---|
| 1286 | + { |
---|
| 1287 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1288 | + } |
---|
| 1289 | + } |
---|
| 1290 | + |
---|
| 1291 | + if (flipV) |
---|
| 1292 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1293 | + else |
---|
| 1294 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1295 | + |
---|
| 1296 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1297 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1298 | + |
---|
| 1299 | + count2 += 2; |
---|
| 1300 | + count3 += 3; |
---|
| 1301 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1302 | + { |
---|
| 1303 | + //gl.glTexCoord2d(...); |
---|
| 1304 | + if (!selectmode) |
---|
| 1305 | + { |
---|
| 1306 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1307 | + { |
---|
| 1308 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + } else |
---|
| 1310 | + { |
---|
| 1311 | + gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + } |
---|
| 1313 | + if (c != null) |
---|
| 1314 | + { |
---|
| 1315 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1316 | + } |
---|
| 1317 | + } |
---|
| 1318 | + |
---|
| 1319 | + if (flipV) |
---|
| 1320 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1321 | + else |
---|
| 1322 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1323 | + |
---|
| 1324 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1325 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1326 | + |
---|
| 1327 | + count2 += 2; |
---|
| 1328 | + count3 += 3; |
---|
| 1329 | + } |
---|
| 1330 | + |
---|
| 1331 | + gl.glEnd(); |
---|
| 1332 | + } |
---|
| 1333 | + } |
---|
| 1334 | + |
---|
| 1335 | + assert count3 == v.length; |
---|
| 1336 | + } |
---|
| 1337 | + else // !trimmed |
---|
| 1338 | + { |
---|
| 1339 | + int count = 0; |
---|
| 1340 | + for (int i = 0; i < strips.length; i++) |
---|
| 1341 | + { |
---|
| 1342 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1343 | + |
---|
| 1344 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1345 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1346 | + |
---|
| 1347 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1348 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1349 | + |
---|
| 1350 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1351 | + { |
---|
| 1352 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1353 | + |
---|
| 1354 | + // if (j%2 == 0) |
---|
| 1355 | + // drawFace(p, q, r, display, null); |
---|
| 1356 | + // else |
---|
| 1357 | + // drawFace(p, r, q, display, null); |
---|
| 1358 | + |
---|
| 1359 | + // p = q; |
---|
| 1360 | + // q = r; |
---|
| 1361 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1362 | + } |
---|
| 1363 | + |
---|
| 1364 | + gl.glEnd(); |
---|
| 1365 | + } |
---|
| 1366 | + } |
---|
| 1367 | + } |
---|
| 1368 | + |
---|
| 1369 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1370 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1371 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1372 | + |
---|
| 1373 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1374 | + { |
---|
| 1375 | + GL gl = GetGL(); // getGL(); |
---|
| 1376 | + |
---|
| 1377 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1378 | + |
---|
| 1379 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1380 | + |
---|
| 1381 | + gl.glLineWidth(1); |
---|
| 1382 | + gl.glColor3f(1,1,1); |
---|
| 1383 | + gl.glBegin(gl.GL_LINES); |
---|
| 1384 | + double scale = 0; |
---|
| 1385 | + int count = 0; |
---|
| 1386 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1387 | + { |
---|
| 1388 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1389 | + if(s == 0) |
---|
| 1390 | + { |
---|
| 1391 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1392 | + } |
---|
| 1393 | + if (mesh.showsprings) |
---|
| 1394 | + { |
---|
| 1395 | + temp.set(spring.a.position); |
---|
| 1396 | + temp.add(spring.b.position); |
---|
| 1397 | + temp.mul(0.5); |
---|
| 1398 | + temp2.set(spring.a.position); |
---|
| 1399 | + temp2.sub(spring.b.position); |
---|
| 1400 | + temp2.mul(spring.restLength/2); |
---|
| 1401 | + temp.sub(temp2); |
---|
| 1402 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1403 | + temp.add(temp2); |
---|
| 1404 | + temp.add(temp2); |
---|
| 1405 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1406 | + } |
---|
| 1407 | + |
---|
| 1408 | + if (spring.isHandle) |
---|
| 1409 | + continue; |
---|
| 1410 | + |
---|
| 1411 | + //if (scale < spring.restLength) |
---|
| 1412 | + scale += spring.restLength; |
---|
| 1413 | + count++; |
---|
| 1414 | + } |
---|
| 1415 | + gl.glEnd(); |
---|
| 1416 | + |
---|
| 1417 | + if (count == 0) |
---|
| 1418 | + scale = 0.01; |
---|
| 1419 | + else |
---|
| 1420 | + scale /= count * 3; |
---|
| 1421 | + |
---|
| 1422 | + //scale = 0.25; |
---|
| 1423 | + |
---|
| 1424 | + if (mesh.ShowInfo()) |
---|
| 1425 | + { |
---|
| 1426 | + gl.glLineWidth(4); |
---|
| 1427 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1428 | + { |
---|
| 1429 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1430 | + if (node.mass == 0) |
---|
| 1431 | + continue; |
---|
| 1432 | + |
---|
| 1433 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1434 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1435 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1436 | + //temp.normalize(); |
---|
| 1437 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1438 | + gl.glBegin(gl.GL_LINES); |
---|
| 1439 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1440 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1441 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1442 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1443 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1444 | + gl.glEnd(); |
---|
| 1445 | + } |
---|
| 1446 | + |
---|
| 1447 | + gl.glLineWidth(8); |
---|
| 1448 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1449 | + { |
---|
| 1450 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1451 | + |
---|
| 1452 | + if (node.springs != null) |
---|
| 1453 | + { |
---|
| 1454 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1455 | + { |
---|
| 1456 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1457 | + |
---|
| 1458 | + int c = i+1; |
---|
| 1459 | + // c = node.springs.get(i).nbcopies; |
---|
| 1460 | + |
---|
| 1461 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1462 | + gl.glBegin(gl.GL_LINES); |
---|
| 1463 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1464 | + 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); |
---|
| 1465 | + gl.glEnd(); |
---|
| 1466 | + } |
---|
| 1467 | + } |
---|
| 1468 | + } |
---|
| 1469 | + |
---|
| 1470 | + gl.glLineWidth(1); |
---|
| 1471 | + } |
---|
| 1472 | + |
---|
| 1473 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1474 | + } |
---|
| 1475 | + |
---|
763 | 1476 | /// INTERFACE |
---|
764 | 1477 | |
---|
| 1478 | + public void StartTriangles() |
---|
| 1479 | + { |
---|
| 1480 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1481 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1482 | + } |
---|
| 1483 | + |
---|
| 1484 | + public void EndTriangles() |
---|
| 1485 | + { |
---|
| 1486 | + GetGL().glEnd(); |
---|
| 1487 | + } |
---|
| 1488 | + |
---|
| 1489 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1490 | + { |
---|
| 1491 | + if (!selectmode) |
---|
| 1492 | + { |
---|
| 1493 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1494 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1495 | + |
---|
| 1496 | + if (flipV) |
---|
| 1497 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1498 | + else |
---|
| 1499 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1500 | + } |
---|
| 1501 | + |
---|
| 1502 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1503 | + } |
---|
| 1504 | + |
---|
| 1505 | + float[] colorV = new float[4]; |
---|
| 1506 | + |
---|
765 | 1507 | void SetColor(Object3D obj, Vertex p0) |
---|
766 | 1508 | { |
---|
767 | 1509 | CameraPane display = this; |
---|
.. | .. |
---|
829 | 1571 | { |
---|
830 | 1572 | return; |
---|
831 | 1573 | } |
---|
832 | | - |
---|
833 | | - float[] colorV = new float[3]; |
---|
834 | 1574 | |
---|
835 | 1575 | if (false) // marked) |
---|
836 | 1576 | { |
---|
.. | .. |
---|
939 | 1679 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
940 | 1680 | } |
---|
941 | 1681 | |
---|
942 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1682 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
943 | 1683 | { |
---|
944 | 1684 | CameraPane display = this; |
---|
945 | 1685 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
955 | 1695 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
956 | 1696 | if (!material.multiply) |
---|
957 | 1697 | { |
---|
958 | | - display.color = color; |
---|
| 1698 | + display.color = material.color; |
---|
959 | 1699 | display.saturation = material.modulation; |
---|
960 | 1700 | } |
---|
961 | 1701 | else |
---|
962 | 1702 | { |
---|
963 | | - display.color *= color*2; |
---|
| 1703 | + display.color *= material.color*2; |
---|
964 | 1704 | display.saturation *= material.modulation*2; |
---|
965 | 1705 | } |
---|
966 | 1706 | |
---|
967 | 1707 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
968 | 1708 | |
---|
969 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1709 | + float[] colorV = Grafreed.colorV; |
---|
970 | 1710 | |
---|
971 | 1711 | /**/ |
---|
972 | 1712 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
974 | 1714 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
975 | 1715 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
976 | 1716 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
977 | | - colorV[3] = material.opacity; |
---|
| 1717 | + colorV[3] = 1; // material.opacity; |
---|
978 | 1718 | |
---|
979 | 1719 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
980 | 1720 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1082 | 1822 | display.modelParams7[2] = 0; |
---|
1083 | 1823 | display.modelParams7[3] = 0; |
---|
1084 | 1824 | |
---|
1085 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1825 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1086 | 1826 | |
---|
1087 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1827 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1088 | 1828 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1089 | 1829 | { |
---|
1090 | 1830 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1226 | 1966 | void PushMatrix(double[][] matrix) |
---|
1227 | 1967 | { |
---|
1228 | 1968 | // GrafreeD.tracein(matrix); |
---|
1229 | | - PushMatrix(matrix,1); |
---|
| 1969 | + PushMatrix(matrix, 1); |
---|
1230 | 1970 | } |
---|
1231 | 1971 | |
---|
1232 | 1972 | void PushMatrix() |
---|
.. | .. |
---|
1323 | 2063 | |
---|
1324 | 2064 | static int camerachangeframe; |
---|
1325 | 2065 | |
---|
1326 | | - boolean SetCamera(Camera cam) |
---|
| 2066 | + public boolean SetCamera(Camera cam) |
---|
1327 | 2067 | { |
---|
1328 | 2068 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1329 | 2069 | // return false; |
---|
.. | .. |
---|
1380 | 2120 | //System.err.println("Oeil on"); |
---|
1381 | 2121 | OEIL = true; |
---|
1382 | 2122 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1383 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2123 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1384 | 2124 | //pingthread.StepToTarget(true); |
---|
1385 | 2125 | } |
---|
1386 | 2126 | |
---|
.. | .. |
---|
1451 | 2191 | mainDL ^= true; |
---|
1452 | 2192 | } |
---|
1453 | 2193 | |
---|
1454 | | - void ToggleTexture() |
---|
1455 | | - { |
---|
1456 | | - textureon ^= true; |
---|
1457 | | - } |
---|
1458 | | - |
---|
1459 | | - void ToggleLive() |
---|
1460 | | - { |
---|
1461 | | - Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
1462 | | - |
---|
1463 | | - System.err.println("LIVE = " + Globals.isLIVE()); |
---|
1464 | | - |
---|
1465 | | - if (!Globals.isLIVE()) // save sound |
---|
1466 | | - GrafreeD.savesound = true; // wav.save(); |
---|
1467 | | - // else |
---|
1468 | | - repaint(); // start loop // may 2013 |
---|
1469 | | - } |
---|
1470 | | - |
---|
1471 | | - void ToggleSupport() |
---|
1472 | | - { |
---|
1473 | | - SUPPORT ^= true; |
---|
1474 | | - } |
---|
1475 | | - |
---|
1476 | | - void ToggleAbort() |
---|
1477 | | - { |
---|
1478 | | - ABORTMODE ^= true; |
---|
1479 | | - } |
---|
1480 | | - |
---|
1481 | 2194 | void ToggleFullScreen() |
---|
1482 | 2195 | { |
---|
1483 | 2196 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1488 | 2201 | Globals.CROWD ^= true; |
---|
1489 | 2202 | } |
---|
1490 | 2203 | |
---|
1491 | | - void ToggleInertia() |
---|
1492 | | - { |
---|
1493 | | - INERTIA ^= true; |
---|
1494 | | - } |
---|
1495 | | - |
---|
1496 | 2204 | void ToggleLocal() |
---|
1497 | 2205 | { |
---|
1498 | 2206 | LOCALTRANSFORM ^= true; |
---|
1499 | 2207 | } |
---|
1500 | 2208 | |
---|
1501 | | - void ToggleFast() |
---|
| 2209 | + public void ToggleTexture() |
---|
| 2210 | + { |
---|
| 2211 | + textureon ^= true; |
---|
| 2212 | + } |
---|
| 2213 | + |
---|
| 2214 | + public void ToggleLive() |
---|
| 2215 | + { |
---|
| 2216 | + Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
| 2217 | + |
---|
| 2218 | + System.err.println("LIVE = " + Globals.isLIVE()); |
---|
| 2219 | + |
---|
| 2220 | + if (!Globals.isLIVE()) // save sound |
---|
| 2221 | + Grafreed.savesound = true; // wav.save(); |
---|
| 2222 | + // else |
---|
| 2223 | + repaint(); // start loop // may 2013 |
---|
| 2224 | + } |
---|
| 2225 | + |
---|
| 2226 | + public void ToggleSupport() |
---|
| 2227 | + { |
---|
| 2228 | + SUPPORT ^= true; |
---|
| 2229 | + } |
---|
| 2230 | + |
---|
| 2231 | + public void ToggleAbort() |
---|
| 2232 | + { |
---|
| 2233 | + ABORTMODE ^= true; |
---|
| 2234 | + } |
---|
| 2235 | + |
---|
| 2236 | + public void ToggleInertia() |
---|
| 2237 | + { |
---|
| 2238 | + INERTIA ^= true; |
---|
| 2239 | + } |
---|
| 2240 | + |
---|
| 2241 | + public void ToggleFast() |
---|
1502 | 2242 | { |
---|
1503 | 2243 | FAST ^= true; |
---|
1504 | 2244 | } |
---|
1505 | 2245 | |
---|
1506 | | - void ToggleSlowPose() |
---|
| 2246 | + public void ToggleSlowPose() |
---|
1507 | 2247 | { |
---|
1508 | 2248 | SLOWPOSE ^= true; |
---|
1509 | 2249 | } |
---|
1510 | 2250 | |
---|
1511 | | - void ToggleFootContact() |
---|
1512 | | - { |
---|
1513 | | - FOOTCONTACT ^= true; |
---|
1514 | | - } |
---|
1515 | | - |
---|
1516 | | - void ToggleBoxMode() |
---|
| 2251 | + public void ToggleBoxMode() |
---|
1517 | 2252 | { |
---|
1518 | 2253 | BOXMODE ^= true; |
---|
1519 | 2254 | } |
---|
1520 | 2255 | |
---|
1521 | | - void ToggleSmoothFocus() |
---|
| 2256 | + public void ToggleZoomBoxMode() |
---|
| 2257 | + { |
---|
| 2258 | + ZOOMBOXMODE ^= true; |
---|
| 2259 | + } |
---|
| 2260 | + |
---|
| 2261 | + public void ToggleSmoothFocus() |
---|
1522 | 2262 | { |
---|
1523 | 2263 | SMOOTHFOCUS ^= true; |
---|
1524 | 2264 | } |
---|
1525 | 2265 | |
---|
1526 | | - void ToggleImageFlip() |
---|
| 2266 | + public void ToggleImageFlip() |
---|
1527 | 2267 | { |
---|
1528 | 2268 | IMAGEFLIP ^= true; |
---|
1529 | 2269 | } |
---|
1530 | 2270 | |
---|
1531 | | - void ToggleSpeakerMocap() |
---|
| 2271 | + public void ToggleSpeakerMocap() |
---|
1532 | 2272 | { |
---|
1533 | 2273 | SPEAKERMOCAP ^= true; |
---|
1534 | 2274 | } |
---|
1535 | 2275 | |
---|
1536 | | - void ToggleSpeakerCamera() |
---|
| 2276 | + public void ToggleSpeakerCamera() |
---|
1537 | 2277 | { |
---|
1538 | 2278 | SPEAKERCAMERA ^= true; |
---|
1539 | 2279 | } |
---|
1540 | 2280 | |
---|
1541 | | - void ToggleSpeakerFocus() |
---|
| 2281 | + public void ToggleSpeakerFocus() |
---|
1542 | 2282 | { |
---|
1543 | 2283 | SPEAKERFOCUS ^= true; |
---|
1544 | 2284 | } |
---|
1545 | 2285 | |
---|
1546 | | - void ToggleDebug() |
---|
1547 | | - { |
---|
1548 | | - DEBUG ^= true; |
---|
1549 | | - } |
---|
1550 | | - |
---|
1551 | | - void ToggleFrustum() |
---|
| 2286 | + public void ToggleFrustum() |
---|
1552 | 2287 | { |
---|
1553 | 2288 | FRUSTUM ^= true; |
---|
1554 | 2289 | } |
---|
1555 | 2290 | |
---|
1556 | | - void ToggleTrack() |
---|
| 2291 | + public void ToggleTrack() |
---|
1557 | 2292 | { |
---|
1558 | 2293 | TRACK ^= true; |
---|
1559 | 2294 | if (TRACK) |
---|
.. | .. |
---|
1572 | 2307 | repaint(); |
---|
1573 | 2308 | } |
---|
1574 | 2309 | |
---|
1575 | | - void ToggleTrackOnce() |
---|
| 2310 | + public void ToggleTrackOnce() |
---|
1576 | 2311 | { |
---|
1577 | 2312 | TRACKONCE ^= true; |
---|
1578 | 2313 | } |
---|
1579 | 2314 | |
---|
1580 | | - void ToggleShadowTrack() |
---|
| 2315 | + public void ToggleShadowTrack() |
---|
1581 | 2316 | { |
---|
1582 | 2317 | SHADOWTRACK ^= true; |
---|
1583 | 2318 | repaint(); |
---|
1584 | 2319 | } |
---|
1585 | 2320 | |
---|
1586 | | - void ToggleOeil() |
---|
| 2321 | + public void ToggleOeil() |
---|
1587 | 2322 | { |
---|
1588 | 2323 | OEIL ^= true; |
---|
1589 | 2324 | } |
---|
1590 | 2325 | |
---|
1591 | | - void ToggleOeilOnce() |
---|
| 2326 | + public void ToggleOeilOnce() |
---|
1592 | 2327 | { |
---|
1593 | 2328 | OEILONCE ^= true; |
---|
| 2329 | + } |
---|
| 2330 | + |
---|
| 2331 | + void ToggleFootContact() |
---|
| 2332 | + { |
---|
| 2333 | + FOOTCONTACT ^= true; |
---|
| 2334 | + } |
---|
| 2335 | + |
---|
| 2336 | + void ToggleDebug() |
---|
| 2337 | + { |
---|
| 2338 | + Globals.DEBUG ^= true; |
---|
1594 | 2339 | } |
---|
1595 | 2340 | |
---|
1596 | 2341 | void ToggleLookAt() |
---|
.. | .. |
---|
1598 | 2343 | LOOKAT ^= true; |
---|
1599 | 2344 | } |
---|
1600 | 2345 | |
---|
1601 | | - void ToggleRandom() |
---|
| 2346 | + void ToggleSwitch() |
---|
1602 | 2347 | { |
---|
1603 | | - RANDOM ^= true; |
---|
| 2348 | + SWITCH ^= true; |
---|
1604 | 2349 | } |
---|
1605 | 2350 | |
---|
1606 | 2351 | void ToggleHandles() |
---|
.. | .. |
---|
1608 | 2353 | HANDLES ^= true; |
---|
1609 | 2354 | } |
---|
1610 | 2355 | |
---|
| 2356 | + Object3D paintFolder; |
---|
| 2357 | + |
---|
1611 | 2358 | void TogglePaint() |
---|
1612 | 2359 | { |
---|
1613 | 2360 | PAINTMODE ^= true; |
---|
1614 | 2361 | paintcount = 0; |
---|
| 2362 | + |
---|
| 2363 | + if (PAINTMODE) |
---|
| 2364 | + { |
---|
| 2365 | + paintFolder = GetFolder(); |
---|
| 2366 | + } |
---|
1615 | 2367 | } |
---|
1616 | 2368 | |
---|
1617 | 2369 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1707 | 2459 | { |
---|
1708 | 2460 | return currentGL; |
---|
1709 | 2461 | } |
---|
1710 | | - |
---|
| 2462 | + |
---|
| 2463 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2464 | + { |
---|
| 2465 | + Grafreed.Assert(texturedata != null); |
---|
| 2466 | + |
---|
| 2467 | + int width = texturedata.getWidth(); |
---|
| 2468 | + int height = texturedata.getHeight(); |
---|
| 2469 | + |
---|
| 2470 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2471 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2472 | + |
---|
| 2473 | + byte[] bytes = bytebuf.array(); |
---|
| 2474 | + |
---|
| 2475 | + return CreateBim(bytes, width, height); |
---|
| 2476 | + } |
---|
| 2477 | + |
---|
1711 | 2478 | /**/ |
---|
1712 | 2479 | class CacheTexture |
---|
1713 | 2480 | { |
---|
.. | .. |
---|
1716 | 2483 | |
---|
1717 | 2484 | int resolution; |
---|
1718 | 2485 | |
---|
1719 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2486 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1720 | 2487 | { |
---|
1721 | | - texture = tex; |
---|
| 2488 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2489 | + texturedata = texdata; |
---|
1722 | 2490 | resolution = res; |
---|
1723 | 2491 | } |
---|
1724 | 2492 | } |
---|
1725 | 2493 | /**/ |
---|
1726 | 2494 | |
---|
1727 | 2495 | // TEXTURE static Texture texture; |
---|
1728 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
1729 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
1730 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2496 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2497 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2498 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2499 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2500 | + |
---|
1731 | 2501 | int pigmentdepth = 0; |
---|
1732 | 2502 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1733 | 2503 | int bumpdepth = 0; |
---|
1734 | 2504 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1735 | 2505 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1736 | 2506 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1737 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2507 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1738 | 2508 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1739 | 2509 | |
---|
1740 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2510 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1741 | 2511 | { |
---|
1742 | 2512 | TextureData texturedata = null; |
---|
1743 | 2513 | |
---|
.. | .. |
---|
1747 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
1748 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
1749 | 2519 | true, |
---|
1750 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
1751 | 2521 | } catch (java.io.IOException e) |
---|
1752 | 2522 | { |
---|
1753 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
1756 | 2526 | if (bump) |
---|
1757 | 2527 | texturedata = ConvertBump(texturedata, false); |
---|
1758 | 2528 | |
---|
1759 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1760 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2529 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2530 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
1761 | 2531 | |
---|
1762 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
1763 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2532 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2533 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
1764 | 2534 | |
---|
1765 | | - return texture; |
---|
| 2535 | + return texturedata; |
---|
| 2536 | + } |
---|
| 2537 | + |
---|
| 2538 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2539 | + { |
---|
| 2540 | + TextureData texturedata = null; |
---|
| 2541 | + |
---|
| 2542 | + try |
---|
| 2543 | + { |
---|
| 2544 | + texturedata = |
---|
| 2545 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2546 | + bim, |
---|
| 2547 | + true); |
---|
| 2548 | + } catch (Exception e) |
---|
| 2549 | + { |
---|
| 2550 | + throw new javax.media.opengl.GLException(e); |
---|
| 2551 | + } |
---|
| 2552 | + |
---|
| 2553 | + if (bump) |
---|
| 2554 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2555 | + |
---|
| 2556 | + return texturedata; |
---|
1766 | 2557 | } |
---|
1767 | 2558 | |
---|
1768 | 2559 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2835 | 3626 | |
---|
2836 | 3627 | System.out.println("LOADING TEXTURE : " + name); |
---|
2837 | 3628 | |
---|
| 3629 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3630 | + |
---|
2838 | 3631 | // |
---|
2839 | 3632 | if (false) // compressbit > 0) |
---|
2840 | 3633 | { |
---|
.. | .. |
---|
3539 | 4332 | |
---|
3540 | 4333 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3541 | 4334 | { |
---|
| 4335 | + new Exception().printStackTrace(); |
---|
3542 | 4336 | System.exit(0); |
---|
3543 | 4337 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3544 | 4338 | |
---|
.. | .. |
---|
7232 | 8026 | String pigment = Object3D.GetPigment(tex); |
---|
7233 | 8027 | String bump = Object3D.GetBump(tex); |
---|
7234 | 8028 | |
---|
7235 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8029 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7236 | 8030 | { |
---|
7237 | 8031 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7238 | 8032 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7247 | 8041 | pigment = null; |
---|
7248 | 8042 | } |
---|
7249 | 8043 | |
---|
7250 | | - ReleaseTexture(bump, true); |
---|
7251 | | - ReleaseTexture(pigment, false); |
---|
| 8044 | + ReleaseTexture(tex, true); |
---|
| 8045 | + ReleaseTexture(tex, false); |
---|
7252 | 8046 | } |
---|
7253 | 8047 | |
---|
7254 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8048 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8049 | + { |
---|
| 8050 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8051 | + { |
---|
| 8052 | + return; |
---|
| 8053 | + } |
---|
| 8054 | + |
---|
| 8055 | + if (tex == null) |
---|
| 8056 | + { |
---|
| 8057 | + ReleaseTexture(null, false); |
---|
| 8058 | + return; |
---|
| 8059 | + } |
---|
| 8060 | + |
---|
| 8061 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8062 | + |
---|
| 8063 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8064 | + { |
---|
| 8065 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8066 | + // System.out.println("; bump = " + bump); |
---|
| 8067 | + } |
---|
| 8068 | + |
---|
| 8069 | + if (pigment.equals("")) |
---|
| 8070 | + { |
---|
| 8071 | + pigment = null; |
---|
| 8072 | + } |
---|
| 8073 | + |
---|
| 8074 | + ReleaseTexture(tex, false); |
---|
| 8075 | + } |
---|
| 8076 | + |
---|
| 8077 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8078 | + { |
---|
| 8079 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8080 | + { |
---|
| 8081 | + return; |
---|
| 8082 | + } |
---|
| 8083 | + |
---|
| 8084 | + if (tex == null) |
---|
| 8085 | + { |
---|
| 8086 | + ReleaseTexture(null, true); |
---|
| 8087 | + return; |
---|
| 8088 | + } |
---|
| 8089 | + |
---|
| 8090 | + String bump = Object3D.GetBump(tex); |
---|
| 8091 | + |
---|
| 8092 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8093 | + { |
---|
| 8094 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8095 | + // System.out.println("; bump = " + bump); |
---|
| 8096 | + } |
---|
| 8097 | + |
---|
| 8098 | + if (bump.equals("")) |
---|
| 8099 | + { |
---|
| 8100 | + bump = null; |
---|
| 8101 | + } |
---|
| 8102 | + |
---|
| 8103 | + ReleaseTexture(tex, true); |
---|
| 8104 | + } |
---|
| 8105 | + |
---|
| 8106 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7255 | 8107 | { |
---|
7256 | 8108 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7257 | 8109 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7262 | 8114 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7263 | 8115 | |
---|
7264 | 8116 | if (tex != null) |
---|
7265 | | - texture = textures.get(tex); |
---|
| 8117 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7266 | 8118 | |
---|
7267 | 8119 | // //assert( texture != null ); |
---|
7268 | 8120 | // if (texture == null) |
---|
.. | .. |
---|
7354 | 8206 | } |
---|
7355 | 8207 | } |
---|
7356 | 8208 | |
---|
7357 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8209 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8210 | + { |
---|
| 8211 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8212 | +// ambientOcclusion ) // || !textureon) |
---|
| 8213 | +// { |
---|
| 8214 | +// return; // false; |
---|
| 8215 | +// } |
---|
| 8216 | +// |
---|
| 8217 | +// if (tex == null) |
---|
| 8218 | +// { |
---|
| 8219 | +// BindTexture(null,false,resolution); |
---|
| 8220 | +// BindTexture(null,true,resolution); |
---|
| 8221 | +// return; |
---|
| 8222 | +// } |
---|
| 8223 | +// |
---|
| 8224 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8225 | +// String bump = Object3D.GetBump(tex); |
---|
| 8226 | +// |
---|
| 8227 | +// usedtextures.add(pigment); |
---|
| 8228 | +// usedtextures.add(bump); |
---|
| 8229 | +// |
---|
| 8230 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8231 | +// { |
---|
| 8232 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8233 | +// // System.out.println("; bump = " + bump); |
---|
| 8234 | +// } |
---|
| 8235 | +// |
---|
| 8236 | +// if (bump.equals("")) |
---|
| 8237 | +// { |
---|
| 8238 | +// bump = null; |
---|
| 8239 | +// } |
---|
| 8240 | +// if (pigment.equals("")) |
---|
| 8241 | +// { |
---|
| 8242 | +// pigment = null; |
---|
| 8243 | +// } |
---|
| 8244 | +// |
---|
| 8245 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8246 | +// BindTexture(pigment, false, resolution); |
---|
| 8247 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8248 | +// BindTexture(bump, true, resolution); |
---|
| 8249 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8250 | +// |
---|
| 8251 | +// return; // true; |
---|
| 8252 | + |
---|
| 8253 | + BindPigmentTexture(tex, resolution); |
---|
| 8254 | + BindBumpTexture(tex, resolution); |
---|
| 8255 | + } |
---|
| 8256 | + |
---|
| 8257 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7358 | 8258 | { |
---|
7359 | 8259 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7360 | 8260 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7365 | 8265 | if (tex == null) |
---|
7366 | 8266 | { |
---|
7367 | 8267 | BindTexture(null,false,resolution); |
---|
7368 | | - BindTexture(null,true,resolution); |
---|
7369 | 8268 | return; |
---|
7370 | 8269 | } |
---|
7371 | 8270 | |
---|
7372 | 8271 | String pigment = Object3D.GetPigment(tex); |
---|
| 8272 | + |
---|
| 8273 | + usedtextures.add(tex); |
---|
| 8274 | + |
---|
| 8275 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8276 | + { |
---|
| 8277 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8278 | + // System.out.println("; bump = " + bump); |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + if (pigment.equals("")) |
---|
| 8282 | + { |
---|
| 8283 | + pigment = null; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
| 8286 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8287 | + BindTexture(tex, false, resolution); |
---|
| 8288 | + } |
---|
| 8289 | + |
---|
| 8290 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8291 | + { |
---|
| 8292 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8293 | + ambientOcclusion ) // || !textureon) |
---|
| 8294 | + { |
---|
| 8295 | + return; // false; |
---|
| 8296 | + } |
---|
| 8297 | + |
---|
| 8298 | + if (tex == null) |
---|
| 8299 | + { |
---|
| 8300 | + BindTexture(null,true,resolution); |
---|
| 8301 | + return; |
---|
| 8302 | + } |
---|
| 8303 | + |
---|
7373 | 8304 | String bump = Object3D.GetBump(tex); |
---|
7374 | 8305 | |
---|
7375 | | - usedtextures.put(pigment, pigment); |
---|
7376 | | - usedtextures.put(bump, bump); |
---|
| 8306 | + usedtextures.add(tex); |
---|
7377 | 8307 | |
---|
7378 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8308 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7379 | 8309 | { |
---|
7380 | 8310 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7381 | 8311 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7385 | 8315 | { |
---|
7386 | 8316 | bump = null; |
---|
7387 | 8317 | } |
---|
7388 | | - if (pigment.equals("")) |
---|
7389 | | - { |
---|
7390 | | - pigment = null; |
---|
7391 | | - } |
---|
7392 | 8318 | |
---|
7393 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7394 | | - BindTexture(pigment, false, resolution); |
---|
7395 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7396 | | - BindTexture(bump, true, resolution); |
---|
| 8320 | + BindTexture(tex, true, resolution); |
---|
7397 | 8321 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7398 | | - |
---|
7399 | | - return; // true; |
---|
7400 | 8322 | } |
---|
7401 | 8323 | |
---|
7402 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8324 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8325 | + |
---|
| 8326 | + private boolean FileExists(String tex) |
---|
7403 | 8327 | { |
---|
7404 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + if (missingTextures.contains(tex)) |
---|
| 8329 | + { |
---|
| 8330 | + return false; |
---|
| 8331 | + } |
---|
| 8332 | + |
---|
| 8333 | + boolean fileExists = new File(tex).exists(); |
---|
| 8334 | + |
---|
| 8335 | + if (!fileExists) |
---|
| 8336 | + { |
---|
| 8337 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8338 | + missingTextures.add(tex); |
---|
| 8339 | + } |
---|
| 8340 | + |
---|
| 8341 | + return fileExists; |
---|
| 8342 | + } |
---|
| 8343 | + |
---|
| 8344 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8345 | + { |
---|
| 8346 | + CacheTexture texturecache = null; |
---|
7405 | 8347 | |
---|
7406 | 8348 | if (tex != null) |
---|
7407 | 8349 | { |
---|
7408 | | - String texname = tex; |
---|
| 8350 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8351 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7409 | 8352 | |
---|
7410 | | - String[] split = tex.split("Textures"); |
---|
7411 | | - if (split.length > 1) |
---|
7412 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
7413 | | - else |
---|
7414 | | - if (!texname.startsWith("/")) |
---|
7415 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8353 | + if (texname.equals("") && texdata == null) |
---|
| 8354 | + { |
---|
| 8355 | + return null; |
---|
| 8356 | + } |
---|
| 8357 | + |
---|
| 8358 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8359 | + |
---|
| 8360 | +// String[] split = tex.split("Textures"); |
---|
| 8361 | +// if (split.length > 1) |
---|
| 8362 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8363 | +// else |
---|
| 8364 | +// if (!texname.startsWith("/")) |
---|
| 8365 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
| 8367 | + { |
---|
| 8368 | + texname = fallbackTextureName; |
---|
| 8369 | + } |
---|
7416 | 8370 | |
---|
7417 | 8371 | if (CACHETEXTURE) |
---|
7418 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7419 | | - |
---|
7420 | | - TextureData texturedata = null; |
---|
7421 | | - |
---|
7422 | | - if (texture == null || texture.resolution < resolution) |
---|
7423 | 8372 | { |
---|
7424 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8373 | + if (texdata == null) |
---|
| 8374 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8375 | + else |
---|
| 8376 | + texturecache = bimtextures.get(texdata); |
---|
| 8377 | + } |
---|
| 8378 | + |
---|
| 8379 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8380 | + { |
---|
| 8381 | + TextureData texturedata = null; |
---|
| 8382 | + |
---|
| 8383 | + if (texdata != null && textureon) |
---|
| 8384 | + { |
---|
| 8385 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8386 | + |
---|
| 8387 | + try |
---|
| 8388 | + { |
---|
| 8389 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8390 | + } |
---|
| 8391 | + catch (Exception e) |
---|
| 8392 | + { |
---|
| 8393 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8394 | + } |
---|
| 8395 | + |
---|
| 8396 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8397 | + bimtextures.put(texdata, texturecache); |
---|
| 8398 | + |
---|
| 8399 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8400 | + |
---|
| 8401 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8402 | + //bim2 = bim; |
---|
| 8403 | + } |
---|
| 8404 | + else |
---|
| 8405 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
7425 | 8406 | { |
---|
7426 | 8407 | assert(!bump); |
---|
7427 | 8408 | // if (bump) |
---|
.. | .. |
---|
7432 | 8413 | // } |
---|
7433 | 8414 | // else |
---|
7434 | 8415 | // { |
---|
7435 | | - texture = textures.get(tex); |
---|
7436 | | - if (texture == null) |
---|
| 8416 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8417 | + if (texturecache == null) |
---|
7437 | 8418 | { |
---|
7438 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8419 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7439 | 8420 | } |
---|
| 8421 | + else |
---|
| 8422 | + new Exception().printStackTrace(); |
---|
7440 | 8423 | // } |
---|
7441 | 8424 | } else |
---|
7442 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8425 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7443 | 8426 | { |
---|
7444 | 8427 | assert(bump); |
---|
7445 | | - texture = textures.get(tex); |
---|
7446 | | - if (texture == null) |
---|
7447 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8428 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8429 | + if (texturecache == null) |
---|
| 8430 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8431 | + else |
---|
| 8432 | + new Exception().printStackTrace(); |
---|
7448 | 8433 | } else |
---|
7449 | 8434 | { |
---|
7450 | 8435 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7452 | 8437 | // texture = GetResourceTexture("default.png"); |
---|
7453 | 8438 | //} else |
---|
7454 | 8439 | //{ |
---|
7455 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8440 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7456 | 8441 | { |
---|
7457 | | - texture = textures.get(tex); |
---|
7458 | | - if (texture == null) |
---|
7459 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8442 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8443 | + if (texturecache == null) |
---|
| 8444 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8445 | + else |
---|
| 8446 | + new Exception().printStackTrace(); |
---|
| 8447 | + } else |
---|
| 8448 | + { |
---|
| 8449 | + if (texname.startsWith("@")) |
---|
| 8450 | + { |
---|
| 8451 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8452 | + if (texturecache == null) |
---|
| 8453 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8454 | + else |
---|
| 8455 | + new Exception().printStackTrace(); |
---|
7460 | 8456 | } else |
---|
7461 | 8457 | { |
---|
7462 | 8458 | if (textureon) |
---|
.. | .. |
---|
7481 | 8477 | } |
---|
7482 | 8478 | |
---|
7483 | 8479 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7484 | | - if (!new File(cachename).exists()) |
---|
| 8480 | + if (!FileExists(cachename)) |
---|
7485 | 8481 | cachename = texname; |
---|
7486 | 8482 | else |
---|
7487 | 8483 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7503 | 8499 | } |
---|
7504 | 8500 | |
---|
7505 | 8501 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7506 | | - if (!new File(cachename).exists()) |
---|
| 8502 | + if (!FileExists(cachename)) |
---|
7507 | 8503 | cachename = texname; |
---|
7508 | 8504 | else |
---|
7509 | 8505 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7512 | 8508 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7513 | 8509 | |
---|
7514 | 8510 | |
---|
7515 | | - if (texturedata != null) |
---|
7516 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8511 | + if (texturedata == null) |
---|
| 8512 | + throw new Exception(); |
---|
| 8513 | + |
---|
| 8514 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
7517 | 8515 | //texture = GetTexture(tex, bump); |
---|
7518 | 8516 | } |
---|
| 8517 | + } |
---|
7519 | 8518 | } |
---|
7520 | 8519 | //} |
---|
7521 | 8520 | } |
---|
7522 | 8521 | |
---|
7523 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8522 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7524 | 8523 | { |
---|
7525 | 8524 | //return false; |
---|
7526 | 8525 | |
---|
7527 | 8526 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7528 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8527 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7529 | 8528 | { |
---|
7530 | 8529 | // String ext = "_highres"; |
---|
7531 | 8530 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7542 | 8541 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7543 | 8542 | if (!cachefile.exists()) |
---|
7544 | 8543 | { |
---|
7545 | | - // cache to disk |
---|
7546 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
7547 | | - //buffers[0]. |
---|
7548 | | - |
---|
7549 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
7550 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
7551 | | - |
---|
7552 | | - // squared size heuristic... |
---|
7553 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8544 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7554 | 8545 | { |
---|
7555 | | - for (int i=pixels.length; --i>=0;) |
---|
7556 | | - { |
---|
7557 | | - int i3 = i*3; |
---|
7558 | | - pixels[i] = 0xFF; |
---|
7559 | | - pixels[i] <<= 8; |
---|
7560 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
7561 | | - pixels[i] <<= 8; |
---|
7562 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
7563 | | - pixels[i] <<= 8; |
---|
7564 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
7565 | | - } |
---|
7566 | | - |
---|
7567 | | - /* |
---|
7568 | | - int r=0,g=0,b=0,a=0; |
---|
7569 | | - for (int i=0; i<width; i++) |
---|
7570 | | - for (int j=0; j<height; j++) |
---|
7571 | | - { |
---|
7572 | | - int index = j*width+i; |
---|
7573 | | - int p = pixels[index]; |
---|
7574 | | - a = ((p>>24) & 0xFF); |
---|
7575 | | - r = ((p>>16) & 0xFF); |
---|
7576 | | - g = ((p>>8) & 0xFF); |
---|
7577 | | - b = (p & 0xFF); |
---|
7578 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
7579 | | - } |
---|
7580 | | - /**/ |
---|
7581 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
7582 | | - int height = width; |
---|
7583 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
7584 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8546 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8547 | + |
---|
7585 | 8548 | ImageWriter writer = null; |
---|
7586 | 8549 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7587 | 8550 | if (iter.hasNext()) { |
---|
7588 | 8551 | writer = (ImageWriter)iter.next(); |
---|
7589 | 8552 | } |
---|
7590 | | - float compressionQuality = 0.9f; |
---|
| 8553 | + |
---|
| 8554 | + float compressionQuality = 0.85f; |
---|
7591 | 8555 | try |
---|
7592 | 8556 | { |
---|
7593 | 8557 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7604 | 8568 | } |
---|
7605 | 8569 | } |
---|
7606 | 8570 | } |
---|
7607 | | - |
---|
| 8571 | + |
---|
| 8572 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8573 | + |
---|
7608 | 8574 | //System.out.println("Texture = " + tex); |
---|
7609 | | - if (textures.containsKey(texname)) |
---|
| 8575 | + if (textures.containsKey(tex)) |
---|
7610 | 8576 | { |
---|
7611 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8577 | + CacheTexture thetex = textures.get(tex); |
---|
7612 | 8578 | thetex.texture.disable(); |
---|
7613 | 8579 | thetex.texture.dispose(); |
---|
7614 | | - textures.remove(texname); |
---|
| 8580 | + textures.remove(tex); |
---|
7615 | 8581 | } |
---|
7616 | 8582 | |
---|
7617 | | - texture.texturedata = texturedata; |
---|
7618 | | - textures.put(texname, texture); |
---|
| 8583 | + //texture.texturedata = texturedata; |
---|
| 8584 | + textures.put(tex, texturecache); |
---|
7619 | 8585 | |
---|
7620 | 8586 | // newtex = true; |
---|
7621 | 8587 | } |
---|
.. | .. |
---|
7631 | 8597 | } |
---|
7632 | 8598 | } |
---|
7633 | 8599 | |
---|
7634 | | - return texture; |
---|
| 8600 | + return texturecache; |
---|
7635 | 8601 | } |
---|
7636 | 8602 | |
---|
7637 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8603 | + static void EmbedTextures(cTexture tex) |
---|
| 8604 | + { |
---|
| 8605 | + if (tex.pigmentdata == null) |
---|
| 8606 | + { |
---|
| 8607 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8608 | + |
---|
| 8609 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8610 | + |
---|
| 8611 | + if (texturecache != null) |
---|
| 8612 | + { |
---|
| 8613 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8614 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8615 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8616 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8617 | + ; |
---|
| 8618 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + if (tex.bumpdata == null) |
---|
| 8623 | + { |
---|
| 8624 | + //String texname = Object3D.GetBump(tex); |
---|
| 8625 | + |
---|
| 8626 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8627 | + |
---|
| 8628 | + if (texturecache != null) |
---|
| 8629 | + { |
---|
| 8630 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8631 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8632 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8633 | + } |
---|
| 8634 | + } |
---|
| 8635 | + } |
---|
| 8636 | + |
---|
| 8637 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7638 | 8638 | { |
---|
7639 | 8639 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7640 | 8640 | |
---|
.. | .. |
---|
7652 | 8652 | return texture!=null?texture.texture:null; |
---|
7653 | 8653 | } |
---|
7654 | 8654 | |
---|
7655 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8655 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7656 | 8656 | { |
---|
7657 | 8657 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7658 | 8658 | |
---|
7659 | 8659 | return texture!=null?texture.texturedata:null; |
---|
7660 | 8660 | } |
---|
7661 | 8661 | |
---|
7662 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8662 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7663 | 8663 | { |
---|
7664 | 8664 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7665 | 8665 | { |
---|
7666 | 8666 | return false; |
---|
7667 | 8667 | } |
---|
7668 | 8668 | |
---|
7669 | | - boolean newtex = false; |
---|
| 8669 | + //boolean newtex = false; |
---|
7670 | 8670 | |
---|
7671 | 8671 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7672 | 8672 | |
---|
.. | .. |
---|
7698 | 8698 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7699 | 8699 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7700 | 8700 | |
---|
7701 | | - return newtex; |
---|
| 8701 | + return true; // Warning: not used. |
---|
7702 | 8702 | } |
---|
7703 | 8703 | |
---|
| 8704 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8705 | + { |
---|
| 8706 | + try |
---|
| 8707 | + { |
---|
| 8708 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8709 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8710 | + ImageWriter writer = writers.next(); |
---|
| 8711 | + |
---|
| 8712 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8713 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8714 | + param.setCompressionQuality(quality); |
---|
| 8715 | + |
---|
| 8716 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8717 | + writer.setOutput(ios); |
---|
| 8718 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8719 | + |
---|
| 8720 | + byte[] data = baos.toByteArray(); |
---|
| 8721 | + writer.dispose(); |
---|
| 8722 | + return data; |
---|
| 8723 | + } |
---|
| 8724 | + catch (Exception e) |
---|
| 8725 | + { |
---|
| 8726 | + e.printStackTrace(); |
---|
| 8727 | + return null; |
---|
| 8728 | + } |
---|
| 8729 | + } |
---|
| 8730 | + |
---|
| 8731 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8732 | + { |
---|
| 8733 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8734 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8735 | + ImageReader reader = writers.next(); |
---|
| 8736 | + |
---|
| 8737 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8738 | + |
---|
| 8739 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8740 | + param.setDestination(bim); |
---|
| 8741 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8742 | + |
---|
| 8743 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8744 | + reader.setInput(ios); |
---|
| 8745 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8746 | + reader.dispose(); |
---|
| 8747 | + |
---|
| 8748 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8749 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8750 | +// byte[] bytes = data.getData(); |
---|
| 8751 | +// |
---|
| 8752 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8753 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8754 | +// { |
---|
| 8755 | +// int i3 = i*3; |
---|
| 8756 | +// pixels[i] = 0xFF; |
---|
| 8757 | +// pixels[i] <<= 8; |
---|
| 8758 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8759 | +// pixels[i] <<= 8; |
---|
| 8760 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8761 | +// pixels[i] <<= 8; |
---|
| 8762 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8763 | +// } |
---|
| 8764 | +// |
---|
| 8765 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8766 | + |
---|
| 8767 | + return bim; |
---|
| 8768 | + } |
---|
| 8769 | + |
---|
7704 | 8770 | ShadowBuffer shadowPBuf; |
---|
7705 | 8771 | AntialiasBuffer antialiasPBuf; |
---|
7706 | 8772 | int MAXSTACK; |
---|
.. | .. |
---|
7717 | 8783 | |
---|
7718 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
7719 | 8785 | MAXSTACK = temp[0]; |
---|
7720 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
7721 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
7722 | 8789 | MAXSTACK = temp[0]; |
---|
7723 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
7724 | 8792 | |
---|
7725 | 8793 | // Use debug pipeline |
---|
7726 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
7728 | 8796 | gl = drawable.getGL(); // |
---|
7729 | 8797 | |
---|
7730 | 8798 | GL gl3 = getGL(); |
---|
7731 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
7732 | 8801 | |
---|
7733 | 8802 | |
---|
7734 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
7893 | 8962 | |
---|
7894 | 8963 | if (cubemap == null) |
---|
7895 | 8964 | { |
---|
7896 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
7897 | 8966 | } |
---|
7898 | 8967 | |
---|
7899 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
8169 | 9238 | |
---|
8170 | 9239 | void LoadEnvy(int which) |
---|
8171 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
8172 | 9243 | String name; |
---|
8173 | 9244 | String ext; |
---|
8174 | 9245 | |
---|
.. | .. |
---|
8180 | 9251 | cubemap = null; |
---|
8181 | 9252 | return; |
---|
8182 | 9253 | case 1: |
---|
8183 | | - name = "cubemaps/box_"; |
---|
8184 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
8185 | 9256 | reverseUP = false; |
---|
8186 | 9257 | break; |
---|
8187 | 9258 | case 2: |
---|
8188 | | - name = "cubemaps/uffizi_"; |
---|
8189 | | - ext = "png"; |
---|
8190 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
8191 | 9263 | case 3: |
---|
8192 | | - name = "cubemaps/CloudyHills_"; |
---|
8193 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
8194 | 9266 | reverseUP = false; |
---|
8195 | 9267 | break; |
---|
8196 | 9268 | case 4: |
---|
8197 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
8198 | 9270 | ext = "png"; |
---|
8199 | 9271 | reverseUP = false; |
---|
8200 | 9272 | break; |
---|
| 9273 | + case 5: |
---|
| 9274 | + name = "cubemaps/skycube/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 6: |
---|
| 9279 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 7: |
---|
| 9284 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
| 9288 | + case 8: |
---|
| 9289 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9290 | + ext = "jpg"; |
---|
| 9291 | + reverseUP = false; |
---|
| 9292 | + break; |
---|
| 9293 | + case 9: |
---|
| 9294 | + name = "cubemaps/UnionSquare/"; |
---|
| 9295 | + ext = "jpg"; |
---|
| 9296 | + reverseUP = false; |
---|
| 9297 | + break; |
---|
8201 | 9298 | default: |
---|
8202 | | - name = "cubemaps/rgb_"; |
---|
8203 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
8204 | 9302 | break; |
---|
8205 | 9303 | } |
---|
8206 | | - |
---|
8207 | | - try |
---|
8208 | | - { |
---|
8209 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8210 | | - } catch (IOException e) |
---|
8211 | | - { |
---|
8212 | | - throw new RuntimeException(e); |
---|
8213 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
8214 | 9306 | } |
---|
8215 | 9307 | |
---|
8216 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8242 | 9334 | static double[] model = new double[16]; |
---|
8243 | 9335 | double[] camera2light = new double[16]; |
---|
8244 | 9336 | double[] light2camera = new double[16]; |
---|
8245 | | - int newenvy = -1; |
---|
8246 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
8247 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8248 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
8249 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
8536 | 9632 | jy8[3] = 0.5f; |
---|
8537 | 9633 | } |
---|
8538 | 9634 | |
---|
8539 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9635 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
8540 | 9636 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8541 | 9637 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8542 | 9638 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8543 | 9639 | |
---|
| 9640 | + void ResetOptions() |
---|
| 9641 | + { |
---|
| 9642 | + options1[0] = 100; |
---|
| 9643 | + options1[1] = 0.025f; |
---|
| 9644 | + options1[2] = 0.01f; |
---|
| 9645 | + options1[3] = 0; |
---|
| 9646 | + options1[4] = 0; |
---|
| 9647 | + |
---|
| 9648 | + options2[0] = 0; |
---|
| 9649 | + options2[1] = 0.75f; |
---|
| 9650 | + options2[2] = 0; |
---|
| 9651 | + options2[3] = 0; |
---|
| 9652 | + |
---|
| 9653 | + options3[0] = 1; |
---|
| 9654 | + options3[1] = 1; |
---|
| 9655 | + options3[2] = 1; |
---|
| 9656 | + options3[3] = 0; |
---|
| 9657 | + |
---|
| 9658 | + options4[0] = 1; |
---|
| 9659 | + options4[1] = 0; |
---|
| 9660 | + options4[2] = 1; |
---|
| 9661 | + options4[3] = 0; |
---|
| 9662 | + } |
---|
| 9663 | + |
---|
8544 | 9664 | static int imagecount = 0; // movie generation |
---|
8545 | 9665 | |
---|
8546 | 9666 | static int jitter = 0; |
---|
.. | .. |
---|
8636 | 9756 | assert (parentcam != renderCamera); |
---|
8637 | 9757 | |
---|
8638 | 9758 | if (renderCamera != lightCamera) |
---|
8639 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8640 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9759 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8641 | 9761 | |
---|
8642 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8643 | 9763 | |
---|
.. | .. |
---|
8652 | 9772 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8653 | 9773 | |
---|
8654 | 9774 | if (renderCamera != lightCamera) |
---|
8655 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8656 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9775 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8657 | 9777 | |
---|
8658 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8659 | 9779 | |
---|
.. | .. |
---|
8699 | 9819 | rati = 1 / rati; |
---|
8700 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
8701 | 9821 | } |
---|
8702 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
8703 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
8704 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
8705 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
8706 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
8707 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
8708 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
8725 | 9847 | //gl.glFlush(); |
---|
8726 | 9848 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8727 | 9849 | |
---|
8728 | | - if (ANIMATION && ABORTED) |
---|
| 9850 | + if (Globals.ANIMATION && ABORTED) |
---|
8729 | 9851 | { |
---|
8730 | 9852 | System.err.println(" ABORTED FRAME"); |
---|
8731 | 9853 | break; |
---|
.. | .. |
---|
8755 | 9877 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8756 | 9878 | |
---|
8757 | 9879 | // save image |
---|
8758 | | - if (ANIMATION && !ABORTED) |
---|
| 9880 | + if (Globals.ANIMATION && !ABORTED) |
---|
8759 | 9881 | { |
---|
8760 | 9882 | VPwidth = viewport[2]; |
---|
8761 | 9883 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8866 | 9988 | |
---|
8867 | 9989 | // imagecount++; |
---|
8868 | 9990 | |
---|
8869 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9991 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
8870 | 9992 | |
---|
8871 | 9993 | if (!BOXMODE) |
---|
8872 | 9994 | { |
---|
8873 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9995 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
8874 | 9996 | } |
---|
8875 | 9997 | |
---|
8876 | 9998 | if (!BOXMODE) |
---|
.. | .. |
---|
8908 | 10030 | ABORTED = false; |
---|
8909 | 10031 | } |
---|
8910 | 10032 | else |
---|
8911 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10033 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8912 | 10034 | |
---|
8913 | 10035 | if (false) |
---|
8914 | 10036 | { |
---|
.. | .. |
---|
9571 | 10693 | |
---|
9572 | 10694 | public void display(GLAutoDrawable drawable) |
---|
9573 | 10695 | { |
---|
9574 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10696 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9575 | 10697 | { |
---|
9576 | | - GrafreeD.wav.save(); |
---|
9577 | | - GrafreeD.savesound = false; |
---|
9578 | | - GrafreeD.hassound = false; |
---|
| 10698 | + Grafreed.wav.save(); |
---|
| 10699 | + Grafreed.savesound = false; |
---|
| 10700 | + Grafreed.hassound = false; |
---|
9579 | 10701 | } |
---|
9580 | 10702 | // if (DEBUG_SELECTION) |
---|
9581 | 10703 | // { |
---|
.. | .. |
---|
9651 | 10773 | ANTIALIAS = 0; |
---|
9652 | 10774 | //System.out.println("RESTART"); |
---|
9653 | 10775 | AAtimer.restart(); |
---|
| 10776 | + Globals.TIMERRUNNING = true; |
---|
9654 | 10777 | } |
---|
9655 | 10778 | } |
---|
9656 | 10779 | } |
---|
.. | .. |
---|
9705 | 10828 | Object3D theobject = object; |
---|
9706 | 10829 | Object3D theparent = object.parent; |
---|
9707 | 10830 | object.parent = null; |
---|
9708 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10831 | + object = (Object3D)Grafreed.clone(object); |
---|
9709 | 10832 | object.Stripify(); |
---|
9710 | 10833 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9711 | 10834 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9718 | 10841 | ambientOcclusion = false; |
---|
9719 | 10842 | } |
---|
9720 | 10843 | |
---|
9721 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10844 | + if (//Globals.lighttouched && |
---|
| 10845 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9722 | 10846 | { |
---|
9723 | 10847 | //if (RENDERSHADOW) // ? |
---|
9724 | 10848 | if (!IsFrozen()) |
---|
9725 | 10849 | { |
---|
9726 | 10850 | // dec 2012 |
---|
9727 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10851 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9728 | 10852 | { |
---|
9729 | 10853 | Globals.framecount++; |
---|
9730 | 10854 | shadowbuffer.display(); |
---|
.. | .. |
---|
9737 | 10861 | |
---|
9738 | 10862 | if (wait) |
---|
9739 | 10863 | { |
---|
9740 | | - Sleep(500); |
---|
| 10864 | + Sleep(200); // blocks everything |
---|
9741 | 10865 | |
---|
9742 | 10866 | wait = false; |
---|
9743 | 10867 | } |
---|
.. | .. |
---|
9851 | 10975 | |
---|
9852 | 10976 | // if (parentcam != renderCamera) // not a light |
---|
9853 | 10977 | if (cam != lightCamera) |
---|
9854 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9855 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10978 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10979 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9856 | 10980 | |
---|
9857 | 10981 | for (int j = 0; j < 4; j++) |
---|
9858 | 10982 | { |
---|
.. | .. |
---|
9866 | 10990 | |
---|
9867 | 10991 | // if (parentcam != renderCamera) // not a light |
---|
9868 | 10992 | if (cam != lightCamera) |
---|
9869 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9870 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10993 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10994 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9871 | 10995 | |
---|
9872 | 10996 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9873 | 10997 | |
---|
.. | .. |
---|
9953 | 11077 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
9954 | 11078 | } |
---|
9955 | 11079 | |
---|
9956 | | - if (newenvy > -1) |
---|
| 11080 | +// if (newenvy > -1) |
---|
| 11081 | +// { |
---|
| 11082 | +// LoadEnvy(newenvy); |
---|
| 11083 | +// } |
---|
| 11084 | +// |
---|
| 11085 | +// newenvy = -1; |
---|
| 11086 | + |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
9957 | 11088 | { |
---|
9958 | | - LoadEnvy(newenvy); |
---|
| 11089 | + if (cubemaprgb == null) |
---|
| 11090 | + { |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
9959 | 11095 | } |
---|
9960 | | - |
---|
9961 | | - newenvy = -1; |
---|
9962 | | - |
---|
| 11096 | + else |
---|
| 11097 | + { |
---|
| 11098 | + if (object.skyboxname != null) |
---|
| 11099 | + { |
---|
| 11100 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11101 | + { |
---|
| 11102 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11103 | + cubemap.dispose(); |
---|
| 11104 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11105 | + loadedskyboxname = object.skyboxname; |
---|
| 11106 | + } |
---|
| 11107 | + } |
---|
| 11108 | + else |
---|
| 11109 | + { |
---|
| 11110 | + cubemapcustom = null; |
---|
| 11111 | + loadedskyboxname = null; |
---|
| 11112 | + } |
---|
| 11113 | + |
---|
| 11114 | + cubemap = cubemapcustom; |
---|
| 11115 | + } |
---|
| 11116 | + |
---|
9963 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
9964 | 11118 | //System.out.println("ratio = " + ratio); |
---|
9965 | 11119 | |
---|
.. | .. |
---|
9975 | 11129 | |
---|
9976 | 11130 | if (!IsFrozen() && !ambientOcclusion) |
---|
9977 | 11131 | { |
---|
9978 | | - DrawSkyBox(gl); |
---|
| 11132 | + DrawSkyBox(gl, (float)ratio); |
---|
9979 | 11133 | } |
---|
9980 | 11134 | |
---|
9981 | 11135 | //if (selection_view == -1) |
---|
.. | .. |
---|
10126 | 11280 | // Bump noise |
---|
10127 | 11281 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10128 | 11282 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10129 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11283 | + |
---|
| 11284 | + try |
---|
| 11285 | + { |
---|
| 11286 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11287 | + } |
---|
| 11288 | + catch (Exception e) |
---|
| 11289 | + { |
---|
| 11290 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11291 | + } |
---|
| 11292 | + |
---|
10130 | 11293 | |
---|
10131 | 11294 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10132 | 11295 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10149 | 11312 | |
---|
10150 | 11313 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10151 | 11314 | |
---|
10152 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10153 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10154 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11315 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11316 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11317 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10155 | 11318 | } else |
---|
10156 | 11319 | { |
---|
10157 | 11320 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10162 | 11325 | //System.out.println("BLENDING ON"); |
---|
10163 | 11326 | gl.glEnable(GL.GL_BLEND); |
---|
10164 | 11327 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10165 | | - |
---|
| 11328 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10166 | 11329 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10167 | 11330 | gl.glLoadIdentity(); |
---|
10168 | 11331 | |
---|
.. | .. |
---|
10251 | 11414 | System.err.println("parentcam != renderCamera"); |
---|
10252 | 11415 | |
---|
10253 | 11416 | // if (cam != lightCamera) |
---|
10254 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10255 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11417 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11418 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
10256 | 11419 | } |
---|
10257 | 11420 | |
---|
10258 | 11421 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10273 | 11436 | if (true) // TODO |
---|
10274 | 11437 | { |
---|
10275 | 11438 | if (cam != lightCamera) |
---|
10276 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10277 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11439 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11440 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10278 | 11441 | } |
---|
10279 | 11442 | |
---|
10280 | 11443 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10340 | 11503 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10341 | 11504 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10342 | 11505 | |
---|
10343 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11506 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10344 | 11507 | { |
---|
10345 | 11508 | /* |
---|
10346 | 11509 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10411 | 11574 | } |
---|
10412 | 11575 | } |
---|
10413 | 11576 | |
---|
10414 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11577 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10415 | 11578 | { |
---|
10416 | 11579 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10417 | 11580 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10419 | 11582 | |
---|
10420 | 11583 | boolean texon = textureon; |
---|
10421 | 11584 | |
---|
10422 | | - if (RENDERPROGRAM > 0) |
---|
10423 | | - { |
---|
10424 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10425 | | - textureon = false; |
---|
10426 | | - } |
---|
| 11585 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11586 | + textureon = false; |
---|
| 11587 | + |
---|
10427 | 11588 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10428 | 11589 | //System.out.println("ALLO"); |
---|
10429 | 11590 | gl.glColorMask(false, false, false, false); |
---|
10430 | 11591 | DrawObject(gl); |
---|
10431 | | - if (RENDERPROGRAM > 0) |
---|
10432 | | - { |
---|
10433 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10434 | | - textureon = texon; |
---|
10435 | | - } |
---|
| 11592 | + |
---|
| 11593 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11594 | + textureon = texon; |
---|
| 11595 | + |
---|
10436 | 11596 | gl.glColorMask(true, true, true, true); |
---|
10437 | 11597 | |
---|
10438 | 11598 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10439 | | - //gl.glDepthMask(false); |
---|
| 11599 | + gl.glDepthMask(false); |
---|
10440 | 11600 | } |
---|
10441 | 11601 | |
---|
10442 | 11602 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10590 | 11750 | { |
---|
10591 | 11751 | renderpass++; |
---|
10592 | 11752 | // System.out.println("Draw object... "); |
---|
| 11753 | + STEP = 1; |
---|
10593 | 11754 | if (FAST) // in case there is no script |
---|
10594 | | - STEP = 16; |
---|
| 11755 | + STEP = 8; |
---|
| 11756 | + |
---|
| 11757 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11758 | + { |
---|
| 11759 | + STEP *= 4; |
---|
| 11760 | + } |
---|
10595 | 11761 | |
---|
10596 | 11762 | //object.FullInvariants(); |
---|
10597 | 11763 | |
---|
.. | .. |
---|
10605 | 11771 | e.printStackTrace(); |
---|
10606 | 11772 | } |
---|
10607 | 11773 | |
---|
10608 | | - if (GrafreeD.RENDERME > 0) |
---|
10609 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11774 | + if (Grafreed.RENDERME > 0) |
---|
| 11775 | + Grafreed.RENDERME--; // mechante magouille |
---|
10610 | 11776 | |
---|
10611 | 11777 | Globals.ONESTEP = false; |
---|
10612 | 11778 | } |
---|
10613 | 11779 | |
---|
10614 | 11780 | static boolean zoomonce = false; |
---|
10615 | 11781 | |
---|
| 11782 | + static void CreateSelectedPoint() |
---|
| 11783 | + { |
---|
| 11784 | + if (selectedpoint == null) |
---|
| 11785 | + { |
---|
| 11786 | + debugpointG = new Sphere(); |
---|
| 11787 | + debugpointP = new Sphere(); |
---|
| 11788 | + debugpointC = new Sphere(); |
---|
| 11789 | + debugpointR = new Sphere(); |
---|
| 11790 | + |
---|
| 11791 | + selectedpoint = new Superellipsoid(); |
---|
| 11792 | + |
---|
| 11793 | + for (int i=0; i<8; i++) |
---|
| 11794 | + { |
---|
| 11795 | + debugpoints[i] = new Sphere(); |
---|
| 11796 | + } |
---|
| 11797 | + } |
---|
| 11798 | + } |
---|
| 11799 | + |
---|
10616 | 11800 | void DrawObject(GL gl, boolean draw) |
---|
10617 | 11801 | { |
---|
| 11802 | + // To clear camera values |
---|
| 11803 | + ResetOptions(); |
---|
| 11804 | + |
---|
10618 | 11805 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10619 | 11806 | // DrawMode() = SELECTION; |
---|
10620 | 11807 | //GL gl = getGL(); |
---|
10621 | 11808 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10622 | 11809 | { |
---|
10623 | 11810 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10624 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11811 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10625 | 11812 | pingthread.StepToTarget(true); // true); |
---|
10626 | 11813 | // zoomonce = false; |
---|
10627 | 11814 | } |
---|
.. | .. |
---|
10641 | 11828 | callist = gl.glGenLists(1); |
---|
10642 | 11829 | } |
---|
10643 | 11830 | |
---|
10644 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11831 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10645 | 11832 | |
---|
10646 | 11833 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10647 | 11834 | |
---|
.. | .. |
---|
10676 | 11863 | |
---|
10677 | 11864 | usedtextures.clear(); |
---|
10678 | 11865 | |
---|
10679 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11866 | + try |
---|
| 11867 | + { |
---|
| 11868 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11869 | + } |
---|
| 11870 | + catch (Exception e) |
---|
| 11871 | + { |
---|
| 11872 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11873 | + } |
---|
10680 | 11874 | } |
---|
10681 | 11875 | //System.out.println("--> " + stackdepth); |
---|
10682 | 11876 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10686 | 11880 | |
---|
10687 | 11881 | if (DrawMode() == DEFAULT) |
---|
10688 | 11882 | { |
---|
10689 | | - if (DEBUG) |
---|
| 11883 | + if (Globals.DEBUG) |
---|
10690 | 11884 | { |
---|
| 11885 | + CreateSelectedPoint(); |
---|
10691 | 11886 | float radius = 0.05f; |
---|
10692 | 11887 | if (selectedpoint.radius != radius) |
---|
10693 | 11888 | { |
---|
.. | .. |
---|
10741 | 11936 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10742 | 11937 | |
---|
10743 | 11938 | if (CLEANCACHE) |
---|
10744 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11939 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10745 | 11940 | { |
---|
10746 | | - String tex = e.nextElement(); |
---|
| 11941 | + cTexture tex = e.nextElement(); |
---|
10747 | 11942 | |
---|
10748 | 11943 | // System.out.println("Texture --------- " + tex); |
---|
10749 | 11944 | |
---|
10750 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11945 | + if (tex.equals("WHITE_NOISE:")) |
---|
10751 | 11946 | continue; |
---|
10752 | 11947 | |
---|
10753 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11948 | + if (!usedtextures.contains(tex)) |
---|
10754 | 11949 | { |
---|
| 11950 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10755 | 11951 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10756 | | - textures.get(tex).texture.dispose(); |
---|
10757 | | - textures.remove(tex); |
---|
| 11952 | + if (gettex != null) |
---|
| 11953 | + { |
---|
| 11954 | + gettex.texture.dispose(); |
---|
| 11955 | + texturepigment.remove(tex); |
---|
| 11956 | + } |
---|
| 11957 | + |
---|
| 11958 | + gettex = texturebump.get(tex); |
---|
| 11959 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11960 | + if (gettex != null) |
---|
| 11961 | + { |
---|
| 11962 | + gettex.texture.dispose(); |
---|
| 11963 | + texturebump.remove(tex); |
---|
| 11964 | + } |
---|
10758 | 11965 | } |
---|
10759 | 11966 | } |
---|
10760 | 11967 | } |
---|
.. | .. |
---|
10767 | 11974 | if (checker != null && DrawMode() == DEFAULT) |
---|
10768 | 11975 | { |
---|
10769 | 11976 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10770 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11977 | + try |
---|
| 11978 | + { |
---|
| 11979 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11980 | + } |
---|
| 11981 | + catch (Exception e) |
---|
| 11982 | + { |
---|
| 11983 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11984 | + } |
---|
10771 | 11985 | // NEAREST |
---|
10772 | 11986 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10773 | 11987 | DrawChecker(gl); |
---|
.. | .. |
---|
10849 | 12063 | return; |
---|
10850 | 12064 | } |
---|
10851 | 12065 | |
---|
10852 | | - String string = obj.GetToolTip(); |
---|
| 12066 | + String string = obj.toString(); //.GetToolTip(); |
---|
10853 | 12067 | |
---|
10854 | 12068 | GL gl = GetGL(); |
---|
10855 | 12069 | |
---|
.. | .. |
---|
11166 | 12380 | //obj.TransformToWorld(light, light); |
---|
11167 | 12381 | for (int i = tp.size(); --i >= 0;) |
---|
11168 | 12382 | { |
---|
11169 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11170 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12383 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12384 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11171 | 12385 | } |
---|
11172 | 12386 | |
---|
11173 | 12387 | |
---|
.. | .. |
---|
11184 | 12398 | parentcam = cameras[0]; |
---|
11185 | 12399 | } |
---|
11186 | 12400 | |
---|
11187 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11188 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12401 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12402 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11189 | 12403 | |
---|
11190 | 12404 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11191 | 12405 | |
---|
.. | .. |
---|
11275 | 12489 | |
---|
11276 | 12490 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11277 | 12491 | |
---|
11278 | | - String program = |
---|
| 12492 | + String programmin = |
---|
| 12493 | + // Min shader |
---|
11279 | 12494 | "!!ARBfp1.0\n" + |
---|
| 12495 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12496 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12497 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12498 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12499 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12500 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12501 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12502 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12503 | + "TEMP temp;" + |
---|
| 12504 | + "TEMP light;" + |
---|
| 12505 | + "TEMP ndotl;" + |
---|
| 12506 | + "TEMP normal;" + |
---|
| 12507 | + "TEMP depth;" + |
---|
| 12508 | + "TEMP eye;" + |
---|
| 12509 | + "TEMP pos;" + |
---|
| 12510 | + |
---|
| 12511 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12512 | + Normalize("normal") + |
---|
| 12513 | + "MOV light, state.light[0].position;" + |
---|
| 12514 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12515 | + |
---|
| 12516 | + // shadow |
---|
| 12517 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12518 | + "MOV temp, pos;" + |
---|
| 12519 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12520 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12521 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12522 | + |
---|
| 12523 | + // No shadow when out of frustum |
---|
| 12524 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12525 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12526 | + |
---|
| 12527 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12528 | + |
---|
| 12529 | + // Backlit |
---|
| 12530 | + "MOV pos.w, zero123.y;" + |
---|
| 12531 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12532 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12533 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12534 | + Normalize("eye") + |
---|
| 12535 | + |
---|
| 12536 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12537 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12538 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12539 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12540 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12541 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12542 | + |
---|
| 12543 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12544 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12545 | + |
---|
| 12546 | + // Pigment |
---|
| 12547 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12548 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12549 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL temp, temp, zero123.z;" + |
---|
| 12552 | + |
---|
| 12553 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12554 | + |
---|
| 12555 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12556 | + "MOV result.color, temp;" + |
---|
| 12557 | + "END"; |
---|
| 12558 | + |
---|
| 12559 | + String programmax = |
---|
| 12560 | + "!!ARBfp1.0\n" + |
---|
| 12561 | + |
---|
11280 | 12562 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11281 | 12563 | "PARAM light2cam0 = program.env[10];" + |
---|
11282 | 12564 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
11391 | 12673 | "TEMP shininess;" + |
---|
11392 | 12674 | "\n" + |
---|
11393 | 12675 | "MOV texSamp, one;" + |
---|
11394 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
11395 | | - |
---|
| 12676 | + |
---|
11396 | 12677 | "MOV mapgrid.x, one2048th.x;" + |
---|
11397 | 12678 | "MOV temp, fragment.texcoord[1];" + |
---|
11398 | 12679 | /* |
---|
.. | .. |
---|
11413 | 12694 | "MUL temp, floor, mapgrid.x;" + |
---|
11414 | 12695 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
11415 | 12696 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11416 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12697 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
11417 | 12698 | "") + |
---|
11418 | 12699 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
11419 | 12700 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
11420 | 12701 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11421 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
11422 | 12703 | "") + |
---|
11423 | 12704 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
11424 | 12705 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
11425 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
11426 | 12707 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
11427 | 12708 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
11428 | 12709 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11429 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12710 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
11430 | 12711 | "") + |
---|
11431 | 12712 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
11432 | 12713 | //"MOV params, material;" + |
---|
.. | .. |
---|
11797 | 13078 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
11798 | 13079 | "") + |
---|
11799 | 13080 | |
---|
11800 | | - // display shadow only (bump == 0) |
---|
| 13081 | + // display shadow only (fakedepth == 0) |
---|
11801 | 13082 | "SUB temp.x, half.x, shadow.x;" + |
---|
11802 | | - "MOV temp.y, -params6.x;" + |
---|
11803 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13083 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13084 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
11804 | 13085 | "SUB temp.y, one.x, temp.z;" + |
---|
11805 | 13086 | "MUL temp.x, temp.x, temp.y;" + |
---|
11806 | 13087 | "KIL temp.x;" + |
---|
.. | .. |
---|
11929 | 13210 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11930 | 13211 | |
---|
11931 | 13212 | "SUB temp.x, one.x, ndotl.x;" + |
---|
11932 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
11933 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13213 | + // Tuning for default skin |
---|
| 13214 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13215 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13216 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11934 | 13217 | "MUL temp.x, temp.x, temp.y;" + |
---|
11935 | 13218 | |
---|
11936 | 13219 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12129 | 13412 | //once = true; |
---|
12130 | 13413 | } |
---|
12131 | 13414 | |
---|
12132 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
12133 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13415 | + String program = programmax; |
---|
| 13416 | + |
---|
| 13417 | + if (Globals.MINSHADER) |
---|
| 13418 | + { |
---|
| 13419 | + program = programmin; |
---|
| 13420 | + } |
---|
| 13421 | + |
---|
| 13422 | + if (Globals.DEBUG) |
---|
| 13423 | + { |
---|
| 13424 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13425 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13426 | + } |
---|
| 13427 | + |
---|
12134 | 13428 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12135 | 13429 | |
---|
12136 | 13430 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12177 | 13471 | "\n" + |
---|
12178 | 13472 | "END\n"; |
---|
12179 | 13473 | |
---|
12180 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13474 | + if (Globals.DEBUG) |
---|
| 13475 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
12181 | 13476 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12182 | 13477 | |
---|
12183 | 13478 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12222 | 13517 | return out; |
---|
12223 | 13518 | } |
---|
12224 | 13519 | |
---|
12225 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13520 | + // Also does frustum culling |
---|
| 13521 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12226 | 13522 | { |
---|
12227 | 13523 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12228 | 13524 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12229 | 13525 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13526 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13527 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12230 | 13528 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12231 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12232 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12233 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12234 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13529 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13530 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12235 | 13531 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12236 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13532 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12237 | 13533 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12238 | 13534 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12239 | 13535 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12240 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13536 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12241 | 13537 | |
---|
12242 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12243 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13538 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13539 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12244 | 13540 | } |
---|
12245 | 13541 | |
---|
12246 | 13542 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12262 | 13558 | |
---|
12263 | 13559 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12264 | 13560 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13561 | + |
---|
| 13562 | + // Compare fragment depth in light space with shadowmap. |
---|
12265 | 13563 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12266 | 13564 | "SGE temp.y, temp.x, zero.x;" + |
---|
12267 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13565 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13566 | + |
---|
| 13567 | + // Reverse comparison |
---|
12268 | 13568 | "SUB temp.x, one.x, temp.x;" + |
---|
12269 | 13569 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12270 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13570 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12271 | 13571 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12272 | 13572 | |
---|
12273 | 13573 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12281 | 13581 | // No shadow for backface |
---|
12282 | 13582 | "DP3 temp.x, normal, lightd;" + |
---|
12283 | 13583 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13584 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13585 | + |
---|
| 13586 | + // No shadow when out of frustum |
---|
| 13587 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12284 | 13588 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12285 | 13589 | ""; |
---|
12286 | 13590 | } |
---|
.. | .. |
---|
12427 | 13731 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12428 | 13732 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12429 | 13733 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12430 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13734 | + |
---|
| 13735 | + //Object3D.cVector2[] vector2buffer; |
---|
12431 | 13736 | |
---|
12432 | 13737 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12433 | 13738 | // OUT : diff, spec |
---|
.. | .. |
---|
12443 | 13748 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12444 | 13749 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12445 | 13750 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
12446 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
12447 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
12448 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13751 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13752 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13753 | + |
---|
| 13754 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12449 | 13755 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12450 | 13756 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12451 | 13757 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12839 | 14145 | public void mousePressed(MouseEvent e) |
---|
12840 | 14146 | { |
---|
12841 | 14147 | //System.out.println("mousePressed: " + e); |
---|
12842 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14148 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12843 | 14149 | } |
---|
12844 | 14150 | |
---|
12845 | 14151 | static long prevtime = 0; |
---|
.. | .. |
---|
12866 | 14172 | |
---|
12867 | 14173 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12868 | 14174 | |
---|
| 14175 | + if (BUTTONLESSWHEEL) |
---|
12869 | 14176 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12870 | 14177 | { |
---|
12871 | 14178 | return; |
---|
.. | .. |
---|
12874 | 14181 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12875 | 14182 | |
---|
12876 | 14183 | // TIMER |
---|
12877 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14184 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12878 | 14185 | { |
---|
12879 | 14186 | keepboxmode = BOXMODE; |
---|
12880 | 14187 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12914 | 14221 | // mode |= META; |
---|
12915 | 14222 | //} |
---|
12916 | 14223 | |
---|
12917 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12918 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14224 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14225 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12919 | 14226 | anchorX = ax; |
---|
12920 | 14227 | anchorY = ay; |
---|
12921 | 14228 | prevX = px; |
---|
.. | .. |
---|
12949 | 14256 | else |
---|
12950 | 14257 | if (evt.getSource() == AAtimer) |
---|
12951 | 14258 | { |
---|
| 14259 | + Globals.TIMERRUNNING = false; |
---|
12952 | 14260 | if (mouseDown) |
---|
12953 | 14261 | { |
---|
12954 | 14262 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12974 | 14282 | // LIVE = waslive; |
---|
12975 | 14283 | // wasliveok = true; |
---|
12976 | 14284 | // waslive = false; |
---|
| 14285 | + |
---|
| 14286 | + // May 2019 Forget it: |
---|
| 14287 | + if (true) |
---|
| 14288 | + return; |
---|
12977 | 14289 | |
---|
12978 | 14290 | // source == timer |
---|
12979 | 14291 | if (mouseDown) |
---|
.. | .. |
---|
13004 | 14316 | |
---|
13005 | 14317 | // fev 2014??? |
---|
13006 | 14318 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13007 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14319 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13008 | 14320 | pingthread.StepToTarget(true); // true); |
---|
13009 | 14321 | } |
---|
13010 | 14322 | // if (!LIVE) |
---|
.. | .. |
---|
13013 | 14325 | |
---|
13014 | 14326 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13015 | 14327 | |
---|
13016 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14328 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13017 | 14329 | { |
---|
13018 | 14330 | if (!wasliveok) |
---|
13019 | 14331 | return; |
---|
13020 | 14332 | |
---|
13021 | 14333 | AAtimer.restart(); // |
---|
| 14334 | + Globals.TIMERRUNNING = true; |
---|
13022 | 14335 | |
---|
13023 | 14336 | // waslive = LIVE; |
---|
13024 | 14337 | // LIVE = false; |
---|
.. | .. |
---|
13030 | 14343 | // touched = true; // main DL |
---|
13031 | 14344 | if (isRenderer) |
---|
13032 | 14345 | { |
---|
13033 | | - SetMouseMode(modifiers); |
---|
| 14346 | + SetMouseMode(modifiers, modifiersex); |
---|
13034 | 14347 | } |
---|
13035 | 14348 | |
---|
13036 | 14349 | selectX = anchorX = x; |
---|
.. | .. |
---|
13043 | 14356 | clicked = true; |
---|
13044 | 14357 | hold = false; |
---|
13045 | 14358 | |
---|
13046 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14359 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13047 | 14360 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13048 | 14361 | { |
---|
13049 | 14362 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13068 | 14381 | drag = false; |
---|
13069 | 14382 | //System.out.println("Mouse DOWN"); |
---|
13070 | 14383 | editObj = false; |
---|
13071 | | - ClickInfo info = new ClickInfo(); |
---|
13072 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13073 | | - info.pane = this; |
---|
13074 | | - info.camera = renderCamera; |
---|
13075 | | - info.x = x; |
---|
13076 | | - info.y = y; |
---|
13077 | | - info.modifiers = modifiers; |
---|
13078 | | - editObj = object.doEditClick(info, 0); |
---|
| 14384 | + //ClickInfo info = new ClickInfo(); |
---|
| 14385 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14386 | + object.clickInfo.pane = this; |
---|
| 14387 | + object.clickInfo.camera = renderCamera; |
---|
| 14388 | + object.clickInfo.x = x; |
---|
| 14389 | + object.clickInfo.y = y; |
---|
| 14390 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14391 | + editObj = object.doEditClick(//info, |
---|
| 14392 | + 0); |
---|
13079 | 14393 | if (!editObj) |
---|
13080 | 14394 | { |
---|
13081 | 14395 | hasMarquee = true; |
---|
.. | .. |
---|
13091 | 14405 | |
---|
13092 | 14406 | public void mouseDragged(MouseEvent e) |
---|
13093 | 14407 | { |
---|
| 14408 | + Globals.MOUSEDRAGGED = true; |
---|
| 14409 | + |
---|
| 14410 | + //System.out.println("mouseDragged: " + e); |
---|
13094 | 14411 | if (isRenderer) |
---|
13095 | 14412 | movingcamera = true; |
---|
| 14413 | + |
---|
13096 | 14414 | //if (drawing) |
---|
13097 | 14415 | //return; |
---|
13098 | | - //System.out.println("mouseDragged: " + e); |
---|
13099 | 14416 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13100 | 14417 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13101 | 14418 | { |
---|
.. | .. |
---|
13103 | 14420 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13104 | 14421 | } |
---|
13105 | 14422 | else |
---|
13106 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14423 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13107 | 14424 | |
---|
13108 | 14425 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13109 | 14426 | } |
---|
.. | .. |
---|
13115 | 14432 | cVector tmp = new cVector(); |
---|
13116 | 14433 | cVector tmp2 = new cVector(); |
---|
13117 | 14434 | boolean isMoving; |
---|
| 14435 | + |
---|
| 14436 | + public cVector TargetLookAt() |
---|
| 14437 | + { |
---|
| 14438 | + return targetLookAt; |
---|
| 14439 | + } |
---|
13118 | 14440 | |
---|
13119 | 14441 | class PingThread extends Thread |
---|
13120 | 14442 | { |
---|
.. | .. |
---|
13271 | 14593 | |
---|
13272 | 14594 | public void run() |
---|
13273 | 14595 | { |
---|
| 14596 | + new Exception().printStackTrace(); |
---|
13274 | 14597 | System.exit(0); |
---|
13275 | 14598 | for (;;) |
---|
13276 | 14599 | { |
---|
.. | .. |
---|
13334 | 14657 | { |
---|
13335 | 14658 | Globals.lighttouched = true; |
---|
13336 | 14659 | } |
---|
13337 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14660 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13338 | 14661 | } |
---|
13339 | 14662 | //else |
---|
13340 | 14663 | } |
---|
.. | .. |
---|
13348 | 14671 | void GoDown(int mod) |
---|
13349 | 14672 | { |
---|
13350 | 14673 | MODIFIERS |= COMMAND; |
---|
13351 | | - /* |
---|
| 14674 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14675 | + /**/ |
---|
13352 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
13353 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14677 | + { |
---|
| 14678 | + if (isVR) |
---|
| 14679 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14680 | + else |
---|
| 14681 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14682 | + } |
---|
13354 | 14683 | else |
---|
13355 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13356 | | - */ |
---|
| 14684 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14685 | + /**/ |
---|
13357 | 14686 | if ((mod & SHIFT) == SHIFT) |
---|
13358 | 14687 | { |
---|
13359 | 14688 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13362 | 14691 | mouseMode |= BACKFORTH; |
---|
13363 | 14692 | } |
---|
13364 | 14693 | |
---|
| 14694 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14695 | + |
---|
13365 | 14696 | //prevX = X = anchorX; |
---|
13366 | 14697 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
13367 | 14698 | } |
---|
.. | .. |
---|
13369 | 14700 | void GoUp(int mod) |
---|
13370 | 14701 | { |
---|
13371 | 14702 | MODIFIERS |= COMMAND; |
---|
13372 | | - /* |
---|
| 14703 | + /**/ |
---|
| 14704 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14705 | + |
---|
13373 | 14706 | if((mod&SHIFT) == SHIFT) |
---|
13374 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14707 | + { |
---|
| 14708 | + if (isVR) |
---|
| 14709 | + manipCamera.RotateInterest(0, speed); |
---|
| 14710 | + else |
---|
| 14711 | + manipCamera.RotatePosition(0, speed); |
---|
| 14712 | + } |
---|
13375 | 14713 | else |
---|
13376 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13377 | | - */ |
---|
| 14714 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14715 | + /**/ |
---|
13378 | 14716 | if ((mod & SHIFT) == SHIFT) |
---|
13379 | 14717 | { |
---|
13380 | 14718 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13383 | 14721 | mouseMode |= BACKFORTH; |
---|
13384 | 14722 | } |
---|
13385 | 14723 | |
---|
| 14724 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14725 | + |
---|
13386 | 14726 | //prevX = X = anchorX; |
---|
13387 | 14727 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
13388 | 14728 | } |
---|
.. | .. |
---|
13390 | 14730 | void GoLeft(int mod) |
---|
13391 | 14731 | { |
---|
13392 | 14732 | MODIFIERS |= COMMAND; |
---|
13393 | | - /* |
---|
| 14733 | + /**/ |
---|
13394 | 14734 | if((mod&SHIFT) == SHIFT) |
---|
13395 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14735 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13396 | 14736 | else |
---|
13397 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13398 | | - */ |
---|
| 14737 | + { |
---|
| 14738 | + if ((mouseMode&VR)!=0) |
---|
| 14739 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14740 | + else |
---|
| 14741 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14742 | + } |
---|
| 14743 | + /**/ |
---|
13399 | 14744 | if ((mod & SHIFT) == SHIFT) |
---|
13400 | 14745 | { |
---|
13401 | 14746 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13404 | 14749 | mouseMode |= ROTATE; |
---|
13405 | 14750 | } // TRANSLATE; |
---|
13406 | 14751 | |
---|
| 14752 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14753 | + |
---|
13407 | 14754 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
13408 | 14755 | prevY = Y = anchorY; |
---|
13409 | 14756 | } |
---|
.. | .. |
---|
13411 | 14758 | void GoRight(int mod) |
---|
13412 | 14759 | { |
---|
13413 | 14760 | MODIFIERS |= COMMAND; |
---|
13414 | | - /* |
---|
| 14761 | + /**/ |
---|
13415 | 14762 | if((mod&SHIFT) == SHIFT) |
---|
13416 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14763 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13417 | 14764 | else |
---|
13418 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13419 | | - */ |
---|
| 14765 | + { |
---|
| 14766 | + if ((mouseMode&VR)!=0) |
---|
| 14767 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14768 | + else |
---|
| 14769 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14770 | + } |
---|
| 14771 | + |
---|
| 14772 | + /**/ |
---|
13420 | 14773 | if ((mod & SHIFT) == SHIFT) |
---|
13421 | 14774 | { |
---|
13422 | 14775 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13425 | 14778 | mouseMode |= ROTATE; |
---|
13426 | 14779 | } // TRANSLATE; |
---|
13427 | 14780 | |
---|
| 14781 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14782 | + |
---|
13428 | 14783 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
13429 | 14784 | prevY = Y = anchorY; |
---|
13430 | 14785 | } |
---|
.. | .. |
---|
13434 | 14789 | int X, Y; |
---|
13435 | 14790 | boolean SX, SY; |
---|
13436 | 14791 | |
---|
13437 | | - void drag(int x, int y, int modifiers) |
---|
| 14792 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13438 | 14793 | { |
---|
13439 | 14794 | if (IsFrozen()) |
---|
13440 | 14795 | { |
---|
.. | .. |
---|
13443 | 14798 | |
---|
13444 | 14799 | drag = true; // NEW |
---|
13445 | 14800 | |
---|
13446 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14801 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13447 | 14802 | |
---|
13448 | 14803 | X = x; |
---|
13449 | 14804 | Y = y; |
---|
13450 | 14805 | // floating state for animation |
---|
13451 | | - MODIFIERS = modifiers; |
---|
13452 | | - modifiers &= ~1024; |
---|
| 14806 | + MODIFIERS = modifiersex; |
---|
| 14807 | + modifiersex &= ~1024; |
---|
13453 | 14808 | if (false) // modifiers != 0) |
---|
13454 | 14809 | { |
---|
13455 | 14810 | //new Exception().printStackTrace(); |
---|
13456 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14811 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13457 | 14812 | System.out.println("SHIFT = " + SHIFT); |
---|
13458 | 14813 | System.out.println("CONTROL = " + COMMAND); |
---|
13459 | 14814 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13466 | 14821 | if (editObj) |
---|
13467 | 14822 | { |
---|
13468 | 14823 | drag = true; |
---|
13469 | | - ClickInfo info = new ClickInfo(); |
---|
13470 | | - info.bounds.setBounds(0, 0, |
---|
| 14824 | + //ClickInfo info = new ClickInfo(); |
---|
| 14825 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
13471 | 14826 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13472 | | - info.pane = this; |
---|
13473 | | - info.camera = renderCamera; |
---|
13474 | | - info.x = x; |
---|
13475 | | - info.y = y; |
---|
13476 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14827 | + object.clickInfo.pane = this; |
---|
| 14828 | + object.clickInfo.camera = renderCamera; |
---|
| 14829 | + object.clickInfo.x = x; |
---|
| 14830 | + object.clickInfo.y = y; |
---|
| 14831 | + object //.GetWindow().copy |
---|
| 14832 | + .doEditDrag(//info, |
---|
| 14833 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13477 | 14834 | } else |
---|
13478 | 14835 | { |
---|
13479 | 14836 | if (x < startX) |
---|
.. | .. |
---|
13622 | 14979 | } |
---|
13623 | 14980 | } |
---|
13624 | 14981 | |
---|
| 14982 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14983 | + |
---|
13625 | 14984 | public void mouseMoved(MouseEvent e) |
---|
13626 | 14985 | { |
---|
13627 | 14986 | //System.out.println("mouseMoved: " + e); |
---|
13628 | | - |
---|
13629 | 14987 | if (isRenderer) |
---|
13630 | 14988 | return; |
---|
13631 | 14989 | |
---|
13632 | | - ClickInfo ci = new ClickInfo(); |
---|
13633 | | - ci.x = e.getX(); |
---|
13634 | | - ci.y = e.getY(); |
---|
13635 | | - ci.modifiers = e.getModifiersEx(); |
---|
13636 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13637 | | - ci.pane = this; |
---|
13638 | | - ci.camera = renderCamera; |
---|
| 14990 | + // Mouse cursor feedback |
---|
| 14991 | + object.clickInfo.x = e.getX(); |
---|
| 14992 | + object.clickInfo.y = e.getY(); |
---|
| 14993 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14994 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14995 | + object.clickInfo.pane = this; |
---|
| 14996 | + object.clickInfo.camera = renderCamera; |
---|
13639 | 14997 | if (!isRenderer) |
---|
13640 | 14998 | { |
---|
13641 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14999 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15000 | + //Object3D copy = editWindow.copy; |
---|
| 15001 | + if (object.doEditClick(//clickInfo, |
---|
| 15002 | + 0)) |
---|
13642 | 15003 | { |
---|
13643 | 15004 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13644 | 15005 | } else |
---|
.. | .. |
---|
13650 | 15011 | |
---|
13651 | 15012 | public void mouseReleased(MouseEvent e) |
---|
13652 | 15013 | { |
---|
| 15014 | + Globals.MOUSEDRAGGED = false; |
---|
| 15015 | + |
---|
13653 | 15016 | movingcamera = false; |
---|
| 15017 | + X = 0; // getBounds().width/2; |
---|
| 15018 | + Y = 0; // getBounds().height/2; |
---|
13654 | 15019 | //System.out.println("mouseReleased: " + e); |
---|
13655 | 15020 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13656 | 15021 | } |
---|
.. | .. |
---|
13673 | 15038 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13674 | 15039 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13675 | 15040 | |
---|
13676 | | - if (control || command || IsFrozen()) |
---|
| 15041 | +// No delay if (control || command || IsFrozen()) |
---|
13677 | 15042 | timeout = true; |
---|
13678 | | - else |
---|
| 15043 | +// ?? May 2019 else |
---|
13679 | 15044 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13680 | 15045 | mouseDown = false; |
---|
13681 | 15046 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13785 | 15150 | System.out.println("keyReleased: " + e); |
---|
13786 | 15151 | } |
---|
13787 | 15152 | |
---|
13788 | | - void SetMouseMode(int modifiers) |
---|
| 15153 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13789 | 15154 | { |
---|
13790 | 15155 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13791 | 15156 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13797 | 15162 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13798 | 15163 | // return; |
---|
13799 | 15164 | //System.out.println("SetMode = " + modifiers); |
---|
13800 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15165 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13801 | 15166 | { |
---|
13802 | 15167 | mouseMode |= ZOOM; |
---|
13803 | 15168 | } |
---|
13804 | 15169 | |
---|
13805 | 15170 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13806 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15171 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13807 | 15172 | { |
---|
13808 | 15173 | mouseMode |= VR; // BACKFORTH; |
---|
13809 | 15174 | } |
---|
13810 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15175 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13811 | 15176 | { |
---|
13812 | 15177 | mouseMode |= SELECT; |
---|
13813 | 15178 | } |
---|
13814 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15179 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13815 | 15180 | { |
---|
13816 | 15181 | mouseMode |= SELECT; |
---|
13817 | 15182 | } |
---|
13818 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15183 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13819 | 15184 | { |
---|
13820 | 15185 | mouseMode &= ~VR; |
---|
13821 | 15186 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13844 | 15209 | |
---|
13845 | 15210 | if (isRenderer) // |
---|
13846 | 15211 | { |
---|
13847 | | - SetMouseMode(modifiers); |
---|
| 15212 | + SetMouseMode(0, modifiers); |
---|
13848 | 15213 | } |
---|
13849 | 15214 | |
---|
13850 | | - theRenderer.keyPressed(key); |
---|
| 15215 | + Globals.theRenderer.keyPressed(key); |
---|
13851 | 15216 | } |
---|
13852 | 15217 | |
---|
13853 | 15218 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13859 | 15224 | float SATPOW = 1; // 2; // 0.5f; |
---|
13860 | 15225 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13861 | 15226 | |
---|
13862 | | - void keyPressed(int key) |
---|
| 15227 | + public void keyPressed(int key) |
---|
13863 | 15228 | { |
---|
13864 | 15229 | if (key >= '0' && key <= '5') |
---|
13865 | 15230 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13906 | 15271 | // break; |
---|
13907 | 15272 | case 'T': |
---|
13908 | 15273 | CACHETEXTURE ^= true; |
---|
13909 | | - textures.clear(); |
---|
| 15274 | + texturepigment.clear(); |
---|
| 15275 | + texturebump.clear(); |
---|
13910 | 15276 | // repaint(); |
---|
13911 | 15277 | break; |
---|
13912 | 15278 | case 'Y': |
---|
.. | .. |
---|
13991 | 15357 | case 'E' : COMPACT ^= true; |
---|
13992 | 15358 | repaint(); |
---|
13993 | 15359 | break; |
---|
13994 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15360 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15361 | + //DEBUGHSB ^= true; |
---|
| 15362 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13995 | 15363 | repaint(); |
---|
13996 | 15364 | break; |
---|
13997 | 15365 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14016 | 15384 | RevertCamera(); |
---|
14017 | 15385 | repaint(); |
---|
14018 | 15386 | break; |
---|
14019 | | - case 'L': |
---|
14020 | 15387 | case 'l': |
---|
| 15388 | + //case 'L': |
---|
14021 | 15389 | if (lightMode) |
---|
14022 | 15390 | { |
---|
14023 | 15391 | lightMode = false; |
---|
.. | .. |
---|
14081 | 15449 | OCCLUSION_CULLING ^= true; |
---|
14082 | 15450 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14083 | 15451 | break; |
---|
14084 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15452 | + //case '0': envyoff ^= true; repaint(); break; |
---|
14085 | 15453 | case '1': |
---|
14086 | 15454 | case '2': |
---|
14087 | 15455 | case '3': |
---|
14088 | 15456 | case '4': |
---|
14089 | 15457 | case '5': |
---|
14090 | | - newenvy = Character.getNumericValue(key); |
---|
14091 | | - repaint(); |
---|
14092 | | - break; |
---|
14093 | 15458 | case '6': |
---|
14094 | 15459 | case '7': |
---|
14095 | 15460 | case '8': |
---|
14096 | 15461 | case '9': |
---|
14097 | | - BGcolor = (key - '6')/3.f; |
---|
| 15462 | + if (true) // envyoff) |
---|
| 15463 | + { |
---|
| 15464 | + BGcolor = (key - '1')/8.f; |
---|
| 15465 | + } |
---|
| 15466 | + else |
---|
| 15467 | + { |
---|
| 15468 | + //newenvy = Character.getNumericValue(key); |
---|
| 15469 | + } |
---|
14098 | 15470 | repaint(); |
---|
14099 | 15471 | break; |
---|
14100 | 15472 | case '!': |
---|
.. | .. |
---|
14160 | 15532 | case '_': |
---|
14161 | 15533 | kompactbit = 5; |
---|
14162 | 15534 | break; |
---|
14163 | | - case '+': |
---|
14164 | | - kompactbit = 6; |
---|
14165 | | - break; |
---|
| 15535 | +// case '+': |
---|
| 15536 | +// kompactbit = 6; |
---|
| 15537 | +// break; |
---|
14166 | 15538 | case ' ': |
---|
14167 | 15539 | lightMode ^= true; |
---|
14168 | 15540 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14174 | 15546 | case ESC: |
---|
14175 | 15547 | RENDERPROGRAM += 1; |
---|
14176 | 15548 | RENDERPROGRAM %= 3; |
---|
| 15549 | + |
---|
14177 | 15550 | repaint(); |
---|
14178 | 15551 | break; |
---|
14179 | 15552 | case 'Z': |
---|
14180 | 15553 | //RESIZETEXTURE ^= true; |
---|
14181 | 15554 | //break; |
---|
14182 | 15555 | case 'z': |
---|
14183 | | - RENDERSHADOW ^= true; |
---|
| 15556 | + Globals.RENDERSHADOW ^= true; |
---|
14184 | 15557 | Globals.lighttouched = true; |
---|
14185 | 15558 | repaint(); |
---|
14186 | 15559 | break; |
---|
.. | .. |
---|
14213 | 15586 | case DELETE: |
---|
14214 | 15587 | ClearSelection(); |
---|
14215 | 15588 | break; |
---|
14216 | | - /* |
---|
14217 | 15589 | case '+': |
---|
| 15590 | + |
---|
| 15591 | + /* |
---|
14218 | 15592 | //fontsize += 1; |
---|
14219 | 15593 | bbzoom *= 2; |
---|
14220 | 15594 | repaint(); |
---|
.. | .. |
---|
14231 | 15605 | case '=': |
---|
14232 | 15606 | IncDepth(); |
---|
14233 | 15607 | //fontsize += 1; |
---|
14234 | | - object.editWindow.refreshContents(true); |
---|
| 15608 | + object.GetWindow().refreshContents(true); |
---|
14235 | 15609 | maskbit = 6; |
---|
14236 | 15610 | break; |
---|
14237 | 15611 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14238 | 15612 | DecDepth(); |
---|
14239 | 15613 | maskbit = 5; |
---|
14240 | 15614 | //if(fontsize > 1) fontsize -= 1; |
---|
14241 | | - if (object.editWindow == null) |
---|
14242 | | - new Exception().printStackTrace(); |
---|
14243 | | - else |
---|
14244 | | - object.editWindow.refreshContents(true); |
---|
| 15615 | +// if (object.editWindow == null) |
---|
| 15616 | +// new Exception().printStackTrace(); |
---|
| 15617 | +// else |
---|
| 15618 | + object.GetWindow().refreshContents(true); |
---|
14245 | 15619 | break; |
---|
14246 | 15620 | case '{': |
---|
14247 | 15621 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14296 | 15670 | } |
---|
14297 | 15671 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14298 | 15672 | } |
---|
| 15673 | + |
---|
14299 | 15674 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14300 | 15675 | |
---|
14301 | 15676 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14303 | 15678 | //mode = ROTATE; |
---|
14304 | 15679 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14305 | 15680 | { |
---|
14306 | | - SetMouseMode(modifiers); |
---|
| 15681 | + SetMouseMode(0, modifiers); |
---|
14307 | 15682 | } |
---|
14308 | 15683 | } |
---|
14309 | 15684 | |
---|
14310 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15685 | + public void processKeyEvent(KeyEvent e) |
---|
14311 | 15686 | { |
---|
14312 | 15687 | switch (e.getID()) |
---|
14313 | 15688 | { |
---|
.. | .. |
---|
14437 | 15812 | |
---|
14438 | 15813 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14439 | 15814 | { |
---|
14440 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14441 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15815 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15816 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15817 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14442 | 15818 | { |
---|
14443 | 15819 | mouseMoved(e); |
---|
14444 | 15820 | } else |
---|
.. | .. |
---|
14463 | 15839 | } |
---|
14464 | 15840 | */ |
---|
14465 | 15841 | |
---|
14466 | | - object.editWindow.EditSelection(); |
---|
| 15842 | + object.GetWindow().EditSelection(false); |
---|
14467 | 15843 | } |
---|
14468 | 15844 | |
---|
14469 | 15845 | void SelectParent() |
---|
14470 | 15846 | { |
---|
| 15847 | + new Exception().printStackTrace(); |
---|
14471 | 15848 | System.exit(0); |
---|
14472 | 15849 | Composite group = (Composite) object; |
---|
14473 | 15850 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14479 | 15856 | { |
---|
14480 | 15857 | //selectees.remove(i); |
---|
14481 | 15858 | System.out.println("select parent of " + elem); |
---|
14482 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15859 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14483 | 15860 | } else |
---|
14484 | 15861 | { |
---|
14485 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15862 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14486 | 15863 | } |
---|
14487 | 15864 | |
---|
14488 | 15865 | first = false; |
---|
.. | .. |
---|
14491 | 15868 | |
---|
14492 | 15869 | void SelectChildren() |
---|
14493 | 15870 | { |
---|
| 15871 | + new Exception().printStackTrace(); |
---|
14494 | 15872 | System.exit(0); |
---|
14495 | 15873 | /* |
---|
14496 | 15874 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14523 | 15901 | for (int j = 0; j < group.children.size(); j++) |
---|
14524 | 15902 | { |
---|
14525 | 15903 | elem = (Object3D) group.children.elementAt(j); |
---|
14526 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15904 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14527 | 15905 | first = false; |
---|
14528 | 15906 | } |
---|
14529 | 15907 | } else |
---|
14530 | 15908 | { |
---|
14531 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15909 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14532 | 15910 | } |
---|
14533 | 15911 | |
---|
14534 | 15912 | first = false; |
---|
.. | .. |
---|
14539 | 15917 | { |
---|
14540 | 15918 | //Composite group = (Composite) object; |
---|
14541 | 15919 | Object3D group = object; |
---|
14542 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15920 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14543 | 15921 | } |
---|
14544 | 15922 | |
---|
14545 | 15923 | void ResetTransform(int mask) |
---|
14546 | 15924 | { |
---|
14547 | 15925 | //Composite group = (Composite) object; |
---|
14548 | 15926 | Object3D group = object; |
---|
14549 | | - group.editWindow.ResetTransform(mask); |
---|
| 15927 | + group.GetWindow().ResetTransform(mask); |
---|
14550 | 15928 | } |
---|
14551 | 15929 | |
---|
14552 | 15930 | void FlipTransform() |
---|
14553 | 15931 | { |
---|
14554 | 15932 | //Composite group = (Composite) object; |
---|
14555 | 15933 | Object3D group = object; |
---|
14556 | | - group.editWindow.FlipTransform(); |
---|
| 15934 | + group.GetWindow().FlipTransform(); |
---|
14557 | 15935 | // group.editWindow.ReduceMesh(true); |
---|
14558 | 15936 | } |
---|
14559 | 15937 | |
---|
.. | .. |
---|
14561 | 15939 | { |
---|
14562 | 15940 | //Composite group = (Composite) object; |
---|
14563 | 15941 | Object3D group = object; |
---|
14564 | | - group.editWindow.PrintMemory(); |
---|
| 15942 | + group.GetWindow().PrintMemory(); |
---|
14565 | 15943 | // group.editWindow.ReduceMesh(true); |
---|
14566 | 15944 | } |
---|
14567 | 15945 | |
---|
.. | .. |
---|
14569 | 15947 | { |
---|
14570 | 15948 | //Composite group = (Composite) object; |
---|
14571 | 15949 | Object3D group = object; |
---|
14572 | | - group.editWindow.ResetCentroid(); |
---|
| 15950 | + group.GetWindow().ResetCentroid(); |
---|
14573 | 15951 | } |
---|
14574 | 15952 | |
---|
14575 | 15953 | void IncDepth() |
---|
.. | .. |
---|
14651 | 16029 | |
---|
14652 | 16030 | int width = getBounds().width; |
---|
14653 | 16031 | int height = getBounds().height; |
---|
14654 | | - ClickInfo info = new ClickInfo(); |
---|
14655 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14656 | 16032 | //Image img = CreateImage(width, height); |
---|
14657 | 16033 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 16034 | + |
---|
14658 | 16035 | Graphics gr = g; // img.getGraphics(); |
---|
| 16036 | + |
---|
14659 | 16037 | if (!hasMarquee) |
---|
14660 | 16038 | { |
---|
14661 | 16039 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14727 | 16105 | } |
---|
14728 | 16106 | if (object != null && !hasMarquee) |
---|
14729 | 16107 | { |
---|
| 16108 | + if (object.clickInfo == null) |
---|
| 16109 | + object.clickInfo = new ClickInfo(); |
---|
| 16110 | + ClickInfo info = object.clickInfo; |
---|
| 16111 | + //ClickInfo info = new ClickInfo(); |
---|
| 16112 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16113 | + |
---|
14730 | 16114 | if (isRenderer) |
---|
14731 | 16115 | { |
---|
14732 | | - info.flags++; |
---|
| 16116 | + object.clickInfo.flags++; |
---|
14733 | 16117 | double frameAspect = (double) width / (double) height; |
---|
14734 | 16118 | if (frameAspect > renderCamera.aspect) |
---|
14735 | 16119 | { |
---|
14736 | 16120 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
14737 | | - info.bounds.width -= width - desired; |
---|
14738 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16121 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16122 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
14739 | 16123 | } else |
---|
14740 | 16124 | { |
---|
14741 | 16125 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
14742 | | - info.bounds.height -= height - desired; |
---|
14743 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16126 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16127 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
14744 | 16128 | } |
---|
14745 | 16129 | } |
---|
14746 | | - info.g = gr; |
---|
14747 | | - info.camera = renderCamera; |
---|
| 16130 | + |
---|
| 16131 | + object.clickInfo.g = gr; |
---|
| 16132 | + object.clickInfo.camera = renderCamera; |
---|
14748 | 16133 | /* |
---|
14749 | 16134 | // Memory intensive (brep.verticescopy) |
---|
14750 | 16135 | if (!(object instanceof Composite)) |
---|
14751 | 16136 | object.draw(info, 0, false); // SLOW : |
---|
14752 | 16137 | */ |
---|
14753 | | - if (!isRenderer) |
---|
| 16138 | + if (!isRenderer) // && drag) |
---|
14754 | 16139 | { |
---|
14755 | | - object.drawEditHandles(info, 0); |
---|
| 16140 | + Grafreed.Assert(object != null); |
---|
| 16141 | + Grafreed.Assert(object.selection != null); |
---|
| 16142 | + if (object.selection.Size() > 0) |
---|
| 16143 | + { |
---|
| 16144 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16145 | + |
---|
| 16146 | + object.clickInfo.DX = 0; |
---|
| 16147 | + object.clickInfo.DY = 0; |
---|
| 16148 | + object.clickInfo.W = 1; |
---|
| 16149 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16150 | + { |
---|
| 16151 | + info.DX = X; |
---|
| 16152 | + if (X != 0) |
---|
| 16153 | + info.DX -= info.bounds.width/2; |
---|
| 16154 | + |
---|
| 16155 | + info.DY = Y; |
---|
| 16156 | + if (Y != 0) |
---|
| 16157 | + info.DY -= info.bounds.height/2; |
---|
| 16158 | + } |
---|
| 16159 | + |
---|
| 16160 | + object.drawEditHandles(//info, |
---|
| 16161 | + 0); |
---|
| 16162 | + |
---|
| 16163 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16164 | + { |
---|
| 16165 | + switch (hitSomething) |
---|
| 16166 | + { |
---|
| 16167 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16168 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16169 | + break; |
---|
| 16170 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16171 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16172 | + break; |
---|
| 16173 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16174 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16175 | + break; |
---|
| 16176 | + } |
---|
| 16177 | + |
---|
| 16178 | + } |
---|
| 16179 | + } |
---|
14756 | 16180 | } |
---|
14757 | 16181 | } |
---|
| 16182 | + |
---|
14758 | 16183 | if (isRenderer) |
---|
14759 | 16184 | { |
---|
14760 | 16185 | //gr.setColor(Color.black); |
---|
14761 | 16186 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14762 | 16187 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14763 | 16188 | } |
---|
| 16189 | + |
---|
14764 | 16190 | if (hasMarquee) |
---|
14765 | 16191 | { |
---|
14766 | 16192 | gr.setXORMode(Color.white); |
---|
14767 | | - gr.setColor(Color.red); |
---|
| 16193 | + gr.setColor(Color.white); |
---|
14768 | 16194 | if (!firstime) |
---|
14769 | 16195 | { |
---|
14770 | 16196 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
14873 | 16299 | public boolean mouseDown(Event evt, int x, int y) |
---|
14874 | 16300 | { |
---|
14875 | 16301 | System.out.println("mouseDown: " + evt); |
---|
| 16302 | + System.exit(0); |
---|
14876 | 16303 | /* |
---|
14877 | 16304 | locked = true; |
---|
14878 | 16305 | drag = false; |
---|
.. | .. |
---|
14916 | 16343 | { |
---|
14917 | 16344 | keyPressed(0, modifiers); |
---|
14918 | 16345 | } |
---|
14919 | | - clickStart(x, y, modifiers); |
---|
| 16346 | + // clickStart(x, y, modifiers); |
---|
14920 | 16347 | return true; |
---|
14921 | 16348 | } |
---|
14922 | 16349 | |
---|
.. | .. |
---|
15034 | 16461 | { |
---|
15035 | 16462 | keyReleased(0, 0); |
---|
15036 | 16463 | } |
---|
15037 | | - drag(x, y, modifiers); |
---|
| 16464 | + drag(x, y, 0, modifiers); |
---|
15038 | 16465 | return true; |
---|
15039 | 16466 | } |
---|
15040 | 16467 | |
---|
.. | .. |
---|
15166 | 16593 | Object3D object; |
---|
15167 | 16594 | static Object3D trackedobject; |
---|
15168 | 16595 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15169 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16596 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15170 | 16597 | /*static*/ Camera eyeCamera; |
---|
15171 | 16598 | /*static*/ Camera lightCamera; |
---|
15172 | 16599 | int cameracount; |
---|
.. | .. |
---|
15230 | 16657 | private /*static*/ boolean firstime; |
---|
15231 | 16658 | private /*static*/ cVector newView = new cVector(); |
---|
15232 | 16659 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16660 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16661 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15233 | 16662 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15234 | 16663 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15235 | 16664 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15242 | 16671 | { |
---|
15243 | 16672 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15244 | 16673 | |
---|
| 16674 | + int usedsuf = 0; |
---|
| 16675 | + |
---|
15245 | 16676 | for (int i = 0; i < suffixes.length; i++) |
---|
15246 | 16677 | { |
---|
15247 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15248 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15249 | | - mipmapped, |
---|
15250 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15251 | | - if (data == null) |
---|
| 16678 | + String[] suffixe = suffixes; |
---|
| 16679 | + String[] fallback = suffixes2; |
---|
| 16680 | + String[] fallfallback = suffixes3; |
---|
| 16681 | + |
---|
| 16682 | + for (int c=usedsuf; --c>=0;) |
---|
15252 | 16683 | { |
---|
15253 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16684 | +// String[] temp = suffixe; |
---|
| 16685 | +// suffixe = fallback; |
---|
| 16686 | +// fallback = fallfallback; |
---|
| 16687 | +// fallfallback = temp; |
---|
15254 | 16688 | } |
---|
| 16689 | + |
---|
| 16690 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16691 | + TextureData data; |
---|
| 16692 | + |
---|
| 16693 | + try |
---|
| 16694 | + { |
---|
| 16695 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16696 | + mipmapped, |
---|
| 16697 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16698 | + } |
---|
| 16699 | + catch (Exception e) |
---|
| 16700 | + { |
---|
| 16701 | + try |
---|
| 16702 | + { |
---|
| 16703 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e2) |
---|
| 16709 | + { |
---|
| 16710 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16711 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16712 | + mipmapped, |
---|
| 16713 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16714 | + } |
---|
| 16715 | + } |
---|
| 16716 | + |
---|
15255 | 16717 | //System.out.println("Target = " + targets[i]); |
---|
15256 | 16718 | cubemap.updateImage(data, targets[i]); |
---|
15257 | 16719 | } |
---|
15258 | 16720 | |
---|
15259 | 16721 | return cubemap; |
---|
15260 | 16722 | } |
---|
| 16723 | + |
---|
15261 | 16724 | int bigsphere = -1; |
---|
15262 | 16725 | |
---|
15263 | 16726 | float BGcolor = 0.5f; |
---|
15264 | 16727 | |
---|
15265 | | - private void DrawSkyBox(GL gl) |
---|
| 16728 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16729 | + |
---|
| 16730 | + private void DrawSkyBox(GL gl, float ratio) |
---|
15266 | 16731 | { |
---|
15267 | | - if (envyoff || cubemap == null) |
---|
| 16732 | + if (//envyoff || |
---|
| 16733 | + WIREFRAME || |
---|
| 16734 | + cubemap == null) |
---|
15268 | 16735 | { |
---|
15269 | 16736 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
15270 | 16737 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
15279 | 16746 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
15280 | 16747 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
15281 | 16748 | gl.glLoadIdentity(); |
---|
| 16749 | + gl.glScalef(1,ratio,1); |
---|
15282 | 16750 | |
---|
| 16751 | +// colorV[0] = 2; |
---|
| 16752 | +// colorV[1] = 2; |
---|
| 16753 | +// colorV[2] = 2; |
---|
| 16754 | +// colorV[3] = 1; |
---|
| 16755 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16756 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16757 | +// |
---|
| 16758 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16759 | + |
---|
15283 | 16760 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
15284 | 16761 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
15285 | 16762 | |
---|
.. | .. |
---|
15311 | 16788 | { |
---|
15312 | 16789 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
15313 | 16790 | } |
---|
| 16791 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
15314 | 16792 | gl.glMultMatrixd(viewrot_1, 0); |
---|
15315 | 16793 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
15316 | 16794 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
15351 | 16829 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
15352 | 16830 | |
---|
15353 | 16831 | cubemap.disable(); |
---|
15354 | | - ////cubemap.unbind(); |
---|
| 16832 | + //cubemap.dispose(); |
---|
| 16833 | + |
---|
15355 | 16834 | if (CULLFACE) |
---|
15356 | 16835 | { |
---|
15357 | 16836 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
15451 | 16930 | cStatic.objectstack[materialdepth++] = checker; |
---|
15452 | 16931 | //System.out.println("material " + material); |
---|
15453 | 16932 | //Applet3D.tracein(this, selected); |
---|
15454 | | - vector2buffer = checker.projectedVertices; |
---|
| 16933 | + //vector2buffer = checker.projectedVertices; |
---|
15455 | 16934 | |
---|
15456 | 16935 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15457 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16936 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15458 | 16937 | |
---|
15459 | 16938 | materialdepth -= 1; |
---|
15460 | 16939 | if (materialdepth > 0) |
---|
15461 | 16940 | { |
---|
15462 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15463 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16941 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16942 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15464 | 16943 | } |
---|
15465 | 16944 | //checker.GetMaterial().opacity = 1f; |
---|
15466 | 16945 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15546 | 17025 | } |
---|
15547 | 17026 | } |
---|
15548 | 17027 | |
---|
| 17028 | + private Object3D GetFolder() |
---|
| 17029 | + { |
---|
| 17030 | + Object3D folder = object.GetWindow().copy; |
---|
| 17031 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17032 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17033 | + return folder; |
---|
| 17034 | + } |
---|
| 17035 | + |
---|
15549 | 17036 | class SelectBuffer implements GLEventListener |
---|
15550 | 17037 | { |
---|
15551 | 17038 | |
---|
.. | .. |
---|
15561 | 17048 | //new Exception().printStackTrace(); |
---|
15562 | 17049 | System.out.println("select buffer init"); |
---|
15563 | 17050 | // Use debug pipeline |
---|
15564 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17051 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
15565 | 17052 | |
---|
15566 | 17053 | GL gl = drawable.getGL(); |
---|
15567 | 17054 | |
---|
.. | .. |
---|
15604 | 17091 | { |
---|
15605 | 17092 | if (!selection) |
---|
15606 | 17093 | { |
---|
| 17094 | + new Exception().printStackTrace(); |
---|
15607 | 17095 | System.exit(0); |
---|
15608 | 17096 | return; |
---|
15609 | 17097 | } |
---|
.. | .. |
---|
15624 | 17112 | |
---|
15625 | 17113 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15626 | 17114 | |
---|
| 17115 | + if (PAINTMODE) |
---|
| 17116 | + { |
---|
| 17117 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17118 | + { |
---|
| 17119 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17120 | + |
---|
| 17121 | + // Make what you paint not selectable. |
---|
| 17122 | + paintobj.ResetSelectable(); |
---|
| 17123 | + } |
---|
| 17124 | + } |
---|
| 17125 | + |
---|
15627 | 17126 | //int tmp = selection_view; |
---|
15628 | 17127 | //selection_view = -1; |
---|
15629 | 17128 | int temp = DrawMode(); |
---|
.. | .. |
---|
15635 | 17134 | // temp = DEFAULT; // patch for selection debug |
---|
15636 | 17135 | Globals.drawMode = temp; // WARNING |
---|
15637 | 17136 | |
---|
| 17137 | + if (PAINTMODE) |
---|
| 17138 | + { |
---|
| 17139 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17140 | + { |
---|
| 17141 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17142 | + |
---|
| 17143 | + // Revert. |
---|
| 17144 | + paintobj.RestoreSelectable(); |
---|
| 17145 | + } |
---|
| 17146 | + } |
---|
| 17147 | + |
---|
15638 | 17148 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15639 | 17149 | |
---|
15640 | 17150 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15682 | 17192 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15683 | 17193 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15684 | 17194 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17195 | + |
---|
| 17196 | + CreateSelectedPoint(); |
---|
15685 | 17197 | |
---|
15686 | 17198 | // Will fit the mesh !!! |
---|
15687 | 17199 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15731 | 17243 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
15732 | 17244 | } |
---|
15733 | 17245 | |
---|
15734 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17246 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15735 | 17247 | } |
---|
15736 | 17248 | } |
---|
15737 | 17249 | |
---|
15738 | 17250 | if (!movingcamera && !PAINTMODE) |
---|
15739 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17251 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15740 | 17252 | |
---|
15741 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17253 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15742 | 17254 | { |
---|
15743 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17255 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15744 | 17256 | |
---|
15745 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17257 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17258 | + { |
---|
| 17259 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15746 | 17260 | |
---|
15747 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
15748 | | - |
---|
15749 | | - group.add(paintobj); // link |
---|
15750 | | - |
---|
15751 | | - object.editWindow.SnapObject(group); |
---|
15752 | | - |
---|
15753 | | - Object3D folder = object.editWindow.copy; |
---|
15754 | | - |
---|
15755 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
15756 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
15757 | | - |
---|
15758 | | - folder.add(group); |
---|
15759 | | - |
---|
15760 | | - object.editWindow.ResetModel(); |
---|
15761 | | - object.editWindow.refreshContents(); |
---|
| 17261 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17262 | + |
---|
| 17263 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17264 | + |
---|
| 17265 | + inst.add(paintobj); // link |
---|
| 17266 | + |
---|
| 17267 | + object.GetWindow().SnapObject(inst); |
---|
| 17268 | + |
---|
| 17269 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17270 | + |
---|
| 17271 | + folder.add(inst); |
---|
| 17272 | + |
---|
| 17273 | + object.GetWindow().ResetModel(); |
---|
| 17274 | + object.GetWindow().refreshContents(); |
---|
| 17275 | + } |
---|
15762 | 17276 | } |
---|
15763 | 17277 | else |
---|
15764 | 17278 | paintcount = 0; |
---|
.. | .. |
---|
15797 | 17311 | //System.out.println("objects[color] = " + objects[color]); |
---|
15798 | 17312 | //objects[color].Select(); |
---|
15799 | 17313 | indexcount = 0; |
---|
| 17314 | + ObjEditor window = object.GetWindow(); |
---|
| 17315 | + if (window != null && deselect) |
---|
| 17316 | + { |
---|
| 17317 | + window.Select(null, deselect, true); |
---|
| 17318 | + } |
---|
15800 | 17319 | object.Select(color, deselect); |
---|
15801 | 17320 | } |
---|
15802 | 17321 | |
---|
.. | .. |
---|
15847 | 17366 | |
---|
15848 | 17367 | public void init(GLAutoDrawable drawable) |
---|
15849 | 17368 | { |
---|
| 17369 | + if (Globals.DEBUG) |
---|
15850 | 17370 | System.out.println("shadow buffer init"); |
---|
15851 | 17371 | |
---|
15852 | 17372 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
15896 | 17416 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15897 | 17417 | } |
---|
15898 | 17418 | |
---|
15899 | | - if (!RENDERSHADOW) |
---|
| 17419 | + if (!Globals.RENDERSHADOW) |
---|
15900 | 17420 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15901 | 17421 | |
---|
15902 | 17422 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15906 | 17426 | //gl.glColorMask(false, false, false, false); |
---|
15907 | 17427 | |
---|
15908 | 17428 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15909 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17429 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15910 | 17430 | { |
---|
15911 | 17431 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15912 | 17432 | |
---|
.. | .. |
---|
15966 | 17486 | |
---|
15967 | 17487 | class AntialiasBuffer implements GLEventListener |
---|
15968 | 17488 | { |
---|
15969 | | - |
---|
15970 | 17489 | CameraPane parent = null; |
---|
15971 | 17490 | |
---|
15972 | 17491 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16076 | 17595 | gl.glFlush(); |
---|
16077 | 17596 | |
---|
16078 | 17597 | /**/ |
---|
16079 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17598 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
16080 | 17599 | |
---|
16081 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17600 | + float[] depths = occlusiondepthbuffer.array(); |
---|
16082 | 17601 | |
---|
| 17602 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17603 | + |
---|
| 17604 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17605 | + |
---|
16083 | 17606 | double r = 0, g = 0, b = 0; |
---|
16084 | 17607 | |
---|
16085 | 17608 | double count = 0; |
---|
.. | .. |
---|
16090 | 17613 | |
---|
16091 | 17614 | double FACTOR = 1; |
---|
16092 | 17615 | |
---|
16093 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17616 | + for (int i = 0; i < depths.length; i++) |
---|
16094 | 17617 | { |
---|
16095 | 17618 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
16096 | 17619 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
16173 | 17696 | |
---|
16174 | 17697 | double scale = ray.z; // 1; // cos |
---|
16175 | 17698 | |
---|
16176 | | - float depth = pixels[newindex]; |
---|
| 17699 | + float depth = depths[newindex]; |
---|
16177 | 17700 | |
---|
16178 | 17701 | /* |
---|
16179 | 17702 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
16323 | 17846 | int AAbuffersize = 0; |
---|
16324 | 17847 | |
---|
16325 | 17848 | //double[] selectedpoint = new double[3]; |
---|
16326 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17849 | + static Superellipsoid selectedpoint; |
---|
16327 | 17850 | static Sphere previousselectedpoint = null; |
---|
16328 | | - static Sphere debugpointG = new Sphere(); |
---|
16329 | | - static Sphere debugpointP = new Sphere(); |
---|
16330 | | - static Sphere debugpointC = new Sphere(); |
---|
16331 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17851 | + static Sphere debugpointG; |
---|
| 17852 | + static Sphere debugpointP; |
---|
| 17853 | + static Sphere debugpointC; |
---|
| 17854 | + static Sphere debugpointR; |
---|
16332 | 17855 | |
---|
16333 | 17856 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16334 | 17857 | |
---|
16335 | | - static |
---|
16336 | | - { |
---|
16337 | | - for (int i=0; i<8; i++) |
---|
16338 | | - { |
---|
16339 | | - debugpoints[i] = new Sphere(); |
---|
16340 | | - } |
---|
16341 | | - } |
---|
16342 | | - |
---|
16343 | 17858 | static void InitPoints(float radius) |
---|
16344 | 17859 | { |
---|
16345 | 17860 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16359 | 17874 | } |
---|
16360 | 17875 | } |
---|
16361 | 17876 | |
---|
16362 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17877 | + static void DrawPoints(iCameraPane cpane) |
---|
16363 | 17878 | { |
---|
16364 | 17879 | for (int i=0; i<8; i++) // first and last are red |
---|
16365 | 17880 | { |
---|
.. | .. |
---|
16378 | 17893 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
16379 | 17894 | static IntBuffer bigAAbuffer; |
---|
16380 | 17895 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
16381 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17896 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
16382 | 17897 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
16383 | 17898 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
16384 | 17899 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
16385 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17900 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17901 | + |
---|
| 17902 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17903 | + |
---|
16386 | 17904 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
16387 | 17905 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
16388 | 17906 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
16391 | 17909 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16392 | 17910 | // Depth buffer format |
---|
16393 | 17911 | //private int depth_format; |
---|
16394 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17912 | + |
---|
| 17913 | + public void NextIndex() |
---|
16395 | 17914 | { |
---|
16396 | 17915 | indexcount+=16; |
---|
16397 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17916 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16398 | 17917 | //objects[indexcount] = o; |
---|
16399 | 17918 | //System.out.println("indexcount = " + indexcount); |
---|
16400 | 17919 | } |
---|