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,41 @@
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;
159
+ }
160
+
161
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
162
+ {
163
+ super(defaultcaps, null, withcontext?glcontext:null, null);
164
+
165
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
166
+ glcontext = getContext();
167
+
168
+ cameras = new Camera[2];
169
+ targetLookAts = new cVector[2];
170
+
171
+ SetCamera(cam);
172
+
173
+ SetLight(new Camera(new cVector(10, 10, -20)));
174
+
175
+ object = o;
176
+
177
+ setBackground(Color.white);
178
+
179
+ addKeyListener(this);
180
+ addMouseListener(this);
181
+ addMouseMotionListener(this);
182
+ addMouseWheelListener(this);
183
+ //System.out.println("addGLEventListener: " + this);
184
+ addGLEventListener(this);
185
+
186
+// pingthread.start(); // may 2013
174187 }
175188
176189 static boolean AntialiasingEnabled()
....@@ -178,12 +191,53 @@
178191 return CURRENTANTIALIAS > 0;
179192 }
180193
181
- 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()
182236 {
183237 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184238 }
185239
186
- void DepthTest(boolean depthtest)
240
+ public void DepthTest(boolean depthtest)
187241 {
188242 if (depthtest)
189243 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +245,7 @@
191245 GetGL().glDepthFunc(GL.GL_ALWAYS);
192246 }
193247
194
- void DepthWrite(boolean depthwrite)
248
+ public void DepthWrite(boolean depthwrite)
195249 {
196250 if (depthwrite)
197251 GetGL().glDepthMask(true);
....@@ -199,12 +253,1602 @@
199253 GetGL().glDepthMask(false);
200254 }
201255
202
- void BackFaceCull(boolean bfc)
256
+ public void BackFaceCull(boolean bfc)
203257 {
204258 if (bfc)
205259 GetGL().glEnable(GetGL().GL_CULL_FACE);
206260 else
207261 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
+ }
2081852 }
2091853
2101854 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,10 +1869,10 @@
2251869 currentGL.glMultMatrixd(model, 0);
2261870 }
2271871
228
- void PushMatrix(double[][] matrix, int count)
1872
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291873 {
2301874 matrixdepth++;
231
- // GraphreeD.tracein(matrix);
1875
+ // GrafreeD.tracein(matrix);
2321876 if (matrix == null)
2331877 return; // Identity
2341878
....@@ -253,13 +1897,13 @@
2531897
2541898 void PushMatrix(double[][] matrix)
2551899 {
256
- // GraphreeD.tracein(matrix);
257
- PushMatrix(matrix,1);
1900
+ // GrafreeD.tracein(matrix);
1901
+ PushMatrix(matrix, 1);
2581902 }
2591903
2601904 void PushMatrix()
2611905 {
262
- // GraphreeD.tracein(null);
1906
+ // GrafreeD.tracein(null);
2631907 if (matrixdepth++ < MAXSTACK - 1)
2641908 {
2651909 currentGL.glPushMatrix();
....@@ -270,11 +1914,11 @@
2701914
2711915 double[][] tmpmat = new double[4][4];
2721916
273
- void PopMatrix(double[][] inverse)
1917
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741918 {
2751919 --matrixdepth;
2761920
277
- // GraphreeD.traceout(inverse);
1921
+ // GrafreeD.traceout(inverse);
2781922 if (inverse == null)
2791923 return; // Identity
2801924
....@@ -292,7 +1936,7 @@
2921936
2931937 void PopMatrix()
2941938 {
295
- // GraphreeD.traceout(null);
1939
+ // GrafreeD.traceout(null);
2961940 // inverse == null??
2971941 if (--matrixdepth < MAXSTACK - 1)
2981942 {
....@@ -310,7 +1954,7 @@
3101954 PushTextureMatrix(matrix, 1);
3111955 }
3121956
313
- void PushTextureMatrix(double[][] matrix, int count)
1957
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141958 {
3151959 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161960
....@@ -324,7 +1968,7 @@
3241968 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251969 }
3261970
327
- void PopTextureMatrix(double[][] inverse)
1971
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281972 {
3291973 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301974 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -351,15 +1995,15 @@
3511995
3521996 static int camerachangeframe;
3531997
354
- boolean SetCamera(Camera cam)
1998
+ public boolean SetCamera(Camera cam)
3551999 {
3562000 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3572001 // return false;
3582002
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
2003
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3602004 {
3612005 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
2006
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3632007 {
3642008 // refuse the camera change
3652009 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +2011,7 @@
3672011 }
3682012 }
3692013
370
- camerachangeframe = framecount;
2014
+ camerachangeframe = Globals.framecount;
3712015
3722016 cam.hAspect = -1; // Read only
3732017
....@@ -398,7 +2042,7 @@
3982042 {
3992043 //System.err.println("Oeil on");
4002044 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2045
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022046 // object.editWindow.ScreenFit(trackedobject);
4032047 //pingthread.StepToTarget(true);
4042048 }
....@@ -407,7 +2051,7 @@
4072051 {
4082052 //System.err.println("Oeil on");
4092053 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2054
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4112055 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4122056 //pingthread.StepToTarget(true);
4132057 }
....@@ -471,39 +2115,12 @@
4712115 {
4722116 frozen ^= true;
4732117 // Weird...
474
- lighttouched = true;
2118
+ Globals.lighttouched = true;
4752119 }
4762120
4772121 void ToggleDL()
4782122 {
4792123 mainDL ^= true;
480
- }
481
-
482
- void ToggleTexture()
483
- {
484
- textureon ^= true;
485
- }
486
-
487
- void ToggleLive()
488
- {
489
- setLIVE(isLIVE() ^ true);
490
-
491
- System.err.println("LIVE = " + isLIVE());
492
-
493
- if (!isLIVE()) // save sound
494
- GraphreeD.savesound = true; // wav.save();
495
- // else
496
- repaint(); // start loop // may 2013
497
- }
498
-
499
- void ToggleSupport()
500
- {
501
- SUPPORT ^= true;
502
- }
503
-
504
- void ToggleAbort()
505
- {
506
- ABORTMODE ^= true;
5072124 }
5082125
5092126 void ToggleFullScreen()
....@@ -513,12 +2130,7 @@
5132130
5142131 void ToggleCrowd()
5152132 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2133
+ Globals.CROWD ^= true;
5222134 }
5232135
5242136 void ToggleLocal()
....@@ -526,62 +2138,89 @@
5262138 LOCALTRANSFORM ^= true;
5272139 }
5282140
529
- 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()
5302174 {
5312175 FAST ^= true;
5322176 }
5332177
534
- void ToggleSlowPose()
2178
+ public void ToggleSlowPose()
5352179 {
5362180 SLOWPOSE ^= true;
5372181 }
5382182
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2183
+ public void ToggleBoxMode()
5452184 {
5462185 BOXMODE ^= true;
5472186 }
5482187
549
- void ToggleSmoothFocus()
2188
+ public void ToggleZoomBoxMode()
2189
+ {
2190
+ ZOOMBOXMODE ^= true;
2191
+ }
2192
+
2193
+ public void ToggleSmoothFocus()
5502194 {
5512195 SMOOTHFOCUS ^= true;
5522196 }
5532197
554
- void ToggleImageFlip()
2198
+ public void ToggleImageFlip()
5552199 {
5562200 IMAGEFLIP ^= true;
5572201 }
5582202
559
- void ToggleSpeakerMocap()
2203
+ public void ToggleSpeakerMocap()
5602204 {
5612205 SPEAKERMOCAP ^= true;
5622206 }
5632207
564
- void ToggleSpeakerCamera()
2208
+ public void ToggleSpeakerCamera()
5652209 {
5662210 SPEAKERCAMERA ^= true;
5672211 }
5682212
569
- void ToggleSpeakerFocus()
2213
+ public void ToggleSpeakerFocus()
5702214 {
5712215 SPEAKERFOCUS ^= true;
5722216 }
5732217
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2218
+ public void ToggleFrustum()
5802219 {
5812220 FRUSTUM ^= true;
5822221 }
5832222
584
- void ToggleTrack()
2223
+ public void ToggleTrack()
5852224 {
5862225 TRACK ^= true;
5872226 if (TRACK)
....@@ -600,25 +2239,35 @@
6002239 repaint();
6012240 }
6022241
603
- void ToggleTrackOnce()
2242
+ public void ToggleTrackOnce()
6042243 {
6052244 TRACKONCE ^= true;
6062245 }
6072246
608
- void ToggleShadowTrack()
2247
+ public void ToggleShadowTrack()
6092248 {
6102249 SHADOWTRACK ^= true;
6112250 repaint();
6122251 }
6132252
614
- void ToggleOeil()
2253
+ public void ToggleOeil()
6152254 {
6162255 OEIL ^= true;
6172256 }
6182257
619
- void ToggleOeilOnce()
2258
+ public void ToggleOeilOnce()
6202259 {
6212260 OEILONCE ^= true;
2261
+ }
2262
+
2263
+ void ToggleFootContact()
2264
+ {
2265
+ FOOTCONTACT ^= true;
2266
+ }
2267
+
2268
+ void ToggleDebug()
2269
+ {
2270
+ DEBUG ^= true;
6222271 }
6232272
6242273 void ToggleLookAt()
....@@ -626,9 +2275,9 @@
6262275 LOOKAT ^= true;
6272276 }
6282277
629
- void ToggleRandom()
2278
+ void ToggleSwitch()
6302279 {
631
- RANDOM ^= true;
2280
+ SWITCH ^= true;
6322281 }
6332282
6342283 void ToggleHandles()
....@@ -672,34 +2321,6 @@
6722321 //assert (cam.hAspect == 0);
6732322 cam.hAspect = 0;
6742323 lightCamera = cam;
675
- }
676
-
677
- CameraPane(Object3D o, Camera cam, boolean withcontext)
678
- {
679
- super(defaultcaps, null, withcontext?glcontext:null, null);
680
-
681
- //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
682
- glcontext = getContext();
683
-
684
- cameras = new Camera[2];
685
- targetLookAts = new cVector[2];
686
-
687
- SetCamera(cam);
688
-
689
- SetLight(new Camera(new cVector(10, 10, -20)));
690
-
691
- object = o;
692
-
693
- setBackground(Color.white);
694
-
695
- addKeyListener(this);
696
- addMouseListener(this);
697
- addMouseMotionListener(this);
698
- addMouseWheelListener(this);
699
- //System.out.println("addGLEventListener: " + this);
700
- addGLEventListener(this);
701
-
702
-// pingthread.start(); // may 2013
7032324 }
7042325
7052326 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -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 {
....@@ -2000,10 +3621,12 @@
20003621 */
20013622 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20023623 {
3624
+ int pixelformat = texturedata.getPixelFormat();
3625
+
20033626 int stride = 1;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
3627
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20053628 stride = 3;
2006
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
3629
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20073630 stride = 4;
20083631
20093632 int width = texturedata.getWidth();
....@@ -2593,6 +4216,7 @@
25934216
25944217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25954218 {
4219
+ new Exception().printStackTrace();
25964220 System.exit(0);
25974221 com.sun.opengl.util.texture.Texture texture = null;
25984222
....@@ -6269,7 +7893,7 @@
62697893 return null;
62707894 }
62717895
6272
- void ReleaseTextures(cTexture tex)
7896
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62737897 {
62747898 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62757899 {
....@@ -6305,9 +7929,67 @@
63057929 ReleaseTexture(pigment, false);
63067930 }
63077931
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
+
63087990 void ReleaseTexture(String tex, boolean bump)
63097991 {
6310
- if (// drawMode != 0 || /*tex == null ||*/
7992
+ if (// DrawMode() != 0 || /*tex == null ||*/
63117993 ambientOcclusion ) // || !textureon)
63127994 {
63137995 return;
....@@ -6333,7 +8015,7 @@
63338015 {
63348016 bumpdepth--;
63358017
6336
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
8018
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63378019 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63388020 {
63398021 // assert (bumpstack[bumpdepth] == texture);
....@@ -6363,7 +8045,7 @@
63638045 {
63648046 pigmentdepth--;
63658047
6366
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
8048
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63678049 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63688050 {
63698051 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6408,9 +8090,9 @@
64088090 }
64098091 }
64108092
6411
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64128094 {
6413
- if (// drawMode != 0 || /*tex == null ||*/
8095
+ if (// DrawMode() != 0 || /*tex == null ||*/
64148096 ambientOcclusion ) // || !textureon)
64158097 {
64168098 return; // false;
....@@ -6453,7 +8135,94 @@
64538135 return; // true;
64548136 }
64558137
6456
- 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
64578226 {
64588227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64598228
....@@ -6461,12 +8230,18 @@
64618230 {
64628231 String texname = tex;
64638232
6464
- String[] split = tex.split("Textures");
6465
- if (split.length > 1)
6466
- texname = "/Users/nbriere/Textures" + split[split.length-1];
6467
- else
6468
- if (!texname.startsWith("/"))
6469
- 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
+ }
64708245
64718246 if (CACHETEXTURE)
64728247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -6535,7 +8310,7 @@
65358310 }
65368311
65378312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
6538
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
65398314 cachename = texname;
65408315 else
65418316 processbump = false; // don't process bump map again
....@@ -6557,7 +8332,7 @@
65578332 }
65588333
65598334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
6560
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
65618336 cachename = texname;
65628337 else
65638338 processbump = false; // don't process bump map again
....@@ -6566,7 +8341,9 @@
65668341 texturedata = GetFileTexture(cachename, processbump, resolution);
65678342
65688343
6569
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
65708347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
65718348 //texture = GetTexture(tex, bump);
65728349 }
....@@ -6688,32 +8465,32 @@
66888465 return texture;
66898466 }
66908467
6691
- 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
66928469 {
66938470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66948471
66958472 if (bump)
66968473 {
6697
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
8474
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66988475 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66998476 }
67008477 else
67018478 {
6702
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
8479
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
67038480 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
67048481 }
67058482
67068483 return texture!=null?texture.texture:null;
67078484 }
67088485
6709
- 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
67108487 {
67118488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67128489
67138490 return texture!=null?texture.texturedata:null;
67148491 }
67158492
6716
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
67178494 {
67188495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67198496 {
....@@ -7310,9 +9087,9 @@
73109087 static boolean occlusionInitialized = false;
73119088 boolean selection = false;
73129089 boolean pointselection = false;
7313
- /*static*/ boolean lighttouched = true;
9090
+ ///*static*/ boolean lighttouched = true;
73149091 boolean deselect;
7315
- boolean ambientOcclusion = false;
9092
+ private boolean ambientOcclusion = false;
73169093 static boolean flash = false;
73179094 /*static*/ boolean wait = false;
73189095 boolean displaydone = false; // after repaint() calls
....@@ -7442,6 +9219,8 @@
74429219 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74439220 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74449221 double scale = lightCamera.SCALE / lightCamera.Distance();
9222
+// PATCH FILLE AUX JEANS
9223
+ //scale *= lightCamera.shaper_fovy / 25;
74459224 gl.glScaled(2 * scale, 2 * scale, -scale);
74469225 gl.glTranslated(0, 0, lightCamera.DECAL);
74479226
....@@ -7590,15 +9369,14 @@
75909369
75919370 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75929371 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
7593
- float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity
9372
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
9373
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75949374
75959375 static int imagecount = 0; // movie generation
75969376
75979377 static int jitter = 0;
75989378
75999379 boolean restartframe = false;
7600
-
7601
- static int framecount = 0; // general-purpose global count
76029380
76039381 void displayAntiAliased(javax.media.opengl.GL gl)
76049382 {
....@@ -7628,14 +9406,14 @@
76289406
76299407 //System.out.println("start frame");
76309408 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7631
- for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0)
9409
+ for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76329410 {
7633
- framecount++;
9411
+ Globals.framecount++;
76349412
76359413 if (CameraPane.tickcount > 0)
76369414 CameraPane.tickcount--;
76379415
7638
-// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
9416
+// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
76399417 // restartframe = true;
76409418 if (options1[2] > 100 && (jitter%2==0))
76419419 {
....@@ -7668,7 +9446,7 @@
76689446
76699447 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76709448 */
7671
- lighttouched = true;
9449
+ Globals.lighttouched = true;
76729450 //System.err.println(" shadowbuffer: " + jitter);
76739451 shadowbuffer.display();
76749452
....@@ -7689,8 +9467,8 @@
76899467 assert (parentcam != renderCamera);
76909468
76919469 if (renderCamera != lightCamera)
7692
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7693
- LA.matConcat(parentcam.toParent, matrix, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
76949472
76959473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76969474
....@@ -7705,8 +9483,8 @@
77059483 LA.matCopy(renderCamera.fromScreen, matrix);
77069484
77079485 if (renderCamera != lightCamera)
7708
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7709
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
77109488
77119489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77129490
....@@ -7778,7 +9556,7 @@
77789556 //gl.glFlush();
77799557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77809558
7781
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
77829560 {
77839561 System.err.println(" ABORTED FRAME");
77849562 break;
....@@ -7808,7 +9586,7 @@
78089586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78099587
78109588 // save image
7811
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
78129590 {
78139591 VPwidth = viewport[2];
78149592 VPheight = viewport[3];
....@@ -7919,11 +9697,11 @@
79199697
79209698 // imagecount++;
79219699
7922
- 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;
79239701
79249702 if (!BOXMODE)
79259703 {
7926
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
9704
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
79279705 }
79289706
79299707 if (!BOXMODE)
....@@ -7951,7 +9729,7 @@
79519729 {
79529730 if (ACSIZE > 1)
79539731 {
7954
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
9732
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79559733 }
79569734 }
79579735
....@@ -7961,7 +9739,7 @@
79619739 ABORTED = false;
79629740 }
79639741 else
7964
- GraphreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
79659743
79669744 if (false)
79679745 {
....@@ -8615,13 +10393,6 @@
861510393 }
861610394 }
861710395
8618
- boolean IsFrozen()
8619
- {
8620
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8621
-
8622
- return !selectmode && cameracount == 0; // != 0;
8623
- }
8624
-
862510396 boolean niceon = false;
862610397 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
862710398 boolean currentlydrawing = false;
....@@ -8631,16 +10402,16 @@
863110402
863210403 public void display(GLAutoDrawable drawable)
863310404 {
8634
- if (GraphreeD.savesound && GraphreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
863510406 {
8636
- GraphreeD.wav.save();
8637
- GraphreeD.savesound = false;
8638
- GraphreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
863910410 }
864010411 // if (DEBUG_SELECTION)
864110412 // {
8642
-// if (drawMode != SELECTION)
8643
-// drawMode = SELECTION;
10413
+// if (DrawMode() != SELECTION)
10414
+// DrawMode() = SELECTION;
864410415 // }
864510416
864610417 if (!isRenderer)
....@@ -8696,9 +10467,9 @@
869610467
869710468 //ANTIALIAS = 0;
869810469
8699
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10470
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870010471 {
8701
- if (niceon || isLIVE())
10472
+ if (niceon || Globals.isLIVE())
870210473 {
870310474 //if(active == 0)
870410475 // antialiaser = null;
....@@ -8723,7 +10494,7 @@
872310494 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872410495 */
872510496
8726
- if (drawMode == DEFAULT)
10497
+ if (DrawMode() == DEFAULT)
872710498 {
872810499 currentlydrawing = true;
872910500 }
....@@ -8754,18 +10525,18 @@
875410525
875510526 // if(Applet3D.clipboard != null)
875610527 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8757
-//drawMode = SELECTION;
10528
+//DrawMode() = SELECTION;
875810529 indexcount = 0;
875910530
8760
- if (drawMode == OCCLUSION)
10531
+ if (DrawMode() == OCCLUSION)
876110532 {
8762
- drawMode = DEFAULT;
10533
+ Globals.drawMode = DEFAULT; // WARNING
876310534 ambientOcclusion = true;
876410535 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876510536 Object3D theobject = object;
876610537 Object3D theparent = object.parent;
876710538 object.parent = null;
8768
- object = (Object3D)GraphreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
876910540 object.Stripify();
877010541 if (theobject.selection == null || theobject.selection.Size() == 0)
877110542 theobject.PreprocessOcclusion(this);
....@@ -8778,19 +10549,19 @@
877810549 ambientOcclusion = false;
877910550 }
878010551
8781
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878210553 {
878310554 //if (RENDERSHADOW) // ?
878410555 if (!IsFrozen())
878510556 {
878610557 // dec 2012
8787
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
878810559 {
8789
- framecount++;
10560
+ Globals.framecount++;
879010561 shadowbuffer.display();
879110562 }
879210563 }
8793
- lighttouched = false; // ??
10564
+ Globals.lighttouched = false; // ??
879410565 //drawing = true;
879510566 //lighttouched = true;
879610567 }
....@@ -8811,9 +10582,9 @@
881110582 //eyeCamera.shaper_fovy = 1;
881210583 }
881310584
8814
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10585
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881510586 {
8816
- //System.out.println("drawMode = " + drawMode);
10587
+ //System.out.println("DrawMode() = " + DrawMode());
881710588 vertexMode |= VP_PASS;
881810589 //vertexMode |= VP_PROJECTION;
881910590 if (!ambientOcclusion)
....@@ -8873,7 +10644,7 @@
887310644 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887410645 //Camera lightcam = new Camera(light0);
887510646
8876
- if (drawMode == SHADOW)
10647
+ if (DrawMode() == SHADOW)
887710648 {
887810649 /*
887910650 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8911,8 +10682,8 @@
891110682
891210683 // if (parentcam != renderCamera) // not a light
891310684 if (cam != lightCamera)
8914
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8915
- LA.matConcat(parentcam.toParent, matrix, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
891610687
891710688 for (int j = 0; j < 4; j++)
891810689 {
....@@ -8926,8 +10697,8 @@
892610697
892710698 // if (parentcam != renderCamera) // not a light
892810699 if (cam != lightCamera)
8929
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8930
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
893110702
893210703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893310704
....@@ -8963,7 +10734,7 @@
896310734 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896410735 } else
896510736 {
8966
- if (drawMode != DEFAULT)
10737
+ if (DrawMode() != DEFAULT)
896710738 {
896810739 gl.glClearColor(1, 1, 1, 0);
896910740 } // 1);
....@@ -9028,7 +10799,7 @@
902810799
902910800 fast &= !ambientOcclusion;
903010801
9031
- if (drawMode == DEFAULT)
10802
+ if (DrawMode() == DEFAULT)
903210803 {
903310804 //gl.glEnable(gl.GL_ALPHA_TEST);
903410805 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9089,6 +10860,8 @@
908910860 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909010861 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909110862 double scale = lightCamera.SCALE / lightCamera.Distance();
10863
+// PATCH FILLE AUX JEANS
10864
+ //scale *= lightCamera.shaper_fovy / 25;
909210865 gl.glScaled(2 * scale, 2 * scale, -scale);
909310866 gl.glTranslated(0, 0, lightCamera.DECAL);
909410867
....@@ -9184,7 +10957,16 @@
918410957 // Bump noise
918510958 gl.glActiveTexture(GL.GL_TEXTURE6);
918610959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9187
- 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
+
918810970
918910971 gl.glActiveTexture(GL.GL_TEXTURE0);
919010972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9224,10 +11006,12 @@
922411006 gl.glMatrixMode(gl.GL_PROJECTION);
922511007 gl.glLoadIdentity();
922611008
9227
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
11009
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
922811010 {
922911011 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923011012 double scale = lightCamera.SCALE / lightCamera.Distance();
11013
+// PATCH FILLE AUX JEANS
11014
+ //scale *= lightCamera.shaper_fovy / 25;
923111015 gl.glScaled(2 * scale, 2 * scale, -scale);
923211016 gl.glTranslated(0, 0, lightCamera.DECAL);
923311017 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9280,7 +11064,7 @@
928011064 //gl.glPushMatrix();
928111065 gl.glLoadIdentity();
928211066
9283
- if (!ambientOcclusion) // drawMode != OCCLUSION)
11067
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928411068 {
928511069 //LA.xformPos(light0, lightCamera.fromScreen, light);
928611070 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9307,8 +11091,8 @@
930711091 System.err.println("parentcam != renderCamera");
930811092
930911093 // if (cam != lightCamera)
9310
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9311
- 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
931211096 }
931311097
931411098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -9329,8 +11113,8 @@
932911113 if (true) // TODO
933011114 {
933111115 if (cam != lightCamera)
9332
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9333
- 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
933411118 }
933511119
933611120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -9367,7 +11151,7 @@
936711151 }
936811152
936911153 /**/
9370
- if (true) // drawMode == SELECTION) // != DEFAULT)
11154
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937111155 gl.glDisable(gl.GL_LIGHTING);
937211156 else
937311157 gl.glEnable(gl.GL_LIGHTING);
....@@ -9379,12 +11163,13 @@
937911163
938011164 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
938111165 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
11166
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
938211167
938311168 options2[0] *= renderCamera.Distance();
938411169
938511170 lightslot = 64;
938611171
9387
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11172
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
938811173 {
938911174 DrawLights(object);
939011175 }
....@@ -9395,7 +11180,7 @@
939511180 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
939611181 //System.out.println("fragmentMode = " + fragmentMode);
939711182
9398
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11183
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
939911184 {
940011185 /*
940111186 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9428,7 +11213,7 @@
942811213 }
942911214 }
943011215
9431
- if (drawMode == DEFAULT)
11216
+ if (DrawMode() == DEFAULT)
943211217 {
943311218 if (WIREFRAME && !ambientOcclusion)
943411219 {
....@@ -9446,7 +11231,7 @@
944611231 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
944711232 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
944811233
9449
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11234
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945011235 {
945111236 if (vertexMode != 0) // && !fast)
945211237 {
....@@ -9466,7 +11251,7 @@
946611251 }
946711252 }
946811253
9469
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11254
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947011255 {
947111256 //gl.glDepthFunc(GL.GL_LEQUAL);
947211257 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9494,7 +11279,7 @@
949411279 //gl.glDepthMask(false);
949511280 }
949611281
9497
- if (false) // drawMode == SHADOW)
11282
+ if (false) // DrawMode() == SHADOW)
949811283 {
949911284 //SetColumnMajorData(cameraInverseTransform, view_1);
950011285 //System.out.println("light = " + cameraInverseTransform);
....@@ -9508,16 +11293,16 @@
950811293 //System.out.println("object = " + object);
950911294 if (!frozen && !imageLocked)
951011295 {
9511
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11296
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951211297 {
951311298 displayAntiAliased(gl);
951411299 } else
951511300 {
951611301 programcount = 0;
9517
- int keepmode = drawMode;
11302
+ int keepmode = DrawMode();
951811303 // if (DEBUG_SELECTION)
951911304 // {
9520
-// drawMode = SELECTION;
11305
+// DrawMode() = SELECTION;
952111306 // }
952211307 // for point selection
952311308 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9527,10 +11312,10 @@
952711312 DrawObject(gl);
952811313
952911314 // jan 2013 System.err.println("RESET ABORT (display)");
9530
- // if (drawMode == DEFAULT)
11315
+ // if (DrawMode() == DEFAULT)
953111316 // ABORTED = false;
953211317 fullreset = false;
9533
- drawMode = keepmode;
11318
+ Globals.drawMode = keepmode; // WARNING
953411319 //System.out.println("PROGRAM SWITCH " + programcount);
953511320 }
953611321 }
....@@ -9538,11 +11323,11 @@
953811323 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
953911324 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954011325
9541
- if (drawMode == DEFAULT)
11326
+ if (DrawMode() == DEFAULT)
954211327 {
954311328 ReleaseTexture(NOISE_TEXTURE, false);
954411329 }
9545
- //if (drawMode == DEFAULT)
11330
+ //if (DrawMode() == DEFAULT)
954611331 {
954711332
954811333 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9554,7 +11339,7 @@
955411339 //else
955511340 //gl.glDisable(gl.GL_TEXTURE_2D);
955611341 //gl.glPopMatrix();
9557
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11342
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
955811343 {
955911344 //new Exception().printStackTrace();
956011345 //System.out.println("Draw image " + width + ", " + height);
....@@ -9596,7 +11381,7 @@
959611381 //gl.glFlush();
959711382 }
959811383
9599
- if (flash && drawMode == DEFAULT)
11384
+ if (flash && DrawMode() == DEFAULT)
960011385 {
960111386 flash = false;
960211387 wait = true;
....@@ -9604,9 +11389,9 @@
960411389 }
960511390
960611391 //drawing = false;
9607
- //if(drawMode == DEFAULT)
11392
+ //if(DrawMode() == DEFAULT)
960811393 // niceon = false;
9609
- if (drawMode == DEFAULT)
11394
+ if (DrawMode() == DEFAULT)
961011395 {
961111396 currentlydrawing = false;
961211397 }
....@@ -9626,7 +11411,7 @@
962611411 repaint();
962711412 }
962811413
9629
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11414
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963011415 repaint();
963111416
963211417 displaydone = true;
....@@ -9645,8 +11430,14 @@
964511430 {
964611431 renderpass++;
964711432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
964811434 if (FAST) // in case there is no script
9649
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
965011441
965111442 //object.FullInvariants();
965211443
....@@ -9660,10 +11451,10 @@
966011451 e.printStackTrace();
966111452 }
966211453
9663
- if (GraphreeD.RENDERME > 0)
9664
- GraphreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
966511456
9666
- ONESTEP = false;
11457
+ Globals.ONESTEP = false;
966711458 }
966811459
966911460 static boolean zoomonce = false;
....@@ -9671,11 +11462,11 @@
967111462 void DrawObject(GL gl, boolean draw)
967211463 {
967311464 //System.out.println("DRAW OBJECT " + mouseDown);
9674
-// drawMode = SELECTION;
11465
+// DrawMode() = SELECTION;
967511466 //GL gl = getGL();
967611467 if ((TRACK || SHADOWTRACK) || zoomonce)
967711468 {
9678
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11469
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
967911470 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968011471 pingthread.StepToTarget(true); // true);
968111472 // zoomonce = false;
....@@ -9696,9 +11487,9 @@
969611487 callist = gl.glGenLists(1);
969711488 }
969811489
9699
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11490
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970011491
9701
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11492
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970211493
970311494 if (!mainDL || !active || touched)
970411495 {
....@@ -9725,21 +11516,28 @@
972511516 PushMatrix(ClickInfo.matbuffer);
972611517 }
972711518
9728
- if (drawMode == 0)
11519
+ if (DrawMode() == 0)
972911520 {
973011521 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973111522
973211523 usedtextures.clear();
973311524
9734
- 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
+ }
973511533 }
973611534 //System.out.println("--> " + stackdepth);
9737
-// GraphreeD.traceon();
11535
+// GrafreeD.traceon();
973811536
973911537 // DRAW
974011538 object.draw(this, /*(Composite)*/ object, false, false);
974111539
9742
- if (drawMode == DEFAULT)
11540
+ if (DrawMode() == DEFAULT)
974311541 {
974411542 if (DEBUG)
974511543 {
....@@ -9750,34 +11548,48 @@
975011548 selectedpoint.radius = radius;
975111549 selectedpoint.recalculate();
975211550 selectedpoint.material = new cMaterial();
9753
- selectedpoint.material.color = 0.25f;
11551
+ selectedpoint.material.color = 0.15f; // Yellow
975411552 selectedpoint.material.modulation = 0.75f;
975511553
9756
- debugpoint.radius = radius;
9757
- debugpoint.recalculate();
9758
- debugpoint.material = new cMaterial();
9759
- debugpoint.material.color = 0.25f;
9760
- debugpoint.material.modulation = 0.75f;
11554
+ debugpointG.radius = radius;
11555
+ debugpointG.recalculate();
11556
+ debugpointG.material = new cMaterial();
11557
+ debugpointG.material.color = 0.25f; // Green
11558
+ debugpointG.material.modulation = 0.75f;
976111559
9762
- debugpoint2.radius = radius;
9763
- debugpoint2.recalculate();
9764
- debugpoint2.material = new cMaterial();
9765
- debugpoint2.material.color = 0.75f;
9766
- debugpoint2.material.modulation = 0.75f;
11560
+ debugpointP.radius = radius;
11561
+ debugpointP.recalculate();
11562
+ debugpointP.material = new cMaterial();
11563
+ debugpointP.material.color = 0.75f; // Purple
11564
+ debugpointP.material.modulation = 0.75f;
11565
+
11566
+ debugpointC.radius = radius;
11567
+ debugpointC.recalculate();
11568
+ debugpointC.material = new cMaterial();
11569
+ debugpointC.material.color = 0.5f; // Cyan
11570
+ debugpointC.material.modulation = 0.75f;
11571
+
11572
+ debugpointR.radius = radius;
11573
+ debugpointR.recalculate();
11574
+ debugpointR.material = new cMaterial();
11575
+ debugpointR.material.color = 0f; // Red
11576
+ debugpointR.material.modulation = 0.75f;
976711577
976811578 InitPoints(radius);
976911579 }
977011580 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9771
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9772
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9773
- DrawPoints(this);
11581
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11582
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11583
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11584
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
11585
+ // DrawPoints(this);
977411586 }
977511587
977611588 // debugstuff.draw(this, /*(Composite)*/ null, false);
977711589 }
9778
-// GraphreeD.traceoff();
11590
+// GrafreeD.traceoff();
977911591 //System.out.println(stackdepth);
9780
- if (drawMode == 0)
11592
+ if (DrawMode() == 0)
978111593 {
978211594 ReleaseTextures(DEFAULT_TEXTURES);
978311595
....@@ -9802,17 +11614,26 @@
980211614
980311615 checker = null;
980411616
9805
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11617
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
980611618 FindChecker(object);
980711619
9808
- if (checker != null && drawMode == DEFAULT)
11620
+ if (checker != null && DrawMode() == DEFAULT)
980911621 {
9810
- // BindTexture(IMMORTAL_TEXTURE);
11622
+ //BindTexture(IMMORTAL_TEXTURE);
11623
+ try
11624
+ {
11625
+ BindTextures(checker.GetTextures(), checker.texres);
11626
+ }
11627
+ catch (Exception e)
11628
+ {
11629
+ System.err.println("FAILED: " + checker.GetTextures());
11630
+ }
981111631 // NEAREST
981211632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
981311633 DrawChecker(gl);
981411634 //checker.Draw(this, null, false);
981511635 // ReleaseTexture(IMMORTAL_TEXTURE);
11636
+ ReleaseTextures(checker.GetTextures());
981611637 }
981711638
981811639 if (object.parent != null)
....@@ -9825,7 +11646,7 @@
982511646 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
982611647 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
982711648
9828
- if (DISPLAYTEXT && drawMode == DEFAULT)
11649
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
982911650 {
983011651 // Draw it once, then use the raster
983111652 Balloon(gl, balloon.createGraphics());
....@@ -9881,14 +11702,14 @@
988111702 int[] xs = new int[3];
988211703 int[] ys = new int[3];
988311704
9884
- void DrawString(Object3D obj) // String string)
11705
+ public void DrawString(Object3D obj) // String string) // INTERFACE
988511706 {
9886
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11707
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
988711708 {
988811709 return;
988911710 }
989011711
9891
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
989211713
989311714 GL gl = GetGL();
989411715
....@@ -10205,8 +12026,8 @@
1020512026 //obj.TransformToWorld(light, light);
1020612027 for (int i = tp.size(); --i >= 0;)
1020712028 {
10208
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
10209
- 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);
1021012031 }
1021112032
1021212033
....@@ -10223,8 +12044,8 @@
1022312044 parentcam = cameras[0];
1022412045 }
1022512046
10226
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10227
- 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
1022812049
1022912050 LA.xformPos(light, renderCamera.toScreen, light);
1023012051
....@@ -10343,11 +12164,13 @@
1034312164 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1034412165 "PARAM params7 = program.env[7];" + // noise power, opacity power
1034512166 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10346
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
12167
+ "PARAM options1 = program.env[62];" + // fog rgb color
12168
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1034712169 "PARAM pointlight = program.env[127];" + // ...
1034812170 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1034912171 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1035012172 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12173
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1035112174 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1035212175 "PARAM ten = { 10, 10, 10, 1.0 };" +
1035312176 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10368,6 +12191,7 @@
1036812191 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1036912192 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1037012193 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
12194
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1037112195 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1037212196 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1037312197 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10408,6 +12232,10 @@
1040812232 "TEMP R1;" +
1040912233 "TEMP R2;" +
1041012234 "TEMP R3;" +
12235
+ "TEMP min;" +
12236
+ "TEMP max;" +
12237
+ "TEMP average;" +
12238
+ "TEMP saturation;" +
1041112239 "TEMP keep1;" +
1041212240 "TEMP keep2;" +
1041312241 "TEMP keep3;" +
....@@ -10831,8 +12659,8 @@
1083112659
1083212660 // display shadow only (bump == 0)
1083312661 "SUB temp.x, half.x, shadow.x;" +
10834
- "MOV temp.y, -params6.x;" +
10835
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1083612664 "SUB temp.y, one.x, temp.z;" +
1083712665 "MUL temp.x, temp.x, temp.y;" +
1083812666 "KIL temp.x;" +
....@@ -10938,10 +12766,42 @@
1093812766
1093912767 // skin?
1094012768 // Saturation for skin
10941
- /**/ // c'est ici
10942
- (Skinshader? "DP3 temp.x, final,one;" +
12769
+ /**/
12770
+ (Skinshader?
12771
+ "DP3 average.x, final,one;" +
12772
+ "MUL average, one3rd.xxxx,average.xxxx;" +
12773
+
12774
+ "MIN min.x, final.x,final.y;" +
12775
+ "MIN min.x, min.x,final.z;" +
12776
+
12777
+ "MAX max.x, final.x,final.y;" +
12778
+ "MAX max.x, max.x,final.z;" +
12779
+ "MOV max, max.xxxx;" +
12780
+
12781
+ "SUB saturation, max, final;" +
12782
+
12783
+ "ADD temp.x, max.x, one10th.x;" +
12784
+ "RCP temp.x, temp.x;" +
12785
+ "MUL temp.x, temp.x, half.x;" +
12786
+ "MUL saturation, saturation, temp.xxxx;" +
12787
+
12788
+ "DP3 ndotl.x, normald, light;" +
12789
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
12790
+
12791
+ "SUB temp.x, one.x, ndotl.x;" +
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
12796
+ "MUL temp.x, temp.x, temp.y;" +
12797
+
12798
+ "MUL saturation, saturation, temp.xxxx;" +
12799
+ "SUB_SAT temp, max, saturation;" +
12800
+/**
12801
+ "DP3 temp.x, final,one;" +
1094312802 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10944
- "SUB temp, final,R2;" +
12803
+ "SUB temp, final, R2;" +
12804
+
1094512805 // using light angle
1094612806 "DP3 ndotl.x, normald,light;" +
1094712807 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10954,7 +12814,6 @@
1095412814 // using light intensity
1095512815 "MOV ndotl.z, R2.x;" +
1095612816 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10957
-
1095812817 // june 2014
1095912818 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1096012819 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10966,6 +12825,7 @@
1096612825 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1096712826
1096812827 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
12828
+/**/
1096912829
1097012830 // "ADD final, R2,temp;" +
1097112831 "MOV final, temp;"
....@@ -11055,7 +12915,7 @@
1105512915 /**/
1105612916 // HDR
1105712917 "MOV temp.z, final.a;" +
11058
- "MUL final, final,options1.w;" +
12918
+ "MUL final, final,options2.x;" +
1105912919 "MOV final.a, temp.z;" +
1106012920 /**/
1106112921
....@@ -11092,10 +12952,17 @@
1109212952 "MOV final.z, zero.x;" +
1109312953 "MOV final.a, one.w;":""
1109412954 ) +
12955
+ /*
1109512956 (NORMALdebug?"MOV final.x, normal.x;" +
1109612957 "MOV final.y, normal.y;" +
1109712958 "MOV final.z, normal.z;" +
1109812959 "MOV final.a, one.w;":""
12960
+ ) +
12961
+ */
12962
+ (NORMALdebug?"SUB final.x, one.x, final.x;" +
12963
+ "SUB final.y, one.x, final.y;" +
12964
+ "SUB final.z, one.x, final.z;" +
12965
+ "MOV final.a, final.a;":""
1109912966 ) +
1110012967 // "MOV final, bumpmap;" +
1110112968 "MOV result.color, final;" +
....@@ -11124,7 +12991,7 @@
1112412991 //once = true;
1112512992 }
1112612993
11127
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1112812995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1112912996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1113012997
....@@ -11241,6 +13108,7 @@
1124113108 String Shadow(String depth, String shadow)
1124213109 {
1124313110 return "MAX temp.x, ndotl.x, one64th.x;" +
13111
+ "MIN temp.x, temp.x, ninetenth.x;" +
1124413112 /**/
1124513113 // Sine
1124613114 "MUL temp.y, temp.x, temp.x;" +
....@@ -11256,12 +13124,16 @@
1125613124
1125713125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1125813126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1125913129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1126013130 "SGE temp.y, temp.x, zero.x;" +
11261
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1126213134 "SUB temp.x, one.x, temp.x;" +
1126313135 "MUL " + shadow + ".x, temp.x, temp.y;" +
11264
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1126513137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1126613138
1126713139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11275,6 +13147,10 @@
1127513147 // No shadow for backface
1127613148 "DP3 temp.x, normal, lightd;" +
1127713149 "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;" +
1127813154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1127913155 "";
1128013156 }
....@@ -11833,7 +13709,7 @@
1183313709 public void mousePressed(MouseEvent e)
1183413710 {
1183513711 //System.out.println("mousePressed: " + e);
11836
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1183713713 }
1183813714
1183913715 static long prevtime = 0;
....@@ -11860,14 +13736,16 @@
1186013736
1186113737 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1186213738
13739
+ if (BUTTONLESSWHEEL)
1186313740 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1186413741 {
1186513742 return;
1186613743 }
1186713744
13745
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1186813746
1186913747 // TIMER
11870
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13748
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1187113749 {
1187213750 keepboxmode = BOXMODE;
1187313751 keepsupport = SUPPORT;
....@@ -11907,8 +13785,8 @@
1190713785 // mode |= META;
1190813786 //}
1190913787
11910
- SetMouseMode(WHEEL | e.getModifiersEx());
11911
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1191213790 anchorX = ax;
1191313791 anchorY = ay;
1191413792 prevX = px;
....@@ -11968,6 +13846,10 @@
1196813846 // wasliveok = true;
1196913847 // waslive = false;
1197013848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1197113853 // source == timer
1197213854 if (mouseDown)
1197313855 {
....@@ -11996,7 +13878,7 @@
1199613878 // ObjEditor.tweenManager.update(1f / 60f);
1199713879
1199813880 // fev 2014???
11999
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13881
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1200013882 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1200113883 pingthread.StepToTarget(true); // true);
1200213884 }
....@@ -12006,7 +13888,7 @@
1200613888
1200713889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1200813890
12009
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1201013892 {
1201113893 if (!wasliveok)
1201213894 return;
....@@ -12023,7 +13905,7 @@
1202313905 // touched = true; // main DL
1202413906 if (isRenderer)
1202513907 {
12026
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1202713909 }
1202813910
1202913911 selectX = anchorX = x;
....@@ -12036,7 +13918,7 @@
1203613918 clicked = true;
1203713919 hold = false;
1203813920
12039
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1204013922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1204113923 {
1204213924 // System.out.println("RESTART II " + modifiers);
....@@ -12067,7 +13949,7 @@
1206713949 info.camera = renderCamera;
1206813950 info.x = x;
1206913951 info.y = y;
12070
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1207113953 editObj = object.doEditClick(info, 0);
1207213954 if (!editObj)
1207313955 {
....@@ -12084,11 +13966,14 @@
1208413966
1208513967 public void mouseDragged(MouseEvent e)
1208613968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
13971
+ //System.out.println("mouseDragged: " + e);
1208713972 if (isRenderer)
1208813973 movingcamera = true;
13974
+
1208913975 //if (drawing)
1209013976 //return;
12091
- //System.out.println("mouseDragged: " + e);
1209213977 if ((e.getModifiersEx() & CTRL) != 0
1209313978 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1209413979 {
....@@ -12096,7 +13981,7 @@
1209613981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1209713982 }
1209813983 else
12099
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1210013985
1210113986 //try { Thread.sleep(1); } catch (Exception ex) {}
1210213987 }
....@@ -12108,6 +13993,11 @@
1210813993 cVector tmp = new cVector();
1210913994 cVector tmp2 = new cVector();
1211013995 boolean isMoving;
13996
+
13997
+ public cVector TargetLookAt()
13998
+ {
13999
+ return targetLookAt;
14000
+ }
1211114001
1211214002 class PingThread extends Thread
1211314003 {
....@@ -12247,7 +14137,7 @@
1224714137 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1224814138 if (lightMode)
1224914139 {
12250
- lighttouched = true;
14140
+ Globals.lighttouched = true;
1225114141 }
1225214142
1225314143 if (OEILONCE && OEIL)
....@@ -12264,6 +14154,7 @@
1226414154
1226514155 public void run()
1226614156 {
14157
+ new Exception().printStackTrace();
1226714158 System.exit(0);
1226814159 for (;;)
1226914160 {
....@@ -12305,7 +14196,7 @@
1230514196 mouseDown = false;
1230614197 if (lightMode)
1230714198 {
12308
- lighttouched = true;
14199
+ Globals.lighttouched = true;
1230914200 }
1231014201 repaint();
1231114202 alreadypainted = true;
....@@ -12313,7 +14204,7 @@
1231314204 isMoving = false;
1231414205 } //??
1231514206
12316
- if (isLIVE() && !alreadypainted)
14207
+ if (Globals.isLIVE() && !alreadypainted)
1231714208 {
1231814209 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1231914210 repaint();
....@@ -12325,9 +14216,9 @@
1232514216 {
1232614217 if (lightMode)
1232714218 {
12328
- lighttouched = true;
14219
+ Globals.lighttouched = true;
1232914220 }
12330
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1233114222 }
1233214223 //else
1233314224 }
....@@ -12427,7 +14318,7 @@
1242714318 int X, Y;
1242814319 boolean SX, SY;
1242914320
12430
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1243114322 {
1243214323 if (IsFrozen())
1243314324 {
....@@ -12436,17 +14327,17 @@
1243614327
1243714328 drag = true; // NEW
1243814329
12439
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1244014331
1244114332 X = x;
1244214333 Y = y;
1244314334 // floating state for animation
12444
- MODIFIERS = modifiers;
12445
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1244614337 if (false) // modifiers != 0)
1244714338 {
1244814339 //new Exception().printStackTrace();
12449
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1245014341 System.out.println("SHIFT = " + SHIFT);
1245114342 System.out.println("CONTROL = " + COMMAND);
1245214343 System.out.println("META = " + META);
....@@ -12466,7 +14357,7 @@
1246614357 info.camera = renderCamera;
1246714358 info.x = x;
1246814359 info.y = y;
12469
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1247014361 } else
1247114362 {
1247214363 if (x < startX)
....@@ -12568,6 +14459,7 @@
1256814459 {
1256914460 manipCamera.Translate(dx, dy, getWidth());
1257014461 }
14462
+ else
1257114463 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1257214464 {
1257314465 manipCamera.RotateInterest(dx, dy);
....@@ -12578,7 +14470,7 @@
1257814470
1257914471 if (manipCamera == lightCamera)
1258014472 {
12581
- lighttouched = true;
14473
+ Globals.lighttouched = true;
1258214474 }
1258314475 /*
1258414476 switch (mode)
....@@ -12617,7 +14509,6 @@
1261714509 public void mouseMoved(MouseEvent e)
1261814510 {
1261914511 //System.out.println("mouseMoved: " + e);
12620
-
1262114512 if (isRenderer)
1262214513 return;
1262314514
....@@ -12642,7 +14533,10 @@
1264214533
1264314534 public void mouseReleased(MouseEvent e)
1264414535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1264514538 movingcamera = false;
14539
+ X = Y = 0;
1264614540 //System.out.println("mouseReleased: " + e);
1264714541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1264814542 }
....@@ -12665,9 +14559,9 @@
1266514559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1266614560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1266714561
12668
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1266914563 timeout = true;
12670
- else
14564
+// ?? May 2019 else
1267114565 // timer.setDelay((modifiers & 128) != 0?0:350);
1267214566 mouseDown = false;
1267314567 if (!control && !command) // june 2013
....@@ -12777,7 +14671,7 @@
1277714671 System.out.println("keyReleased: " + e);
1277814672 }
1277914673
12780
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1278114675 {
1278214676 //System.out.println("SetMouseMode = " + modifiers);
1278314677 //modifiers &= ~1024;
....@@ -12789,24 +14683,27 @@
1278914683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1279014684 // return;
1279114685 //System.out.println("SetMode = " + modifiers);
12792
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1279314687 {
1279414688 mouseMode |= ZOOM;
1279514689 }
12796
- if ((modifiers & META) == META)
14690
+
14691
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14692
+ if (capsLocked) // || (modifiers & META) == META)
1279714693 {
1279814694 mouseMode |= VR; // BACKFORTH;
1279914695 }
12800
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
12801
- {
12802
- mouseMode |= SELECT; // BACKFORTH;
12803
- }
12804
- if ((modifiers & COMMAND) == COMMAND)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1280514697 {
1280614698 mouseMode |= SELECT;
1280714699 }
12808
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1280914701 {
14702
+ mouseMode |= SELECT;
14703
+ }
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
14705
+ {
14706
+ mouseMode &= ~VR;
1281014707 mouseMode |= TRANSLATE;
1281114708 }
1281214709 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12833,10 +14730,10 @@
1283314730
1283414731 if (isRenderer) //
1283514732 {
12836
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1283714734 }
1283814735
12839
- theRenderer.keyPressed(key);
14736
+ Globals.theRenderer.keyPressed(key);
1284014737 }
1284114738
1284214739 int kompactbit = 4; // power bit
....@@ -12848,7 +14745,7 @@
1284814745 float SATPOW = 1; // 2; // 0.5f;
1284914746 float BRIPOW = 1; // 0.5f; // 0.5f;
1285014747
12851
- void keyPressed(int key)
14748
+ public void keyPressed(int key)
1285214749 {
1285314750 if (key >= '0' && key <= '5')
1285414751 clampbit = (key-'0');
....@@ -12963,7 +14860,7 @@
1296314860 case 'B':
1296414861 BRISMOOTH ^= true;
1296514862 SHADOWCULLFACE ^= true;
12966
- lighttouched = true;
14863
+ Globals.lighttouched = true;
1296714864 repaint();
1296814865 break;
1296914866 case 'b':
....@@ -13063,7 +14960,7 @@
1306314960 repaint();
1306414961 break;
1306514962 case 'O':
13066
- drawMode = OCCLUSION;
14963
+ Globals.drawMode = OCCLUSION; // WARNING
1306714964 repaint();
1306814965 break;
1306914966 case 'o':
....@@ -13154,7 +15051,7 @@
1315415051 break;
1315515052 case ' ':
1315615053 lightMode ^= true;
13157
- lighttouched = true;
15054
+ Globals.lighttouched = true;
1315815055 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1315915056 targetLookAt.set(manipCamera.lookAt);
1316015057 repaint();
....@@ -13166,11 +15063,11 @@
1316615063 repaint();
1316715064 break;
1316815065 case 'Z':
13169
- RESIZETEXTURE ^= true;
13170
- break;
15066
+ //RESIZETEXTURE ^= true;
15067
+ //break;
1317115068 case 'z':
13172
- RENDERSHADOW ^= true;
13173
- lighttouched = true;
15069
+ Globals.RENDERSHADOW ^= true;
15070
+ Globals.lighttouched = true;
1317415071 repaint();
1317515072 break;
1317615073 //case UP:
....@@ -13196,7 +15093,8 @@
1319615093 FlipTransform();
1319715094 break;
1319815095 case ENTER:
13199
- object.editWindow.ScreenFit(); // Edit();
15096
+ // object.editWindow.ScreenFit(); // Edit();
15097
+ ToggleLive();
1320015098 break;
1320115099 case DELETE:
1320215100 ClearSelection();
....@@ -13284,6 +15182,7 @@
1328415182 }
1328515183 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1328615184 }
15185
+
1328715186 static double OCCLUSIONBOOST = 1; // 0.5;
1328815187
1328915188 void keyReleased(int key, int modifiers)
....@@ -13291,11 +15190,11 @@
1329115190 //mode = ROTATE;
1329215191 if ((MODIFIERS & COMMAND) == 0) // VR??
1329315192 {
13294
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1329515194 }
1329615195 }
1329715196
13298
- protected void processKeyEvent(KeyEvent e)
15197
+ public void processKeyEvent(KeyEvent e)
1329915198 {
1330015199 switch (e.getID())
1330115200 {
....@@ -13425,8 +15324,9 @@
1342515324
1342615325 protected void processMouseMotionEvent(MouseEvent e)
1342715326 {
13428
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13429
- 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)
1343015330 {
1343115331 mouseMoved(e);
1343215332 } else
....@@ -13456,6 +15356,7 @@
1345615356
1345715357 void SelectParent()
1345815358 {
15359
+ new Exception().printStackTrace();
1345915360 System.exit(0);
1346015361 Composite group = (Composite) object;
1346115362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13479,6 +15380,7 @@
1347915380
1348015381 void SelectChildren()
1348115382 {
15383
+ new Exception().printStackTrace();
1348215384 System.exit(0);
1348315385 /*
1348415386 Composite group = (Composite) object;
....@@ -13643,7 +15545,9 @@
1364315545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1364415546 //Image img = CreateImage(width, height);
1364515547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1364615549 Graphics gr = g; // img.getGraphics();
15550
+
1364715551 if (!hasMarquee)
1364815552 {
1364915553 if (Xmin < Xmax) // !locked)
....@@ -13741,14 +15645,33 @@
1374115645 if (!isRenderer)
1374215646 {
1374315647 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
+ }
1374415665 }
1374515666 }
15667
+
1374615668 if (isRenderer)
1374715669 {
1374815670 //gr.setColor(Color.black);
1374915671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1375015672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1375115673 }
15674
+
1375215675 if (hasMarquee)
1375315676 {
1375415677 gr.setXORMode(Color.white);
....@@ -13771,6 +15694,7 @@
1377115694 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1377215695 }
1377315696
15697
+ // To avoid clear.
1377415698 public void update(Graphics g)
1377515699 {
1377615700 paint(g);
....@@ -13860,6 +15784,7 @@
1386015784 public boolean mouseDown(Event evt, int x, int y)
1386115785 {
1386215786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1386315788 /*
1386415789 locked = true;
1386515790 drag = false;
....@@ -13903,7 +15828,7 @@
1390315828 {
1390415829 keyPressed(0, modifiers);
1390515830 }
13906
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1390715832 return true;
1390815833 }
1390915834
....@@ -14021,7 +15946,7 @@
1402115946 {
1402215947 keyReleased(0, 0);
1402315948 }
14024
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1402515950 return true;
1402615951 }
1402715952
....@@ -14153,7 +16078,7 @@
1415316078 Object3D object;
1415416079 static Object3D trackedobject;
1415516080 Camera renderCamera; // Light or Eye (or Occlusion)
14156
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1415716082 /*static*/ Camera eyeCamera;
1415816083 /*static*/ Camera lightCamera;
1415916084 int cameracount;
....@@ -14373,7 +16298,7 @@
1437316298 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1437416299 gl.glPushMatrix();
1437516300 gl.glLoadIdentity();
14376
- PushMatrix(checker.toParent);
16301
+ //PushMatrix(checker.toParent);
1437716302
1437816303 gl.glMatrixMode(GL.GL_TEXTURE);
1437916304 gl.glPushMatrix();
....@@ -14396,8 +16321,8 @@
1439616321
1439716322 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1439816323
14399
- float step = 0.1666f; //0.25f;
14400
- float stepv = step * 1652 / 998;
16324
+ float step = 2; // 0.1666f; //0.25f;
16325
+ float stepv = 2; // step * 1652 / 998;
1440116326
1440216327 int i0 = 0;
1440316328 /*
....@@ -14433,20 +16358,21 @@
1443316358 /**/
1443416359 //checker.GetMaterial().opacity = 1.1f;
1443516360 ////checker.GetMaterial().ambient = 0.99f;
14436
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14437
- Object3D.selectedstack[Object3D.materialdepth] = false;
14438
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16361
+ materialstack[materialdepth] = checker.material;
16362
+ selectedstack[materialdepth] = false;
16363
+ cStatic.objectstack[materialdepth++] = checker;
1443916364 //System.out.println("material " + material);
1444016365 //Applet3D.tracein(this, selected);
1444116366 vector2buffer = checker.projectedVertices;
1444216367
14443
- checker.GetMaterial().Draw(this, false); // true);
16368
+ //checker.GetMaterial().Draw(this, false); // true);
16369
+ DrawMaterial(checker.GetMaterial(), false); // true);
1444416370
14445
- Object3D.materialdepth -= 1;
14446
- if (Object3D.materialdepth > 0)
16371
+ materialdepth -= 1;
16372
+ if (materialdepth > 0)
1444716373 {
14448
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14449
- 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]);
1445016376 }
1445116377 //checker.GetMaterial().opacity = 1f;
1445216378 ////checker.GetMaterial().ambient = 1f;
....@@ -14467,15 +16393,27 @@
1446716393
1446816394 //float u = (i+1)/2;
1446916395 //float v = (j+1)/2;
14470
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
16396
+ if (checker.flipV)
16397
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
16398
+ else
16399
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1447116400 gl.glVertex3f(i, j, -0.5f);
1447216401
16402
+ if (checker.flipV)
16403
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
16404
+ else
1447316405 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1447416406 gl.glVertex3f(i + step, j, -0.5f);
1447516407
16408
+ if (checker.flipV)
16409
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
16410
+ else
1447616411 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1447716412 gl.glVertex3f(i + step, j + stepv, -0.5f);
1447816413
16414
+ if (checker.flipV)
16415
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
16416
+ else
1447916417 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1448016418 gl.glVertex3f(i, j + stepv, -0.5f);
1448116419 }
....@@ -14487,7 +16425,7 @@
1448716425 gl.glMatrixMode(GL.GL_PROJECTION);
1448816426 gl.glPopMatrix();
1448916427 gl.glMatrixMode(GL.GL_MODELVIEW);
14490
- PopMatrix(null); // checker.toParent); // null);
16428
+ //PopMatrix(null); // checker.toParent); // null);
1449116429 gl.glPopMatrix();
1449216430 PopTextureMatrix(checker.toParent);
1449316431 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14578,6 +16516,7 @@
1457816516 {
1457916517 if (!selection)
1458016518 {
16519
+ new Exception().printStackTrace();
1458116520 System.exit(0);
1458216521 return;
1458316522 }
....@@ -14600,14 +16539,14 @@
1460016539
1460116540 //int tmp = selection_view;
1460216541 //selection_view = -1;
14603
- int temp = drawMode;
14604
- drawMode = SELECTION;
16542
+ int temp = DrawMode();
16543
+ Globals.drawMode = SELECTION; // WARNING
1460516544 indexcount = 0;
1460616545 parent.display(drawable);
1460716546 //selection_view = tmp;
1460816547 //if (temp == SELECTION)
1460916548 // temp = DEFAULT; // patch for selection debug
14610
- drawMode = temp;
16549
+ Globals.drawMode = temp; // WARNING
1461116550
1461216551 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1461316552
....@@ -14657,6 +16596,11 @@
1465716596 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1465816597 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1465916598
16599
+ // Will fit the mesh !!!
16600
+ selectedpoint.toParent[0][0] = 0.0001;
16601
+ selectedpoint.toParent[1][1] = 0.0001;
16602
+ selectedpoint.toParent[2][2] = 0.0001;
16603
+
1466016604 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1466116605
1466216606 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14700,16 +16644,16 @@
1470016644 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]));
1470116645 }
1470216646
14703
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1470416648 }
1470516649 }
1470616650
1470716651 if (!movingcamera && !PAINTMODE)
1470816652 object.editWindow.ScreenFitPoint(); // fev 2014
1470916653
14710
- if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16654
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1471116655 {
14712
- Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16656
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1471316657
1471416658 Object3D group = new Object3D("inst" + paintcount++);
1471516659
....@@ -14865,7 +16809,7 @@
1486516809 gl.glDisable(gl.GL_CULL_FACE);
1486616810 }
1486716811
14868
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1486916813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1487016814
1487116815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14875,14 +16819,14 @@
1487516819 //gl.glColorMask(false, false, false, false);
1487616820
1487716821 //render_scene_from_light_view(gl, drawable, 0, 0);
14878
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1487916823 {
1488016824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1488116825
14882
- int temp = drawMode;
14883
- drawMode = SHADOW;
16826
+ int temp = DrawMode();
16827
+ Globals.drawMode = SHADOW; // WARNING
1488416828 parent.display(drawable);
14885
- drawMode = temp;
16829
+ Globals.drawMode = temp; // WARNING
1488616830 }
1488716831
1488816832 gl.glCullFace(gl.GL_BACK);
....@@ -14935,7 +16879,6 @@
1493516879
1493616880 class AntialiasBuffer implements GLEventListener
1493716881 {
14938
-
1493916882 CameraPane parent = null;
1494016883
1494116884 AntialiasBuffer(CameraPane p)
....@@ -15045,13 +16988,19 @@
1504516988 gl.glFlush();
1504616989
1504716990 /**/
15048
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16991
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1504916992
15050
- int[] pixels = occlusionsizebuffer.array();
16993
+ float[] pixels = occlusionsizebuffer.array();
1505116994
1505216995 double r = 0, g = 0, b = 0;
1505316996
1505416997 double count = 0;
16998
+
16999
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
17000
+
17001
+ float mindepth = 1;
17002
+
17003
+ double FACTOR = 1;
1505517004
1505617005 for (int i = 0; i < pixels.length; i++)
1505717006 {
....@@ -15136,7 +17085,7 @@
1513617085
1513717086 double scale = ray.z; // 1; // cos
1513817087
15139
- int p = pixels[newindex];
17088
+ float depth = pixels[newindex];
1514017089
1514117090 /*
1514217091 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15160,10 +17109,23 @@
1516017109 scale = (1 - modu) * modv;
1516117110 */
1516217111
15163
- r += ((p >> 16) & 0xFF) * scale / 255;
15164
- g += ((p >> 8) & 0xFF) * scale / 255;
15165
- b += (p & 0xFF) * scale / 255;
17112
+ //r += ((p >> 16) & 0xFF) * scale / 255;
17113
+ //g += ((p >> 8) & 0xFF) * scale / 255;
17114
+ //b += (p & 0xFF) * scale / 255;
17115
+
17116
+ if (mindepth > depth)
17117
+ {
17118
+ mindepth = depth;
17119
+ }
1516617120
17121
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
17122
+
17123
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
17124
+
17125
+ r += factor * scale;
17126
+ g += factor * scale;
17127
+ b += factor * scale;
17128
+
1516717129 count += scale;
1516817130 }
1516917131
....@@ -15261,12 +17223,6 @@
1526117223 GLUT glut = new GLUT();
1526217224
1526317225
15264
- static final public int DEFAULT = 0;
15265
- static final public int SELECTION = 1;
15266
- static final public int SHADOW = 2;
15267
- static final public int OCCLUSION = 3;
15268
- static
15269
- public int drawMode = DEFAULT;
1527017226 public boolean spherical = false;
1527117227 static boolean DEBUG_OCCLUSION = false;
1527217228 static boolean DEBUG_SELECTION = false;
....@@ -15279,10 +17235,12 @@
1527917235 int AAbuffersize = 0;
1528017236
1528117237 //double[] selectedpoint = new double[3];
15282
- static Sphere selectedpoint = new Sphere();
17238
+ static Superellipsoid selectedpoint = new Superellipsoid();
1528317239 static Sphere previousselectedpoint = null;
15284
- static Sphere debugpoint = new Sphere();
15285
- static Sphere debugpoint2 = new Sphere();
17240
+ static Sphere debugpointG = new Sphere();
17241
+ static Sphere debugpointP = new Sphere();
17242
+ static Sphere debugpointC = new Sphere();
17243
+ static Sphere debugpointR = new Sphere();
1528617244
1528717245 static Sphere debugpoints[] = new Sphere[8];
1528817246
....@@ -15313,7 +17271,7 @@
1531317271 }
1531417272 }
1531517273
15316
- static void DrawPoints(CameraPane cpane)
17274
+ static void DrawPoints(iCameraPane cpane)
1531717275 {
1531817276 for (int i=0; i<8; i++) // first and last are red
1531917277 {
....@@ -15335,7 +17293,8 @@
1533517293 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1533617294 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1533717295 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15338
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17296
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17297
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1533917298 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1534017299 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1534117300 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15344,10 +17303,11 @@
1534417303 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1534517304 // Depth buffer format
1534617305 //private int depth_format;
15347
- static public void NextIndex(Object3D o, GL gl)
17306
+
17307
+ public void NextIndex()
1534817308 {
1534917309 indexcount+=16;
15350
- 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);
1535117311 //objects[indexcount] = o;
1535217312 //System.out.println("indexcount = " + indexcount);
1535317313 }