Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
CameraPane.java
....@@ -31,9 +31,12 @@
3131
3232 import gleem.linalg.Mat4f;
3333
34
-class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
34
+class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3535 {
36
- static boolean DEBUG = false;
36
+ static cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3740 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3841
3942 // camera change fix
....@@ -42,25 +45,40 @@
4245
4346 static int STEP = 1;
4447
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
48
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
5149 {
52
- return LIVE || ONESTEP;
50
+ int[] pixels = new int[bytes.length/3];
51
+ for (int i=pixels.length; --i>=0;)
52
+ {
53
+ int i3 = i*3;
54
+ pixels[i] = 0xFF;
55
+ pixels[i] <<= 8;
56
+ pixels[i] |= bytes[i3+2] & 0xFF;
57
+ pixels[i] <<= 8;
58
+ pixels[i] |= bytes[i3+1] & 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3] & 0xFF;
61
+ }
62
+ /*
63
+ int r=0,g=0,b=0,a=0;
64
+ for (int i=0; i<width; i++)
65
+ for (int j=0; j<height; j++)
66
+ {
67
+ int index = j*width+i;
68
+ int p = pixels[index];
69
+ a = ((p>>24) & 0xFF);
70
+ r = ((p>>16) & 0xFF);
71
+ g = ((p>>8) & 0xFF);
72
+ b = (p & 0xFF);
73
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
74
+ }
75
+ /**/
76
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
77
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
78
+ return rendImage;
5379 }
5480
55
- /**
56
- * @param aLIVE the LIVE to set
57
- */
58
- public static void setLIVE(boolean aLIVE)
59
- {
60
- LIVE = aLIVE;
61
- }
62
-
63
- /*static*/ boolean CULLFACE = false; // true;
81
+ /*static*/ private boolean CULLFACE = false; // true;
6482 /*static*/ boolean NEAREST = false; // true;
6583 /*static*/ boolean WIREFRAME = false; // true;
6684
....@@ -70,14 +88,12 @@
7088 static int CURRENTANTIALIAS = 0; // 1;
7189 /*static*/ boolean RENDERSHADOW = true;
7290 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
73
- static boolean ANIMATION = false;
74
- static String filename;
7591
7692 boolean DISPLAYTEXT = false;
7793 //boolean REDUCETEXTURE = true;
7894 boolean CACHETEXTURE = true;
7995 boolean CLEANCACHE = false; // true;
80
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
8197 boolean COMPRESSTEXTURE = false;
8298 boolean KOMPACTTEXTURE = false; // true;
8399 boolean RESIZETEXTURE = false;
....@@ -97,10 +113,8 @@
97113
98114 static boolean textureon = true;
99115 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
101116 static boolean FULLSCREEN = false;
102117 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
104118 static boolean INERTIA = true;
105119 static boolean FAST = false;
106120 static boolean SLOWPOSE = false;
....@@ -108,6 +122,8 @@
108122
109123 static int tickcount = 0; // slow pose issue
110124
125
+static boolean BUTTONLESSWHEEL = false;
126
+static boolean ZOOMBOXMODE = false;
111127 static boolean BOXMODE = false;
112128 static boolean IMAGEFLIP = false;
113129 static boolean SMOOTHFOCUS = false;
....@@ -122,7 +138,7 @@
122138 static boolean OEIL = true;
123139 static boolean OEILONCE = false; // do oeilon then oeiloff
124140 static boolean LOOKAT = true;
125
-static boolean RANDOM = true; // false;
141
+static boolean SWITCH = true; // false;
126142 static boolean HANDLES = false; // selection doesn't work!!
127143 static boolean PAINTMODE = false;
128144
....@@ -165,12 +181,13 @@
165181 defaultcaps.setAccumBlueBits(16);
166182 defaultcaps.setAccumAlphaBits(16);
167183 }
168
- static CameraPane theRenderer;
169
-
184
+
185
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
186
+
170187 void SetAsGLRenderer(boolean b)
171188 {
172189 isRenderer = b;
173
- theRenderer = this;
190
+ Globals.theRenderer = this;
174191 }
175192
176193 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -206,12 +223,53 @@
206223 return CURRENTANTIALIAS > 0;
207224 }
208225
209
- void ClearDepth()
226
+ /// INTERFACE
227
+
228
+ public javax.media.opengl.GL GetGL0()
229
+ {
230
+ return null;
231
+ }
232
+
233
+ public int GenList()
234
+ {
235
+ javax.media.opengl.GL gl = GetGL();
236
+ return gl.glGenLists(1);
237
+ }
238
+
239
+ public void NewList(int id)
240
+ {
241
+ javax.media.opengl.GL gl = GetGL();
242
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
243
+ }
244
+
245
+ public void CallList(int id)
246
+ {
247
+ javax.media.opengl.GL gl = GetGL();
248
+ gl.glCallList(id);
249
+ }
250
+
251
+ public void EndList()
252
+ {
253
+ javax.media.opengl.GL gl = GetGL();
254
+ gl.glEndList();
255
+ }
256
+
257
+ public boolean IsBoxMode()
258
+ {
259
+ return BOXMODE;
260
+ }
261
+
262
+ public boolean IsZoomBoxMode()
263
+ {
264
+ return ZOOMBOXMODE;
265
+ }
266
+
267
+ public void ClearDepth()
210268 {
211269 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
212270 }
213271
214
- void DepthTest(boolean depthtest)
272
+ public void DepthTest(boolean depthtest)
215273 {
216274 if (depthtest)
217275 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -219,7 +277,7 @@
219277 GetGL().glDepthFunc(GL.GL_ALWAYS);
220278 }
221279
222
- void DepthWrite(boolean depthwrite)
280
+ public void DepthWrite(boolean depthwrite)
223281 {
224282 if (depthwrite)
225283 GetGL().glDepthMask(true);
....@@ -227,12 +285,1616 @@
227285 GetGL().glDepthMask(false);
228286 }
229287
230
- void BackFaceCull(boolean bfc)
288
+ public void BackFaceCull(boolean bfc)
231289 {
232290 if (bfc)
233291 GetGL().glEnable(GetGL().GL_CULL_FACE);
234292 else
235293 GetGL().glDisable(GetGL().GL_CULL_FACE);
294
+ }
295
+
296
+ public boolean BackFaceCullMode()
297
+ {
298
+ return this.CULLFACE;
299
+ }
300
+
301
+ public boolean IsAmbientOcclusionOn()
302
+ {
303
+ return this.ambientOcclusion;
304
+ }
305
+
306
+ public boolean IsDebugSelection()
307
+ {
308
+ return DEBUG_SELECTION;
309
+ }
310
+
311
+ public boolean IsFrozen()
312
+ {
313
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
314
+
315
+ return !selectmode && cameracount == 0; // != 0;
316
+ }
317
+
318
+ // Currently in Globals
319
+ public int DrawMode()
320
+ {
321
+ return Globals.DrawMode();
322
+ }
323
+
324
+ public Camera EyeCamera()
325
+ {
326
+ return eyeCamera;
327
+ }
328
+
329
+ public Camera LightCamera()
330
+ {
331
+ return lightCamera;
332
+ }
333
+
334
+ public Camera ManipCamera()
335
+ {
336
+ return manipCamera;
337
+ }
338
+
339
+ public Camera RenderCamera()
340
+ {
341
+ return renderCamera;
342
+ }
343
+
344
+ public Camera[] Cameras()
345
+ {
346
+ return cameras;
347
+ }
348
+
349
+ public void PushMaterial(Object3D obj, boolean selected)
350
+ {
351
+ CameraPane display = this;
352
+ javax.media.opengl.GL gl = display.GetGL();
353
+ cMaterial material = obj.material;
354
+
355
+ if (material != null)
356
+ {
357
+ materialstack[materialdepth] = material;
358
+ selectedstack[materialdepth] = selected;
359
+ cStatic.objectstack[materialdepth++] = obj;
360
+ //System.out.println("material " + material);
361
+ //Applet3D.tracein(this, selected);
362
+ //display.vector2buffer = obj.projectedVertices;
363
+ if (obj instanceof Camera)
364
+ {
365
+ display.options1[0] = material.shift;
366
+ //System.out.println("shift " + material.shift);
367
+ display.options1[1] = material.lightarea;
368
+ display.options1[2] = material.shadowbias;
369
+ display.options1[3] = material.aniso;
370
+ display.options1[4] = material.anisoV;
371
+// System.out.println("display.options1[0] " + display.options1[0]);
372
+// System.out.println("display.options1[1] " + display.options1[1]);
373
+// System.out.println("display.options1[2] " + display.options1[2]);
374
+// System.out.println("display.options1[3] " + display.options1[3]);
375
+// System.out.println("display.options1[4] " + display.options1[4]);
376
+ display.options2[0] = material.opacity;
377
+ display.options2[1] = material.diffuse;
378
+ display.options2[2] = material.factor;
379
+// System.out.println("display.options2[0] " + display.options2[0]);
380
+// System.out.println("display.options2[1] " + display.options2[1]);
381
+// System.out.println("display.options2[2] " + display.options2[2]);
382
+
383
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
384
+// System.out.println("display.options3[0] " + display.options3[0]);
385
+// System.out.println("display.options3[1] " + display.options3[1]);
386
+// System.out.println("display.options3[2] " + display.options3[2]);
387
+ display.options4[0] = material.cameralight/0.2f;
388
+ display.options4[1] = material.subsurface;
389
+ display.options4[2] = material.sheen;
390
+// System.out.println("display.options4[0] " + display.options4[0]);
391
+// System.out.println("display.options4[1] " + display.options4[1]);
392
+// System.out.println("display.options4[2] " + display.options4[2]);
393
+
394
+ // if (display.CURRENTANTIALIAS > 0)
395
+ // display.options3[3] /= 4;
396
+
397
+ /*
398
+ System.out.println("Focus = " + display.options1[0]);
399
+ System.out.println("Aperture = " + display.options1[1]);
400
+ System.out.println("ShadowBlur = " + display.options1[2]);
401
+ System.out.println("Antialiasing = " + display.options1[3]);
402
+ System.out.println("Fog = " + display.options2[0]);
403
+ System.out.println("Intensity = " + display.options2[1]);
404
+ System.out.println("Elevation = " + display.options2[2]);
405
+ /**/
406
+ } else
407
+ {
408
+ DrawMaterial(material, selected, obj.projectedVertices);
409
+ }
410
+ } else
411
+ {
412
+ if (selected && CameraPane.flash)
413
+ {
414
+ display.modelParams4[1] = 100;
415
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
416
+ }
417
+ }
418
+ }
419
+
420
+ public void PushMaterial2(Object3D obj, boolean selected)
421
+ {
422
+ CameraPane display = this;
423
+ cMaterial material = obj.material;
424
+
425
+ if (material != null)
426
+ {
427
+ materialstack[materialdepth] = material;
428
+ selectedstack[materialdepth] = selected;
429
+ cStatic.objectstack[materialdepth++] = obj;
430
+ //System.out.println("material " + material);
431
+ //Applet3D.tracein("selected ", selected);
432
+ //display.vector2buffer = obj.projectedVertices;
433
+ display.DrawMaterial(material, selected, obj.projectedVertices);
434
+ }
435
+ }
436
+
437
+ public void PopMaterial(Object3D obj, boolean selected)
438
+ {
439
+ CameraPane display = this;
440
+ javax.media.opengl.GL gl = display.GetGL();
441
+ cMaterial material = obj.material;
442
+
443
+ //if (parent != null && parent.GetMaterial() != null)
444
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
445
+ if (material != null)
446
+ {
447
+ materialdepth -= 1;
448
+ if (materialdepth > 0)
449
+ {
450
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
451
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
452
+ }
453
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
454
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
455
+ {
456
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
457
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
458
+ }
459
+ }
460
+
461
+ public void PopMaterial2(Object3D obj)
462
+ {
463
+ CameraPane display = this;
464
+ cMaterial material = obj.material;
465
+
466
+ if (material != null)
467
+ {
468
+ materialdepth -= 1;
469
+ if (materialdepth > 0)
470
+ {
471
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
472
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
473
+ }
474
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
475
+ //else
476
+ //material.Draw(display, false);
477
+ }
478
+ }
479
+
480
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
481
+ {
482
+ CameraPane display = this;
483
+
484
+ if (pv.y == -10000 ||
485
+ qv.y == -10000 ||
486
+ rv.y == -10000)
487
+ return;
488
+
489
+// float b = f.nbiterations & 1;
490
+// float g = (f.nbiterations>>1) & 1;
491
+// float r = (f.nbiterations>>2) & 1;
492
+//
493
+// //if (f.weight == 10000)
494
+// //{
495
+// // r = 1; g = b = 0;
496
+// //}
497
+// //else
498
+// //{
499
+// // assert(f.weight < 10000);
500
+// r = g = b = (float)bRep.FaceWeight(f)*100;
501
+// if (r<0)
502
+// assert(r>=0);
503
+// //}
504
+
505
+ javax.media.opengl.GL gl = display.GetGL();
506
+
507
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
508
+
509
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
510
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
511
+ {
512
+ //gl.glBegin(gl.GL_TRIANGLES);
513
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
514
+ // TEST LIVE NORMALS && !obj.dontselect
515
+ ;
516
+ if (!hasnorm)
517
+ {
518
+ // System.out.println("Mesh normal");
519
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
520
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
521
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
522
+ LA.vecNormalize(obj.v2);
523
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
524
+ }
525
+
526
+ // P
527
+ float x = (float)pv.x;
528
+ float y = (float)pv.y;
529
+ float z = (float)pv.z;
530
+
531
+ if (hasnorm)
532
+ {
533
+// if (!pv.norm.normalized())
534
+// assert(pv.norm.normalized());
535
+
536
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
537
+ float nx = (float)pv.norm.x;
538
+ float ny = (float)pv.norm.y;
539
+ float nz = (float)pv.norm.z;
540
+
541
+ x += nx * obj.NORMALPUSH;
542
+ y += ny * obj.NORMALPUSH;
543
+ z += nz * obj.NORMALPUSH;
544
+
545
+ gl.glNormal3f(nx, ny, nz);
546
+ }
547
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
548
+ SetColor(obj, pv);
549
+ //gl.glColor4f(r, g, b, 1);
550
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
551
+ if (obj.flipV)
552
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
553
+ else
554
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
555
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
556
+
557
+ gl.glVertex3f(x, y, z);
558
+
559
+ // Q
560
+ x = (float)qv.x;
561
+ y = (float)qv.y;
562
+ z = (float)qv.z;
563
+
564
+// Print(pv);
565
+ if (hasnorm)
566
+ {
567
+// assert(qv.norm.normalized());
568
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
569
+ float nx = (float)qv.norm.x;
570
+ float ny = (float)qv.norm.y;
571
+ float nz = (float)qv.norm.z;
572
+
573
+ x += nx * obj.NORMALPUSH;
574
+ y += ny * obj.NORMALPUSH;
575
+ z += nz * obj.NORMALPUSH;
576
+
577
+ gl.glNormal3f(nx, ny, nz);
578
+ }
579
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
580
+ // boolean locked = false;
581
+ // float eps = 0.1f;
582
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
583
+
584
+ // int dot = 0; //*/ (int)f.dot;
585
+
586
+ // if ((dot&1) == 0)
587
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
588
+
589
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
590
+ if (obj.flipV)
591
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
592
+ else
593
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
594
+ // else
595
+ // {
596
+ // locked = true;
597
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
598
+ // }
599
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
600
+ SetColor(obj, qv);
601
+
602
+ gl.glVertex3f(x, y, z);
603
+ //gl.glColor4f(r, g, b, 1);
604
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
605
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
606
+// Print(qv);
607
+
608
+ // R
609
+ x = (float)rv.x;
610
+ y = (float)rv.y;
611
+ z = (float)rv.z;
612
+
613
+ if (hasnorm)
614
+ {
615
+// assert(rv.norm.normalized());
616
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
617
+ float nx = (float)rv.norm.x;
618
+ float ny = (float)rv.norm.y;
619
+ float nz = (float)rv.norm.z;
620
+
621
+ x += nx * obj.NORMALPUSH;
622
+ y += ny * obj.NORMALPUSH;
623
+ z += nz * obj.NORMALPUSH;
624
+
625
+ gl.glNormal3f(nx, ny, nz);
626
+ }
627
+
628
+ // if ((dot&4) == 0)
629
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
630
+
631
+ // if (wrap || !locked && (dot&8) != 0)
632
+ if (obj.flipV)
633
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
634
+ else
635
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
636
+ // else
637
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
638
+
639
+ // f.dot = dot;
640
+
641
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
642
+ SetColor(obj, rv);
643
+ //gl.glColor4f(r, g, b, 1);
644
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
645
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
646
+ gl.glVertex3f(x, y, z);
647
+// Print(rv);
648
+ //gl.glEnd();
649
+ }
650
+ else
651
+ {
652
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
653
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
654
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
655
+
656
+ }
657
+
658
+ if (false) // (attributes & WIREFRAME) != 0)
659
+ {
660
+ gl.glDisable(gl.GL_LIGHTING);
661
+
662
+ gl.glBegin(gl.GL_LINE_LOOP);
663
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
664
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
665
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
666
+ gl.glEnd();
667
+
668
+ gl.glEnable(gl.GL_LIGHTING);
669
+ }
670
+ }
671
+
672
+ /**
673
+ * <code>draw</code> renders a <code>TriMesh</code> object including
674
+ * it's normals, colors, textures and vertices.
675
+ *
676
+ * @see Renderer#draw(TriMesh)
677
+ * @param tris
678
+ * the mesh to render.
679
+ */
680
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
681
+ {
682
+ CameraPane display = this;
683
+
684
+ float r = display.modelParams0[0];
685
+ float g = display.modelParams0[1];
686
+ float b = display.modelParams0[2];
687
+ float opacity = display.modelParams5[1];
688
+
689
+ //final GL gl = GLU.getCurrentGL();
690
+ GL gl = display.GetGL(); // getGL();
691
+
692
+ FloatBuffer vertBuf = geo.vertBuf;
693
+
694
+ int v = vertBuf.capacity();
695
+
696
+ int count = 0;
697
+
698
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
699
+ gl.glEnable(gl.GL_CULL_FACE);
700
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
701
+ for (int i=0; i<v/3; i++)
702
+ {
703
+ int index3 = i*3;
704
+
705
+ if (geo.sizeBuf.get(index3+1) == 0)
706
+ continue;
707
+
708
+ count++;
709
+
710
+ int index4 = i*4;
711
+
712
+ float tx = vertBuf.get(index3);
713
+ float ty = vertBuf.get(index3+1);
714
+ float tz = vertBuf.get(index3+2);
715
+
716
+ // if (tx == 0 && ty == 0 && tz == 0)
717
+ // continue;
718
+
719
+ gl.glMatrixMode(gl.GL_TEXTURE);
720
+ gl.glPushMatrix();
721
+
722
+ float[] texmat = geo.texmat;
723
+ texmat[12] = texmat[13] = texmat[14] = i;
724
+
725
+ gl.glMultMatrixf(texmat, 0);
726
+
727
+ gl.glMatrixMode(gl.GL_MODELVIEW);
728
+ gl.glPushMatrix();
729
+
730
+ gl.glTranslatef(tx,ty,tz);
731
+
732
+ if (rotate)
733
+ gl.glRotatef(i, 0, 1, 0);
734
+
735
+ float size = geo.sizeBuf.get(index3) / 100;
736
+ gl.glScalef(size,size,size);
737
+
738
+ float cr = geo.colorBuf.get(index4);
739
+ float cg = geo.colorBuf.get(index4+1);
740
+ float cb = geo.colorBuf.get(index4+2);
741
+ float ca = geo.colorBuf.get(index4+3);
742
+
743
+ display.modelParams0[0] = r * cr;
744
+ display.modelParams0[1] = g * cg;
745
+ display.modelParams0[2] = b * cb;
746
+
747
+ display.modelParams5[1] = opacity * ca;
748
+
749
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
750
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
751
+
752
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
753
+ RandomNode.globalseed2 = RandomNode.globalseed;
754
+
755
+// gl.glColor4f(cr,cg,cb,ca);
756
+ // gl.glScalef(1024/16,1024/16,1024/16);
757
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
758
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
759
+ //gl.glTranslatef(-tx,-ty,-tz);
760
+ gl.glPopMatrix();
761
+
762
+ gl.glMatrixMode(gl.GL_TEXTURE);
763
+ gl.glPopMatrix();
764
+ }
765
+ // gl.glScalef(1024,1024,1024);
766
+ if (!cf)
767
+ gl.glDisable(gl.GL_CULL_FACE);
768
+
769
+ display.modelParams0[0] = r;
770
+ display.modelParams0[1] = g;
771
+ display.modelParams0[2] = b;
772
+
773
+ display.modelParams5[1] = opacity;
774
+
775
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
776
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
777
+
778
+ gl.glMatrixMode(gl.GL_MODELVIEW);
779
+
780
+// System.err.println("total = " + v/3 + "; displayed = " + count);
781
+ if (true)
782
+ return;
783
+
784
+//// if (!tris.predraw(this))
785
+//// {
786
+//// return;
787
+//// }
788
+//// if (Debug.stats)
789
+//// {
790
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
791
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
792
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
793
+//// }
794
+////
795
+//// if (tris.getDisplayListID() != -1)
796
+//// {
797
+//// renderDisplayList(tris);
798
+//// return;
799
+//// }
800
+////
801
+//// if (!generatingDisplayList)
802
+//// {
803
+//// applyStates(tris.states, tris);
804
+//// }
805
+//// if (Debug.stats)
806
+//// {
807
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
808
+//// }
809
+//// boolean transformed = doTransforms(tris);
810
+//
811
+// int glMode = GL.GL_TRIANGLES;
812
+// switch (getMode())
813
+// {
814
+// case Triangles:
815
+// glMode = GL.GL_TRIANGLES;
816
+// break;
817
+// case Strip:
818
+// glMode = GL.GL_TRIANGLE_STRIP;
819
+// break;
820
+// case Fan:
821
+// glMode = GL.GL_TRIANGLE_FAN;
822
+// break;
823
+// }
824
+//
825
+// if (!predrawGeometry(gl))
826
+// {
827
+// // make sure only the necessary indices are sent through on old
828
+// // cards.
829
+// IntBuffer indices = this.getIndexBuffer();
830
+// if (indices == null)
831
+// {
832
+// logger.severe("missing indices on geometry object: " + this.toString());
833
+// } else
834
+// {
835
+// indices.rewind();
836
+// indices.limit(this.getMaxIndex());
837
+//
838
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
839
+//
840
+// indices.clear();
841
+// }
842
+// } else
843
+// {
844
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
845
+// GL.GL_UNSIGNED_INT, 0);
846
+// }
847
+//
848
+//// postdrawGeometry(tris);
849
+//// if (transformed)
850
+//// {
851
+//// undoTransforms(tris);
852
+//// }
853
+////
854
+//// if (Debug.stats)
855
+//// {
856
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
857
+//// }
858
+//// tris.postdraw(this);
859
+ }
860
+
861
+ static Camera localcamera = new Camera();
862
+ static cVector from = new cVector();
863
+ static cVector to = new cVector();
864
+
865
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
866
+ {
867
+ CameraPane cp = this;
868
+
869
+ Camera keep = cp.RenderCamera();
870
+ cp.renderCamera = localcamera;
871
+
872
+ if (br.trimmed)
873
+ {
874
+ float[] colors = new float[br.positions.length / 3];
875
+
876
+ int i3 = 0;
877
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
878
+ {
879
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
880
+ continue;
881
+
882
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
883
+ to.set(br.positions[i3] + br.normals[i3],
884
+ br.positions[i3 + 1] + br.normals[i3 + 1],
885
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
886
+ LA.xformPos(from, transform, from);
887
+ LA.xformPos(to, transform, to); // RIGID ONLY
888
+ localcamera.setAim(from, to);
889
+
890
+ CameraPane.occlusionbuffer.display();
891
+
892
+ if (CameraPane.DEBUG_OCCLUSION)
893
+ cp.display(); // debug
894
+
895
+ colors[i] = cp.vertexOcclusion.r;
896
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
897
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
898
+
899
+ if ((i % 100) == 0 && i != 0)
900
+ {
901
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
902
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
903
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
904
+ }
905
+ }
906
+
907
+ br.colors = colors;
908
+ }
909
+ else
910
+ {
911
+ for (int i = 0; i < br.VertexCount(); i++)
912
+ {
913
+ Vertex v = br.GetVertex(i);
914
+
915
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
916
+ continue;
917
+
918
+ from.set(v.x, v.y, v.z);
919
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
920
+ LA.xformPos(from, transform, from);
921
+ LA.xformPos(to, transform, to); // RIGID ONLY
922
+ localcamera.setAim(from, to);
923
+
924
+ CameraPane.occlusionbuffer.display();
925
+
926
+ if (CameraPane.DEBUG_OCCLUSION)
927
+ cp.display(); // debug
928
+
929
+ v.AO = cp.vertexOcclusion.r;
930
+
931
+ if ((i % 100) == 0 && i != 0)
932
+ {
933
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
934
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
935
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
936
+ }
937
+ }
938
+ }
939
+
940
+ //System.out.println("done.");
941
+
942
+ cp.renderCamera = keep;
943
+ }
944
+
945
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
946
+ {
947
+ CameraPane display = this;
948
+ pointFlow.CreateHT();
949
+
950
+ float r = display.modelParams0[0];
951
+ float g = display.modelParams0[1];
952
+ float b = display.modelParams0[2];
953
+ float opacity = display.modelParams5[1];
954
+
955
+ //final GL gl = GLU.getCurrentGL();
956
+ GL gl = display.GetGL(); // getGL();
957
+
958
+ int s = pointFlow.points.size();
959
+
960
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
961
+ gl.glEnable(gl.GL_CULL_FACE);
962
+
963
+ for (int i=s; --i>=0;)
964
+ //for (int i=0; i<s; i++)
965
+ {
966
+ cVector v = pointFlow.points.get(i);
967
+
968
+ double mindist = Double.MAX_VALUE;
969
+
970
+ double size = pointFlow.minimumSize;
971
+
972
+ double distancenext = 0;
973
+
974
+ if (i > 0)
975
+ {
976
+ cVector w = pointFlow.points.get(i-1);
977
+
978
+ double dist = w.distance(v);
979
+
980
+ distancenext = dist;
981
+
982
+ if (mindist > dist)
983
+ {
984
+ mindist = dist;
985
+ size = mindist*pointFlow.resizefactor;
986
+ }
987
+ }
988
+
989
+ if (i < s-1)
990
+ {
991
+ cVector w = pointFlow.points.get(i+1);
992
+
993
+ double dist = w.distance(v);
994
+
995
+ if (mindist > dist)
996
+ {
997
+ mindist = dist;
998
+ size = mindist*pointFlow.resizefactor;
999
+ }
1000
+ }
1001
+
1002
+ if (size < pointFlow.minimumSize)
1003
+ size = pointFlow.minimumSize;
1004
+ if (size > pointFlow.maximumSize)
1005
+ size = pointFlow.maximumSize;
1006
+
1007
+ double tx = v.x;
1008
+ double ty = v.y;
1009
+ double tz = v.z;
1010
+
1011
+ // if (tx == 0 && ty == 0 && tz == 0)
1012
+ // continue;
1013
+
1014
+ gl.glMatrixMode(gl.GL_TEXTURE);
1015
+ gl.glPushMatrix();
1016
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
1017
+
1018
+ gl.glMultMatrixf(pointFlow.texmat, 0);
1019
+
1020
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1021
+ gl.glPushMatrix();
1022
+
1023
+ gl.glTranslated(tx,ty,tz);
1024
+
1025
+ gl.glScaled(size,size,size);
1026
+
1027
+// float cr = colorBuf.get(index4);
1028
+// float cg = colorBuf.get(index4+1);
1029
+// float cb = colorBuf.get(index4+2);
1030
+// float ca = colorBuf.get(index4+3);
1031
+//
1032
+// display.modelParams0[0] = r * cr;
1033
+// display.modelParams0[1] = g * cg;
1034
+// display.modelParams0[2] = b * cb;
1035
+//
1036
+// display.modelParams5[1] = opacity * ca;
1037
+//
1038
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1039
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1040
+//
1041
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
1042
+// RandomNode.globalseed2 = RandomNode.globalseed;
1043
+//
1044
+//// gl.glColor4f(cr,cg,cb,ca);
1045
+// // gl.glScalef(1024/16,1024/16,1024/16);
1046
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
1047
+
1048
+ gl.glPopMatrix();
1049
+
1050
+ double step = size/4; //
1051
+
1052
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1053
+ continue;
1054
+
1055
+ int nbsteps = (int)(distancenext/step);
1056
+
1057
+ step = distancenext/nbsteps;
1058
+
1059
+ cVector next = pointFlow.points.get(i-1);
1060
+
1061
+ tmp.set(next);
1062
+ tmp.sub(v);
1063
+ tmp.normalize();
1064
+ tmp.mul(step);
1065
+
1066
+ // calculate next size
1067
+ mindist = Double.MAX_VALUE;
1068
+
1069
+ double nextsize = pointFlow.minimumSize;
1070
+
1071
+ if (i > 1)
1072
+ {
1073
+ cVector w = pointFlow.points.get(i-2);
1074
+
1075
+ double dist = w.distance(next);
1076
+
1077
+ if (mindist > dist)
1078
+ {
1079
+ mindist = dist;
1080
+ nextsize = mindist*pointFlow.resizefactor;
1081
+ }
1082
+ }
1083
+
1084
+ double dist = v.distance(next);
1085
+
1086
+ if (mindist > dist)
1087
+ {
1088
+ mindist = dist;
1089
+ nextsize = mindist*pointFlow.resizefactor;
1090
+ }
1091
+
1092
+ if (nextsize < pointFlow.minimumSize)
1093
+ nextsize = pointFlow.minimumSize;
1094
+ if (nextsize > pointFlow.maximumSize)
1095
+ nextsize = pointFlow.maximumSize;
1096
+ //
1097
+
1098
+ double count = 0;
1099
+
1100
+ while (distancenext > 0.000000001) // step
1101
+ {
1102
+ gl.glPushMatrix();
1103
+
1104
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1105
+
1106
+ double K = count/nbsteps;
1107
+
1108
+ double intersize = K*nextsize + (1-K)*size;
1109
+
1110
+ gl.glScaled(intersize,intersize,intersize);
1111
+
1112
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1113
+
1114
+ count++;
1115
+
1116
+ distancenext -= step;
1117
+
1118
+ gl.glPopMatrix();
1119
+ }
1120
+
1121
+ if (count != nbsteps)
1122
+ assert(count == nbsteps);
1123
+
1124
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1125
+ //gl.glTranslatef(-tx,-ty,-tz);
1126
+
1127
+ gl.glMatrixMode(gl.GL_TEXTURE);
1128
+ gl.glPopMatrix();
1129
+ }
1130
+
1131
+ if (!cf)
1132
+ gl.glDisable(gl.GL_CULL_FACE);
1133
+
1134
+// display.modelParams0[0] = r;
1135
+// display.modelParams0[1] = g;
1136
+// display.modelParams0[2] = b;
1137
+//
1138
+// display.modelParams5[1] = opacity;
1139
+//
1140
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1141
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1142
+
1143
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1144
+ }
1145
+
1146
+ public void DrawBox(cVector min, cVector max)
1147
+ {
1148
+ javax.media.opengl.GL gl = GetGL();
1149
+ gl.glBegin(gl.GL_LINES);
1150
+
1151
+ gl.glVertex3d(min.x, min.y, min.z);
1152
+ gl.glVertex3d(min.x, min.y, max.z);
1153
+ gl.glVertex3d(min.x, min.y, min.z);
1154
+ gl.glVertex3d(min.x, max.y, min.z);
1155
+ gl.glVertex3d(min.x, min.y, min.z);
1156
+ gl.glVertex3d(max.x, min.y, min.z);
1157
+
1158
+ gl.glVertex3d(max.x, max.y, max.z);
1159
+ gl.glVertex3d(min.x, max.y, max.z);
1160
+ gl.glVertex3d(max.x, max.y, max.z);
1161
+ gl.glVertex3d(max.x, min.y, max.z);
1162
+ gl.glVertex3d(max.x, max.y, max.z);
1163
+ gl.glVertex3d(max.x, max.y, min.z);
1164
+
1165
+ gl.glEnd();
1166
+ }
1167
+
1168
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1169
+ {
1170
+ int[] strips = bRep.getRawIndices();
1171
+
1172
+ javax.media.opengl.GL gl = GetGL();
1173
+
1174
+ // TRIANGLE STRIP ARRAY
1175
+ if (bRep.trimmed)
1176
+ {
1177
+ float[] v = bRep.getRawVertices();
1178
+ float[] n = bRep.getRawNormals();
1179
+ float[] c = bRep.getRawColors();
1180
+ float[] uv = bRep.getRawUVMap();
1181
+
1182
+ int count2 = 0;
1183
+ int count3 = 0;
1184
+
1185
+ if (n.length > 0)
1186
+ {
1187
+ for (int i = 0; i < strips.length; i++)
1188
+ {
1189
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1190
+
1191
+ /*
1192
+ boolean locked = false;
1193
+ float eps = 0.1f;
1194
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1195
+
1196
+ int dot = 0;
1197
+
1198
+ if ((dot&1) == 0)
1199
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1200
+
1201
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1202
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1203
+ else
1204
+ {
1205
+ locked = true;
1206
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1207
+ }
1208
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1209
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1210
+ if (hasnorm)
1211
+ {
1212
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1213
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1214
+ }
1215
+
1216
+ if ((dot&4) == 0)
1217
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1218
+
1219
+ if (wrap || !locked && (dot&8) != 0)
1220
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1221
+ else
1222
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1223
+
1224
+ f.dot = dot;
1225
+ */
1226
+
1227
+ if (!selectmode)
1228
+ {
1229
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1230
+ {
1231
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1232
+ } else
1233
+ {
1234
+ gl.glNormal3f(0, 0, 1);
1235
+ }
1236
+
1237
+ if (c != null)
1238
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1239
+ {
1240
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1241
+ }
1242
+ }
1243
+
1244
+ if (flipV)
1245
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1246
+ else
1247
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1248
+
1249
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1250
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1251
+
1252
+ count2 += 2;
1253
+ count3 += 3;
1254
+ if (!selectmode)
1255
+ {
1256
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1257
+ {
1258
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1259
+ } else
1260
+ {
1261
+ gl.glNormal3f(0, 0, 1);
1262
+ }
1263
+ if (c != null)
1264
+ {
1265
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1266
+ }
1267
+ }
1268
+
1269
+ if (flipV)
1270
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1271
+ else
1272
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1273
+
1274
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1275
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1276
+
1277
+ count2 += 2;
1278
+ count3 += 3;
1279
+ for (int j = 0; j < strips[i] - 2; j++)
1280
+ {
1281
+ //gl.glTexCoord2d(...);
1282
+ if (!selectmode)
1283
+ {
1284
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1285
+ {
1286
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1287
+ } else
1288
+ {
1289
+ gl.glNormal3f(0, 0, 1);
1290
+ }
1291
+ if (c != null)
1292
+ {
1293
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1294
+ }
1295
+ }
1296
+
1297
+ if (flipV)
1298
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1299
+ else
1300
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1301
+
1302
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1303
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1304
+
1305
+ count2 += 2;
1306
+ count3 += 3;
1307
+ }
1308
+
1309
+ gl.glEnd();
1310
+ }
1311
+ }
1312
+
1313
+ assert count3 == v.length;
1314
+ }
1315
+ else // !trimmed
1316
+ {
1317
+ int count = 0;
1318
+ for (int i = 0; i < strips.length; i++)
1319
+ {
1320
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1321
+
1322
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1323
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1324
+
1325
+ drawVertex(gl, p, flipV, selectmode);
1326
+ drawVertex(gl, q, flipV, selectmode);
1327
+
1328
+ for (int j = 0; j < strips[i] - 2; j++)
1329
+ {
1330
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1331
+
1332
+ // if (j%2 == 0)
1333
+ // drawFace(p, q, r, display, null);
1334
+ // else
1335
+ // drawFace(p, r, q, display, null);
1336
+
1337
+ // p = q;
1338
+ // q = r;
1339
+ drawVertex(gl, r, flipV, selectmode);
1340
+ }
1341
+
1342
+ gl.glEnd();
1343
+ }
1344
+ }
1345
+ }
1346
+
1347
+ static cSpring.Point3D temp = new cSpring.Point3D();
1348
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1349
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1350
+
1351
+ public void DrawDynamicMesh(cMesh mesh)
1352
+ {
1353
+ GL gl = GetGL(); // getGL();
1354
+
1355
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1356
+
1357
+ gl.glDisable(gl.GL_LIGHTING);
1358
+
1359
+ gl.glLineWidth(1);
1360
+ gl.glColor3f(1,1,1);
1361
+ gl.glBegin(gl.GL_LINES);
1362
+ double scale = 0;
1363
+ int count = 0;
1364
+ for (int s=0; s<Phys.allSprings.size(); s++)
1365
+ {
1366
+ cSpring.Spring spring = Phys.allSprings.get(s);
1367
+ if(s == 0)
1368
+ {
1369
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1370
+ }
1371
+ if (mesh.showsprings)
1372
+ {
1373
+ temp.set(spring.a.position);
1374
+ temp.add(spring.b.position);
1375
+ temp.mul(0.5);
1376
+ temp2.set(spring.a.position);
1377
+ temp2.sub(spring.b.position);
1378
+ temp2.mul(spring.restLength/2);
1379
+ temp.sub(temp2);
1380
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1381
+ temp.add(temp2);
1382
+ temp.add(temp2);
1383
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1384
+ }
1385
+
1386
+ if (spring.isHandle)
1387
+ continue;
1388
+
1389
+ //if (scale < spring.restLength)
1390
+ scale += spring.restLength;
1391
+ count++;
1392
+ }
1393
+ gl.glEnd();
1394
+
1395
+ if (count == 0)
1396
+ scale = 0.01;
1397
+ else
1398
+ scale /= count * 3;
1399
+
1400
+ //scale = 0.25;
1401
+
1402
+ if (mesh.ShowInfo())
1403
+ {
1404
+ gl.glLineWidth(4);
1405
+ for (int s=0; s<Phys.allNodes.size(); s++)
1406
+ {
1407
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1408
+ if (node.mass == 0)
1409
+ continue;
1410
+
1411
+ int i = node.springs==null?-1:node.springs.size();
1412
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1413
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1414
+ //temp.normalize();
1415
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1416
+ gl.glBegin(gl.GL_LINES);
1417
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1418
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1419
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1420
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1421
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1422
+ gl.glEnd();
1423
+ }
1424
+
1425
+ gl.glLineWidth(8);
1426
+ for (int s=0; s<Phys.allNodes.size(); s++)
1427
+ {
1428
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1429
+
1430
+ if (node.springs != null)
1431
+ {
1432
+ for (int i=0; i<node.springs.size(); i+=1)
1433
+ {
1434
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1435
+
1436
+ int c = i+1;
1437
+ // c = node.springs.get(i).nbcopies;
1438
+
1439
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1440
+ gl.glBegin(gl.GL_LINES);
1441
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1442
+ gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3);
1443
+ gl.glEnd();
1444
+ }
1445
+ }
1446
+ }
1447
+
1448
+ gl.glLineWidth(1);
1449
+ }
1450
+
1451
+ gl.glEnable(gl.GL_LIGHTING);
1452
+ }
1453
+
1454
+ /// INTERFACE
1455
+
1456
+ public void StartTriangles()
1457
+ {
1458
+ javax.media.opengl.GL gl = GetGL();
1459
+ gl.glBegin(gl.GL_TRIANGLES);
1460
+ }
1461
+
1462
+ public void EndTriangles()
1463
+ {
1464
+ GetGL().glEnd();
1465
+ }
1466
+
1467
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1468
+ {
1469
+ if (!selectmode)
1470
+ {
1471
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1472
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1473
+
1474
+ if (flipV)
1475
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1476
+ else
1477
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1478
+ }
1479
+
1480
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1481
+ }
1482
+
1483
+ void SetColor(Object3D obj, Vertex p0)
1484
+ {
1485
+ CameraPane display = this;
1486
+ BoundaryRep bRep = obj.bRep;
1487
+
1488
+ if (RENDERPROGRAM == 0)
1489
+ {
1490
+ float r = 0;
1491
+ if (bRep != null)
1492
+ {
1493
+ if (bRep.stripified)
1494
+ {
1495
+ r = 1;
1496
+ }
1497
+ }
1498
+ float g = 0;
1499
+ if (bRep != null)
1500
+ {
1501
+ if (bRep.trimmed)
1502
+ {
1503
+ g = 1;
1504
+ }
1505
+ }
1506
+ float b = 0;
1507
+ if (obj.support != null && obj.link2master)
1508
+ {
1509
+ b = 1;
1510
+ }
1511
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1512
+ return;
1513
+ }
1514
+
1515
+ if (display.DrawMode() != CameraPane.SHADOW)
1516
+ return;
1517
+
1518
+ javax.media.opengl.GL gl = display.GetGL();
1519
+// if (true) return;
1520
+// float ao = p.AO;
1521
+//
1522
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1523
+// // ao = 1;
1524
+//
1525
+// gl.glColor4f(ao, ao, ao, 1);
1526
+
1527
+// CameraPane.selectedpoint.
1528
+// getAverage(cStatic.point1, true);
1529
+ if (CameraPane.pointflow == null) // !random) // live)
1530
+ {
1531
+ return;
1532
+ }
1533
+
1534
+ cStatic.point1.set(0,0,0);
1535
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1536
+
1537
+ cStatic.point1.sub(p0);
1538
+
1539
+
1540
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1541
+// {
1542
+// return;
1543
+// }
1544
+
1545
+ //if (true)
1546
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1547
+ {
1548
+ return;
1549
+ }
1550
+
1551
+ float[] colorV = new float[3];
1552
+
1553
+ if (false) // marked)
1554
+ {
1555
+ // debug rigging weights
1556
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1557
+ {
1558
+ float weight = p0.weights[object] / p0.totalweight;
1559
+
1560
+ // if (weight < 0.1)
1561
+ // {
1562
+ // assert(weight == 0);
1563
+ // continue;
1564
+ // }
1565
+
1566
+ if (p0.vertexlinks[object] == -1)
1567
+ continue;
1568
+
1569
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1570
+
1571
+ int color = //1 << object; //
1572
+ //p.vertexlinks.length;
1573
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1574
+ colorV[2] += (color & 1) * weight;
1575
+ colorV[1] += ((color & 2) >> 1) * weight;
1576
+ colorV[0] += ((color & 4) >> 2) * weight;
1577
+ }
1578
+ }
1579
+ else
1580
+ {
1581
+ if (obj.drawingstarted)
1582
+ {
1583
+ // find next point
1584
+ if (bRep.GetVertex(0).faceindices == null)
1585
+ {
1586
+ bRep.InitFaceIndices();
1587
+ }
1588
+
1589
+ double ymin = p0.y;
1590
+
1591
+ Vertex newp = p0;
1592
+
1593
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1594
+ {
1595
+ int fi = p0.faceindices[fii];
1596
+
1597
+ if (fi == -1)
1598
+ break;
1599
+
1600
+ Face f = bRep.GetFace(fi);
1601
+
1602
+ Vertex p = bRep.GetVertex(f.p);
1603
+ Vertex q = bRep.GetVertex(f.q);
1604
+ Vertex r = bRep.GetVertex(f.r);
1605
+
1606
+ int swap = (int)(Math.random()*3);
1607
+
1608
+// for (int s=swap; --s>=0;)
1609
+// {
1610
+// Vertex t = p;
1611
+// p = q;
1612
+// q = r;
1613
+// r = t;
1614
+// }
1615
+ if (ymin > p.y)
1616
+ {
1617
+ ymin = p.y;
1618
+ newp = p;
1619
+// break;
1620
+ }
1621
+ if (ymin > q.y)
1622
+ {
1623
+ ymin = q.y;
1624
+ newp = q;
1625
+// break;
1626
+ }
1627
+ if (ymin > r.y)
1628
+ {
1629
+ ymin = r.y;
1630
+ newp = r;
1631
+// break;
1632
+ }
1633
+ }
1634
+
1635
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1636
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1637
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1638
+
1639
+ obj.drawingstarted = false;
1640
+
1641
+ // return;
1642
+ }
1643
+
1644
+ if (false) // CameraPane.DRAW
1645
+ {
1646
+ p0.AO = colorV[0] = 2;
1647
+ colorV[1] = 2;
1648
+ colorV[2] = 2;
1649
+ }
1650
+
1651
+ CameraPane.pointflow.add(p0);
1652
+ CameraPane.pointflow.Touch();
1653
+ }
1654
+
1655
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1656
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1657
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1658
+ }
1659
+
1660
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
1661
+ {
1662
+ CameraPane display = this;
1663
+ //new Exception().printStackTrace();
1664
+
1665
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1666
+ {
1667
+ return;
1668
+ }
1669
+
1670
+ javax.media.opengl.GL gl = display.GetGL();
1671
+
1672
+ //Color col = Color.getHSBColor(color,modulation,1);
1673
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1674
+ if (!material.multiply)
1675
+ {
1676
+ display.color = material.color;
1677
+ display.saturation = material.modulation;
1678
+ }
1679
+ else
1680
+ {
1681
+ display.color *= material.color*2;
1682
+ display.saturation *= material.modulation*2;
1683
+ }
1684
+
1685
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1686
+
1687
+ float[] colorV = Grafreed.colorV;
1688
+
1689
+ /**/
1690
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1691
+ {
1692
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1693
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1694
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1695
+ colorV[3] = 1; // material.opacity;
1696
+
1697
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1698
+ //System.out.println("Opacity = " + opacity);
1699
+
1700
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1701
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1702
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1703
+
1704
+ float amb = material.ambient;
1705
+ if (amb < material.cameralight)
1706
+ {
1707
+ amb = material.cameralight;
1708
+ }
1709
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1710
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1711
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1712
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1713
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1714
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1715
+
1716
+ /**/
1717
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1718
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1719
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1720
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1721
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1722
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1723
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1724
+ //System.out.println("shininess = " + colorV[0]);
1725
+ if (colorV[0] > 128)
1726
+ {
1727
+ colorV[0] = 128;
1728
+ }
1729
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1730
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1731
+ /**/
1732
+ }
1733
+ /**/
1734
+
1735
+ //selected = false;
1736
+ selected = selected && display.flash;
1737
+
1738
+ //display.modelParams0[0] = 0; // pigment.r;
1739
+ //display.modelParams0[1] = 0; // pigment.g;
1740
+ //display.modelParams0[2] = 0; // pigment.b;
1741
+ if (!material.multiply)
1742
+ {
1743
+ display.modelParams0[3] = material.metalness;
1744
+ display.modelParams1[0] = material.diffuse;
1745
+ display.modelParams1[1] = material.specular;
1746
+ display.modelParams1[2] = 1 / material.shininess;
1747
+ display.modelParams1[3] = material.shift;
1748
+ display.modelParams2[0] = material.ambient;
1749
+ display.modelParams2[1] = material.lightarea;
1750
+ //System.out.println("light area = " + lightarea);
1751
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1752
+ display.modelParams2[3] = material.velvet;
1753
+ display.modelParams3[0] = material.sheen;
1754
+ display.modelParams3[1] = material.subsurface;
1755
+ display.modelParams3[2] = material.bump; // backlit
1756
+ display.modelParams3[3] = material.aniso;
1757
+ display.modelParams4[0] = material.anisoV;
1758
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1759
+ //System.out.println("selected = " + selected);
1760
+ display.modelParams4[2] = material.diffuseness;
1761
+ display.modelParams4[3] = material.shadow;
1762
+ display.modelParams5[0] = material.texture;
1763
+ display.modelParams5[1] = material.opacity;
1764
+ display.modelParams5[2] = material.fakedepth;
1765
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1766
+ }
1767
+ else
1768
+ {
1769
+ display.modelParams0[3] *= material.metalness*2;
1770
+ display.modelParams1[0] *= material.diffuse*2;
1771
+ display.modelParams1[1] *= material.specular*2;
1772
+ display.modelParams1[2] *= material.shininess*2;
1773
+ display.modelParams1[3] *= material.shift*2;
1774
+ display.modelParams2[0] *= material.ambient*2;
1775
+ display.modelParams2[1] *= material.lightarea*2;
1776
+ display.modelParams2[2] *= material.factor*2;
1777
+ display.modelParams2[3] *= material.velvet*2;
1778
+ display.modelParams3[0] *= material.sheen*2;
1779
+ display.modelParams3[1] *= material.subsurface*2;
1780
+ display.modelParams3[2] *= material.bump*2;
1781
+ display.modelParams3[3] *= material.aniso*2;
1782
+ display.modelParams4[0] *= material.anisoV*2;
1783
+ display.modelParams4[1] *= material.cameralight*2;
1784
+ //System.out.println("selected = " + selected);
1785
+ display.modelParams4[2] *= material.diffuseness*2;
1786
+ display.modelParams4[3] *= material.shadow*2;
1787
+ display.modelParams5[0] *= material.texture*2;
1788
+ display.modelParams5[1] *= material.opacity*2;
1789
+ display.modelParams5[2] *= material.fakedepth*2;
1790
+ display.modelParams5[3] *= material.shadowbias*2;
1791
+ }
1792
+
1793
+ display.modelParams6[0] = 0;
1794
+ display.modelParams6[1] = 0;
1795
+ display.modelParams6[2] = 0;
1796
+ display.modelParams6[3] = 0;
1797
+
1798
+ display.modelParams7[0] = 0;
1799
+ display.modelParams7[1] = 1000;
1800
+ display.modelParams7[2] = 0;
1801
+ display.modelParams7[3] = 0;
1802
+
1803
+ //display.modelParams6[0] = 100; // criss de bug de bump
1804
+
1805
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
1806
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1807
+ {
1808
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1809
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1810
+ if (extparams.length > 1)
1811
+ {
1812
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1813
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1814
+ if (extparams.length > 2)
1815
+ {
1816
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1817
+ float x = extparams[2].y / 1000.0f;
1818
+ //if (x == 0)
1819
+ // x = 1f;
1820
+ display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power
1821
+ if (extparams[2].y > 0)
1822
+ {
1823
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1824
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1825
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1826
+ }
1827
+ }
1828
+ }
1829
+ }
1830
+
1831
+ //if (display.modelParams6[2] != 0)
1832
+ /*
1833
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1834
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1835
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1836
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1837
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1838
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1839
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1840
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1841
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1842
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1843
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1844
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1845
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1846
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1847
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1848
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1849
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1850
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1851
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1852
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1853
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1854
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1855
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1856
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1857
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1858
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1859
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1860
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1861
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1862
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1863
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1864
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1865
+ /**/
1866
+ //assert (display.modelParams6[2] == 0);
1867
+
1868
+ //System.out.println("noise power = " + display.modelParams7[0]);
1869
+ //System.out.println("shadowbias = " + shadowbias);
1870
+
1871
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1872
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1873
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1874
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1875
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1876
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1877
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1878
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1879
+
1880
+ int mode = display.FP_SHADER;
1881
+
1882
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1883
+ {
1884
+ mode |= display.FP_ANISO;
1885
+ }
1886
+
1887
+ display.EnableProgram(mode);
1888
+
1889
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1890
+
1891
+ if (!material.multiply)
1892
+ {
1893
+ if (Globals.drawMode == CameraPane.SHADOW)
1894
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1895
+ else
1896
+ gl.glDepthMask(material.opacity >= 0.99);
1897
+ }
2361898 }
2371899
2381900 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -253,7 +1915,7 @@
2531915 currentGL.glMultMatrixd(model, 0);
2541916 }
2551917
256
- void PushMatrix(double[][] matrix, int count)
1918
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2571919 {
2581920 matrixdepth++;
2591921 // GrafreeD.tracein(matrix);
....@@ -282,7 +1944,7 @@
2821944 void PushMatrix(double[][] matrix)
2831945 {
2841946 // GrafreeD.tracein(matrix);
285
- PushMatrix(matrix,1);
1947
+ PushMatrix(matrix, 1);
2861948 }
2871949
2881950 void PushMatrix()
....@@ -298,7 +1960,7 @@
2981960
2991961 double[][] tmpmat = new double[4][4];
3001962
301
- void PopMatrix(double[][] inverse)
1963
+ public void PopMatrix(double[][] inverse) // INTERFACE
3021964 {
3031965 --matrixdepth;
3041966
....@@ -338,7 +2000,7 @@
3382000 PushTextureMatrix(matrix, 1);
3392001 }
3402002
341
- void PushTextureMatrix(double[][] matrix, int count)
2003
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3422004 {
3432005 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3442006
....@@ -352,7 +2014,7 @@
3522014 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3532015 }
3542016
355
- void PopTextureMatrix(double[][] inverse)
2017
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3562018 {
3572019 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3582020 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -379,15 +2041,15 @@
3792041
3802042 static int camerachangeframe;
3812043
382
- boolean SetCamera(Camera cam)
2044
+ public boolean SetCamera(Camera cam)
3832045 {
3842046 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3852047 // return false;
3862048
387
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
2049
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3882050 {
3892051 // check for last change
390
- if (framecount < camerachangeframe + 400) // 120 == 1 second
2052
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3912053 {
3922054 // refuse the camera change
3932055 System.err.println("Camera " + cam + " REFUSED");
....@@ -395,7 +2057,7 @@
3952057 }
3962058 }
3972059
398
- camerachangeframe = framecount;
2060
+ camerachangeframe = Globals.framecount;
3992061
4002062 cam.hAspect = -1; // Read only
4012063
....@@ -426,7 +2088,7 @@
4262088 {
4272089 //System.err.println("Oeil on");
4282090 TRACK = true;
429
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2091
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4302092 // object.editWindow.ScreenFit(trackedobject);
4312093 //pingthread.StepToTarget(true);
4322094 }
....@@ -435,8 +2097,8 @@
4352097 {
4362098 //System.err.println("Oeil on");
4372099 OEIL = true;
438
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
439
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2100
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4402102 //pingthread.StepToTarget(true);
4412103 }
4422104
....@@ -499,39 +2161,12 @@
4992161 {
5002162 frozen ^= true;
5012163 // Weird...
502
- lighttouched = true;
2164
+ Globals.lighttouched = true;
5032165 }
5042166
5052167 void ToggleDL()
5062168 {
5072169 mainDL ^= true;
508
- }
509
-
510
- void ToggleTexture()
511
- {
512
- textureon ^= true;
513
- }
514
-
515
- void ToggleLive()
516
- {
517
- setLIVE(isLIVE() ^ true);
518
-
519
- System.err.println("LIVE = " + isLIVE());
520
-
521
- if (!isLIVE()) // save sound
522
- GrafreeD.savesound = true; // wav.save();
523
- // else
524
- repaint(); // start loop // may 2013
525
- }
526
-
527
- void ToggleSupport()
528
- {
529
- SUPPORT ^= true;
530
- }
531
-
532
- void ToggleAbort()
533
- {
534
- ABORTMODE ^= true;
5352170 }
5362171
5372172 void ToggleFullScreen()
....@@ -541,12 +2176,7 @@
5412176
5422177 void ToggleCrowd()
5432178 {
544
- CROWD ^= true;
545
- }
546
-
547
- void ToggleInertia()
548
- {
549
- INERTIA ^= true;
2179
+ Globals.CROWD ^= true;
5502180 }
5512181
5522182 void ToggleLocal()
....@@ -554,62 +2184,89 @@
5542184 LOCALTRANSFORM ^= true;
5552185 }
5562186
557
- void ToggleFast()
2187
+ public void ToggleTexture()
2188
+ {
2189
+ textureon ^= true;
2190
+ }
2191
+
2192
+ public void ToggleLive()
2193
+ {
2194
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2195
+
2196
+ System.err.println("LIVE = " + Globals.isLIVE());
2197
+
2198
+ if (!Globals.isLIVE()) // save sound
2199
+ Grafreed.savesound = true; // wav.save();
2200
+ // else
2201
+ repaint(); // start loop // may 2013
2202
+ }
2203
+
2204
+ public void ToggleSupport()
2205
+ {
2206
+ SUPPORT ^= true;
2207
+ }
2208
+
2209
+ public void ToggleAbort()
2210
+ {
2211
+ ABORTMODE ^= true;
2212
+ }
2213
+
2214
+ public void ToggleInertia()
2215
+ {
2216
+ INERTIA ^= true;
2217
+ }
2218
+
2219
+ public void ToggleFast()
5582220 {
5592221 FAST ^= true;
5602222 }
5612223
562
- void ToggleSlowPose()
2224
+ public void ToggleSlowPose()
5632225 {
5642226 SLOWPOSE ^= true;
5652227 }
5662228
567
- void ToggleFootContact()
568
- {
569
- FOOTCONTACT ^= true;
570
- }
571
-
572
- void ToggleBoxMode()
2229
+ public void ToggleBoxMode()
5732230 {
5742231 BOXMODE ^= true;
5752232 }
5762233
577
- void ToggleSmoothFocus()
2234
+ public void ToggleZoomBoxMode()
2235
+ {
2236
+ ZOOMBOXMODE ^= true;
2237
+ }
2238
+
2239
+ public void ToggleSmoothFocus()
5782240 {
5792241 SMOOTHFOCUS ^= true;
5802242 }
5812243
582
- void ToggleImageFlip()
2244
+ public void ToggleImageFlip()
5832245 {
5842246 IMAGEFLIP ^= true;
5852247 }
5862248
587
- void ToggleSpeakerMocap()
2249
+ public void ToggleSpeakerMocap()
5882250 {
5892251 SPEAKERMOCAP ^= true;
5902252 }
5912253
592
- void ToggleSpeakerCamera()
2254
+ public void ToggleSpeakerCamera()
5932255 {
5942256 SPEAKERCAMERA ^= true;
5952257 }
5962258
597
- void ToggleSpeakerFocus()
2259
+ public void ToggleSpeakerFocus()
5982260 {
5992261 SPEAKERFOCUS ^= true;
6002262 }
6012263
602
- void ToggleDebug()
603
- {
604
- DEBUG ^= true;
605
- }
606
-
607
- void ToggleFrustum()
2264
+ public void ToggleFrustum()
6082265 {
6092266 FRUSTUM ^= true;
6102267 }
6112268
612
- void ToggleTrack()
2269
+ public void ToggleTrack()
6132270 {
6142271 TRACK ^= true;
6152272 if (TRACK)
....@@ -628,25 +2285,35 @@
6282285 repaint();
6292286 }
6302287
631
- void ToggleTrackOnce()
2288
+ public void ToggleTrackOnce()
6322289 {
6332290 TRACKONCE ^= true;
6342291 }
6352292
636
- void ToggleShadowTrack()
2293
+ public void ToggleShadowTrack()
6372294 {
6382295 SHADOWTRACK ^= true;
6392296 repaint();
6402297 }
6412298
642
- void ToggleOeil()
2299
+ public void ToggleOeil()
6432300 {
6442301 OEIL ^= true;
6452302 }
6462303
647
- void ToggleOeilOnce()
2304
+ public void ToggleOeilOnce()
6482305 {
6492306 OEILONCE ^= true;
2307
+ }
2308
+
2309
+ void ToggleFootContact()
2310
+ {
2311
+ FOOTCONTACT ^= true;
2312
+ }
2313
+
2314
+ void ToggleDebug()
2315
+ {
2316
+ Globals.DEBUG ^= true;
6502317 }
6512318
6522319 void ToggleLookAt()
....@@ -654,9 +2321,9 @@
6542321 LOOKAT ^= true;
6552322 }
6562323
657
- void ToggleRandom()
2324
+ void ToggleSwitch()
6582325 {
659
- RANDOM ^= true;
2326
+ SWITCH ^= true;
6602327 }
6612328
6622329 void ToggleHandles()
....@@ -664,10 +2331,17 @@
6642331 HANDLES ^= true;
6652332 }
6662333
2334
+ Object3D paintFolder;
2335
+
6672336 void TogglePaint()
6682337 {
6692338 PAINTMODE ^= true;
6702339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
6712345 }
6722346
6732347 void SwapCamera(int a, int b)
....@@ -759,11 +2433,26 @@
7592433
7602434 GL currentGL;
7612435
762
- GL GetGL()
2436
+ public GL GetGL() // INTERFACE
7632437 {
7642438 return currentGL;
7652439 }
766
-
2440
+
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
2442
+ {
2443
+ Grafreed.Assert(texturedata != null);
2444
+
2445
+ int width = texturedata.getWidth();
2446
+ int height = texturedata.getHeight();
2447
+
2448
+ Buffer buffer = texturedata.getBuffer();
2449
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2450
+
2451
+ byte[] bytes = bytebuf.array();
2452
+
2453
+ return CreateBim(bytes, width, height);
2454
+ }
2455
+
7672456 /**/
7682457 class CacheTexture
7692458 {
....@@ -772,28 +2461,31 @@
7722461
7732462 int resolution;
7742463
775
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
7762465 {
777
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
7782468 resolution = res;
7792469 }
7802470 }
7812471 /**/
7822472
7832473 // TEXTURE static Texture texture;
784
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
785
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
786
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2474
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2475
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2476
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2477
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2478
+
7872479 int pigmentdepth = 0;
7882480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
7892481 int bumpdepth = 0;
7902482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
7912483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
7922484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
793
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
7942486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
7952487
796
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
7972489 {
7982490 TextureData texturedata = null;
7992491
....@@ -812,13 +2504,34 @@
8122504 if (bump)
8132505 texturedata = ConvertBump(texturedata, false);
8142506
815
- com.sun.opengl.util.texture.Texture texture =
816
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2507
+// com.sun.opengl.util.texture.Texture texture =
2508
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
8172509
818
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
819
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2510
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2511
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
8202512
821
- return texture;
2513
+ return texturedata;
2514
+ }
2515
+
2516
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2517
+ {
2518
+ TextureData texturedata = null;
2519
+
2520
+ try
2521
+ {
2522
+ texturedata =
2523
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2524
+ bim,
2525
+ true);
2526
+ } catch (Exception e)
2527
+ {
2528
+ throw new javax.media.opengl.GLException(e);
2529
+ }
2530
+
2531
+ if (bump)
2532
+ texturedata = ConvertBump(texturedata, false);
2533
+
2534
+ return texturedata;
8222535 }
8232536
8242537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -1891,6 +3604,8 @@
18913604
18923605 System.out.println("LOADING TEXTURE : " + name);
18933606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
18943609 //
18953610 if (false) // compressbit > 0)
18963611 {
....@@ -2595,6 +4310,7 @@
25954310
25964311 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25974312 {
4313
+ new Exception().printStackTrace();
25984314 System.exit(0);
25994315 com.sun.opengl.util.texture.Texture texture = null;
26004316
....@@ -6271,7 +7987,7 @@
62717987 return null;
62727988 }
62737989
6274
- void ReleaseTextures(cTexture tex)
7990
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757991 {
62767992 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777993 {
....@@ -6288,7 +8004,7 @@
62888004 String pigment = Object3D.GetPigment(tex);
62898005 String bump = Object3D.GetBump(tex);
62908006
6291
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
62928008 {
62938009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
62948010 // System.out.println("; bump = " + bump);
....@@ -6303,13 +8019,71 @@
63038019 pigment = null;
63048020 }
63058021
6306
- ReleaseTexture(bump, true);
6307
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
63088024 }
63098025
6310
- void ReleaseTexture(String tex, boolean bump)
8026
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
63118027 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
8028
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8029
+ {
8030
+ return;
8031
+ }
8032
+
8033
+ if (tex == null)
8034
+ {
8035
+ ReleaseTexture(null, false);
8036
+ return;
8037
+ }
8038
+
8039
+ String pigment = Object3D.GetPigment(tex);
8040
+
8041
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ {
8043
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8044
+ // System.out.println("; bump = " + bump);
8045
+ }
8046
+
8047
+ if (pigment.equals(""))
8048
+ {
8049
+ pigment = null;
8050
+ }
8051
+
8052
+ ReleaseTexture(tex, false);
8053
+ }
8054
+
8055
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8056
+ {
8057
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8058
+ {
8059
+ return;
8060
+ }
8061
+
8062
+ if (tex == null)
8063
+ {
8064
+ ReleaseTexture(null, true);
8065
+ return;
8066
+ }
8067
+
8068
+ String bump = Object3D.GetBump(tex);
8069
+
8070
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8071
+ {
8072
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8073
+ // System.out.println("; bump = " + bump);
8074
+ }
8075
+
8076
+ if (bump.equals(""))
8077
+ {
8078
+ bump = null;
8079
+ }
8080
+
8081
+ ReleaseTexture(tex, true);
8082
+ }
8083
+
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
8085
+ {
8086
+ if (// DrawMode() != 0 || /*tex == null ||*/
63138087 ambientOcclusion ) // || !textureon)
63148088 {
63158089 return;
....@@ -6318,7 +8092,7 @@
63188092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
63198093
63208094 if (tex != null)
6321
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
63228096
63238097 // //assert( texture != null );
63248098 // if (texture == null)
....@@ -6410,9 +8184,57 @@
64108184 }
64118185 }
64128186
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8187
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64148188 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
8189
+// if (// DrawMode() != 0 || /*tex == null ||*/
8190
+// ambientOcclusion ) // || !textureon)
8191
+// {
8192
+// return; // false;
8193
+// }
8194
+//
8195
+// if (tex == null)
8196
+// {
8197
+// BindTexture(null,false,resolution);
8198
+// BindTexture(null,true,resolution);
8199
+// return;
8200
+// }
8201
+//
8202
+// String pigment = Object3D.GetPigment(tex);
8203
+// String bump = Object3D.GetBump(tex);
8204
+//
8205
+// usedtextures.add(pigment);
8206
+// usedtextures.add(bump);
8207
+//
8208
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8209
+// {
8210
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8211
+// // System.out.println("; bump = " + bump);
8212
+// }
8213
+//
8214
+// if (bump.equals(""))
8215
+// {
8216
+// bump = null;
8217
+// }
8218
+// if (pigment.equals(""))
8219
+// {
8220
+// pigment = null;
8221
+// }
8222
+//
8223
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8224
+// BindTexture(pigment, false, resolution);
8225
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8226
+// BindTexture(bump, true, resolution);
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+//
8229
+// return; // true;
8230
+
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
8233
+ }
8234
+
8235
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8236
+ {
8237
+ if (// DrawMode() != 0 || /*tex == null ||*/
64168238 ambientOcclusion ) // || !textureon)
64178239 {
64188240 return; // false;
....@@ -6421,17 +8243,47 @@
64218243 if (tex == null)
64228244 {
64238245 BindTexture(null,false,resolution);
6424
- BindTexture(null,true,resolution);
64258246 return;
64268247 }
64278248
64288249 String pigment = Object3D.GetPigment(tex);
8250
+
8251
+ usedtextures.add(tex);
8252
+
8253
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8254
+ {
8255
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8256
+ // System.out.println("; bump = " + bump);
8257
+ }
8258
+
8259
+ if (pigment.equals(""))
8260
+ {
8261
+ pigment = null;
8262
+ }
8263
+
8264
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8265
+ BindTexture(tex, false, resolution);
8266
+ }
8267
+
8268
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8269
+ {
8270
+ if (// DrawMode() != 0 || /*tex == null ||*/
8271
+ ambientOcclusion ) // || !textureon)
8272
+ {
8273
+ return; // false;
8274
+ }
8275
+
8276
+ if (tex == null)
8277
+ {
8278
+ BindTexture(null,true,resolution);
8279
+ return;
8280
+ }
8281
+
64298282 String bump = Object3D.GetBump(tex);
64308283
6431
- usedtextures.put(pigment, pigment);
6432
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
64338285
6434
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
64358287 {
64368288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
64378289 // System.out.println("; bump = " + bump);
....@@ -6441,43 +8293,82 @@
64418293 {
64428294 bump = null;
64438295 }
6444
- if (pigment.equals(""))
6445
- {
6446
- pigment = null;
6447
- }
64488296
6449
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
6450
- BindTexture(pigment, false, resolution);
64518297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
6452
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
64538299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
6454
-
6455
- return; // true;
64568300 }
64578301
6458
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8302
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8303
+
8304
+ private boolean FileExists(String tex)
64598305 {
6460
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8306
+ if (missingTextures.contains(tex))
8307
+ {
8308
+ return false;
8309
+ }
8310
+
8311
+ boolean fileExists = new File(tex).exists();
8312
+
8313
+ if (!fileExists)
8314
+ {
8315
+ // If file exists, the "new File()" is not executed sgain
8316
+ missingTextures.add(tex);
8317
+ }
8318
+
8319
+ return fileExists;
8320
+ }
8321
+
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8323
+ {
8324
+ CacheTexture texturecache = null;
64618325
64628326 if (tex != null)
64638327 {
6464
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
64658330
6466
- String[] split = tex.split("Textures");
6467
- if (split.length > 1)
6468
- texname = "/Users/nbriere/Textures" + split[split.length-1];
6469
- else
6470
- if (!texname.startsWith("/"))
6471
- texname = "/Users/nbriere/Textures/" + texname;
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
8335
+
8336
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8337
+
8338
+// String[] split = tex.split("Textures");
8339
+// if (split.length > 1)
8340
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8341
+// else
8342
+// if (!texname.startsWith("/"))
8343
+// texname = "/Users/nbriere/Textures/" + texname;
8344
+ if (!FileExists(texname))
8345
+ {
8346
+ texname = fallbackTextureName;
8347
+ }
64728348
64738349 if (CACHETEXTURE)
6474
- texture = textures.get(texname); // TEXTURE CACHE
6475
-
6476
- TextureData texturedata = null;
6477
-
6478
- if (texture == null || texture.resolution < resolution)
64798350 {
6480
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8351
+ if (texdata == null)
8352
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8353
+ else
8354
+ texturecache = bimtextures.get(texdata);
8355
+ }
8356
+
8357
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8358
+ {
8359
+ TextureData texturedata = null;
8360
+
8361
+ if (texdata != null)
8362
+ {
8363
+ BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8364
+
8365
+ CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8366
+
8367
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8368
+ bimtextures.put(texdata, texturecache);
8369
+ }
8370
+ else
8371
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
64818372 {
64828373 assert(!bump);
64838374 // if (bump)
....@@ -6488,19 +8379,23 @@
64888379 // }
64898380 // else
64908381 // {
6491
- texture = textures.get(tex);
6492
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
64938384 {
6494
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
64958386 }
8387
+ else
8388
+ new Exception().printStackTrace();
64968389 // }
64978390 } else
6498
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
64998392 {
65008393 assert(bump);
6501
- texture = textures.get(tex);
6502
- if (texture == null)
6503
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8394
+ // texturecache = textures.get(texname); // suspicious
8395
+ if (texturecache == null)
8396
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8397
+ else
8398
+ new Exception().printStackTrace();
65048399 } else
65058400 {
65068401 //if (tex.equals("IMMORTAL"))
....@@ -6508,11 +8403,13 @@
65088403 // texture = GetResourceTexture("default.png");
65098404 //} else
65108405 //{
6511
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
65128407 {
6513
- texture = textures.get(tex);
6514
- if (texture == null)
6515
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8408
+ // texturecache = textures.get(texname); // suspicious
8409
+ if (texturecache == null)
8410
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8411
+ else
8412
+ new Exception().printStackTrace();
65168413 } else
65178414 {
65188415 if (textureon)
....@@ -6537,7 +8434,7 @@
65378434 }
65388435
65398436 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
6540
- if (!new File(cachename).exists())
8437
+ if (!FileExists(cachename))
65418438 cachename = texname;
65428439 else
65438440 processbump = false; // don't process bump map again
....@@ -6559,7 +8456,7 @@
65598456 }
65608457
65618458 cachename = texname.substring(0, texname.length()-4)+ext+".png";
6562
- if (!new File(cachename).exists())
8459
+ if (!FileExists(cachename))
65638460 cachename = texname;
65648461 else
65658462 processbump = false; // don't process bump map again
....@@ -6568,20 +8465,22 @@
65688465 texturedata = GetFileTexture(cachename, processbump, resolution);
65698466
65708467
6571
- if (texturedata != null)
6572
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8468
+ if (texturedata == null)
8469
+ throw new Exception();
8470
+
8471
+ texturecache = new CacheTexture(texturedata,resolution);
65738472 //texture = GetTexture(tex, bump);
65748473 }
65758474 }
65768475 //}
65778476 }
65788477
6579
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
65808479 {
65818480 //return false;
65828481
65838482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
6584
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
65858484 {
65868485 // String ext = "_highres";
65878486 // if (REDUCETEXTURE)
....@@ -6598,52 +8497,17 @@
65988497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
65998498 if (!cachefile.exists())
66008499 {
6601
- // cache to disk
6602
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
6603
- //buffers[0].
6604
-
6605
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
6606
- int[] pixels = new int[bytebuf.capacity()/3];
6607
-
6608
- // squared size heuristic...
6609
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
66108501 {
6611
- for (int i=pixels.length; --i>=0;)
6612
- {
6613
- int i3 = i*3;
6614
- pixels[i] = 0xFF;
6615
- pixels[i] <<= 8;
6616
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
6617
- pixels[i] <<= 8;
6618
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
6619
- pixels[i] <<= 8;
6620
- pixels[i] |= bytebuf.get(i3) & 0xFF;
6621
- }
6622
-
6623
- /*
6624
- int r=0,g=0,b=0,a=0;
6625
- for (int i=0; i<width; i++)
6626
- for (int j=0; j<height; j++)
6627
- {
6628
- int index = j*width+i;
6629
- int p = pixels[index];
6630
- a = ((p>>24) & 0xFF);
6631
- r = ((p>>16) & 0xFF);
6632
- g = ((p>>8) & 0xFF);
6633
- b = (p & 0xFF);
6634
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
6635
- }
6636
- /**/
6637
- int width = (int)Math.sqrt(pixels.length); // squared
6638
- int height = width;
6639
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
6640
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
66418504 ImageWriter writer = null;
66428505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
66438506 if (iter.hasNext()) {
66448507 writer = (ImageWriter)iter.next();
66458508 }
6646
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
66478511 try
66488512 {
66498513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -6660,18 +8524,20 @@
66608524 }
66618525 }
66628526 }
6663
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
66648530 //System.out.println("Texture = " + tex);
6665
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
66668532 {
6667
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
66688534 thetex.texture.disable();
66698535 thetex.texture.dispose();
6670
- textures.remove(texname);
8536
+ textures.remove(tex);
66718537 }
66728538
6673
- texture.texturedata = texturedata;
6674
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
66758541
66768542 // newtex = true;
66778543 }
....@@ -6687,10 +8553,41 @@
66878553 }
66888554 }
66898555
6690
- return texture;
8556
+ return texturecache;
66918557 }
66928558
6693
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8559
+ static void EmbedTextures(cTexture tex)
8560
+ {
8561
+ if (tex.pigmentdata == null)
8562
+ {
8563
+ String texname = Object3D.GetPigment(tex);
8564
+
8565
+ CacheTexture texturecache = texturepigment.get(tex);
8566
+
8567
+ if (texturecache != null)
8568
+ {
8569
+ tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8570
+ tex.pw = texturecache.texturedata.getWidth();
8571
+ tex.ph = texturecache.texturedata.getHeight();
8572
+ }
8573
+ }
8574
+
8575
+ if (tex.bumpdata == null)
8576
+ {
8577
+ String texname = Object3D.GetBump(tex);
8578
+
8579
+ CacheTexture texturecache = texturebump.get(tex);
8580
+
8581
+ if (texturecache != null)
8582
+ {
8583
+ tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8584
+ tex.bw = texturecache.texturedata.getWidth();
8585
+ tex.bh = texturecache.texturedata.getHeight();
8586
+ }
8587
+ }
8588
+ }
8589
+
8590
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
66948591 {
66958592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66968593
....@@ -6708,21 +8605,21 @@
67088605 return texture!=null?texture.texture:null;
67098606 }
67108607
6711
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8608
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
67128609 {
67138610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67148611
67158612 return texture!=null?texture.texturedata:null;
67168613 }
67178614
6718
- boolean BindTexture(String tex, boolean bump, int resolution)
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
67198616 {
67208617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67218618 {
67228619 return false;
67238620 }
67248621
6725
- boolean newtex = false;
8622
+ //boolean newtex = false;
67268623
67278624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
67288625
....@@ -6754,7 +8651,7 @@
67548651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
67558652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
67568653
6757
- return newtex;
8654
+ return true; // Warning: not used.
67588655 }
67598656
67608657 ShadowBuffer shadowPBuf;
....@@ -7312,9 +9209,9 @@
73129209 static boolean occlusionInitialized = false;
73139210 boolean selection = false;
73149211 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
9212
+ ///*static*/ boolean lighttouched = true;
73169213 boolean deselect;
7317
- boolean ambientOcclusion = false;
9214
+ private boolean ambientOcclusion = false;
73189215 static boolean flash = false;
73199216 /*static*/ boolean wait = false;
73209217 boolean displaydone = false; // after repaint() calls
....@@ -7592,18 +9489,40 @@
75929489 jy8[3] = 0.5f;
75939490 }
75949491
7595
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9492
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75969493 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
75979494 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
75989495 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75999496
9497
+ void ResetOptions()
9498
+ {
9499
+ options1[0] = 100;
9500
+ options1[1] = 0.025f;
9501
+ options1[2] = 0.01f;
9502
+ options1[3] = 0;
9503
+ options1[4] = 0;
9504
+
9505
+ options2[0] = 0;
9506
+ options2[1] = 0.75f;
9507
+ options2[2] = 0;
9508
+ options2[3] = 0;
9509
+
9510
+ options3[0] = 1;
9511
+ options3[1] = 1;
9512
+ options3[2] = 1;
9513
+ options3[3] = 0;
9514
+
9515
+ options4[0] = 1;
9516
+ options4[1] = 0;
9517
+ options4[2] = 1;
9518
+ options4[3] = 0;
9519
+ }
9520
+
76009521 static int imagecount = 0; // movie generation
76019522
76029523 static int jitter = 0;
76039524
76049525 boolean restartframe = false;
7605
-
7606
- static int framecount = 0; // general-purpose global count
76079526
76089527 void displayAntiAliased(javax.media.opengl.GL gl)
76099528 {
....@@ -7635,7 +9554,7 @@
76359554 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76369555 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76379556 {
7638
- framecount++;
9557
+ Globals.framecount++;
76399558
76409559 if (CameraPane.tickcount > 0)
76419560 CameraPane.tickcount--;
....@@ -7673,7 +9592,7 @@
76739592
76749593 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76759594 */
7676
- lighttouched = true;
9595
+ Globals.lighttouched = true;
76779596 //System.err.println(" shadowbuffer: " + jitter);
76789597 shadowbuffer.display();
76799598
....@@ -7694,8 +9613,8 @@
76949613 assert (parentcam != renderCamera);
76959614
76969615 if (renderCamera != lightCamera)
7697
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7698
- LA.matConcat(matrix, parentcam.toParent, matrix);
9616
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
76999618
77009619 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
77019620
....@@ -7710,8 +9629,8 @@
77109629 LA.matCopy(renderCamera.fromScreen, matrix);
77119630
77129631 if (renderCamera != lightCamera)
7713
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7714
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9632
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
77159634
77169635 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77179636
....@@ -7783,7 +9702,7 @@
77839702 //gl.glFlush();
77849703 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77859704
7786
- if (ANIMATION && ABORTED)
9705
+ if (Globals.ANIMATION && ABORTED)
77879706 {
77889707 System.err.println(" ABORTED FRAME");
77899708 break;
....@@ -7813,7 +9732,7 @@
78139732 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78149733
78159734 // save image
7816
- if (ANIMATION && !ABORTED)
9735
+ if (Globals.ANIMATION && !ABORTED)
78179736 {
78189737 VPwidth = viewport[2];
78199738 VPheight = viewport[3];
....@@ -7924,11 +9843,11 @@
79249843
79259844 // imagecount++;
79269845
7927
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9846
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
79289847
79299848 if (!BOXMODE)
79309849 {
7931
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9850
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
79329851 }
79339852
79349853 if (!BOXMODE)
....@@ -7966,7 +9885,7 @@
79669885 ABORTED = false;
79679886 }
79689887 else
7969
- GrafreeD.wav.cursor += 735 * ACSIZE;
9888
+ Grafreed.wav.cursor += 735 * ACSIZE;
79709889
79719890 if (false)
79729891 {
....@@ -8620,13 +10539,6 @@
862010539 }
862110540 }
862210541
8623
- boolean IsFrozen()
8624
- {
8625
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8626
-
8627
- return !selectmode && cameracount == 0; // != 0;
8628
- }
8629
-
863010542 boolean niceon = false;
863110543 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
863210544 boolean currentlydrawing = false;
....@@ -8636,16 +10548,16 @@
863610548
863710549 public void display(GLAutoDrawable drawable)
863810550 {
8639
- if (GrafreeD.savesound && GrafreeD.hassound)
10551
+ if (Grafreed.savesound && Grafreed.hassound)
864010552 {
8641
- GrafreeD.wav.save();
8642
- GrafreeD.savesound = false;
8643
- GrafreeD.hassound = false;
10553
+ Grafreed.wav.save();
10554
+ Grafreed.savesound = false;
10555
+ Grafreed.hassound = false;
864410556 }
864510557 // if (DEBUG_SELECTION)
864610558 // {
8647
-// if (drawMode != SELECTION)
8648
-// drawMode = SELECTION;
10559
+// if (DrawMode() != SELECTION)
10560
+// DrawMode() = SELECTION;
864910561 // }
865010562
865110563 if (!isRenderer)
....@@ -8701,9 +10613,9 @@
870110613
870210614 //ANTIALIAS = 0;
870310615
8704
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10616
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870510617 {
8706
- if (niceon || isLIVE())
10618
+ if (niceon || Globals.isLIVE())
870710619 {
870810620 //if(active == 0)
870910621 // antialiaser = null;
....@@ -8716,6 +10628,7 @@
871610628 ANTIALIAS = 0;
871710629 //System.out.println("RESTART");
871810630 AAtimer.restart();
10631
+ Globals.TIMERRUNNING = true;
871910632 }
872010633 }
872110634 }
....@@ -8728,7 +10641,7 @@
872810641 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872910642 */
873010643
8731
- if (drawMode == DEFAULT)
10644
+ if (DrawMode() == DEFAULT)
873210645 {
873310646 currentlydrawing = true;
873410647 }
....@@ -8759,18 +10672,18 @@
875910672
876010673 // if(Applet3D.clipboard != null)
876110674 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8762
-//drawMode = SELECTION;
10675
+//DrawMode() = SELECTION;
876310676 indexcount = 0;
876410677
8765
- if (drawMode == OCCLUSION)
10678
+ if (DrawMode() == OCCLUSION)
876610679 {
8767
- drawMode = DEFAULT;
10680
+ Globals.drawMode = DEFAULT; // WARNING
876810681 ambientOcclusion = true;
876910682 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
877010683 Object3D theobject = object;
877110684 Object3D theparent = object.parent;
877210685 object.parent = null;
8773
- object = (Object3D)GrafreeD.clone(object);
10686
+ object = (Object3D)Grafreed.clone(object);
877410687 object.Stripify();
877510688 if (theobject.selection == null || theobject.selection.Size() == 0)
877610689 theobject.PreprocessOcclusion(this);
....@@ -8783,19 +10696,20 @@
878310696 ambientOcclusion = false;
878410697 }
878510698
8786
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10699
+ if (//Globals.lighttouched &&
10700
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878710701 {
878810702 //if (RENDERSHADOW) // ?
878910703 if (!IsFrozen())
879010704 {
879110705 // dec 2012
8792
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10706
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
879310707 {
8794
- framecount++;
10708
+ Globals.framecount++;
879510709 shadowbuffer.display();
879610710 }
879710711 }
8798
- lighttouched = false; // ??
10712
+ Globals.lighttouched = false; // ??
879910713 //drawing = true;
880010714 //lighttouched = true;
880110715 }
....@@ -8816,9 +10730,9 @@
881610730 //eyeCamera.shaper_fovy = 1;
881710731 }
881810732
8819
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10733
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
882010734 {
8821
- //System.out.println("drawMode = " + drawMode);
10735
+ //System.out.println("DrawMode() = " + DrawMode());
882210736 vertexMode |= VP_PASS;
882310737 //vertexMode |= VP_PROJECTION;
882410738 if (!ambientOcclusion)
....@@ -8878,7 +10792,7 @@
887810792 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887910793 //Camera lightcam = new Camera(light0);
888010794
8881
- if (drawMode == SHADOW)
10795
+ if (DrawMode() == SHADOW)
888210796 {
888310797 /*
888410798 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8916,8 +10830,8 @@
891610830
891710831 // if (parentcam != renderCamera) // not a light
891810832 if (cam != lightCamera)
8919
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8920
- LA.matConcat(matrix, parentcam.toParent, matrix);
10833
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
892110835
892210836 for (int j = 0; j < 4; j++)
892310837 {
....@@ -8931,8 +10845,8 @@
893110845
893210846 // if (parentcam != renderCamera) // not a light
893310847 if (cam != lightCamera)
8934
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8935
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10848
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
893610850
893710851 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893810852
....@@ -8968,7 +10882,7 @@
896810882 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896910883 } else
897010884 {
8971
- if (drawMode != DEFAULT)
10885
+ if (DrawMode() != DEFAULT)
897210886 {
897310887 gl.glClearColor(1, 1, 1, 0);
897410888 } // 1);
....@@ -9033,7 +10947,7 @@
903310947
903410948 fast &= !ambientOcclusion;
903510949
9036
- if (drawMode == DEFAULT)
10950
+ if (DrawMode() == DEFAULT)
903710951 {
903810952 //gl.glEnable(gl.GL_ALPHA_TEST);
903910953 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9191,7 +11105,16 @@
919111105 // Bump noise
919211106 gl.glActiveTexture(GL.GL_TEXTURE6);
919311107 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9194
- BindTexture(NOISE_TEXTURE, false, 2);
11108
+
11109
+ try
11110
+ {
11111
+ BindTexture(NOISE_TEXTURE, false, 2);
11112
+ }
11113
+ catch (Exception e)
11114
+ {
11115
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11116
+ }
11117
+
919511118
919611119 gl.glActiveTexture(GL.GL_TEXTURE0);
919711120 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9214,9 +11137,9 @@
921411137
921511138 gl.glMatrixMode(GL.GL_MODELVIEW);
921611139
9217
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
9218
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
9219
-//gl.glEnable(gl.GL_MULTISAMPLE);
11140
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11141
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11142
+gl.glEnable(gl.GL_MULTISAMPLE);
922011143 } else
922111144 {
922211145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -9227,11 +11150,11 @@
922711150 //System.out.println("BLENDING ON");
922811151 gl.glEnable(GL.GL_BLEND);
922911152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
9230
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
923111154 gl.glMatrixMode(gl.GL_PROJECTION);
923211155 gl.glLoadIdentity();
923311156
9234
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
11157
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923511158 {
923611159 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923711160 double scale = lightCamera.SCALE / lightCamera.Distance();
....@@ -9289,7 +11212,7 @@
928911212 //gl.glPushMatrix();
929011213 gl.glLoadIdentity();
929111214
9292
- if (!ambientOcclusion) // drawMode != OCCLUSION)
11215
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
929311216 {
929411217 //LA.xformPos(light0, lightCamera.fromScreen, light);
929511218 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9316,8 +11239,8 @@
931611239 System.err.println("parentcam != renderCamera");
931711240
931811241 // if (cam != lightCamera)
9319
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9320
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11242
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11243
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
932111244 }
932211245
932311246 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -9338,8 +11261,8 @@
933811261 if (true) // TODO
933911262 {
934011263 if (cam != lightCamera)
9341
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9342
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11264
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11265
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
934311266 }
934411267
934511268 LA.xformPos(light0, cam.toScreen, light0);
....@@ -9376,7 +11299,7 @@
937611299 }
937711300
937811301 /**/
9379
- if (true) // drawMode == SELECTION) // != DEFAULT)
11302
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
938011303 gl.glDisable(gl.GL_LIGHTING);
938111304 else
938211305 gl.glEnable(gl.GL_LIGHTING);
....@@ -9394,7 +11317,7 @@
939411317
939511318 lightslot = 64;
939611319
9397
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11320
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939811321 {
939911322 DrawLights(object);
940011323 }
....@@ -9405,7 +11328,7 @@
940511328 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940611329 //System.out.println("fragmentMode = " + fragmentMode);
940711330
9408
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11331
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
940911332 {
941011333 /*
941111334 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9438,7 +11361,7 @@
943811361 }
943911362 }
944011363
9441
- if (drawMode == DEFAULT)
11364
+ if (DrawMode() == DEFAULT)
944211365 {
944311366 if (WIREFRAME && !ambientOcclusion)
944411367 {
....@@ -9456,7 +11379,7 @@
945611379 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945711380 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945811381
9459
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11382
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
946011383 {
946111384 if (vertexMode != 0) // && !fast)
946211385 {
....@@ -9476,7 +11399,7 @@
947611399 }
947711400 }
947811401
9479
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11402
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
948011403 {
948111404 //gl.glDepthFunc(GL.GL_LEQUAL);
948211405 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9504,7 +11427,7 @@
950411427 //gl.glDepthMask(false);
950511428 }
950611429
9507
- if (false) // drawMode == SHADOW)
11430
+ if (false) // DrawMode() == SHADOW)
950811431 {
950911432 //SetColumnMajorData(cameraInverseTransform, view_1);
951011433 //System.out.println("light = " + cameraInverseTransform);
....@@ -9518,16 +11441,16 @@
951811441 //System.out.println("object = " + object);
951911442 if (!frozen && !imageLocked)
952011443 {
9521
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11444
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
952211445 {
952311446 displayAntiAliased(gl);
952411447 } else
952511448 {
952611449 programcount = 0;
9527
- int keepmode = drawMode;
11450
+ int keepmode = DrawMode();
952811451 // if (DEBUG_SELECTION)
952911452 // {
9530
-// drawMode = SELECTION;
11453
+// DrawMode() = SELECTION;
953111454 // }
953211455 // for point selection
953311456 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9537,10 +11460,10 @@
953711460 DrawObject(gl);
953811461
953911462 // jan 2013 System.err.println("RESET ABORT (display)");
9540
- // if (drawMode == DEFAULT)
11463
+ // if (DrawMode() == DEFAULT)
954111464 // ABORTED = false;
954211465 fullreset = false;
9543
- drawMode = keepmode;
11466
+ Globals.drawMode = keepmode; // WARNING
954411467 //System.out.println("PROGRAM SWITCH " + programcount);
954511468 }
954611469 }
....@@ -9548,11 +11471,11 @@
954811471 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954911472 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
955011473
9551
- if (drawMode == DEFAULT)
11474
+ if (DrawMode() == DEFAULT)
955211475 {
955311476 ReleaseTexture(NOISE_TEXTURE, false);
955411477 }
9555
- //if (drawMode == DEFAULT)
11478
+ //if (DrawMode() == DEFAULT)
955611479 {
955711480
955811481 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9564,7 +11487,7 @@
956411487 //else
956511488 //gl.glDisable(gl.GL_TEXTURE_2D);
956611489 //gl.glPopMatrix();
9567
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11490
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956811491 {
956911492 //new Exception().printStackTrace();
957011493 //System.out.println("Draw image " + width + ", " + height);
....@@ -9606,7 +11529,7 @@
960611529 //gl.glFlush();
960711530 }
960811531
9609
- if (flash && drawMode == DEFAULT)
11532
+ if (flash && DrawMode() == DEFAULT)
961011533 {
961111534 flash = false;
961211535 wait = true;
....@@ -9614,9 +11537,9 @@
961411537 }
961511538
961611539 //drawing = false;
9617
- //if(drawMode == DEFAULT)
11540
+ //if(DrawMode() == DEFAULT)
961811541 // niceon = false;
9619
- if (drawMode == DEFAULT)
11542
+ if (DrawMode() == DEFAULT)
962011543 {
962111544 currentlydrawing = false;
962211545 }
....@@ -9636,7 +11559,7 @@
963611559 repaint();
963711560 }
963811561
9639
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11562
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
964011563 repaint();
964111564
964211565 displaydone = true;
....@@ -9655,8 +11578,14 @@
965511578 {
965611579 renderpass++;
965711580 // System.out.println("Draw object... ");
11581
+ STEP = 1;
965811582 if (FAST) // in case there is no script
9659
- STEP = 16;
11583
+ STEP = 8;
11584
+
11585
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11586
+ {
11587
+ STEP *= 4;
11588
+ }
966011589
966111590 //object.FullInvariants();
966211591
....@@ -9670,23 +11599,44 @@
967011599 e.printStackTrace();
967111600 }
967211601
9673
- if (GrafreeD.RENDERME > 0)
9674
- GrafreeD.RENDERME--; // mechante magouille
11602
+ if (Grafreed.RENDERME > 0)
11603
+ Grafreed.RENDERME--; // mechante magouille
967511604
9676
- ONESTEP = false;
11605
+ Globals.ONESTEP = false;
967711606 }
967811607
967911608 static boolean zoomonce = false;
968011609
11610
+ static void CreateSelectedPoint()
11611
+ {
11612
+ if (selectedpoint == null)
11613
+ {
11614
+ debugpointG = new Sphere();
11615
+ debugpointP = new Sphere();
11616
+ debugpointC = new Sphere();
11617
+ debugpointR = new Sphere();
11618
+
11619
+ selectedpoint = new Superellipsoid();
11620
+
11621
+ for (int i=0; i<8; i++)
11622
+ {
11623
+ debugpoints[i] = new Sphere();
11624
+ }
11625
+ }
11626
+ }
11627
+
968111628 void DrawObject(GL gl, boolean draw)
968211629 {
11630
+ // To clear camera values
11631
+ ResetOptions();
11632
+
968311633 //System.out.println("DRAW OBJECT " + mouseDown);
9684
-// drawMode = SELECTION;
11634
+// DrawMode() = SELECTION;
968511635 //GL gl = getGL();
968611636 if ((TRACK || SHADOWTRACK) || zoomonce)
968711637 {
9688
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
9689
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11638
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
969011640 pingthread.StepToTarget(true); // true);
969111641 // zoomonce = false;
969211642 }
....@@ -9706,9 +11656,9 @@
970611656 callist = gl.glGenLists(1);
970711657 }
970811658
9709
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11659
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
971011660
9711
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11661
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
971211662
971311663 if (!mainDL || !active || touched)
971411664 {
....@@ -9735,13 +11685,20 @@
973511685 PushMatrix(ClickInfo.matbuffer);
973611686 }
973711687
9738
- if (drawMode == 0)
11688
+ if (DrawMode() == 0)
973911689 {
974011690 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
974111691
974211692 usedtextures.clear();
974311693
9744
- BindTextures(DEFAULT_TEXTURES, 2);
11694
+ try
11695
+ {
11696
+ BindTextures(DEFAULT_TEXTURES, 2);
11697
+ }
11698
+ catch (Exception e)
11699
+ {
11700
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11701
+ }
974511702 }
974611703 //System.out.println("--> " + stackdepth);
974711704 // GrafreeD.traceon();
....@@ -9749,10 +11706,11 @@
974911706 // DRAW
975011707 object.draw(this, /*(Composite)*/ object, false, false);
975111708
9752
- if (drawMode == DEFAULT)
11709
+ if (DrawMode() == DEFAULT)
975311710 {
9754
- if (DEBUG)
11711
+ if (Globals.DEBUG)
975511712 {
11713
+ CreateSelectedPoint();
975611714 float radius = 0.05f;
975711715 if (selectedpoint.radius != radius)
975811716 {
....@@ -9801,38 +11759,57 @@
980111759 }
980211760 // GrafreeD.traceoff();
980311761 //System.out.println(stackdepth);
9804
- if (drawMode == 0)
11762
+ if (DrawMode() == 0)
980511763 {
980611764 ReleaseTextures(DEFAULT_TEXTURES);
980711765
980811766 if (CLEANCACHE)
9809
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
981011768 {
9811
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
981211770
981311771 // System.out.println("Texture --------- " + tex);
981411772
9815
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
981611774 continue;
981711775
9818
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
981911777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
982011779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
9821
- textures.get(tex).texture.dispose();
9822
- textures.remove(tex);
11780
+ if (gettex != null)
11781
+ {
11782
+ gettex.texture.dispose();
11783
+ texturepigment.remove(tex);
11784
+ }
11785
+
11786
+ gettex = texturebump.get(tex);
11787
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11788
+ if (gettex != null)
11789
+ {
11790
+ gettex.texture.dispose();
11791
+ texturebump.remove(tex);
11792
+ }
982311793 }
982411794 }
982511795 }
982611796
982711797 checker = null;
982811798
9829
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11799
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
983011800 FindChecker(object);
983111801
9832
- if (checker != null && drawMode == DEFAULT)
11802
+ if (checker != null && DrawMode() == DEFAULT)
983311803 {
983411804 //BindTexture(IMMORTAL_TEXTURE);
9835
- BindTextures(checker.GetTextures(), checker.texres);
11805
+ try
11806
+ {
11807
+ BindTextures(checker.GetTextures(), checker.texres);
11808
+ }
11809
+ catch (Exception e)
11810
+ {
11811
+ System.err.println("FAILED: " + checker.GetTextures());
11812
+ }
983611813 // NEAREST
983711814 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
983811815 DrawChecker(gl);
....@@ -9851,7 +11828,7 @@
985111828 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
985211829 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
985311830
9854
- if (DISPLAYTEXT && drawMode == DEFAULT)
11831
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
985511832 {
985611833 // Draw it once, then use the raster
985711834 Balloon(gl, balloon.createGraphics());
....@@ -9907,14 +11884,14 @@
990711884 int[] xs = new int[3];
990811885 int[] ys = new int[3];
990911886
9910
- void DrawString(Object3D obj) // String string)
11887
+ public void DrawString(Object3D obj) // String string) // INTERFACE
991111888 {
9912
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11889
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
991311890 {
991411891 return;
991511892 }
991611893
9917
- String string = obj.GetToolTip();
11894
+ String string = obj.toString(); //.GetToolTip();
991811895
991911896 GL gl = GetGL();
992011897
....@@ -10231,8 +12208,8 @@
1023112208 //obj.TransformToWorld(light, light);
1023212209 for (int i = tp.size(); --i >= 0;)
1023312210 {
10234
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
10235
- LA.xformPos(light, tp.get(i).toParent, light);
12211
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12212
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1023612213 }
1023712214
1023812215
....@@ -10249,8 +12226,8 @@
1024912226 parentcam = cameras[0];
1025012227 }
1025112228
10252
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10253
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12229
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12230
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1025412231
1025512232 LA.xformPos(light, renderCamera.toScreen, light);
1025612233
....@@ -10864,8 +12841,8 @@
1086412841
1086512842 // display shadow only (bump == 0)
1086612843 "SUB temp.x, half.x, shadow.x;" +
10867
- "MOV temp.y, -params6.x;" +
10868
- "SLT temp.z, temp.y, zero.x;" +
12844
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12845
+ "SLT temp.z, temp.y, -one2048th.x;" +
1086912846 "SUB temp.y, one.x, temp.z;" +
1087012847 "MUL temp.x, temp.x, temp.y;" +
1087112848 "KIL temp.x;" +
....@@ -10994,8 +12971,10 @@
1099412971 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1099512972
1099612973 "SUB temp.x, one.x, ndotl.x;" +
10997
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
10998
- "ADD temp.y, one.y, options2.y;" + // sursurface
12974
+ // Tuning for default skin
12975
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12976
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12977
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1099912978 "MUL temp.x, temp.x, temp.y;" +
1100012979
1100112980 "MUL saturation, saturation, temp.xxxx;" +
....@@ -11194,7 +13173,7 @@
1119413173 //once = true;
1119513174 }
1119613175
11197
- System.out.print("Program #" + mode + "; length = " + program.length());
13176
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1119813177 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1119913178 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1120013179
....@@ -11327,12 +13306,16 @@
1132713306
1132813307 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1132913308 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13309
+
13310
+ // Compare fragment depth in light space with shadowmap.
1133013311 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1133113312 "SGE temp.y, temp.x, zero.x;" +
11332
- "SUB " + shadow + ".y, one.x, temp.y;" +
13313
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13314
+
13315
+ // Reverse comparison
1133313316 "SUB temp.x, one.x, temp.x;" +
1133413317 "MUL " + shadow + ".x, temp.x, temp.y;" +
11335
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13318
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1133613319 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1133713320
1133813321 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11346,6 +13329,10 @@
1134613329 // No shadow for backface
1134713330 "DP3 temp.x, normal, lightd;" +
1134813331 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13332
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13333
+
13334
+ // No shadow when out of frustrum
13335
+ "SGE temp.x, " + depth + ".z, one.z;" +
1134913336 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1135013337 "";
1135113338 }
....@@ -11492,7 +13479,8 @@
1149213479 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1149313480 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1149413481 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
11495
- Object3D.cVector2[] vector2buffer;
13482
+
13483
+ //Object3D.cVector2[] vector2buffer;
1149613484
1149713485 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1149813486 // OUT : diff, spec
....@@ -11508,9 +13496,10 @@
1150813496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1150913497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1151013498 //"MOV " + dest + ".w," + "normal.z;" +
11511
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
11512
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
11513
- //"MOV " + dest + ".z," + "params2.w;" +
13499
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13500
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13501
+
13502
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1151413503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1151513504 "RCP " + dest + ".w," + dest + ".w;" +
1151613505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -11904,7 +13893,7 @@
1190413893 public void mousePressed(MouseEvent e)
1190513894 {
1190613895 //System.out.println("mousePressed: " + e);
11907
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13896
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1190813897 }
1190913898
1191013899 static long prevtime = 0;
....@@ -11931,6 +13920,7 @@
1193113920
1193213921 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1193313922
13923
+ if (BUTTONLESSWHEEL)
1193413924 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1193513925 {
1193613926 return;
....@@ -11939,7 +13929,7 @@
1193913929 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1194013930
1194113931 // TIMER
11942
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13932
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1194313933 {
1194413934 keepboxmode = BOXMODE;
1194513935 keepsupport = SUPPORT;
....@@ -11979,8 +13969,8 @@
1197913969 // mode |= META;
1198013970 //}
1198113971
11982
- SetMouseMode(WHEEL | e.getModifiersEx());
11983
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13972
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13973
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1198413974 anchorX = ax;
1198513975 anchorY = ay;
1198613976 prevX = px;
....@@ -12014,6 +14004,7 @@
1201414004 else
1201514005 if (evt.getSource() == AAtimer)
1201614006 {
14007
+ Globals.TIMERRUNNING = false;
1201714008 if (mouseDown)
1201814009 {
1201914010 //new Exception().printStackTrace();
....@@ -12039,6 +14030,10 @@
1203914030 // LIVE = waslive;
1204014031 // wasliveok = true;
1204114032 // waslive = false;
14033
+
14034
+ // May 2019 Forget it:
14035
+ if (true)
14036
+ return;
1204214037
1204314038 // source == timer
1204414039 if (mouseDown)
....@@ -12068,8 +14063,8 @@
1206814063 // ObjEditor.tweenManager.update(1f / 60f);
1206914064
1207014065 // fev 2014???
12071
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
12072
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14066
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1207314068 pingthread.StepToTarget(true); // true);
1207414069 }
1207514070 // if (!LIVE)
....@@ -12078,12 +14073,13 @@
1207814073
1207914074 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1208014075
12081
- void clickStart(int x, int y, int modifiers)
14076
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1208214077 {
1208314078 if (!wasliveok)
1208414079 return;
1208514080
1208614081 AAtimer.restart(); //
14082
+ Globals.TIMERRUNNING = true;
1208714083
1208814084 // waslive = LIVE;
1208914085 // LIVE = false;
....@@ -12095,7 +14091,7 @@
1209514091 // touched = true; // main DL
1209614092 if (isRenderer)
1209714093 {
12098
- SetMouseMode(modifiers);
14094
+ SetMouseMode(modifiers, modifiersex);
1209914095 }
1210014096
1210114097 selectX = anchorX = x;
....@@ -12108,7 +14104,7 @@
1210814104 clicked = true;
1210914105 hold = false;
1211014106
12111
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14107
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1211214108 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1211314109 {
1211414110 // System.out.println("RESTART II " + modifiers);
....@@ -12139,7 +14135,7 @@
1213914135 info.camera = renderCamera;
1214014136 info.x = x;
1214114137 info.y = y;
12142
- info.modifiers = modifiers;
14138
+ info.modifiers = modifiersex;
1214314139 editObj = object.doEditClick(info, 0);
1214414140 if (!editObj)
1214514141 {
....@@ -12156,11 +14152,14 @@
1215614152
1215714153 public void mouseDragged(MouseEvent e)
1215814154 {
14155
+ Globals.MOUSEDRAGGED = true;
14156
+
14157
+ //System.out.println("mouseDragged: " + e);
1215914158 if (isRenderer)
1216014159 movingcamera = true;
14160
+
1216114161 //if (drawing)
1216214162 //return;
12163
- //System.out.println("mouseDragged: " + e);
1216414163 if ((e.getModifiersEx() & CTRL) != 0
1216514164 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1216614165 {
....@@ -12168,7 +14167,7 @@
1216814167 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1216914168 }
1217014169 else
12171
- drag(e.getX(), e.getY(), e.getModifiersEx());
14170
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1217214171
1217314172 //try { Thread.sleep(1); } catch (Exception ex) {}
1217414173 }
....@@ -12180,6 +14179,11 @@
1218014179 cVector tmp = new cVector();
1218114180 cVector tmp2 = new cVector();
1218214181 boolean isMoving;
14182
+
14183
+ public cVector TargetLookAt()
14184
+ {
14185
+ return targetLookAt;
14186
+ }
1218314187
1218414188 class PingThread extends Thread
1218514189 {
....@@ -12319,7 +14323,7 @@
1231914323 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1232014324 if (lightMode)
1232114325 {
12322
- lighttouched = true;
14326
+ Globals.lighttouched = true;
1232314327 }
1232414328
1232514329 if (OEILONCE && OEIL)
....@@ -12336,6 +14340,7 @@
1233614340
1233714341 public void run()
1233814342 {
14343
+ new Exception().printStackTrace();
1233914344 System.exit(0);
1234014345 for (;;)
1234114346 {
....@@ -12377,7 +14382,7 @@
1237714382 mouseDown = false;
1237814383 if (lightMode)
1237914384 {
12380
- lighttouched = true;
14385
+ Globals.lighttouched = true;
1238114386 }
1238214387 repaint();
1238314388 alreadypainted = true;
....@@ -12385,7 +14390,7 @@
1238514390 isMoving = false;
1238614391 } //??
1238714392
12388
- if (isLIVE() && !alreadypainted)
14393
+ if (Globals.isLIVE() && !alreadypainted)
1238914394 {
1239014395 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1239114396 repaint();
....@@ -12397,9 +14402,9 @@
1239714402 {
1239814403 if (lightMode)
1239914404 {
12400
- lighttouched = true;
14405
+ Globals.lighttouched = true;
1240114406 }
12402
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14407
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1240314408 }
1240414409 //else
1240514410 }
....@@ -12413,12 +14418,12 @@
1241314418 void GoDown(int mod)
1241414419 {
1241514420 MODIFIERS |= COMMAND;
12416
- /*
14421
+ /**/
1241714422 if((mod&SHIFT) == SHIFT)
1241814423 manipCamera.RotatePosition(0, -speed);
1241914424 else
12420
- manipCamera.BackForth(0, -speed*delta, getWidth());
12421
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1242214427 if ((mod & SHIFT) == SHIFT)
1242314428 {
1242414429 mouseMode = mouseMode; // VR??
....@@ -12434,12 +14439,12 @@
1243414439 void GoUp(int mod)
1243514440 {
1243614441 MODIFIERS |= COMMAND;
12437
- /*
14442
+ /**/
1243814443 if((mod&SHIFT) == SHIFT)
1243914444 manipCamera.RotatePosition(0, speed);
1244014445 else
12441
- manipCamera.BackForth(0, speed*delta, getWidth());
12442
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1244314448 if ((mod & SHIFT) == SHIFT)
1244414449 {
1244514450 mouseMode = mouseMode;
....@@ -12455,12 +14460,12 @@
1245514460 void GoLeft(int mod)
1245614461 {
1245714462 MODIFIERS |= COMMAND;
12458
- /*
14463
+ /**/
1245914464 if((mod&SHIFT) == SHIFT)
12460
- manipCamera.RotatePosition(speed, 0);
12461
- else
1246214465 manipCamera.Translate(speed*delta, 0, getWidth());
12463
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1246414469 if ((mod & SHIFT) == SHIFT)
1246514470 {
1246614471 mouseMode = mouseMode;
....@@ -12476,12 +14481,12 @@
1247614481 void GoRight(int mod)
1247714482 {
1247814483 MODIFIERS |= COMMAND;
12479
- /*
14484
+ /**/
1248014485 if((mod&SHIFT) == SHIFT)
12481
- manipCamera.RotatePosition(-speed, 0);
12482
- else
1248314486 manipCamera.Translate(-speed*delta, 0, getWidth());
12484
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1248514490 if ((mod & SHIFT) == SHIFT)
1248614491 {
1248714492 mouseMode = mouseMode;
....@@ -12499,7 +14504,7 @@
1249914504 int X, Y;
1250014505 boolean SX, SY;
1250114506
12502
- void drag(int x, int y, int modifiers)
14507
+ void drag(int x, int y, int modifiers, int modifiersex)
1250314508 {
1250414509 if (IsFrozen())
1250514510 {
....@@ -12508,17 +14513,17 @@
1250814513
1250914514 drag = true; // NEW
1251014515
12511
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14516
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1251214517
1251314518 X = x;
1251414519 Y = y;
1251514520 // floating state for animation
12516
- MODIFIERS = modifiers;
12517
- modifiers &= ~1024;
14521
+ MODIFIERS = modifiersex;
14522
+ modifiersex &= ~1024;
1251814523 if (false) // modifiers != 0)
1251914524 {
1252014525 //new Exception().printStackTrace();
12521
- System.out.println("mouseDragged: " + modifiers);
14526
+ System.out.println("mouseDragged: " + modifiersex);
1252214527 System.out.println("SHIFT = " + SHIFT);
1252314528 System.out.println("CONTROL = " + COMMAND);
1252414529 System.out.println("META = " + META);
....@@ -12538,7 +14543,8 @@
1253814543 info.camera = renderCamera;
1253914544 info.x = x;
1254014545 info.y = y;
12541
- object.editWindow.copy.doEditDrag(info);
14546
+ object.GetWindow().copy
14547
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1254214548 } else
1254314549 {
1254414550 if (x < startX)
....@@ -12651,7 +14657,7 @@
1265114657
1265214658 if (manipCamera == lightCamera)
1265314659 {
12654
- lighttouched = true;
14660
+ Globals.lighttouched = true;
1265514661 }
1265614662 /*
1265714663 switch (mode)
....@@ -12690,7 +14696,6 @@
1269014696 public void mouseMoved(MouseEvent e)
1269114697 {
1269214698 //System.out.println("mouseMoved: " + e);
12693
-
1269414699 if (isRenderer)
1269514700 return;
1269614701
....@@ -12703,7 +14708,9 @@
1270314708 ci.camera = renderCamera;
1270414709 if (!isRenderer)
1270514710 {
12706
- if (object.editWindow.copy.doEditClick(ci, 0))
14711
+ //ObjEditor editWindow = object.editWindow;
14712
+ //Object3D copy = editWindow.copy;
14713
+ if (object.doEditClick(ci, 0))
1270714714 {
1270814715 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1270914716 } else
....@@ -12715,7 +14722,11 @@
1271514722
1271614723 public void mouseReleased(MouseEvent e)
1271714724 {
14725
+ Globals.MOUSEDRAGGED = false;
14726
+
1271814727 movingcamera = false;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1271914730 //System.out.println("mouseReleased: " + e);
1272014731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1272114732 }
....@@ -12738,9 +14749,9 @@
1273814749 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1273914750 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1274014751
12741
- if (control || command || IsFrozen())
14752
+// No delay if (control || command || IsFrozen())
1274214753 timeout = true;
12743
- else
14754
+// ?? May 2019 else
1274414755 // timer.setDelay((modifiers & 128) != 0?0:350);
1274514756 mouseDown = false;
1274614757 if (!control && !command) // june 2013
....@@ -12850,7 +14861,7 @@
1285014861 System.out.println("keyReleased: " + e);
1285114862 }
1285214863
12853
- void SetMouseMode(int modifiers)
14864
+ void SetMouseMode(int modifiers, int modifiersex)
1285414865 {
1285514866 //System.out.println("SetMouseMode = " + modifiers);
1285614867 //modifiers &= ~1024;
....@@ -12862,25 +14873,25 @@
1286214873 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1286314874 // return;
1286414875 //System.out.println("SetMode = " + modifiers);
12865
- if ((modifiers & WHEEL) == WHEEL)
14876
+ if ((modifiersex & WHEEL) == WHEEL)
1286614877 {
1286714878 mouseMode |= ZOOM;
1286814879 }
1286914880
1287014881 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
12871
- if (capsLocked || (modifiers & META) == META)
14882
+ if (capsLocked) // || (modifiers & META) == META)
1287214883 {
1287314884 mouseMode |= VR; // BACKFORTH;
1287414885 }
12875
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14886
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1287614887 {
1287714888 mouseMode |= SELECT;
1287814889 }
12879
- if ((modifiers & COMMAND) == COMMAND)
14890
+ if ((modifiersex & COMMAND) == COMMAND)
1288014891 {
1288114892 mouseMode |= SELECT;
1288214893 }
12883
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14894
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1288414895 {
1288514896 mouseMode &= ~VR;
1288614897 mouseMode |= TRANSLATE;
....@@ -12909,10 +14920,10 @@
1290914920
1291014921 if (isRenderer) //
1291114922 {
12912
- SetMouseMode(modifiers);
14923
+ SetMouseMode(0, modifiers);
1291314924 }
1291414925
12915
- theRenderer.keyPressed(key);
14926
+ Globals.theRenderer.keyPressed(key);
1291614927 }
1291714928
1291814929 int kompactbit = 4; // power bit
....@@ -12924,7 +14935,7 @@
1292414935 float SATPOW = 1; // 2; // 0.5f;
1292514936 float BRIPOW = 1; // 0.5f; // 0.5f;
1292614937
12927
- void keyPressed(int key)
14938
+ public void keyPressed(int key)
1292814939 {
1292914940 if (key >= '0' && key <= '5')
1293014941 clampbit = (key-'0');
....@@ -12971,7 +14982,8 @@
1297114982 // break;
1297214983 case 'T':
1297314984 CACHETEXTURE ^= true;
12974
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1297514987 // repaint();
1297614988 break;
1297714989 case 'Y':
....@@ -13039,7 +15051,7 @@
1303915051 case 'B':
1304015052 BRISMOOTH ^= true;
1304115053 SHADOWCULLFACE ^= true;
13042
- lighttouched = true;
15054
+ Globals.lighttouched = true;
1304315055 repaint();
1304415056 break;
1304515057 case 'b':
....@@ -13056,7 +15068,9 @@
1305615068 case 'E' : COMPACT ^= true;
1305715069 repaint();
1305815070 break;
13059
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1306015074 repaint();
1306115075 break;
1306215076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -13081,8 +15095,8 @@
1308115095 RevertCamera();
1308215096 repaint();
1308315097 break;
13084
- case 'L':
1308515098 case 'l':
15099
+ //case 'L':
1308615100 if (lightMode)
1308715101 {
1308815102 lightMode = false;
....@@ -13139,7 +15153,7 @@
1313915153 repaint();
1314015154 break;
1314115155 case 'O':
13142
- drawMode = OCCLUSION;
15156
+ Globals.drawMode = OCCLUSION; // WARNING
1314315157 repaint();
1314415158 break;
1314515159 case 'o':
....@@ -13225,12 +15239,12 @@
1322515239 case '_':
1322615240 kompactbit = 5;
1322715241 break;
13228
- case '+':
13229
- kompactbit = 6;
13230
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1323115245 case ' ':
1323215246 lightMode ^= true;
13233
- lighttouched = true;
15247
+ Globals.lighttouched = true;
1323415248 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1323515249 targetLookAt.set(manipCamera.lookAt);
1323615250 repaint();
....@@ -13239,14 +15253,15 @@
1323915253 case ESC:
1324015254 RENDERPROGRAM += 1;
1324115255 RENDERPROGRAM %= 3;
15256
+
1324215257 repaint();
1324315258 break;
1324415259 case 'Z':
1324515260 //RESIZETEXTURE ^= true;
1324615261 //break;
1324715262 case 'z':
13248
- RENDERSHADOW ^= true;
13249
- lighttouched = true;
15263
+ Globals.RENDERSHADOW ^= true;
15264
+ Globals.lighttouched = true;
1325015265 repaint();
1325115266 break;
1325215267 //case UP:
....@@ -13278,8 +15293,9 @@
1327815293 case DELETE:
1327915294 ClearSelection();
1328015295 break;
13281
- /*
1328215296 case '+':
15297
+
15298
+ /*
1328315299 //fontsize += 1;
1328415300 bbzoom *= 2;
1328515301 repaint();
....@@ -13296,17 +15312,17 @@
1329615312 case '=':
1329715313 IncDepth();
1329815314 //fontsize += 1;
13299
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1330015316 maskbit = 6;
1330115317 break;
1330215318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1330315319 DecDepth();
1330415320 maskbit = 5;
1330515321 //if(fontsize > 1) fontsize -= 1;
13306
- if (object.editWindow == null)
13307
- new Exception().printStackTrace();
13308
- else
13309
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1331015326 break;
1331115327 case '{':
1331215328 manipCamera.shaper_fovy /= 1.1;
....@@ -13361,6 +15377,7 @@
1336115377 }
1336215378 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1336315379 }
15380
+
1336415381 static double OCCLUSIONBOOST = 1; // 0.5;
1336515382
1336615383 void keyReleased(int key, int modifiers)
....@@ -13368,11 +15385,11 @@
1336815385 //mode = ROTATE;
1336915386 if ((MODIFIERS & COMMAND) == 0) // VR??
1337015387 {
13371
- SetMouseMode(modifiers);
15388
+ SetMouseMode(0, modifiers);
1337215389 }
1337315390 }
1337415391
13375
- protected void processKeyEvent(KeyEvent e)
15392
+ public void processKeyEvent(KeyEvent e)
1337615393 {
1337715394 switch (e.getID())
1337815395 {
....@@ -13502,8 +15519,9 @@
1350215519
1350315520 protected void processMouseMotionEvent(MouseEvent e)
1350415521 {
13505
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13506
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15522
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15523
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15524
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1350715525 {
1350815526 mouseMoved(e);
1350915527 } else
....@@ -13528,11 +15546,12 @@
1352815546 }
1352915547 */
1353015548
13531
- object.editWindow.EditSelection();
15549
+ object.GetWindow().EditSelection(false);
1353215550 }
1353315551
1353415552 void SelectParent()
1353515553 {
15554
+ new Exception().printStackTrace();
1353615555 System.exit(0);
1353715556 Composite group = (Composite) object;
1353815557 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13544,10 +15563,10 @@
1354415563 {
1354515564 //selectees.remove(i);
1354615565 System.out.println("select parent of " + elem);
13547
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1354815567 } else
1354915568 {
13550
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1355115570 }
1355215571
1355315572 first = false;
....@@ -13556,6 +15575,7 @@
1355615575
1355715576 void SelectChildren()
1355815577 {
15578
+ new Exception().printStackTrace();
1355915579 System.exit(0);
1356015580 /*
1356115581 Composite group = (Composite) object;
....@@ -13588,12 +15608,12 @@
1358815608 for (int j = 0; j < group.children.size(); j++)
1358915609 {
1359015610 elem = (Object3D) group.children.elementAt(j);
13591
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1359215612 first = false;
1359315613 }
1359415614 } else
1359515615 {
13596
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1359715617 }
1359815618
1359915619 first = false;
....@@ -13604,21 +15624,21 @@
1360415624 {
1360515625 //Composite group = (Composite) object;
1360615626 Object3D group = object;
13607
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1360815628 }
1360915629
1361015630 void ResetTransform(int mask)
1361115631 {
1361215632 //Composite group = (Composite) object;
1361315633 Object3D group = object;
13614
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1361515635 }
1361615636
1361715637 void FlipTransform()
1361815638 {
1361915639 //Composite group = (Composite) object;
1362015640 Object3D group = object;
13621
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1362215642 // group.editWindow.ReduceMesh(true);
1362315643 }
1362415644
....@@ -13626,7 +15646,7 @@
1362615646 {
1362715647 //Composite group = (Composite) object;
1362815648 Object3D group = object;
13629
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1363015650 // group.editWindow.ReduceMesh(true);
1363115651 }
1363215652
....@@ -13634,7 +15654,7 @@
1363415654 {
1363515655 //Composite group = (Composite) object;
1363615656 Object3D group = object;
13637
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1363815658 }
1363915659
1364015660 void IncDepth()
....@@ -13720,7 +15740,9 @@
1372015740 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1372115741 //Image img = CreateImage(width, height);
1372215742 //System.out.println("width = " + width + "; height = " + height + "\n");
15743
+
1372315744 Graphics gr = g; // img.getGraphics();
15745
+
1372415746 if (!hasMarquee)
1372515747 {
1372615748 if (Xmin < Xmax) // !locked)
....@@ -13808,6 +15830,7 @@
1380815830 info.bounds.y += (height - desired) / 2;
1380915831 }
1381015832 }
15833
+
1381115834 info.g = gr;
1381215835 info.camera = renderCamera;
1381315836 /*
....@@ -13817,15 +15840,55 @@
1381715840 */
1381815841 if (!isRenderer)
1381915842 {
13820
- object.drawEditHandles(info, 0);
15843
+ Grafreed.Assert(object != null);
15844
+ Grafreed.Assert(object.selection != null);
15845
+ if (object.selection.Size() > 0)
15846
+ {
15847
+ int hitSomething = object.selection.get(0).hitSomething;
15848
+
15849
+ info.DX = 0;
15850
+ info.DY = 0;
15851
+ info.W = 1;
15852
+ if (hitSomething == Object3D.hitCenter)
15853
+ {
15854
+ info.DX = X;
15855
+ if (X != 0)
15856
+ info.DX -= info.bounds.width/2;
15857
+
15858
+ info.DY = Y;
15859
+ if (Y != 0)
15860
+ info.DY -= info.bounds.height/2;
15861
+ }
15862
+
15863
+ object.drawEditHandles(info, 0);
15864
+
15865
+ if (drag && (X != 0 || Y != 0))
15866
+ {
15867
+ switch (hitSomething)
15868
+ {
15869
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15870
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15871
+ break;
15872
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15873
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15874
+ break;
15875
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15876
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15877
+ break;
15878
+ }
15879
+
15880
+ }
15881
+ }
1382115882 }
1382215883 }
15884
+
1382315885 if (isRenderer)
1382415886 {
1382515887 //gr.setColor(Color.black);
1382615888 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1382715889 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1382815890 }
15891
+
1382915892 if (hasMarquee)
1383015893 {
1383115894 gr.setXORMode(Color.white);
....@@ -13848,6 +15911,7 @@
1384815911 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1384915912 }
1385015913
15914
+ // To avoid clear.
1385115915 public void update(Graphics g)
1385215916 {
1385315917 paint(g);
....@@ -13937,6 +16001,7 @@
1393716001 public boolean mouseDown(Event evt, int x, int y)
1393816002 {
1393916003 System.out.println("mouseDown: " + evt);
16004
+ System.exit(0);
1394016005 /*
1394116006 locked = true;
1394216007 drag = false;
....@@ -13980,7 +16045,7 @@
1398016045 {
1398116046 keyPressed(0, modifiers);
1398216047 }
13983
- clickStart(x, y, modifiers);
16048
+ // clickStart(x, y, modifiers);
1398416049 return true;
1398516050 }
1398616051
....@@ -14098,7 +16163,7 @@
1409816163 {
1409916164 keyReleased(0, 0);
1410016165 }
14101
- drag(x, y, modifiers);
16166
+ drag(x, y, 0, modifiers);
1410216167 return true;
1410316168 }
1410416169
....@@ -14230,7 +16295,7 @@
1423016295 Object3D object;
1423116296 static Object3D trackedobject;
1423216297 Camera renderCamera; // Light or Eye (or Occlusion)
14233
- /*static*/ Camera manipCamera; // Light or Eye
16298
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1423416299 /*static*/ Camera eyeCamera;
1423516300 /*static*/ Camera lightCamera;
1423616301 int cameracount;
....@@ -14510,20 +16575,21 @@
1451016575 /**/
1451116576 //checker.GetMaterial().opacity = 1.1f;
1451216577 ////checker.GetMaterial().ambient = 0.99f;
14513
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14514
- Object3D.selectedstack[Object3D.materialdepth] = false;
14515
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16578
+ materialstack[materialdepth] = checker.material;
16579
+ selectedstack[materialdepth] = false;
16580
+ cStatic.objectstack[materialdepth++] = checker;
1451616581 //System.out.println("material " + material);
1451716582 //Applet3D.tracein(this, selected);
14518
- vector2buffer = checker.projectedVertices;
16583
+ //vector2buffer = checker.projectedVertices;
1451916584
14520
- checker.GetMaterial().Draw(this, false); // true);
16585
+ //checker.GetMaterial().Draw(this, false); // true);
16586
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1452116587
14522
- Object3D.materialdepth -= 1;
14523
- if (Object3D.materialdepth > 0)
16588
+ materialdepth -= 1;
16589
+ if (materialdepth > 0)
1452416590 {
14525
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14526
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16591
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16592
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1452716593 }
1452816594 //checker.GetMaterial().opacity = 1f;
1452916595 ////checker.GetMaterial().ambient = 1f;
....@@ -14609,6 +16675,14 @@
1460916675 }
1461016676 }
1461116677
16678
+ private Object3D GetFolder()
16679
+ {
16680
+ Object3D folder = object.GetWindow().copy;
16681
+ if (object.GetWindow().copy.selection.Size() > 0)
16682
+ folder = object.GetWindow().copy.selection.elementAt(0);
16683
+ return folder;
16684
+ }
16685
+
1461216686 class SelectBuffer implements GLEventListener
1461316687 {
1461416688
....@@ -14667,6 +16741,7 @@
1466716741 {
1466816742 if (!selection)
1466916743 {
16744
+ new Exception().printStackTrace();
1467016745 System.exit(0);
1467116746 return;
1467216747 }
....@@ -14687,17 +16762,39 @@
1468716762
1468816763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1468916764
16765
+ if (PAINTMODE)
16766
+ {
16767
+ if (object.GetWindow().copy.selection.Size() > 0)
16768
+ {
16769
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16770
+
16771
+ // Make what you paint not selectable.
16772
+ paintobj.ResetSelectable();
16773
+ }
16774
+ }
16775
+
1469016776 //int tmp = selection_view;
1469116777 //selection_view = -1;
14692
- int temp = drawMode;
14693
- drawMode = SELECTION;
16778
+ int temp = DrawMode();
16779
+ Globals.drawMode = SELECTION; // WARNING
1469416780 indexcount = 0;
1469516781 parent.display(drawable);
1469616782 //selection_view = tmp;
1469716783 //if (temp == SELECTION)
1469816784 // temp = DEFAULT; // patch for selection debug
14699
- drawMode = temp;
16785
+ Globals.drawMode = temp; // WARNING
1470016786
16787
+ if (PAINTMODE)
16788
+ {
16789
+ if (object.GetWindow().copy.selection.Size() > 0)
16790
+ {
16791
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16792
+
16793
+ // Revert.
16794
+ paintobj.RestoreSelectable();
16795
+ }
16796
+ }
16797
+
1470116798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1470216799
1470316800 // trying different ways of getting the depth info over
....@@ -14745,6 +16842,8 @@
1474516842 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1474616843 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1474716844 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16845
+
16846
+ CreateSelectedPoint();
1474816847
1474916848 // Will fit the mesh !!!
1475016849 selectedpoint.toParent[0][0] = 0.0001;
....@@ -14794,34 +16893,36 @@
1479416893 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]));
1479516894 }
1479616895
14797
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16896
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1479816897 }
1479916898 }
1480016899
1480116900 if (!movingcamera && !PAINTMODE)
14802
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1480316902
14804
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16903
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1480516904 {
14806
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16905
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1480716906
14808
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1480916910
14810
- group.CreateMaterial(); // use a void leaf to select instances
14811
-
14812
- group.add(paintobj); // link
14813
-
14814
- object.editWindow.SnapObject(group);
14815
-
14816
- Object3D folder = object.editWindow.copy;
14817
-
14818
- if (object.editWindow.copy.selection.Size() > 0)
14819
- folder = object.editWindow.copy.selection.elementAt(0);
14820
-
14821
- folder.add(group);
14822
-
14823
- object.editWindow.ResetModel();
14824
- object.editWindow.refreshContents();
16911
+ Object3D inst = new Object3D("inst" + paintcount++);
16912
+
16913
+ inst.CreateMaterial(); // use a void leaf to select instances
16914
+
16915
+ inst.add(paintobj); // link
16916
+
16917
+ object.GetWindow().SnapObject(inst);
16918
+
16919
+ Object3D folder = paintFolder; // GetFolder();
16920
+
16921
+ folder.add(inst);
16922
+
16923
+ object.GetWindow().ResetModel();
16924
+ object.GetWindow().refreshContents();
16925
+ }
1482516926 }
1482616927 else
1482716928 paintcount = 0;
....@@ -14860,6 +16961,11 @@
1486016961 //System.out.println("objects[color] = " + objects[color]);
1486116962 //objects[color].Select();
1486216963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1486316969 object.Select(color, deselect);
1486416970 }
1486516971
....@@ -14959,7 +17065,7 @@
1495917065 gl.glDisable(gl.GL_CULL_FACE);
1496017066 }
1496117067
14962
- if (!RENDERSHADOW)
17068
+ if (!Globals.RENDERSHADOW)
1496317069 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1496417070
1496517071 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14969,14 +17075,14 @@
1496917075 //gl.glColorMask(false, false, false, false);
1497017076
1497117077 //render_scene_from_light_view(gl, drawable, 0, 0);
14972
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
17078
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1497317079 {
1497417080 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1497517081
14976
- int temp = drawMode;
14977
- drawMode = SHADOW;
17082
+ int temp = DrawMode();
17083
+ Globals.drawMode = SHADOW; // WARNING
1497817084 parent.display(drawable);
14979
- drawMode = temp;
17085
+ Globals.drawMode = temp; // WARNING
1498017086 }
1498117087
1498217088 gl.glCullFace(gl.GL_BACK);
....@@ -15029,7 +17135,6 @@
1502917135
1503017136 class AntialiasBuffer implements GLEventListener
1503117137 {
15032
-
1503317138 CameraPane parent = null;
1503417139
1503517140 AntialiasBuffer(CameraPane p)
....@@ -15374,12 +17479,6 @@
1537417479 GLUT glut = new GLUT();
1537517480
1537617481
15377
- static final public int DEFAULT = 0;
15378
- static final public int SELECTION = 1;
15379
- static final public int SHADOW = 2;
15380
- static final public int OCCLUSION = 3;
15381
- static
15382
- public int drawMode = DEFAULT;
1538317482 public boolean spherical = false;
1538417483 static boolean DEBUG_OCCLUSION = false;
1538517484 static boolean DEBUG_SELECTION = false;
....@@ -15392,23 +17491,15 @@
1539217491 int AAbuffersize = 0;
1539317492
1539417493 //double[] selectedpoint = new double[3];
15395
- static Superellipsoid selectedpoint = new Superellipsoid();
17494
+ static Superellipsoid selectedpoint;
1539617495 static Sphere previousselectedpoint = null;
15397
- static Sphere debugpointG = new Sphere();
15398
- static Sphere debugpointP = new Sphere();
15399
- static Sphere debugpointC = new Sphere();
15400
- static Sphere debugpointR = new Sphere();
17496
+ static Sphere debugpointG;
17497
+ static Sphere debugpointP;
17498
+ static Sphere debugpointC;
17499
+ static Sphere debugpointR;
1540117500
1540217501 static Sphere debugpoints[] = new Sphere[8];
1540317502
15404
- static
15405
- {
15406
- for (int i=0; i<8; i++)
15407
- {
15408
- debugpoints[i] = new Sphere();
15409
- }
15410
- }
15411
-
1541217503 static void InitPoints(float radius)
1541317504 {
1541417505 for (int i=0; i<8; i++)
....@@ -15428,7 +17519,7 @@
1542817519 }
1542917520 }
1543017521
15431
- static void DrawPoints(CameraPane cpane)
17522
+ static void DrawPoints(iCameraPane cpane)
1543217523 {
1543317524 for (int i=0; i<8; i++) // first and last are red
1543417525 {
....@@ -15460,10 +17551,11 @@
1546017551 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1546117552 // Depth buffer format
1546217553 //private int depth_format;
15463
- static public void NextIndex(Object3D o, GL gl)
17554
+
17555
+ public void NextIndex()
1546417556 {
1546517557 indexcount+=16;
15466
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17558
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1546717559 //objects[indexcount] = o;
1546817560 //System.out.println("indexcount = " + indexcount);
1546917561 }