Normand Briere
2019-06-11 98896326eb94666451b7e419becfb5d721840313
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,39 @@
165149 defaultcaps.setAccumBlueBits(16);
166150 defaultcaps.setAccumAlphaBits(16);
167151 }
168
- static CameraPane theRenderer;
169
-
152
+
170153 void SetAsGLRenderer(boolean b)
171154 {
172155 isRenderer = b;
173
- theRenderer = this;
156
+ Globals.theRenderer = this;
157
+ }
158
+
159
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
160
+ {
161
+ super(defaultcaps, null, withcontext?glcontext:null, null);
162
+
163
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
164
+ glcontext = getContext();
165
+
166
+ cameras = new Camera[2];
167
+ targetLookAts = new cVector[2];
168
+
169
+ SetCamera(cam);
170
+
171
+ SetLight(new Camera(new cVector(10, 10, -20)));
172
+
173
+ object = o;
174
+
175
+ setBackground(Color.white);
176
+
177
+ addKeyListener(this);
178
+ addMouseListener(this);
179
+ addMouseMotionListener(this);
180
+ addMouseWheelListener(this);
181
+ //System.out.println("addGLEventListener: " + this);
182
+ addGLEventListener(this);
183
+
184
+// pingthread.start(); // may 2013
174185 }
175186
176187 static boolean AntialiasingEnabled()
....@@ -178,12 +189,53 @@
178189 return CURRENTANTIALIAS > 0;
179190 }
180191
181
- void ClearDepth()
192
+ /// INTERFACE
193
+
194
+ public javax.media.opengl.GL GetGL0()
195
+ {
196
+ return null;
197
+ }
198
+
199
+ public int GenList()
200
+ {
201
+ javax.media.opengl.GL gl = GetGL();
202
+ return gl.glGenLists(1);
203
+ }
204
+
205
+ public void NewList(int id)
206
+ {
207
+ javax.media.opengl.GL gl = GetGL();
208
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
209
+ }
210
+
211
+ public void CallList(int id)
212
+ {
213
+ javax.media.opengl.GL gl = GetGL();
214
+ gl.glCallList(id);
215
+ }
216
+
217
+ public void EndList()
218
+ {
219
+ javax.media.opengl.GL gl = GetGL();
220
+ gl.glEndList();
221
+ }
222
+
223
+ public boolean IsBoxMode()
224
+ {
225
+ return BOXMODE;
226
+ }
227
+
228
+ public boolean IsZoomBoxMode()
229
+ {
230
+ return ZOOMBOXMODE;
231
+ }
232
+
233
+ public void ClearDepth()
182234 {
183235 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184236 }
185237
186
- void DepthTest(boolean depthtest)
238
+ public void DepthTest(boolean depthtest)
187239 {
188240 if (depthtest)
189241 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +243,7 @@
191243 GetGL().glDepthFunc(GL.GL_ALWAYS);
192244 }
193245
194
- void DepthWrite(boolean depthwrite)
246
+ public void DepthWrite(boolean depthwrite)
195247 {
196248 if (depthwrite)
197249 GetGL().glDepthMask(true);
....@@ -199,12 +251,1594 @@
199251 GetGL().glDepthMask(false);
200252 }
201253
202
- void BackFaceCull(boolean bfc)
254
+ public void BackFaceCull(boolean bfc)
203255 {
204256 if (bfc)
205257 GetGL().glEnable(GetGL().GL_CULL_FACE);
206258 else
207259 GetGL().glDisable(GetGL().GL_CULL_FACE);
260
+ }
261
+
262
+ public boolean BackFaceCullMode()
263
+ {
264
+ return this.CULLFACE;
265
+ }
266
+
267
+ public boolean IsAmbientOcclusionOn()
268
+ {
269
+ return this.ambientOcclusion;
270
+ }
271
+
272
+ public boolean IsDebugSelection()
273
+ {
274
+ return DEBUG_SELECTION;
275
+ }
276
+
277
+ public boolean IsFrozen()
278
+ {
279
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
280
+
281
+ return !selectmode && cameracount == 0; // != 0;
282
+ }
283
+
284
+ // Currently in Globals
285
+ public int DrawMode()
286
+ {
287
+ return Globals.DrawMode();
288
+ }
289
+
290
+ public Camera EyeCamera()
291
+ {
292
+ return eyeCamera;
293
+ }
294
+
295
+ public Camera LightCamera()
296
+ {
297
+ return lightCamera;
298
+ }
299
+
300
+ public Camera ManipCamera()
301
+ {
302
+ return manipCamera;
303
+ }
304
+
305
+ public Camera RenderCamera()
306
+ {
307
+ return renderCamera;
308
+ }
309
+
310
+ public Camera[] Cameras()
311
+ {
312
+ return cameras;
313
+ }
314
+
315
+ public void PushMaterial(Object3D obj, boolean selected)
316
+ {
317
+ CameraPane display = this;
318
+ javax.media.opengl.GL gl = display.GetGL();
319
+ cMaterial material = obj.material;
320
+
321
+ if (material != null)
322
+ {
323
+ materialstack[materialdepth] = material;
324
+ selectedstack[materialdepth] = selected;
325
+ cStatic.objectstack[materialdepth++] = obj;
326
+ //System.out.println("material " + material);
327
+ //Applet3D.tracein(this, selected);
328
+ display.vector2buffer = obj.projectedVertices;
329
+ if (obj instanceof Camera)
330
+ {
331
+ display.options1[0] = material.shift;
332
+ //System.out.println("shift " + material.shift);
333
+ display.options1[1] = material.lightarea;
334
+ display.options1[2] = material.shadowbias;
335
+ display.options1[3] = material.aniso;
336
+ display.options1[4] = material.anisoV;
337
+ display.options2[0] = material.opacity;
338
+ display.options2[1] = material.diffuse;
339
+ display.options2[2] = material.factor;
340
+
341
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
342
+ display.options4[0] = material.cameralight/0.2f;
343
+ display.options4[1] = material.subsurface;
344
+ display.options4[2] = material.sheen;
345
+
346
+ // if (display.CURRENTANTIALIAS > 0)
347
+ // display.options3[3] /= 4;
348
+
349
+ /*
350
+ System.out.println("Focus = " + display.options1[0]);
351
+ System.out.println("Aperture = " + display.options1[1]);
352
+ System.out.println("ShadowBlur = " + display.options1[2]);
353
+ System.out.println("Antialiasing = " + display.options1[3]);
354
+ System.out.println("Fog = " + display.options2[0]);
355
+ System.out.println("Intensity = " + display.options2[1]);
356
+ System.out.println("Elevation = " + display.options2[2]);
357
+ /**/
358
+ } else
359
+ {
360
+ DrawMaterial(material, selected);
361
+ }
362
+ } else
363
+ {
364
+ if (selected && CameraPane.flash)
365
+ {
366
+ display.modelParams4[1] = 100;
367
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
368
+ }
369
+ }
370
+ }
371
+
372
+ public void PushMaterial2(Object3D obj, boolean selected)
373
+ {
374
+ CameraPane display = this;
375
+ cMaterial material = obj.material;
376
+
377
+ if (material != null)
378
+ {
379
+ materialstack[materialdepth] = material;
380
+ selectedstack[materialdepth] = selected;
381
+ cStatic.objectstack[materialdepth++] = obj;
382
+ //System.out.println("material " + material);
383
+ //Applet3D.tracein("selected ", selected);
384
+ display.vector2buffer = obj.projectedVertices;
385
+ display.DrawMaterial(material, selected);
386
+ }
387
+ }
388
+
389
+ public void PopMaterial(Object3D obj, boolean selected)
390
+ {
391
+ CameraPane display = this;
392
+ javax.media.opengl.GL gl = display.GetGL();
393
+ cMaterial material = obj.material;
394
+
395
+ //if (parent != null && parent.GetMaterial() != null)
396
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
397
+ if (material != null)
398
+ {
399
+ materialdepth -= 1;
400
+ if (materialdepth > 0)
401
+ {
402
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
404
+ }
405
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
407
+ {
408
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
409
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
410
+ }
411
+ }
412
+
413
+ public void PopMaterial2(Object3D obj)
414
+ {
415
+ CameraPane display = this;
416
+ cMaterial material = obj.material;
417
+
418
+ if (material != null)
419
+ {
420
+ materialdepth -= 1;
421
+ if (materialdepth > 0)
422
+ {
423
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
425
+ }
426
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427
+ //else
428
+ //material.Draw(display, false);
429
+ }
430
+ }
431
+
432
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
433
+ {
434
+ CameraPane display = this;
435
+
436
+ if (pv.y == -10000 ||
437
+ qv.y == -10000 ||
438
+ rv.y == -10000)
439
+ return;
440
+
441
+// float b = f.nbiterations & 1;
442
+// float g = (f.nbiterations>>1) & 1;
443
+// float r = (f.nbiterations>>2) & 1;
444
+//
445
+// //if (f.weight == 10000)
446
+// //{
447
+// // r = 1; g = b = 0;
448
+// //}
449
+// //else
450
+// //{
451
+// // assert(f.weight < 10000);
452
+// r = g = b = (float)bRep.FaceWeight(f)*100;
453
+// if (r<0)
454
+// assert(r>=0);
455
+// //}
456
+
457
+ javax.media.opengl.GL gl = display.GetGL();
458
+
459
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
460
+
461
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
462
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463
+ {
464
+ //gl.glBegin(gl.GL_TRIANGLES);
465
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
466
+ if (!hasnorm)
467
+ {
468
+ // System.out.println("FUCK!!");
469
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
472
+ LA.vecNormalize(obj.v2);
473
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
474
+ }
475
+
476
+ // P
477
+ float x = (float)pv.x;
478
+ float y = (float)pv.y;
479
+ float z = (float)pv.z;
480
+
481
+ if (hasnorm)
482
+ {
483
+// if (!pv.norm.normalized())
484
+// assert(pv.norm.normalized());
485
+
486
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
487
+ float nx = (float)pv.norm.x;
488
+ float ny = (float)pv.norm.y;
489
+ float nz = (float)pv.norm.z;
490
+
491
+ x += nx * obj.NORMALPUSH;
492
+ y += ny * obj.NORMALPUSH;
493
+ z += nz * obj.NORMALPUSH;
494
+
495
+ gl.glNormal3f(nx, ny, nz);
496
+ }
497
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
498
+ SetColor(obj, pv);
499
+ //gl.glColor4f(r, g, b, 1);
500
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
501
+ if (obj.flipV)
502
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
503
+ else
504
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
505
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
506
+
507
+ gl.glVertex3f(x, y, z);
508
+
509
+ // Q
510
+ x = (float)qv.x;
511
+ y = (float)qv.y;
512
+ z = (float)qv.z;
513
+
514
+// Print(pv);
515
+ if (hasnorm)
516
+ {
517
+// assert(qv.norm.normalized());
518
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
519
+ float nx = (float)qv.norm.x;
520
+ float ny = (float)qv.norm.y;
521
+ float nz = (float)qv.norm.z;
522
+
523
+ x += nx * obj.NORMALPUSH;
524
+ y += ny * obj.NORMALPUSH;
525
+ z += nz * obj.NORMALPUSH;
526
+
527
+ gl.glNormal3f(nx, ny, nz);
528
+ }
529
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
530
+ // boolean locked = false;
531
+ // float eps = 0.1f;
532
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
533
+
534
+ // int dot = 0; //*/ (int)f.dot;
535
+
536
+ // if ((dot&1) == 0)
537
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
538
+
539
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
540
+ if (obj.flipV)
541
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
542
+ else
543
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
544
+ // else
545
+ // {
546
+ // locked = true;
547
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
548
+ // }
549
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
550
+ SetColor(obj, qv);
551
+
552
+ gl.glVertex3f(x, y, z);
553
+ //gl.glColor4f(r, g, b, 1);
554
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
555
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
556
+// Print(qv);
557
+
558
+ // R
559
+ x = (float)rv.x;
560
+ y = (float)rv.y;
561
+ z = (float)rv.z;
562
+
563
+ if (hasnorm)
564
+ {
565
+// assert(rv.norm.normalized());
566
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
567
+ float nx = (float)rv.norm.x;
568
+ float ny = (float)rv.norm.y;
569
+ float nz = (float)rv.norm.z;
570
+
571
+ x += nx * obj.NORMALPUSH;
572
+ y += ny * obj.NORMALPUSH;
573
+ z += nz * obj.NORMALPUSH;
574
+
575
+ gl.glNormal3f(nx, ny, nz);
576
+ }
577
+
578
+ // if ((dot&4) == 0)
579
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
580
+
581
+ // if (wrap || !locked && (dot&8) != 0)
582
+ if (obj.flipV)
583
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
584
+ else
585
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
586
+ // else
587
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
588
+
589
+ // f.dot = dot;
590
+
591
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
592
+ SetColor(obj, rv);
593
+ //gl.glColor4f(r, g, b, 1);
594
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
595
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
596
+ gl.glVertex3f(x, y, z);
597
+// Print(rv);
598
+ //gl.glEnd();
599
+ }
600
+ else
601
+ {
602
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
603
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
604
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
605
+
606
+ }
607
+
608
+ if (false) // (attributes & WIREFRAME) != 0)
609
+ {
610
+ gl.glDisable(gl.GL_LIGHTING);
611
+
612
+ gl.glBegin(gl.GL_LINE_LOOP);
613
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
614
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
615
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
616
+ gl.glEnd();
617
+
618
+ gl.glEnable(gl.GL_LIGHTING);
619
+ }
620
+ }
621
+
622
+ /**
623
+ * <code>draw</code> renders a <code>TriMesh</code> object including
624
+ * it's normals, colors, textures and vertices.
625
+ *
626
+ * @see Renderer#draw(TriMesh)
627
+ * @param tris
628
+ * the mesh to render.
629
+ */
630
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
631
+ {
632
+ CameraPane display = this;
633
+
634
+ float r = display.modelParams0[0];
635
+ float g = display.modelParams0[1];
636
+ float b = display.modelParams0[2];
637
+ float opacity = display.modelParams5[1];
638
+
639
+ //final GL gl = GLU.getCurrentGL();
640
+ GL gl = display.GetGL(); // getGL();
641
+
642
+ FloatBuffer vertBuf = geo.vertBuf;
643
+
644
+ int v = vertBuf.capacity();
645
+
646
+ int count = 0;
647
+
648
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
649
+ gl.glEnable(gl.GL_CULL_FACE);
650
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
651
+ for (int i=0; i<v/3; i++)
652
+ {
653
+ int index3 = i*3;
654
+
655
+ if (geo.sizeBuf.get(index3+1) == 0)
656
+ continue;
657
+
658
+ count++;
659
+
660
+ int index4 = i*4;
661
+
662
+ float tx = vertBuf.get(index3);
663
+ float ty = vertBuf.get(index3+1);
664
+ float tz = vertBuf.get(index3+2);
665
+
666
+ // if (tx == 0 && ty == 0 && tz == 0)
667
+ // continue;
668
+
669
+ gl.glMatrixMode(gl.GL_TEXTURE);
670
+ gl.glPushMatrix();
671
+
672
+ float[] texmat = geo.texmat;
673
+ texmat[12] = texmat[13] = texmat[14] = i;
674
+
675
+ gl.glMultMatrixf(texmat, 0);
676
+
677
+ gl.glMatrixMode(gl.GL_MODELVIEW);
678
+ gl.glPushMatrix();
679
+
680
+ gl.glTranslatef(tx,ty,tz);
681
+
682
+ if (rotate)
683
+ gl.glRotatef(i, 0, 1, 0);
684
+
685
+ float size = geo.sizeBuf.get(index3) / 100;
686
+ gl.glScalef(size,size,size);
687
+
688
+ float cr = geo.colorBuf.get(index4);
689
+ float cg = geo.colorBuf.get(index4+1);
690
+ float cb = geo.colorBuf.get(index4+2);
691
+ float ca = geo.colorBuf.get(index4+3);
692
+
693
+ display.modelParams0[0] = r * cr;
694
+ display.modelParams0[1] = g * cg;
695
+ display.modelParams0[2] = b * cb;
696
+
697
+ display.modelParams5[1] = opacity * ca;
698
+
699
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
700
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
701
+
702
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
703
+ RandomNode.globalseed2 = RandomNode.globalseed;
704
+
705
+// gl.glColor4f(cr,cg,cb,ca);
706
+ // gl.glScalef(1024/16,1024/16,1024/16);
707
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
708
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
709
+ //gl.glTranslatef(-tx,-ty,-tz);
710
+ gl.glPopMatrix();
711
+
712
+ gl.glMatrixMode(gl.GL_TEXTURE);
713
+ gl.glPopMatrix();
714
+ }
715
+ // gl.glScalef(1024,1024,1024);
716
+ if (!cf)
717
+ gl.glDisable(gl.GL_CULL_FACE);
718
+
719
+ display.modelParams0[0] = r;
720
+ display.modelParams0[1] = g;
721
+ display.modelParams0[2] = b;
722
+
723
+ display.modelParams5[1] = opacity;
724
+
725
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
726
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
727
+
728
+ gl.glMatrixMode(gl.GL_MODELVIEW);
729
+
730
+// System.err.println("total = " + v/3 + "; displayed = " + count);
731
+ if (true)
732
+ return;
733
+
734
+//// if (!tris.predraw(this))
735
+//// {
736
+//// return;
737
+//// }
738
+//// if (Debug.stats)
739
+//// {
740
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
741
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
742
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
743
+//// }
744
+////
745
+//// if (tris.getDisplayListID() != -1)
746
+//// {
747
+//// renderDisplayList(tris);
748
+//// return;
749
+//// }
750
+////
751
+//// if (!generatingDisplayList)
752
+//// {
753
+//// applyStates(tris.states, tris);
754
+//// }
755
+//// if (Debug.stats)
756
+//// {
757
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
758
+//// }
759
+//// boolean transformed = doTransforms(tris);
760
+//
761
+// int glMode = GL.GL_TRIANGLES;
762
+// switch (getMode())
763
+// {
764
+// case Triangles:
765
+// glMode = GL.GL_TRIANGLES;
766
+// break;
767
+// case Strip:
768
+// glMode = GL.GL_TRIANGLE_STRIP;
769
+// break;
770
+// case Fan:
771
+// glMode = GL.GL_TRIANGLE_FAN;
772
+// break;
773
+// }
774
+//
775
+// if (!predrawGeometry(gl))
776
+// {
777
+// // make sure only the necessary indices are sent through on old
778
+// // cards.
779
+// IntBuffer indices = this.getIndexBuffer();
780
+// if (indices == null)
781
+// {
782
+// logger.severe("missing indices on geometry object: " + this.toString());
783
+// } else
784
+// {
785
+// indices.rewind();
786
+// indices.limit(this.getMaxIndex());
787
+//
788
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
789
+//
790
+// indices.clear();
791
+// }
792
+// } else
793
+// {
794
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
795
+// GL.GL_UNSIGNED_INT, 0);
796
+// }
797
+//
798
+//// postdrawGeometry(tris);
799
+//// if (transformed)
800
+//// {
801
+//// undoTransforms(tris);
802
+//// }
803
+////
804
+//// if (Debug.stats)
805
+//// {
806
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
807
+//// }
808
+//// tris.postdraw(this);
809
+ }
810
+
811
+ static Camera localcamera = new Camera();
812
+ static cVector from = new cVector();
813
+ static cVector to = new cVector();
814
+
815
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
816
+ {
817
+ CameraPane cp = this;
818
+
819
+ Camera keep = cp.RenderCamera();
820
+ cp.renderCamera = localcamera;
821
+
822
+ if (br.trimmed)
823
+ {
824
+ float[] colors = new float[br.positions.length / 3];
825
+
826
+ int i3 = 0;
827
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
828
+ {
829
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
830
+ continue;
831
+
832
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
833
+ to.set(br.positions[i3] + br.normals[i3],
834
+ br.positions[i3 + 1] + br.normals[i3 + 1],
835
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
836
+ LA.xformPos(from, transform, from);
837
+ LA.xformPos(to, transform, to); // RIGID ONLY
838
+ localcamera.setAim(from, to);
839
+
840
+ CameraPane.occlusionbuffer.display();
841
+
842
+ if (CameraPane.DEBUG_OCCLUSION)
843
+ cp.display(); // debug
844
+
845
+ colors[i] = cp.vertexOcclusion.r;
846
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
847
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
848
+
849
+ if ((i % 100) == 0 && i != 0)
850
+ {
851
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
852
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
853
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
854
+ }
855
+ }
856
+
857
+ br.colors = colors;
858
+ }
859
+ else
860
+ {
861
+ for (int i = 0; i < br.VertexCount(); i++)
862
+ {
863
+ Vertex v = br.GetVertex(i);
864
+
865
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
866
+ continue;
867
+
868
+ from.set(v.x, v.y, v.z);
869
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
870
+ LA.xformPos(from, transform, from);
871
+ LA.xformPos(to, transform, to); // RIGID ONLY
872
+ localcamera.setAim(from, to);
873
+
874
+ CameraPane.occlusionbuffer.display();
875
+
876
+ if (CameraPane.DEBUG_OCCLUSION)
877
+ cp.display(); // debug
878
+
879
+ v.AO = cp.vertexOcclusion.r;
880
+
881
+ if ((i % 100) == 0 && i != 0)
882
+ {
883
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
884
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
885
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
886
+ }
887
+ }
888
+ }
889
+
890
+ //System.out.println("done.");
891
+
892
+ cp.renderCamera = keep;
893
+ }
894
+
895
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
896
+ {
897
+ CameraPane display = this;
898
+ pointFlow.CreateHT();
899
+
900
+ float r = display.modelParams0[0];
901
+ float g = display.modelParams0[1];
902
+ float b = display.modelParams0[2];
903
+ float opacity = display.modelParams5[1];
904
+
905
+ //final GL gl = GLU.getCurrentGL();
906
+ GL gl = display.GetGL(); // getGL();
907
+
908
+ int s = pointFlow.points.size();
909
+
910
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
911
+ gl.glEnable(gl.GL_CULL_FACE);
912
+
913
+ for (int i=s; --i>=0;)
914
+ //for (int i=0; i<s; i++)
915
+ {
916
+ cVector v = pointFlow.points.get(i);
917
+
918
+ double mindist = Double.MAX_VALUE;
919
+
920
+ double size = pointFlow.minimumSize;
921
+
922
+ double distancenext = 0;
923
+
924
+ if (i > 0)
925
+ {
926
+ cVector w = pointFlow.points.get(i-1);
927
+
928
+ double dist = w.distance(v);
929
+
930
+ distancenext = dist;
931
+
932
+ if (mindist > dist)
933
+ {
934
+ mindist = dist;
935
+ size = mindist*pointFlow.resizefactor;
936
+ }
937
+ }
938
+
939
+ if (i < s-1)
940
+ {
941
+ cVector w = pointFlow.points.get(i+1);
942
+
943
+ double dist = w.distance(v);
944
+
945
+ if (mindist > dist)
946
+ {
947
+ mindist = dist;
948
+ size = mindist*pointFlow.resizefactor;
949
+ }
950
+ }
951
+
952
+ if (size < pointFlow.minimumSize)
953
+ size = pointFlow.minimumSize;
954
+ if (size > pointFlow.maximumSize)
955
+ size = pointFlow.maximumSize;
956
+
957
+ double tx = v.x;
958
+ double ty = v.y;
959
+ double tz = v.z;
960
+
961
+ // if (tx == 0 && ty == 0 && tz == 0)
962
+ // continue;
963
+
964
+ gl.glMatrixMode(gl.GL_TEXTURE);
965
+ gl.glPushMatrix();
966
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
967
+
968
+ gl.glMultMatrixf(pointFlow.texmat, 0);
969
+
970
+ gl.glMatrixMode(gl.GL_MODELVIEW);
971
+ gl.glPushMatrix();
972
+
973
+ gl.glTranslated(tx,ty,tz);
974
+
975
+ gl.glScaled(size,size,size);
976
+
977
+// float cr = colorBuf.get(index4);
978
+// float cg = colorBuf.get(index4+1);
979
+// float cb = colorBuf.get(index4+2);
980
+// float ca = colorBuf.get(index4+3);
981
+//
982
+// display.modelParams0[0] = r * cr;
983
+// display.modelParams0[1] = g * cg;
984
+// display.modelParams0[2] = b * cb;
985
+//
986
+// display.modelParams5[1] = opacity * ca;
987
+//
988
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
989
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
990
+//
991
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
992
+// RandomNode.globalseed2 = RandomNode.globalseed;
993
+//
994
+//// gl.glColor4f(cr,cg,cb,ca);
995
+// // gl.glScalef(1024/16,1024/16,1024/16);
996
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
997
+
998
+ gl.glPopMatrix();
999
+
1000
+ double step = size/4; //
1001
+
1002
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1003
+ continue;
1004
+
1005
+ int nbsteps = (int)(distancenext/step);
1006
+
1007
+ step = distancenext/nbsteps;
1008
+
1009
+ cVector next = pointFlow.points.get(i-1);
1010
+
1011
+ tmp.set(next);
1012
+ tmp.sub(v);
1013
+ tmp.normalize();
1014
+ tmp.mul(step);
1015
+
1016
+ // calculate next size
1017
+ mindist = Double.MAX_VALUE;
1018
+
1019
+ double nextsize = pointFlow.minimumSize;
1020
+
1021
+ if (i > 1)
1022
+ {
1023
+ cVector w = pointFlow.points.get(i-2);
1024
+
1025
+ double dist = w.distance(next);
1026
+
1027
+ if (mindist > dist)
1028
+ {
1029
+ mindist = dist;
1030
+ nextsize = mindist*pointFlow.resizefactor;
1031
+ }
1032
+ }
1033
+
1034
+ double dist = v.distance(next);
1035
+
1036
+ if (mindist > dist)
1037
+ {
1038
+ mindist = dist;
1039
+ nextsize = mindist*pointFlow.resizefactor;
1040
+ }
1041
+
1042
+ if (nextsize < pointFlow.minimumSize)
1043
+ nextsize = pointFlow.minimumSize;
1044
+ if (nextsize > pointFlow.maximumSize)
1045
+ nextsize = pointFlow.maximumSize;
1046
+ //
1047
+
1048
+ double count = 0;
1049
+
1050
+ while (distancenext > 0.000000001) // step
1051
+ {
1052
+ gl.glPushMatrix();
1053
+
1054
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1055
+
1056
+ double K = count/nbsteps;
1057
+
1058
+ double intersize = K*nextsize + (1-K)*size;
1059
+
1060
+ gl.glScaled(intersize,intersize,intersize);
1061
+
1062
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1063
+
1064
+ count++;
1065
+
1066
+ distancenext -= step;
1067
+
1068
+ gl.glPopMatrix();
1069
+ }
1070
+
1071
+ if (count != nbsteps)
1072
+ assert(count == nbsteps);
1073
+
1074
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1075
+ //gl.glTranslatef(-tx,-ty,-tz);
1076
+
1077
+ gl.glMatrixMode(gl.GL_TEXTURE);
1078
+ gl.glPopMatrix();
1079
+ }
1080
+
1081
+ if (!cf)
1082
+ gl.glDisable(gl.GL_CULL_FACE);
1083
+
1084
+// display.modelParams0[0] = r;
1085
+// display.modelParams0[1] = g;
1086
+// display.modelParams0[2] = b;
1087
+//
1088
+// display.modelParams5[1] = opacity;
1089
+//
1090
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1091
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1092
+
1093
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1094
+ }
1095
+
1096
+ public void DrawBox(cVector min, cVector max)
1097
+ {
1098
+ javax.media.opengl.GL gl = GetGL();
1099
+ gl.glBegin(gl.GL_LINES);
1100
+
1101
+ gl.glVertex3d(min.x, min.y, min.z);
1102
+ gl.glVertex3d(min.x, min.y, max.z);
1103
+ gl.glVertex3d(min.x, min.y, min.z);
1104
+ gl.glVertex3d(min.x, max.y, min.z);
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(max.x, min.y, min.z);
1107
+
1108
+ gl.glVertex3d(max.x, max.y, max.z);
1109
+ gl.glVertex3d(min.x, max.y, max.z);
1110
+ gl.glVertex3d(max.x, max.y, max.z);
1111
+ gl.glVertex3d(max.x, min.y, max.z);
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(max.x, max.y, min.z);
1114
+
1115
+ gl.glEnd();
1116
+ }
1117
+
1118
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1119
+ {
1120
+ int[] strips = bRep.getRawIndices();
1121
+
1122
+ javax.media.opengl.GL gl = GetGL();
1123
+
1124
+ // TRIANGLE STRIP ARRAY
1125
+ if (bRep.trimmed)
1126
+ {
1127
+ float[] v = bRep.getRawVertices();
1128
+ float[] n = bRep.getRawNormals();
1129
+ float[] c = bRep.getRawColors();
1130
+ float[] uv = bRep.getRawUVMap();
1131
+
1132
+ int count2 = 0;
1133
+ int count3 = 0;
1134
+
1135
+ if (n.length > 0)
1136
+ {
1137
+ for (int i = 0; i < strips.length; i++)
1138
+ {
1139
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1140
+
1141
+ /*
1142
+ boolean locked = false;
1143
+ float eps = 0.1f;
1144
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1145
+
1146
+ int dot = 0;
1147
+
1148
+ if ((dot&1) == 0)
1149
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1150
+
1151
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1152
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1153
+ else
1154
+ {
1155
+ locked = true;
1156
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1157
+ }
1158
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1159
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1160
+ if (hasnorm)
1161
+ {
1162
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1163
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1164
+ }
1165
+
1166
+ if ((dot&4) == 0)
1167
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1168
+
1169
+ if (wrap || !locked && (dot&8) != 0)
1170
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1171
+ else
1172
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1173
+
1174
+ f.dot = dot;
1175
+ */
1176
+
1177
+ if (!selectmode)
1178
+ {
1179
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1180
+ {
1181
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1182
+ } else
1183
+ {
1184
+ gl.glNormal3f(0, 0, 1);
1185
+ }
1186
+
1187
+ if (c != null)
1188
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1189
+ {
1190
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1191
+ }
1192
+ }
1193
+ if (flipV)
1194
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1195
+ else
1196
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1197
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1198
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1199
+
1200
+ count2 += 2;
1201
+ count3 += 3;
1202
+ if (!selectmode)
1203
+ {
1204
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1205
+ {
1206
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1207
+ } else
1208
+ {
1209
+ gl.glNormal3f(0, 0, 1);
1210
+ }
1211
+ if (c != null)
1212
+ {
1213
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1214
+ }
1215
+ }
1216
+ if (flipV)
1217
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1218
+ else
1219
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1220
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1221
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1222
+
1223
+ count2 += 2;
1224
+ count3 += 3;
1225
+ for (int j = 0; j < strips[i] - 2; j++)
1226
+ {
1227
+ //gl.glTexCoord2d(...);
1228
+ if (!selectmode)
1229
+ {
1230
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1231
+ {
1232
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1233
+ } else
1234
+ {
1235
+ gl.glNormal3f(0, 0, 1);
1236
+ }
1237
+ if (c != null)
1238
+ {
1239
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1240
+ }
1241
+ }
1242
+
1243
+ if (flipV)
1244
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1245
+ else
1246
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1247
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1248
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1249
+ count2 += 2;
1250
+ count3 += 3;
1251
+ }
1252
+
1253
+ gl.glEnd();
1254
+ }
1255
+ }
1256
+
1257
+ assert count3 == v.length;
1258
+ }
1259
+ else // !trimmed
1260
+ {
1261
+ int count = 0;
1262
+ for (int i = 0; i < strips.length; i++)
1263
+ {
1264
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1265
+
1266
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1267
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1268
+
1269
+ drawVertex(gl, p, flipV, selectmode);
1270
+ drawVertex(gl, q, flipV, selectmode);
1271
+
1272
+ for (int j = 0; j < strips[i] - 2; j++)
1273
+ {
1274
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1275
+
1276
+ // if (j%2 == 0)
1277
+ // drawFace(p, q, r, display, null);
1278
+ // else
1279
+ // drawFace(p, r, q, display, null);
1280
+
1281
+ // p = q;
1282
+ // q = r;
1283
+ drawVertex(gl, r, flipV, selectmode);
1284
+ }
1285
+
1286
+ gl.glEnd();
1287
+ }
1288
+ }
1289
+ }
1290
+
1291
+ static cSpring.Point3D temp = new cSpring.Point3D();
1292
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1293
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1294
+
1295
+ public void DrawDynamicMesh(cMesh mesh)
1296
+ {
1297
+ GL gl = GetGL(); // getGL();
1298
+
1299
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1300
+
1301
+ gl.glDisable(gl.GL_LIGHTING);
1302
+
1303
+ gl.glLineWidth(1);
1304
+ gl.glColor3f(1,1,1);
1305
+ gl.glBegin(gl.GL_LINES);
1306
+ double scale = 0;
1307
+ int count = 0;
1308
+ for (int s=0; s<Phys.allSprings.size(); s++)
1309
+ {
1310
+ cSpring.Spring spring = Phys.allSprings.get(s);
1311
+ if(s == 0)
1312
+ {
1313
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1314
+ }
1315
+ if (mesh.showsprings)
1316
+ {
1317
+ temp.set(spring.a.position);
1318
+ temp.add(spring.b.position);
1319
+ temp.mul(0.5);
1320
+ temp2.set(spring.a.position);
1321
+ temp2.sub(spring.b.position);
1322
+ temp2.mul(spring.restLength/2);
1323
+ temp.sub(temp2);
1324
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1325
+ temp.add(temp2);
1326
+ temp.add(temp2);
1327
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1328
+ }
1329
+
1330
+ if (spring.isHandle)
1331
+ continue;
1332
+
1333
+ //if (scale < spring.restLength)
1334
+ scale += spring.restLength;
1335
+ count++;
1336
+ }
1337
+ gl.glEnd();
1338
+
1339
+ if (count == 0)
1340
+ scale = 0.01;
1341
+ else
1342
+ scale /= count * 3;
1343
+
1344
+ //scale = 0.25;
1345
+
1346
+ if (mesh.ShowInfo())
1347
+ {
1348
+ gl.glLineWidth(4);
1349
+ for (int s=0; s<Phys.allNodes.size(); s++)
1350
+ {
1351
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1352
+ if (node.mass == 0)
1353
+ continue;
1354
+
1355
+ int i = node.springs==null?-1:node.springs.size();
1356
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1357
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1358
+ //temp.normalize();
1359
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1360
+ gl.glBegin(gl.GL_LINES);
1361
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1362
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1363
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1364
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1365
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1366
+ gl.glEnd();
1367
+ }
1368
+
1369
+ gl.glLineWidth(8);
1370
+ for (int s=0; s<Phys.allNodes.size(); s++)
1371
+ {
1372
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1373
+
1374
+ if (node.springs != null)
1375
+ {
1376
+ for (int i=0; i<node.springs.size(); i+=1)
1377
+ {
1378
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1379
+
1380
+ int c = i+1;
1381
+ // c = node.springs.get(i).nbcopies;
1382
+
1383
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1384
+ gl.glBegin(gl.GL_LINES);
1385
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1386
+ 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);
1387
+ gl.glEnd();
1388
+ }
1389
+ }
1390
+ }
1391
+
1392
+ gl.glLineWidth(1);
1393
+ }
1394
+
1395
+ gl.glEnable(gl.GL_LIGHTING);
1396
+ }
1397
+
1398
+ /// INTERFACE
1399
+
1400
+ public void StartTriangles()
1401
+ {
1402
+ javax.media.opengl.GL gl = GetGL();
1403
+ gl.glBegin(gl.GL_TRIANGLES);
1404
+ }
1405
+
1406
+ public void EndTriangles()
1407
+ {
1408
+ GetGL().glEnd();
1409
+ }
1410
+
1411
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1412
+ {
1413
+ if (!selectmode)
1414
+ {
1415
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1416
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1417
+
1418
+ if (flipV)
1419
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1420
+ else
1421
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1422
+ }
1423
+
1424
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1425
+ }
1426
+
1427
+ void SetColor(Object3D obj, Vertex p0)
1428
+ {
1429
+ CameraPane display = this;
1430
+ BoundaryRep bRep = obj.bRep;
1431
+
1432
+ if (RENDERPROGRAM == 0)
1433
+ {
1434
+ float r = 0;
1435
+ if (bRep != null)
1436
+ {
1437
+ if (bRep.stripified)
1438
+ {
1439
+ r = 1;
1440
+ }
1441
+ }
1442
+ float g = 0;
1443
+ if (bRep != null)
1444
+ {
1445
+ if (bRep.trimmed)
1446
+ {
1447
+ g = 1;
1448
+ }
1449
+ }
1450
+ float b = 0;
1451
+ if (obj.support != null && obj.link2master)
1452
+ {
1453
+ b = 1;
1454
+ }
1455
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1456
+ return;
1457
+ }
1458
+
1459
+ if (display.DrawMode() != CameraPane.SHADOW)
1460
+ return;
1461
+
1462
+ javax.media.opengl.GL gl = display.GetGL();
1463
+// if (true) return;
1464
+// float ao = p.AO;
1465
+//
1466
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1467
+// // ao = 1;
1468
+//
1469
+// gl.glColor4f(ao, ao, ao, 1);
1470
+
1471
+// CameraPane.selectedpoint.
1472
+// getAverage(cStatic.point1, true);
1473
+ if (CameraPane.pointflow == null) // !random) // live)
1474
+ {
1475
+ return;
1476
+ }
1477
+
1478
+ cStatic.point1.set(0,0,0);
1479
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1480
+
1481
+ cStatic.point1.sub(p0);
1482
+
1483
+
1484
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1485
+// {
1486
+// return;
1487
+// }
1488
+
1489
+ //if (true)
1490
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1491
+ {
1492
+ return;
1493
+ }
1494
+
1495
+ float[] colorV = new float[3];
1496
+
1497
+ if (false) // marked)
1498
+ {
1499
+ // debug rigging weights
1500
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1501
+ {
1502
+ float weight = p0.weights[object] / p0.totalweight;
1503
+
1504
+ // if (weight < 0.1)
1505
+ // {
1506
+ // assert(weight == 0);
1507
+ // continue;
1508
+ // }
1509
+
1510
+ if (p0.vertexlinks[object] == -1)
1511
+ continue;
1512
+
1513
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1514
+
1515
+ int color = //1 << object; //
1516
+ //p.vertexlinks.length;
1517
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1518
+ colorV[2] += (color & 1) * weight;
1519
+ colorV[1] += ((color & 2) >> 1) * weight;
1520
+ colorV[0] += ((color & 4) >> 2) * weight;
1521
+ }
1522
+ }
1523
+ else
1524
+ {
1525
+ if (obj.drawingstarted)
1526
+ {
1527
+ // find next point
1528
+ if (bRep.GetVertex(0).faceindices == null)
1529
+ {
1530
+ bRep.InitFaceIndices();
1531
+ }
1532
+
1533
+ double ymin = p0.y;
1534
+
1535
+ Vertex newp = p0;
1536
+
1537
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1538
+ {
1539
+ int fi = p0.faceindices[fii];
1540
+
1541
+ if (fi == -1)
1542
+ break;
1543
+
1544
+ Face f = bRep.GetFace(fi);
1545
+
1546
+ Vertex p = bRep.GetVertex(f.p);
1547
+ Vertex q = bRep.GetVertex(f.q);
1548
+ Vertex r = bRep.GetVertex(f.r);
1549
+
1550
+ int swap = (int)(Math.random()*3);
1551
+
1552
+// for (int s=swap; --s>=0;)
1553
+// {
1554
+// Vertex t = p;
1555
+// p = q;
1556
+// q = r;
1557
+// r = t;
1558
+// }
1559
+ if (ymin > p.y)
1560
+ {
1561
+ ymin = p.y;
1562
+ newp = p;
1563
+// break;
1564
+ }
1565
+ if (ymin > q.y)
1566
+ {
1567
+ ymin = q.y;
1568
+ newp = q;
1569
+// break;
1570
+ }
1571
+ if (ymin > r.y)
1572
+ {
1573
+ ymin = r.y;
1574
+ newp = r;
1575
+// break;
1576
+ }
1577
+ }
1578
+
1579
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1580
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1581
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1582
+
1583
+ obj.drawingstarted = false;
1584
+
1585
+ // return;
1586
+ }
1587
+
1588
+ if (false) // CameraPane.DRAW
1589
+ {
1590
+ p0.AO = colorV[0] = 2;
1591
+ colorV[1] = 2;
1592
+ colorV[2] = 2;
1593
+ }
1594
+
1595
+ CameraPane.pointflow.add(p0);
1596
+ CameraPane.pointflow.Touch();
1597
+ }
1598
+
1599
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1600
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1601
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1602
+ }
1603
+
1604
+ void DrawMaterial(cMaterial material, boolean selected)
1605
+ {
1606
+ CameraPane display = this;
1607
+ //new Exception().printStackTrace();
1608
+
1609
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1610
+ {
1611
+ return;
1612
+ }
1613
+
1614
+ javax.media.opengl.GL gl = display.GetGL();
1615
+
1616
+ //Color col = Color.getHSBColor(color,modulation,1);
1617
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1618
+ if (!material.multiply)
1619
+ {
1620
+ display.color = material.color;
1621
+ display.saturation = material.modulation;
1622
+ }
1623
+ else
1624
+ {
1625
+ display.color *= material.color*2;
1626
+ display.saturation *= material.modulation*2;
1627
+ }
1628
+
1629
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1630
+
1631
+ float[] colorV = Grafreed.colorV;
1632
+
1633
+ /**/
1634
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1635
+ {
1636
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1637
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1638
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1639
+ colorV[3] = material.opacity;
1640
+
1641
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1642
+ //System.out.println("Opacity = " + opacity);
1643
+
1644
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1645
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1646
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1647
+
1648
+ float amb = material.ambient;
1649
+ if (amb < material.cameralight)
1650
+ {
1651
+ amb = material.cameralight;
1652
+ }
1653
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1654
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1655
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1656
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1657
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1658
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1659
+
1660
+ /**/
1661
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1662
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1663
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1664
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1665
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1666
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1667
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1668
+ //System.out.println("shininess = " + colorV[0]);
1669
+ if (colorV[0] > 128)
1670
+ {
1671
+ colorV[0] = 128;
1672
+ }
1673
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1674
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1675
+ /**/
1676
+ }
1677
+ /**/
1678
+
1679
+ //selected = false;
1680
+ selected = selected && display.flash;
1681
+
1682
+ //display.modelParams0[0] = 0; // pigment.r;
1683
+ //display.modelParams0[1] = 0; // pigment.g;
1684
+ //display.modelParams0[2] = 0; // pigment.b;
1685
+ if (!material.multiply)
1686
+ {
1687
+ display.modelParams0[3] = material.metalness;
1688
+ display.modelParams1[0] = material.diffuse;
1689
+ display.modelParams1[1] = material.specular;
1690
+ display.modelParams1[2] = 1 / material.shininess;
1691
+ display.modelParams1[3] = material.shift;
1692
+ display.modelParams2[0] = material.ambient;
1693
+ display.modelParams2[1] = material.lightarea;
1694
+ //System.out.println("light area = " + lightarea);
1695
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1696
+ display.modelParams2[3] = material.velvet;
1697
+ display.modelParams3[0] = material.sheen;
1698
+ display.modelParams3[1] = material.subsurface;
1699
+ display.modelParams3[2] = material.bump; // backlit
1700
+ display.modelParams3[3] = material.aniso;
1701
+ display.modelParams4[0] = material.anisoV;
1702
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1703
+ //System.out.println("selected = " + selected);
1704
+ display.modelParams4[2] = material.diffuseness;
1705
+ display.modelParams4[3] = material.shadow;
1706
+ display.modelParams5[0] = material.texture;
1707
+ display.modelParams5[1] = material.opacity;
1708
+ display.modelParams5[2] = material.fakedepth;
1709
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1710
+ }
1711
+ else
1712
+ {
1713
+ display.modelParams0[3] *= material.metalness*2;
1714
+ display.modelParams1[0] *= material.diffuse*2;
1715
+ display.modelParams1[1] *= material.specular*2;
1716
+ display.modelParams1[2] *= material.shininess*2;
1717
+ display.modelParams1[3] *= material.shift*2;
1718
+ display.modelParams2[0] *= material.ambient*2;
1719
+ display.modelParams2[1] *= material.lightarea*2;
1720
+ display.modelParams2[2] *= material.factor*2;
1721
+ display.modelParams2[3] *= material.velvet*2;
1722
+ display.modelParams3[0] *= material.sheen*2;
1723
+ display.modelParams3[1] *= material.subsurface*2;
1724
+ display.modelParams3[2] *= material.bump*2;
1725
+ display.modelParams3[3] *= material.aniso*2;
1726
+ display.modelParams4[0] *= material.anisoV*2;
1727
+ display.modelParams4[1] *= material.cameralight*2;
1728
+ //System.out.println("selected = " + selected);
1729
+ display.modelParams4[2] *= material.diffuseness*2;
1730
+ display.modelParams4[3] *= material.shadow*2;
1731
+ display.modelParams5[0] *= material.texture*2;
1732
+ display.modelParams5[1] *= material.opacity*2;
1733
+ display.modelParams5[2] *= material.fakedepth*2;
1734
+ display.modelParams5[3] *= material.shadowbias*2;
1735
+ }
1736
+
1737
+ display.modelParams6[0] = 0;
1738
+ display.modelParams6[1] = 0;
1739
+ display.modelParams6[2] = 0;
1740
+ display.modelParams6[3] = 0;
1741
+
1742
+ display.modelParams7[0] = 0;
1743
+ display.modelParams7[1] = 1000;
1744
+ display.modelParams7[2] = 0;
1745
+ display.modelParams7[3] = 0;
1746
+
1747
+ display.modelParams6[0] = 100; // criss de bug de bump
1748
+
1749
+ Object3D.cVector2[] extparams = display.vector2buffer;
1750
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1751
+ {
1752
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1753
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1754
+ if (extparams.length > 1)
1755
+ {
1756
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1757
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1758
+ if (extparams.length > 2)
1759
+ {
1760
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1761
+ float x = extparams[2].y / 1000.0f;
1762
+ //if (x == 0)
1763
+ // x = 1f;
1764
+ 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
1765
+ if (extparams[2].y > 0)
1766
+ {
1767
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1768
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1769
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1770
+ }
1771
+ }
1772
+ }
1773
+ }
1774
+
1775
+ //if (display.modelParams6[2] != 0)
1776
+ /*
1777
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1778
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1779
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1780
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1781
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1782
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1783
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1784
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1785
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1786
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1787
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1788
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1789
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1790
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1791
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1792
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1793
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1794
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1795
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1796
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1797
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1798
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1799
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1800
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1801
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1802
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1803
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1804
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1805
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1806
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1807
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1808
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1809
+ /**/
1810
+ //assert (display.modelParams6[2] == 0);
1811
+
1812
+ //System.out.println("noise power = " + display.modelParams7[0]);
1813
+ //System.out.println("shadowbias = " + shadowbias);
1814
+
1815
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1816
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1817
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1818
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1819
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1820
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1821
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1822
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1823
+
1824
+ int mode = display.FP_SHADER;
1825
+
1826
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1827
+ {
1828
+ mode |= display.FP_ANISO;
1829
+ }
1830
+
1831
+ display.EnableProgram(mode);
1832
+
1833
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1834
+
1835
+ if (!material.multiply)
1836
+ {
1837
+ if (Globals.drawMode == CameraPane.SHADOW)
1838
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1839
+ else
1840
+ gl.glDepthMask(material.opacity >= 0.99);
1841
+ }
2081842 }
2091843
2101844 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1859,7 @@
2251859 currentGL.glMultMatrixd(model, 0);
2261860 }
2271861
228
- void PushMatrix(double[][] matrix, int count)
1862
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291863 {
2301864 matrixdepth++;
2311865 // GrafreeD.tracein(matrix);
....@@ -270,7 +1904,7 @@
2701904
2711905 double[][] tmpmat = new double[4][4];
2721906
273
- void PopMatrix(double[][] inverse)
1907
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741908 {
2751909 --matrixdepth;
2761910
....@@ -310,7 +1944,7 @@
3101944 PushTextureMatrix(matrix, 1);
3111945 }
3121946
313
- void PushTextureMatrix(double[][] matrix, int count)
1947
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141948 {
3151949 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161950
....@@ -324,7 +1958,7 @@
3241958 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251959 }
3261960
327
- void PopTextureMatrix(double[][] inverse)
1961
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281962 {
3291963 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301964 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -351,15 +1985,15 @@
3511985
3521986 static int camerachangeframe;
3531987
354
- boolean SetCamera(Camera cam)
1988
+ public boolean SetCamera(Camera cam)
3551989 {
3561990 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571991 // return false;
3581992
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1993
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601994 {
3611995 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1996
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631997 {
3641998 // refuse the camera change
3651999 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +2001,7 @@
3672001 }
3682002 }
3692003
370
- camerachangeframe = framecount;
2004
+ camerachangeframe = Globals.framecount;
3712005
3722006 cam.hAspect = -1; // Read only
3732007
....@@ -398,7 +2032,7 @@
3982032 {
3992033 //System.err.println("Oeil on");
4002034 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2035
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022036 // object.editWindow.ScreenFit(trackedobject);
4032037 //pingthread.StepToTarget(true);
4042038 }
....@@ -407,7 +2041,7 @@
4072041 {
4082042 //System.err.println("Oeil on");
4092043 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2044
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4112045 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4122046 //pingthread.StepToTarget(true);
4132047 }
....@@ -471,39 +2105,12 @@
4712105 {
4722106 frozen ^= true;
4732107 // Weird...
474
- lighttouched = true;
2108
+ Globals.lighttouched = true;
4752109 }
4762110
4772111 void ToggleDL()
4782112 {
4792113 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
- GrafreeD.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;
5072114 }
5082115
5092116 void ToggleFullScreen()
....@@ -513,12 +2120,7 @@
5132120
5142121 void ToggleCrowd()
5152122 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2123
+ Globals.CROWD ^= true;
5222124 }
5232125
5242126 void ToggleLocal()
....@@ -526,62 +2128,89 @@
5262128 LOCALTRANSFORM ^= true;
5272129 }
5282130
529
- void ToggleFast()
2131
+ public void ToggleTexture()
2132
+ {
2133
+ textureon ^= true;
2134
+ }
2135
+
2136
+ public void ToggleLive()
2137
+ {
2138
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2139
+
2140
+ System.err.println("LIVE = " + Globals.isLIVE());
2141
+
2142
+ if (!Globals.isLIVE()) // save sound
2143
+ Grafreed.savesound = true; // wav.save();
2144
+ // else
2145
+ repaint(); // start loop // may 2013
2146
+ }
2147
+
2148
+ public void ToggleSupport()
2149
+ {
2150
+ SUPPORT ^= true;
2151
+ }
2152
+
2153
+ public void ToggleAbort()
2154
+ {
2155
+ ABORTMODE ^= true;
2156
+ }
2157
+
2158
+ public void ToggleInertia()
2159
+ {
2160
+ INERTIA ^= true;
2161
+ }
2162
+
2163
+ public void ToggleFast()
5302164 {
5312165 FAST ^= true;
5322166 }
5332167
534
- void ToggleSlowPose()
2168
+ public void ToggleSlowPose()
5352169 {
5362170 SLOWPOSE ^= true;
5372171 }
5382172
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2173
+ public void ToggleBoxMode()
5452174 {
5462175 BOXMODE ^= true;
5472176 }
5482177
549
- void ToggleSmoothFocus()
2178
+ public void ToggleZoomBoxMode()
2179
+ {
2180
+ ZOOMBOXMODE ^= true;
2181
+ }
2182
+
2183
+ public void ToggleSmoothFocus()
5502184 {
5512185 SMOOTHFOCUS ^= true;
5522186 }
5532187
554
- void ToggleImageFlip()
2188
+ public void ToggleImageFlip()
5552189 {
5562190 IMAGEFLIP ^= true;
5572191 }
5582192
559
- void ToggleSpeakerMocap()
2193
+ public void ToggleSpeakerMocap()
5602194 {
5612195 SPEAKERMOCAP ^= true;
5622196 }
5632197
564
- void ToggleSpeakerCamera()
2198
+ public void ToggleSpeakerCamera()
5652199 {
5662200 SPEAKERCAMERA ^= true;
5672201 }
5682202
569
- void ToggleSpeakerFocus()
2203
+ public void ToggleSpeakerFocus()
5702204 {
5712205 SPEAKERFOCUS ^= true;
5722206 }
5732207
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2208
+ public void ToggleFrustum()
5802209 {
5812210 FRUSTUM ^= true;
5822211 }
5832212
584
- void ToggleTrack()
2213
+ public void ToggleTrack()
5852214 {
5862215 TRACK ^= true;
5872216 if (TRACK)
....@@ -600,25 +2229,35 @@
6002229 repaint();
6012230 }
6022231
603
- void ToggleTrackOnce()
2232
+ public void ToggleTrackOnce()
6042233 {
6052234 TRACKONCE ^= true;
6062235 }
6072236
608
- void ToggleShadowTrack()
2237
+ public void ToggleShadowTrack()
6092238 {
6102239 SHADOWTRACK ^= true;
6112240 repaint();
6122241 }
6132242
614
- void ToggleOeil()
2243
+ public void ToggleOeil()
6152244 {
6162245 OEIL ^= true;
6172246 }
6182247
619
- void ToggleOeilOnce()
2248
+ public void ToggleOeilOnce()
6202249 {
6212250 OEILONCE ^= true;
2251
+ }
2252
+
2253
+ void ToggleFootContact()
2254
+ {
2255
+ FOOTCONTACT ^= true;
2256
+ }
2257
+
2258
+ void ToggleDebug()
2259
+ {
2260
+ DEBUG ^= true;
6222261 }
6232262
6242263 void ToggleLookAt()
....@@ -628,7 +2267,7 @@
6282267
6292268 void ToggleRandom()
6302269 {
631
- RANDOM ^= true;
2270
+ SWITCH ^= true;
6322271 }
6332272
6342273 void ToggleHandles()
....@@ -672,34 +2311,6 @@
6722311 //assert (cam.hAspect == 0);
6732312 cam.hAspect = 0;
6742313 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
7032314 }
7042315
7052316 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -759,7 +2370,7 @@
7592370
7602371 GL currentGL;
7612372
762
- GL GetGL()
2373
+ public GL GetGL() // INTERFACE
7632374 {
7642375 return currentGL;
7652376 }
....@@ -2000,10 +3611,12 @@
20003611 */
20013612 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20023613 {
3614
+ int pixelformat = texturedata.getPixelFormat();
3615
+
20033616 int stride = 1;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
3617
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20053618 stride = 3;
2006
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
3619
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20073620 stride = 4;
20083621
20093622 int width = texturedata.getWidth();
....@@ -2593,6 +4206,7 @@
25934206
25944207 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25954208 {
4209
+ new Exception().printStackTrace();
25964210 System.exit(0);
25974211 com.sun.opengl.util.texture.Texture texture = null;
25984212
....@@ -6269,7 +7883,7 @@
62697883 return null;
62707884 }
62717885
6272
- void ReleaseTextures(cTexture tex)
7886
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62737887 {
62747888 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62757889 {
....@@ -6307,7 +7921,7 @@
63077921
63087922 void ReleaseTexture(String tex, boolean bump)
63097923 {
6310
- if (// drawMode != 0 || /*tex == null ||*/
7924
+ if (// DrawMode() != 0 || /*tex == null ||*/
63117925 ambientOcclusion ) // || !textureon)
63127926 {
63137927 return;
....@@ -6408,9 +8022,9 @@
64088022 }
64098023 }
64108024
6411
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8025
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64128026 {
6413
- if (// drawMode != 0 || /*tex == null ||*/
8027
+ if (// DrawMode() != 0 || /*tex == null ||*/
64148028 ambientOcclusion ) // || !textureon)
64158029 {
64168030 return; // false;
....@@ -6453,7 +8067,7 @@
64538067 return; // true;
64548068 }
64558069
6456
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8070
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
64578071 {
64588072 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64598073
....@@ -6461,12 +8075,16 @@
64618075 {
64628076 String texname = tex;
64638077
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;
8078
+// String[] split = tex.split("Textures");
8079
+// if (split.length > 1)
8080
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
+// else
8082
+// if (!texname.startsWith("/"))
8083
+// texname = "/Users/nbriere/Textures/" + texname;
8084
+ if (!new File(tex).exists())
8085
+ {
8086
+ texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8087
+ }
64708088
64718089 if (CACHETEXTURE)
64728090 texture = textures.get(texname); // TEXTURE CACHE
....@@ -6566,7 +8184,9 @@
65668184 texturedata = GetFileTexture(cachename, processbump, resolution);
65678185
65688186
6569
- if (texturedata != null)
8187
+ if (texturedata == null)
8188
+ throw new Exception();
8189
+
65708190 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
65718191 //texture = GetTexture(tex, bump);
65728192 }
....@@ -6688,7 +8308,7 @@
66888308 return texture;
66898309 }
66908310
6691
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8311
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
66928312 {
66938313 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66948314
....@@ -6706,14 +8326,14 @@
67068326 return texture!=null?texture.texture:null;
67078327 }
67088328
6709
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8329
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
67108330 {
67118331 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67128332
67138333 return texture!=null?texture.texturedata:null;
67148334 }
67158335
6716
- boolean BindTexture(String tex, boolean bump, int resolution)
8336
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
67178337 {
67188338 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67198339 {
....@@ -7310,9 +8930,9 @@
73108930 static boolean occlusionInitialized = false;
73118931 boolean selection = false;
73128932 boolean pointselection = false;
7313
- /*static*/ boolean lighttouched = true;
8933
+ ///*static*/ boolean lighttouched = true;
73148934 boolean deselect;
7315
- boolean ambientOcclusion = false;
8935
+ private boolean ambientOcclusion = false;
73168936 static boolean flash = false;
73178937 /*static*/ boolean wait = false;
73188938 boolean displaydone = false; // after repaint() calls
....@@ -7442,6 +9062,8 @@
74429062 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74439063 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74449064 double scale = lightCamera.SCALE / lightCamera.Distance();
9065
+// PATCH FILLE AUX JEANS
9066
+ //scale *= lightCamera.shaper_fovy / 25;
74459067 gl.glScaled(2 * scale, 2 * scale, -scale);
74469068 gl.glTranslated(0, 0, lightCamera.DECAL);
74479069
....@@ -7590,15 +9212,14 @@
75909212
75919213 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75929214 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
9215
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
9216
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75949217
75959218 static int imagecount = 0; // movie generation
75969219
75979220 static int jitter = 0;
75989221
75999222 boolean restartframe = false;
7600
-
7601
- static int framecount = 0; // general-purpose global count
76029223
76039224 void displayAntiAliased(javax.media.opengl.GL gl)
76049225 {
....@@ -7630,7 +9251,7 @@
76309251 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76319252 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76329253 {
7633
- framecount++;
9254
+ Globals.framecount++;
76349255
76359256 if (CameraPane.tickcount > 0)
76369257 CameraPane.tickcount--;
....@@ -7668,7 +9289,7 @@
76689289
76699290 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76709291 */
7671
- lighttouched = true;
9292
+ Globals.lighttouched = true;
76729293 //System.err.println(" shadowbuffer: " + jitter);
76739294 shadowbuffer.display();
76749295
....@@ -7690,7 +9311,7 @@
76909311
76919312 if (renderCamera != lightCamera)
76929313 for (int count = parentcam.GetTransformCount(); --count>=0;)
7693
- LA.matConcat(parentcam.toParent, matrix, matrix);
9314
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76949315
76959316 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76969317
....@@ -7706,7 +9327,7 @@
77069327
77079328 if (renderCamera != lightCamera)
77089329 for (int count = parentcam.GetTransformCount(); --count>=0;)
7709
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9330
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77109331
77119332 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77129333
....@@ -7778,7 +9399,7 @@
77789399 //gl.glFlush();
77799400 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77809401
7781
- if (ANIMATION && ABORTED)
9402
+ if (Globals.ANIMATION && ABORTED)
77829403 {
77839404 System.err.println(" ABORTED FRAME");
77849405 break;
....@@ -7808,7 +9429,7 @@
78089429 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78099430
78109431 // save image
7811
- if (ANIMATION && !ABORTED)
9432
+ if (Globals.ANIMATION && !ABORTED)
78129433 {
78139434 VPwidth = viewport[2];
78149435 VPheight = viewport[3];
....@@ -7919,11 +9540,11 @@
79199540
79209541 // imagecount++;
79219542
7922
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9543
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
79239544
79249545 if (!BOXMODE)
79259546 {
7926
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9547
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
79279548 }
79289549
79299550 if (!BOXMODE)
....@@ -7961,7 +9582,7 @@
79619582 ABORTED = false;
79629583 }
79639584 else
7964
- GrafreeD.wav.cursor += 735 * ACSIZE;
9585
+ Grafreed.wav.cursor += 735 * ACSIZE;
79659586
79669587 if (false)
79679588 {
....@@ -8615,13 +10236,6 @@
861510236 }
861610237 }
861710238
8618
- boolean IsFrozen()
8619
- {
8620
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8621
-
8622
- return !selectmode && cameracount == 0; // != 0;
8623
- }
8624
-
862510239 boolean niceon = false;
862610240 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
862710241 boolean currentlydrawing = false;
....@@ -8631,16 +10245,16 @@
863110245
863210246 public void display(GLAutoDrawable drawable)
863310247 {
8634
- if (GrafreeD.savesound && GrafreeD.hassound)
10248
+ if (Grafreed.savesound && Grafreed.hassound)
863510249 {
8636
- GrafreeD.wav.save();
8637
- GrafreeD.savesound = false;
8638
- GrafreeD.hassound = false;
10250
+ Grafreed.wav.save();
10251
+ Grafreed.savesound = false;
10252
+ Grafreed.hassound = false;
863910253 }
864010254 // if (DEBUG_SELECTION)
864110255 // {
8642
-// if (drawMode != SELECTION)
8643
-// drawMode = SELECTION;
10256
+// if (DrawMode() != SELECTION)
10257
+// DrawMode() = SELECTION;
864410258 // }
864510259
864610260 if (!isRenderer)
....@@ -8696,9 +10310,9 @@
869610310
869710311 //ANTIALIAS = 0;
869810312
8699
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10313
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870010314 {
8701
- if (niceon || isLIVE())
10315
+ if (niceon || Globals.isLIVE())
870210316 {
870310317 //if(active == 0)
870410318 // antialiaser = null;
....@@ -8723,7 +10337,7 @@
872310337 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872410338 */
872510339
8726
- if (drawMode == DEFAULT)
10340
+ if (DrawMode() == DEFAULT)
872710341 {
872810342 currentlydrawing = true;
872910343 }
....@@ -8754,18 +10368,18 @@
875410368
875510369 // if(Applet3D.clipboard != null)
875610370 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8757
-//drawMode = SELECTION;
10371
+//DrawMode() = SELECTION;
875810372 indexcount = 0;
875910373
8760
- if (drawMode == OCCLUSION)
10374
+ if (DrawMode() == OCCLUSION)
876110375 {
8762
- drawMode = DEFAULT;
10376
+ Globals.drawMode = DEFAULT; // WARNING
876310377 ambientOcclusion = true;
876410378 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876510379 Object3D theobject = object;
876610380 Object3D theparent = object.parent;
876710381 object.parent = null;
8768
- object = (Object3D)GrafreeD.clone(object);
10382
+ object = (Object3D)Grafreed.clone(object);
876910383 object.Stripify();
877010384 if (theobject.selection == null || theobject.selection.Size() == 0)
877110385 theobject.PreprocessOcclusion(this);
....@@ -8778,19 +10392,19 @@
877810392 ambientOcclusion = false;
877910393 }
878010394
8781
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10395
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878210396 {
878310397 //if (RENDERSHADOW) // ?
878410398 if (!IsFrozen())
878510399 {
878610400 // dec 2012
8787
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10401
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
878810402 {
8789
- framecount++;
10403
+ Globals.framecount++;
879010404 shadowbuffer.display();
879110405 }
879210406 }
8793
- lighttouched = false; // ??
10407
+ Globals.lighttouched = false; // ??
879410408 //drawing = true;
879510409 //lighttouched = true;
879610410 }
....@@ -8811,9 +10425,9 @@
881110425 //eyeCamera.shaper_fovy = 1;
881210426 }
881310427
8814
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10428
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881510429 {
8816
- //System.out.println("drawMode = " + drawMode);
10430
+ //System.out.println("DrawMode() = " + DrawMode());
881710431 vertexMode |= VP_PASS;
881810432 //vertexMode |= VP_PROJECTION;
881910433 if (!ambientOcclusion)
....@@ -8873,7 +10487,7 @@
887310487 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887410488 //Camera lightcam = new Camera(light0);
887510489
8876
- if (drawMode == SHADOW)
10490
+ if (DrawMode() == SHADOW)
887710491 {
887810492 /*
887910493 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8912,7 +10526,7 @@
891210526 // if (parentcam != renderCamera) // not a light
891310527 if (cam != lightCamera)
891410528 for (int count = parentcam.GetTransformCount(); --count>=0;)
8915
- LA.matConcat(parentcam.toParent, matrix, matrix);
10529
+ LA.matConcat(matrix, parentcam.toParent, matrix);
891610530
891710531 for (int j = 0; j < 4; j++)
891810532 {
....@@ -8927,7 +10541,7 @@
892710541 // if (parentcam != renderCamera) // not a light
892810542 if (cam != lightCamera)
892910543 for (int count = parentcam.GetTransformCount(); --count>=0;)
8930
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10544
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
893110545
893210546 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893310547
....@@ -8963,7 +10577,7 @@
896310577 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896410578 } else
896510579 {
8966
- if (drawMode != DEFAULT)
10580
+ if (DrawMode() != DEFAULT)
896710581 {
896810582 gl.glClearColor(1, 1, 1, 0);
896910583 } // 1);
....@@ -9028,7 +10642,7 @@
902810642
902910643 fast &= !ambientOcclusion;
903010644
9031
- if (drawMode == DEFAULT)
10645
+ if (DrawMode() == DEFAULT)
903210646 {
903310647 //gl.glEnable(gl.GL_ALPHA_TEST);
903410648 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9089,6 +10703,8 @@
908910703 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909010704 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909110705 double scale = lightCamera.SCALE / lightCamera.Distance();
10706
+// PATCH FILLE AUX JEANS
10707
+ //scale *= lightCamera.shaper_fovy / 25;
909210708 gl.glScaled(2 * scale, 2 * scale, -scale);
909310709 gl.glTranslated(0, 0, lightCamera.DECAL);
909410710
....@@ -9184,7 +10800,16 @@
918410800 // Bump noise
918510801 gl.glActiveTexture(GL.GL_TEXTURE6);
918610802 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9187
- BindTexture(NOISE_TEXTURE, false, 2);
10803
+
10804
+ try
10805
+ {
10806
+ BindTexture(NOISE_TEXTURE, false, 2);
10807
+ }
10808
+ catch (Exception e)
10809
+ {
10810
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10811
+ }
10812
+
918810813
918910814 gl.glActiveTexture(GL.GL_TEXTURE0);
919010815 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9224,10 +10849,12 @@
922410849 gl.glMatrixMode(gl.GL_PROJECTION);
922510850 gl.glLoadIdentity();
922610851
9227
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10852
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
922810853 {
922910854 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923010855 double scale = lightCamera.SCALE / lightCamera.Distance();
10856
+// PATCH FILLE AUX JEANS
10857
+ //scale *= lightCamera.shaper_fovy / 25;
923110858 gl.glScaled(2 * scale, 2 * scale, -scale);
923210859 gl.glTranslated(0, 0, lightCamera.DECAL);
923310860 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9280,7 +10907,7 @@
928010907 //gl.glPushMatrix();
928110908 gl.glLoadIdentity();
928210909
9283
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10910
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928410911 {
928510912 //LA.xformPos(light0, lightCamera.fromScreen, light);
928610913 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9367,7 +10994,7 @@
936710994 }
936810995
936910996 /**/
9370
- if (true) // drawMode == SELECTION) // != DEFAULT)
10997
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937110998 gl.glDisable(gl.GL_LIGHTING);
937210999 else
937311000 gl.glEnable(gl.GL_LIGHTING);
....@@ -9379,12 +11006,13 @@
937911006
938011007 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
938111008 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
11009
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
938211010
938311011 options2[0] *= renderCamera.Distance();
938411012
938511013 lightslot = 64;
938611014
9387
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11015
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
938811016 {
938911017 DrawLights(object);
939011018 }
....@@ -9395,7 +11023,7 @@
939511023 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
939611024 //System.out.println("fragmentMode = " + fragmentMode);
939711025
9398
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11026
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
939911027 {
940011028 /*
940111029 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9428,7 +11056,7 @@
942811056 }
942911057 }
943011058
9431
- if (drawMode == DEFAULT)
11059
+ if (DrawMode() == DEFAULT)
943211060 {
943311061 if (WIREFRAME && !ambientOcclusion)
943411062 {
....@@ -9446,7 +11074,7 @@
944611074 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
944711075 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
944811076
9449
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11077
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945011078 {
945111079 if (vertexMode != 0) // && !fast)
945211080 {
....@@ -9466,7 +11094,7 @@
946611094 }
946711095 }
946811096
9469
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11097
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947011098 {
947111099 //gl.glDepthFunc(GL.GL_LEQUAL);
947211100 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9494,7 +11122,7 @@
949411122 //gl.glDepthMask(false);
949511123 }
949611124
9497
- if (false) // drawMode == SHADOW)
11125
+ if (false) // DrawMode() == SHADOW)
949811126 {
949911127 //SetColumnMajorData(cameraInverseTransform, view_1);
950011128 //System.out.println("light = " + cameraInverseTransform);
....@@ -9508,16 +11136,16 @@
950811136 //System.out.println("object = " + object);
950911137 if (!frozen && !imageLocked)
951011138 {
9511
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11139
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951211140 {
951311141 displayAntiAliased(gl);
951411142 } else
951511143 {
951611144 programcount = 0;
9517
- int keepmode = drawMode;
11145
+ int keepmode = DrawMode();
951811146 // if (DEBUG_SELECTION)
951911147 // {
9520
-// drawMode = SELECTION;
11148
+// DrawMode() = SELECTION;
952111149 // }
952211150 // for point selection
952311151 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9527,10 +11155,10 @@
952711155 DrawObject(gl);
952811156
952911157 // jan 2013 System.err.println("RESET ABORT (display)");
9530
- // if (drawMode == DEFAULT)
11158
+ // if (DrawMode() == DEFAULT)
953111159 // ABORTED = false;
953211160 fullreset = false;
9533
- drawMode = keepmode;
11161
+ Globals.drawMode = keepmode; // WARNING
953411162 //System.out.println("PROGRAM SWITCH " + programcount);
953511163 }
953611164 }
....@@ -9538,11 +11166,11 @@
953811166 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
953911167 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954011168
9541
- if (drawMode == DEFAULT)
11169
+ if (DrawMode() == DEFAULT)
954211170 {
954311171 ReleaseTexture(NOISE_TEXTURE, false);
954411172 }
9545
- //if (drawMode == DEFAULT)
11173
+ //if (DrawMode() == DEFAULT)
954611174 {
954711175
954811176 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9554,7 +11182,7 @@
955411182 //else
955511183 //gl.glDisable(gl.GL_TEXTURE_2D);
955611184 //gl.glPopMatrix();
9557
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11185
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
955811186 {
955911187 //new Exception().printStackTrace();
956011188 //System.out.println("Draw image " + width + ", " + height);
....@@ -9596,7 +11224,7 @@
959611224 //gl.glFlush();
959711225 }
959811226
9599
- if (flash && drawMode == DEFAULT)
11227
+ if (flash && DrawMode() == DEFAULT)
960011228 {
960111229 flash = false;
960211230 wait = true;
....@@ -9604,9 +11232,9 @@
960411232 }
960511233
960611234 //drawing = false;
9607
- //if(drawMode == DEFAULT)
11235
+ //if(DrawMode() == DEFAULT)
960811236 // niceon = false;
9609
- if (drawMode == DEFAULT)
11237
+ if (DrawMode() == DEFAULT)
961011238 {
961111239 currentlydrawing = false;
961211240 }
....@@ -9626,7 +11254,7 @@
962611254 repaint();
962711255 }
962811256
9629
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11257
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963011258 repaint();
963111259
963211260 displaydone = true;
....@@ -9645,8 +11273,14 @@
964511273 {
964611274 renderpass++;
964711275 // System.out.println("Draw object... ");
11276
+ STEP = 1;
964811277 if (FAST) // in case there is no script
9649
- STEP = 16;
11278
+ STEP = 8;
11279
+
11280
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11281
+ {
11282
+ STEP *= 4;
11283
+ }
965011284
965111285 //object.FullInvariants();
965211286
....@@ -9660,10 +11294,10 @@
966011294 e.printStackTrace();
966111295 }
966211296
9663
- if (GrafreeD.RENDERME > 0)
9664
- GrafreeD.RENDERME--; // mechante magouille
11297
+ if (Grafreed.RENDERME > 0)
11298
+ Grafreed.RENDERME--; // mechante magouille
966511299
9666
- ONESTEP = false;
11300
+ Globals.ONESTEP = false;
966711301 }
966811302
966911303 static boolean zoomonce = false;
....@@ -9671,11 +11305,11 @@
967111305 void DrawObject(GL gl, boolean draw)
967211306 {
967311307 //System.out.println("DRAW OBJECT " + mouseDown);
9674
-// drawMode = SELECTION;
11308
+// DrawMode() = SELECTION;
967511309 //GL gl = getGL();
967611310 if ((TRACK || SHADOWTRACK) || zoomonce)
967711311 {
9678
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11312
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
967911313 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968011314 pingthread.StepToTarget(true); // true);
968111315 // zoomonce = false;
....@@ -9696,9 +11330,9 @@
969611330 callist = gl.glGenLists(1);
969711331 }
969811332
9699
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11333
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970011334
9701
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11335
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970211336
970311337 if (!mainDL || !active || touched)
970411338 {
....@@ -9725,13 +11359,20 @@
972511359 PushMatrix(ClickInfo.matbuffer);
972611360 }
972711361
9728
- if (drawMode == 0)
11362
+ if (DrawMode() == 0)
972911363 {
973011364 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973111365
973211366 usedtextures.clear();
973311367
9734
- BindTextures(DEFAULT_TEXTURES, 2);
11368
+ try
11369
+ {
11370
+ BindTextures(DEFAULT_TEXTURES, 2);
11371
+ }
11372
+ catch (Exception e)
11373
+ {
11374
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11375
+ }
973511376 }
973611377 //System.out.println("--> " + stackdepth);
973711378 // GrafreeD.traceon();
....@@ -9739,7 +11380,7 @@
973911380 // DRAW
974011381 object.draw(this, /*(Composite)*/ object, false, false);
974111382
9742
- if (drawMode == DEFAULT)
11383
+ if (DrawMode() == DEFAULT)
974311384 {
974411385 if (DEBUG)
974511386 {
....@@ -9750,40 +11391,40 @@
975011391 selectedpoint.radius = radius;
975111392 selectedpoint.recalculate();
975211393 selectedpoint.material = new cMaterial();
9753
- selectedpoint.material.color = 0.25f;
11394
+ selectedpoint.material.color = 0.15f; // Yellow
975411395 selectedpoint.material.modulation = 0.75f;
975511396
9756
- debugpoint.radius = radius;
9757
- debugpoint.recalculate();
9758
- debugpoint.material = new cMaterial();
9759
- debugpoint.material.color = 0.25f;
9760
- debugpoint.material.modulation = 0.75f;
11397
+ debugpointG.radius = radius;
11398
+ debugpointG.recalculate();
11399
+ debugpointG.material = new cMaterial();
11400
+ debugpointG.material.color = 0.25f; // Green
11401
+ debugpointG.material.modulation = 0.75f;
976111402
9762
- debugpoint2.radius = radius;
9763
- debugpoint2.recalculate();
9764
- debugpoint2.material = new cMaterial();
9765
- debugpoint2.material.color = 0.75f;
9766
- debugpoint2.material.modulation = 0.75f;
11403
+ debugpointP.radius = radius;
11404
+ debugpointP.recalculate();
11405
+ debugpointP.material = new cMaterial();
11406
+ debugpointP.material.color = 0.75f; // Purple
11407
+ debugpointP.material.modulation = 0.75f;
976711408
9768
- debugpoint3.radius = radius;
9769
- debugpoint3.recalculate();
9770
- debugpoint3.material = new cMaterial();
9771
- debugpoint3.material.color = 0.5f;
9772
- debugpoint3.material.modulation = 0.75f;
11409
+ debugpointC.radius = radius;
11410
+ debugpointC.recalculate();
11411
+ debugpointC.material = new cMaterial();
11412
+ debugpointC.material.color = 0.5f; // Cyan
11413
+ debugpointC.material.modulation = 0.75f;
977311414
9774
- debugpoint4.radius = radius;
9775
- debugpoint4.recalculate();
9776
- debugpoint4.material = new cMaterial();
9777
- debugpoint4.material.color = 0f;
9778
- debugpoint4.material.modulation = 0.75f;
11415
+ debugpointR.radius = radius;
11416
+ debugpointR.recalculate();
11417
+ debugpointR.material = new cMaterial();
11418
+ debugpointR.material.color = 0f; // Red
11419
+ debugpointR.material.modulation = 0.75f;
977911420
978011421 InitPoints(radius);
978111422 }
978211423 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9783
- debugpoint.draw(this, /*(Composite)*/ null, false,false);
9784
- debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9785
- debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9786
- debugpoint4.draw(this, /*(Composite)*/ null, false,false);
11424
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11425
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11426
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11427
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
978711428 // DrawPoints(this);
978811429 }
978911430
....@@ -9791,7 +11432,7 @@
979111432 }
979211433 // GrafreeD.traceoff();
979311434 //System.out.println(stackdepth);
9794
- if (drawMode == 0)
11435
+ if (DrawMode() == 0)
979511436 {
979611437 ReleaseTextures(DEFAULT_TEXTURES);
979711438
....@@ -9816,17 +11457,26 @@
981611457
981711458 checker = null;
981811459
9819
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11460
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982011461 FindChecker(object);
982111462
9822
- if (checker != null && drawMode == DEFAULT)
11463
+ if (checker != null && DrawMode() == DEFAULT)
982311464 {
9824
- // BindTexture(IMMORTAL_TEXTURE);
11465
+ //BindTexture(IMMORTAL_TEXTURE);
11466
+ try
11467
+ {
11468
+ BindTextures(checker.GetTextures(), checker.texres);
11469
+ }
11470
+ catch (Exception e)
11471
+ {
11472
+ System.err.println("FAILED: " + checker.GetTextures());
11473
+ }
982511474 // NEAREST
982611475 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
982711476 DrawChecker(gl);
982811477 //checker.Draw(this, null, false);
982911478 // ReleaseTexture(IMMORTAL_TEXTURE);
11479
+ ReleaseTextures(checker.GetTextures());
983011480 }
983111481
983211482 if (object.parent != null)
....@@ -9839,7 +11489,7 @@
983911489 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984011490 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984111491
9842
- if (DISPLAYTEXT && drawMode == DEFAULT)
11492
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984311493 {
984411494 // Draw it once, then use the raster
984511495 Balloon(gl, balloon.createGraphics());
....@@ -9895,14 +11545,14 @@
989511545 int[] xs = new int[3];
989611546 int[] ys = new int[3];
989711547
9898
- void DrawString(Object3D obj) // String string)
11548
+ public void DrawString(Object3D obj) // String string) // INTERFACE
989911549 {
9900
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11550
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990111551 {
990211552 return;
990311553 }
990411554
9905
- String string = obj.GetToolTip();
11555
+ String string = obj.toString(); //.GetToolTip();
990611556
990711557 GL gl = GetGL();
990811558
....@@ -10357,11 +12007,13 @@
1035712007 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1035812008 "PARAM params7 = program.env[7];" + // noise power, opacity power
1035912009 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10360
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
12010
+ "PARAM options1 = program.env[62];" + // fog rgb color
12011
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1036112012 "PARAM pointlight = program.env[127];" + // ...
1036212013 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1036312014 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1036412015 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12016
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1036512017 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1036612018 "PARAM ten = { 10, 10, 10, 1.0 };" +
1036712019 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10382,6 +12034,7 @@
1038212034 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038312035 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1038412036 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
12037
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1038512038 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1038612039 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1038712040 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10422,6 +12075,10 @@
1042212075 "TEMP R1;" +
1042312076 "TEMP R2;" +
1042412077 "TEMP R3;" +
12078
+ "TEMP min;" +
12079
+ "TEMP max;" +
12080
+ "TEMP average;" +
12081
+ "TEMP saturation;" +
1042512082 "TEMP keep1;" +
1042612083 "TEMP keep2;" +
1042712084 "TEMP keep3;" +
....@@ -10845,8 +12502,8 @@
1084512502
1084612503 // display shadow only (bump == 0)
1084712504 "SUB temp.x, half.x, shadow.x;" +
10848
- "MOV temp.y, -params6.x;" +
10849
- "SLT temp.z, temp.y, zero.x;" +
12505
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12506
+ "SLT temp.z, temp.y, -one2048th.x;" +
1085012507 "SUB temp.y, one.x, temp.z;" +
1085112508 "MUL temp.x, temp.x, temp.y;" +
1085212509 "KIL temp.x;" +
....@@ -10952,10 +12609,42 @@
1095212609
1095312610 // skin?
1095412611 // Saturation for skin
10955
- /**/ // c'est ici
10956
- (Skinshader? "DP3 temp.x, final,one;" +
12612
+ /**/
12613
+ (Skinshader?
12614
+ "DP3 average.x, final,one;" +
12615
+ "MUL average, one3rd.xxxx,average.xxxx;" +
12616
+
12617
+ "MIN min.x, final.x,final.y;" +
12618
+ "MIN min.x, min.x,final.z;" +
12619
+
12620
+ "MAX max.x, final.x,final.y;" +
12621
+ "MAX max.x, max.x,final.z;" +
12622
+ "MOV max, max.xxxx;" +
12623
+
12624
+ "SUB saturation, max, final;" +
12625
+
12626
+ "ADD temp.x, max.x, one10th.x;" +
12627
+ "RCP temp.x, temp.x;" +
12628
+ "MUL temp.x, temp.x, half.x;" +
12629
+ "MUL saturation, saturation, temp.xxxx;" +
12630
+
12631
+ "DP3 ndotl.x, normald, light;" +
12632
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
12633
+
12634
+ "SUB temp.x, one.x, ndotl.x;" +
12635
+ // Tuning for default skin
12636
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12637
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12638
+ "ADD temp.y, one.y, options2.y;" + // subsurface
12639
+ "MUL temp.x, temp.x, temp.y;" +
12640
+
12641
+ "MUL saturation, saturation, temp.xxxx;" +
12642
+ "SUB_SAT temp, max, saturation;" +
12643
+/**
12644
+ "DP3 temp.x, final,one;" +
1095712645 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10958
- "SUB temp, final,R2;" +
12646
+ "SUB temp, final, R2;" +
12647
+
1095912648 // using light angle
1096012649 "DP3 ndotl.x, normald,light;" +
1096112650 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10968,7 +12657,6 @@
1096812657 // using light intensity
1096912658 "MOV ndotl.z, R2.x;" +
1097012659 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10971
-
1097212660 // june 2014
1097312661 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1097412662 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10980,6 +12668,7 @@
1098012668 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1098112669
1098212670 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
12671
+/**/
1098312672
1098412673 // "ADD final, R2,temp;" +
1098512674 "MOV final, temp;"
....@@ -11069,7 +12758,7 @@
1106912758 /**/
1107012759 // HDR
1107112760 "MOV temp.z, final.a;" +
11072
- "MUL final, final,options1.w;" +
12761
+ "MUL final, final,options2.x;" +
1107312762 "MOV final.a, temp.z;" +
1107412763 /**/
1107512764
....@@ -11145,7 +12834,7 @@
1114512834 //once = true;
1114612835 }
1114712836
11148
- System.out.print("Program #" + mode + "; length = " + program.length());
12837
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1114912838 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1115012839 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1115112840
....@@ -11262,6 +12951,7 @@
1126212951 String Shadow(String depth, String shadow)
1126312952 {
1126412953 return "MAX temp.x, ndotl.x, one64th.x;" +
12954
+ "MIN temp.x, temp.x, ninetenth.x;" +
1126512955 /**/
1126612956 // Sine
1126712957 "MUL temp.y, temp.x, temp.x;" +
....@@ -11277,12 +12967,16 @@
1127712967
1127812968 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1127912969 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12970
+
12971
+ // Compare fragment depth in light space with shadowmap.
1128012972 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1128112973 "SGE temp.y, temp.x, zero.x;" +
11282
- "SUB " + shadow + ".y, one.x, temp.y;" +
12974
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12975
+
12976
+ // Reverse comparison
1128312977 "SUB temp.x, one.x, temp.x;" +
1128412978 "MUL " + shadow + ".x, temp.x, temp.y;" +
11285
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
12979
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1128612980 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1128712981
1128812982 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11296,6 +12990,10 @@
1129612990 // No shadow for backface
1129712991 "DP3 temp.x, normal, lightd;" +
1129812992 "SLT temp.x, temp.x, zero.x;" + // shadoweps
12993
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
12994
+
12995
+ // No shadow when out of frustrum
12996
+ "SGE temp.x, " + depth + ".z, one.z;" +
1129912997 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1130012998 "";
1130112999 }
....@@ -11854,7 +13552,7 @@
1185413552 public void mousePressed(MouseEvent e)
1185513553 {
1185613554 //System.out.println("mousePressed: " + e);
11857
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13555
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1185813556 }
1185913557
1186013558 static long prevtime = 0;
....@@ -11881,14 +13579,16 @@
1188113579
1188213580 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1188313581
13582
+ if (BUTTONLESSWHEEL)
1188413583 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1188513584 {
1188613585 return;
1188713586 }
1188813587
13588
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1188913589
1189013590 // TIMER
11891
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13591
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1189213592 {
1189313593 keepboxmode = BOXMODE;
1189413594 keepsupport = SUPPORT;
....@@ -11928,8 +13628,8 @@
1192813628 // mode |= META;
1192913629 //}
1193013630
11931
- SetMouseMode(WHEEL | e.getModifiersEx());
11932
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13631
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13632
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1193313633 anchorX = ax;
1193413634 anchorY = ay;
1193513635 prevX = px;
....@@ -11989,6 +13689,10 @@
1198913689 // wasliveok = true;
1199013690 // waslive = false;
1199113691
13692
+ // May 2019 Forget it:
13693
+ if (true)
13694
+ return;
13695
+
1199213696 // source == timer
1199313697 if (mouseDown)
1199413698 {
....@@ -12017,7 +13721,7 @@
1201713721 // ObjEditor.tweenManager.update(1f / 60f);
1201813722
1201913723 // fev 2014???
12020
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13724
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1202113725 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1202213726 pingthread.StepToTarget(true); // true);
1202313727 }
....@@ -12027,7 +13731,7 @@
1202713731
1202813732 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1202913733
12030
- void clickStart(int x, int y, int modifiers)
13734
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1203113735 {
1203213736 if (!wasliveok)
1203313737 return;
....@@ -12044,7 +13748,7 @@
1204413748 // touched = true; // main DL
1204513749 if (isRenderer)
1204613750 {
12047
- SetMouseMode(modifiers);
13751
+ SetMouseMode(modifiers, modifiersex);
1204813752 }
1204913753
1205013754 selectX = anchorX = x;
....@@ -12057,7 +13761,7 @@
1205713761 clicked = true;
1205813762 hold = false;
1205913763
12060
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13764
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1206113765 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1206213766 {
1206313767 // System.out.println("RESTART II " + modifiers);
....@@ -12088,7 +13792,7 @@
1208813792 info.camera = renderCamera;
1208913793 info.x = x;
1209013794 info.y = y;
12091
- info.modifiers = modifiers;
13795
+ info.modifiers = modifiersex;
1209213796 editObj = object.doEditClick(info, 0);
1209313797 if (!editObj)
1209413798 {
....@@ -12105,11 +13809,11 @@
1210513809
1210613810 public void mouseDragged(MouseEvent e)
1210713811 {
13812
+ //System.out.println("mouseDragged: " + e);
1210813813 if (isRenderer)
1210913814 movingcamera = true;
1211013815 //if (drawing)
1211113816 //return;
12112
- //System.out.println("mouseDragged: " + e);
1211313817 if ((e.getModifiersEx() & CTRL) != 0
1211413818 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1211513819 {
....@@ -12117,7 +13821,7 @@
1211713821 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1211813822 }
1211913823 else
12120
- drag(e.getX(), e.getY(), e.getModifiersEx());
13824
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1212113825
1212213826 //try { Thread.sleep(1); } catch (Exception ex) {}
1212313827 }
....@@ -12129,6 +13833,11 @@
1212913833 cVector tmp = new cVector();
1213013834 cVector tmp2 = new cVector();
1213113835 boolean isMoving;
13836
+
13837
+ public cVector TargetLookAt()
13838
+ {
13839
+ return targetLookAt;
13840
+ }
1213213841
1213313842 class PingThread extends Thread
1213413843 {
....@@ -12268,7 +13977,7 @@
1226813977 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1226913978 if (lightMode)
1227013979 {
12271
- lighttouched = true;
13980
+ Globals.lighttouched = true;
1227213981 }
1227313982
1227413983 if (OEILONCE && OEIL)
....@@ -12285,6 +13994,7 @@
1228513994
1228613995 public void run()
1228713996 {
13997
+ new Exception().printStackTrace();
1228813998 System.exit(0);
1228913999 for (;;)
1229014000 {
....@@ -12326,7 +14036,7 @@
1232614036 mouseDown = false;
1232714037 if (lightMode)
1232814038 {
12329
- lighttouched = true;
14039
+ Globals.lighttouched = true;
1233014040 }
1233114041 repaint();
1233214042 alreadypainted = true;
....@@ -12334,7 +14044,7 @@
1233414044 isMoving = false;
1233514045 } //??
1233614046
12337
- if (isLIVE() && !alreadypainted)
14047
+ if (Globals.isLIVE() && !alreadypainted)
1233814048 {
1233914049 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1234014050 repaint();
....@@ -12346,9 +14056,9 @@
1234614056 {
1234714057 if (lightMode)
1234814058 {
12349
- lighttouched = true;
14059
+ Globals.lighttouched = true;
1235014060 }
12351
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14061
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1235214062 }
1235314063 //else
1235414064 }
....@@ -12448,7 +14158,7 @@
1244814158 int X, Y;
1244914159 boolean SX, SY;
1245014160
12451
- void drag(int x, int y, int modifiers)
14161
+ void drag(int x, int y, int modifiers, int modifiersex)
1245214162 {
1245314163 if (IsFrozen())
1245414164 {
....@@ -12457,17 +14167,17 @@
1245714167
1245814168 drag = true; // NEW
1245914169
12460
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14170
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1246114171
1246214172 X = x;
1246314173 Y = y;
1246414174 // floating state for animation
12465
- MODIFIERS = modifiers;
12466
- modifiers &= ~1024;
14175
+ MODIFIERS = modifiersex;
14176
+ modifiersex &= ~1024;
1246714177 if (false) // modifiers != 0)
1246814178 {
1246914179 //new Exception().printStackTrace();
12470
- System.out.println("mouseDragged: " + modifiers);
14180
+ System.out.println("mouseDragged: " + modifiersex);
1247114181 System.out.println("SHIFT = " + SHIFT);
1247214182 System.out.println("CONTROL = " + COMMAND);
1247314183 System.out.println("META = " + META);
....@@ -12487,7 +14197,7 @@
1248714197 info.camera = renderCamera;
1248814198 info.x = x;
1248914199 info.y = y;
12490
- object.editWindow.copy.doEditDrag(info);
14200
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1249114201 } else
1249214202 {
1249314203 if (x < startX)
....@@ -12589,6 +14299,7 @@
1258914299 {
1259014300 manipCamera.Translate(dx, dy, getWidth());
1259114301 }
14302
+ else
1259214303 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1259314304 {
1259414305 manipCamera.RotateInterest(dx, dy);
....@@ -12599,7 +14310,7 @@
1259914310
1260014311 if (manipCamera == lightCamera)
1260114312 {
12602
- lighttouched = true;
14313
+ Globals.lighttouched = true;
1260314314 }
1260414315 /*
1260514316 switch (mode)
....@@ -12638,7 +14349,6 @@
1263814349 public void mouseMoved(MouseEvent e)
1263914350 {
1264014351 //System.out.println("mouseMoved: " + e);
12641
-
1264214352 if (isRenderer)
1264314353 return;
1264414354
....@@ -12664,6 +14374,7 @@
1266414374 public void mouseReleased(MouseEvent e)
1266514375 {
1266614376 movingcamera = false;
14377
+ X = Y = 0;
1266714378 //System.out.println("mouseReleased: " + e);
1266814379 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1266914380 }
....@@ -12686,9 +14397,9 @@
1268614397 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1268714398 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1268814399
12689
- if (control || command || IsFrozen())
14400
+// No delay if (control || command || IsFrozen())
1269014401 timeout = true;
12691
- else
14402
+// ?? May 2019 else
1269214403 // timer.setDelay((modifiers & 128) != 0?0:350);
1269314404 mouseDown = false;
1269414405 if (!control && !command) // june 2013
....@@ -12798,7 +14509,7 @@
1279814509 System.out.println("keyReleased: " + e);
1279914510 }
1280014511
12801
- void SetMouseMode(int modifiers)
14512
+ void SetMouseMode(int modifiers, int modifiersex)
1280214513 {
1280314514 //System.out.println("SetMouseMode = " + modifiers);
1280414515 //modifiers &= ~1024;
....@@ -12810,24 +14521,27 @@
1281014521 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1281114522 // return;
1281214523 //System.out.println("SetMode = " + modifiers);
12813
- if ((modifiers & WHEEL) == WHEEL)
14524
+ if ((modifiersex & WHEEL) == WHEEL)
1281414525 {
1281514526 mouseMode |= ZOOM;
1281614527 }
12817
- if ((modifiers & META) == META)
14528
+
14529
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14530
+ if (capsLocked) // || (modifiers & META) == META)
1281814531 {
1281914532 mouseMode |= VR; // BACKFORTH;
1282014533 }
12821
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
12822
- {
12823
- mouseMode |= SELECT; // BACKFORTH;
12824
- }
12825
- if ((modifiers & COMMAND) == COMMAND)
14534
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1282614535 {
1282714536 mouseMode |= SELECT;
1282814537 }
12829
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14538
+ if ((modifiersex & COMMAND) == COMMAND)
1283014539 {
14540
+ mouseMode |= SELECT;
14541
+ }
14542
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
14543
+ {
14544
+ mouseMode &= ~VR;
1283114545 mouseMode |= TRANSLATE;
1283214546 }
1283314547 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12854,10 +14568,10 @@
1285414568
1285514569 if (isRenderer) //
1285614570 {
12857
- SetMouseMode(modifiers);
14571
+ SetMouseMode(0, modifiers);
1285814572 }
1285914573
12860
- theRenderer.keyPressed(key);
14574
+ Globals.theRenderer.keyPressed(key);
1286114575 }
1286214576
1286314577 int kompactbit = 4; // power bit
....@@ -12869,7 +14583,7 @@
1286914583 float SATPOW = 1; // 2; // 0.5f;
1287014584 float BRIPOW = 1; // 0.5f; // 0.5f;
1287114585
12872
- void keyPressed(int key)
14586
+ public void keyPressed(int key)
1287314587 {
1287414588 if (key >= '0' && key <= '5')
1287514589 clampbit = (key-'0');
....@@ -12984,7 +14698,7 @@
1298414698 case 'B':
1298514699 BRISMOOTH ^= true;
1298614700 SHADOWCULLFACE ^= true;
12987
- lighttouched = true;
14701
+ Globals.lighttouched = true;
1298814702 repaint();
1298914703 break;
1299014704 case 'b':
....@@ -13084,7 +14798,7 @@
1308414798 repaint();
1308514799 break;
1308614800 case 'O':
13087
- drawMode = OCCLUSION;
14801
+ Globals.drawMode = OCCLUSION; // WARNING
1308814802 repaint();
1308914803 break;
1309014804 case 'o':
....@@ -13175,7 +14889,7 @@
1317514889 break;
1317614890 case ' ':
1317714891 lightMode ^= true;
13178
- lighttouched = true;
14892
+ Globals.lighttouched = true;
1317914893 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1318014894 targetLookAt.set(manipCamera.lookAt);
1318114895 repaint();
....@@ -13187,11 +14901,11 @@
1318714901 repaint();
1318814902 break;
1318914903 case 'Z':
13190
- RESIZETEXTURE ^= true;
13191
- break;
14904
+ //RESIZETEXTURE ^= true;
14905
+ //break;
1319214906 case 'z':
13193
- RENDERSHADOW ^= true;
13194
- lighttouched = true;
14907
+ Globals.RENDERSHADOW ^= true;
14908
+ Globals.lighttouched = true;
1319514909 repaint();
1319614910 break;
1319714911 //case UP:
....@@ -13217,7 +14931,8 @@
1321714931 FlipTransform();
1321814932 break;
1321914933 case ENTER:
13220
- object.editWindow.ScreenFit(); // Edit();
14934
+ // object.editWindow.ScreenFit(); // Edit();
14935
+ ToggleLive();
1322114936 break;
1322214937 case DELETE:
1322314938 ClearSelection();
....@@ -13305,6 +15020,7 @@
1330515020 }
1330615021 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1330715022 }
15023
+
1330815024 static double OCCLUSIONBOOST = 1; // 0.5;
1330915025
1331015026 void keyReleased(int key, int modifiers)
....@@ -13312,11 +15028,11 @@
1331215028 //mode = ROTATE;
1331315029 if ((MODIFIERS & COMMAND) == 0) // VR??
1331415030 {
13315
- SetMouseMode(modifiers);
15031
+ SetMouseMode(0, modifiers);
1331615032 }
1331715033 }
1331815034
13319
- protected void processKeyEvent(KeyEvent e)
15035
+ public void processKeyEvent(KeyEvent e)
1332015036 {
1332115037 switch (e.getID())
1332215038 {
....@@ -13446,8 +15162,9 @@
1344615162
1344715163 protected void processMouseMotionEvent(MouseEvent e)
1344815164 {
13449
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13450
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15165
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15166
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15167
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1345115168 {
1345215169 mouseMoved(e);
1345315170 } else
....@@ -13477,6 +15194,7 @@
1347715194
1347815195 void SelectParent()
1347915196 {
15197
+ new Exception().printStackTrace();
1348015198 System.exit(0);
1348115199 Composite group = (Composite) object;
1348215200 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13500,6 +15218,7 @@
1350015218
1350115219 void SelectChildren()
1350215220 {
15221
+ new Exception().printStackTrace();
1350315222 System.exit(0);
1350415223 /*
1350515224 Composite group = (Composite) object;
....@@ -13664,7 +15383,9 @@
1366415383 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1366515384 //Image img = CreateImage(width, height);
1366615385 //System.out.println("width = " + width + "; height = " + height + "\n");
15386
+
1366715387 Graphics gr = g; // img.getGraphics();
15388
+
1366815389 if (!hasMarquee)
1366915390 {
1367015391 if (Xmin < Xmax) // !locked)
....@@ -13762,14 +15483,28 @@
1376215483 if (!isRenderer)
1376315484 {
1376415485 object.drawEditHandles(info, 0);
15486
+
15487
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15488
+ {
15489
+ switch (object.selection.get(0).hitSomething)
15490
+ {
15491
+ case Object3D.hitCenter: gr.setColor(Color.pink); break;
15492
+ case Object3D.hitRotate: gr.setColor(Color.green); break;
15493
+ case Object3D.hitScale: gr.setColor(Color.cyan); break;
15494
+ }
15495
+
15496
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15497
+ }
1376515498 }
1376615499 }
15500
+
1376715501 if (isRenderer)
1376815502 {
1376915503 //gr.setColor(Color.black);
1377015504 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1377115505 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1377215506 }
15507
+
1377315508 if (hasMarquee)
1377415509 {
1377515510 gr.setXORMode(Color.white);
....@@ -13792,6 +15527,7 @@
1379215527 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1379315528 }
1379415529
15530
+ // To avoid clear.
1379515531 public void update(Graphics g)
1379615532 {
1379715533 paint(g);
....@@ -13881,6 +15617,7 @@
1388115617 public boolean mouseDown(Event evt, int x, int y)
1388215618 {
1388315619 System.out.println("mouseDown: " + evt);
15620
+ System.exit(0);
1388415621 /*
1388515622 locked = true;
1388615623 drag = false;
....@@ -13924,7 +15661,7 @@
1392415661 {
1392515662 keyPressed(0, modifiers);
1392615663 }
13927
- clickStart(x, y, modifiers);
15664
+ // clickStart(x, y, modifiers);
1392815665 return true;
1392915666 }
1393015667
....@@ -14042,7 +15779,7 @@
1404215779 {
1404315780 keyReleased(0, 0);
1404415781 }
14045
- drag(x, y, modifiers);
15782
+ drag(x, y, 0, modifiers);
1404615783 return true;
1404715784 }
1404815785
....@@ -14394,7 +16131,7 @@
1439416131 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1439516132 gl.glPushMatrix();
1439616133 gl.glLoadIdentity();
14397
- PushMatrix(checker.toParent);
16134
+ //PushMatrix(checker.toParent);
1439816135
1439916136 gl.glMatrixMode(GL.GL_TEXTURE);
1440016137 gl.glPushMatrix();
....@@ -14417,8 +16154,8 @@
1441716154
1441816155 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1441916156
14420
- float step = 0.1666f; //0.25f;
14421
- float stepv = step * 1652 / 998;
16157
+ float step = 2; // 0.1666f; //0.25f;
16158
+ float stepv = 2; // step * 1652 / 998;
1442216159
1442316160 int i0 = 0;
1442416161 /*
....@@ -14454,20 +16191,21 @@
1445416191 /**/
1445516192 //checker.GetMaterial().opacity = 1.1f;
1445616193 ////checker.GetMaterial().ambient = 0.99f;
14457
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14458
- Object3D.selectedstack[Object3D.materialdepth] = false;
14459
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16194
+ materialstack[materialdepth] = checker.material;
16195
+ selectedstack[materialdepth] = false;
16196
+ cStatic.objectstack[materialdepth++] = checker;
1446016197 //System.out.println("material " + material);
1446116198 //Applet3D.tracein(this, selected);
1446216199 vector2buffer = checker.projectedVertices;
1446316200
14464
- checker.GetMaterial().Draw(this, false); // true);
16201
+ //checker.GetMaterial().Draw(this, false); // true);
16202
+ DrawMaterial(checker.GetMaterial(), false); // true);
1446516203
14466
- Object3D.materialdepth -= 1;
14467
- if (Object3D.materialdepth > 0)
16204
+ materialdepth -= 1;
16205
+ if (materialdepth > 0)
1446816206 {
14469
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14470
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16207
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16208
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1447116209 }
1447216210 //checker.GetMaterial().opacity = 1f;
1447316211 ////checker.GetMaterial().ambient = 1f;
....@@ -14488,15 +16226,27 @@
1448816226
1448916227 //float u = (i+1)/2;
1449016228 //float v = (j+1)/2;
14491
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
16229
+ if (checker.flipV)
16230
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
16231
+ else
16232
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1449216233 gl.glVertex3f(i, j, -0.5f);
1449316234
16235
+ if (checker.flipV)
16236
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
16237
+ else
1449416238 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1449516239 gl.glVertex3f(i + step, j, -0.5f);
1449616240
16241
+ if (checker.flipV)
16242
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
16243
+ else
1449716244 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1449816245 gl.glVertex3f(i + step, j + stepv, -0.5f);
1449916246
16247
+ if (checker.flipV)
16248
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
16249
+ else
1450016250 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1450116251 gl.glVertex3f(i, j + stepv, -0.5f);
1450216252 }
....@@ -14508,7 +16258,7 @@
1450816258 gl.glMatrixMode(GL.GL_PROJECTION);
1450916259 gl.glPopMatrix();
1451016260 gl.glMatrixMode(GL.GL_MODELVIEW);
14511
- PopMatrix(null); // checker.toParent); // null);
16261
+ //PopMatrix(null); // checker.toParent); // null);
1451216262 gl.glPopMatrix();
1451316263 PopTextureMatrix(checker.toParent);
1451416264 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14599,6 +16349,7 @@
1459916349 {
1460016350 if (!selection)
1460116351 {
16352
+ new Exception().printStackTrace();
1460216353 System.exit(0);
1460316354 return;
1460416355 }
....@@ -14621,14 +16372,14 @@
1462116372
1462216373 //int tmp = selection_view;
1462316374 //selection_view = -1;
14624
- int temp = drawMode;
14625
- drawMode = SELECTION;
16375
+ int temp = DrawMode();
16376
+ Globals.drawMode = SELECTION; // WARNING
1462616377 indexcount = 0;
1462716378 parent.display(drawable);
1462816379 //selection_view = tmp;
1462916380 //if (temp == SELECTION)
1463016381 // temp = DEFAULT; // patch for selection debug
14631
- drawMode = temp;
16382
+ Globals.drawMode = temp; // WARNING
1463216383
1463316384 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1463416385
....@@ -14678,6 +16429,11 @@
1467816429 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1467916430 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1468016431
16432
+ // Will fit the mesh !!!
16433
+ selectedpoint.toParent[0][0] = 0.0001;
16434
+ selectedpoint.toParent[1][1] = 0.0001;
16435
+ selectedpoint.toParent[2][2] = 0.0001;
16436
+
1468116437 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1468216438
1468316439 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14721,16 +16477,16 @@
1472116477 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]));
1472216478 }
1472316479
14724
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16480
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1472516481 }
1472616482 }
1472716483
1472816484 if (!movingcamera && !PAINTMODE)
1472916485 object.editWindow.ScreenFitPoint(); // fev 2014
1473016486
14731
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16487
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1473216488 {
14733
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16489
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1473416490
1473516491 Object3D group = new Object3D("inst" + paintcount++);
1473616492
....@@ -14886,7 +16642,7 @@
1488616642 gl.glDisable(gl.GL_CULL_FACE);
1488716643 }
1488816644
14889
- if (!RENDERSHADOW)
16645
+ if (!Globals.RENDERSHADOW)
1489016646 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1489116647
1489216648 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14896,14 +16652,14 @@
1489616652 //gl.glColorMask(false, false, false, false);
1489716653
1489816654 //render_scene_from_light_view(gl, drawable, 0, 0);
14899
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16655
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1490016656 {
1490116657 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1490216658
14903
- int temp = drawMode;
14904
- drawMode = SHADOW;
16659
+ int temp = DrawMode();
16660
+ Globals.drawMode = SHADOW; // WARNING
1490516661 parent.display(drawable);
14906
- drawMode = temp;
16662
+ Globals.drawMode = temp; // WARNING
1490716663 }
1490816664
1490916665 gl.glCullFace(gl.GL_BACK);
....@@ -14956,7 +16712,6 @@
1495616712
1495716713 class AntialiasBuffer implements GLEventListener
1495816714 {
14959
-
1496016715 CameraPane parent = null;
1496116716
1496216717 AntialiasBuffer(CameraPane p)
....@@ -15066,13 +16821,19 @@
1506616821 gl.glFlush();
1506716822
1506816823 /**/
15069
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16824
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1507016825
15071
- int[] pixels = occlusionsizebuffer.array();
16826
+ float[] pixels = occlusionsizebuffer.array();
1507216827
1507316828 double r = 0, g = 0, b = 0;
1507416829
1507516830 double count = 0;
16831
+
16832
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16833
+
16834
+ float mindepth = 1;
16835
+
16836
+ double FACTOR = 1;
1507616837
1507716838 for (int i = 0; i < pixels.length; i++)
1507816839 {
....@@ -15157,7 +16918,7 @@
1515716918
1515816919 double scale = ray.z; // 1; // cos
1515916920
15160
- int p = pixels[newindex];
16921
+ float depth = pixels[newindex];
1516116922
1516216923 /*
1516316924 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15181,10 +16942,23 @@
1518116942 scale = (1 - modu) * modv;
1518216943 */
1518316944
15184
- r += ((p >> 16) & 0xFF) * scale / 255;
15185
- g += ((p >> 8) & 0xFF) * scale / 255;
15186
- b += (p & 0xFF) * scale / 255;
16945
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16946
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16947
+ //b += (p & 0xFF) * scale / 255;
16948
+
16949
+ if (mindepth > depth)
16950
+ {
16951
+ mindepth = depth;
16952
+ }
1518716953
16954
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16955
+
16956
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16957
+
16958
+ r += factor * scale;
16959
+ g += factor * scale;
16960
+ b += factor * scale;
16961
+
1518816962 count += scale;
1518916963 }
1519016964
....@@ -15282,12 +17056,6 @@
1528217056 GLUT glut = new GLUT();
1528317057
1528417058
15285
- static final public int DEFAULT = 0;
15286
- static final public int SELECTION = 1;
15287
- static final public int SHADOW = 2;
15288
- static final public int OCCLUSION = 3;
15289
- static
15290
- public int drawMode = DEFAULT;
1529117059 public boolean spherical = false;
1529217060 static boolean DEBUG_OCCLUSION = false;
1529317061 static boolean DEBUG_SELECTION = false;
....@@ -15300,12 +17068,12 @@
1530017068 int AAbuffersize = 0;
1530117069
1530217070 //double[] selectedpoint = new double[3];
15303
- static Sphere selectedpoint = new Sphere();
17071
+ static Superellipsoid selectedpoint = new Superellipsoid();
1530417072 static Sphere previousselectedpoint = null;
15305
- static Sphere debugpoint = new Sphere();
15306
- static Sphere debugpoint2 = new Sphere();
15307
- static Sphere debugpoint3 = new Sphere();
15308
- static Sphere debugpoint4 = new Sphere();
17073
+ static Sphere debugpointG = new Sphere();
17074
+ static Sphere debugpointP = new Sphere();
17075
+ static Sphere debugpointC = new Sphere();
17076
+ static Sphere debugpointR = new Sphere();
1530917077
1531017078 static Sphere debugpoints[] = new Sphere[8];
1531117079
....@@ -15336,7 +17104,7 @@
1533617104 }
1533717105 }
1533817106
15339
- static void DrawPoints(CameraPane cpane)
17107
+ static void DrawPoints(iCameraPane cpane)
1534017108 {
1534117109 for (int i=0; i<8; i++) // first and last are red
1534217110 {
....@@ -15358,7 +17126,8 @@
1535817126 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1535917127 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1536017128 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15361
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17129
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17130
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1536217131 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1536317132 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1536417133 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15367,10 +17136,11 @@
1536717136 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1536817137 // Depth buffer format
1536917138 //private int depth_format;
15370
- static public void NextIndex(Object3D o, GL gl)
17139
+
17140
+ public void NextIndex()
1537117141 {
1537217142 indexcount+=16;
15373
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17143
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1537417144 //objects[indexcount] = o;
1537517145 //System.out.println("indexcount = " + indexcount);
1537617146 }