Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
CameraPane.java
....@@ -31,8 +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 cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3640 static boolean DEBUG = false;
3741 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3842
....@@ -42,25 +46,7 @@
4246
4347 static int STEP = 1;
4448
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
51
- {
52
- return LIVE || ONESTEP;
53
- }
54
-
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;
49
+ /*static*/ private boolean CULLFACE = false; // true;
6450 /*static*/ boolean NEAREST = false; // true;
6551 /*static*/ boolean WIREFRAME = false; // true;
6652
....@@ -70,8 +56,6 @@
7056 static int CURRENTANTIALIAS = 0; // 1;
7157 /*static*/ boolean RENDERSHADOW = true;
7258 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
73
- static boolean ANIMATION = false;
74
- static String filename;
7559
7660 boolean DISPLAYTEXT = false;
7761 //boolean REDUCETEXTURE = true;
....@@ -97,10 +81,8 @@
9781
9882 static boolean textureon = true;
9983 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10184 static boolean FULLSCREEN = false;
10285 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10486 static boolean INERTIA = true;
10587 static boolean FAST = false;
10688 static boolean SLOWPOSE = false;
....@@ -108,6 +90,8 @@
10890
10991 static int tickcount = 0; // slow pose issue
11092
93
+static boolean BUTTONLESSWHEEL = false;
94
+static boolean ZOOMBOXMODE = false;
11195 static boolean BOXMODE = false;
11296 static boolean IMAGEFLIP = false;
11397 static boolean SMOOTHFOCUS = false;
....@@ -122,7 +106,7 @@
122106 static boolean OEIL = true;
123107 static boolean OEILONCE = false; // do oeilon then oeiloff
124108 static boolean LOOKAT = true;
125
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
126110 static boolean HANDLES = false; // selection doesn't work!!
127111 static boolean PAINTMODE = false;
128112
....@@ -165,12 +149,13 @@
165149 defaultcaps.setAccumBlueBits(16);
166150 defaultcaps.setAccumAlphaBits(16);
167151 }
168
- static CameraPane theRenderer;
169
-
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154
+
170155 void SetAsGLRenderer(boolean b)
171156 {
172157 isRenderer = b;
173
- theRenderer = this;
158
+ Globals.theRenderer = this;
174159 }
175160
176161 CameraPane(Object3D o, Camera cam, boolean withcontext)
....@@ -206,12 +191,53 @@
206191 return CURRENTANTIALIAS > 0;
207192 }
208193
209
- void ClearDepth()
194
+ /// INTERFACE
195
+
196
+ public javax.media.opengl.GL GetGL0()
197
+ {
198
+ return null;
199
+ }
200
+
201
+ public int GenList()
202
+ {
203
+ javax.media.opengl.GL gl = GetGL();
204
+ return gl.glGenLists(1);
205
+ }
206
+
207
+ public void NewList(int id)
208
+ {
209
+ javax.media.opengl.GL gl = GetGL();
210
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
211
+ }
212
+
213
+ public void CallList(int id)
214
+ {
215
+ javax.media.opengl.GL gl = GetGL();
216
+ gl.glCallList(id);
217
+ }
218
+
219
+ public void EndList()
220
+ {
221
+ javax.media.opengl.GL gl = GetGL();
222
+ gl.glEndList();
223
+ }
224
+
225
+ public boolean IsBoxMode()
226
+ {
227
+ return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
233
+ }
234
+
235
+ public void ClearDepth()
210236 {
211237 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
212238 }
213239
214
- void DepthTest(boolean depthtest)
240
+ public void DepthTest(boolean depthtest)
215241 {
216242 if (depthtest)
217243 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -219,7 +245,7 @@
219245 GetGL().glDepthFunc(GL.GL_ALWAYS);
220246 }
221247
222
- void DepthWrite(boolean depthwrite)
248
+ public void DepthWrite(boolean depthwrite)
223249 {
224250 if (depthwrite)
225251 GetGL().glDepthMask(true);
....@@ -227,12 +253,1602 @@
227253 GetGL().glDepthMask(false);
228254 }
229255
230
- void BackFaceCull(boolean bfc)
256
+ public void BackFaceCull(boolean bfc)
231257 {
232258 if (bfc)
233259 GetGL().glEnable(GetGL().GL_CULL_FACE);
234260 else
235261 GetGL().glDisable(GetGL().GL_CULL_FACE);
262
+ }
263
+
264
+ public boolean BackFaceCullMode()
265
+ {
266
+ return this.CULLFACE;
267
+ }
268
+
269
+ public boolean IsAmbientOcclusionOn()
270
+ {
271
+ return this.ambientOcclusion;
272
+ }
273
+
274
+ public boolean IsDebugSelection()
275
+ {
276
+ return DEBUG_SELECTION;
277
+ }
278
+
279
+ public boolean IsFrozen()
280
+ {
281
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
282
+
283
+ return !selectmode && cameracount == 0; // != 0;
284
+ }
285
+
286
+ // Currently in Globals
287
+ public int DrawMode()
288
+ {
289
+ return Globals.DrawMode();
290
+ }
291
+
292
+ public Camera EyeCamera()
293
+ {
294
+ return eyeCamera;
295
+ }
296
+
297
+ public Camera LightCamera()
298
+ {
299
+ return lightCamera;
300
+ }
301
+
302
+ public Camera ManipCamera()
303
+ {
304
+ return manipCamera;
305
+ }
306
+
307
+ public Camera RenderCamera()
308
+ {
309
+ return renderCamera;
310
+ }
311
+
312
+ public Camera[] Cameras()
313
+ {
314
+ return cameras;
315
+ }
316
+
317
+ public void PushMaterial(Object3D obj, boolean selected)
318
+ {
319
+ CameraPane display = this;
320
+ javax.media.opengl.GL gl = display.GetGL();
321
+ cMaterial material = obj.material;
322
+
323
+ if (material != null)
324
+ {
325
+ materialstack[materialdepth] = material;
326
+ selectedstack[materialdepth] = selected;
327
+ cStatic.objectstack[materialdepth++] = obj;
328
+ //System.out.println("material " + material);
329
+ //Applet3D.tracein(this, selected);
330
+ display.vector2buffer = obj.projectedVertices;
331
+ if (obj instanceof Camera)
332
+ {
333
+ display.options1[0] = material.shift;
334
+ //System.out.println("shift " + material.shift);
335
+ display.options1[1] = material.lightarea;
336
+ display.options1[2] = material.shadowbias;
337
+ display.options1[3] = material.aniso;
338
+ display.options1[4] = material.anisoV;
339
+ display.options2[0] = material.opacity;
340
+ display.options2[1] = material.diffuse;
341
+ display.options2[2] = material.factor;
342
+
343
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
344
+ display.options4[0] = material.cameralight/0.2f;
345
+ display.options4[1] = material.subsurface;
346
+ display.options4[2] = material.sheen;
347
+
348
+ // if (display.CURRENTANTIALIAS > 0)
349
+ // display.options3[3] /= 4;
350
+
351
+ /*
352
+ System.out.println("Focus = " + display.options1[0]);
353
+ System.out.println("Aperture = " + display.options1[1]);
354
+ System.out.println("ShadowBlur = " + display.options1[2]);
355
+ System.out.println("Antialiasing = " + display.options1[3]);
356
+ System.out.println("Fog = " + display.options2[0]);
357
+ System.out.println("Intensity = " + display.options2[1]);
358
+ System.out.println("Elevation = " + display.options2[2]);
359
+ /**/
360
+ } else
361
+ {
362
+ DrawMaterial(material, selected);
363
+ }
364
+ } else
365
+ {
366
+ if (selected && CameraPane.flash)
367
+ {
368
+ display.modelParams4[1] = 100;
369
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
370
+ }
371
+ }
372
+ }
373
+
374
+ public void PushMaterial2(Object3D obj, boolean selected)
375
+ {
376
+ CameraPane display = this;
377
+ cMaterial material = obj.material;
378
+
379
+ if (material != null)
380
+ {
381
+ materialstack[materialdepth] = material;
382
+ selectedstack[materialdepth] = selected;
383
+ cStatic.objectstack[materialdepth++] = obj;
384
+ //System.out.println("material " + material);
385
+ //Applet3D.tracein("selected ", selected);
386
+ display.vector2buffer = obj.projectedVertices;
387
+ display.DrawMaterial(material, selected);
388
+ }
389
+ }
390
+
391
+ public void PopMaterial(Object3D obj, boolean selected)
392
+ {
393
+ CameraPane display = this;
394
+ javax.media.opengl.GL gl = display.GetGL();
395
+ cMaterial material = obj.material;
396
+
397
+ //if (parent != null && parent.GetMaterial() != null)
398
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
399
+ if (material != null)
400
+ {
401
+ materialdepth -= 1;
402
+ if (materialdepth > 0)
403
+ {
404
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
406
+ }
407
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
409
+ {
410
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
411
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
412
+ }
413
+ }
414
+
415
+ public void PopMaterial2(Object3D obj)
416
+ {
417
+ CameraPane display = this;
418
+ cMaterial material = obj.material;
419
+
420
+ if (material != null)
421
+ {
422
+ materialdepth -= 1;
423
+ if (materialdepth > 0)
424
+ {
425
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
427
+ }
428
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429
+ //else
430
+ //material.Draw(display, false);
431
+ }
432
+ }
433
+
434
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
435
+ {
436
+ CameraPane display = this;
437
+
438
+ if (pv.y == -10000 ||
439
+ qv.y == -10000 ||
440
+ rv.y == -10000)
441
+ return;
442
+
443
+// float b = f.nbiterations & 1;
444
+// float g = (f.nbiterations>>1) & 1;
445
+// float r = (f.nbiterations>>2) & 1;
446
+//
447
+// //if (f.weight == 10000)
448
+// //{
449
+// // r = 1; g = b = 0;
450
+// //}
451
+// //else
452
+// //{
453
+// // assert(f.weight < 10000);
454
+// r = g = b = (float)bRep.FaceWeight(f)*100;
455
+// if (r<0)
456
+// assert(r>=0);
457
+// //}
458
+
459
+ javax.media.opengl.GL gl = display.GetGL();
460
+
461
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
462
+
463
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
464
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465
+ {
466
+ //gl.glBegin(gl.GL_TRIANGLES);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
468
+ // TEST LIVE NORMALS && !obj.dontselect
469
+ ;
470
+ if (!hasnorm)
471
+ {
472
+ // System.out.println("Mesh normal");
473
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
474
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
475
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
476
+ LA.vecNormalize(obj.v2);
477
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
478
+ }
479
+
480
+ // P
481
+ float x = (float)pv.x;
482
+ float y = (float)pv.y;
483
+ float z = (float)pv.z;
484
+
485
+ if (hasnorm)
486
+ {
487
+// if (!pv.norm.normalized())
488
+// assert(pv.norm.normalized());
489
+
490
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
491
+ float nx = (float)pv.norm.x;
492
+ float ny = (float)pv.norm.y;
493
+ float nz = (float)pv.norm.z;
494
+
495
+ x += nx * obj.NORMALPUSH;
496
+ y += ny * obj.NORMALPUSH;
497
+ z += nz * obj.NORMALPUSH;
498
+
499
+ gl.glNormal3f(nx, ny, nz);
500
+ }
501
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
502
+ SetColor(obj, pv);
503
+ //gl.glColor4f(r, g, b, 1);
504
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
505
+ if (obj.flipV)
506
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
507
+ else
508
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
509
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
510
+
511
+ gl.glVertex3f(x, y, z);
512
+
513
+ // Q
514
+ x = (float)qv.x;
515
+ y = (float)qv.y;
516
+ z = (float)qv.z;
517
+
518
+// Print(pv);
519
+ if (hasnorm)
520
+ {
521
+// assert(qv.norm.normalized());
522
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
523
+ float nx = (float)qv.norm.x;
524
+ float ny = (float)qv.norm.y;
525
+ float nz = (float)qv.norm.z;
526
+
527
+ x += nx * obj.NORMALPUSH;
528
+ y += ny * obj.NORMALPUSH;
529
+ z += nz * obj.NORMALPUSH;
530
+
531
+ gl.glNormal3f(nx, ny, nz);
532
+ }
533
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
534
+ // boolean locked = false;
535
+ // float eps = 0.1f;
536
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
537
+
538
+ // int dot = 0; //*/ (int)f.dot;
539
+
540
+ // if ((dot&1) == 0)
541
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
542
+
543
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
544
+ if (obj.flipV)
545
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
546
+ else
547
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
548
+ // else
549
+ // {
550
+ // locked = true;
551
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
552
+ // }
553
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
554
+ SetColor(obj, qv);
555
+
556
+ gl.glVertex3f(x, y, z);
557
+ //gl.glColor4f(r, g, b, 1);
558
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
559
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
560
+// Print(qv);
561
+
562
+ // R
563
+ x = (float)rv.x;
564
+ y = (float)rv.y;
565
+ z = (float)rv.z;
566
+
567
+ if (hasnorm)
568
+ {
569
+// assert(rv.norm.normalized());
570
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
571
+ float nx = (float)rv.norm.x;
572
+ float ny = (float)rv.norm.y;
573
+ float nz = (float)rv.norm.z;
574
+
575
+ x += nx * obj.NORMALPUSH;
576
+ y += ny * obj.NORMALPUSH;
577
+ z += nz * obj.NORMALPUSH;
578
+
579
+ gl.glNormal3f(nx, ny, nz);
580
+ }
581
+
582
+ // if ((dot&4) == 0)
583
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
584
+
585
+ // if (wrap || !locked && (dot&8) != 0)
586
+ if (obj.flipV)
587
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
588
+ else
589
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
590
+ // else
591
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
592
+
593
+ // f.dot = dot;
594
+
595
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
596
+ SetColor(obj, rv);
597
+ //gl.glColor4f(r, g, b, 1);
598
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
599
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
600
+ gl.glVertex3f(x, y, z);
601
+// Print(rv);
602
+ //gl.glEnd();
603
+ }
604
+ else
605
+ {
606
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
607
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
608
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
609
+
610
+ }
611
+
612
+ if (false) // (attributes & WIREFRAME) != 0)
613
+ {
614
+ gl.glDisable(gl.GL_LIGHTING);
615
+
616
+ gl.glBegin(gl.GL_LINE_LOOP);
617
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
618
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
619
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
620
+ gl.glEnd();
621
+
622
+ gl.glEnable(gl.GL_LIGHTING);
623
+ }
624
+ }
625
+
626
+ /**
627
+ * <code>draw</code> renders a <code>TriMesh</code> object including
628
+ * it's normals, colors, textures and vertices.
629
+ *
630
+ * @see Renderer#draw(TriMesh)
631
+ * @param tris
632
+ * the mesh to render.
633
+ */
634
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
635
+ {
636
+ CameraPane display = this;
637
+
638
+ float r = display.modelParams0[0];
639
+ float g = display.modelParams0[1];
640
+ float b = display.modelParams0[2];
641
+ float opacity = display.modelParams5[1];
642
+
643
+ //final GL gl = GLU.getCurrentGL();
644
+ GL gl = display.GetGL(); // getGL();
645
+
646
+ FloatBuffer vertBuf = geo.vertBuf;
647
+
648
+ int v = vertBuf.capacity();
649
+
650
+ int count = 0;
651
+
652
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
653
+ gl.glEnable(gl.GL_CULL_FACE);
654
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
655
+ for (int i=0; i<v/3; i++)
656
+ {
657
+ int index3 = i*3;
658
+
659
+ if (geo.sizeBuf.get(index3+1) == 0)
660
+ continue;
661
+
662
+ count++;
663
+
664
+ int index4 = i*4;
665
+
666
+ float tx = vertBuf.get(index3);
667
+ float ty = vertBuf.get(index3+1);
668
+ float tz = vertBuf.get(index3+2);
669
+
670
+ // if (tx == 0 && ty == 0 && tz == 0)
671
+ // continue;
672
+
673
+ gl.glMatrixMode(gl.GL_TEXTURE);
674
+ gl.glPushMatrix();
675
+
676
+ float[] texmat = geo.texmat;
677
+ texmat[12] = texmat[13] = texmat[14] = i;
678
+
679
+ gl.glMultMatrixf(texmat, 0);
680
+
681
+ gl.glMatrixMode(gl.GL_MODELVIEW);
682
+ gl.glPushMatrix();
683
+
684
+ gl.glTranslatef(tx,ty,tz);
685
+
686
+ if (rotate)
687
+ gl.glRotatef(i, 0, 1, 0);
688
+
689
+ float size = geo.sizeBuf.get(index3) / 100;
690
+ gl.glScalef(size,size,size);
691
+
692
+ float cr = geo.colorBuf.get(index4);
693
+ float cg = geo.colorBuf.get(index4+1);
694
+ float cb = geo.colorBuf.get(index4+2);
695
+ float ca = geo.colorBuf.get(index4+3);
696
+
697
+ display.modelParams0[0] = r * cr;
698
+ display.modelParams0[1] = g * cg;
699
+ display.modelParams0[2] = b * cb;
700
+
701
+ display.modelParams5[1] = opacity * ca;
702
+
703
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
704
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
705
+
706
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
707
+ RandomNode.globalseed2 = RandomNode.globalseed;
708
+
709
+// gl.glColor4f(cr,cg,cb,ca);
710
+ // gl.glScalef(1024/16,1024/16,1024/16);
711
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
712
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
713
+ //gl.glTranslatef(-tx,-ty,-tz);
714
+ gl.glPopMatrix();
715
+
716
+ gl.glMatrixMode(gl.GL_TEXTURE);
717
+ gl.glPopMatrix();
718
+ }
719
+ // gl.glScalef(1024,1024,1024);
720
+ if (!cf)
721
+ gl.glDisable(gl.GL_CULL_FACE);
722
+
723
+ display.modelParams0[0] = r;
724
+ display.modelParams0[1] = g;
725
+ display.modelParams0[2] = b;
726
+
727
+ display.modelParams5[1] = opacity;
728
+
729
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
730
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
731
+
732
+ gl.glMatrixMode(gl.GL_MODELVIEW);
733
+
734
+// System.err.println("total = " + v/3 + "; displayed = " + count);
735
+ if (true)
736
+ return;
737
+
738
+//// if (!tris.predraw(this))
739
+//// {
740
+//// return;
741
+//// }
742
+//// if (Debug.stats)
743
+//// {
744
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
745
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
746
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
747
+//// }
748
+////
749
+//// if (tris.getDisplayListID() != -1)
750
+//// {
751
+//// renderDisplayList(tris);
752
+//// return;
753
+//// }
754
+////
755
+//// if (!generatingDisplayList)
756
+//// {
757
+//// applyStates(tris.states, tris);
758
+//// }
759
+//// if (Debug.stats)
760
+//// {
761
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
762
+//// }
763
+//// boolean transformed = doTransforms(tris);
764
+//
765
+// int glMode = GL.GL_TRIANGLES;
766
+// switch (getMode())
767
+// {
768
+// case Triangles:
769
+// glMode = GL.GL_TRIANGLES;
770
+// break;
771
+// case Strip:
772
+// glMode = GL.GL_TRIANGLE_STRIP;
773
+// break;
774
+// case Fan:
775
+// glMode = GL.GL_TRIANGLE_FAN;
776
+// break;
777
+// }
778
+//
779
+// if (!predrawGeometry(gl))
780
+// {
781
+// // make sure only the necessary indices are sent through on old
782
+// // cards.
783
+// IntBuffer indices = this.getIndexBuffer();
784
+// if (indices == null)
785
+// {
786
+// logger.severe("missing indices on geometry object: " + this.toString());
787
+// } else
788
+// {
789
+// indices.rewind();
790
+// indices.limit(this.getMaxIndex());
791
+//
792
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
793
+//
794
+// indices.clear();
795
+// }
796
+// } else
797
+// {
798
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
799
+// GL.GL_UNSIGNED_INT, 0);
800
+// }
801
+//
802
+//// postdrawGeometry(tris);
803
+//// if (transformed)
804
+//// {
805
+//// undoTransforms(tris);
806
+//// }
807
+////
808
+//// if (Debug.stats)
809
+//// {
810
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
811
+//// }
812
+//// tris.postdraw(this);
813
+ }
814
+
815
+ static Camera localcamera = new Camera();
816
+ static cVector from = new cVector();
817
+ static cVector to = new cVector();
818
+
819
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
820
+ {
821
+ CameraPane cp = this;
822
+
823
+ Camera keep = cp.RenderCamera();
824
+ cp.renderCamera = localcamera;
825
+
826
+ if (br.trimmed)
827
+ {
828
+ float[] colors = new float[br.positions.length / 3];
829
+
830
+ int i3 = 0;
831
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
832
+ {
833
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
834
+ continue;
835
+
836
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
837
+ to.set(br.positions[i3] + br.normals[i3],
838
+ br.positions[i3 + 1] + br.normals[i3 + 1],
839
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
840
+ LA.xformPos(from, transform, from);
841
+ LA.xformPos(to, transform, to); // RIGID ONLY
842
+ localcamera.setAim(from, to);
843
+
844
+ CameraPane.occlusionbuffer.display();
845
+
846
+ if (CameraPane.DEBUG_OCCLUSION)
847
+ cp.display(); // debug
848
+
849
+ colors[i] = cp.vertexOcclusion.r;
850
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
851
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
852
+
853
+ if ((i % 100) == 0 && i != 0)
854
+ {
855
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
856
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
857
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
858
+ }
859
+ }
860
+
861
+ br.colors = colors;
862
+ }
863
+ else
864
+ {
865
+ for (int i = 0; i < br.VertexCount(); i++)
866
+ {
867
+ Vertex v = br.GetVertex(i);
868
+
869
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
870
+ continue;
871
+
872
+ from.set(v.x, v.y, v.z);
873
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
874
+ LA.xformPos(from, transform, from);
875
+ LA.xformPos(to, transform, to); // RIGID ONLY
876
+ localcamera.setAim(from, to);
877
+
878
+ CameraPane.occlusionbuffer.display();
879
+
880
+ if (CameraPane.DEBUG_OCCLUSION)
881
+ cp.display(); // debug
882
+
883
+ v.AO = cp.vertexOcclusion.r;
884
+
885
+ if ((i % 100) == 0 && i != 0)
886
+ {
887
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
888
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
889
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
890
+ }
891
+ }
892
+ }
893
+
894
+ //System.out.println("done.");
895
+
896
+ cp.renderCamera = keep;
897
+ }
898
+
899
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
900
+ {
901
+ CameraPane display = this;
902
+ pointFlow.CreateHT();
903
+
904
+ float r = display.modelParams0[0];
905
+ float g = display.modelParams0[1];
906
+ float b = display.modelParams0[2];
907
+ float opacity = display.modelParams5[1];
908
+
909
+ //final GL gl = GLU.getCurrentGL();
910
+ GL gl = display.GetGL(); // getGL();
911
+
912
+ int s = pointFlow.points.size();
913
+
914
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
915
+ gl.glEnable(gl.GL_CULL_FACE);
916
+
917
+ for (int i=s; --i>=0;)
918
+ //for (int i=0; i<s; i++)
919
+ {
920
+ cVector v = pointFlow.points.get(i);
921
+
922
+ double mindist = Double.MAX_VALUE;
923
+
924
+ double size = pointFlow.minimumSize;
925
+
926
+ double distancenext = 0;
927
+
928
+ if (i > 0)
929
+ {
930
+ cVector w = pointFlow.points.get(i-1);
931
+
932
+ double dist = w.distance(v);
933
+
934
+ distancenext = dist;
935
+
936
+ if (mindist > dist)
937
+ {
938
+ mindist = dist;
939
+ size = mindist*pointFlow.resizefactor;
940
+ }
941
+ }
942
+
943
+ if (i < s-1)
944
+ {
945
+ cVector w = pointFlow.points.get(i+1);
946
+
947
+ double dist = w.distance(v);
948
+
949
+ if (mindist > dist)
950
+ {
951
+ mindist = dist;
952
+ size = mindist*pointFlow.resizefactor;
953
+ }
954
+ }
955
+
956
+ if (size < pointFlow.minimumSize)
957
+ size = pointFlow.minimumSize;
958
+ if (size > pointFlow.maximumSize)
959
+ size = pointFlow.maximumSize;
960
+
961
+ double tx = v.x;
962
+ double ty = v.y;
963
+ double tz = v.z;
964
+
965
+ // if (tx == 0 && ty == 0 && tz == 0)
966
+ // continue;
967
+
968
+ gl.glMatrixMode(gl.GL_TEXTURE);
969
+ gl.glPushMatrix();
970
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
971
+
972
+ gl.glMultMatrixf(pointFlow.texmat, 0);
973
+
974
+ gl.glMatrixMode(gl.GL_MODELVIEW);
975
+ gl.glPushMatrix();
976
+
977
+ gl.glTranslated(tx,ty,tz);
978
+
979
+ gl.glScaled(size,size,size);
980
+
981
+// float cr = colorBuf.get(index4);
982
+// float cg = colorBuf.get(index4+1);
983
+// float cb = colorBuf.get(index4+2);
984
+// float ca = colorBuf.get(index4+3);
985
+//
986
+// display.modelParams0[0] = r * cr;
987
+// display.modelParams0[1] = g * cg;
988
+// display.modelParams0[2] = b * cb;
989
+//
990
+// display.modelParams5[1] = opacity * ca;
991
+//
992
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
993
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
994
+//
995
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
996
+// RandomNode.globalseed2 = RandomNode.globalseed;
997
+//
998
+//// gl.glColor4f(cr,cg,cb,ca);
999
+// // gl.glScalef(1024/16,1024/16,1024/16);
1000
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
1001
+
1002
+ gl.glPopMatrix();
1003
+
1004
+ double step = size/4; //
1005
+
1006
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1007
+ continue;
1008
+
1009
+ int nbsteps = (int)(distancenext/step);
1010
+
1011
+ step = distancenext/nbsteps;
1012
+
1013
+ cVector next = pointFlow.points.get(i-1);
1014
+
1015
+ tmp.set(next);
1016
+ tmp.sub(v);
1017
+ tmp.normalize();
1018
+ tmp.mul(step);
1019
+
1020
+ // calculate next size
1021
+ mindist = Double.MAX_VALUE;
1022
+
1023
+ double nextsize = pointFlow.minimumSize;
1024
+
1025
+ if (i > 1)
1026
+ {
1027
+ cVector w = pointFlow.points.get(i-2);
1028
+
1029
+ double dist = w.distance(next);
1030
+
1031
+ if (mindist > dist)
1032
+ {
1033
+ mindist = dist;
1034
+ nextsize = mindist*pointFlow.resizefactor;
1035
+ }
1036
+ }
1037
+
1038
+ double dist = v.distance(next);
1039
+
1040
+ if (mindist > dist)
1041
+ {
1042
+ mindist = dist;
1043
+ nextsize = mindist*pointFlow.resizefactor;
1044
+ }
1045
+
1046
+ if (nextsize < pointFlow.minimumSize)
1047
+ nextsize = pointFlow.minimumSize;
1048
+ if (nextsize > pointFlow.maximumSize)
1049
+ nextsize = pointFlow.maximumSize;
1050
+ //
1051
+
1052
+ double count = 0;
1053
+
1054
+ while (distancenext > 0.000000001) // step
1055
+ {
1056
+ gl.glPushMatrix();
1057
+
1058
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1059
+
1060
+ double K = count/nbsteps;
1061
+
1062
+ double intersize = K*nextsize + (1-K)*size;
1063
+
1064
+ gl.glScaled(intersize,intersize,intersize);
1065
+
1066
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1067
+
1068
+ count++;
1069
+
1070
+ distancenext -= step;
1071
+
1072
+ gl.glPopMatrix();
1073
+ }
1074
+
1075
+ if (count != nbsteps)
1076
+ assert(count == nbsteps);
1077
+
1078
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1079
+ //gl.glTranslatef(-tx,-ty,-tz);
1080
+
1081
+ gl.glMatrixMode(gl.GL_TEXTURE);
1082
+ gl.glPopMatrix();
1083
+ }
1084
+
1085
+ if (!cf)
1086
+ gl.glDisable(gl.GL_CULL_FACE);
1087
+
1088
+// display.modelParams0[0] = r;
1089
+// display.modelParams0[1] = g;
1090
+// display.modelParams0[2] = b;
1091
+//
1092
+// display.modelParams5[1] = opacity;
1093
+//
1094
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1095
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1096
+
1097
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1098
+ }
1099
+
1100
+ public void DrawBox(cVector min, cVector max)
1101
+ {
1102
+ javax.media.opengl.GL gl = GetGL();
1103
+ gl.glBegin(gl.GL_LINES);
1104
+
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(min.x, min.y, max.z);
1107
+ gl.glVertex3d(min.x, min.y, min.z);
1108
+ gl.glVertex3d(min.x, max.y, min.z);
1109
+ gl.glVertex3d(min.x, min.y, min.z);
1110
+ gl.glVertex3d(max.x, min.y, min.z);
1111
+
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(min.x, max.y, max.z);
1114
+ gl.glVertex3d(max.x, max.y, max.z);
1115
+ gl.glVertex3d(max.x, min.y, max.z);
1116
+ gl.glVertex3d(max.x, max.y, max.z);
1117
+ gl.glVertex3d(max.x, max.y, min.z);
1118
+
1119
+ gl.glEnd();
1120
+ }
1121
+
1122
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1123
+ {
1124
+ int[] strips = bRep.getRawIndices();
1125
+
1126
+ javax.media.opengl.GL gl = GetGL();
1127
+
1128
+ // TRIANGLE STRIP ARRAY
1129
+ if (bRep.trimmed)
1130
+ {
1131
+ float[] v = bRep.getRawVertices();
1132
+ float[] n = bRep.getRawNormals();
1133
+ float[] c = bRep.getRawColors();
1134
+ float[] uv = bRep.getRawUVMap();
1135
+
1136
+ int count2 = 0;
1137
+ int count3 = 0;
1138
+
1139
+ if (n.length > 0)
1140
+ {
1141
+ for (int i = 0; i < strips.length; i++)
1142
+ {
1143
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1144
+
1145
+ /*
1146
+ boolean locked = false;
1147
+ float eps = 0.1f;
1148
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1149
+
1150
+ int dot = 0;
1151
+
1152
+ if ((dot&1) == 0)
1153
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1154
+
1155
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1156
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1157
+ else
1158
+ {
1159
+ locked = true;
1160
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1161
+ }
1162
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1163
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1164
+ if (hasnorm)
1165
+ {
1166
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1167
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1168
+ }
1169
+
1170
+ if ((dot&4) == 0)
1171
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1172
+
1173
+ if (wrap || !locked && (dot&8) != 0)
1174
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1175
+ else
1176
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1177
+
1178
+ f.dot = dot;
1179
+ */
1180
+
1181
+ if (!selectmode)
1182
+ {
1183
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1184
+ {
1185
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1186
+ } else
1187
+ {
1188
+ gl.glNormal3f(0, 0, 1);
1189
+ }
1190
+
1191
+ if (c != null)
1192
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1193
+ {
1194
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1195
+ }
1196
+ }
1197
+
1198
+ if (flipV)
1199
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1200
+ else
1201
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1202
+
1203
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1204
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1205
+
1206
+ count2 += 2;
1207
+ count3 += 3;
1208
+ if (!selectmode)
1209
+ {
1210
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1211
+ {
1212
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1213
+ } else
1214
+ {
1215
+ gl.glNormal3f(0, 0, 1);
1216
+ }
1217
+ if (c != null)
1218
+ {
1219
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1220
+ }
1221
+ }
1222
+
1223
+ if (flipV)
1224
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1225
+ else
1226
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1227
+
1228
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1229
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1230
+
1231
+ count2 += 2;
1232
+ count3 += 3;
1233
+ for (int j = 0; j < strips[i] - 2; j++)
1234
+ {
1235
+ //gl.glTexCoord2d(...);
1236
+ if (!selectmode)
1237
+ {
1238
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1239
+ {
1240
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1241
+ } else
1242
+ {
1243
+ gl.glNormal3f(0, 0, 1);
1244
+ }
1245
+ if (c != null)
1246
+ {
1247
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1248
+ }
1249
+ }
1250
+
1251
+ if (flipV)
1252
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1253
+ else
1254
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1255
+
1256
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1257
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1258
+
1259
+ count2 += 2;
1260
+ count3 += 3;
1261
+ }
1262
+
1263
+ gl.glEnd();
1264
+ }
1265
+ }
1266
+
1267
+ assert count3 == v.length;
1268
+ }
1269
+ else // !trimmed
1270
+ {
1271
+ int count = 0;
1272
+ for (int i = 0; i < strips.length; i++)
1273
+ {
1274
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1275
+
1276
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1277
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1278
+
1279
+ drawVertex(gl, p, flipV, selectmode);
1280
+ drawVertex(gl, q, flipV, selectmode);
1281
+
1282
+ for (int j = 0; j < strips[i] - 2; j++)
1283
+ {
1284
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1285
+
1286
+ // if (j%2 == 0)
1287
+ // drawFace(p, q, r, display, null);
1288
+ // else
1289
+ // drawFace(p, r, q, display, null);
1290
+
1291
+ // p = q;
1292
+ // q = r;
1293
+ drawVertex(gl, r, flipV, selectmode);
1294
+ }
1295
+
1296
+ gl.glEnd();
1297
+ }
1298
+ }
1299
+ }
1300
+
1301
+ static cSpring.Point3D temp = new cSpring.Point3D();
1302
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1303
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1304
+
1305
+ public void DrawDynamicMesh(cMesh mesh)
1306
+ {
1307
+ GL gl = GetGL(); // getGL();
1308
+
1309
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1310
+
1311
+ gl.glDisable(gl.GL_LIGHTING);
1312
+
1313
+ gl.glLineWidth(1);
1314
+ gl.glColor3f(1,1,1);
1315
+ gl.glBegin(gl.GL_LINES);
1316
+ double scale = 0;
1317
+ int count = 0;
1318
+ for (int s=0; s<Phys.allSprings.size(); s++)
1319
+ {
1320
+ cSpring.Spring spring = Phys.allSprings.get(s);
1321
+ if(s == 0)
1322
+ {
1323
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1324
+ }
1325
+ if (mesh.showsprings)
1326
+ {
1327
+ temp.set(spring.a.position);
1328
+ temp.add(spring.b.position);
1329
+ temp.mul(0.5);
1330
+ temp2.set(spring.a.position);
1331
+ temp2.sub(spring.b.position);
1332
+ temp2.mul(spring.restLength/2);
1333
+ temp.sub(temp2);
1334
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1335
+ temp.add(temp2);
1336
+ temp.add(temp2);
1337
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1338
+ }
1339
+
1340
+ if (spring.isHandle)
1341
+ continue;
1342
+
1343
+ //if (scale < spring.restLength)
1344
+ scale += spring.restLength;
1345
+ count++;
1346
+ }
1347
+ gl.glEnd();
1348
+
1349
+ if (count == 0)
1350
+ scale = 0.01;
1351
+ else
1352
+ scale /= count * 3;
1353
+
1354
+ //scale = 0.25;
1355
+
1356
+ if (mesh.ShowInfo())
1357
+ {
1358
+ gl.glLineWidth(4);
1359
+ for (int s=0; s<Phys.allNodes.size(); s++)
1360
+ {
1361
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1362
+ if (node.mass == 0)
1363
+ continue;
1364
+
1365
+ int i = node.springs==null?-1:node.springs.size();
1366
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1367
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1368
+ //temp.normalize();
1369
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1370
+ gl.glBegin(gl.GL_LINES);
1371
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1372
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1373
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1374
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1375
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1376
+ gl.glEnd();
1377
+ }
1378
+
1379
+ gl.glLineWidth(8);
1380
+ for (int s=0; s<Phys.allNodes.size(); s++)
1381
+ {
1382
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1383
+
1384
+ if (node.springs != null)
1385
+ {
1386
+ for (int i=0; i<node.springs.size(); i+=1)
1387
+ {
1388
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1389
+
1390
+ int c = i+1;
1391
+ // c = node.springs.get(i).nbcopies;
1392
+
1393
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1394
+ gl.glBegin(gl.GL_LINES);
1395
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1396
+ 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);
1397
+ gl.glEnd();
1398
+ }
1399
+ }
1400
+ }
1401
+
1402
+ gl.glLineWidth(1);
1403
+ }
1404
+
1405
+ gl.glEnable(gl.GL_LIGHTING);
1406
+ }
1407
+
1408
+ /// INTERFACE
1409
+
1410
+ public void StartTriangles()
1411
+ {
1412
+ javax.media.opengl.GL gl = GetGL();
1413
+ gl.glBegin(gl.GL_TRIANGLES);
1414
+ }
1415
+
1416
+ public void EndTriangles()
1417
+ {
1418
+ GetGL().glEnd();
1419
+ }
1420
+
1421
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1422
+ {
1423
+ if (!selectmode)
1424
+ {
1425
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1426
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1427
+
1428
+ if (flipV)
1429
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1430
+ else
1431
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1432
+ }
1433
+
1434
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1435
+ }
1436
+
1437
+ void SetColor(Object3D obj, Vertex p0)
1438
+ {
1439
+ CameraPane display = this;
1440
+ BoundaryRep bRep = obj.bRep;
1441
+
1442
+ if (RENDERPROGRAM == 0)
1443
+ {
1444
+ float r = 0;
1445
+ if (bRep != null)
1446
+ {
1447
+ if (bRep.stripified)
1448
+ {
1449
+ r = 1;
1450
+ }
1451
+ }
1452
+ float g = 0;
1453
+ if (bRep != null)
1454
+ {
1455
+ if (bRep.trimmed)
1456
+ {
1457
+ g = 1;
1458
+ }
1459
+ }
1460
+ float b = 0;
1461
+ if (obj.support != null && obj.link2master)
1462
+ {
1463
+ b = 1;
1464
+ }
1465
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1466
+ return;
1467
+ }
1468
+
1469
+ if (display.DrawMode() != CameraPane.SHADOW)
1470
+ return;
1471
+
1472
+ javax.media.opengl.GL gl = display.GetGL();
1473
+// if (true) return;
1474
+// float ao = p.AO;
1475
+//
1476
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1477
+// // ao = 1;
1478
+//
1479
+// gl.glColor4f(ao, ao, ao, 1);
1480
+
1481
+// CameraPane.selectedpoint.
1482
+// getAverage(cStatic.point1, true);
1483
+ if (CameraPane.pointflow == null) // !random) // live)
1484
+ {
1485
+ return;
1486
+ }
1487
+
1488
+ cStatic.point1.set(0,0,0);
1489
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1490
+
1491
+ cStatic.point1.sub(p0);
1492
+
1493
+
1494
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1495
+// {
1496
+// return;
1497
+// }
1498
+
1499
+ //if (true)
1500
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1501
+ {
1502
+ return;
1503
+ }
1504
+
1505
+ float[] colorV = new float[3];
1506
+
1507
+ if (false) // marked)
1508
+ {
1509
+ // debug rigging weights
1510
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1511
+ {
1512
+ float weight = p0.weights[object] / p0.totalweight;
1513
+
1514
+ // if (weight < 0.1)
1515
+ // {
1516
+ // assert(weight == 0);
1517
+ // continue;
1518
+ // }
1519
+
1520
+ if (p0.vertexlinks[object] == -1)
1521
+ continue;
1522
+
1523
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1524
+
1525
+ int color = //1 << object; //
1526
+ //p.vertexlinks.length;
1527
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1528
+ colorV[2] += (color & 1) * weight;
1529
+ colorV[1] += ((color & 2) >> 1) * weight;
1530
+ colorV[0] += ((color & 4) >> 2) * weight;
1531
+ }
1532
+ }
1533
+ else
1534
+ {
1535
+ if (obj.drawingstarted)
1536
+ {
1537
+ // find next point
1538
+ if (bRep.GetVertex(0).faceindices == null)
1539
+ {
1540
+ bRep.InitFaceIndices();
1541
+ }
1542
+
1543
+ double ymin = p0.y;
1544
+
1545
+ Vertex newp = p0;
1546
+
1547
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1548
+ {
1549
+ int fi = p0.faceindices[fii];
1550
+
1551
+ if (fi == -1)
1552
+ break;
1553
+
1554
+ Face f = bRep.GetFace(fi);
1555
+
1556
+ Vertex p = bRep.GetVertex(f.p);
1557
+ Vertex q = bRep.GetVertex(f.q);
1558
+ Vertex r = bRep.GetVertex(f.r);
1559
+
1560
+ int swap = (int)(Math.random()*3);
1561
+
1562
+// for (int s=swap; --s>=0;)
1563
+// {
1564
+// Vertex t = p;
1565
+// p = q;
1566
+// q = r;
1567
+// r = t;
1568
+// }
1569
+ if (ymin > p.y)
1570
+ {
1571
+ ymin = p.y;
1572
+ newp = p;
1573
+// break;
1574
+ }
1575
+ if (ymin > q.y)
1576
+ {
1577
+ ymin = q.y;
1578
+ newp = q;
1579
+// break;
1580
+ }
1581
+ if (ymin > r.y)
1582
+ {
1583
+ ymin = r.y;
1584
+ newp = r;
1585
+// break;
1586
+ }
1587
+ }
1588
+
1589
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1590
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1591
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1592
+
1593
+ obj.drawingstarted = false;
1594
+
1595
+ // return;
1596
+ }
1597
+
1598
+ if (false) // CameraPane.DRAW
1599
+ {
1600
+ p0.AO = colorV[0] = 2;
1601
+ colorV[1] = 2;
1602
+ colorV[2] = 2;
1603
+ }
1604
+
1605
+ CameraPane.pointflow.add(p0);
1606
+ CameraPane.pointflow.Touch();
1607
+ }
1608
+
1609
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1610
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1611
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1612
+ }
1613
+
1614
+ void DrawMaterial(cMaterial material, boolean selected)
1615
+ {
1616
+ CameraPane display = this;
1617
+ //new Exception().printStackTrace();
1618
+
1619
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1620
+ {
1621
+ return;
1622
+ }
1623
+
1624
+ javax.media.opengl.GL gl = display.GetGL();
1625
+
1626
+ //Color col = Color.getHSBColor(color,modulation,1);
1627
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1628
+ if (!material.multiply)
1629
+ {
1630
+ display.color = material.color;
1631
+ display.saturation = material.modulation;
1632
+ }
1633
+ else
1634
+ {
1635
+ display.color *= material.color*2;
1636
+ display.saturation *= material.modulation*2;
1637
+ }
1638
+
1639
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1640
+
1641
+ float[] colorV = Grafreed.colorV;
1642
+
1643
+ /**/
1644
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1645
+ {
1646
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1647
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1648
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1649
+ colorV[3] = material.opacity;
1650
+
1651
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1652
+ //System.out.println("Opacity = " + opacity);
1653
+
1654
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1655
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1656
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1657
+
1658
+ float amb = material.ambient;
1659
+ if (amb < material.cameralight)
1660
+ {
1661
+ amb = material.cameralight;
1662
+ }
1663
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1664
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1665
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1666
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1667
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1668
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1669
+
1670
+ /**/
1671
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1672
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1673
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1674
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1675
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1676
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1677
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1678
+ //System.out.println("shininess = " + colorV[0]);
1679
+ if (colorV[0] > 128)
1680
+ {
1681
+ colorV[0] = 128;
1682
+ }
1683
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1684
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1685
+ /**/
1686
+ }
1687
+ /**/
1688
+
1689
+ //selected = false;
1690
+ selected = selected && display.flash;
1691
+
1692
+ //display.modelParams0[0] = 0; // pigment.r;
1693
+ //display.modelParams0[1] = 0; // pigment.g;
1694
+ //display.modelParams0[2] = 0; // pigment.b;
1695
+ if (!material.multiply)
1696
+ {
1697
+ display.modelParams0[3] = material.metalness;
1698
+ display.modelParams1[0] = material.diffuse;
1699
+ display.modelParams1[1] = material.specular;
1700
+ display.modelParams1[2] = 1 / material.shininess;
1701
+ display.modelParams1[3] = material.shift;
1702
+ display.modelParams2[0] = material.ambient;
1703
+ display.modelParams2[1] = material.lightarea;
1704
+ //System.out.println("light area = " + lightarea);
1705
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1706
+ display.modelParams2[3] = material.velvet;
1707
+ display.modelParams3[0] = material.sheen;
1708
+ display.modelParams3[1] = material.subsurface;
1709
+ display.modelParams3[2] = material.bump; // backlit
1710
+ display.modelParams3[3] = material.aniso;
1711
+ display.modelParams4[0] = material.anisoV;
1712
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1713
+ //System.out.println("selected = " + selected);
1714
+ display.modelParams4[2] = material.diffuseness;
1715
+ display.modelParams4[3] = material.shadow;
1716
+ display.modelParams5[0] = material.texture;
1717
+ display.modelParams5[1] = material.opacity;
1718
+ display.modelParams5[2] = material.fakedepth;
1719
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1720
+ }
1721
+ else
1722
+ {
1723
+ display.modelParams0[3] *= material.metalness*2;
1724
+ display.modelParams1[0] *= material.diffuse*2;
1725
+ display.modelParams1[1] *= material.specular*2;
1726
+ display.modelParams1[2] *= material.shininess*2;
1727
+ display.modelParams1[3] *= material.shift*2;
1728
+ display.modelParams2[0] *= material.ambient*2;
1729
+ display.modelParams2[1] *= material.lightarea*2;
1730
+ display.modelParams2[2] *= material.factor*2;
1731
+ display.modelParams2[3] *= material.velvet*2;
1732
+ display.modelParams3[0] *= material.sheen*2;
1733
+ display.modelParams3[1] *= material.subsurface*2;
1734
+ display.modelParams3[2] *= material.bump*2;
1735
+ display.modelParams3[3] *= material.aniso*2;
1736
+ display.modelParams4[0] *= material.anisoV*2;
1737
+ display.modelParams4[1] *= material.cameralight*2;
1738
+ //System.out.println("selected = " + selected);
1739
+ display.modelParams4[2] *= material.diffuseness*2;
1740
+ display.modelParams4[3] *= material.shadow*2;
1741
+ display.modelParams5[0] *= material.texture*2;
1742
+ display.modelParams5[1] *= material.opacity*2;
1743
+ display.modelParams5[2] *= material.fakedepth*2;
1744
+ display.modelParams5[3] *= material.shadowbias*2;
1745
+ }
1746
+
1747
+ display.modelParams6[0] = 0;
1748
+ display.modelParams6[1] = 0;
1749
+ display.modelParams6[2] = 0;
1750
+ display.modelParams6[3] = 0;
1751
+
1752
+ display.modelParams7[0] = 0;
1753
+ display.modelParams7[1] = 1000;
1754
+ display.modelParams7[2] = 0;
1755
+ display.modelParams7[3] = 0;
1756
+
1757
+ display.modelParams6[0] = 100; // criss de bug de bump
1758
+
1759
+ Object3D.cVector2[] extparams = display.vector2buffer;
1760
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1761
+ {
1762
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1763
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1764
+ if (extparams.length > 1)
1765
+ {
1766
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1767
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1768
+ if (extparams.length > 2)
1769
+ {
1770
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1771
+ float x = extparams[2].y / 1000.0f;
1772
+ //if (x == 0)
1773
+ // x = 1f;
1774
+ 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
1775
+ if (extparams[2].y > 0)
1776
+ {
1777
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1778
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1779
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1780
+ }
1781
+ }
1782
+ }
1783
+ }
1784
+
1785
+ //if (display.modelParams6[2] != 0)
1786
+ /*
1787
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1788
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1789
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1790
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1791
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1792
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1793
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1794
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1795
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1796
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1797
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1798
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1799
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1800
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1801
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1802
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1803
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1804
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1805
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1806
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1807
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1808
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1809
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1810
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1811
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1812
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1813
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1814
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1815
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1816
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1817
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1818
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1819
+ /**/
1820
+ //assert (display.modelParams6[2] == 0);
1821
+
1822
+ //System.out.println("noise power = " + display.modelParams7[0]);
1823
+ //System.out.println("shadowbias = " + shadowbias);
1824
+
1825
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1826
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1827
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1828
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1829
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1830
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1831
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1832
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1833
+
1834
+ int mode = display.FP_SHADER;
1835
+
1836
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1837
+ {
1838
+ mode |= display.FP_ANISO;
1839
+ }
1840
+
1841
+ display.EnableProgram(mode);
1842
+
1843
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1844
+
1845
+ if (!material.multiply)
1846
+ {
1847
+ if (Globals.drawMode == CameraPane.SHADOW)
1848
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1849
+ else
1850
+ gl.glDepthMask(material.opacity >= 0.99);
1851
+ }
2361852 }
2371853
2381854 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -253,7 +1869,7 @@
2531869 currentGL.glMultMatrixd(model, 0);
2541870 }
2551871
256
- void PushMatrix(double[][] matrix, int count)
1872
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2571873 {
2581874 matrixdepth++;
2591875 // GrafreeD.tracein(matrix);
....@@ -282,7 +1898,7 @@
2821898 void PushMatrix(double[][] matrix)
2831899 {
2841900 // GrafreeD.tracein(matrix);
285
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
2861902 }
2871903
2881904 void PushMatrix()
....@@ -298,7 +1914,7 @@
2981914
2991915 double[][] tmpmat = new double[4][4];
3001916
301
- void PopMatrix(double[][] inverse)
1917
+ public void PopMatrix(double[][] inverse) // INTERFACE
3021918 {
3031919 --matrixdepth;
3041920
....@@ -338,7 +1954,7 @@
3381954 PushTextureMatrix(matrix, 1);
3391955 }
3401956
341
- void PushTextureMatrix(double[][] matrix, int count)
1957
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3421958 {
3431959 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3441960
....@@ -352,7 +1968,7 @@
3521968 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3531969 }
3541970
355
- void PopTextureMatrix(double[][] inverse)
1971
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3561972 {
3571973 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3581974 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -379,15 +1995,15 @@
3791995
3801996 static int camerachangeframe;
3811997
382
- boolean SetCamera(Camera cam)
1998
+ public boolean SetCamera(Camera cam)
3831999 {
3842000 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3852001 // return false;
3862002
387
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
2003
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3882004 {
3892005 // check for last change
390
- if (framecount < camerachangeframe + 400) // 120 == 1 second
2006
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3912007 {
3922008 // refuse the camera change
3932009 System.err.println("Camera " + cam + " REFUSED");
....@@ -395,7 +2011,7 @@
3952011 }
3962012 }
3972013
398
- camerachangeframe = framecount;
2014
+ camerachangeframe = Globals.framecount;
3992015
4002016 cam.hAspect = -1; // Read only
4012017
....@@ -426,7 +2042,7 @@
4262042 {
4272043 //System.err.println("Oeil on");
4282044 TRACK = true;
429
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2045
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4302046 // object.editWindow.ScreenFit(trackedobject);
4312047 //pingthread.StepToTarget(true);
4322048 }
....@@ -435,7 +2051,7 @@
4352051 {
4362052 //System.err.println("Oeil on");
4372053 OEIL = true;
438
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2054
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4392055 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4402056 //pingthread.StepToTarget(true);
4412057 }
....@@ -499,39 +2115,12 @@
4992115 {
5002116 frozen ^= true;
5012117 // Weird...
502
- lighttouched = true;
2118
+ Globals.lighttouched = true;
5032119 }
5042120
5052121 void ToggleDL()
5062122 {
5072123 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;
5352124 }
5362125
5372126 void ToggleFullScreen()
....@@ -541,12 +2130,7 @@
5412130
5422131 void ToggleCrowd()
5432132 {
544
- CROWD ^= true;
545
- }
546
-
547
- void ToggleInertia()
548
- {
549
- INERTIA ^= true;
2133
+ Globals.CROWD ^= true;
5502134 }
5512135
5522136 void ToggleLocal()
....@@ -554,62 +2138,89 @@
5542138 LOCALTRANSFORM ^= true;
5552139 }
5562140
557
- void ToggleFast()
2141
+ public void ToggleTexture()
2142
+ {
2143
+ textureon ^= true;
2144
+ }
2145
+
2146
+ public void ToggleLive()
2147
+ {
2148
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2149
+
2150
+ System.err.println("LIVE = " + Globals.isLIVE());
2151
+
2152
+ if (!Globals.isLIVE()) // save sound
2153
+ Grafreed.savesound = true; // wav.save();
2154
+ // else
2155
+ repaint(); // start loop // may 2013
2156
+ }
2157
+
2158
+ public void ToggleSupport()
2159
+ {
2160
+ SUPPORT ^= true;
2161
+ }
2162
+
2163
+ public void ToggleAbort()
2164
+ {
2165
+ ABORTMODE ^= true;
2166
+ }
2167
+
2168
+ public void ToggleInertia()
2169
+ {
2170
+ INERTIA ^= true;
2171
+ }
2172
+
2173
+ public void ToggleFast()
5582174 {
5592175 FAST ^= true;
5602176 }
5612177
562
- void ToggleSlowPose()
2178
+ public void ToggleSlowPose()
5632179 {
5642180 SLOWPOSE ^= true;
5652181 }
5662182
567
- void ToggleFootContact()
568
- {
569
- FOOTCONTACT ^= true;
570
- }
571
-
572
- void ToggleBoxMode()
2183
+ public void ToggleBoxMode()
5732184 {
5742185 BOXMODE ^= true;
5752186 }
5762187
577
- void ToggleSmoothFocus()
2188
+ public void ToggleZoomBoxMode()
2189
+ {
2190
+ ZOOMBOXMODE ^= true;
2191
+ }
2192
+
2193
+ public void ToggleSmoothFocus()
5782194 {
5792195 SMOOTHFOCUS ^= true;
5802196 }
5812197
582
- void ToggleImageFlip()
2198
+ public void ToggleImageFlip()
5832199 {
5842200 IMAGEFLIP ^= true;
5852201 }
5862202
587
- void ToggleSpeakerMocap()
2203
+ public void ToggleSpeakerMocap()
5882204 {
5892205 SPEAKERMOCAP ^= true;
5902206 }
5912207
592
- void ToggleSpeakerCamera()
2208
+ public void ToggleSpeakerCamera()
5932209 {
5942210 SPEAKERCAMERA ^= true;
5952211 }
5962212
597
- void ToggleSpeakerFocus()
2213
+ public void ToggleSpeakerFocus()
5982214 {
5992215 SPEAKERFOCUS ^= true;
6002216 }
6012217
602
- void ToggleDebug()
603
- {
604
- DEBUG ^= true;
605
- }
606
-
607
- void ToggleFrustum()
2218
+ public void ToggleFrustum()
6082219 {
6092220 FRUSTUM ^= true;
6102221 }
6112222
612
- void ToggleTrack()
2223
+ public void ToggleTrack()
6132224 {
6142225 TRACK ^= true;
6152226 if (TRACK)
....@@ -628,25 +2239,35 @@
6282239 repaint();
6292240 }
6302241
631
- void ToggleTrackOnce()
2242
+ public void ToggleTrackOnce()
6322243 {
6332244 TRACKONCE ^= true;
6342245 }
6352246
636
- void ToggleShadowTrack()
2247
+ public void ToggleShadowTrack()
6372248 {
6382249 SHADOWTRACK ^= true;
6392250 repaint();
6402251 }
6412252
642
- void ToggleOeil()
2253
+ public void ToggleOeil()
6432254 {
6442255 OEIL ^= true;
6452256 }
6462257
647
- void ToggleOeilOnce()
2258
+ public void ToggleOeilOnce()
6482259 {
6492260 OEILONCE ^= true;
2261
+ }
2262
+
2263
+ void ToggleFootContact()
2264
+ {
2265
+ FOOTCONTACT ^= true;
2266
+ }
2267
+
2268
+ void ToggleDebug()
2269
+ {
2270
+ DEBUG ^= true;
6502271 }
6512272
6522273 void ToggleLookAt()
....@@ -654,9 +2275,9 @@
6542275 LOOKAT ^= true;
6552276 }
6562277
657
- void ToggleRandom()
2278
+ void ToggleSwitch()
6582279 {
659
- RANDOM ^= true;
2280
+ SWITCH ^= true;
6602281 }
6612282
6622283 void ToggleHandles()
....@@ -759,11 +2380,11 @@
7592380
7602381 GL currentGL;
7612382
762
- GL GetGL()
2383
+ public GL GetGL() // INTERFACE
7632384 {
7642385 return currentGL;
7652386 }
766
-
2387
+
7672388 /**/
7682389 class CacheTexture
7692390 {
....@@ -2595,6 +4216,7 @@
25954216
25964217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25974218 {
4219
+ new Exception().printStackTrace();
25984220 System.exit(0);
25994221 com.sun.opengl.util.texture.Texture texture = null;
26004222
....@@ -6271,7 +7893,7 @@
62717893 return null;
62727894 }
62737895
6274
- void ReleaseTextures(cTexture tex)
7896
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757897 {
62767898 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777899 {
....@@ -6307,9 +7929,67 @@
63077929 ReleaseTexture(pigment, false);
63087930 }
63097931
7932
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7933
+ {
7934
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7935
+ {
7936
+ return;
7937
+ }
7938
+
7939
+ if (tex == null)
7940
+ {
7941
+ ReleaseTexture(null, false);
7942
+ return;
7943
+ }
7944
+
7945
+ String pigment = Object3D.GetPigment(tex);
7946
+
7947
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7948
+ {
7949
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7950
+ // System.out.println("; bump = " + bump);
7951
+ }
7952
+
7953
+ if (pigment.equals(""))
7954
+ {
7955
+ pigment = null;
7956
+ }
7957
+
7958
+ ReleaseTexture(pigment, false);
7959
+ }
7960
+
7961
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7962
+ {
7963
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7964
+ {
7965
+ return;
7966
+ }
7967
+
7968
+ if (tex == null)
7969
+ {
7970
+ ReleaseTexture(null, true);
7971
+ return;
7972
+ }
7973
+
7974
+ String bump = Object3D.GetBump(tex);
7975
+
7976
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7977
+ {
7978
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7979
+ // System.out.println("; bump = " + bump);
7980
+ }
7981
+
7982
+ if (bump.equals(""))
7983
+ {
7984
+ bump = null;
7985
+ }
7986
+
7987
+ ReleaseTexture(bump, true);
7988
+ }
7989
+
63107990 void ReleaseTexture(String tex, boolean bump)
63117991 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
7992
+ if (// DrawMode() != 0 || /*tex == null ||*/
63137993 ambientOcclusion ) // || !textureon)
63147994 {
63157995 return;
....@@ -6410,9 +8090,9 @@
64108090 }
64118091 }
64128092
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64148094 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
8095
+ if (// DrawMode() != 0 || /*tex == null ||*/
64168096 ambientOcclusion ) // || !textureon)
64178097 {
64188098 return; // false;
....@@ -6455,7 +8135,94 @@
64558135 return; // true;
64568136 }
64578137
6458
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8138
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8139
+ {
8140
+ if (// DrawMode() != 0 || /*tex == null ||*/
8141
+ ambientOcclusion ) // || !textureon)
8142
+ {
8143
+ return; // false;
8144
+ }
8145
+
8146
+ if (tex == null)
8147
+ {
8148
+ BindTexture(null,false,resolution);
8149
+ return;
8150
+ }
8151
+
8152
+ String pigment = Object3D.GetPigment(tex);
8153
+
8154
+ usedtextures.put(pigment, pigment);
8155
+
8156
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8157
+ {
8158
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8159
+ // System.out.println("; bump = " + bump);
8160
+ }
8161
+
8162
+ if (pigment.equals(""))
8163
+ {
8164
+ pigment = null;
8165
+ }
8166
+
8167
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
+ BindTexture(pigment, false, resolution);
8169
+ }
8170
+
8171
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8172
+ {
8173
+ if (// DrawMode() != 0 || /*tex == null ||*/
8174
+ ambientOcclusion ) // || !textureon)
8175
+ {
8176
+ return; // false;
8177
+ }
8178
+
8179
+ if (tex == null)
8180
+ {
8181
+ BindTexture(null,true,resolution);
8182
+ return;
8183
+ }
8184
+
8185
+ String bump = Object3D.GetBump(tex);
8186
+
8187
+ usedtextures.put(bump, bump);
8188
+
8189
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8190
+ {
8191
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8192
+ // System.out.println("; bump = " + bump);
8193
+ }
8194
+
8195
+ if (bump.equals(""))
8196
+ {
8197
+ bump = null;
8198
+ }
8199
+
8200
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
+ BindTexture(bump, true, resolution);
8202
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8203
+ }
8204
+
8205
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8206
+
8207
+ private boolean FileExists(String tex)
8208
+ {
8209
+ if (missingTextures.contains(tex))
8210
+ {
8211
+ return false;
8212
+ }
8213
+
8214
+ boolean fileExists = new File(tex).exists();
8215
+
8216
+ if (!fileExists)
8217
+ {
8218
+ // If file exists, the "new File()" is not executed sgain
8219
+ missingTextures.add(tex);
8220
+ }
8221
+
8222
+ return fileExists;
8223
+ }
8224
+
8225
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
64598226 {
64608227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64618228
....@@ -6463,12 +8230,18 @@
64638230 {
64648231 String texname = tex;
64658232
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;
8233
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8234
+
8235
+// String[] split = tex.split("Textures");
8236
+// if (split.length > 1)
8237
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8238
+// else
8239
+// if (!texname.startsWith("/"))
8240
+// texname = "/Users/nbriere/Textures/" + texname;
8241
+ if (!FileExists(tex))
8242
+ {
8243
+ texname = fallbackTextureName;
8244
+ }
64728245
64738246 if (CACHETEXTURE)
64748247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -6537,7 +8310,7 @@
65378310 }
65388311
65398312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
6540
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
65418314 cachename = texname;
65428315 else
65438316 processbump = false; // don't process bump map again
....@@ -6559,7 +8332,7 @@
65598332 }
65608333
65618334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
6562
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
65638336 cachename = texname;
65648337 else
65658338 processbump = false; // don't process bump map again
....@@ -6568,7 +8341,9 @@
65688341 texturedata = GetFileTexture(cachename, processbump, resolution);
65698342
65708343
6571
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
65728347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
65738348 //texture = GetTexture(tex, bump);
65748349 }
....@@ -6690,7 +8465,7 @@
66908465 return texture;
66918466 }
66928467
6693
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8468
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
66948469 {
66958470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66968471
....@@ -6708,14 +8483,14 @@
67088483 return texture!=null?texture.texture:null;
67098484 }
67108485
6711
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8486
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
67128487 {
67138488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67148489
67158490 return texture!=null?texture.texturedata:null;
67168491 }
67178492
6718
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
67198494 {
67208495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67218496 {
....@@ -7312,9 +9087,9 @@
73129087 static boolean occlusionInitialized = false;
73139088 boolean selection = false;
73149089 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
9090
+ ///*static*/ boolean lighttouched = true;
73169091 boolean deselect;
7317
- boolean ambientOcclusion = false;
9092
+ private boolean ambientOcclusion = false;
73189093 static boolean flash = false;
73199094 /*static*/ boolean wait = false;
73209095 boolean displaydone = false; // after repaint() calls
....@@ -7603,8 +9378,6 @@
76039378
76049379 boolean restartframe = false;
76059380
7606
- static int framecount = 0; // general-purpose global count
7607
-
76089381 void displayAntiAliased(javax.media.opengl.GL gl)
76099382 {
76109383 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7635,7 +9408,7 @@
76359408 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76369409 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76379410 {
7638
- framecount++;
9411
+ Globals.framecount++;
76399412
76409413 if (CameraPane.tickcount > 0)
76419414 CameraPane.tickcount--;
....@@ -7673,7 +9446,7 @@
76739446
76749447 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76759448 */
7676
- lighttouched = true;
9449
+ Globals.lighttouched = true;
76779450 //System.err.println(" shadowbuffer: " + jitter);
76789451 shadowbuffer.display();
76799452
....@@ -7694,8 +9467,8 @@
76949467 assert (parentcam != renderCamera);
76959468
76969469 if (renderCamera != lightCamera)
7697
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7698
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
76999472
77009473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
77019474
....@@ -7710,8 +9483,8 @@
77109483 LA.matCopy(renderCamera.fromScreen, matrix);
77119484
77129485 if (renderCamera != lightCamera)
7713
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7714
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
77159488
77169489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77179490
....@@ -7783,7 +9556,7 @@
77839556 //gl.glFlush();
77849557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77859558
7786
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
77879560 {
77889561 System.err.println(" ABORTED FRAME");
77899562 break;
....@@ -7813,7 +9586,7 @@
78139586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78149587
78159588 // save image
7816
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
78179590 {
78189591 VPwidth = viewport[2];
78199592 VPheight = viewport[3];
....@@ -7924,11 +9697,11 @@
79249697
79259698 // imagecount++;
79269699
7927
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9700
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
79289701
79299702 if (!BOXMODE)
79309703 {
7931
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9704
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
79329705 }
79339706
79349707 if (!BOXMODE)
....@@ -7966,7 +9739,7 @@
79669739 ABORTED = false;
79679740 }
79689741 else
7969
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
79709743
79719744 if (false)
79729745 {
....@@ -8620,13 +10393,6 @@
862010393 }
862110394 }
862210395
8623
- boolean IsFrozen()
8624
- {
8625
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8626
-
8627
- return !selectmode && cameracount == 0; // != 0;
8628
- }
8629
-
863010396 boolean niceon = false;
863110397 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
863210398 boolean currentlydrawing = false;
....@@ -8636,16 +10402,16 @@
863610402
863710403 public void display(GLAutoDrawable drawable)
863810404 {
8639
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
864010406 {
8641
- GrafreeD.wav.save();
8642
- GrafreeD.savesound = false;
8643
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
864410410 }
864510411 // if (DEBUG_SELECTION)
864610412 // {
8647
-// if (drawMode != SELECTION)
8648
-// drawMode = SELECTION;
10413
+// if (DrawMode() != SELECTION)
10414
+// DrawMode() = SELECTION;
864910415 // }
865010416
865110417 if (!isRenderer)
....@@ -8701,9 +10467,9 @@
870110467
870210468 //ANTIALIAS = 0;
870310469
8704
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10470
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870510471 {
8706
- if (niceon || isLIVE())
10472
+ if (niceon || Globals.isLIVE())
870710473 {
870810474 //if(active == 0)
870910475 // antialiaser = null;
....@@ -8728,7 +10494,7 @@
872810494 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872910495 */
873010496
8731
- if (drawMode == DEFAULT)
10497
+ if (DrawMode() == DEFAULT)
873210498 {
873310499 currentlydrawing = true;
873410500 }
....@@ -8759,18 +10525,18 @@
875910525
876010526 // if(Applet3D.clipboard != null)
876110527 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8762
-//drawMode = SELECTION;
10528
+//DrawMode() = SELECTION;
876310529 indexcount = 0;
876410530
8765
- if (drawMode == OCCLUSION)
10531
+ if (DrawMode() == OCCLUSION)
876610532 {
8767
- drawMode = DEFAULT;
10533
+ Globals.drawMode = DEFAULT; // WARNING
876810534 ambientOcclusion = true;
876910535 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
877010536 Object3D theobject = object;
877110537 Object3D theparent = object.parent;
877210538 object.parent = null;
8773
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
877410540 object.Stripify();
877510541 if (theobject.selection == null || theobject.selection.Size() == 0)
877610542 theobject.PreprocessOcclusion(this);
....@@ -8783,19 +10549,19 @@
878310549 ambientOcclusion = false;
878410550 }
878510551
8786
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878710553 {
878810554 //if (RENDERSHADOW) // ?
878910555 if (!IsFrozen())
879010556 {
879110557 // dec 2012
8792
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
879310559 {
8794
- framecount++;
10560
+ Globals.framecount++;
879510561 shadowbuffer.display();
879610562 }
879710563 }
8798
- lighttouched = false; // ??
10564
+ Globals.lighttouched = false; // ??
879910565 //drawing = true;
880010566 //lighttouched = true;
880110567 }
....@@ -8816,9 +10582,9 @@
881610582 //eyeCamera.shaper_fovy = 1;
881710583 }
881810584
8819
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10585
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
882010586 {
8821
- //System.out.println("drawMode = " + drawMode);
10587
+ //System.out.println("DrawMode() = " + DrawMode());
882210588 vertexMode |= VP_PASS;
882310589 //vertexMode |= VP_PROJECTION;
882410590 if (!ambientOcclusion)
....@@ -8878,7 +10644,7 @@
887810644 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887910645 //Camera lightcam = new Camera(light0);
888010646
8881
- if (drawMode == SHADOW)
10647
+ if (DrawMode() == SHADOW)
888210648 {
888310649 /*
888410650 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8916,8 +10682,8 @@
891610682
891710683 // if (parentcam != renderCamera) // not a light
891810684 if (cam != lightCamera)
8919
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8920
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
892110687
892210688 for (int j = 0; j < 4; j++)
892310689 {
....@@ -8931,8 +10697,8 @@
893110697
893210698 // if (parentcam != renderCamera) // not a light
893310699 if (cam != lightCamera)
8934
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8935
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
893610702
893710703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893810704
....@@ -8968,7 +10734,7 @@
896810734 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896910735 } else
897010736 {
8971
- if (drawMode != DEFAULT)
10737
+ if (DrawMode() != DEFAULT)
897210738 {
897310739 gl.glClearColor(1, 1, 1, 0);
897410740 } // 1);
....@@ -9033,7 +10799,7 @@
903310799
903410800 fast &= !ambientOcclusion;
903510801
9036
- if (drawMode == DEFAULT)
10802
+ if (DrawMode() == DEFAULT)
903710803 {
903810804 //gl.glEnable(gl.GL_ALPHA_TEST);
903910805 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9191,7 +10957,16 @@
919110957 // Bump noise
919210958 gl.glActiveTexture(GL.GL_TEXTURE6);
919310959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9194
- BindTexture(NOISE_TEXTURE, false, 2);
10960
+
10961
+ try
10962
+ {
10963
+ BindTexture(NOISE_TEXTURE, false, 2);
10964
+ }
10965
+ catch (Exception e)
10966
+ {
10967
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10968
+ }
10969
+
919510970
919610971 gl.glActiveTexture(GL.GL_TEXTURE0);
919710972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9231,7 +11006,7 @@
923111006 gl.glMatrixMode(gl.GL_PROJECTION);
923211007 gl.glLoadIdentity();
923311008
9234
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
11009
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923511010 {
923611011 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923711012 double scale = lightCamera.SCALE / lightCamera.Distance();
....@@ -9289,7 +11064,7 @@
928911064 //gl.glPushMatrix();
929011065 gl.glLoadIdentity();
929111066
9292
- if (!ambientOcclusion) // drawMode != OCCLUSION)
11067
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
929311068 {
929411069 //LA.xformPos(light0, lightCamera.fromScreen, light);
929511070 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9316,8 +11091,8 @@
931611091 System.err.println("parentcam != renderCamera");
931711092
931811093 // if (cam != lightCamera)
9319
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9320
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11094
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11095
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
932111096 }
932211097
932311098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -9338,8 +11113,8 @@
933811113 if (true) // TODO
933911114 {
934011115 if (cam != lightCamera)
9341
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9342
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11116
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11117
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
934311118 }
934411119
934511120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -9376,7 +11151,7 @@
937611151 }
937711152
937811153 /**/
9379
- if (true) // drawMode == SELECTION) // != DEFAULT)
11154
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
938011155 gl.glDisable(gl.GL_LIGHTING);
938111156 else
938211157 gl.glEnable(gl.GL_LIGHTING);
....@@ -9394,7 +11169,7 @@
939411169
939511170 lightslot = 64;
939611171
9397
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11172
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939811173 {
939911174 DrawLights(object);
940011175 }
....@@ -9405,7 +11180,7 @@
940511180 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940611181 //System.out.println("fragmentMode = " + fragmentMode);
940711182
9408
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11183
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
940911184 {
941011185 /*
941111186 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9438,7 +11213,7 @@
943811213 }
943911214 }
944011215
9441
- if (drawMode == DEFAULT)
11216
+ if (DrawMode() == DEFAULT)
944211217 {
944311218 if (WIREFRAME && !ambientOcclusion)
944411219 {
....@@ -9456,7 +11231,7 @@
945611231 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945711232 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945811233
9459
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11234
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
946011235 {
946111236 if (vertexMode != 0) // && !fast)
946211237 {
....@@ -9476,7 +11251,7 @@
947611251 }
947711252 }
947811253
9479
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11254
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
948011255 {
948111256 //gl.glDepthFunc(GL.GL_LEQUAL);
948211257 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9504,7 +11279,7 @@
950411279 //gl.glDepthMask(false);
950511280 }
950611281
9507
- if (false) // drawMode == SHADOW)
11282
+ if (false) // DrawMode() == SHADOW)
950811283 {
950911284 //SetColumnMajorData(cameraInverseTransform, view_1);
951011285 //System.out.println("light = " + cameraInverseTransform);
....@@ -9518,16 +11293,16 @@
951811293 //System.out.println("object = " + object);
951911294 if (!frozen && !imageLocked)
952011295 {
9521
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11296
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
952211297 {
952311298 displayAntiAliased(gl);
952411299 } else
952511300 {
952611301 programcount = 0;
9527
- int keepmode = drawMode;
11302
+ int keepmode = DrawMode();
952811303 // if (DEBUG_SELECTION)
952911304 // {
9530
-// drawMode = SELECTION;
11305
+// DrawMode() = SELECTION;
953111306 // }
953211307 // for point selection
953311308 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9537,10 +11312,10 @@
953711312 DrawObject(gl);
953811313
953911314 // jan 2013 System.err.println("RESET ABORT (display)");
9540
- // if (drawMode == DEFAULT)
11315
+ // if (DrawMode() == DEFAULT)
954111316 // ABORTED = false;
954211317 fullreset = false;
9543
- drawMode = keepmode;
11318
+ Globals.drawMode = keepmode; // WARNING
954411319 //System.out.println("PROGRAM SWITCH " + programcount);
954511320 }
954611321 }
....@@ -9548,11 +11323,11 @@
954811323 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954911324 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
955011325
9551
- if (drawMode == DEFAULT)
11326
+ if (DrawMode() == DEFAULT)
955211327 {
955311328 ReleaseTexture(NOISE_TEXTURE, false);
955411329 }
9555
- //if (drawMode == DEFAULT)
11330
+ //if (DrawMode() == DEFAULT)
955611331 {
955711332
955811333 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9564,7 +11339,7 @@
956411339 //else
956511340 //gl.glDisable(gl.GL_TEXTURE_2D);
956611341 //gl.glPopMatrix();
9567
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11342
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956811343 {
956911344 //new Exception().printStackTrace();
957011345 //System.out.println("Draw image " + width + ", " + height);
....@@ -9606,7 +11381,7 @@
960611381 //gl.glFlush();
960711382 }
960811383
9609
- if (flash && drawMode == DEFAULT)
11384
+ if (flash && DrawMode() == DEFAULT)
961011385 {
961111386 flash = false;
961211387 wait = true;
....@@ -9614,9 +11389,9 @@
961411389 }
961511390
961611391 //drawing = false;
9617
- //if(drawMode == DEFAULT)
11392
+ //if(DrawMode() == DEFAULT)
961811393 // niceon = false;
9619
- if (drawMode == DEFAULT)
11394
+ if (DrawMode() == DEFAULT)
962011395 {
962111396 currentlydrawing = false;
962211397 }
....@@ -9636,7 +11411,7 @@
963611411 repaint();
963711412 }
963811413
9639
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11414
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
964011415 repaint();
964111416
964211417 displaydone = true;
....@@ -9655,8 +11430,14 @@
965511430 {
965611431 renderpass++;
965711432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
965811434 if (FAST) // in case there is no script
9659
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
966011441
966111442 //object.FullInvariants();
966211443
....@@ -9670,10 +11451,10 @@
967011451 e.printStackTrace();
967111452 }
967211453
9673
- if (GrafreeD.RENDERME > 0)
9674
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
967511456
9676
- ONESTEP = false;
11457
+ Globals.ONESTEP = false;
967711458 }
967811459
967911460 static boolean zoomonce = false;
....@@ -9681,11 +11462,11 @@
968111462 void DrawObject(GL gl, boolean draw)
968211463 {
968311464 //System.out.println("DRAW OBJECT " + mouseDown);
9684
-// drawMode = SELECTION;
11465
+// DrawMode() = SELECTION;
968511466 //GL gl = getGL();
968611467 if ((TRACK || SHADOWTRACK) || zoomonce)
968711468 {
9688
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11469
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968911470 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
969011471 pingthread.StepToTarget(true); // true);
969111472 // zoomonce = false;
....@@ -9706,9 +11487,9 @@
970611487 callist = gl.glGenLists(1);
970711488 }
970811489
9709
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11490
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
971011491
9711
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11492
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
971211493
971311494 if (!mainDL || !active || touched)
971411495 {
....@@ -9735,13 +11516,20 @@
973511516 PushMatrix(ClickInfo.matbuffer);
973611517 }
973711518
9738
- if (drawMode == 0)
11519
+ if (DrawMode() == 0)
973911520 {
974011521 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
974111522
974211523 usedtextures.clear();
974311524
9744
- BindTextures(DEFAULT_TEXTURES, 2);
11525
+ try
11526
+ {
11527
+ BindTextures(DEFAULT_TEXTURES, 2);
11528
+ }
11529
+ catch (Exception e)
11530
+ {
11531
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11532
+ }
974511533 }
974611534 //System.out.println("--> " + stackdepth);
974711535 // GrafreeD.traceon();
....@@ -9749,7 +11537,7 @@
974911537 // DRAW
975011538 object.draw(this, /*(Composite)*/ object, false, false);
975111539
9752
- if (drawMode == DEFAULT)
11540
+ if (DrawMode() == DEFAULT)
975311541 {
975411542 if (DEBUG)
975511543 {
....@@ -9801,7 +11589,7 @@
980111589 }
980211590 // GrafreeD.traceoff();
980311591 //System.out.println(stackdepth);
9804
- if (drawMode == 0)
11592
+ if (DrawMode() == 0)
980511593 {
980611594 ReleaseTextures(DEFAULT_TEXTURES);
980711595
....@@ -9826,13 +11614,20 @@
982611614
982711615 checker = null;
982811616
9829
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11617
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
983011618 FindChecker(object);
983111619
9832
- if (checker != null && drawMode == DEFAULT)
11620
+ if (checker != null && DrawMode() == DEFAULT)
983311621 {
983411622 //BindTexture(IMMORTAL_TEXTURE);
9835
- BindTextures(checker.GetTextures(), checker.texres);
11623
+ try
11624
+ {
11625
+ BindTextures(checker.GetTextures(), checker.texres);
11626
+ }
11627
+ catch (Exception e)
11628
+ {
11629
+ System.err.println("FAILED: " + checker.GetTextures());
11630
+ }
983611631 // NEAREST
983711632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
983811633 DrawChecker(gl);
....@@ -9851,7 +11646,7 @@
985111646 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
985211647 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
985311648
9854
- if (DISPLAYTEXT && drawMode == DEFAULT)
11649
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
985511650 {
985611651 // Draw it once, then use the raster
985711652 Balloon(gl, balloon.createGraphics());
....@@ -9907,14 +11702,14 @@
990711702 int[] xs = new int[3];
990811703 int[] ys = new int[3];
990911704
9910
- void DrawString(Object3D obj) // String string)
11705
+ public void DrawString(Object3D obj) // String string) // INTERFACE
991111706 {
9912
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11707
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
991311708 {
991411709 return;
991511710 }
991611711
9917
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
991811713
991911714 GL gl = GetGL();
992011715
....@@ -10231,8 +12026,8 @@
1023112026 //obj.TransformToWorld(light, light);
1023212027 for (int i = tp.size(); --i >= 0;)
1023312028 {
10234
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
10235
- LA.xformPos(light, tp.get(i).toParent, light);
12029
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1023612031 }
1023712032
1023812033
....@@ -10249,8 +12044,8 @@
1024912044 parentcam = cameras[0];
1025012045 }
1025112046
10252
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10253
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12047
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12048
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1025412049
1025512050 LA.xformPos(light, renderCamera.toScreen, light);
1025612051
....@@ -10864,8 +12659,8 @@
1086412659
1086512660 // display shadow only (bump == 0)
1086612661 "SUB temp.x, half.x, shadow.x;" +
10867
- "MOV temp.y, -params6.x;" +
10868
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1086912664 "SUB temp.y, one.x, temp.z;" +
1087012665 "MUL temp.x, temp.x, temp.y;" +
1087112666 "KIL temp.x;" +
....@@ -10994,8 +12789,10 @@
1099412789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1099512790
1099612791 "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
12792
+ // Tuning for default skin
12793
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12794
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12795
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1099912796 "MUL temp.x, temp.x, temp.y;" +
1100012797
1100112798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -11194,7 +12991,7 @@
1119412991 //once = true;
1119512992 }
1119612993
11197
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1119812995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1119912996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1120012997
....@@ -11327,12 +13124,16 @@
1132713124
1132813125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1132913126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1133013129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1133113130 "SGE temp.y, temp.x, zero.x;" +
11332
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1133313134 "SUB temp.x, one.x, temp.x;" +
1133413135 "MUL " + shadow + ".x, temp.x, temp.y;" +
11335
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1133613137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1133713138
1133813139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11346,6 +13147,10 @@
1134613147 // No shadow for backface
1134713148 "DP3 temp.x, normal, lightd;" +
1134813149 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13150
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13151
+
13152
+ // No shadow when out of frustrum
13153
+ "SGE temp.x, " + depth + ".z, one.z;" +
1134913154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1135013155 "";
1135113156 }
....@@ -11904,7 +13709,7 @@
1190413709 public void mousePressed(MouseEvent e)
1190513710 {
1190613711 //System.out.println("mousePressed: " + e);
11907
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1190813713 }
1190913714
1191013715 static long prevtime = 0;
....@@ -11931,14 +13736,16 @@
1193113736
1193213737 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1193313738
13739
+ if (BUTTONLESSWHEEL)
1193413740 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1193513741 {
1193613742 return;
1193713743 }
1193813744
13745
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1193913746
1194013747 // TIMER
11941
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13748
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1194213749 {
1194313750 keepboxmode = BOXMODE;
1194413751 keepsupport = SUPPORT;
....@@ -11978,8 +13785,8 @@
1197813785 // mode |= META;
1197913786 //}
1198013787
11981
- SetMouseMode(WHEEL | e.getModifiersEx());
11982
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1198313790 anchorX = ax;
1198413791 anchorY = ay;
1198513792 prevX = px;
....@@ -12039,6 +13846,10 @@
1203913846 // wasliveok = true;
1204013847 // waslive = false;
1204113848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1204213853 // source == timer
1204313854 if (mouseDown)
1204413855 {
....@@ -12067,7 +13878,7 @@
1206713878 // ObjEditor.tweenManager.update(1f / 60f);
1206813879
1206913880 // fev 2014???
12070
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13881
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1207113882 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1207213883 pingthread.StepToTarget(true); // true);
1207313884 }
....@@ -12077,7 +13888,7 @@
1207713888
1207813889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1207913890
12080
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1208113892 {
1208213893 if (!wasliveok)
1208313894 return;
....@@ -12094,7 +13905,7 @@
1209413905 // touched = true; // main DL
1209513906 if (isRenderer)
1209613907 {
12097
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1209813909 }
1209913910
1210013911 selectX = anchorX = x;
....@@ -12107,7 +13918,7 @@
1210713918 clicked = true;
1210813919 hold = false;
1210913920
12110
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1211113922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1211213923 {
1211313924 // System.out.println("RESTART II " + modifiers);
....@@ -12138,7 +13949,7 @@
1213813949 info.camera = renderCamera;
1213913950 info.x = x;
1214013951 info.y = y;
12141
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1214213953 editObj = object.doEditClick(info, 0);
1214313954 if (!editObj)
1214413955 {
....@@ -12155,11 +13966,14 @@
1215513966
1215613967 public void mouseDragged(MouseEvent e)
1215713968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
13971
+ //System.out.println("mouseDragged: " + e);
1215813972 if (isRenderer)
1215913973 movingcamera = true;
13974
+
1216013975 //if (drawing)
1216113976 //return;
12162
- //System.out.println("mouseDragged: " + e);
1216313977 if ((e.getModifiersEx() & CTRL) != 0
1216413978 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1216513979 {
....@@ -12167,7 +13981,7 @@
1216713981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1216813982 }
1216913983 else
12170
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1217113985
1217213986 //try { Thread.sleep(1); } catch (Exception ex) {}
1217313987 }
....@@ -12179,6 +13993,11 @@
1217913993 cVector tmp = new cVector();
1218013994 cVector tmp2 = new cVector();
1218113995 boolean isMoving;
13996
+
13997
+ public cVector TargetLookAt()
13998
+ {
13999
+ return targetLookAt;
14000
+ }
1218214001
1218314002 class PingThread extends Thread
1218414003 {
....@@ -12318,7 +14137,7 @@
1231814137 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1231914138 if (lightMode)
1232014139 {
12321
- lighttouched = true;
14140
+ Globals.lighttouched = true;
1232214141 }
1232314142
1232414143 if (OEILONCE && OEIL)
....@@ -12335,6 +14154,7 @@
1233514154
1233614155 public void run()
1233714156 {
14157
+ new Exception().printStackTrace();
1233814158 System.exit(0);
1233914159 for (;;)
1234014160 {
....@@ -12376,7 +14196,7 @@
1237614196 mouseDown = false;
1237714197 if (lightMode)
1237814198 {
12379
- lighttouched = true;
14199
+ Globals.lighttouched = true;
1238014200 }
1238114201 repaint();
1238214202 alreadypainted = true;
....@@ -12384,7 +14204,7 @@
1238414204 isMoving = false;
1238514205 } //??
1238614206
12387
- if (isLIVE() && !alreadypainted)
14207
+ if (Globals.isLIVE() && !alreadypainted)
1238814208 {
1238914209 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1239014210 repaint();
....@@ -12396,9 +14216,9 @@
1239614216 {
1239714217 if (lightMode)
1239814218 {
12399
- lighttouched = true;
14219
+ Globals.lighttouched = true;
1240014220 }
12401
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1240214222 }
1240314223 //else
1240414224 }
....@@ -12498,7 +14318,7 @@
1249814318 int X, Y;
1249914319 boolean SX, SY;
1250014320
12501
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1250214322 {
1250314323 if (IsFrozen())
1250414324 {
....@@ -12507,17 +14327,17 @@
1250714327
1250814328 drag = true; // NEW
1250914329
12510
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1251114331
1251214332 X = x;
1251314333 Y = y;
1251414334 // floating state for animation
12515
- MODIFIERS = modifiers;
12516
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1251714337 if (false) // modifiers != 0)
1251814338 {
1251914339 //new Exception().printStackTrace();
12520
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1252114341 System.out.println("SHIFT = " + SHIFT);
1252214342 System.out.println("CONTROL = " + COMMAND);
1252314343 System.out.println("META = " + META);
....@@ -12537,7 +14357,7 @@
1253714357 info.camera = renderCamera;
1253814358 info.x = x;
1253914359 info.y = y;
12540
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1254114361 } else
1254214362 {
1254314363 if (x < startX)
....@@ -12639,6 +14459,7 @@
1263914459 {
1264014460 manipCamera.Translate(dx, dy, getWidth());
1264114461 }
14462
+ else
1264214463 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1264314464 {
1264414465 manipCamera.RotateInterest(dx, dy);
....@@ -12649,7 +14470,7 @@
1264914470
1265014471 if (manipCamera == lightCamera)
1265114472 {
12652
- lighttouched = true;
14473
+ Globals.lighttouched = true;
1265314474 }
1265414475 /*
1265514476 switch (mode)
....@@ -12688,7 +14509,6 @@
1268814509 public void mouseMoved(MouseEvent e)
1268914510 {
1269014511 //System.out.println("mouseMoved: " + e);
12691
-
1269214512 if (isRenderer)
1269314513 return;
1269414514
....@@ -12713,7 +14533,10 @@
1271314533
1271414534 public void mouseReleased(MouseEvent e)
1271514535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1271614538 movingcamera = false;
14539
+ X = Y = 0;
1271714540 //System.out.println("mouseReleased: " + e);
1271814541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1271914542 }
....@@ -12736,9 +14559,9 @@
1273614559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1273714560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1273814561
12739
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1274014563 timeout = true;
12741
- else
14564
+// ?? May 2019 else
1274214565 // timer.setDelay((modifiers & 128) != 0?0:350);
1274314566 mouseDown = false;
1274414567 if (!control && !command) // june 2013
....@@ -12848,7 +14671,7 @@
1284814671 System.out.println("keyReleased: " + e);
1284914672 }
1285014673
12851
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1285214675 {
1285314676 //System.out.println("SetMouseMode = " + modifiers);
1285414677 //modifiers &= ~1024;
....@@ -12860,25 +14683,25 @@
1286014683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1286114684 // return;
1286214685 //System.out.println("SetMode = " + modifiers);
12863
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1286414687 {
1286514688 mouseMode |= ZOOM;
1286614689 }
1286714690
1286814691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
12869
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1287014693 {
1287114694 mouseMode |= VR; // BACKFORTH;
1287214695 }
12873
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
12874
- {
12875
- mouseMode |= SELECT; // BACKFORTH;
12876
- }
12877
- if ((modifiers & COMMAND) == COMMAND)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1287814697 {
1287914698 mouseMode |= SELECT;
1288014699 }
12881
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
14701
+ {
14702
+ mouseMode |= SELECT;
14703
+ }
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1288214705 {
1288314706 mouseMode &= ~VR;
1288414707 mouseMode |= TRANSLATE;
....@@ -12907,10 +14730,10 @@
1290714730
1290814731 if (isRenderer) //
1290914732 {
12910
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1291114734 }
1291214735
12913
- theRenderer.keyPressed(key);
14736
+ Globals.theRenderer.keyPressed(key);
1291414737 }
1291514738
1291614739 int kompactbit = 4; // power bit
....@@ -12922,7 +14745,7 @@
1292214745 float SATPOW = 1; // 2; // 0.5f;
1292314746 float BRIPOW = 1; // 0.5f; // 0.5f;
1292414747
12925
- void keyPressed(int key)
14748
+ public void keyPressed(int key)
1292614749 {
1292714750 if (key >= '0' && key <= '5')
1292814751 clampbit = (key-'0');
....@@ -13037,7 +14860,7 @@
1303714860 case 'B':
1303814861 BRISMOOTH ^= true;
1303914862 SHADOWCULLFACE ^= true;
13040
- lighttouched = true;
14863
+ Globals.lighttouched = true;
1304114864 repaint();
1304214865 break;
1304314866 case 'b':
....@@ -13137,7 +14960,7 @@
1313714960 repaint();
1313814961 break;
1313914962 case 'O':
13140
- drawMode = OCCLUSION;
14963
+ Globals.drawMode = OCCLUSION; // WARNING
1314114964 repaint();
1314214965 break;
1314314966 case 'o':
....@@ -13228,7 +15051,7 @@
1322815051 break;
1322915052 case ' ':
1323015053 lightMode ^= true;
13231
- lighttouched = true;
15054
+ Globals.lighttouched = true;
1323215055 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1323315056 targetLookAt.set(manipCamera.lookAt);
1323415057 repaint();
....@@ -13240,11 +15063,11 @@
1324015063 repaint();
1324115064 break;
1324215065 case 'Z':
13243
- RESIZETEXTURE ^= true;
13244
- break;
15066
+ //RESIZETEXTURE ^= true;
15067
+ //break;
1324515068 case 'z':
13246
- RENDERSHADOW ^= true;
13247
- lighttouched = true;
15069
+ Globals.RENDERSHADOW ^= true;
15070
+ Globals.lighttouched = true;
1324815071 repaint();
1324915072 break;
1325015073 //case UP:
....@@ -13359,6 +15182,7 @@
1335915182 }
1336015183 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1336115184 }
15185
+
1336215186 static double OCCLUSIONBOOST = 1; // 0.5;
1336315187
1336415188 void keyReleased(int key, int modifiers)
....@@ -13366,11 +15190,11 @@
1336615190 //mode = ROTATE;
1336715191 if ((MODIFIERS & COMMAND) == 0) // VR??
1336815192 {
13369
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1337015194 }
1337115195 }
1337215196
13373
- protected void processKeyEvent(KeyEvent e)
15197
+ public void processKeyEvent(KeyEvent e)
1337415198 {
1337515199 switch (e.getID())
1337615200 {
....@@ -13500,8 +15324,9 @@
1350015324
1350115325 protected void processMouseMotionEvent(MouseEvent e)
1350215326 {
13503
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13504
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15327
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15328
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15329
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1350515330 {
1350615331 mouseMoved(e);
1350715332 } else
....@@ -13531,6 +15356,7 @@
1353115356
1353215357 void SelectParent()
1353315358 {
15359
+ new Exception().printStackTrace();
1353415360 System.exit(0);
1353515361 Composite group = (Composite) object;
1353615362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13554,6 +15380,7 @@
1355415380
1355515381 void SelectChildren()
1355615382 {
15383
+ new Exception().printStackTrace();
1355715384 System.exit(0);
1355815385 /*
1355915386 Composite group = (Composite) object;
....@@ -13718,7 +15545,9 @@
1371815545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1371915546 //Image img = CreateImage(width, height);
1372015547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1372115549 Graphics gr = g; // img.getGraphics();
15550
+
1372215551 if (!hasMarquee)
1372315552 {
1372415553 if (Xmin < Xmax) // !locked)
....@@ -13816,14 +15645,33 @@
1381615645 if (!isRenderer)
1381715646 {
1381815647 object.drawEditHandles(info, 0);
15648
+
15649
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15650
+ {
15651
+ switch (object.selection.get(0).hitSomething)
15652
+ {
15653
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15654
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
+ break;
15656
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
+ break;
15659
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15660
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
+ break;
15662
+ }
15663
+
15664
+ }
1381915665 }
1382015666 }
15667
+
1382115668 if (isRenderer)
1382215669 {
1382315670 //gr.setColor(Color.black);
1382415671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1382515672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1382615673 }
15674
+
1382715675 if (hasMarquee)
1382815676 {
1382915677 gr.setXORMode(Color.white);
....@@ -13846,6 +15694,7 @@
1384615694 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1384715695 }
1384815696
15697
+ // To avoid clear.
1384915698 public void update(Graphics g)
1385015699 {
1385115700 paint(g);
....@@ -13935,6 +15784,7 @@
1393515784 public boolean mouseDown(Event evt, int x, int y)
1393615785 {
1393715786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1393815788 /*
1393915789 locked = true;
1394015790 drag = false;
....@@ -13978,7 +15828,7 @@
1397815828 {
1397915829 keyPressed(0, modifiers);
1398015830 }
13981
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1398215832 return true;
1398315833 }
1398415834
....@@ -14096,7 +15946,7 @@
1409615946 {
1409715947 keyReleased(0, 0);
1409815948 }
14099
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1410015950 return true;
1410115951 }
1410215952
....@@ -14228,7 +16078,7 @@
1422816078 Object3D object;
1422916079 static Object3D trackedobject;
1423016080 Camera renderCamera; // Light or Eye (or Occlusion)
14231
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1423216082 /*static*/ Camera eyeCamera;
1423316083 /*static*/ Camera lightCamera;
1423416084 int cameracount;
....@@ -14508,20 +16358,21 @@
1450816358 /**/
1450916359 //checker.GetMaterial().opacity = 1.1f;
1451016360 ////checker.GetMaterial().ambient = 0.99f;
14511
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14512
- Object3D.selectedstack[Object3D.materialdepth] = false;
14513
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16361
+ materialstack[materialdepth] = checker.material;
16362
+ selectedstack[materialdepth] = false;
16363
+ cStatic.objectstack[materialdepth++] = checker;
1451416364 //System.out.println("material " + material);
1451516365 //Applet3D.tracein(this, selected);
1451616366 vector2buffer = checker.projectedVertices;
1451716367
14518
- checker.GetMaterial().Draw(this, false); // true);
16368
+ //checker.GetMaterial().Draw(this, false); // true);
16369
+ DrawMaterial(checker.GetMaterial(), false); // true);
1451916370
14520
- Object3D.materialdepth -= 1;
14521
- if (Object3D.materialdepth > 0)
16371
+ materialdepth -= 1;
16372
+ if (materialdepth > 0)
1452216373 {
14523
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14524
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16374
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16375
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1452516376 }
1452616377 //checker.GetMaterial().opacity = 1f;
1452716378 ////checker.GetMaterial().ambient = 1f;
....@@ -14665,6 +16516,7 @@
1466516516 {
1466616517 if (!selection)
1466716518 {
16519
+ new Exception().printStackTrace();
1466816520 System.exit(0);
1466916521 return;
1467016522 }
....@@ -14687,14 +16539,14 @@
1468716539
1468816540 //int tmp = selection_view;
1468916541 //selection_view = -1;
14690
- int temp = drawMode;
14691
- drawMode = SELECTION;
16542
+ int temp = DrawMode();
16543
+ Globals.drawMode = SELECTION; // WARNING
1469216544 indexcount = 0;
1469316545 parent.display(drawable);
1469416546 //selection_view = tmp;
1469516547 //if (temp == SELECTION)
1469616548 // temp = DEFAULT; // patch for selection debug
14697
- drawMode = temp;
16549
+ Globals.drawMode = temp; // WARNING
1469816550
1469916551 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1470016552
....@@ -14792,16 +16644,16 @@
1479216644 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]));
1479316645 }
1479416646
14795
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1479616648 }
1479716649 }
1479816650
1479916651 if (!movingcamera && !PAINTMODE)
1480016652 object.editWindow.ScreenFitPoint(); // fev 2014
1480116653
14802
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16654
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1480316655 {
14804
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16656
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1480516657
1480616658 Object3D group = new Object3D("inst" + paintcount++);
1480716659
....@@ -14957,7 +16809,7 @@
1495716809 gl.glDisable(gl.GL_CULL_FACE);
1495816810 }
1495916811
14960
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1496116813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1496216814
1496316815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14967,14 +16819,14 @@
1496716819 //gl.glColorMask(false, false, false, false);
1496816820
1496916821 //render_scene_from_light_view(gl, drawable, 0, 0);
14970
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1497116823 {
1497216824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1497316825
14974
- int temp = drawMode;
14975
- drawMode = SHADOW;
16826
+ int temp = DrawMode();
16827
+ Globals.drawMode = SHADOW; // WARNING
1497616828 parent.display(drawable);
14977
- drawMode = temp;
16829
+ Globals.drawMode = temp; // WARNING
1497816830 }
1497916831
1498016832 gl.glCullFace(gl.GL_BACK);
....@@ -15027,7 +16879,6 @@
1502716879
1502816880 class AntialiasBuffer implements GLEventListener
1502916881 {
15030
-
1503116882 CameraPane parent = null;
1503216883
1503316884 AntialiasBuffer(CameraPane p)
....@@ -15372,12 +17223,6 @@
1537217223 GLUT glut = new GLUT();
1537317224
1537417225
15375
- static final public int DEFAULT = 0;
15376
- static final public int SELECTION = 1;
15377
- static final public int SHADOW = 2;
15378
- static final public int OCCLUSION = 3;
15379
- static
15380
- public int drawMode = DEFAULT;
1538117226 public boolean spherical = false;
1538217227 static boolean DEBUG_OCCLUSION = false;
1538317228 static boolean DEBUG_SELECTION = false;
....@@ -15426,7 +17271,7 @@
1542617271 }
1542717272 }
1542817273
15429
- static void DrawPoints(CameraPane cpane)
17274
+ static void DrawPoints(iCameraPane cpane)
1543017275 {
1543117276 for (int i=0; i<8; i++) // first and last are red
1543217277 {
....@@ -15458,10 +17303,11 @@
1545817303 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1545917304 // Depth buffer format
1546017305 //private int depth_format;
15461
- static public void NextIndex(Object3D o, GL gl)
17306
+
17307
+ public void NextIndex()
1546217308 {
1546317309 indexcount+=16;
15464
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17310
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1546517311 //objects[indexcount] = o;
1546617312 //System.out.println("indexcount = " + indexcount);
1546717313 }