Normand Briere
2019-04-22 91106535bc5aa5e67cbb02a67cf6de1519cba0e4
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
....@@ -97,10 +83,8 @@
9783
9884 static boolean textureon = true;
9985 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10186 static boolean FULLSCREEN = false;
10287 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10488 static boolean INERTIA = true;
10589 static boolean FAST = false;
10690 static boolean SLOWPOSE = false;
....@@ -173,17 +157,47 @@
173157 theRenderer = this;
174158 }
175159
160
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
161
+ {
162
+ super(defaultcaps, null, withcontext?glcontext:null, null);
163
+
164
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
165
+ glcontext = getContext();
166
+
167
+ cameras = new Camera[2];
168
+ targetLookAts = new cVector[2];
169
+
170
+ SetCamera(cam);
171
+
172
+ SetLight(new Camera(new cVector(10, 10, -20)));
173
+
174
+ object = o;
175
+
176
+ setBackground(Color.white);
177
+
178
+ addKeyListener(this);
179
+ addMouseListener(this);
180
+ addMouseMotionListener(this);
181
+ addMouseWheelListener(this);
182
+ //System.out.println("addGLEventListener: " + this);
183
+ addGLEventListener(this);
184
+
185
+// pingthread.start(); // may 2013
186
+ }
187
+
176188 static boolean AntialiasingEnabled()
177189 {
178190 return CURRENTANTIALIAS > 0;
179191 }
180192
181
- void ClearDepth()
193
+ /// INTERFACE
194
+
195
+ public void ClearDepth()
182196 {
183197 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184198 }
185199
186
- void DepthTest(boolean depthtest)
200
+ public void DepthTest(boolean depthtest)
187201 {
188202 if (depthtest)
189203 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +205,7 @@
191205 GetGL().glDepthFunc(GL.GL_ALWAYS);
192206 }
193207
194
- void DepthWrite(boolean depthwrite)
208
+ public void DepthWrite(boolean depthwrite)
195209 {
196210 if (depthwrite)
197211 GetGL().glDepthMask(true);
....@@ -199,12 +213,776 @@
199213 GetGL().glDepthMask(false);
200214 }
201215
202
- void BackFaceCull(boolean bfc)
216
+ public void BackFaceCull(boolean bfc)
203217 {
204218 if (bfc)
205219 GetGL().glEnable(GetGL().GL_CULL_FACE);
206220 else
207221 GetGL().glDisable(GetGL().GL_CULL_FACE);
222
+ }
223
+
224
+ public boolean BackFaceCullMode()
225
+ {
226
+ return this.CULLFACE;
227
+ }
228
+
229
+ public boolean IsAmbientOcclusionOn()
230
+ {
231
+ return this.ambientOcclusion;
232
+ }
233
+
234
+ public boolean IsFrozen()
235
+ {
236
+ boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
237
+
238
+ return !selectmode && cameracount == 0; // != 0;
239
+ }
240
+
241
+ // Currently in Globals
242
+ public int DrawMode()
243
+ {
244
+ return Globals.DrawMode();
245
+ }
246
+
247
+ public Camera EyeCamera()
248
+ {
249
+ return eyeCamera;
250
+ }
251
+
252
+ public Camera LightCamera()
253
+ {
254
+ return lightCamera;
255
+ }
256
+
257
+ public Camera RenderCamera()
258
+ {
259
+ return renderCamera;
260
+ }
261
+
262
+ public void PushMaterial(Object3D obj, boolean selected)
263
+ {
264
+ CameraPane display = this;
265
+ javax.media.opengl.GL gl = display.GetGL();
266
+ cMaterial material = obj.material;
267
+
268
+ if (material != null)
269
+ {
270
+ materialstack[materialdepth] = material;
271
+ selectedstack[materialdepth] = selected;
272
+ cStatic.objectstack[materialdepth++] = obj;
273
+ //System.out.println("material " + material);
274
+ //Applet3D.tracein(this, selected);
275
+ display.vector2buffer = obj.projectedVertices;
276
+ if (obj instanceof Camera)
277
+ {
278
+ display.options1[0] = material.shift;
279
+ //System.out.println("shift " + material.shift);
280
+ display.options1[1] = material.lightarea;
281
+ display.options1[2] = material.shadowbias;
282
+ display.options1[3] = material.aniso;
283
+ display.options1[4] = material.anisoV;
284
+ display.options2[0] = material.opacity;
285
+ display.options2[1] = material.diffuse;
286
+ display.options2[2] = material.factor;
287
+
288
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
289
+ display.options4[0] = material.cameralight/0.2f;
290
+ display.options4[1] = material.subsurface;
291
+ display.options4[2] = material.sheen;
292
+
293
+ // if (display.CURRENTANTIALIAS > 0)
294
+ // display.options3[3] /= 4;
295
+
296
+ /*
297
+ System.out.println("Focus = " + display.options1[0]);
298
+ System.out.println("Aperture = " + display.options1[1]);
299
+ System.out.println("ShadowBlur = " + display.options1[2]);
300
+ System.out.println("Antialiasing = " + display.options1[3]);
301
+ System.out.println("Fog = " + display.options2[0]);
302
+ System.out.println("Intensity = " + display.options2[1]);
303
+ System.out.println("Elevation = " + display.options2[2]);
304
+ /**/
305
+ } else
306
+ {
307
+ DrawMaterial(material, selected);
308
+ }
309
+ } else
310
+ {
311
+ if (selected && CameraPane.flash)
312
+ {
313
+ display.modelParams4[1] = 100;
314
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
315
+ }
316
+ }
317
+ }
318
+
319
+ public void PushMaterial2(Object3D obj, boolean selected)
320
+ {
321
+ CameraPane display = this;
322
+ cMaterial material = obj.material;
323
+
324
+ if (material != null)
325
+ {
326
+ materialstack[materialdepth] = material;
327
+ selectedstack[materialdepth] = selected;
328
+ cStatic.objectstack[materialdepth++] = obj;
329
+ //System.out.println("material " + material);
330
+ //Applet3D.tracein("selected ", selected);
331
+ display.vector2buffer = obj.projectedVertices;
332
+ display.DrawMaterial(material, selected);
333
+ }
334
+ }
335
+
336
+ public void PopMaterial(Object3D obj, boolean selected)
337
+ {
338
+ CameraPane display = this;
339
+ javax.media.opengl.GL gl = display.GetGL();
340
+ cMaterial material = obj.material;
341
+
342
+ //if (parent != null && parent.GetMaterial() != null)
343
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
344
+ if (material != null)
345
+ {
346
+ materialdepth -= 1;
347
+ if (materialdepth > 0)
348
+ {
349
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
350
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
351
+ }
352
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
353
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
354
+ {
355
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
356
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
357
+ }
358
+ }
359
+
360
+ public void PopMaterial2(Object3D obj)
361
+ {
362
+ CameraPane display = this;
363
+ cMaterial material = obj.material;
364
+
365
+ if (material != null)
366
+ {
367
+ materialdepth -= 1;
368
+ if (materialdepth > 0)
369
+ {
370
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
371
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
372
+ }
373
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
374
+ //else
375
+ //material.Draw(display, false);
376
+ }
377
+ }
378
+
379
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
380
+ {
381
+ CameraPane display = this;
382
+
383
+ if (pv.y == -10000 ||
384
+ qv.y == -10000 ||
385
+ rv.y == -10000)
386
+ return;
387
+
388
+// float b = f.nbiterations & 1;
389
+// float g = (f.nbiterations>>1) & 1;
390
+// float r = (f.nbiterations>>2) & 1;
391
+//
392
+// //if (f.weight == 10000)
393
+// //{
394
+// // r = 1; g = b = 0;
395
+// //}
396
+// //else
397
+// //{
398
+// // assert(f.weight < 10000);
399
+// r = g = b = (float)bRep.FaceWeight(f)*100;
400
+// if (r<0)
401
+// assert(r>=0);
402
+// //}
403
+
404
+ javax.media.opengl.GL gl = display.GetGL();
405
+
406
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
407
+
408
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
409
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
410
+ {
411
+ //gl.glBegin(gl.GL_TRIANGLES);
412
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
413
+ if (!hasnorm)
414
+ {
415
+ // System.out.println("FUCK!!");
416
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
417
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
418
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
419
+ LA.vecNormalize(obj.v2);
420
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
421
+ }
422
+
423
+ // P
424
+ float x = (float)pv.x;
425
+ float y = (float)pv.y;
426
+ float z = (float)pv.z;
427
+
428
+ if (hasnorm)
429
+ {
430
+// if (!pv.norm.normalized())
431
+// assert(pv.norm.normalized());
432
+
433
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
434
+ float nx = (float)pv.norm.x;
435
+ float ny = (float)pv.norm.y;
436
+ float nz = (float)pv.norm.z;
437
+
438
+ x += nx * obj.NORMALPUSH;
439
+ y += ny * obj.NORMALPUSH;
440
+ z += nz * obj.NORMALPUSH;
441
+
442
+ gl.glNormal3f(nx, ny, nz);
443
+ }
444
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
445
+ SetColor(obj, pv);
446
+ //gl.glColor4f(r, g, b, 1);
447
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
448
+ if (obj.flipV)
449
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
450
+ else
451
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
452
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
453
+
454
+ gl.glVertex3f(x, y, z);
455
+
456
+ // Q
457
+ x = (float)qv.x;
458
+ y = (float)qv.y;
459
+ z = (float)qv.z;
460
+
461
+// Print(pv);
462
+ if (hasnorm)
463
+ {
464
+// assert(qv.norm.normalized());
465
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
466
+ float nx = (float)qv.norm.x;
467
+ float ny = (float)qv.norm.y;
468
+ float nz = (float)qv.norm.z;
469
+
470
+ x += nx * obj.NORMALPUSH;
471
+ y += ny * obj.NORMALPUSH;
472
+ z += nz * obj.NORMALPUSH;
473
+
474
+ gl.glNormal3f(nx, ny, nz);
475
+ }
476
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
477
+ // boolean locked = false;
478
+ // float eps = 0.1f;
479
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
480
+
481
+ // int dot = 0; //*/ (int)f.dot;
482
+
483
+ // if ((dot&1) == 0)
484
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
485
+
486
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
487
+ if (obj.flipV)
488
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
489
+ else
490
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
491
+ // else
492
+ // {
493
+ // locked = true;
494
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
495
+ // }
496
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
497
+ SetColor(obj, qv);
498
+
499
+ gl.glVertex3f(x, y, z);
500
+ //gl.glColor4f(r, g, b, 1);
501
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
502
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
503
+// Print(qv);
504
+
505
+ // R
506
+ x = (float)rv.x;
507
+ y = (float)rv.y;
508
+ z = (float)rv.z;
509
+
510
+ if (hasnorm)
511
+ {
512
+// assert(rv.norm.normalized());
513
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
514
+ float nx = (float)rv.norm.x;
515
+ float ny = (float)rv.norm.y;
516
+ float nz = (float)rv.norm.z;
517
+
518
+ x += nx * obj.NORMALPUSH;
519
+ y += ny * obj.NORMALPUSH;
520
+ z += nz * obj.NORMALPUSH;
521
+
522
+ gl.glNormal3f(nx, ny, nz);
523
+ }
524
+
525
+ // if ((dot&4) == 0)
526
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
527
+
528
+ // if (wrap || !locked && (dot&8) != 0)
529
+ if (obj.flipV)
530
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
531
+ else
532
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
533
+ // else
534
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
535
+
536
+ // f.dot = dot;
537
+
538
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
539
+ SetColor(obj, rv);
540
+ //gl.glColor4f(r, g, b, 1);
541
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
542
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
543
+ gl.glVertex3f(x, y, z);
544
+// Print(rv);
545
+ //gl.glEnd();
546
+ }
547
+ else
548
+ {
549
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
550
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
551
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
552
+
553
+ }
554
+
555
+ if (false) // (attributes & WIREFRAME) != 0)
556
+ {
557
+ gl.glDisable(gl.GL_LIGHTING);
558
+
559
+ gl.glBegin(gl.GL_LINE_LOOP);
560
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
561
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
562
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
563
+ gl.glEnd();
564
+
565
+ gl.glEnable(gl.GL_LIGHTING);
566
+ }
567
+ }
568
+
569
+ /// INTERFACE
570
+
571
+ void SetColor(Object3D obj, Vertex p0)
572
+ {
573
+ CameraPane display = this;
574
+ BoundaryRep bRep = obj.bRep;
575
+
576
+ if (RENDERPROGRAM == 0)
577
+ {
578
+ float r = 0;
579
+ if (bRep != null)
580
+ {
581
+ if (bRep.stripified)
582
+ {
583
+ r = 1;
584
+ }
585
+ }
586
+ float g = 0;
587
+ if (bRep != null)
588
+ {
589
+ if (bRep.trimmed)
590
+ {
591
+ g = 1;
592
+ }
593
+ }
594
+ float b = 0;
595
+ if (obj.support != null && obj.link2master)
596
+ {
597
+ b = 1;
598
+ }
599
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
600
+ return;
601
+ }
602
+
603
+ if (display.DrawMode() != CameraPane.SHADOW)
604
+ return;
605
+
606
+ javax.media.opengl.GL gl = display.GetGL();
607
+// if (true) return;
608
+// float ao = p.AO;
609
+//
610
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
611
+// // ao = 1;
612
+//
613
+// gl.glColor4f(ao, ao, ao, 1);
614
+
615
+// CameraPane.selectedpoint.
616
+// getAverage(cStatic.point1, true);
617
+ if (CameraPane.pointflow == null) // !random) // live)
618
+ {
619
+ return;
620
+ }
621
+
622
+ cStatic.point1.set(0,0,0);
623
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
624
+
625
+ cStatic.point1.sub(p0);
626
+
627
+
628
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
629
+// {
630
+// return;
631
+// }
632
+
633
+ //if (true)
634
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
635
+ {
636
+ return;
637
+ }
638
+
639
+ float[] colorV = new float[3];
640
+
641
+ if (false) // marked)
642
+ {
643
+ // debug rigging weights
644
+ for (int object = 0; object < p0.vertexlinks.length; object++)
645
+ {
646
+ float weight = p0.weights[object] / p0.totalweight;
647
+
648
+ // if (weight < 0.1)
649
+ // {
650
+ // assert(weight == 0);
651
+ // continue;
652
+ // }
653
+
654
+ if (p0.vertexlinks[object] == -1)
655
+ continue;
656
+
657
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
658
+
659
+ int color = //1 << object; //
660
+ //p.vertexlinks.length;
661
+ obj.support.bRep.supports[p0.closestsupport].links[object];
662
+ colorV[2] += (color & 1) * weight;
663
+ colorV[1] += ((color & 2) >> 1) * weight;
664
+ colorV[0] += ((color & 4) >> 2) * weight;
665
+ }
666
+ }
667
+ else
668
+ {
669
+ if (obj.drawingstarted)
670
+ {
671
+ // find next point
672
+ if (bRep.GetVertex(0).faceindices == null)
673
+ {
674
+ bRep.InitFaceIndices();
675
+ }
676
+
677
+ double ymin = p0.y;
678
+
679
+ Vertex newp = p0;
680
+
681
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
682
+ {
683
+ int fi = p0.faceindices[fii];
684
+
685
+ if (fi == -1)
686
+ break;
687
+
688
+ Face f = bRep.GetFace(fi);
689
+
690
+ Vertex p = bRep.GetVertex(f.p);
691
+ Vertex q = bRep.GetVertex(f.q);
692
+ Vertex r = bRep.GetVertex(f.r);
693
+
694
+ int swap = (int)(Math.random()*3);
695
+
696
+// for (int s=swap; --s>=0;)
697
+// {
698
+// Vertex t = p;
699
+// p = q;
700
+// q = r;
701
+// r = t;
702
+// }
703
+ if (ymin > p.y)
704
+ {
705
+ ymin = p.y;
706
+ newp = p;
707
+// break;
708
+ }
709
+ if (ymin > q.y)
710
+ {
711
+ ymin = q.y;
712
+ newp = q;
713
+// break;
714
+ }
715
+ if (ymin > r.y)
716
+ {
717
+ ymin = r.y;
718
+ newp = r;
719
+// break;
720
+ }
721
+ }
722
+
723
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
724
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
725
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
726
+
727
+ obj.drawingstarted = false;
728
+
729
+ // return;
730
+ }
731
+
732
+ if (false) // CameraPane.DRAW
733
+ {
734
+ p0.AO = colorV[0] = 2;
735
+ colorV[1] = 2;
736
+ colorV[2] = 2;
737
+ }
738
+
739
+ CameraPane.pointflow.add(p0);
740
+ CameraPane.pointflow.Touch();
741
+ }
742
+
743
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
744
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
745
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
746
+ }
747
+
748
+ void DrawMaterial(cMaterial material, boolean selected)
749
+ {
750
+ CameraPane display = this;
751
+ //new Exception().printStackTrace();
752
+
753
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
754
+ {
755
+ return;
756
+ }
757
+
758
+ javax.media.opengl.GL gl = display.GetGL();
759
+
760
+ //Color col = Color.getHSBColor(color,modulation,1);
761
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
762
+ if (!material.multiply)
763
+ {
764
+ display.color = color;
765
+ display.saturation = material.modulation;
766
+ }
767
+ else
768
+ {
769
+ display.color *= color*2;
770
+ display.saturation *= material.modulation*2;
771
+ }
772
+
773
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
774
+
775
+ float[] colorV = GrafreeD.colorV;
776
+
777
+ /**/
778
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
779
+ {
780
+ colorV[0] = display.modelParams0[0] * material.diffuse;
781
+ colorV[1] = display.modelParams0[1] * material.diffuse;
782
+ colorV[2] = display.modelParams0[2] * material.diffuse;
783
+ colorV[3] = material.opacity;
784
+
785
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
786
+ //System.out.println("Opacity = " + opacity);
787
+
788
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
789
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
790
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
791
+
792
+ float amb = material.ambient;
793
+ if (amb < material.cameralight)
794
+ {
795
+ amb = material.cameralight;
796
+ }
797
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
798
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
799
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
800
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
801
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
802
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
803
+
804
+ /**/
805
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
806
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
807
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
808
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
809
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
810
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
811
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
812
+ //System.out.println("shininess = " + colorV[0]);
813
+ if (colorV[0] > 128)
814
+ {
815
+ colorV[0] = 128;
816
+ }
817
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
818
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
819
+ /**/
820
+ }
821
+ /**/
822
+
823
+ //selected = false;
824
+ selected = selected && display.flash;
825
+
826
+ //display.modelParams0[0] = 0; // pigment.r;
827
+ //display.modelParams0[1] = 0; // pigment.g;
828
+ //display.modelParams0[2] = 0; // pigment.b;
829
+ if (!material.multiply)
830
+ {
831
+ display.modelParams0[3] = material.metalness;
832
+ display.modelParams1[0] = material.diffuse;
833
+ display.modelParams1[1] = material.specular;
834
+ display.modelParams1[2] = 1 / material.shininess;
835
+ display.modelParams1[3] = material.shift;
836
+ display.modelParams2[0] = material.ambient;
837
+ display.modelParams2[1] = material.lightarea;
838
+ //System.out.println("light area = " + lightarea);
839
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
840
+ display.modelParams2[3] = material.velvet;
841
+ display.modelParams3[0] = material.sheen;
842
+ display.modelParams3[1] = material.subsurface;
843
+ display.modelParams3[2] = material.bump; // backlit
844
+ display.modelParams3[3] = material.aniso;
845
+ display.modelParams4[0] = material.anisoV;
846
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
847
+ //System.out.println("selected = " + selected);
848
+ display.modelParams4[2] = material.diffuseness;
849
+ display.modelParams4[3] = material.shadow;
850
+ display.modelParams5[0] = material.texture;
851
+ display.modelParams5[1] = material.opacity;
852
+ display.modelParams5[2] = material.fakedepth;
853
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
854
+ }
855
+ else
856
+ {
857
+ display.modelParams0[3] *= material.metalness*2;
858
+ display.modelParams1[0] *= material.diffuse*2;
859
+ display.modelParams1[1] *= material.specular*2;
860
+ display.modelParams1[2] *= material.shininess*2;
861
+ display.modelParams1[3] *= material.shift*2;
862
+ display.modelParams2[0] *= material.ambient*2;
863
+ display.modelParams2[1] *= material.lightarea*2;
864
+ display.modelParams2[2] *= material.factor*2;
865
+ display.modelParams2[3] *= material.velvet*2;
866
+ display.modelParams3[0] *= material.sheen*2;
867
+ display.modelParams3[1] *= material.subsurface*2;
868
+ display.modelParams3[2] *= material.bump*2;
869
+ display.modelParams3[3] *= material.aniso*2;
870
+ display.modelParams4[0] *= material.anisoV*2;
871
+ display.modelParams4[1] *= material.cameralight*2;
872
+ //System.out.println("selected = " + selected);
873
+ display.modelParams4[2] *= material.diffuseness*2;
874
+ display.modelParams4[3] *= material.shadow*2;
875
+ display.modelParams5[0] *= material.texture*2;
876
+ display.modelParams5[1] *= material.opacity*2;
877
+ display.modelParams5[2] *= material.fakedepth*2;
878
+ display.modelParams5[3] *= material.shadowbias*2;
879
+ }
880
+
881
+ display.modelParams6[0] = 0;
882
+ display.modelParams6[1] = 0;
883
+ display.modelParams6[2] = 0;
884
+ display.modelParams6[3] = 0;
885
+
886
+ display.modelParams7[0] = 0;
887
+ display.modelParams7[1] = 1000;
888
+ display.modelParams7[2] = 0;
889
+ display.modelParams7[3] = 0;
890
+
891
+ display.modelParams6[0] = 100; // criss de bug de bump
892
+
893
+ Object3D.cVector2[] extparams = display.vector2buffer;
894
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
895
+ {
896
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
897
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
898
+ if (extparams.length > 1)
899
+ {
900
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
901
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
902
+ if (extparams.length > 2)
903
+ {
904
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
905
+ float x = extparams[2].y / 1000.0f;
906
+ //if (x == 0)
907
+ // x = 1f;
908
+ 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
909
+ if (extparams[2].y > 0)
910
+ {
911
+ //System.out.println("extparams[1].y = " + extparams[1].y);
912
+ //System.out.println("extparams[2].y = " + extparams[2].y);
913
+ //System.out.println("opacity power = " + display.modelParams7[1]);
914
+ }
915
+ }
916
+ }
917
+ }
918
+
919
+ //if (display.modelParams6[2] != 0)
920
+ /*
921
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
922
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
923
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
924
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
925
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
926
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
927
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
928
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
929
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
930
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
931
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
932
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
933
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
934
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
935
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
936
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
937
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
938
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
939
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
940
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
941
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
942
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
943
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
944
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
945
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
946
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
947
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
948
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
949
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
950
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
951
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
952
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
953
+ /**/
954
+ //assert (display.modelParams6[2] == 0);
955
+
956
+ //System.out.println("noise power = " + display.modelParams7[0]);
957
+ //System.out.println("shadowbias = " + shadowbias);
958
+
959
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
960
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
961
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
962
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
963
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
964
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
965
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
966
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
967
+
968
+ int mode = display.FP_SHADER;
969
+
970
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
971
+ {
972
+ mode |= display.FP_ANISO;
973
+ }
974
+
975
+ display.EnableProgram(mode);
976
+
977
+ //System.out.println("opacity power = " + display.modelParams7[1]);
978
+
979
+ if (!material.multiply)
980
+ {
981
+ if (Globals.drawMode == CameraPane.SHADOW)
982
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
983
+ else
984
+ gl.glDepthMask(material.opacity >= 0.99);
985
+ }
208986 }
209987
210988 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,10 +1003,10 @@
2251003 currentGL.glMultMatrixd(model, 0);
2261004 }
2271005
228
- void PushMatrix(double[][] matrix, int count)
1006
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291007 {
2301008 matrixdepth++;
231
- // GraphreeD.tracein(matrix);
1009
+ // GrafreeD.tracein(matrix);
2321010 if (matrix == null)
2331011 return; // Identity
2341012
....@@ -253,13 +1031,13 @@
2531031
2541032 void PushMatrix(double[][] matrix)
2551033 {
256
- // GraphreeD.tracein(matrix);
1034
+ // GrafreeD.tracein(matrix);
2571035 PushMatrix(matrix,1);
2581036 }
2591037
2601038 void PushMatrix()
2611039 {
262
- // GraphreeD.tracein(null);
1040
+ // GrafreeD.tracein(null);
2631041 if (matrixdepth++ < MAXSTACK - 1)
2641042 {
2651043 currentGL.glPushMatrix();
....@@ -270,11 +1048,11 @@
2701048
2711049 double[][] tmpmat = new double[4][4];
2721050
273
- void PopMatrix(double[][] inverse)
1051
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741052 {
2751053 --matrixdepth;
2761054
277
- // GraphreeD.traceout(inverse);
1055
+ // GrafreeD.traceout(inverse);
2781056 if (inverse == null)
2791057 return; // Identity
2801058
....@@ -292,7 +1070,7 @@
2921070
2931071 void PopMatrix()
2941072 {
295
- // GraphreeD.traceout(null);
1073
+ // GrafreeD.traceout(null);
2961074 // inverse == null??
2971075 if (--matrixdepth < MAXSTACK - 1)
2981076 {
....@@ -310,7 +1088,7 @@
3101088 PushTextureMatrix(matrix, 1);
3111089 }
3121090
313
- void PushTextureMatrix(double[][] matrix, int count)
1091
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141092 {
3151093 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161094
....@@ -324,7 +1102,7 @@
3241102 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251103 }
3261104
327
- void PopTextureMatrix(double[][] inverse)
1105
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281106 {
3291107 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301108 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -356,10 +1134,10 @@
3561134 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571135 // return false;
3581136
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1137
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601138 {
3611139 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1140
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631141 {
3641142 // refuse the camera change
3651143 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +1145,7 @@
3671145 }
3681146 }
3691147
370
- camerachangeframe = framecount;
1148
+ camerachangeframe = Globals.framecount;
3711149
3721150 cam.hAspect = -1; // Read only
3731151
....@@ -398,7 +1176,7 @@
3981176 {
3991177 //System.err.println("Oeil on");
4001178 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1179
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4021180 // object.editWindow.ScreenFit(trackedobject);
4031181 //pingthread.StepToTarget(true);
4041182 }
....@@ -407,7 +1185,7 @@
4071185 {
4081186 //System.err.println("Oeil on");
4091187 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1188
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4111189 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4121190 //pingthread.StepToTarget(true);
4131191 }
....@@ -471,7 +1249,7 @@
4711249 {
4721250 frozen ^= true;
4731251 // Weird...
474
- lighttouched = true;
1252
+ Globals.lighttouched = true;
4751253 }
4761254
4771255 void ToggleDL()
....@@ -486,12 +1264,12 @@
4861264
4871265 void ToggleLive()
4881266 {
489
- setLIVE(isLIVE() ^ true);
1267
+ Globals.setLIVE(Globals.isLIVE() ^ true);
4901268
491
- System.err.println("LIVE = " + isLIVE());
1269
+ System.err.println("LIVE = " + Globals.isLIVE());
4921270
493
- if (!isLIVE()) // save sound
494
- GraphreeD.savesound = true; // wav.save();
1271
+ if (!Globals.isLIVE()) // save sound
1272
+ GrafreeD.savesound = true; // wav.save();
4951273 // else
4961274 repaint(); // start loop // may 2013
4971275 }
....@@ -513,7 +1291,7 @@
5131291
5141292 void ToggleCrowd()
5151293 {
516
- CROWD ^= true;
1294
+ Globals.CROWD ^= true;
5171295 }
5181296
5191297 void ToggleInertia()
....@@ -674,34 +1452,6 @@
6741452 lightCamera = cam;
6751453 }
6761454
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
703
- }
704
-
7051455 private static void ApplyTransform(GL gl, Mat4f xform)
7061456 {
7071457 float[] data = new float[16];
....@@ -759,7 +1509,7 @@
7591509
7601510 GL currentGL;
7611511
762
- GL GetGL()
1512
+ public GL GetGL() // INTERFACE
7631513 {
7641514 return currentGL;
7651515 }
....@@ -768,6 +1518,8 @@
7681518 class CacheTexture
7691519 {
7701520 com.sun.opengl.util.texture.Texture texture;
1521
+ com.sun.opengl.util.texture.TextureData texturedata;
1522
+
7711523 int resolution;
7721524
7731525 CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
....@@ -1998,10 +2750,12 @@
19982750 */
19992751 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20002752 {
2753
+ int pixelformat = texturedata.getPixelFormat();
2754
+
20012755 int stride = 1;
2002
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
2756
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20032757 stride = 3;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
2758
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20052759 stride = 4;
20062760
20072761 int width = texturedata.getWidth();
....@@ -6267,7 +7021,7 @@
62677021 return null;
62687022 }
62697023
6270
- void ReleaseTextures(cTexture tex)
7024
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62717025 {
62727026 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62737027 {
....@@ -6305,7 +7059,7 @@
63057059
63067060 void ReleaseTexture(String tex, boolean bump)
63077061 {
6308
- if (// drawMode != 0 || /*tex == null ||*/
7062
+ if (// DrawMode() != 0 || /*tex == null ||*/
63097063 ambientOcclusion ) // || !textureon)
63107064 {
63117065 return;
....@@ -6331,7 +7085,7 @@
63317085 {
63327086 bumpdepth--;
63337087
6334
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7088
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63357089 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63367090 {
63377091 // assert (bumpstack[bumpdepth] == texture);
....@@ -6361,7 +7115,7 @@
63617115 {
63627116 pigmentdepth--;
63637117
6364
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7118
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63657119 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63667120 {
63677121 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6406,9 +7160,9 @@
64067160 }
64077161 }
64087162
6409
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7163
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64107164 {
6411
- if (// drawMode != 0 || /*tex == null ||*/
7165
+ if (// DrawMode() != 0 || /*tex == null ||*/
64127166 ambientOcclusion ) // || !textureon)
64137167 {
64147168 return; // false;
....@@ -6451,7 +7205,7 @@
64517205 return; // true;
64527206 }
64537207
6454
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
7208
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
64557209 {
64567210 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64577211
....@@ -6665,6 +7419,8 @@
66657419 thetex.texture.dispose();
66667420 textures.remove(texname);
66677421 }
7422
+
7423
+ texture.texturedata = texturedata;
66687424 textures.put(texname, texture);
66697425
66707426 // newtex = true;
....@@ -6681,18 +7437,32 @@
66817437 }
66827438 }
66837439
7440
+ return texture;
7441
+ }
7442
+
7443
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
7444
+ {
7445
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
7446
+
66847447 if (bump)
66857448 {
6686
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
7449
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66877450 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66887451 }
66897452 else
66907453 {
6691
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
7454
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
66927455 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
66937456 }
66947457
66957458 return texture!=null?texture.texture:null;
7459
+ }
7460
+
7461
+ com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
7462
+ {
7463
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
7464
+
7465
+ return texture!=null?texture.texturedata:null;
66967466 }
66977467
66987468 boolean BindTexture(String tex, boolean bump, int resolution)
....@@ -7292,9 +8062,9 @@
72928062 static boolean occlusionInitialized = false;
72938063 boolean selection = false;
72948064 boolean pointselection = false;
7295
- /*static*/ boolean lighttouched = true;
8065
+ ///*static*/ boolean lighttouched = true;
72968066 boolean deselect;
7297
- boolean ambientOcclusion = false;
8067
+ private boolean ambientOcclusion = false;
72988068 static boolean flash = false;
72998069 /*static*/ boolean wait = false;
73008070 boolean displaydone = false; // after repaint() calls
....@@ -7424,6 +8194,8 @@
74248194 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74258195 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74268196 double scale = lightCamera.SCALE / lightCamera.Distance();
8197
+// PATCH FILLE AUX JEANS
8198
+ //scale *= lightCamera.shaper_fovy / 25;
74278199 gl.glScaled(2 * scale, 2 * scale, -scale);
74288200 gl.glTranslated(0, 0, lightCamera.DECAL);
74298201
....@@ -7572,15 +8344,14 @@
75728344
75738345 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75748346 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
7575
- float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity
8347
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
8348
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75768349
75778350 static int imagecount = 0; // movie generation
75788351
75798352 static int jitter = 0;
75808353
75818354 boolean restartframe = false;
7582
-
7583
- static int framecount = 0; // general-purpose global count
75848355
75858356 void displayAntiAliased(javax.media.opengl.GL gl)
75868357 {
....@@ -7610,14 +8381,14 @@
76108381
76118382 //System.out.println("start frame");
76128383 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7613
- for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0)
8384
+ for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76148385 {
7615
- framecount++;
8386
+ Globals.framecount++;
76168387
76178388 if (CameraPane.tickcount > 0)
76188389 CameraPane.tickcount--;
76198390
7620
-// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
8391
+// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
76218392 // restartframe = true;
76228393 if (options1[2] > 100 && (jitter%2==0))
76238394 {
....@@ -7650,7 +8421,7 @@
76508421
76518422 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76528423 */
7653
- lighttouched = true;
8424
+ Globals.lighttouched = true;
76548425 //System.err.println(" shadowbuffer: " + jitter);
76558426 shadowbuffer.display();
76568427
....@@ -7672,7 +8443,7 @@
76728443
76738444 if (renderCamera != lightCamera)
76748445 for (int count = parentcam.GetTransformCount(); --count>=0;)
7675
- LA.matConcat(parentcam.toParent, matrix, matrix);
8446
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76768447
76778448 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76788449
....@@ -7688,7 +8459,7 @@
76888459
76898460 if (renderCamera != lightCamera)
76908461 for (int count = parentcam.GetTransformCount(); --count>=0;)
7691
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8462
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
76928463
76938464 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
76948465
....@@ -7905,7 +8676,7 @@
79058676
79068677 if (!BOXMODE)
79078678 {
7908
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
8679
+ System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
79098680 }
79108681
79118682 if (!BOXMODE)
....@@ -7933,7 +8704,7 @@
79338704 {
79348705 if (ACSIZE > 1)
79358706 {
7936
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
8707
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79378708 }
79388709 }
79398710
....@@ -7943,7 +8714,7 @@
79438714 ABORTED = false;
79448715 }
79458716 else
7946
- GraphreeD.wav.cursor += 735 * ACSIZE;
8717
+ GrafreeD.wav.cursor += 735 * ACSIZE;
79478718
79488719 if (false)
79498720 {
....@@ -8597,13 +9368,6 @@
85979368 }
85989369 }
85999370
8600
- boolean IsFrozen()
8601
- {
8602
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8603
-
8604
- return !selectmode && cameracount == 0; // != 0;
8605
- }
8606
-
86079371 boolean niceon = false;
86089372 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86099373 boolean currentlydrawing = false;
....@@ -8613,16 +9377,16 @@
86139377
86149378 public void display(GLAutoDrawable drawable)
86159379 {
8616
- if (GraphreeD.savesound && GraphreeD.hassound)
9380
+ if (GrafreeD.savesound && GrafreeD.hassound)
86179381 {
8618
- GraphreeD.wav.save();
8619
- GraphreeD.savesound = false;
8620
- GraphreeD.hassound = false;
9382
+ GrafreeD.wav.save();
9383
+ GrafreeD.savesound = false;
9384
+ GrafreeD.hassound = false;
86219385 }
86229386 // if (DEBUG_SELECTION)
86239387 // {
8624
-// if (drawMode != SELECTION)
8625
-// drawMode = SELECTION;
9388
+// if (DrawMode() != SELECTION)
9389
+// DrawMode() = SELECTION;
86269390 // }
86279391
86289392 if (!isRenderer)
....@@ -8678,9 +9442,9 @@
86789442
86799443 //ANTIALIAS = 0;
86809444
8681
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9445
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
86829446 {
8683
- if (niceon || isLIVE())
9447
+ if (niceon || Globals.isLIVE())
86849448 {
86859449 //if(active == 0)
86869450 // antialiaser = null;
....@@ -8705,7 +9469,7 @@
87059469 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87069470 */
87079471
8708
- if (drawMode == DEFAULT)
9472
+ if (DrawMode() == DEFAULT)
87099473 {
87109474 currentlydrawing = true;
87119475 }
....@@ -8736,18 +9500,18 @@
87369500
87379501 // if(Applet3D.clipboard != null)
87389502 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8739
-//drawMode = SELECTION;
9503
+//DrawMode() = SELECTION;
87409504 indexcount = 0;
87419505
8742
- if (drawMode == OCCLUSION)
9506
+ if (DrawMode() == OCCLUSION)
87439507 {
8744
- drawMode = DEFAULT;
9508
+ Globals.drawMode = DEFAULT; // WARNING
87459509 ambientOcclusion = true;
87469510 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
87479511 Object3D theobject = object;
87489512 Object3D theparent = object.parent;
87499513 object.parent = null;
8750
- object = (Object3D)GraphreeD.clone(object);
9514
+ object = (Object3D)GrafreeD.clone(object);
87519515 object.Stripify();
87529516 if (theobject.selection == null || theobject.selection.Size() == 0)
87539517 theobject.PreprocessOcclusion(this);
....@@ -8760,19 +9524,19 @@
87609524 ambientOcclusion = false;
87619525 }
87629526
8763
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
9527
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
87649528 {
87659529 //if (RENDERSHADOW) // ?
87669530 if (!IsFrozen())
87679531 {
87689532 // dec 2012
8769
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
9533
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
87709534 {
8771
- framecount++;
9535
+ Globals.framecount++;
87729536 shadowbuffer.display();
87739537 }
87749538 }
8775
- lighttouched = false; // ??
9539
+ Globals.lighttouched = false; // ??
87769540 //drawing = true;
87779541 //lighttouched = true;
87789542 }
....@@ -8793,9 +9557,9 @@
87939557 //eyeCamera.shaper_fovy = 1;
87949558 }
87959559
8796
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
9560
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
87979561 {
8798
- //System.out.println("drawMode = " + drawMode);
9562
+ //System.out.println("DrawMode() = " + DrawMode());
87999563 vertexMode |= VP_PASS;
88009564 //vertexMode |= VP_PROJECTION;
88019565 if (!ambientOcclusion)
....@@ -8855,7 +9619,7 @@
88559619 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
88569620 //Camera lightcam = new Camera(light0);
88579621
8858
- if (drawMode == SHADOW)
9622
+ if (DrawMode() == SHADOW)
88599623 {
88609624 /*
88619625 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8894,7 +9658,7 @@
88949658 // if (parentcam != renderCamera) // not a light
88959659 if (cam != lightCamera)
88969660 for (int count = parentcam.GetTransformCount(); --count>=0;)
8897
- LA.matConcat(parentcam.toParent, matrix, matrix);
9661
+ LA.matConcat(matrix, parentcam.toParent, matrix);
88989662
88999663 for (int j = 0; j < 4; j++)
89009664 {
....@@ -8909,7 +9673,7 @@
89099673 // if (parentcam != renderCamera) // not a light
89109674 if (cam != lightCamera)
89119675 for (int count = parentcam.GetTransformCount(); --count>=0;)
8912
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9676
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
89139677
89149678 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
89159679
....@@ -8945,7 +9709,7 @@
89459709 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
89469710 } else
89479711 {
8948
- if (drawMode != DEFAULT)
9712
+ if (DrawMode() != DEFAULT)
89499713 {
89509714 gl.glClearColor(1, 1, 1, 0);
89519715 } // 1);
....@@ -9010,7 +9774,7 @@
90109774
90119775 fast &= !ambientOcclusion;
90129776
9013
- if (drawMode == DEFAULT)
9777
+ if (DrawMode() == DEFAULT)
90149778 {
90159779 //gl.glEnable(gl.GL_ALPHA_TEST);
90169780 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9071,6 +9835,8 @@
90719835 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
90729836 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
90739837 double scale = lightCamera.SCALE / lightCamera.Distance();
9838
+// PATCH FILLE AUX JEANS
9839
+ //scale *= lightCamera.shaper_fovy / 25;
90749840 gl.glScaled(2 * scale, 2 * scale, -scale);
90759841 gl.glTranslated(0, 0, lightCamera.DECAL);
90769842
....@@ -9206,10 +9972,12 @@
92069972 gl.glMatrixMode(gl.GL_PROJECTION);
92079973 gl.glLoadIdentity();
92089974
9209
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
9975
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
92109976 {
92119977 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
92129978 double scale = lightCamera.SCALE / lightCamera.Distance();
9979
+// PATCH FILLE AUX JEANS
9980
+ //scale *= lightCamera.shaper_fovy / 25;
92139981 gl.glScaled(2 * scale, 2 * scale, -scale);
92149982 gl.glTranslated(0, 0, lightCamera.DECAL);
92159983 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9262,7 +10030,7 @@
926210030 //gl.glPushMatrix();
926310031 gl.glLoadIdentity();
926410032
9265
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10033
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
926610034 {
926710035 //LA.xformPos(light0, lightCamera.fromScreen, light);
926810036 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9349,7 +10117,7 @@
934910117 }
935010118
935110119 /**/
9352
- if (true) // drawMode == SELECTION) // != DEFAULT)
10120
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
935310121 gl.glDisable(gl.GL_LIGHTING);
935410122 else
935510123 gl.glEnable(gl.GL_LIGHTING);
....@@ -9361,12 +10129,13 @@
936110129
936210130 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
936310131 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
10132
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
936410133
936510134 options2[0] *= renderCamera.Distance();
936610135
936710136 lightslot = 64;
936810137
9369
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10138
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
937010139 {
937110140 DrawLights(object);
937210141 }
....@@ -9377,7 +10146,7 @@
937710146 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
937810147 //System.out.println("fragmentMode = " + fragmentMode);
937910148
9380
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10149
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
938110150 {
938210151 /*
938310152 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9410,7 +10179,7 @@
941010179 }
941110180 }
941210181
9413
- if (drawMode == DEFAULT)
10182
+ if (DrawMode() == DEFAULT)
941410183 {
941510184 if (WIREFRAME && !ambientOcclusion)
941610185 {
....@@ -9428,7 +10197,7 @@
942810197 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
942910198 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
943010199
9431
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10200
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
943210201 {
943310202 if (vertexMode != 0) // && !fast)
943410203 {
....@@ -9448,7 +10217,7 @@
944810217 }
944910218 }
945010219
9451
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10220
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
945210221 {
945310222 //gl.glDepthFunc(GL.GL_LEQUAL);
945410223 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9476,7 +10245,7 @@
947610245 //gl.glDepthMask(false);
947710246 }
947810247
9479
- if (false) // drawMode == SHADOW)
10248
+ if (false) // DrawMode() == SHADOW)
948010249 {
948110250 //SetColumnMajorData(cameraInverseTransform, view_1);
948210251 //System.out.println("light = " + cameraInverseTransform);
....@@ -9490,16 +10259,16 @@
949010259 //System.out.println("object = " + object);
949110260 if (!frozen && !imageLocked)
949210261 {
9493
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10262
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
949410263 {
949510264 displayAntiAliased(gl);
949610265 } else
949710266 {
949810267 programcount = 0;
9499
- int keepmode = drawMode;
10268
+ int keepmode = DrawMode();
950010269 // if (DEBUG_SELECTION)
950110270 // {
9502
-// drawMode = SELECTION;
10271
+// DrawMode() = SELECTION;
950310272 // }
950410273 // for point selection
950510274 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9509,10 +10278,10 @@
950910278 DrawObject(gl);
951010279
951110280 // jan 2013 System.err.println("RESET ABORT (display)");
9512
- // if (drawMode == DEFAULT)
10281
+ // if (DrawMode() == DEFAULT)
951310282 // ABORTED = false;
951410283 fullreset = false;
9515
- drawMode = keepmode;
10284
+ Globals.drawMode = keepmode; // WARNING
951610285 //System.out.println("PROGRAM SWITCH " + programcount);
951710286 }
951810287 }
....@@ -9520,11 +10289,11 @@
952010289 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
952110290 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
952210291
9523
- if (drawMode == DEFAULT)
10292
+ if (DrawMode() == DEFAULT)
952410293 {
952510294 ReleaseTexture(NOISE_TEXTURE, false);
952610295 }
9527
- //if (drawMode == DEFAULT)
10296
+ //if (DrawMode() == DEFAULT)
952810297 {
952910298
953010299 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9536,7 +10305,7 @@
953610305 //else
953710306 //gl.glDisable(gl.GL_TEXTURE_2D);
953810307 //gl.glPopMatrix();
9539
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10308
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
954010309 {
954110310 //new Exception().printStackTrace();
954210311 //System.out.println("Draw image " + width + ", " + height);
....@@ -9578,7 +10347,7 @@
957810347 //gl.glFlush();
957910348 }
958010349
9581
- if (flash && drawMode == DEFAULT)
10350
+ if (flash && DrawMode() == DEFAULT)
958210351 {
958310352 flash = false;
958410353 wait = true;
....@@ -9586,9 +10355,9 @@
958610355 }
958710356
958810357 //drawing = false;
9589
- //if(drawMode == DEFAULT)
10358
+ //if(DrawMode() == DEFAULT)
959010359 // niceon = false;
9591
- if (drawMode == DEFAULT)
10360
+ if (DrawMode() == DEFAULT)
959210361 {
959310362 currentlydrawing = false;
959410363 }
....@@ -9608,7 +10377,7 @@
960810377 repaint();
960910378 }
961010379
9611
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10380
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
961210381 repaint();
961310382
961410383 displaydone = true;
....@@ -9642,10 +10411,10 @@
964210411 e.printStackTrace();
964310412 }
964410413
9645
- if (GraphreeD.RENDERME > 0)
9646
- GraphreeD.RENDERME--; // mechante magouille
10414
+ if (GrafreeD.RENDERME > 0)
10415
+ GrafreeD.RENDERME--; // mechante magouille
964710416
9648
- ONESTEP = false;
10417
+ Globals.ONESTEP = false;
964910418 }
965010419
965110420 static boolean zoomonce = false;
....@@ -9653,11 +10422,11 @@
965310422 void DrawObject(GL gl, boolean draw)
965410423 {
965510424 //System.out.println("DRAW OBJECT " + mouseDown);
9656
-// drawMode = SELECTION;
10425
+// DrawMode() = SELECTION;
965710426 //GL gl = getGL();
965810427 if ((TRACK || SHADOWTRACK) || zoomonce)
965910428 {
9660
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10429
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
966110430 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
966210431 pingthread.StepToTarget(true); // true);
966310432 // zoomonce = false;
....@@ -9678,9 +10447,9 @@
967810447 callist = gl.glGenLists(1);
967910448 }
968010449
9681
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10450
+ boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
968210451
9683
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10452
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
968410453
968510454 if (!mainDL || !active || touched)
968610455 {
....@@ -9707,7 +10476,7 @@
970710476 PushMatrix(ClickInfo.matbuffer);
970810477 }
970910478
9710
- if (drawMode == 0)
10479
+ if (DrawMode() == 0)
971110480 {
971210481 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
971310482
....@@ -9716,12 +10485,12 @@
971610485 BindTextures(DEFAULT_TEXTURES, 2);
971710486 }
971810487 //System.out.println("--> " + stackdepth);
9719
-// GraphreeD.traceon();
10488
+// GrafreeD.traceon();
972010489
972110490 // DRAW
972210491 object.draw(this, /*(Composite)*/ object, false, false);
972310492
9724
- if (drawMode == DEFAULT)
10493
+ if (DrawMode() == DEFAULT)
972510494 {
972610495 if (DEBUG)
972710496 {
....@@ -9732,34 +10501,48 @@
973210501 selectedpoint.radius = radius;
973310502 selectedpoint.recalculate();
973410503 selectedpoint.material = new cMaterial();
9735
- selectedpoint.material.color = 0.25f;
10504
+ selectedpoint.material.color = 0.15f; // Yellow
973610505 selectedpoint.material.modulation = 0.75f;
973710506
9738
- debugpoint.radius = radius;
9739
- debugpoint.recalculate();
9740
- debugpoint.material = new cMaterial();
9741
- debugpoint.material.color = 0.25f;
9742
- debugpoint.material.modulation = 0.75f;
10507
+ debugpointG.radius = radius;
10508
+ debugpointG.recalculate();
10509
+ debugpointG.material = new cMaterial();
10510
+ debugpointG.material.color = 0.25f; // Green
10511
+ debugpointG.material.modulation = 0.75f;
974310512
9744
- debugpoint2.radius = radius;
9745
- debugpoint2.recalculate();
9746
- debugpoint2.material = new cMaterial();
9747
- debugpoint2.material.color = 0.75f;
9748
- debugpoint2.material.modulation = 0.75f;
10513
+ debugpointP.radius = radius;
10514
+ debugpointP.recalculate();
10515
+ debugpointP.material = new cMaterial();
10516
+ debugpointP.material.color = 0.75f; // Purple
10517
+ debugpointP.material.modulation = 0.75f;
10518
+
10519
+ debugpointC.radius = radius;
10520
+ debugpointC.recalculate();
10521
+ debugpointC.material = new cMaterial();
10522
+ debugpointC.material.color = 0.5f; // Cyan
10523
+ debugpointC.material.modulation = 0.75f;
10524
+
10525
+ debugpointR.radius = radius;
10526
+ debugpointR.recalculate();
10527
+ debugpointR.material = new cMaterial();
10528
+ debugpointR.material.color = 0f; // Red
10529
+ debugpointR.material.modulation = 0.75f;
974910530
975010531 InitPoints(radius);
975110532 }
975210533 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9753
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9754
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9755
- DrawPoints(this);
10534
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
10535
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
10536
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
10537
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
10538
+ // DrawPoints(this);
975610539 }
975710540
975810541 // debugstuff.draw(this, /*(Composite)*/ null, false);
975910542 }
9760
-// GraphreeD.traceoff();
10543
+// GrafreeD.traceoff();
976110544 //System.out.println(stackdepth);
9762
- if (drawMode == 0)
10545
+ if (DrawMode() == 0)
976310546 {
976410547 ReleaseTextures(DEFAULT_TEXTURES);
976510548
....@@ -9784,17 +10567,19 @@
978410567
978510568 checker = null;
978610569
9787
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
10570
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
978810571 FindChecker(object);
978910572
9790
- if (checker != null && drawMode == DEFAULT)
10573
+ if (checker != null && DrawMode() == DEFAULT)
979110574 {
9792
- // BindTexture(IMMORTAL_TEXTURE);
10575
+ //BindTexture(IMMORTAL_TEXTURE);
10576
+ BindTextures(checker.GetTextures(), checker.texres);
979310577 // NEAREST
979410578 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
979510579 DrawChecker(gl);
979610580 //checker.Draw(this, null, false);
979710581 // ReleaseTexture(IMMORTAL_TEXTURE);
10582
+ ReleaseTextures(checker.GetTextures());
979810583 }
979910584
980010585 if (object.parent != null)
....@@ -9807,7 +10592,7 @@
980710592 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
980810593 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
980910594
9810
- if (DISPLAYTEXT && drawMode == DEFAULT)
10595
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
981110596 {
981210597 // Draw it once, then use the raster
981310598 Balloon(gl, balloon.createGraphics());
....@@ -9863,9 +10648,9 @@
986310648 int[] xs = new int[3];
986410649 int[] ys = new int[3];
986510650
9866
- void DrawString(Object3D obj) // String string)
10651
+ public void DrawString(Object3D obj) // String string) // INTERFACE
986710652 {
9868
- if (!DISPLAYTEXT || drawMode != DEFAULT)
10653
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
986910654 {
987010655 return;
987110656 }
....@@ -10253,7 +11038,7 @@
1025311038 return;
1025411039 }
1025511040
10256
- if (obj instanceof CheckerIG)
11041
+ if (obj instanceof Checker)
1025711042 {
1025811043 checker = obj;
1025911044
....@@ -10325,11 +11110,13 @@
1032511110 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1032611111 "PARAM params7 = program.env[7];" + // noise power, opacity power
1032711112 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10328
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
11113
+ "PARAM options1 = program.env[62];" + // fog rgb color
11114
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1032911115 "PARAM pointlight = program.env[127];" + // ...
1033011116 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1033111117 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1033211118 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
11119
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1033311120 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1033411121 "PARAM ten = { 10, 10, 10, 1.0 };" +
1033511122 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10350,6 +11137,7 @@
1035011137 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1035111138 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1035211139 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11140
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1035311141 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1035411142 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1035511143 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10390,6 +11178,10 @@
1039011178 "TEMP R1;" +
1039111179 "TEMP R2;" +
1039211180 "TEMP R3;" +
11181
+ "TEMP min;" +
11182
+ "TEMP max;" +
11183
+ "TEMP average;" +
11184
+ "TEMP saturation;" +
1039311185 "TEMP keep1;" +
1039411186 "TEMP keep2;" +
1039511187 "TEMP keep3;" +
....@@ -10920,10 +11712,40 @@
1092011712
1092111713 // skin?
1092211714 // Saturation for skin
10923
- /**/ // c'est ici
10924
- (Skinshader? "DP3 temp.x, final,one;" +
11715
+ /**/
11716
+ (Skinshader?
11717
+ "DP3 average.x, final,one;" +
11718
+ "MUL average, one3rd.xxxx,average.xxxx;" +
11719
+
11720
+ "MIN min.x, final.x,final.y;" +
11721
+ "MIN min.x, min.x,final.z;" +
11722
+
11723
+ "MAX max.x, final.x,final.y;" +
11724
+ "MAX max.x, max.x,final.z;" +
11725
+ "MOV max, max.xxxx;" +
11726
+
11727
+ "SUB saturation, max, final;" +
11728
+
11729
+ "ADD temp.x, max.x, one10th.x;" +
11730
+ "RCP temp.x, temp.x;" +
11731
+ "MUL temp.x, temp.x, half.x;" +
11732
+ "MUL saturation, saturation, temp.xxxx;" +
11733
+
11734
+ "DP3 ndotl.x, normald, light;" +
11735
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
11736
+
11737
+ "SUB temp.x, one.x, ndotl.x;" +
11738
+ "ADD temp.x, temp.x, options2.z;" + // lightsheen
11739
+ "ADD temp.y, one.y, options2.y;" + // sursurface
11740
+ "MUL temp.x, temp.x, temp.y;" +
11741
+
11742
+ "MUL saturation, saturation, temp.xxxx;" +
11743
+ "SUB_SAT temp, max, saturation;" +
11744
+/**
11745
+ "DP3 temp.x, final,one;" +
1092511746 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10926
- "SUB temp, final,R2;" +
11747
+ "SUB temp, final, R2;" +
11748
+
1092711749 // using light angle
1092811750 "DP3 ndotl.x, normald,light;" +
1092911751 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10936,7 +11758,6 @@
1093611758 // using light intensity
1093711759 "MOV ndotl.z, R2.x;" +
1093811760 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10939
-
1094011761 // june 2014
1094111762 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1094211763 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10948,6 +11769,7 @@
1094811769 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1094911770
1095011771 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
11772
+/**/
1095111773
1095211774 // "ADD final, R2,temp;" +
1095311775 "MOV final, temp;"
....@@ -11037,7 +11859,7 @@
1103711859 /**/
1103811860 // HDR
1103911861 "MOV temp.z, final.a;" +
11040
- "MUL final, final,options1.w;" +
11862
+ "MUL final, final,options2.x;" +
1104111863 "MOV final.a, temp.z;" +
1104211864 /**/
1104311865
....@@ -11074,10 +11896,17 @@
1107411896 "MOV final.z, zero.x;" +
1107511897 "MOV final.a, one.w;":""
1107611898 ) +
11899
+ /*
1107711900 (NORMALdebug?"MOV final.x, normal.x;" +
1107811901 "MOV final.y, normal.y;" +
1107911902 "MOV final.z, normal.z;" +
1108011903 "MOV final.a, one.w;":""
11904
+ ) +
11905
+ */
11906
+ (NORMALdebug?"SUB final.x, one.x, final.x;" +
11907
+ "SUB final.y, one.x, final.y;" +
11908
+ "SUB final.z, one.x, final.z;" +
11909
+ "MOV final.a, final.a;":""
1108111910 ) +
1108211911 // "MOV final, bumpmap;" +
1108311912 "MOV result.color, final;" +
....@@ -11223,6 +12052,7 @@
1122312052 String Shadow(String depth, String shadow)
1122412053 {
1122512054 return "MAX temp.x, ndotl.x, one64th.x;" +
12055
+ "MIN temp.x, temp.x, ninetenth.x;" +
1122612056 /**/
1122712057 // Sine
1122812058 "MUL temp.y, temp.x, temp.x;" +
....@@ -11847,9 +12677,10 @@
1184712677 return;
1184812678 }
1184912679
12680
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1185012681
1185112682 // TIMER
11852
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
12683
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1185312684 {
1185412685 keepboxmode = BOXMODE;
1185512686 keepsupport = SUPPORT;
....@@ -11978,7 +12809,7 @@
1197812809 // ObjEditor.tweenManager.update(1f / 60f);
1197912810
1198012811 // fev 2014???
11981
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
12812
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1198212813 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1198312814 pingthread.StepToTarget(true); // true);
1198412815 }
....@@ -12229,7 +13060,7 @@
1222913060 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1223013061 if (lightMode)
1223113062 {
12232
- lighttouched = true;
13063
+ Globals.lighttouched = true;
1223313064 }
1223413065
1223513066 if (OEILONCE && OEIL)
....@@ -12287,7 +13118,7 @@
1228713118 mouseDown = false;
1228813119 if (lightMode)
1228913120 {
12290
- lighttouched = true;
13121
+ Globals.lighttouched = true;
1229113122 }
1229213123 repaint();
1229313124 alreadypainted = true;
....@@ -12295,7 +13126,7 @@
1229513126 isMoving = false;
1229613127 } //??
1229713128
12298
- if (isLIVE() && !alreadypainted)
13129
+ if (Globals.isLIVE() && !alreadypainted)
1229913130 {
1230013131 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1230113132 repaint();
....@@ -12307,7 +13138,7 @@
1230713138 {
1230813139 if (lightMode)
1230913140 {
12310
- lighttouched = true;
13141
+ Globals.lighttouched = true;
1231113142 }
1231213143 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1231313144 }
....@@ -12550,6 +13381,7 @@
1255013381 {
1255113382 manipCamera.Translate(dx, dy, getWidth());
1255213383 }
13384
+ else
1255313385 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1255413386 {
1255513387 manipCamera.RotateInterest(dx, dy);
....@@ -12560,7 +13392,7 @@
1256013392
1256113393 if (manipCamera == lightCamera)
1256213394 {
12563
- lighttouched = true;
13395
+ Globals.lighttouched = true;
1256413396 }
1256513397 /*
1256613398 switch (mode)
....@@ -12775,13 +13607,15 @@
1277513607 {
1277613608 mouseMode |= ZOOM;
1277713609 }
12778
- if ((modifiers & META) == META)
13610
+
13611
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
13612
+ if (capsLocked || (modifiers & META) == META)
1277913613 {
1278013614 mouseMode |= VR; // BACKFORTH;
1278113615 }
1278213616 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1278313617 {
12784
- mouseMode |= SELECT; // BACKFORTH;
13618
+ mouseMode |= SELECT;
1278513619 }
1278613620 if ((modifiers & COMMAND) == COMMAND)
1278713621 {
....@@ -12789,6 +13623,7 @@
1278913623 }
1279013624 if ((modifiers & SHIFT) == SHIFT || forcetranslate)
1279113625 {
13626
+ mouseMode &= ~VR;
1279213627 mouseMode |= TRANSLATE;
1279313628 }
1279413629 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12945,7 +13780,7 @@
1294513780 case 'B':
1294613781 BRISMOOTH ^= true;
1294713782 SHADOWCULLFACE ^= true;
12948
- lighttouched = true;
13783
+ Globals.lighttouched = true;
1294913784 repaint();
1295013785 break;
1295113786 case 'b':
....@@ -13045,7 +13880,7 @@
1304513880 repaint();
1304613881 break;
1304713882 case 'O':
13048
- drawMode = OCCLUSION;
13883
+ Globals.drawMode = OCCLUSION; // WARNING
1304913884 repaint();
1305013885 break;
1305113886 case 'o':
....@@ -13136,7 +13971,7 @@
1313613971 break;
1313713972 case ' ':
1313813973 lightMode ^= true;
13139
- lighttouched = true;
13974
+ Globals.lighttouched = true;
1314013975 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1314113976 targetLookAt.set(manipCamera.lookAt);
1314213977 repaint();
....@@ -13148,11 +13983,11 @@
1314813983 repaint();
1314913984 break;
1315013985 case 'Z':
13151
- RESIZETEXTURE ^= true;
13152
- break;
13986
+ //RESIZETEXTURE ^= true;
13987
+ //break;
1315313988 case 'z':
1315413989 RENDERSHADOW ^= true;
13155
- lighttouched = true;
13990
+ Globals.lighttouched = true;
1315613991 repaint();
1315713992 break;
1315813993 //case UP:
....@@ -13178,7 +14013,8 @@
1317814013 FlipTransform();
1317914014 break;
1318014015 case ENTER:
13181
- object.editWindow.ScreenFit(); // Edit();
14016
+ // object.editWindow.ScreenFit(); // Edit();
14017
+ ToggleLive();
1318214018 break;
1318314019 case DELETE:
1318414020 ClearSelection();
....@@ -13753,6 +14589,7 @@
1375314589 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1375414590 }
1375514591
14592
+ // To avoid clear.
1375614593 public void update(Graphics g)
1375714594 {
1375814595 paint(g);
....@@ -14355,7 +15192,7 @@
1435515192 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1435615193 gl.glPushMatrix();
1435715194 gl.glLoadIdentity();
14358
- PushMatrix(checker.toParent);
15195
+ //PushMatrix(checker.toParent);
1435915196
1436015197 gl.glMatrixMode(GL.GL_TEXTURE);
1436115198 gl.glPushMatrix();
....@@ -14378,8 +15215,8 @@
1437815215
1437915216 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1438015217
14381
- float step = 0.1666f; //0.25f;
14382
- float stepv = step * 1652 / 998;
15218
+ float step = 2; // 0.1666f; //0.25f;
15219
+ float stepv = 2; // step * 1652 / 998;
1438315220
1438415221 int i0 = 0;
1438515222 /*
....@@ -14415,20 +15252,21 @@
1441515252 /**/
1441615253 //checker.GetMaterial().opacity = 1.1f;
1441715254 ////checker.GetMaterial().ambient = 0.99f;
14418
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14419
- Object3D.selectedstack[Object3D.materialdepth] = false;
14420
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15255
+ materialstack[materialdepth] = checker.material;
15256
+ selectedstack[materialdepth] = false;
15257
+ cStatic.objectstack[materialdepth++] = checker;
1442115258 //System.out.println("material " + material);
1442215259 //Applet3D.tracein(this, selected);
1442315260 vector2buffer = checker.projectedVertices;
1442415261
14425
- checker.GetMaterial().Draw(this, false); // true);
15262
+ //checker.GetMaterial().Draw(this, false); // true);
15263
+ DrawMaterial(checker.GetMaterial(), false); // true);
1442615264
14427
- Object3D.materialdepth -= 1;
14428
- if (Object3D.materialdepth > 0)
15265
+ materialdepth -= 1;
15266
+ if (materialdepth > 0)
1442915267 {
14430
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14431
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
15268
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15269
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1443215270 }
1443315271 //checker.GetMaterial().opacity = 1f;
1443415272 ////checker.GetMaterial().ambient = 1f;
....@@ -14449,15 +15287,27 @@
1444915287
1445015288 //float u = (i+1)/2;
1445115289 //float v = (j+1)/2;
14452
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
15290
+ if (checker.flipV)
15291
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
15292
+ else
15293
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1445315294 gl.glVertex3f(i, j, -0.5f);
1445415295
15296
+ if (checker.flipV)
15297
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
15298
+ else
1445515299 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1445615300 gl.glVertex3f(i + step, j, -0.5f);
1445715301
15302
+ if (checker.flipV)
15303
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
15304
+ else
1445815305 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1445915306 gl.glVertex3f(i + step, j + stepv, -0.5f);
1446015307
15308
+ if (checker.flipV)
15309
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
15310
+ else
1446115311 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1446215312 gl.glVertex3f(i, j + stepv, -0.5f);
1446315313 }
....@@ -14469,7 +15319,7 @@
1446915319 gl.glMatrixMode(GL.GL_PROJECTION);
1447015320 gl.glPopMatrix();
1447115321 gl.glMatrixMode(GL.GL_MODELVIEW);
14472
- PopMatrix(null); // checker.toParent); // null);
15322
+ //PopMatrix(null); // checker.toParent); // null);
1447315323 gl.glPopMatrix();
1447415324 PopTextureMatrix(checker.toParent);
1447515325 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14582,14 +15432,14 @@
1458215432
1458315433 //int tmp = selection_view;
1458415434 //selection_view = -1;
14585
- int temp = drawMode;
14586
- drawMode = SELECTION;
15435
+ int temp = DrawMode();
15436
+ Globals.drawMode = SELECTION; // WARNING
1458715437 indexcount = 0;
1458815438 parent.display(drawable);
1458915439 //selection_view = tmp;
1459015440 //if (temp == SELECTION)
1459115441 // temp = DEFAULT; // patch for selection debug
14592
- drawMode = temp;
15442
+ Globals.drawMode = temp; // WARNING
1459315443
1459415444 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1459515445
....@@ -14639,6 +15489,11 @@
1463915489 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1464015490 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1464115491
15492
+ // Will fit the mesh !!!
15493
+ selectedpoint.toParent[0][0] = 0.0001;
15494
+ selectedpoint.toParent[1][1] = 0.0001;
15495
+ selectedpoint.toParent[2][2] = 0.0001;
15496
+
1464215497 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1464315498
1464415499 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14682,16 +15537,16 @@
1468215537 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]));
1468315538 }
1468415539
14685
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
15540
+ previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
1468615541 }
1468715542 }
1468815543
1468915544 if (!movingcamera && !PAINTMODE)
1469015545 object.editWindow.ScreenFitPoint(); // fev 2014
1469115546
14692
- if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
15547
+ if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1469315548 {
14694
- Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
15549
+ Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1469515550
1469615551 Object3D group = new Object3D("inst" + paintcount++);
1469715552
....@@ -14857,14 +15712,14 @@
1485715712 //gl.glColorMask(false, false, false, false);
1485815713
1485915714 //render_scene_from_light_view(gl, drawable, 0, 0);
14860
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
15715
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1486115716 {
1486215717 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1486315718
14864
- int temp = drawMode;
14865
- drawMode = SHADOW;
15719
+ int temp = DrawMode();
15720
+ Globals.drawMode = SHADOW; // WARNING
1486615721 parent.display(drawable);
14867
- drawMode = temp;
15722
+ Globals.drawMode = temp; // WARNING
1486815723 }
1486915724
1487015725 gl.glCullFace(gl.GL_BACK);
....@@ -15027,13 +15882,19 @@
1502715882 gl.glFlush();
1502815883
1502915884 /**/
15030
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
15885
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1503115886
15032
- int[] pixels = occlusionsizebuffer.array();
15887
+ float[] pixels = occlusionsizebuffer.array();
1503315888
1503415889 double r = 0, g = 0, b = 0;
1503515890
1503615891 double count = 0;
15892
+
15893
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
15894
+
15895
+ float mindepth = 1;
15896
+
15897
+ double FACTOR = 1;
1503715898
1503815899 for (int i = 0; i < pixels.length; i++)
1503915900 {
....@@ -15118,7 +15979,7 @@
1511815979
1511915980 double scale = ray.z; // 1; // cos
1512015981
15121
- int p = pixels[newindex];
15982
+ float depth = pixels[newindex];
1512215983
1512315984 /*
1512415985 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15142,10 +16003,23 @@
1514216003 scale = (1 - modu) * modv;
1514316004 */
1514416005
15145
- r += ((p >> 16) & 0xFF) * scale / 255;
15146
- g += ((p >> 8) & 0xFF) * scale / 255;
15147
- b += (p & 0xFF) * scale / 255;
16006
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16007
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16008
+ //b += (p & 0xFF) * scale / 255;
16009
+
16010
+ if (mindepth > depth)
16011
+ {
16012
+ mindepth = depth;
16013
+ }
1514816014
16015
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16016
+
16017
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16018
+
16019
+ r += factor * scale;
16020
+ g += factor * scale;
16021
+ b += factor * scale;
16022
+
1514916023 count += scale;
1515016024 }
1515116025
....@@ -15243,12 +16117,6 @@
1524316117 GLUT glut = new GLUT();
1524416118
1524516119
15246
- static final public int DEFAULT = 0;
15247
- static final public int SELECTION = 1;
15248
- static final public int SHADOW = 2;
15249
- static final public int OCCLUSION = 3;
15250
- static
15251
- public int drawMode = DEFAULT;
1525216120 public boolean spherical = false;
1525316121 static boolean DEBUG_OCCLUSION = false;
1525416122 static boolean DEBUG_SELECTION = false;
....@@ -15261,10 +16129,12 @@
1526116129 int AAbuffersize = 0;
1526216130
1526316131 //double[] selectedpoint = new double[3];
15264
- static Sphere selectedpoint = new Sphere();
16132
+ static Superellipsoid selectedpoint = new Superellipsoid();
1526516133 static Sphere previousselectedpoint = null;
15266
- static Sphere debugpoint = new Sphere();
15267
- static Sphere debugpoint2 = new Sphere();
16134
+ static Sphere debugpointG = new Sphere();
16135
+ static Sphere debugpointP = new Sphere();
16136
+ static Sphere debugpointC = new Sphere();
16137
+ static Sphere debugpointR = new Sphere();
1526816138
1526916139 static Sphere debugpoints[] = new Sphere[8];
1527016140
....@@ -15317,7 +16187,8 @@
1531716187 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1531816188 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1531916189 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15320
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16190
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16191
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1532116192 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1532216193 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1532316194 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();