.. | .. |
---|
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 | |
---|
.. | .. |
---|
128 | 168 | |
---|
129 | 169 | |
---|
130 | 170 | // OPTIONS |
---|
131 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
132 | 172 | boolean cameraLight = false; |
---|
133 | 173 | boolean UVdebug = false; |
---|
134 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
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 | |
---|
.. | .. |
---|
191 | 246 | } |
---|
192 | 247 | |
---|
193 | 248 | /// INTERFACE |
---|
| 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 | + |
---|
| 279 | + public boolean IsBoxMode() |
---|
| 280 | + { |
---|
| 281 | + return BOXMODE; |
---|
| 282 | + } |
---|
| 283 | + |
---|
| 284 | + public boolean IsZoomBoxMode() |
---|
| 285 | + { |
---|
| 286 | + return ZOOMBOXMODE; |
---|
| 287 | + } |
---|
194 | 288 | |
---|
195 | 289 | public void ClearDepth() |
---|
196 | 290 | { |
---|
.. | .. |
---|
231 | 325 | return this.ambientOcclusion; |
---|
232 | 326 | } |
---|
233 | 327 | |
---|
| 328 | + public boolean IsDebugSelection() |
---|
| 329 | + { |
---|
| 330 | + return DEBUG_SELECTION; |
---|
| 331 | + } |
---|
| 332 | + |
---|
234 | 333 | public boolean IsFrozen() |
---|
235 | 334 | { |
---|
236 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 335 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
237 | 336 | |
---|
238 | 337 | return !selectmode && cameracount == 0; // != 0; |
---|
239 | 338 | } |
---|
.. | .. |
---|
254 | 353 | return lightCamera; |
---|
255 | 354 | } |
---|
256 | 355 | |
---|
| 356 | + public Camera ManipCamera() |
---|
| 357 | + { |
---|
| 358 | + return manipCamera; |
---|
| 359 | + } |
---|
| 360 | + |
---|
257 | 361 | public Camera RenderCamera() |
---|
258 | 362 | { |
---|
259 | 363 | return renderCamera; |
---|
| 364 | + } |
---|
| 365 | + |
---|
| 366 | + public Camera[] Cameras() |
---|
| 367 | + { |
---|
| 368 | + return cameras; |
---|
260 | 369 | } |
---|
261 | 370 | |
---|
262 | 371 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
272 | 381 | cStatic.objectstack[materialdepth++] = obj; |
---|
273 | 382 | //System.out.println("material " + material); |
---|
274 | 383 | //Applet3D.tracein(this, selected); |
---|
275 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 384 | + //display.vector2buffer = obj.projectedVertices; |
---|
276 | 385 | if (obj instanceof Camera) |
---|
277 | 386 | { |
---|
278 | 387 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
281 | 390 | display.options1[2] = material.shadowbias; |
---|
282 | 391 | display.options1[3] = material.aniso; |
---|
283 | 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]); |
---|
284 | 398 | display.options2[0] = material.opacity; |
---|
285 | 399 | display.options2[1] = material.diffuse; |
---|
286 | 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]); |
---|
287 | 404 | |
---|
288 | 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]); |
---|
289 | 409 | display.options4[0] = material.cameralight/0.2f; |
---|
290 | 410 | display.options4[1] = material.subsurface; |
---|
291 | 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]); |
---|
292 | 415 | |
---|
293 | 416 | // if (display.CURRENTANTIALIAS > 0) |
---|
294 | 417 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
304 | 427 | /**/ |
---|
305 | 428 | } else |
---|
306 | 429 | { |
---|
307 | | - DrawMaterial(material, selected); |
---|
| 430 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
308 | 431 | } |
---|
309 | 432 | } else |
---|
310 | 433 | { |
---|
.. | .. |
---|
328 | 451 | cStatic.objectstack[materialdepth++] = obj; |
---|
329 | 452 | //System.out.println("material " + material); |
---|
330 | 453 | //Applet3D.tracein("selected ", selected); |
---|
331 | | - display.vector2buffer = obj.projectedVertices; |
---|
332 | | - display.DrawMaterial(material, selected); |
---|
| 454 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 455 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
333 | 456 | } |
---|
334 | 457 | } |
---|
335 | 458 | |
---|
.. | .. |
---|
346 | 469 | materialdepth -= 1; |
---|
347 | 470 | if (materialdepth > 0) |
---|
348 | 471 | { |
---|
349 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
350 | | - 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); |
---|
351 | 474 | } |
---|
352 | 475 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
353 | 476 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
367 | 490 | materialdepth -= 1; |
---|
368 | 491 | if (materialdepth > 0) |
---|
369 | 492 | { |
---|
370 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
371 | | - 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); |
---|
372 | 495 | } |
---|
373 | 496 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
374 | 497 | //else |
---|
.. | .. |
---|
403 | 526 | |
---|
404 | 527 | javax.media.opengl.GL gl = display.GetGL(); |
---|
405 | 528 | |
---|
406 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 529 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
407 | 530 | |
---|
408 | 531 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
409 | 532 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
410 | 533 | { |
---|
411 | 534 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
412 | | - 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 | + ; |
---|
413 | 538 | if (!hasnorm) |
---|
414 | 539 | { |
---|
415 | | - // System.out.println("FUCK!!"); |
---|
| 540 | + // System.out.println("Mesh normal"); |
---|
416 | 541 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
417 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
418 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
566 | 691 | } |
---|
567 | 692 | } |
---|
568 | 693 | |
---|
| 694 | + /** |
---|
| 695 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 696 | + * it's normals, colors, textures and vertices. |
---|
| 697 | + * |
---|
| 698 | + * @see Renderer#draw(TriMesh) |
---|
| 699 | + * @param tris |
---|
| 700 | + * the mesh to render. |
---|
| 701 | + */ |
---|
| 702 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 703 | + { |
---|
| 704 | + CameraPane display = this; |
---|
| 705 | + |
---|
| 706 | + float r = display.modelParams0[0]; |
---|
| 707 | + float g = display.modelParams0[1]; |
---|
| 708 | + float b = display.modelParams0[2]; |
---|
| 709 | + float opacity = display.modelParams5[1]; |
---|
| 710 | + |
---|
| 711 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 712 | + GL gl = display.GetGL(); // getGL(); |
---|
| 713 | + |
---|
| 714 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 715 | + |
---|
| 716 | + int v = vertBuf.capacity(); |
---|
| 717 | + |
---|
| 718 | + int count = 0; |
---|
| 719 | + |
---|
| 720 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 721 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 722 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 723 | + for (int i=0; i<v/3; i++) |
---|
| 724 | + { |
---|
| 725 | + int index3 = i*3; |
---|
| 726 | + |
---|
| 727 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 728 | + continue; |
---|
| 729 | + |
---|
| 730 | + count++; |
---|
| 731 | + |
---|
| 732 | + int index4 = i*4; |
---|
| 733 | + |
---|
| 734 | + float tx = vertBuf.get(index3); |
---|
| 735 | + float ty = vertBuf.get(index3+1); |
---|
| 736 | + float tz = vertBuf.get(index3+2); |
---|
| 737 | + |
---|
| 738 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 739 | + // continue; |
---|
| 740 | + |
---|
| 741 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 742 | + gl.glPushMatrix(); |
---|
| 743 | + |
---|
| 744 | + float[] texmat = geo.texmat; |
---|
| 745 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 746 | + |
---|
| 747 | + gl.glMultMatrixf(texmat, 0); |
---|
| 748 | + |
---|
| 749 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 750 | + gl.glPushMatrix(); |
---|
| 751 | + |
---|
| 752 | + gl.glTranslatef(tx,ty,tz); |
---|
| 753 | + |
---|
| 754 | + if (rotate) |
---|
| 755 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 756 | + |
---|
| 757 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 758 | + gl.glScalef(size,size,size); |
---|
| 759 | + |
---|
| 760 | + float cr = geo.colorBuf.get(index4); |
---|
| 761 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 762 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 763 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 764 | + |
---|
| 765 | + display.modelParams0[0] = r * cr; |
---|
| 766 | + display.modelParams0[1] = g * cg; |
---|
| 767 | + display.modelParams0[2] = b * cb; |
---|
| 768 | + |
---|
| 769 | + display.modelParams5[1] = opacity * ca; |
---|
| 770 | + |
---|
| 771 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 772 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 773 | + |
---|
| 774 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 775 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 776 | + |
---|
| 777 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 778 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 779 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 780 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 781 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 782 | + gl.glPopMatrix(); |
---|
| 783 | + |
---|
| 784 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 785 | + gl.glPopMatrix(); |
---|
| 786 | + } |
---|
| 787 | + // gl.glScalef(1024,1024,1024); |
---|
| 788 | + if (!cf) |
---|
| 789 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 790 | + |
---|
| 791 | + display.modelParams0[0] = r; |
---|
| 792 | + display.modelParams0[1] = g; |
---|
| 793 | + display.modelParams0[2] = b; |
---|
| 794 | + |
---|
| 795 | + display.modelParams5[1] = opacity; |
---|
| 796 | + |
---|
| 797 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 798 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 799 | + |
---|
| 800 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 801 | + |
---|
| 802 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 803 | + if (true) |
---|
| 804 | + return; |
---|
| 805 | + |
---|
| 806 | +//// if (!tris.predraw(this)) |
---|
| 807 | +//// { |
---|
| 808 | +//// return; |
---|
| 809 | +//// } |
---|
| 810 | +//// if (Debug.stats) |
---|
| 811 | +//// { |
---|
| 812 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 813 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 814 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 815 | +//// } |
---|
| 816 | +//// |
---|
| 817 | +//// if (tris.getDisplayListID() != -1) |
---|
| 818 | +//// { |
---|
| 819 | +//// renderDisplayList(tris); |
---|
| 820 | +//// return; |
---|
| 821 | +//// } |
---|
| 822 | +//// |
---|
| 823 | +//// if (!generatingDisplayList) |
---|
| 824 | +//// { |
---|
| 825 | +//// applyStates(tris.states, tris); |
---|
| 826 | +//// } |
---|
| 827 | +//// if (Debug.stats) |
---|
| 828 | +//// { |
---|
| 829 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 830 | +//// } |
---|
| 831 | +//// boolean transformed = doTransforms(tris); |
---|
| 832 | +// |
---|
| 833 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 834 | +// switch (getMode()) |
---|
| 835 | +// { |
---|
| 836 | +// case Triangles: |
---|
| 837 | +// glMode = GL.GL_TRIANGLES; |
---|
| 838 | +// break; |
---|
| 839 | +// case Strip: |
---|
| 840 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 841 | +// break; |
---|
| 842 | +// case Fan: |
---|
| 843 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 844 | +// break; |
---|
| 845 | +// } |
---|
| 846 | +// |
---|
| 847 | +// if (!predrawGeometry(gl)) |
---|
| 848 | +// { |
---|
| 849 | +// // make sure only the necessary indices are sent through on old |
---|
| 850 | +// // cards. |
---|
| 851 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 852 | +// if (indices == null) |
---|
| 853 | +// { |
---|
| 854 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 855 | +// } else |
---|
| 856 | +// { |
---|
| 857 | +// indices.rewind(); |
---|
| 858 | +// indices.limit(this.getMaxIndex()); |
---|
| 859 | +// |
---|
| 860 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 861 | +// |
---|
| 862 | +// indices.clear(); |
---|
| 863 | +// } |
---|
| 864 | +// } else |
---|
| 865 | +// { |
---|
| 866 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 867 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 868 | +// } |
---|
| 869 | +// |
---|
| 870 | +//// postdrawGeometry(tris); |
---|
| 871 | +//// if (transformed) |
---|
| 872 | +//// { |
---|
| 873 | +//// undoTransforms(tris); |
---|
| 874 | +//// } |
---|
| 875 | +//// |
---|
| 876 | +//// if (Debug.stats) |
---|
| 877 | +//// { |
---|
| 878 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 879 | +//// } |
---|
| 880 | +//// tris.postdraw(this); |
---|
| 881 | + } |
---|
| 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 | + |
---|
569 | 1476 | /// INTERFACE |
---|
570 | 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 | + |
---|
571 | 1507 | void SetColor(Object3D obj, Vertex p0) |
---|
572 | 1508 | { |
---|
573 | 1509 | CameraPane display = this; |
---|
.. | .. |
---|
635 | 1571 | { |
---|
636 | 1572 | return; |
---|
637 | 1573 | } |
---|
638 | | - |
---|
639 | | - float[] colorV = new float[3]; |
---|
640 | 1574 | |
---|
641 | 1575 | if (false) // marked) |
---|
642 | 1576 | { |
---|
.. | .. |
---|
745 | 1679 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
746 | 1680 | } |
---|
747 | 1681 | |
---|
748 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1682 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
749 | 1683 | { |
---|
750 | 1684 | CameraPane display = this; |
---|
751 | 1685 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
761 | 1695 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
762 | 1696 | if (!material.multiply) |
---|
763 | 1697 | { |
---|
764 | | - display.color = color; |
---|
| 1698 | + display.color = material.color; |
---|
765 | 1699 | display.saturation = material.modulation; |
---|
766 | 1700 | } |
---|
767 | 1701 | else |
---|
768 | 1702 | { |
---|
769 | | - display.color *= color*2; |
---|
| 1703 | + display.color *= material.color*2; |
---|
770 | 1704 | display.saturation *= material.modulation*2; |
---|
771 | 1705 | } |
---|
772 | 1706 | |
---|
773 | 1707 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
774 | 1708 | |
---|
775 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1709 | + float[] colorV = Grafreed.colorV; |
---|
776 | 1710 | |
---|
777 | 1711 | /**/ |
---|
778 | 1712 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
780 | 1714 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
781 | 1715 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
782 | 1716 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
783 | | - colorV[3] = material.opacity; |
---|
| 1717 | + colorV[3] = 1; // material.opacity; |
---|
784 | 1718 | |
---|
785 | 1719 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
786 | 1720 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
888 | 1822 | display.modelParams7[2] = 0; |
---|
889 | 1823 | display.modelParams7[3] = 0; |
---|
890 | 1824 | |
---|
891 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1825 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
892 | 1826 | |
---|
893 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1827 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
894 | 1828 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
895 | 1829 | { |
---|
896 | 1830 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1032 | 1966 | void PushMatrix(double[][] matrix) |
---|
1033 | 1967 | { |
---|
1034 | 1968 | // GrafreeD.tracein(matrix); |
---|
1035 | | - PushMatrix(matrix,1); |
---|
| 1969 | + PushMatrix(matrix, 1); |
---|
1036 | 1970 | } |
---|
1037 | 1971 | |
---|
1038 | 1972 | void PushMatrix() |
---|
.. | .. |
---|
1129 | 2063 | |
---|
1130 | 2064 | static int camerachangeframe; |
---|
1131 | 2065 | |
---|
1132 | | - boolean SetCamera(Camera cam) |
---|
| 2066 | + public boolean SetCamera(Camera cam) |
---|
1133 | 2067 | { |
---|
1134 | 2068 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1135 | 2069 | // return false; |
---|
.. | .. |
---|
1186 | 2120 | //System.err.println("Oeil on"); |
---|
1187 | 2121 | OEIL = true; |
---|
1188 | 2122 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
1189 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2123 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
1190 | 2124 | //pingthread.StepToTarget(true); |
---|
1191 | 2125 | } |
---|
1192 | 2126 | |
---|
.. | .. |
---|
1257 | 2191 | mainDL ^= true; |
---|
1258 | 2192 | } |
---|
1259 | 2193 | |
---|
1260 | | - void ToggleTexture() |
---|
1261 | | - { |
---|
1262 | | - textureon ^= true; |
---|
1263 | | - } |
---|
1264 | | - |
---|
1265 | | - void ToggleLive() |
---|
1266 | | - { |
---|
1267 | | - Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
1268 | | - |
---|
1269 | | - System.err.println("LIVE = " + Globals.isLIVE()); |
---|
1270 | | - |
---|
1271 | | - if (!Globals.isLIVE()) // save sound |
---|
1272 | | - GrafreeD.savesound = true; // wav.save(); |
---|
1273 | | - // else |
---|
1274 | | - repaint(); // start loop // may 2013 |
---|
1275 | | - } |
---|
1276 | | - |
---|
1277 | | - void ToggleSupport() |
---|
1278 | | - { |
---|
1279 | | - SUPPORT ^= true; |
---|
1280 | | - } |
---|
1281 | | - |
---|
1282 | | - void ToggleAbort() |
---|
1283 | | - { |
---|
1284 | | - ABORTMODE ^= true; |
---|
1285 | | - } |
---|
1286 | | - |
---|
1287 | 2194 | void ToggleFullScreen() |
---|
1288 | 2195 | { |
---|
1289 | 2196 | FULLSCREEN ^= true; |
---|
.. | .. |
---|
1294 | 2201 | Globals.CROWD ^= true; |
---|
1295 | 2202 | } |
---|
1296 | 2203 | |
---|
1297 | | - void ToggleInertia() |
---|
1298 | | - { |
---|
1299 | | - INERTIA ^= true; |
---|
1300 | | - } |
---|
1301 | | - |
---|
1302 | 2204 | void ToggleLocal() |
---|
1303 | 2205 | { |
---|
1304 | 2206 | LOCALTRANSFORM ^= true; |
---|
1305 | 2207 | } |
---|
1306 | 2208 | |
---|
1307 | | - 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() |
---|
1308 | 2242 | { |
---|
1309 | 2243 | FAST ^= true; |
---|
1310 | 2244 | } |
---|
1311 | 2245 | |
---|
1312 | | - void ToggleSlowPose() |
---|
| 2246 | + public void ToggleSlowPose() |
---|
1313 | 2247 | { |
---|
1314 | 2248 | SLOWPOSE ^= true; |
---|
1315 | 2249 | } |
---|
1316 | 2250 | |
---|
1317 | | - void ToggleFootContact() |
---|
1318 | | - { |
---|
1319 | | - FOOTCONTACT ^= true; |
---|
1320 | | - } |
---|
1321 | | - |
---|
1322 | | - void ToggleBoxMode() |
---|
| 2251 | + public void ToggleBoxMode() |
---|
1323 | 2252 | { |
---|
1324 | 2253 | BOXMODE ^= true; |
---|
1325 | 2254 | } |
---|
1326 | 2255 | |
---|
1327 | | - void ToggleSmoothFocus() |
---|
| 2256 | + public void ToggleZoomBoxMode() |
---|
| 2257 | + { |
---|
| 2258 | + ZOOMBOXMODE ^= true; |
---|
| 2259 | + } |
---|
| 2260 | + |
---|
| 2261 | + public void ToggleSmoothFocus() |
---|
1328 | 2262 | { |
---|
1329 | 2263 | SMOOTHFOCUS ^= true; |
---|
1330 | 2264 | } |
---|
1331 | 2265 | |
---|
1332 | | - void ToggleImageFlip() |
---|
| 2266 | + public void ToggleImageFlip() |
---|
1333 | 2267 | { |
---|
1334 | 2268 | IMAGEFLIP ^= true; |
---|
1335 | 2269 | } |
---|
1336 | 2270 | |
---|
1337 | | - void ToggleSpeakerMocap() |
---|
| 2271 | + public void ToggleSpeakerMocap() |
---|
1338 | 2272 | { |
---|
1339 | 2273 | SPEAKERMOCAP ^= true; |
---|
1340 | 2274 | } |
---|
1341 | 2275 | |
---|
1342 | | - void ToggleSpeakerCamera() |
---|
| 2276 | + public void ToggleSpeakerCamera() |
---|
1343 | 2277 | { |
---|
1344 | 2278 | SPEAKERCAMERA ^= true; |
---|
1345 | 2279 | } |
---|
1346 | 2280 | |
---|
1347 | | - void ToggleSpeakerFocus() |
---|
| 2281 | + public void ToggleSpeakerFocus() |
---|
1348 | 2282 | { |
---|
1349 | 2283 | SPEAKERFOCUS ^= true; |
---|
1350 | 2284 | } |
---|
1351 | 2285 | |
---|
1352 | | - void ToggleDebug() |
---|
1353 | | - { |
---|
1354 | | - DEBUG ^= true; |
---|
1355 | | - } |
---|
1356 | | - |
---|
1357 | | - void ToggleFrustum() |
---|
| 2286 | + public void ToggleFrustum() |
---|
1358 | 2287 | { |
---|
1359 | 2288 | FRUSTUM ^= true; |
---|
1360 | 2289 | } |
---|
1361 | 2290 | |
---|
1362 | | - void ToggleTrack() |
---|
| 2291 | + public void ToggleTrack() |
---|
1363 | 2292 | { |
---|
1364 | 2293 | TRACK ^= true; |
---|
1365 | 2294 | if (TRACK) |
---|
.. | .. |
---|
1378 | 2307 | repaint(); |
---|
1379 | 2308 | } |
---|
1380 | 2309 | |
---|
1381 | | - void ToggleTrackOnce() |
---|
| 2310 | + public void ToggleTrackOnce() |
---|
1382 | 2311 | { |
---|
1383 | 2312 | TRACKONCE ^= true; |
---|
1384 | 2313 | } |
---|
1385 | 2314 | |
---|
1386 | | - void ToggleShadowTrack() |
---|
| 2315 | + public void ToggleShadowTrack() |
---|
1387 | 2316 | { |
---|
1388 | 2317 | SHADOWTRACK ^= true; |
---|
1389 | 2318 | repaint(); |
---|
1390 | 2319 | } |
---|
1391 | 2320 | |
---|
1392 | | - void ToggleOeil() |
---|
| 2321 | + public void ToggleOeil() |
---|
1393 | 2322 | { |
---|
1394 | 2323 | OEIL ^= true; |
---|
1395 | 2324 | } |
---|
1396 | 2325 | |
---|
1397 | | - void ToggleOeilOnce() |
---|
| 2326 | + public void ToggleOeilOnce() |
---|
1398 | 2327 | { |
---|
1399 | 2328 | OEILONCE ^= true; |
---|
| 2329 | + } |
---|
| 2330 | + |
---|
| 2331 | + void ToggleFootContact() |
---|
| 2332 | + { |
---|
| 2333 | + FOOTCONTACT ^= true; |
---|
| 2334 | + } |
---|
| 2335 | + |
---|
| 2336 | + void ToggleDebug() |
---|
| 2337 | + { |
---|
| 2338 | + Globals.DEBUG ^= true; |
---|
1400 | 2339 | } |
---|
1401 | 2340 | |
---|
1402 | 2341 | void ToggleLookAt() |
---|
.. | .. |
---|
1404 | 2343 | LOOKAT ^= true; |
---|
1405 | 2344 | } |
---|
1406 | 2345 | |
---|
1407 | | - void ToggleRandom() |
---|
| 2346 | + void ToggleSwitch() |
---|
1408 | 2347 | { |
---|
1409 | | - RANDOM ^= true; |
---|
| 2348 | + SWITCH ^= true; |
---|
1410 | 2349 | } |
---|
1411 | 2350 | |
---|
1412 | 2351 | void ToggleHandles() |
---|
.. | .. |
---|
1414 | 2353 | HANDLES ^= true; |
---|
1415 | 2354 | } |
---|
1416 | 2355 | |
---|
| 2356 | + Object3D paintFolder; |
---|
| 2357 | + |
---|
1417 | 2358 | void TogglePaint() |
---|
1418 | 2359 | { |
---|
1419 | 2360 | PAINTMODE ^= true; |
---|
1420 | 2361 | paintcount = 0; |
---|
| 2362 | + |
---|
| 2363 | + if (PAINTMODE) |
---|
| 2364 | + { |
---|
| 2365 | + paintFolder = GetFolder(); |
---|
| 2366 | + } |
---|
1421 | 2367 | } |
---|
1422 | 2368 | |
---|
1423 | 2369 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
1513 | 2459 | { |
---|
1514 | 2460 | return currentGL; |
---|
1515 | 2461 | } |
---|
1516 | | - |
---|
| 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 | + |
---|
1517 | 2478 | /**/ |
---|
1518 | 2479 | class CacheTexture |
---|
1519 | 2480 | { |
---|
.. | .. |
---|
1522 | 2483 | |
---|
1523 | 2484 | int resolution; |
---|
1524 | 2485 | |
---|
1525 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2486 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
1526 | 2487 | { |
---|
1527 | | - texture = tex; |
---|
| 2488 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2489 | + texturedata = texdata; |
---|
1528 | 2490 | resolution = res; |
---|
1529 | 2491 | } |
---|
1530 | 2492 | } |
---|
1531 | 2493 | /**/ |
---|
1532 | 2494 | |
---|
1533 | 2495 | // TEXTURE static Texture texture; |
---|
1534 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
1535 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
1536 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 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 | + |
---|
1537 | 2501 | int pigmentdepth = 0; |
---|
1538 | 2502 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1539 | 2503 | int bumpdepth = 0; |
---|
1540 | 2504 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
1541 | 2505 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
1542 | 2506 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
1543 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2507 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
1544 | 2508 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
1545 | 2509 | |
---|
1546 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2510 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
1547 | 2511 | { |
---|
1548 | 2512 | TextureData texturedata = null; |
---|
1549 | 2513 | |
---|
.. | .. |
---|
1553 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
1554 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
1555 | 2519 | true, |
---|
1556 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
1557 | 2521 | } catch (java.io.IOException e) |
---|
1558 | 2522 | { |
---|
1559 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
1562 | 2526 | if (bump) |
---|
1563 | 2527 | texturedata = ConvertBump(texturedata, false); |
---|
1564 | 2528 | |
---|
1565 | | - com.sun.opengl.util.texture.Texture texture = |
---|
1566 | | - 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); |
---|
1567 | 2531 | |
---|
1568 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
1569 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 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); |
---|
1570 | 2534 | |
---|
1571 | | - 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; |
---|
1572 | 2557 | } |
---|
1573 | 2558 | |
---|
1574 | 2559 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
2641 | 3626 | |
---|
2642 | 3627 | System.out.println("LOADING TEXTURE : " + name); |
---|
2643 | 3628 | |
---|
| 3629 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3630 | + |
---|
2644 | 3631 | // |
---|
2645 | 3632 | if (false) // compressbit > 0) |
---|
2646 | 3633 | { |
---|
.. | .. |
---|
3345 | 4332 | |
---|
3346 | 4333 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3347 | 4334 | { |
---|
| 4335 | + new Exception().printStackTrace(); |
---|
3348 | 4336 | System.exit(0); |
---|
3349 | 4337 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3350 | 4338 | |
---|
.. | .. |
---|
7038 | 8026 | String pigment = Object3D.GetPigment(tex); |
---|
7039 | 8027 | String bump = Object3D.GetBump(tex); |
---|
7040 | 8028 | |
---|
7041 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8029 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7042 | 8030 | { |
---|
7043 | 8031 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7044 | 8032 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7053 | 8041 | pigment = null; |
---|
7054 | 8042 | } |
---|
7055 | 8043 | |
---|
7056 | | - ReleaseTexture(bump, true); |
---|
7057 | | - ReleaseTexture(pigment, false); |
---|
| 8044 | + ReleaseTexture(tex, true); |
---|
| 8045 | + ReleaseTexture(tex, false); |
---|
7058 | 8046 | } |
---|
7059 | 8047 | |
---|
7060 | | - 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) |
---|
7061 | 8107 | { |
---|
7062 | 8108 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7063 | 8109 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7068 | 8114 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7069 | 8115 | |
---|
7070 | 8116 | if (tex != null) |
---|
7071 | | - texture = textures.get(tex); |
---|
| 8117 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7072 | 8118 | |
---|
7073 | 8119 | // //assert( texture != null ); |
---|
7074 | 8120 | // if (texture == null) |
---|
.. | .. |
---|
7160 | 8206 | } |
---|
7161 | 8207 | } |
---|
7162 | 8208 | |
---|
7163 | | - /*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 |
---|
7164 | 8258 | { |
---|
7165 | 8259 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7166 | 8260 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7171 | 8265 | if (tex == null) |
---|
7172 | 8266 | { |
---|
7173 | 8267 | BindTexture(null,false,resolution); |
---|
7174 | | - BindTexture(null,true,resolution); |
---|
7175 | 8268 | return; |
---|
7176 | 8269 | } |
---|
7177 | 8270 | |
---|
7178 | 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 | + |
---|
7179 | 8304 | String bump = Object3D.GetBump(tex); |
---|
7180 | 8305 | |
---|
7181 | | - usedtextures.put(pigment, pigment); |
---|
7182 | | - usedtextures.put(bump, bump); |
---|
| 8306 | + usedtextures.add(tex); |
---|
7183 | 8307 | |
---|
7184 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8308 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7185 | 8309 | { |
---|
7186 | 8310 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
7187 | 8311 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7191 | 8315 | { |
---|
7192 | 8316 | bump = null; |
---|
7193 | 8317 | } |
---|
7194 | | - if (pigment.equals("")) |
---|
7195 | | - { |
---|
7196 | | - pigment = null; |
---|
7197 | | - } |
---|
7198 | 8318 | |
---|
7199 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7200 | | - BindTexture(pigment, false, resolution); |
---|
7201 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
7202 | | - BindTexture(bump, true, resolution); |
---|
| 8320 | + BindTexture(tex, true, resolution); |
---|
7203 | 8321 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
7204 | | - |
---|
7205 | | - return; // true; |
---|
7206 | 8322 | } |
---|
7207 | 8323 | |
---|
7208 | | - 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) |
---|
7209 | 8327 | { |
---|
7210 | | - 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; |
---|
7211 | 8347 | |
---|
7212 | 8348 | if (tex != null) |
---|
7213 | 8349 | { |
---|
7214 | | - String texname = tex; |
---|
| 8350 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8351 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
7215 | 8352 | |
---|
7216 | | - String[] split = tex.split("Textures"); |
---|
7217 | | - if (split.length > 1) |
---|
7218 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
7219 | | - else |
---|
7220 | | - if (!texname.startsWith("/")) |
---|
7221 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 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 | + } |
---|
7222 | 8370 | |
---|
7223 | 8371 | if (CACHETEXTURE) |
---|
7224 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
7225 | | - |
---|
7226 | | - TextureData texturedata = null; |
---|
7227 | | - |
---|
7228 | | - if (texture == null || texture.resolution < resolution) |
---|
7229 | 8372 | { |
---|
7230 | | - 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("")) |
---|
7231 | 8406 | { |
---|
7232 | 8407 | assert(!bump); |
---|
7233 | 8408 | // if (bump) |
---|
.. | .. |
---|
7238 | 8413 | // } |
---|
7239 | 8414 | // else |
---|
7240 | 8415 | // { |
---|
7241 | | - texture = textures.get(tex); |
---|
7242 | | - if (texture == null) |
---|
| 8416 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8417 | + if (texturecache == null) |
---|
7243 | 8418 | { |
---|
7244 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8419 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
7245 | 8420 | } |
---|
| 8421 | + else |
---|
| 8422 | + new Exception().printStackTrace(); |
---|
7246 | 8423 | // } |
---|
7247 | 8424 | } else |
---|
7248 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8425 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
7249 | 8426 | { |
---|
7250 | 8427 | assert(bump); |
---|
7251 | | - texture = textures.get(tex); |
---|
7252 | | - if (texture == null) |
---|
7253 | | - 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(); |
---|
7254 | 8433 | } else |
---|
7255 | 8434 | { |
---|
7256 | 8435 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
7258 | 8437 | // texture = GetResourceTexture("default.png"); |
---|
7259 | 8438 | //} else |
---|
7260 | 8439 | //{ |
---|
7261 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8440 | + if (texname.endsWith("WHITE_NOISE")) |
---|
7262 | 8441 | { |
---|
7263 | | - texture = textures.get(tex); |
---|
7264 | | - if (texture == null) |
---|
7265 | | - 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(); |
---|
7266 | 8456 | } else |
---|
7267 | 8457 | { |
---|
7268 | 8458 | if (textureon) |
---|
.. | .. |
---|
7287 | 8477 | } |
---|
7288 | 8478 | |
---|
7289 | 8479 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7290 | | - if (!new File(cachename).exists()) |
---|
| 8480 | + if (!FileExists(cachename)) |
---|
7291 | 8481 | cachename = texname; |
---|
7292 | 8482 | else |
---|
7293 | 8483 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7309 | 8499 | } |
---|
7310 | 8500 | |
---|
7311 | 8501 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7312 | | - if (!new File(cachename).exists()) |
---|
| 8502 | + if (!FileExists(cachename)) |
---|
7313 | 8503 | cachename = texname; |
---|
7314 | 8504 | else |
---|
7315 | 8505 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7318 | 8508 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7319 | 8509 | |
---|
7320 | 8510 | |
---|
7321 | | - if (texturedata != null) |
---|
7322 | | - 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); |
---|
7323 | 8515 | //texture = GetTexture(tex, bump); |
---|
7324 | 8516 | } |
---|
| 8517 | + } |
---|
7325 | 8518 | } |
---|
7326 | 8519 | //} |
---|
7327 | 8520 | } |
---|
7328 | 8521 | |
---|
7329 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8522 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
7330 | 8523 | { |
---|
7331 | 8524 | //return false; |
---|
7332 | 8525 | |
---|
7333 | 8526 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
7334 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8527 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
7335 | 8528 | { |
---|
7336 | 8529 | // String ext = "_highres"; |
---|
7337 | 8530 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
7348 | 8541 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
7349 | 8542 | if (!cachefile.exists()) |
---|
7350 | 8543 | { |
---|
7351 | | - // cache to disk |
---|
7352 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
7353 | | - //buffers[0]. |
---|
7354 | | - |
---|
7355 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
7356 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
7357 | | - |
---|
7358 | | - // squared size heuristic... |
---|
7359 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8544 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
7360 | 8545 | { |
---|
7361 | | - for (int i=pixels.length; --i>=0;) |
---|
7362 | | - { |
---|
7363 | | - int i3 = i*3; |
---|
7364 | | - pixels[i] = 0xFF; |
---|
7365 | | - pixels[i] <<= 8; |
---|
7366 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
7367 | | - pixels[i] <<= 8; |
---|
7368 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
7369 | | - pixels[i] <<= 8; |
---|
7370 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
7371 | | - } |
---|
7372 | | - |
---|
7373 | | - /* |
---|
7374 | | - int r=0,g=0,b=0,a=0; |
---|
7375 | | - for (int i=0; i<width; i++) |
---|
7376 | | - for (int j=0; j<height; j++) |
---|
7377 | | - { |
---|
7378 | | - int index = j*width+i; |
---|
7379 | | - int p = pixels[index]; |
---|
7380 | | - a = ((p>>24) & 0xFF); |
---|
7381 | | - r = ((p>>16) & 0xFF); |
---|
7382 | | - g = ((p>>8) & 0xFF); |
---|
7383 | | - b = (p & 0xFF); |
---|
7384 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
7385 | | - } |
---|
7386 | | - /**/ |
---|
7387 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
7388 | | - int height = width; |
---|
7389 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
7390 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8546 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8547 | + |
---|
7391 | 8548 | ImageWriter writer = null; |
---|
7392 | 8549 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
7393 | 8550 | if (iter.hasNext()) { |
---|
7394 | 8551 | writer = (ImageWriter)iter.next(); |
---|
7395 | 8552 | } |
---|
7396 | | - float compressionQuality = 0.9f; |
---|
| 8553 | + |
---|
| 8554 | + float compressionQuality = 0.85f; |
---|
7397 | 8555 | try |
---|
7398 | 8556 | { |
---|
7399 | 8557 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
7410 | 8568 | } |
---|
7411 | 8569 | } |
---|
7412 | 8570 | } |
---|
7413 | | - |
---|
| 8571 | + |
---|
| 8572 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8573 | + |
---|
7414 | 8574 | //System.out.println("Texture = " + tex); |
---|
7415 | | - if (textures.containsKey(texname)) |
---|
| 8575 | + if (textures.containsKey(tex)) |
---|
7416 | 8576 | { |
---|
7417 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8577 | + CacheTexture thetex = textures.get(tex); |
---|
7418 | 8578 | thetex.texture.disable(); |
---|
7419 | 8579 | thetex.texture.dispose(); |
---|
7420 | | - textures.remove(texname); |
---|
| 8580 | + textures.remove(tex); |
---|
7421 | 8581 | } |
---|
7422 | 8582 | |
---|
7423 | | - texture.texturedata = texturedata; |
---|
7424 | | - textures.put(texname, texture); |
---|
| 8583 | + //texture.texturedata = texturedata; |
---|
| 8584 | + textures.put(tex, texturecache); |
---|
7425 | 8585 | |
---|
7426 | 8586 | // newtex = true; |
---|
7427 | 8587 | } |
---|
.. | .. |
---|
7437 | 8597 | } |
---|
7438 | 8598 | } |
---|
7439 | 8599 | |
---|
7440 | | - return texture; |
---|
| 8600 | + return texturecache; |
---|
7441 | 8601 | } |
---|
7442 | 8602 | |
---|
7443 | | - 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 |
---|
7444 | 8638 | { |
---|
7445 | 8639 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7446 | 8640 | |
---|
.. | .. |
---|
7458 | 8652 | return texture!=null?texture.texture:null; |
---|
7459 | 8653 | } |
---|
7460 | 8654 | |
---|
7461 | | - 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 |
---|
7462 | 8656 | { |
---|
7463 | 8657 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7464 | 8658 | |
---|
7465 | 8659 | return texture!=null?texture.texturedata:null; |
---|
7466 | 8660 | } |
---|
7467 | 8661 | |
---|
7468 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8662 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
7469 | 8663 | { |
---|
7470 | 8664 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7471 | 8665 | { |
---|
7472 | 8666 | return false; |
---|
7473 | 8667 | } |
---|
7474 | 8668 | |
---|
7475 | | - boolean newtex = false; |
---|
| 8669 | + //boolean newtex = false; |
---|
7476 | 8670 | |
---|
7477 | 8671 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
7478 | 8672 | |
---|
.. | .. |
---|
7504 | 8698 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
7505 | 8699 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
7506 | 8700 | |
---|
7507 | | - return newtex; |
---|
| 8701 | + return true; // Warning: not used. |
---|
7508 | 8702 | } |
---|
7509 | 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 | + |
---|
7510 | 8770 | ShadowBuffer shadowPBuf; |
---|
7511 | 8771 | AntialiasBuffer antialiasPBuf; |
---|
7512 | 8772 | int MAXSTACK; |
---|
.. | .. |
---|
7523 | 8783 | |
---|
7524 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
7525 | 8785 | MAXSTACK = temp[0]; |
---|
7526 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
7527 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
7528 | 8789 | MAXSTACK = temp[0]; |
---|
7529 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
7530 | 8792 | |
---|
7531 | 8793 | // Use debug pipeline |
---|
7532 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
7534 | 8796 | gl = drawable.getGL(); // |
---|
7535 | 8797 | |
---|
7536 | 8798 | GL gl3 = getGL(); |
---|
7537 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
7538 | 8801 | |
---|
7539 | 8802 | |
---|
7540 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
7699 | 8962 | |
---|
7700 | 8963 | if (cubemap == null) |
---|
7701 | 8964 | { |
---|
7702 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
7703 | 8966 | } |
---|
7704 | 8967 | |
---|
7705 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
7975 | 9238 | |
---|
7976 | 9239 | void LoadEnvy(int which) |
---|
7977 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
7978 | 9243 | String name; |
---|
7979 | 9244 | String ext; |
---|
7980 | 9245 | |
---|
.. | .. |
---|
7986 | 9251 | cubemap = null; |
---|
7987 | 9252 | return; |
---|
7988 | 9253 | case 1: |
---|
7989 | | - name = "cubemaps/box_"; |
---|
7990 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
7991 | 9256 | reverseUP = false; |
---|
7992 | 9257 | break; |
---|
7993 | 9258 | case 2: |
---|
7994 | | - name = "cubemaps/uffizi_"; |
---|
7995 | | - ext = "png"; |
---|
7996 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
7997 | 9263 | case 3: |
---|
7998 | | - name = "cubemaps/CloudyHills_"; |
---|
7999 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
8000 | 9266 | reverseUP = false; |
---|
8001 | 9267 | break; |
---|
8002 | 9268 | case 4: |
---|
8003 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
8004 | 9270 | ext = "png"; |
---|
8005 | 9271 | reverseUP = false; |
---|
8006 | 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; |
---|
8007 | 9298 | default: |
---|
8008 | | - name = "cubemaps/rgb_"; |
---|
8009 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
8010 | 9302 | break; |
---|
8011 | 9303 | } |
---|
8012 | | - |
---|
8013 | | - try |
---|
8014 | | - { |
---|
8015 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8016 | | - } catch (IOException e) |
---|
8017 | | - { |
---|
8018 | | - throw new RuntimeException(e); |
---|
8019 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
8020 | 9306 | } |
---|
8021 | 9307 | |
---|
8022 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8048 | 9334 | static double[] model = new double[16]; |
---|
8049 | 9335 | double[] camera2light = new double[16]; |
---|
8050 | 9336 | double[] light2camera = new double[16]; |
---|
8051 | | - int newenvy = -1; |
---|
8052 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
8053 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8054 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
8055 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
8342 | 9632 | jy8[3] = 0.5f; |
---|
8343 | 9633 | } |
---|
8344 | 9634 | |
---|
8345 | | - 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 |
---|
8346 | 9636 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
8347 | 9637 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
8348 | 9638 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
8349 | 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 | + |
---|
8350 | 9664 | static int imagecount = 0; // movie generation |
---|
8351 | 9665 | |
---|
8352 | 9666 | static int jitter = 0; |
---|
.. | .. |
---|
8442 | 9756 | assert (parentcam != renderCamera); |
---|
8443 | 9757 | |
---|
8444 | 9758 | if (renderCamera != lightCamera) |
---|
8445 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8446 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9759 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
8447 | 9761 | |
---|
8448 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8449 | 9763 | |
---|
.. | .. |
---|
8458 | 9772 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8459 | 9773 | |
---|
8460 | 9774 | if (renderCamera != lightCamera) |
---|
8461 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8462 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9775 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
8463 | 9777 | |
---|
8464 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8465 | 9779 | |
---|
.. | .. |
---|
8505 | 9819 | rati = 1 / rati; |
---|
8506 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
8507 | 9821 | } |
---|
8508 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
8509 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
8510 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
8511 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
8512 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
8513 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
8514 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
8531 | 9847 | //gl.glFlush(); |
---|
8532 | 9848 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
8533 | 9849 | |
---|
8534 | | - if (ANIMATION && ABORTED) |
---|
| 9850 | + if (Globals.ANIMATION && ABORTED) |
---|
8535 | 9851 | { |
---|
8536 | 9852 | System.err.println(" ABORTED FRAME"); |
---|
8537 | 9853 | break; |
---|
.. | .. |
---|
8561 | 9877 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
8562 | 9878 | |
---|
8563 | 9879 | // save image |
---|
8564 | | - if (ANIMATION && !ABORTED) |
---|
| 9880 | + if (Globals.ANIMATION && !ABORTED) |
---|
8565 | 9881 | { |
---|
8566 | 9882 | VPwidth = viewport[2]; |
---|
8567 | 9883 | VPheight = viewport[3]; |
---|
.. | .. |
---|
8672 | 9988 | |
---|
8673 | 9989 | // imagecount++; |
---|
8674 | 9990 | |
---|
8675 | | - 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; |
---|
8676 | 9992 | |
---|
8677 | 9993 | if (!BOXMODE) |
---|
8678 | 9994 | { |
---|
8679 | | - 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) + ")"); |
---|
8680 | 9996 | } |
---|
8681 | 9997 | |
---|
8682 | 9998 | if (!BOXMODE) |
---|
.. | .. |
---|
8714 | 10030 | ABORTED = false; |
---|
8715 | 10031 | } |
---|
8716 | 10032 | else |
---|
8717 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10033 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
8718 | 10034 | |
---|
8719 | 10035 | if (false) |
---|
8720 | 10036 | { |
---|
.. | .. |
---|
9374 | 10690 | static boolean init = false; |
---|
9375 | 10691 | |
---|
9376 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
9377 | 10696 | |
---|
9378 | 10697 | public void display(GLAutoDrawable drawable) |
---|
9379 | 10698 | { |
---|
9380 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
9381 | 10700 | { |
---|
9382 | | - GrafreeD.wav.save(); |
---|
9383 | | - GrafreeD.savesound = false; |
---|
9384 | | - GrafreeD.hassound = false; |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(0); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
| 10705 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
| 10706 | + { |
---|
| 10707 | + Grafreed.wav.save(); |
---|
| 10708 | + Grafreed.savesound = false; |
---|
| 10709 | + Grafreed.hassound = false; |
---|
9385 | 10710 | } |
---|
9386 | 10711 | // if (DEBUG_SELECTION) |
---|
9387 | 10712 | // { |
---|
.. | .. |
---|
9457 | 10782 | ANTIALIAS = 0; |
---|
9458 | 10783 | //System.out.println("RESTART"); |
---|
9459 | 10784 | AAtimer.restart(); |
---|
| 10785 | + Globals.TIMERRUNNING = true; |
---|
9460 | 10786 | } |
---|
9461 | 10787 | } |
---|
9462 | 10788 | } |
---|
.. | .. |
---|
9511 | 10837 | Object3D theobject = object; |
---|
9512 | 10838 | Object3D theparent = object.parent; |
---|
9513 | 10839 | object.parent = null; |
---|
9514 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10840 | + object = (Object3D)Grafreed.clone(object); |
---|
9515 | 10841 | object.Stripify(); |
---|
9516 | 10842 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
9517 | 10843 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
9524 | 10850 | ambientOcclusion = false; |
---|
9525 | 10851 | } |
---|
9526 | 10852 | |
---|
9527 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10853 | + if (//Globals.lighttouched && |
---|
| 10854 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
9528 | 10855 | { |
---|
9529 | 10856 | //if (RENDERSHADOW) // ? |
---|
9530 | 10857 | if (!IsFrozen()) |
---|
9531 | 10858 | { |
---|
9532 | 10859 | // dec 2012 |
---|
9533 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10860 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
9534 | 10861 | { |
---|
9535 | 10862 | Globals.framecount++; |
---|
9536 | 10863 | shadowbuffer.display(); |
---|
.. | .. |
---|
9543 | 10870 | |
---|
9544 | 10871 | if (wait) |
---|
9545 | 10872 | { |
---|
9546 | | - Sleep(500); |
---|
| 10873 | + Sleep(200); // blocks everything |
---|
9547 | 10874 | |
---|
9548 | 10875 | wait = false; |
---|
9549 | 10876 | } |
---|
.. | .. |
---|
9657 | 10984 | |
---|
9658 | 10985 | // if (parentcam != renderCamera) // not a light |
---|
9659 | 10986 | if (cam != lightCamera) |
---|
9660 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9661 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10987 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10988 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9662 | 10989 | |
---|
9663 | 10990 | for (int j = 0; j < 4; j++) |
---|
9664 | 10991 | { |
---|
.. | .. |
---|
9672 | 10999 | |
---|
9673 | 11000 | // if (parentcam != renderCamera) // not a light |
---|
9674 | 11001 | if (cam != lightCamera) |
---|
9675 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9676 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 11002 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11003 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9677 | 11004 | |
---|
9678 | 11005 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
9679 | 11006 | |
---|
.. | .. |
---|
9759 | 11086 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
9760 | 11087 | } |
---|
9761 | 11088 | |
---|
9762 | | - if (newenvy > -1) |
---|
| 11089 | +// if (newenvy > -1) |
---|
| 11090 | +// { |
---|
| 11091 | +// LoadEnvy(newenvy); |
---|
| 11092 | +// } |
---|
| 11093 | +// |
---|
| 11094 | +// newenvy = -1; |
---|
| 11095 | + |
---|
| 11096 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
9763 | 11097 | { |
---|
9764 | | - LoadEnvy(newenvy); |
---|
| 11098 | + if (cubemaprgb == null) |
---|
| 11099 | + { |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11101 | + } |
---|
| 11102 | + |
---|
| 11103 | + cubemap = cubemaprgb; |
---|
9765 | 11104 | } |
---|
9766 | | - |
---|
9767 | | - newenvy = -1; |
---|
9768 | | - |
---|
| 11105 | + else |
---|
| 11106 | + { |
---|
| 11107 | + if (object.skyboxname != null) |
---|
| 11108 | + { |
---|
| 11109 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11110 | + { |
---|
| 11111 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11112 | + cubemap.dispose(); |
---|
| 11113 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11114 | + loadedskyboxname = object.skyboxname; |
---|
| 11115 | + } |
---|
| 11116 | + } |
---|
| 11117 | + else |
---|
| 11118 | + { |
---|
| 11119 | + cubemapcustom = null; |
---|
| 11120 | + loadedskyboxname = null; |
---|
| 11121 | + } |
---|
| 11122 | + |
---|
| 11123 | + cubemap = cubemapcustom; |
---|
| 11124 | + } |
---|
| 11125 | + |
---|
9769 | 11126 | ratio = ((double) getWidth()) / getHeight(); |
---|
9770 | 11127 | //System.out.println("ratio = " + ratio); |
---|
9771 | 11128 | |
---|
.. | .. |
---|
9781 | 11138 | |
---|
9782 | 11139 | if (!IsFrozen() && !ambientOcclusion) |
---|
9783 | 11140 | { |
---|
9784 | | - DrawSkyBox(gl); |
---|
| 11141 | + DrawSkyBox(gl, (float)ratio); |
---|
9785 | 11142 | } |
---|
9786 | 11143 | |
---|
9787 | 11144 | //if (selection_view == -1) |
---|
.. | .. |
---|
9932 | 11289 | // Bump noise |
---|
9933 | 11290 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
9934 | 11291 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
9935 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11292 | + |
---|
| 11293 | + try |
---|
| 11294 | + { |
---|
| 11295 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11296 | + } |
---|
| 11297 | + catch (Exception e) |
---|
| 11298 | + { |
---|
| 11299 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11300 | + } |
---|
| 11301 | + |
---|
9936 | 11302 | |
---|
9937 | 11303 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
9938 | 11304 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9955 | 11321 | |
---|
9956 | 11322 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
9957 | 11323 | |
---|
9958 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
9959 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
9960 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11324 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11325 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11326 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
9961 | 11327 | } else |
---|
9962 | 11328 | { |
---|
9963 | 11329 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
9968 | 11334 | //System.out.println("BLENDING ON"); |
---|
9969 | 11335 | gl.glEnable(GL.GL_BLEND); |
---|
9970 | 11336 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
9971 | | - |
---|
| 11337 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
9972 | 11338 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
9973 | 11339 | gl.glLoadIdentity(); |
---|
9974 | 11340 | |
---|
.. | .. |
---|
10057 | 11423 | System.err.println("parentcam != renderCamera"); |
---|
10058 | 11424 | |
---|
10059 | 11425 | // if (cam != lightCamera) |
---|
10060 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10061 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11426 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11427 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
10062 | 11428 | } |
---|
10063 | 11429 | |
---|
10064 | 11430 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10079 | 11445 | if (true) // TODO |
---|
10080 | 11446 | { |
---|
10081 | 11447 | if (cam != lightCamera) |
---|
10082 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10083 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11448 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11449 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10084 | 11450 | } |
---|
10085 | 11451 | |
---|
10086 | 11452 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10146 | 11512 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10147 | 11513 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10148 | 11514 | |
---|
10149 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11515 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10150 | 11516 | { |
---|
10151 | 11517 | /* |
---|
10152 | 11518 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10217 | 11583 | } |
---|
10218 | 11584 | } |
---|
10219 | 11585 | |
---|
10220 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11586 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
10221 | 11587 | { |
---|
10222 | 11588 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
10223 | 11589 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
10225 | 11591 | |
---|
10226 | 11592 | boolean texon = textureon; |
---|
10227 | 11593 | |
---|
10228 | | - if (RENDERPROGRAM > 0) |
---|
10229 | | - { |
---|
10230 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10231 | | - textureon = false; |
---|
10232 | | - } |
---|
| 11594 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11595 | + textureon = false; |
---|
| 11596 | + |
---|
10233 | 11597 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
10234 | 11598 | //System.out.println("ALLO"); |
---|
10235 | 11599 | gl.glColorMask(false, false, false, false); |
---|
10236 | 11600 | DrawObject(gl); |
---|
10237 | | - if (RENDERPROGRAM > 0) |
---|
10238 | | - { |
---|
10239 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
10240 | | - textureon = texon; |
---|
10241 | | - } |
---|
| 11601 | + |
---|
| 11602 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11603 | + textureon = texon; |
---|
| 11604 | + |
---|
10242 | 11605 | gl.glColorMask(true, true, true, true); |
---|
10243 | 11606 | |
---|
10244 | 11607 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
10245 | | - //gl.glDepthMask(false); |
---|
| 11608 | + gl.glDepthMask(false); |
---|
10246 | 11609 | } |
---|
10247 | 11610 | |
---|
10248 | 11611 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
10396 | 11759 | { |
---|
10397 | 11760 | renderpass++; |
---|
10398 | 11761 | // System.out.println("Draw object... "); |
---|
| 11762 | + STEP = 1; |
---|
10399 | 11763 | if (FAST) // in case there is no script |
---|
10400 | | - STEP = 16; |
---|
| 11764 | + STEP = 8; |
---|
| 11765 | + |
---|
| 11766 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11767 | + { |
---|
| 11768 | + STEP *= 4; |
---|
| 11769 | + } |
---|
10401 | 11770 | |
---|
10402 | 11771 | //object.FullInvariants(); |
---|
10403 | 11772 | |
---|
.. | .. |
---|
10411 | 11780 | e.printStackTrace(); |
---|
10412 | 11781 | } |
---|
10413 | 11782 | |
---|
10414 | | - if (GrafreeD.RENDERME > 0) |
---|
10415 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11783 | + if (Grafreed.RENDERME > 0) |
---|
| 11784 | + Grafreed.RENDERME--; // mechante magouille |
---|
10416 | 11785 | |
---|
10417 | 11786 | Globals.ONESTEP = false; |
---|
10418 | 11787 | } |
---|
10419 | 11788 | |
---|
10420 | 11789 | static boolean zoomonce = false; |
---|
10421 | 11790 | |
---|
| 11791 | + static void CreateSelectedPoint() |
---|
| 11792 | + { |
---|
| 11793 | + if (selectedpoint == null) |
---|
| 11794 | + { |
---|
| 11795 | + debugpointG = new Sphere(); |
---|
| 11796 | + debugpointP = new Sphere(); |
---|
| 11797 | + debugpointC = new Sphere(); |
---|
| 11798 | + debugpointR = new Sphere(); |
---|
| 11799 | + |
---|
| 11800 | + selectedpoint = new Superellipsoid(); |
---|
| 11801 | + |
---|
| 11802 | + for (int i=0; i<8; i++) |
---|
| 11803 | + { |
---|
| 11804 | + debugpoints[i] = new Sphere(); |
---|
| 11805 | + } |
---|
| 11806 | + } |
---|
| 11807 | + } |
---|
| 11808 | + |
---|
10422 | 11809 | void DrawObject(GL gl, boolean draw) |
---|
10423 | 11810 | { |
---|
| 11811 | + // To clear camera values |
---|
| 11812 | + ResetOptions(); |
---|
| 11813 | + |
---|
10424 | 11814 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
10425 | 11815 | // DrawMode() = SELECTION; |
---|
10426 | 11816 | //GL gl = getGL(); |
---|
10427 | 11817 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
10428 | 11818 | { |
---|
10429 | 11819 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
10430 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11820 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
10431 | 11821 | pingthread.StepToTarget(true); // true); |
---|
10432 | 11822 | // zoomonce = false; |
---|
10433 | 11823 | } |
---|
.. | .. |
---|
10447 | 11837 | callist = gl.glGenLists(1); |
---|
10448 | 11838 | } |
---|
10449 | 11839 | |
---|
10450 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11840 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10451 | 11841 | |
---|
10452 | 11842 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10453 | 11843 | |
---|
.. | .. |
---|
10482 | 11872 | |
---|
10483 | 11873 | usedtextures.clear(); |
---|
10484 | 11874 | |
---|
10485 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11875 | + try |
---|
| 11876 | + { |
---|
| 11877 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11878 | + } |
---|
| 11879 | + catch (Exception e) |
---|
| 11880 | + { |
---|
| 11881 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11882 | + } |
---|
10486 | 11883 | } |
---|
10487 | 11884 | //System.out.println("--> " + stackdepth); |
---|
10488 | 11885 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
10492 | 11889 | |
---|
10493 | 11890 | if (DrawMode() == DEFAULT) |
---|
10494 | 11891 | { |
---|
10495 | | - if (DEBUG) |
---|
| 11892 | + if (Globals.DEBUG) |
---|
10496 | 11893 | { |
---|
| 11894 | + CreateSelectedPoint(); |
---|
10497 | 11895 | float radius = 0.05f; |
---|
10498 | 11896 | if (selectedpoint.radius != radius) |
---|
10499 | 11897 | { |
---|
.. | .. |
---|
10547 | 11945 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
10548 | 11946 | |
---|
10549 | 11947 | if (CLEANCACHE) |
---|
10550 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11948 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
10551 | 11949 | { |
---|
10552 | | - String tex = e.nextElement(); |
---|
| 11950 | + cTexture tex = e.nextElement(); |
---|
10553 | 11951 | |
---|
10554 | 11952 | // System.out.println("Texture --------- " + tex); |
---|
10555 | 11953 | |
---|
10556 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11954 | + if (tex.equals("WHITE_NOISE:")) |
---|
10557 | 11955 | continue; |
---|
10558 | 11956 | |
---|
10559 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11957 | + if (!usedtextures.contains(tex)) |
---|
10560 | 11958 | { |
---|
| 11959 | + CacheTexture gettex = texturepigment.get(tex); |
---|
10561 | 11960 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
10562 | | - textures.get(tex).texture.dispose(); |
---|
10563 | | - textures.remove(tex); |
---|
| 11961 | + if (gettex != null) |
---|
| 11962 | + { |
---|
| 11963 | + gettex.texture.dispose(); |
---|
| 11964 | + texturepigment.remove(tex); |
---|
| 11965 | + } |
---|
| 11966 | + |
---|
| 11967 | + gettex = texturebump.get(tex); |
---|
| 11968 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11969 | + if (gettex != null) |
---|
| 11970 | + { |
---|
| 11971 | + gettex.texture.dispose(); |
---|
| 11972 | + texturebump.remove(tex); |
---|
| 11973 | + } |
---|
10564 | 11974 | } |
---|
10565 | 11975 | } |
---|
10566 | 11976 | } |
---|
.. | .. |
---|
10573 | 11983 | if (checker != null && DrawMode() == DEFAULT) |
---|
10574 | 11984 | { |
---|
10575 | 11985 | //BindTexture(IMMORTAL_TEXTURE); |
---|
10576 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11986 | + try |
---|
| 11987 | + { |
---|
| 11988 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11989 | + } |
---|
| 11990 | + catch (Exception e) |
---|
| 11991 | + { |
---|
| 11992 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11993 | + } |
---|
10577 | 11994 | // NEAREST |
---|
10578 | 11995 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
10579 | 11996 | DrawChecker(gl); |
---|
.. | .. |
---|
10655 | 12072 | return; |
---|
10656 | 12073 | } |
---|
10657 | 12074 | |
---|
10658 | | - String string = obj.GetToolTip(); |
---|
| 12075 | + String string = obj.toString(); //.GetToolTip(); |
---|
10659 | 12076 | |
---|
10660 | 12077 | GL gl = GetGL(); |
---|
10661 | 12078 | |
---|
.. | .. |
---|
10972 | 12389 | //obj.TransformToWorld(light, light); |
---|
10973 | 12390 | for (int i = tp.size(); --i >= 0;) |
---|
10974 | 12391 | { |
---|
10975 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
10976 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12392 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12393 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
10977 | 12394 | } |
---|
10978 | 12395 | |
---|
10979 | 12396 | |
---|
.. | .. |
---|
10990 | 12407 | parentcam = cameras[0]; |
---|
10991 | 12408 | } |
---|
10992 | 12409 | |
---|
10993 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10994 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12410 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12411 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
10995 | 12412 | |
---|
10996 | 12413 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
10997 | 12414 | |
---|
.. | .. |
---|
11081 | 12498 | |
---|
11082 | 12499 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11083 | 12500 | |
---|
11084 | | - String program = |
---|
| 12501 | + String programmin = |
---|
| 12502 | + // Min shader |
---|
11085 | 12503 | "!!ARBfp1.0\n" + |
---|
| 12504 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12505 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12506 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12507 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12508 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12509 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12510 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12511 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12512 | + "TEMP temp;" + |
---|
| 12513 | + "TEMP light;" + |
---|
| 12514 | + "TEMP ndotl;" + |
---|
| 12515 | + "TEMP normal;" + |
---|
| 12516 | + "TEMP depth;" + |
---|
| 12517 | + "TEMP eye;" + |
---|
| 12518 | + "TEMP pos;" + |
---|
| 12519 | + |
---|
| 12520 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12521 | + Normalize("normal") + |
---|
| 12522 | + "MOV light, state.light[0].position;" + |
---|
| 12523 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12524 | + |
---|
| 12525 | + // shadow |
---|
| 12526 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12527 | + "MOV temp, pos;" + |
---|
| 12528 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12529 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12530 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12531 | + |
---|
| 12532 | + // No shadow when out of frustum |
---|
| 12533 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12534 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12535 | + |
---|
| 12536 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12537 | + |
---|
| 12538 | + // Backlit |
---|
| 12539 | + "MOV pos.w, zero123.y;" + |
---|
| 12540 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12541 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12542 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12543 | + Normalize("eye") + |
---|
| 12544 | + |
---|
| 12545 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12546 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12547 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12548 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12549 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12550 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12551 | + |
---|
| 12552 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12553 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12554 | + |
---|
| 12555 | + // Pigment |
---|
| 12556 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12557 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12558 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12559 | + |
---|
| 12560 | + "MUL temp, temp, zero123.z;" + |
---|
| 12561 | + |
---|
| 12562 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12563 | + |
---|
| 12564 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12565 | + "MOV result.color, temp;" + |
---|
| 12566 | + "END"; |
---|
| 12567 | + |
---|
| 12568 | + String programmax = |
---|
| 12569 | + "!!ARBfp1.0\n" + |
---|
| 12570 | + |
---|
11086 | 12571 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11087 | 12572 | "PARAM light2cam0 = program.env[10];" + |
---|
11088 | 12573 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
11197 | 12682 | "TEMP shininess;" + |
---|
11198 | 12683 | "\n" + |
---|
11199 | 12684 | "MOV texSamp, one;" + |
---|
11200 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
11201 | | - |
---|
| 12685 | + |
---|
11202 | 12686 | "MOV mapgrid.x, one2048th.x;" + |
---|
11203 | 12687 | "MOV temp, fragment.texcoord[1];" + |
---|
11204 | 12688 | /* |
---|
.. | .. |
---|
11219 | 12703 | "MUL temp, floor, mapgrid.x;" + |
---|
11220 | 12704 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
11221 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11222 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
11223 | 12707 | "") + |
---|
11224 | 12708 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
11225 | 12709 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
11226 | 12710 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11227 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12711 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
11228 | 12712 | "") + |
---|
11229 | 12713 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
11230 | 12714 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
11231 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12715 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
11232 | 12716 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
11233 | 12717 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
11234 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
11235 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
11236 | 12720 | "") + |
---|
11237 | 12721 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
11238 | 12722 | //"MOV params, material;" + |
---|
.. | .. |
---|
11603 | 13087 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
11604 | 13088 | "") + |
---|
11605 | 13089 | |
---|
11606 | | - // display shadow only (bump == 0) |
---|
| 13090 | + // display shadow only (fakedepth == 0) |
---|
11607 | 13091 | "SUB temp.x, half.x, shadow.x;" + |
---|
11608 | | - "MOV temp.y, -params6.x;" + |
---|
11609 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13092 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13093 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
11610 | 13094 | "SUB temp.y, one.x, temp.z;" + |
---|
11611 | 13095 | "MUL temp.x, temp.x, temp.y;" + |
---|
11612 | 13096 | "KIL temp.x;" + |
---|
.. | .. |
---|
11735 | 13219 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
11736 | 13220 | |
---|
11737 | 13221 | "SUB temp.x, one.x, ndotl.x;" + |
---|
11738 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
11739 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13222 | + // Tuning for default skin |
---|
| 13223 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13224 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13225 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
11740 | 13226 | "MUL temp.x, temp.x, temp.y;" + |
---|
11741 | 13227 | |
---|
11742 | 13228 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
11935 | 13421 | //once = true; |
---|
11936 | 13422 | } |
---|
11937 | 13423 | |
---|
11938 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
11939 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13424 | + String program = programmax; |
---|
| 13425 | + |
---|
| 13426 | + if (Globals.MINSHADER) |
---|
| 13427 | + { |
---|
| 13428 | + program = programmin; |
---|
| 13429 | + } |
---|
| 13430 | + |
---|
| 13431 | + if (Globals.DEBUG) |
---|
| 13432 | + { |
---|
| 13433 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13434 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13435 | + } |
---|
| 13436 | + |
---|
11940 | 13437 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11941 | 13438 | |
---|
11942 | 13439 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
11983 | 13480 | "\n" + |
---|
11984 | 13481 | "END\n"; |
---|
11985 | 13482 | |
---|
11986 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13483 | + if (Globals.DEBUG) |
---|
| 13484 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
11987 | 13485 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
11988 | 13486 | |
---|
11989 | 13487 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12028 | 13526 | return out; |
---|
12029 | 13527 | } |
---|
12030 | 13528 | |
---|
12031 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13529 | + // Also does frustum culling |
---|
| 13530 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12032 | 13531 | { |
---|
12033 | 13532 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12034 | 13533 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12035 | 13534 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13535 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13536 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12036 | 13537 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12037 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12038 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12039 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12040 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13538 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13539 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12041 | 13540 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12042 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13541 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12043 | 13542 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12044 | 13543 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12045 | 13544 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12046 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13545 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12047 | 13546 | |
---|
12048 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12049 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13547 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13548 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12050 | 13549 | } |
---|
12051 | 13550 | |
---|
12052 | 13551 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12068 | 13567 | |
---|
12069 | 13568 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12070 | 13569 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13570 | + |
---|
| 13571 | + // Compare fragment depth in light space with shadowmap. |
---|
12071 | 13572 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12072 | 13573 | "SGE temp.y, temp.x, zero.x;" + |
---|
12073 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13574 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13575 | + |
---|
| 13576 | + // Reverse comparison |
---|
12074 | 13577 | "SUB temp.x, one.x, temp.x;" + |
---|
12075 | 13578 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12076 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13579 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12077 | 13580 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12078 | 13581 | |
---|
12079 | 13582 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12087 | 13590 | // No shadow for backface |
---|
12088 | 13591 | "DP3 temp.x, normal, lightd;" + |
---|
12089 | 13592 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13593 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13594 | + |
---|
| 13595 | + // No shadow when out of frustum |
---|
| 13596 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12090 | 13597 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12091 | 13598 | ""; |
---|
12092 | 13599 | } |
---|
.. | .. |
---|
12233 | 13740 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
12234 | 13741 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
12235 | 13742 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
12236 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13743 | + |
---|
| 13744 | + //Object3D.cVector2[] vector2buffer; |
---|
12237 | 13745 | |
---|
12238 | 13746 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
12239 | 13747 | // OUT : diff, spec |
---|
.. | .. |
---|
12249 | 13757 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
12250 | 13758 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
12251 | 13759 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
12252 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
12253 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
12254 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13760 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13761 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13762 | + |
---|
| 13763 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
12255 | 13764 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
12256 | 13765 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
12257 | 13766 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
12645 | 14154 | public void mousePressed(MouseEvent e) |
---|
12646 | 14155 | { |
---|
12647 | 14156 | //System.out.println("mousePressed: " + e); |
---|
12648 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14157 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12649 | 14158 | } |
---|
12650 | 14159 | |
---|
12651 | 14160 | static long prevtime = 0; |
---|
.. | .. |
---|
12672 | 14181 | |
---|
12673 | 14182 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12674 | 14183 | |
---|
| 14184 | + if (BUTTONLESSWHEEL) |
---|
12675 | 14185 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12676 | 14186 | { |
---|
12677 | 14187 | return; |
---|
.. | .. |
---|
12680 | 14190 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12681 | 14191 | |
---|
12682 | 14192 | // TIMER |
---|
12683 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14193 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12684 | 14194 | { |
---|
12685 | 14195 | keepboxmode = BOXMODE; |
---|
12686 | 14196 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12720 | 14230 | // mode |= META; |
---|
12721 | 14231 | //} |
---|
12722 | 14232 | |
---|
12723 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
12724 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14233 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14234 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
12725 | 14235 | anchorX = ax; |
---|
12726 | 14236 | anchorY = ay; |
---|
12727 | 14237 | prevX = px; |
---|
.. | .. |
---|
12755 | 14265 | else |
---|
12756 | 14266 | if (evt.getSource() == AAtimer) |
---|
12757 | 14267 | { |
---|
| 14268 | + Globals.TIMERRUNNING = false; |
---|
12758 | 14269 | if (mouseDown) |
---|
12759 | 14270 | { |
---|
12760 | 14271 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
12780 | 14291 | // LIVE = waslive; |
---|
12781 | 14292 | // wasliveok = true; |
---|
12782 | 14293 | // waslive = false; |
---|
| 14294 | + |
---|
| 14295 | + // May 2019 Forget it: |
---|
| 14296 | + if (true) |
---|
| 14297 | + return; |
---|
12783 | 14298 | |
---|
12784 | 14299 | // source == timer |
---|
12785 | 14300 | if (mouseDown) |
---|
.. | .. |
---|
12810 | 14325 | |
---|
12811 | 14326 | // fev 2014??? |
---|
12812 | 14327 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
12813 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14328 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
12814 | 14329 | pingthread.StepToTarget(true); // true); |
---|
12815 | 14330 | } |
---|
12816 | 14331 | // if (!LIVE) |
---|
.. | .. |
---|
12819 | 14334 | |
---|
12820 | 14335 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
12821 | 14336 | |
---|
12822 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14337 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
12823 | 14338 | { |
---|
12824 | 14339 | if (!wasliveok) |
---|
12825 | 14340 | return; |
---|
12826 | 14341 | |
---|
12827 | 14342 | AAtimer.restart(); // |
---|
| 14343 | + Globals.TIMERRUNNING = true; |
---|
12828 | 14344 | |
---|
12829 | 14345 | // waslive = LIVE; |
---|
12830 | 14346 | // LIVE = false; |
---|
.. | .. |
---|
12836 | 14352 | // touched = true; // main DL |
---|
12837 | 14353 | if (isRenderer) |
---|
12838 | 14354 | { |
---|
12839 | | - SetMouseMode(modifiers); |
---|
| 14355 | + SetMouseMode(modifiers, modifiersex); |
---|
12840 | 14356 | } |
---|
12841 | 14357 | |
---|
12842 | 14358 | selectX = anchorX = x; |
---|
.. | .. |
---|
12849 | 14365 | clicked = true; |
---|
12850 | 14366 | hold = false; |
---|
12851 | 14367 | |
---|
12852 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14368 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
12853 | 14369 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
12854 | 14370 | { |
---|
12855 | 14371 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
12874 | 14390 | drag = false; |
---|
12875 | 14391 | //System.out.println("Mouse DOWN"); |
---|
12876 | 14392 | editObj = false; |
---|
12877 | | - ClickInfo info = new ClickInfo(); |
---|
12878 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
12879 | | - info.pane = this; |
---|
12880 | | - info.camera = renderCamera; |
---|
12881 | | - info.x = x; |
---|
12882 | | - info.y = y; |
---|
12883 | | - info.modifiers = modifiers; |
---|
12884 | | - editObj = object.doEditClick(info, 0); |
---|
| 14393 | + //ClickInfo info = new ClickInfo(); |
---|
| 14394 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14395 | + object.clickInfo.pane = this; |
---|
| 14396 | + object.clickInfo.camera = renderCamera; |
---|
| 14397 | + object.clickInfo.x = x; |
---|
| 14398 | + object.clickInfo.y = y; |
---|
| 14399 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14400 | + editObj = object.doEditClick(//info, |
---|
| 14401 | + 0); |
---|
12885 | 14402 | if (!editObj) |
---|
12886 | 14403 | { |
---|
12887 | 14404 | hasMarquee = true; |
---|
.. | .. |
---|
12897 | 14414 | |
---|
12898 | 14415 | public void mouseDragged(MouseEvent e) |
---|
12899 | 14416 | { |
---|
| 14417 | + Globals.MOUSEDRAGGED = true; |
---|
| 14418 | + |
---|
| 14419 | + //System.out.println("mouseDragged: " + e); |
---|
12900 | 14420 | if (isRenderer) |
---|
12901 | 14421 | movingcamera = true; |
---|
| 14422 | + |
---|
12902 | 14423 | //if (drawing) |
---|
12903 | 14424 | //return; |
---|
12904 | | - //System.out.println("mouseDragged: " + e); |
---|
12905 | 14425 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12906 | 14426 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12907 | 14427 | { |
---|
.. | .. |
---|
12909 | 14429 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
12910 | 14430 | } |
---|
12911 | 14431 | else |
---|
12912 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14432 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
12913 | 14433 | |
---|
12914 | 14434 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
12915 | 14435 | } |
---|
.. | .. |
---|
12921 | 14441 | cVector tmp = new cVector(); |
---|
12922 | 14442 | cVector tmp2 = new cVector(); |
---|
12923 | 14443 | boolean isMoving; |
---|
| 14444 | + |
---|
| 14445 | + public cVector TargetLookAt() |
---|
| 14446 | + { |
---|
| 14447 | + return targetLookAt; |
---|
| 14448 | + } |
---|
12924 | 14449 | |
---|
12925 | 14450 | class PingThread extends Thread |
---|
12926 | 14451 | { |
---|
.. | .. |
---|
13077 | 14602 | |
---|
13078 | 14603 | public void run() |
---|
13079 | 14604 | { |
---|
| 14605 | + new Exception().printStackTrace(); |
---|
13080 | 14606 | System.exit(0); |
---|
13081 | 14607 | for (;;) |
---|
13082 | 14608 | { |
---|
.. | .. |
---|
13140 | 14666 | { |
---|
13141 | 14667 | Globals.lighttouched = true; |
---|
13142 | 14668 | } |
---|
13143 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14669 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13144 | 14670 | } |
---|
13145 | 14671 | //else |
---|
13146 | 14672 | } |
---|
.. | .. |
---|
13154 | 14680 | void GoDown(int mod) |
---|
13155 | 14681 | { |
---|
13156 | 14682 | MODIFIERS |= COMMAND; |
---|
13157 | | - /* |
---|
| 14683 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14684 | + /**/ |
---|
13158 | 14685 | if((mod&SHIFT) == SHIFT) |
---|
13159 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14686 | + { |
---|
| 14687 | + if (isVR) |
---|
| 14688 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14691 | + } |
---|
13160 | 14692 | else |
---|
13161 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
13162 | | - */ |
---|
| 14693 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14694 | + /**/ |
---|
13163 | 14695 | if ((mod & SHIFT) == SHIFT) |
---|
13164 | 14696 | { |
---|
13165 | 14697 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
13168 | 14700 | mouseMode |= BACKFORTH; |
---|
13169 | 14701 | } |
---|
13170 | 14702 | |
---|
| 14703 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14704 | + |
---|
13171 | 14705 | //prevX = X = anchorX; |
---|
13172 | 14706 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
13173 | 14707 | } |
---|
.. | .. |
---|
13175 | 14709 | void GoUp(int mod) |
---|
13176 | 14710 | { |
---|
13177 | 14711 | MODIFIERS |= COMMAND; |
---|
13178 | | - /* |
---|
| 14712 | + /**/ |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14714 | + |
---|
13179 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
13180 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, speed); |
---|
| 14721 | + } |
---|
13181 | 14722 | else |
---|
13182 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
13183 | | - */ |
---|
| 14723 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14724 | + /**/ |
---|
13184 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
13185 | 14726 | { |
---|
13186 | 14727 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13189 | 14730 | mouseMode |= BACKFORTH; |
---|
13190 | 14731 | } |
---|
13191 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
13192 | 14735 | //prevX = X = anchorX; |
---|
13193 | 14736 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
13194 | 14737 | } |
---|
.. | .. |
---|
13196 | 14739 | void GoLeft(int mod) |
---|
13197 | 14740 | { |
---|
13198 | 14741 | MODIFIERS |= COMMAND; |
---|
13199 | | - /* |
---|
| 14742 | + /**/ |
---|
13200 | 14743 | if((mod&SHIFT) == SHIFT) |
---|
13201 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14744 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13202 | 14745 | else |
---|
13203 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
13204 | | - */ |
---|
| 14746 | + { |
---|
| 14747 | + if ((mouseMode&VR)!=0) |
---|
| 14748 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14751 | + } |
---|
| 14752 | + /**/ |
---|
13205 | 14753 | if ((mod & SHIFT) == SHIFT) |
---|
13206 | 14754 | { |
---|
13207 | 14755 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13210 | 14758 | mouseMode |= ROTATE; |
---|
13211 | 14759 | } // TRANSLATE; |
---|
13212 | 14760 | |
---|
| 14761 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14762 | + |
---|
13213 | 14763 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
13214 | 14764 | prevY = Y = anchorY; |
---|
13215 | 14765 | } |
---|
.. | .. |
---|
13217 | 14767 | void GoRight(int mod) |
---|
13218 | 14768 | { |
---|
13219 | 14769 | MODIFIERS |= COMMAND; |
---|
13220 | | - /* |
---|
| 14770 | + /**/ |
---|
13221 | 14771 | if((mod&SHIFT) == SHIFT) |
---|
13222 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14772 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13223 | 14773 | else |
---|
13224 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
13225 | | - */ |
---|
| 14774 | + { |
---|
| 14775 | + if ((mouseMode&VR)!=0) |
---|
| 14776 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14777 | + else |
---|
| 14778 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14779 | + } |
---|
| 14780 | + |
---|
| 14781 | + /**/ |
---|
13226 | 14782 | if ((mod & SHIFT) == SHIFT) |
---|
13227 | 14783 | { |
---|
13228 | 14784 | mouseMode = mouseMode; |
---|
.. | .. |
---|
13231 | 14787 | mouseMode |= ROTATE; |
---|
13232 | 14788 | } // TRANSLATE; |
---|
13233 | 14789 | |
---|
| 14790 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14791 | + |
---|
13234 | 14792 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
13235 | 14793 | prevY = Y = anchorY; |
---|
13236 | 14794 | } |
---|
.. | .. |
---|
13240 | 14798 | int X, Y; |
---|
13241 | 14799 | boolean SX, SY; |
---|
13242 | 14800 | |
---|
13243 | | - void drag(int x, int y, int modifiers) |
---|
| 14801 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13244 | 14802 | { |
---|
13245 | 14803 | if (IsFrozen()) |
---|
13246 | 14804 | { |
---|
.. | .. |
---|
13249 | 14807 | |
---|
13250 | 14808 | drag = true; // NEW |
---|
13251 | 14809 | |
---|
13252 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14810 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13253 | 14811 | |
---|
13254 | 14812 | X = x; |
---|
13255 | 14813 | Y = y; |
---|
13256 | 14814 | // floating state for animation |
---|
13257 | | - MODIFIERS = modifiers; |
---|
13258 | | - modifiers &= ~1024; |
---|
| 14815 | + MODIFIERS = modifiersex; |
---|
| 14816 | + modifiersex &= ~1024; |
---|
13259 | 14817 | if (false) // modifiers != 0) |
---|
13260 | 14818 | { |
---|
13261 | 14819 | //new Exception().printStackTrace(); |
---|
13262 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14820 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13263 | 14821 | System.out.println("SHIFT = " + SHIFT); |
---|
13264 | 14822 | System.out.println("CONTROL = " + COMMAND); |
---|
13265 | 14823 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13272 | 14830 | if (editObj) |
---|
13273 | 14831 | { |
---|
13274 | 14832 | drag = true; |
---|
13275 | | - ClickInfo info = new ClickInfo(); |
---|
13276 | | - info.bounds.setBounds(0, 0, |
---|
| 14833 | + //ClickInfo info = new ClickInfo(); |
---|
| 14834 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
13277 | 14835 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13278 | | - info.pane = this; |
---|
13279 | | - info.camera = renderCamera; |
---|
13280 | | - info.x = x; |
---|
13281 | | - info.y = y; |
---|
13282 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14836 | + object.clickInfo.pane = this; |
---|
| 14837 | + object.clickInfo.camera = renderCamera; |
---|
| 14838 | + object.clickInfo.x = x; |
---|
| 14839 | + object.clickInfo.y = y; |
---|
| 14840 | + object //.GetWindow().copy |
---|
| 14841 | + .doEditDrag(//info, |
---|
| 14842 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13283 | 14843 | } else |
---|
13284 | 14844 | { |
---|
13285 | 14845 | if (x < startX) |
---|
.. | .. |
---|
13428 | 14988 | } |
---|
13429 | 14989 | } |
---|
13430 | 14990 | |
---|
| 14991 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14992 | + |
---|
13431 | 14993 | public void mouseMoved(MouseEvent e) |
---|
13432 | 14994 | { |
---|
13433 | 14995 | //System.out.println("mouseMoved: " + e); |
---|
13434 | | - |
---|
13435 | 14996 | if (isRenderer) |
---|
13436 | 14997 | return; |
---|
13437 | 14998 | |
---|
13438 | | - ClickInfo ci = new ClickInfo(); |
---|
13439 | | - ci.x = e.getX(); |
---|
13440 | | - ci.y = e.getY(); |
---|
13441 | | - ci.modifiers = e.getModifiersEx(); |
---|
13442 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13443 | | - ci.pane = this; |
---|
13444 | | - ci.camera = renderCamera; |
---|
| 14999 | + // Mouse cursor feedback |
---|
| 15000 | + object.clickInfo.x = e.getX(); |
---|
| 15001 | + object.clickInfo.y = e.getY(); |
---|
| 15002 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15003 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15004 | + object.clickInfo.pane = this; |
---|
| 15005 | + object.clickInfo.camera = renderCamera; |
---|
13445 | 15006 | if (!isRenderer) |
---|
13446 | 15007 | { |
---|
13447 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 15008 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15009 | + //Object3D copy = editWindow.copy; |
---|
| 15010 | + if (object.doEditClick(//clickInfo, |
---|
| 15011 | + 0)) |
---|
13448 | 15012 | { |
---|
13449 | 15013 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
13450 | 15014 | } else |
---|
.. | .. |
---|
13456 | 15020 | |
---|
13457 | 15021 | public void mouseReleased(MouseEvent e) |
---|
13458 | 15022 | { |
---|
| 15023 | + Globals.MOUSEDRAGGED = false; |
---|
| 15024 | + |
---|
13459 | 15025 | movingcamera = false; |
---|
| 15026 | + X = 0; // getBounds().width/2; |
---|
| 15027 | + Y = 0; // getBounds().height/2; |
---|
13460 | 15028 | //System.out.println("mouseReleased: " + e); |
---|
13461 | 15029 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13462 | 15030 | } |
---|
.. | .. |
---|
13479 | 15047 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13480 | 15048 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13481 | 15049 | |
---|
13482 | | - if (control || command || IsFrozen()) |
---|
| 15050 | +// No delay if (control || command || IsFrozen()) |
---|
13483 | 15051 | timeout = true; |
---|
13484 | | - else |
---|
| 15052 | +// ?? May 2019 else |
---|
13485 | 15053 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13486 | 15054 | mouseDown = false; |
---|
13487 | 15055 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
13591 | 15159 | System.out.println("keyReleased: " + e); |
---|
13592 | 15160 | } |
---|
13593 | 15161 | |
---|
13594 | | - void SetMouseMode(int modifiers) |
---|
| 15162 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
13595 | 15163 | { |
---|
13596 | 15164 | //System.out.println("SetMouseMode = " + modifiers); |
---|
13597 | 15165 | //modifiers &= ~1024; |
---|
.. | .. |
---|
13603 | 15171 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
13604 | 15172 | // return; |
---|
13605 | 15173 | //System.out.println("SetMode = " + modifiers); |
---|
13606 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15174 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
13607 | 15175 | { |
---|
13608 | 15176 | mouseMode |= ZOOM; |
---|
13609 | 15177 | } |
---|
13610 | 15178 | |
---|
13611 | 15179 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13612 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15180 | + if (capsLocked) // || (modifiers & META) == META) |
---|
13613 | 15181 | { |
---|
13614 | 15182 | mouseMode |= VR; // BACKFORTH; |
---|
13615 | 15183 | } |
---|
13616 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15184 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
13617 | 15185 | { |
---|
13618 | 15186 | mouseMode |= SELECT; |
---|
13619 | 15187 | } |
---|
13620 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15188 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
13621 | 15189 | { |
---|
13622 | 15190 | mouseMode |= SELECT; |
---|
13623 | 15191 | } |
---|
13624 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15192 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
13625 | 15193 | { |
---|
13626 | 15194 | mouseMode &= ~VR; |
---|
13627 | 15195 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
13650 | 15218 | |
---|
13651 | 15219 | if (isRenderer) // |
---|
13652 | 15220 | { |
---|
13653 | | - SetMouseMode(modifiers); |
---|
| 15221 | + SetMouseMode(0, modifiers); |
---|
13654 | 15222 | } |
---|
13655 | 15223 | |
---|
13656 | | - theRenderer.keyPressed(key); |
---|
| 15224 | + Globals.theRenderer.keyPressed(key); |
---|
13657 | 15225 | } |
---|
13658 | 15226 | |
---|
13659 | 15227 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13665 | 15233 | float SATPOW = 1; // 2; // 0.5f; |
---|
13666 | 15234 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13667 | 15235 | |
---|
13668 | | - void keyPressed(int key) |
---|
| 15236 | + public void keyPressed(int key) |
---|
13669 | 15237 | { |
---|
13670 | 15238 | if (key >= '0' && key <= '5') |
---|
13671 | 15239 | clampbit = (key-'0'); |
---|
.. | .. |
---|
13712 | 15280 | // break; |
---|
13713 | 15281 | case 'T': |
---|
13714 | 15282 | CACHETEXTURE ^= true; |
---|
13715 | | - textures.clear(); |
---|
| 15283 | + texturepigment.clear(); |
---|
| 15284 | + texturebump.clear(); |
---|
13716 | 15285 | // repaint(); |
---|
13717 | 15286 | break; |
---|
13718 | 15287 | case 'Y': |
---|
.. | .. |
---|
13722 | 15291 | case 'K': |
---|
13723 | 15292 | KOMPACTTEXTURE ^= true; |
---|
13724 | 15293 | //textures.clear(); |
---|
13725 | | - break; |
---|
13726 | | - case 'P': // Texture Projection macros |
---|
| 15294 | + // break; |
---|
| 15295 | + //case 'P': // Texture Projection macros |
---|
13727 | 15296 | // SAVETEXTURE ^= true; |
---|
13728 | 15297 | macromode = true; |
---|
13729 | 15298 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
13797 | 15366 | case 'E' : COMPACT ^= true; |
---|
13798 | 15367 | repaint(); |
---|
13799 | 15368 | break; |
---|
13800 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15369 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15370 | + //DEBUGHSB ^= true; |
---|
| 15371 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
13801 | 15372 | repaint(); |
---|
13802 | 15373 | break; |
---|
13803 | 15374 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
13822 | 15393 | RevertCamera(); |
---|
13823 | 15394 | repaint(); |
---|
13824 | 15395 | break; |
---|
13825 | | - case 'L': |
---|
13826 | 15396 | case 'l': |
---|
| 15397 | + //case 'L': |
---|
13827 | 15398 | if (lightMode) |
---|
13828 | 15399 | { |
---|
13829 | 15400 | lightMode = false; |
---|
.. | .. |
---|
13842 | 15413 | targetLookAt.set(manipCamera.lookAt); |
---|
13843 | 15414 | repaint(); |
---|
13844 | 15415 | break; |
---|
13845 | | - case 'p': |
---|
| 15416 | + case 'P': // p': |
---|
13846 | 15417 | // c'est quoi ca au juste? spherical ^= true; |
---|
13847 | 15418 | Skinshader ^= true; programInitialized = false; |
---|
13848 | 15419 | repaint(); |
---|
.. | .. |
---|
13887 | 15458 | OCCLUSION_CULLING ^= true; |
---|
13888 | 15459 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
13889 | 15460 | break; |
---|
13890 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15461 | + //case '0': envyoff ^= true; repaint(); break; |
---|
13891 | 15462 | case '1': |
---|
13892 | 15463 | case '2': |
---|
13893 | 15464 | case '3': |
---|
13894 | 15465 | case '4': |
---|
13895 | 15466 | case '5': |
---|
13896 | | - newenvy = Character.getNumericValue(key); |
---|
13897 | | - repaint(); |
---|
13898 | | - break; |
---|
13899 | 15467 | case '6': |
---|
13900 | 15468 | case '7': |
---|
13901 | 15469 | case '8': |
---|
13902 | 15470 | case '9': |
---|
13903 | | - BGcolor = (key - '6')/3.f; |
---|
| 15471 | + if (true) // envyoff) |
---|
| 15472 | + { |
---|
| 15473 | + BGcolor = (key - '1')/8.f; |
---|
| 15474 | + } |
---|
| 15475 | + else |
---|
| 15476 | + { |
---|
| 15477 | + //newenvy = Character.getNumericValue(key); |
---|
| 15478 | + } |
---|
13904 | 15479 | repaint(); |
---|
13905 | 15480 | break; |
---|
13906 | 15481 | case '!': |
---|
.. | .. |
---|
13966 | 15541 | case '_': |
---|
13967 | 15542 | kompactbit = 5; |
---|
13968 | 15543 | break; |
---|
13969 | | - case '+': |
---|
13970 | | - kompactbit = 6; |
---|
13971 | | - break; |
---|
| 15544 | +// case '+': |
---|
| 15545 | +// kompactbit = 6; |
---|
| 15546 | +// break; |
---|
13972 | 15547 | case ' ': |
---|
13973 | 15548 | lightMode ^= true; |
---|
13974 | 15549 | Globals.lighttouched = true; |
---|
.. | .. |
---|
13980 | 15555 | case ESC: |
---|
13981 | 15556 | RENDERPROGRAM += 1; |
---|
13982 | 15557 | RENDERPROGRAM %= 3; |
---|
| 15558 | + |
---|
13983 | 15559 | repaint(); |
---|
13984 | 15560 | break; |
---|
13985 | 15561 | case 'Z': |
---|
13986 | 15562 | //RESIZETEXTURE ^= true; |
---|
13987 | 15563 | //break; |
---|
13988 | 15564 | case 'z': |
---|
13989 | | - RENDERSHADOW ^= true; |
---|
| 15565 | + Globals.RENDERSHADOW ^= true; |
---|
13990 | 15566 | Globals.lighttouched = true; |
---|
13991 | 15567 | repaint(); |
---|
13992 | 15568 | break; |
---|
.. | .. |
---|
14019 | 15595 | case DELETE: |
---|
14020 | 15596 | ClearSelection(); |
---|
14021 | 15597 | break; |
---|
14022 | | - /* |
---|
14023 | 15598 | case '+': |
---|
| 15599 | + |
---|
| 15600 | + /* |
---|
14024 | 15601 | //fontsize += 1; |
---|
14025 | 15602 | bbzoom *= 2; |
---|
14026 | 15603 | repaint(); |
---|
.. | .. |
---|
14037 | 15614 | case '=': |
---|
14038 | 15615 | IncDepth(); |
---|
14039 | 15616 | //fontsize += 1; |
---|
14040 | | - object.editWindow.refreshContents(true); |
---|
| 15617 | + object.GetWindow().refreshContents(true); |
---|
14041 | 15618 | maskbit = 6; |
---|
14042 | 15619 | break; |
---|
14043 | 15620 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14044 | 15621 | DecDepth(); |
---|
14045 | 15622 | maskbit = 5; |
---|
14046 | 15623 | //if(fontsize > 1) fontsize -= 1; |
---|
14047 | | - if (object.editWindow == null) |
---|
14048 | | - new Exception().printStackTrace(); |
---|
14049 | | - else |
---|
14050 | | - object.editWindow.refreshContents(true); |
---|
| 15624 | +// if (object.editWindow == null) |
---|
| 15625 | +// new Exception().printStackTrace(); |
---|
| 15626 | +// else |
---|
| 15627 | + object.GetWindow().refreshContents(true); |
---|
14051 | 15628 | break; |
---|
14052 | 15629 | case '{': |
---|
14053 | 15630 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14102 | 15679 | } |
---|
14103 | 15680 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14104 | 15681 | } |
---|
| 15682 | + |
---|
14105 | 15683 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14106 | 15684 | |
---|
14107 | 15685 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14109 | 15687 | //mode = ROTATE; |
---|
14110 | 15688 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14111 | 15689 | { |
---|
14112 | | - SetMouseMode(modifiers); |
---|
| 15690 | + SetMouseMode(0, modifiers); |
---|
14113 | 15691 | } |
---|
14114 | 15692 | } |
---|
14115 | 15693 | |
---|
14116 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 15694 | + public void processKeyEvent(KeyEvent e) |
---|
14117 | 15695 | { |
---|
14118 | 15696 | switch (e.getID()) |
---|
14119 | 15697 | { |
---|
.. | .. |
---|
14243 | 15821 | |
---|
14244 | 15822 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14245 | 15823 | { |
---|
14246 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14247 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15824 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15825 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15826 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14248 | 15827 | { |
---|
14249 | 15828 | mouseMoved(e); |
---|
14250 | 15829 | } else |
---|
.. | .. |
---|
14269 | 15848 | } |
---|
14270 | 15849 | */ |
---|
14271 | 15850 | |
---|
14272 | | - object.editWindow.EditSelection(); |
---|
| 15851 | + object.GetWindow().EditSelection(false); |
---|
14273 | 15852 | } |
---|
14274 | 15853 | |
---|
14275 | 15854 | void SelectParent() |
---|
14276 | 15855 | { |
---|
| 15856 | + new Exception().printStackTrace(); |
---|
14277 | 15857 | System.exit(0); |
---|
14278 | 15858 | Composite group = (Composite) object; |
---|
14279 | 15859 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14285 | 15865 | { |
---|
14286 | 15866 | //selectees.remove(i); |
---|
14287 | 15867 | System.out.println("select parent of " + elem); |
---|
14288 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15868 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
14289 | 15869 | } else |
---|
14290 | 15870 | { |
---|
14291 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15871 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14292 | 15872 | } |
---|
14293 | 15873 | |
---|
14294 | 15874 | first = false; |
---|
.. | .. |
---|
14297 | 15877 | |
---|
14298 | 15878 | void SelectChildren() |
---|
14299 | 15879 | { |
---|
| 15880 | + new Exception().printStackTrace(); |
---|
14300 | 15881 | System.exit(0); |
---|
14301 | 15882 | /* |
---|
14302 | 15883 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14329 | 15910 | for (int j = 0; j < group.children.size(); j++) |
---|
14330 | 15911 | { |
---|
14331 | 15912 | elem = (Object3D) group.children.elementAt(j); |
---|
14332 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15913 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14333 | 15914 | first = false; |
---|
14334 | 15915 | } |
---|
14335 | 15916 | } else |
---|
14336 | 15917 | { |
---|
14337 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15918 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
14338 | 15919 | } |
---|
14339 | 15920 | |
---|
14340 | 15921 | first = false; |
---|
.. | .. |
---|
14345 | 15926 | { |
---|
14346 | 15927 | //Composite group = (Composite) object; |
---|
14347 | 15928 | Object3D group = object; |
---|
14348 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15929 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
14349 | 15930 | } |
---|
14350 | 15931 | |
---|
14351 | 15932 | void ResetTransform(int mask) |
---|
14352 | 15933 | { |
---|
14353 | 15934 | //Composite group = (Composite) object; |
---|
14354 | 15935 | Object3D group = object; |
---|
14355 | | - group.editWindow.ResetTransform(mask); |
---|
| 15936 | + group.GetWindow().ResetTransform(mask); |
---|
14356 | 15937 | } |
---|
14357 | 15938 | |
---|
14358 | 15939 | void FlipTransform() |
---|
14359 | 15940 | { |
---|
14360 | 15941 | //Composite group = (Composite) object; |
---|
14361 | 15942 | Object3D group = object; |
---|
14362 | | - group.editWindow.FlipTransform(); |
---|
| 15943 | + group.GetWindow().FlipTransform(); |
---|
14363 | 15944 | // group.editWindow.ReduceMesh(true); |
---|
14364 | 15945 | } |
---|
14365 | 15946 | |
---|
.. | .. |
---|
14367 | 15948 | { |
---|
14368 | 15949 | //Composite group = (Composite) object; |
---|
14369 | 15950 | Object3D group = object; |
---|
14370 | | - group.editWindow.PrintMemory(); |
---|
| 15951 | + group.GetWindow().PrintMemory(); |
---|
14371 | 15952 | // group.editWindow.ReduceMesh(true); |
---|
14372 | 15953 | } |
---|
14373 | 15954 | |
---|
.. | .. |
---|
14375 | 15956 | { |
---|
14376 | 15957 | //Composite group = (Composite) object; |
---|
14377 | 15958 | Object3D group = object; |
---|
14378 | | - group.editWindow.ResetCentroid(); |
---|
| 15959 | + group.GetWindow().ResetCentroid(); |
---|
14379 | 15960 | } |
---|
14380 | 15961 | |
---|
14381 | 15962 | void IncDepth() |
---|
.. | .. |
---|
14457 | 16038 | |
---|
14458 | 16039 | int width = getBounds().width; |
---|
14459 | 16040 | int height = getBounds().height; |
---|
14460 | | - ClickInfo info = new ClickInfo(); |
---|
14461 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14462 | 16041 | //Image img = CreateImage(width, height); |
---|
14463 | 16042 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 16043 | + |
---|
14464 | 16044 | Graphics gr = g; // img.getGraphics(); |
---|
| 16045 | + |
---|
14465 | 16046 | if (!hasMarquee) |
---|
14466 | 16047 | { |
---|
14467 | 16048 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
14533 | 16114 | } |
---|
14534 | 16115 | if (object != null && !hasMarquee) |
---|
14535 | 16116 | { |
---|
| 16117 | + if (object.clickInfo == null) |
---|
| 16118 | + object.clickInfo = new ClickInfo(); |
---|
| 16119 | + ClickInfo info = object.clickInfo; |
---|
| 16120 | + //ClickInfo info = new ClickInfo(); |
---|
| 16121 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16122 | + |
---|
14536 | 16123 | if (isRenderer) |
---|
14537 | 16124 | { |
---|
14538 | | - info.flags++; |
---|
| 16125 | + object.clickInfo.flags++; |
---|
14539 | 16126 | double frameAspect = (double) width / (double) height; |
---|
14540 | 16127 | if (frameAspect > renderCamera.aspect) |
---|
14541 | 16128 | { |
---|
14542 | 16129 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
14543 | | - info.bounds.width -= width - desired; |
---|
14544 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16130 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16131 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
14545 | 16132 | } else |
---|
14546 | 16133 | { |
---|
14547 | 16134 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
14548 | | - info.bounds.height -= height - desired; |
---|
14549 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16135 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16136 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
14550 | 16137 | } |
---|
14551 | 16138 | } |
---|
14552 | | - info.g = gr; |
---|
14553 | | - info.camera = renderCamera; |
---|
| 16139 | + |
---|
| 16140 | + object.clickInfo.g = gr; |
---|
| 16141 | + object.clickInfo.camera = renderCamera; |
---|
14554 | 16142 | /* |
---|
14555 | 16143 | // Memory intensive (brep.verticescopy) |
---|
14556 | 16144 | if (!(object instanceof Composite)) |
---|
14557 | 16145 | object.draw(info, 0, false); // SLOW : |
---|
14558 | 16146 | */ |
---|
14559 | | - if (!isRenderer) |
---|
| 16147 | + if (!isRenderer) // && drag) |
---|
14560 | 16148 | { |
---|
14561 | | - object.drawEditHandles(info, 0); |
---|
| 16149 | + Grafreed.Assert(object != null); |
---|
| 16150 | + Grafreed.Assert(object.selection != null); |
---|
| 16151 | + if (object.selection.Size() > 0) |
---|
| 16152 | + { |
---|
| 16153 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16154 | + |
---|
| 16155 | + object.clickInfo.DX = 0; |
---|
| 16156 | + object.clickInfo.DY = 0; |
---|
| 16157 | + object.clickInfo.W = 1; |
---|
| 16158 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16159 | + { |
---|
| 16160 | + info.DX = X; |
---|
| 16161 | + if (X != 0) |
---|
| 16162 | + info.DX -= info.bounds.width/2; |
---|
| 16163 | + |
---|
| 16164 | + info.DY = Y; |
---|
| 16165 | + if (Y != 0) |
---|
| 16166 | + info.DY -= info.bounds.height/2; |
---|
| 16167 | + } |
---|
| 16168 | + |
---|
| 16169 | + object.drawEditHandles(//info, |
---|
| 16170 | + 0); |
---|
| 16171 | + |
---|
| 16172 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16173 | + { |
---|
| 16174 | + switch (hitSomething) |
---|
| 16175 | + { |
---|
| 16176 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16177 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16178 | + break; |
---|
| 16179 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16180 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16181 | + break; |
---|
| 16182 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16183 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16184 | + break; |
---|
| 16185 | + } |
---|
| 16186 | + |
---|
| 16187 | + } |
---|
| 16188 | + } |
---|
14562 | 16189 | } |
---|
14563 | 16190 | } |
---|
| 16191 | + |
---|
14564 | 16192 | if (isRenderer) |
---|
14565 | 16193 | { |
---|
14566 | 16194 | //gr.setColor(Color.black); |
---|
14567 | 16195 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
14568 | 16196 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
14569 | 16197 | } |
---|
| 16198 | + |
---|
14570 | 16199 | if (hasMarquee) |
---|
14571 | 16200 | { |
---|
14572 | 16201 | gr.setXORMode(Color.white); |
---|
14573 | | - gr.setColor(Color.red); |
---|
| 16202 | + gr.setColor(Color.white); |
---|
14574 | 16203 | if (!firstime) |
---|
14575 | 16204 | { |
---|
14576 | 16205 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
14679 | 16308 | public boolean mouseDown(Event evt, int x, int y) |
---|
14680 | 16309 | { |
---|
14681 | 16310 | System.out.println("mouseDown: " + evt); |
---|
| 16311 | + System.exit(0); |
---|
14682 | 16312 | /* |
---|
14683 | 16313 | locked = true; |
---|
14684 | 16314 | drag = false; |
---|
.. | .. |
---|
14722 | 16352 | { |
---|
14723 | 16353 | keyPressed(0, modifiers); |
---|
14724 | 16354 | } |
---|
14725 | | - clickStart(x, y, modifiers); |
---|
| 16355 | + // clickStart(x, y, modifiers); |
---|
14726 | 16356 | return true; |
---|
14727 | 16357 | } |
---|
14728 | 16358 | |
---|
.. | .. |
---|
14840 | 16470 | { |
---|
14841 | 16471 | keyReleased(0, 0); |
---|
14842 | 16472 | } |
---|
14843 | | - drag(x, y, modifiers); |
---|
| 16473 | + drag(x, y, 0, modifiers); |
---|
14844 | 16474 | return true; |
---|
14845 | 16475 | } |
---|
14846 | 16476 | |
---|
.. | .. |
---|
14972 | 16602 | Object3D object; |
---|
14973 | 16603 | static Object3D trackedobject; |
---|
14974 | 16604 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
14975 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16605 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
14976 | 16606 | /*static*/ Camera eyeCamera; |
---|
14977 | 16607 | /*static*/ Camera lightCamera; |
---|
14978 | 16608 | int cameracount; |
---|
.. | .. |
---|
15036 | 16666 | private /*static*/ boolean firstime; |
---|
15037 | 16667 | private /*static*/ cVector newView = new cVector(); |
---|
15038 | 16668 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16669 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16670 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15039 | 16671 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15040 | 16672 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15041 | 16673 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15048 | 16680 | { |
---|
15049 | 16681 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15050 | 16682 | |
---|
| 16683 | + int usedsuf = 0; |
---|
| 16684 | + |
---|
15051 | 16685 | for (int i = 0; i < suffixes.length; i++) |
---|
15052 | 16686 | { |
---|
15053 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15054 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15055 | | - mipmapped, |
---|
15056 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15057 | | - if (data == null) |
---|
| 16687 | + String[] suffixe = suffixes; |
---|
| 16688 | + String[] fallback = suffixes2; |
---|
| 16689 | + String[] fallfallback = suffixes3; |
---|
| 16690 | + |
---|
| 16691 | + for (int c=usedsuf; --c>=0;) |
---|
15058 | 16692 | { |
---|
15059 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16693 | +// String[] temp = suffixe; |
---|
| 16694 | +// suffixe = fallback; |
---|
| 16695 | +// fallback = fallfallback; |
---|
| 16696 | +// fallfallback = temp; |
---|
15060 | 16697 | } |
---|
| 16698 | + |
---|
| 16699 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16700 | + TextureData data; |
---|
| 16701 | + |
---|
| 16702 | + try |
---|
| 16703 | + { |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e) |
---|
| 16709 | + { |
---|
| 16710 | + try |
---|
| 16711 | + { |
---|
| 16712 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16713 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16714 | + mipmapped, |
---|
| 16715 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16716 | + } |
---|
| 16717 | + catch (Exception e2) |
---|
| 16718 | + { |
---|
| 16719 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16720 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16721 | + mipmapped, |
---|
| 16722 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16723 | + } |
---|
| 16724 | + } |
---|
| 16725 | + |
---|
15061 | 16726 | //System.out.println("Target = " + targets[i]); |
---|
15062 | 16727 | cubemap.updateImage(data, targets[i]); |
---|
15063 | 16728 | } |
---|
15064 | 16729 | |
---|
15065 | 16730 | return cubemap; |
---|
15066 | 16731 | } |
---|
| 16732 | + |
---|
15067 | 16733 | int bigsphere = -1; |
---|
15068 | 16734 | |
---|
15069 | 16735 | float BGcolor = 0.5f; |
---|
15070 | 16736 | |
---|
15071 | | - private void DrawSkyBox(GL gl) |
---|
| 16737 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16738 | + |
---|
| 16739 | + private void DrawSkyBox(GL gl, float ratio) |
---|
15072 | 16740 | { |
---|
15073 | | - if (envyoff || cubemap == null) |
---|
| 16741 | + if (//envyoff || |
---|
| 16742 | + WIREFRAME || |
---|
| 16743 | + cubemap == null) |
---|
15074 | 16744 | { |
---|
15075 | 16745 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
15076 | 16746 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
15085 | 16755 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
15086 | 16756 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
15087 | 16757 | gl.glLoadIdentity(); |
---|
| 16758 | + gl.glScalef(1,ratio,1); |
---|
15088 | 16759 | |
---|
| 16760 | +// colorV[0] = 2; |
---|
| 16761 | +// colorV[1] = 2; |
---|
| 16762 | +// colorV[2] = 2; |
---|
| 16763 | +// colorV[3] = 1; |
---|
| 16764 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16765 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16766 | +// |
---|
| 16767 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16768 | + |
---|
15089 | 16769 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
15090 | 16770 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
15091 | 16771 | |
---|
.. | .. |
---|
15117 | 16797 | { |
---|
15118 | 16798 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
15119 | 16799 | } |
---|
| 16800 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
15120 | 16801 | gl.glMultMatrixd(viewrot_1, 0); |
---|
15121 | 16802 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
15122 | 16803 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
15157 | 16838 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
15158 | 16839 | |
---|
15159 | 16840 | cubemap.disable(); |
---|
15160 | | - ////cubemap.unbind(); |
---|
| 16841 | + //cubemap.dispose(); |
---|
| 16842 | + |
---|
15161 | 16843 | if (CULLFACE) |
---|
15162 | 16844 | { |
---|
15163 | 16845 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
15257 | 16939 | cStatic.objectstack[materialdepth++] = checker; |
---|
15258 | 16940 | //System.out.println("material " + material); |
---|
15259 | 16941 | //Applet3D.tracein(this, selected); |
---|
15260 | | - vector2buffer = checker.projectedVertices; |
---|
| 16942 | + //vector2buffer = checker.projectedVertices; |
---|
15261 | 16943 | |
---|
15262 | 16944 | //checker.GetMaterial().Draw(this, false); // true); |
---|
15263 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16945 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
15264 | 16946 | |
---|
15265 | 16947 | materialdepth -= 1; |
---|
15266 | 16948 | if (materialdepth > 0) |
---|
15267 | 16949 | { |
---|
15268 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
15269 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16950 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16951 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
15270 | 16952 | } |
---|
15271 | 16953 | //checker.GetMaterial().opacity = 1f; |
---|
15272 | 16954 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
15352 | 17034 | } |
---|
15353 | 17035 | } |
---|
15354 | 17036 | |
---|
| 17037 | + private Object3D GetFolder() |
---|
| 17038 | + { |
---|
| 17039 | + Object3D folder = object.GetWindow().copy; |
---|
| 17040 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17041 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17042 | + return folder; |
---|
| 17043 | + } |
---|
| 17044 | + |
---|
15355 | 17045 | class SelectBuffer implements GLEventListener |
---|
15356 | 17046 | { |
---|
15357 | 17047 | |
---|
.. | .. |
---|
15367 | 17057 | //new Exception().printStackTrace(); |
---|
15368 | 17058 | System.out.println("select buffer init"); |
---|
15369 | 17059 | // Use debug pipeline |
---|
15370 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17060 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
15371 | 17061 | |
---|
15372 | 17062 | GL gl = drawable.getGL(); |
---|
15373 | 17063 | |
---|
.. | .. |
---|
15410 | 17100 | { |
---|
15411 | 17101 | if (!selection) |
---|
15412 | 17102 | { |
---|
| 17103 | + new Exception().printStackTrace(); |
---|
15413 | 17104 | System.exit(0); |
---|
15414 | 17105 | return; |
---|
15415 | 17106 | } |
---|
.. | .. |
---|
15430 | 17121 | |
---|
15431 | 17122 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
15432 | 17123 | |
---|
| 17124 | + if (PAINTMODE) |
---|
| 17125 | + { |
---|
| 17126 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17127 | + { |
---|
| 17128 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17129 | + |
---|
| 17130 | + // Make what you paint not selectable. |
---|
| 17131 | + paintobj.ResetSelectable(); |
---|
| 17132 | + } |
---|
| 17133 | + } |
---|
| 17134 | + |
---|
15433 | 17135 | //int tmp = selection_view; |
---|
15434 | 17136 | //selection_view = -1; |
---|
15435 | 17137 | int temp = DrawMode(); |
---|
.. | .. |
---|
15441 | 17143 | // temp = DEFAULT; // patch for selection debug |
---|
15442 | 17144 | Globals.drawMode = temp; // WARNING |
---|
15443 | 17145 | |
---|
| 17146 | + if (PAINTMODE) |
---|
| 17147 | + { |
---|
| 17148 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17149 | + { |
---|
| 17150 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17151 | + |
---|
| 17152 | + // Revert. |
---|
| 17153 | + paintobj.RestoreSelectable(); |
---|
| 17154 | + } |
---|
| 17155 | + } |
---|
| 17156 | + |
---|
15444 | 17157 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
15445 | 17158 | |
---|
15446 | 17159 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
15488 | 17201 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
15489 | 17202 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
15490 | 17203 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17204 | + |
---|
| 17205 | + CreateSelectedPoint(); |
---|
15491 | 17206 | |
---|
15492 | 17207 | // Will fit the mesh !!! |
---|
15493 | 17208 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
15537 | 17252 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
15538 | 17253 | } |
---|
15539 | 17254 | |
---|
15540 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17255 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
15541 | 17256 | } |
---|
15542 | 17257 | } |
---|
15543 | 17258 | |
---|
15544 | 17259 | if (!movingcamera && !PAINTMODE) |
---|
15545 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17260 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
15546 | 17261 | |
---|
15547 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17262 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
15548 | 17263 | { |
---|
15549 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17264 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
15550 | 17265 | |
---|
15551 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17266 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17267 | + { |
---|
| 17268 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
15552 | 17269 | |
---|
15553 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
15554 | | - |
---|
15555 | | - group.add(paintobj); // link |
---|
15556 | | - |
---|
15557 | | - object.editWindow.SnapObject(group); |
---|
15558 | | - |
---|
15559 | | - Object3D folder = object.editWindow.copy; |
---|
15560 | | - |
---|
15561 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
15562 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
15563 | | - |
---|
15564 | | - folder.add(group); |
---|
15565 | | - |
---|
15566 | | - object.editWindow.ResetModel(); |
---|
15567 | | - object.editWindow.refreshContents(); |
---|
| 17270 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17271 | + |
---|
| 17272 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17273 | + |
---|
| 17274 | + inst.add(paintobj); // link |
---|
| 17275 | + |
---|
| 17276 | + object.GetWindow().SnapObject(inst); |
---|
| 17277 | + |
---|
| 17278 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17279 | + |
---|
| 17280 | + folder.add(inst); |
---|
| 17281 | + |
---|
| 17282 | + object.GetWindow().ResetModel(); |
---|
| 17283 | + object.GetWindow().refreshContents(); |
---|
| 17284 | + } |
---|
15568 | 17285 | } |
---|
15569 | 17286 | else |
---|
15570 | 17287 | paintcount = 0; |
---|
.. | .. |
---|
15603 | 17320 | //System.out.println("objects[color] = " + objects[color]); |
---|
15604 | 17321 | //objects[color].Select(); |
---|
15605 | 17322 | indexcount = 0; |
---|
| 17323 | + ObjEditor window = object.GetWindow(); |
---|
| 17324 | + if (window != null && deselect) |
---|
| 17325 | + { |
---|
| 17326 | + window.Select(null, deselect, true); |
---|
| 17327 | + } |
---|
15606 | 17328 | object.Select(color, deselect); |
---|
15607 | 17329 | } |
---|
15608 | 17330 | |
---|
.. | .. |
---|
15653 | 17375 | |
---|
15654 | 17376 | public void init(GLAutoDrawable drawable) |
---|
15655 | 17377 | { |
---|
| 17378 | + if (Globals.DEBUG) |
---|
15656 | 17379 | System.out.println("shadow buffer init"); |
---|
15657 | 17380 | |
---|
15658 | 17381 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
15702 | 17425 | gl.glDisable(gl.GL_CULL_FACE); |
---|
15703 | 17426 | } |
---|
15704 | 17427 | |
---|
15705 | | - if (!RENDERSHADOW) |
---|
| 17428 | + if (!Globals.RENDERSHADOW) |
---|
15706 | 17429 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15707 | 17430 | |
---|
15708 | 17431 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
15712 | 17435 | //gl.glColorMask(false, false, false, false); |
---|
15713 | 17436 | |
---|
15714 | 17437 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
15715 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17438 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
15716 | 17439 | { |
---|
15717 | 17440 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
15718 | 17441 | |
---|
.. | .. |
---|
15772 | 17495 | |
---|
15773 | 17496 | class AntialiasBuffer implements GLEventListener |
---|
15774 | 17497 | { |
---|
15775 | | - |
---|
15776 | 17498 | CameraPane parent = null; |
---|
15777 | 17499 | |
---|
15778 | 17500 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
15882 | 17604 | gl.glFlush(); |
---|
15883 | 17605 | |
---|
15884 | 17606 | /**/ |
---|
15885 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17607 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
15886 | 17608 | |
---|
15887 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17609 | + float[] depths = occlusiondepthbuffer.array(); |
---|
15888 | 17610 | |
---|
| 17611 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17612 | + |
---|
| 17613 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17614 | + |
---|
15889 | 17615 | double r = 0, g = 0, b = 0; |
---|
15890 | 17616 | |
---|
15891 | 17617 | double count = 0; |
---|
.. | .. |
---|
15896 | 17622 | |
---|
15897 | 17623 | double FACTOR = 1; |
---|
15898 | 17624 | |
---|
15899 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17625 | + for (int i = 0; i < depths.length; i++) |
---|
15900 | 17626 | { |
---|
15901 | 17627 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
15902 | 17628 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
15979 | 17705 | |
---|
15980 | 17706 | double scale = ray.z; // 1; // cos |
---|
15981 | 17707 | |
---|
15982 | | - float depth = pixels[newindex]; |
---|
| 17708 | + float depth = depths[newindex]; |
---|
15983 | 17709 | |
---|
15984 | 17710 | /* |
---|
15985 | 17711 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
16129 | 17855 | int AAbuffersize = 0; |
---|
16130 | 17856 | |
---|
16131 | 17857 | //double[] selectedpoint = new double[3]; |
---|
16132 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17858 | + static Superellipsoid selectedpoint; |
---|
16133 | 17859 | static Sphere previousselectedpoint = null; |
---|
16134 | | - static Sphere debugpointG = new Sphere(); |
---|
16135 | | - static Sphere debugpointP = new Sphere(); |
---|
16136 | | - static Sphere debugpointC = new Sphere(); |
---|
16137 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17860 | + static Sphere debugpointG; |
---|
| 17861 | + static Sphere debugpointP; |
---|
| 17862 | + static Sphere debugpointC; |
---|
| 17863 | + static Sphere debugpointR; |
---|
16138 | 17864 | |
---|
16139 | 17865 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16140 | 17866 | |
---|
16141 | | - static |
---|
16142 | | - { |
---|
16143 | | - for (int i=0; i<8; i++) |
---|
16144 | | - { |
---|
16145 | | - debugpoints[i] = new Sphere(); |
---|
16146 | | - } |
---|
16147 | | - } |
---|
16148 | | - |
---|
16149 | 17867 | static void InitPoints(float radius) |
---|
16150 | 17868 | { |
---|
16151 | 17869 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
16165 | 17883 | } |
---|
16166 | 17884 | } |
---|
16167 | 17885 | |
---|
16168 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17886 | + static void DrawPoints(iCameraPane cpane) |
---|
16169 | 17887 | { |
---|
16170 | 17888 | for (int i=0; i<8; i++) // first and last are red |
---|
16171 | 17889 | { |
---|
.. | .. |
---|
16184 | 17902 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
16185 | 17903 | static IntBuffer bigAAbuffer; |
---|
16186 | 17904 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
16187 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17905 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
16188 | 17906 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
16189 | 17907 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
16190 | 17908 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
16191 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17909 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17910 | + |
---|
| 17911 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17912 | + |
---|
16192 | 17913 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
16193 | 17914 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
16194 | 17915 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|
.. | .. |
---|
16197 | 17918 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16198 | 17919 | // Depth buffer format |
---|
16199 | 17920 | //private int depth_format; |
---|
16200 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17921 | + |
---|
| 17922 | + public void NextIndex() |
---|
16201 | 17923 | { |
---|
16202 | 17924 | indexcount+=16; |
---|
16203 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17925 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16204 | 17926 | //objects[indexcount] = o; |
---|
16205 | 17927 | //System.out.println("indexcount = " + indexcount); |
---|
16206 | 17928 | } |
---|