Normand Briere
2019-04-22 3c4c16e0a4ca3949a7a37a24607df7f89abfe7ea
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;
....@@ -165,12 +149,41 @@
165149 defaultcaps.setAccumBlueBits(16);
166150 defaultcaps.setAccumAlphaBits(16);
167151 }
152
+
168153 static CameraPane theRenderer;
169
-
154
+
170155 void SetAsGLRenderer(boolean b)
171156 {
172157 isRenderer = b;
173158 theRenderer = this;
159
+ }
160
+
161
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
162
+ {
163
+ super(defaultcaps, null, withcontext?glcontext:null, null);
164
+
165
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
166
+ glcontext = getContext();
167
+
168
+ cameras = new Camera[2];
169
+ targetLookAts = new cVector[2];
170
+
171
+ SetCamera(cam);
172
+
173
+ SetLight(new Camera(new cVector(10, 10, -20)));
174
+
175
+ object = o;
176
+
177
+ setBackground(Color.white);
178
+
179
+ addKeyListener(this);
180
+ addMouseListener(this);
181
+ addMouseMotionListener(this);
182
+ addMouseWheelListener(this);
183
+ //System.out.println("addGLEventListener: " + this);
184
+ addGLEventListener(this);
185
+
186
+// pingthread.start(); // may 2013
174187 }
175188
176189 static boolean AntialiasingEnabled()
....@@ -178,12 +191,19 @@
178191 return CURRENTANTIALIAS > 0;
179192 }
180193
181
- void ClearDepth()
194
+ /// INTERFACE
195
+
196
+ public boolean IsBoxMode()
197
+ {
198
+ return BOXMODE;
199
+ }
200
+
201
+ public void ClearDepth()
182202 {
183203 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184204 }
185205
186
- void DepthTest(boolean depthtest)
206
+ public void DepthTest(boolean depthtest)
187207 {
188208 if (depthtest)
189209 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +211,7 @@
191211 GetGL().glDepthFunc(GL.GL_ALWAYS);
192212 }
193213
194
- void DepthWrite(boolean depthwrite)
214
+ public void DepthWrite(boolean depthwrite)
195215 {
196216 if (depthwrite)
197217 GetGL().glDepthMask(true);
....@@ -199,12 +219,1265 @@
199219 GetGL().glDepthMask(false);
200220 }
201221
202
- void BackFaceCull(boolean bfc)
222
+ public void BackFaceCull(boolean bfc)
203223 {
204224 if (bfc)
205225 GetGL().glEnable(GetGL().GL_CULL_FACE);
206226 else
207227 GetGL().glDisable(GetGL().GL_CULL_FACE);
228
+ }
229
+
230
+ public boolean BackFaceCullMode()
231
+ {
232
+ return this.CULLFACE;
233
+ }
234
+
235
+ public boolean IsAmbientOcclusionOn()
236
+ {
237
+ return this.ambientOcclusion;
238
+ }
239
+
240
+ public boolean IsDebugSelection()
241
+ {
242
+ return DEBUG_SELECTION;
243
+ }
244
+
245
+ public boolean IsFrozen()
246
+ {
247
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
248
+
249
+ return !selectmode && cameracount == 0; // != 0;
250
+ }
251
+
252
+ // Currently in Globals
253
+ public int DrawMode()
254
+ {
255
+ return Globals.DrawMode();
256
+ }
257
+
258
+ public Camera EyeCamera()
259
+ {
260
+ return eyeCamera;
261
+ }
262
+
263
+ public Camera LightCamera()
264
+ {
265
+ return lightCamera;
266
+ }
267
+
268
+ public Camera ManipCamera()
269
+ {
270
+ return manipCamera;
271
+ }
272
+
273
+ public Camera RenderCamera()
274
+ {
275
+ return renderCamera;
276
+ }
277
+
278
+ public Camera[] Cameras()
279
+ {
280
+ return cameras;
281
+ }
282
+
283
+ public void PushMaterial(Object3D obj, boolean selected)
284
+ {
285
+ CameraPane display = this;
286
+ javax.media.opengl.GL gl = display.GetGL();
287
+ cMaterial material = obj.material;
288
+
289
+ if (material != null)
290
+ {
291
+ materialstack[materialdepth] = material;
292
+ selectedstack[materialdepth] = selected;
293
+ cStatic.objectstack[materialdepth++] = obj;
294
+ //System.out.println("material " + material);
295
+ //Applet3D.tracein(this, selected);
296
+ display.vector2buffer = obj.projectedVertices;
297
+ if (obj instanceof Camera)
298
+ {
299
+ display.options1[0] = material.shift;
300
+ //System.out.println("shift " + material.shift);
301
+ display.options1[1] = material.lightarea;
302
+ display.options1[2] = material.shadowbias;
303
+ display.options1[3] = material.aniso;
304
+ display.options1[4] = material.anisoV;
305
+ display.options2[0] = material.opacity;
306
+ display.options2[1] = material.diffuse;
307
+ display.options2[2] = material.factor;
308
+
309
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
310
+ display.options4[0] = material.cameralight/0.2f;
311
+ display.options4[1] = material.subsurface;
312
+ display.options4[2] = material.sheen;
313
+
314
+ // if (display.CURRENTANTIALIAS > 0)
315
+ // display.options3[3] /= 4;
316
+
317
+ /*
318
+ System.out.println("Focus = " + display.options1[0]);
319
+ System.out.println("Aperture = " + display.options1[1]);
320
+ System.out.println("ShadowBlur = " + display.options1[2]);
321
+ System.out.println("Antialiasing = " + display.options1[3]);
322
+ System.out.println("Fog = " + display.options2[0]);
323
+ System.out.println("Intensity = " + display.options2[1]);
324
+ System.out.println("Elevation = " + display.options2[2]);
325
+ /**/
326
+ } else
327
+ {
328
+ DrawMaterial(material, selected);
329
+ }
330
+ } else
331
+ {
332
+ if (selected && CameraPane.flash)
333
+ {
334
+ display.modelParams4[1] = 100;
335
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
336
+ }
337
+ }
338
+ }
339
+
340
+ public void PushMaterial2(Object3D obj, boolean selected)
341
+ {
342
+ CameraPane display = this;
343
+ cMaterial material = obj.material;
344
+
345
+ if (material != null)
346
+ {
347
+ materialstack[materialdepth] = material;
348
+ selectedstack[materialdepth] = selected;
349
+ cStatic.objectstack[materialdepth++] = obj;
350
+ //System.out.println("material " + material);
351
+ //Applet3D.tracein("selected ", selected);
352
+ display.vector2buffer = obj.projectedVertices;
353
+ display.DrawMaterial(material, selected);
354
+ }
355
+ }
356
+
357
+ public void PopMaterial(Object3D obj, boolean selected)
358
+ {
359
+ CameraPane display = this;
360
+ javax.media.opengl.GL gl = display.GetGL();
361
+ cMaterial material = obj.material;
362
+
363
+ //if (parent != null && parent.GetMaterial() != null)
364
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
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 if (selected && CameraPane.flash && obj.GetMaterial() != null)
375
+ {
376
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
377
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
378
+ }
379
+ }
380
+
381
+ public void PopMaterial2(Object3D obj)
382
+ {
383
+ CameraPane display = this;
384
+ cMaterial material = obj.material;
385
+
386
+ if (material != null)
387
+ {
388
+ materialdepth -= 1;
389
+ if (materialdepth > 0)
390
+ {
391
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
392
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
393
+ }
394
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
395
+ //else
396
+ //material.Draw(display, false);
397
+ }
398
+ }
399
+
400
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
401
+ {
402
+ CameraPane display = this;
403
+
404
+ if (pv.y == -10000 ||
405
+ qv.y == -10000 ||
406
+ rv.y == -10000)
407
+ return;
408
+
409
+// float b = f.nbiterations & 1;
410
+// float g = (f.nbiterations>>1) & 1;
411
+// float r = (f.nbiterations>>2) & 1;
412
+//
413
+// //if (f.weight == 10000)
414
+// //{
415
+// // r = 1; g = b = 0;
416
+// //}
417
+// //else
418
+// //{
419
+// // assert(f.weight < 10000);
420
+// r = g = b = (float)bRep.FaceWeight(f)*100;
421
+// if (r<0)
422
+// assert(r>=0);
423
+// //}
424
+
425
+ javax.media.opengl.GL gl = display.GetGL();
426
+
427
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
428
+
429
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
430
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
431
+ {
432
+ //gl.glBegin(gl.GL_TRIANGLES);
433
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
434
+ if (!hasnorm)
435
+ {
436
+ // System.out.println("FUCK!!");
437
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
438
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
439
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
440
+ LA.vecNormalize(obj.v2);
441
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
442
+ }
443
+
444
+ // P
445
+ float x = (float)pv.x;
446
+ float y = (float)pv.y;
447
+ float z = (float)pv.z;
448
+
449
+ if (hasnorm)
450
+ {
451
+// if (!pv.norm.normalized())
452
+// assert(pv.norm.normalized());
453
+
454
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
455
+ float nx = (float)pv.norm.x;
456
+ float ny = (float)pv.norm.y;
457
+ float nz = (float)pv.norm.z;
458
+
459
+ x += nx * obj.NORMALPUSH;
460
+ y += ny * obj.NORMALPUSH;
461
+ z += nz * obj.NORMALPUSH;
462
+
463
+ gl.glNormal3f(nx, ny, nz);
464
+ }
465
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
466
+ SetColor(obj, pv);
467
+ //gl.glColor4f(r, g, b, 1);
468
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
469
+ if (obj.flipV)
470
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
471
+ else
472
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
473
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
474
+
475
+ gl.glVertex3f(x, y, z);
476
+
477
+ // Q
478
+ x = (float)qv.x;
479
+ y = (float)qv.y;
480
+ z = (float)qv.z;
481
+
482
+// Print(pv);
483
+ if (hasnorm)
484
+ {
485
+// assert(qv.norm.normalized());
486
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
487
+ float nx = (float)qv.norm.x;
488
+ float ny = (float)qv.norm.y;
489
+ float nz = (float)qv.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
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
498
+ // boolean locked = false;
499
+ // float eps = 0.1f;
500
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
501
+
502
+ // int dot = 0; //*/ (int)f.dot;
503
+
504
+ // if ((dot&1) == 0)
505
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
506
+
507
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
508
+ if (obj.flipV)
509
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
510
+ else
511
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
512
+ // else
513
+ // {
514
+ // locked = true;
515
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
516
+ // }
517
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
518
+ SetColor(obj, qv);
519
+
520
+ gl.glVertex3f(x, y, z);
521
+ //gl.glColor4f(r, g, b, 1);
522
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
523
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
524
+// Print(qv);
525
+
526
+ // R
527
+ x = (float)rv.x;
528
+ y = (float)rv.y;
529
+ z = (float)rv.z;
530
+
531
+ if (hasnorm)
532
+ {
533
+// assert(rv.norm.normalized());
534
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
535
+ float nx = (float)rv.norm.x;
536
+ float ny = (float)rv.norm.y;
537
+ float nz = (float)rv.norm.z;
538
+
539
+ x += nx * obj.NORMALPUSH;
540
+ y += ny * obj.NORMALPUSH;
541
+ z += nz * obj.NORMALPUSH;
542
+
543
+ gl.glNormal3f(nx, ny, nz);
544
+ }
545
+
546
+ // if ((dot&4) == 0)
547
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
548
+
549
+ // if (wrap || !locked && (dot&8) != 0)
550
+ if (obj.flipV)
551
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
552
+ else
553
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
554
+ // else
555
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
556
+
557
+ // f.dot = dot;
558
+
559
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
560
+ SetColor(obj, rv);
561
+ //gl.glColor4f(r, g, b, 1);
562
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
563
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
564
+ gl.glVertex3f(x, y, z);
565
+// Print(rv);
566
+ //gl.glEnd();
567
+ }
568
+ else
569
+ {
570
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
571
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
572
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
573
+
574
+ }
575
+
576
+ if (false) // (attributes & WIREFRAME) != 0)
577
+ {
578
+ gl.glDisable(gl.GL_LIGHTING);
579
+
580
+ gl.glBegin(gl.GL_LINE_LOOP);
581
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
582
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
583
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
584
+ gl.glEnd();
585
+
586
+ gl.glEnable(gl.GL_LIGHTING);
587
+ }
588
+ }
589
+
590
+ /**
591
+ * <code>draw</code> renders a <code>TriMesh</code> object including
592
+ * it's normals, colors, textures and vertices.
593
+ *
594
+ * @see Renderer#draw(TriMesh)
595
+ * @param tris
596
+ * the mesh to render.
597
+ */
598
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
599
+ {
600
+ CameraPane display = this;
601
+
602
+ float r = display.modelParams0[0];
603
+ float g = display.modelParams0[1];
604
+ float b = display.modelParams0[2];
605
+ float opacity = display.modelParams5[1];
606
+
607
+ //final GL gl = GLU.getCurrentGL();
608
+ GL gl = display.GetGL(); // getGL();
609
+
610
+ FloatBuffer vertBuf = geo.vertBuf;
611
+
612
+ int v = vertBuf.capacity();
613
+
614
+ int count = 0;
615
+
616
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
617
+ gl.glEnable(gl.GL_CULL_FACE);
618
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
619
+ for (int i=0; i<v/3; i++)
620
+ {
621
+ int index3 = i*3;
622
+
623
+ if (geo.sizeBuf.get(index3+1) == 0)
624
+ continue;
625
+
626
+ count++;
627
+
628
+ int index4 = i*4;
629
+
630
+ float tx = vertBuf.get(index3);
631
+ float ty = vertBuf.get(index3+1);
632
+ float tz = vertBuf.get(index3+2);
633
+
634
+ // if (tx == 0 && ty == 0 && tz == 0)
635
+ // continue;
636
+
637
+ gl.glMatrixMode(gl.GL_TEXTURE);
638
+ gl.glPushMatrix();
639
+
640
+ float[] texmat = geo.texmat;
641
+ texmat[12] = texmat[13] = texmat[14] = i;
642
+
643
+ gl.glMultMatrixf(texmat, 0);
644
+
645
+ gl.glMatrixMode(gl.GL_MODELVIEW);
646
+ gl.glPushMatrix();
647
+
648
+ gl.glTranslatef(tx,ty,tz);
649
+
650
+ if (rotate)
651
+ gl.glRotatef(i, 0, 1, 0);
652
+
653
+ float size = geo.sizeBuf.get(index3) / 100;
654
+ gl.glScalef(size,size,size);
655
+
656
+ float cr = geo.colorBuf.get(index4);
657
+ float cg = geo.colorBuf.get(index4+1);
658
+ float cb = geo.colorBuf.get(index4+2);
659
+ float ca = geo.colorBuf.get(index4+3);
660
+
661
+ display.modelParams0[0] = r * cr;
662
+ display.modelParams0[1] = g * cg;
663
+ display.modelParams0[2] = b * cb;
664
+
665
+ display.modelParams5[1] = opacity * ca;
666
+
667
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
668
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
669
+
670
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
671
+ RandomNode.globalseed2 = RandomNode.globalseed;
672
+
673
+// gl.glColor4f(cr,cg,cb,ca);
674
+ // gl.glScalef(1024/16,1024/16,1024/16);
675
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
676
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
677
+ //gl.glTranslatef(-tx,-ty,-tz);
678
+ gl.glPopMatrix();
679
+
680
+ gl.glMatrixMode(gl.GL_TEXTURE);
681
+ gl.glPopMatrix();
682
+ }
683
+ // gl.glScalef(1024,1024,1024);
684
+ if (!cf)
685
+ gl.glDisable(gl.GL_CULL_FACE);
686
+
687
+ display.modelParams0[0] = r;
688
+ display.modelParams0[1] = g;
689
+ display.modelParams0[2] = b;
690
+
691
+ display.modelParams5[1] = opacity;
692
+
693
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
694
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
695
+
696
+ gl.glMatrixMode(gl.GL_MODELVIEW);
697
+
698
+// System.err.println("total = " + v/3 + "; displayed = " + count);
699
+ if (true)
700
+ return;
701
+
702
+//// if (!tris.predraw(this))
703
+//// {
704
+//// return;
705
+//// }
706
+//// if (Debug.stats)
707
+//// {
708
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
709
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
710
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
711
+//// }
712
+////
713
+//// if (tris.getDisplayListID() != -1)
714
+//// {
715
+//// renderDisplayList(tris);
716
+//// return;
717
+//// }
718
+////
719
+//// if (!generatingDisplayList)
720
+//// {
721
+//// applyStates(tris.states, tris);
722
+//// }
723
+//// if (Debug.stats)
724
+//// {
725
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
726
+//// }
727
+//// boolean transformed = doTransforms(tris);
728
+//
729
+// int glMode = GL.GL_TRIANGLES;
730
+// switch (getMode())
731
+// {
732
+// case Triangles:
733
+// glMode = GL.GL_TRIANGLES;
734
+// break;
735
+// case Strip:
736
+// glMode = GL.GL_TRIANGLE_STRIP;
737
+// break;
738
+// case Fan:
739
+// glMode = GL.GL_TRIANGLE_FAN;
740
+// break;
741
+// }
742
+//
743
+// if (!predrawGeometry(gl))
744
+// {
745
+// // make sure only the necessary indices are sent through on old
746
+// // cards.
747
+// IntBuffer indices = this.getIndexBuffer();
748
+// if (indices == null)
749
+// {
750
+// logger.severe("missing indices on geometry object: " + this.toString());
751
+// } else
752
+// {
753
+// indices.rewind();
754
+// indices.limit(this.getMaxIndex());
755
+//
756
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
757
+//
758
+// indices.clear();
759
+// }
760
+// } else
761
+// {
762
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
763
+// GL.GL_UNSIGNED_INT, 0);
764
+// }
765
+//
766
+//// postdrawGeometry(tris);
767
+//// if (transformed)
768
+//// {
769
+//// undoTransforms(tris);
770
+//// }
771
+////
772
+//// if (Debug.stats)
773
+//// {
774
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
775
+//// }
776
+//// tris.postdraw(this);
777
+ }
778
+
779
+ static Camera localcamera = new Camera();
780
+ static cVector from = new cVector();
781
+ static cVector to = new cVector();
782
+
783
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
784
+ {
785
+ CameraPane cp = this;
786
+
787
+ Camera keep = cp.RenderCamera();
788
+ cp.renderCamera = localcamera;
789
+
790
+ if (br.trimmed)
791
+ {
792
+ float[] colors = new float[br.positions.length / 3];
793
+
794
+ int i3 = 0;
795
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
796
+ {
797
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
798
+ continue;
799
+
800
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
801
+ to.set(br.positions[i3] + br.normals[i3],
802
+ br.positions[i3 + 1] + br.normals[i3 + 1],
803
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
804
+ LA.xformPos(from, transform, from);
805
+ LA.xformPos(to, transform, to); // RIGID ONLY
806
+ localcamera.setAim(from, to);
807
+
808
+ CameraPane.occlusionbuffer.display();
809
+
810
+ if (CameraPane.DEBUG_OCCLUSION)
811
+ cp.display(); // debug
812
+
813
+ colors[i] = cp.vertexOcclusion.r;
814
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
815
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
816
+
817
+ if ((i % 100) == 0 && i != 0)
818
+ {
819
+ CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
820
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
821
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
822
+ }
823
+ }
824
+
825
+ br.colors = colors;
826
+ }
827
+ else
828
+ {
829
+ for (int i = 0; i < br.VertexCount(); i++)
830
+ {
831
+ Vertex v = br.GetVertex(i);
832
+
833
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
834
+ continue;
835
+
836
+ from.set(v.x, v.y, v.z);
837
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
838
+ LA.xformPos(from, transform, from);
839
+ LA.xformPos(to, transform, to); // RIGID ONLY
840
+ localcamera.setAim(from, to);
841
+
842
+ CameraPane.occlusionbuffer.display();
843
+
844
+ if (CameraPane.DEBUG_OCCLUSION)
845
+ cp.display(); // debug
846
+
847
+ v.AO = cp.vertexOcclusion.r;
848
+
849
+ if ((i % 100) == 0 && i != 0)
850
+ {
851
+ CameraPane.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.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
854
+ }
855
+ }
856
+ }
857
+
858
+ //System.out.println("done.");
859
+
860
+ cp.renderCamera = keep;
861
+ }
862
+
863
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
864
+ {
865
+ CameraPane display = this;
866
+ pointFlow.CreateHT();
867
+
868
+ float r = display.modelParams0[0];
869
+ float g = display.modelParams0[1];
870
+ float b = display.modelParams0[2];
871
+ float opacity = display.modelParams5[1];
872
+
873
+ //final GL gl = GLU.getCurrentGL();
874
+ GL gl = display.GetGL(); // getGL();
875
+
876
+ int s = pointFlow.points.size();
877
+
878
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
879
+ gl.glEnable(gl.GL_CULL_FACE);
880
+
881
+ for (int i=s; --i>=0;)
882
+ //for (int i=0; i<s; i++)
883
+ {
884
+ cVector v = pointFlow.points.get(i);
885
+
886
+ double mindist = Double.MAX_VALUE;
887
+
888
+ double size = pointFlow.minimumSize;
889
+
890
+ double distancenext = 0;
891
+
892
+ if (i > 0)
893
+ {
894
+ cVector w = pointFlow.points.get(i-1);
895
+
896
+ double dist = w.distance(v);
897
+
898
+ distancenext = dist;
899
+
900
+ if (mindist > dist)
901
+ {
902
+ mindist = dist;
903
+ size = mindist*pointFlow.resizefactor;
904
+ }
905
+ }
906
+
907
+ if (i < s-1)
908
+ {
909
+ cVector w = pointFlow.points.get(i+1);
910
+
911
+ double dist = w.distance(v);
912
+
913
+ if (mindist > dist)
914
+ {
915
+ mindist = dist;
916
+ size = mindist*pointFlow.resizefactor;
917
+ }
918
+ }
919
+
920
+ if (size < pointFlow.minimumSize)
921
+ size = pointFlow.minimumSize;
922
+ if (size > pointFlow.maximumSize)
923
+ size = pointFlow.maximumSize;
924
+
925
+ double tx = v.x;
926
+ double ty = v.y;
927
+ double tz = v.z;
928
+
929
+ // if (tx == 0 && ty == 0 && tz == 0)
930
+ // continue;
931
+
932
+ gl.glMatrixMode(gl.GL_TEXTURE);
933
+ gl.glPushMatrix();
934
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
935
+
936
+ gl.glMultMatrixf(pointFlow.texmat, 0);
937
+
938
+ gl.glMatrixMode(gl.GL_MODELVIEW);
939
+ gl.glPushMatrix();
940
+
941
+ gl.glTranslated(tx,ty,tz);
942
+
943
+ gl.glScaled(size,size,size);
944
+
945
+// float cr = colorBuf.get(index4);
946
+// float cg = colorBuf.get(index4+1);
947
+// float cb = colorBuf.get(index4+2);
948
+// float ca = colorBuf.get(index4+3);
949
+//
950
+// display.modelParams0[0] = r * cr;
951
+// display.modelParams0[1] = g * cg;
952
+// display.modelParams0[2] = b * cb;
953
+//
954
+// display.modelParams5[1] = opacity * ca;
955
+//
956
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
957
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
958
+//
959
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
960
+// RandomNode.globalseed2 = RandomNode.globalseed;
961
+//
962
+//// gl.glColor4f(cr,cg,cb,ca);
963
+// // gl.glScalef(1024/16,1024/16,1024/16);
964
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
965
+
966
+ gl.glPopMatrix();
967
+
968
+ double step = size/4; //
969
+
970
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
971
+ continue;
972
+
973
+ int nbsteps = (int)(distancenext/step);
974
+
975
+ step = distancenext/nbsteps;
976
+
977
+ cVector next = pointFlow.points.get(i-1);
978
+
979
+ tmp.set(next);
980
+ tmp.sub(v);
981
+ tmp.normalize();
982
+ tmp.mul(step);
983
+
984
+ // calculate next size
985
+ mindist = Double.MAX_VALUE;
986
+
987
+ double nextsize = pointFlow.minimumSize;
988
+
989
+ if (i > 1)
990
+ {
991
+ cVector w = pointFlow.points.get(i-2);
992
+
993
+ double dist = w.distance(next);
994
+
995
+ if (mindist > dist)
996
+ {
997
+ mindist = dist;
998
+ nextsize = mindist*pointFlow.resizefactor;
999
+ }
1000
+ }
1001
+
1002
+ double dist = v.distance(next);
1003
+
1004
+ if (mindist > dist)
1005
+ {
1006
+ mindist = dist;
1007
+ nextsize = mindist*pointFlow.resizefactor;
1008
+ }
1009
+
1010
+ if (nextsize < pointFlow.minimumSize)
1011
+ nextsize = pointFlow.minimumSize;
1012
+ if (nextsize > pointFlow.maximumSize)
1013
+ nextsize = pointFlow.maximumSize;
1014
+ //
1015
+
1016
+ double count = 0;
1017
+
1018
+ while (distancenext > 0.000000001) // step
1019
+ {
1020
+ gl.glPushMatrix();
1021
+
1022
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1023
+
1024
+ double K = count/nbsteps;
1025
+
1026
+ double intersize = K*nextsize + (1-K)*size;
1027
+
1028
+ gl.glScaled(intersize,intersize,intersize);
1029
+
1030
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1031
+
1032
+ count++;
1033
+
1034
+ distancenext -= step;
1035
+
1036
+ gl.glPopMatrix();
1037
+ }
1038
+
1039
+ if (count != nbsteps)
1040
+ assert(count == nbsteps);
1041
+
1042
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1043
+ //gl.glTranslatef(-tx,-ty,-tz);
1044
+
1045
+ gl.glMatrixMode(gl.GL_TEXTURE);
1046
+ gl.glPopMatrix();
1047
+ }
1048
+
1049
+ if (!cf)
1050
+ gl.glDisable(gl.GL_CULL_FACE);
1051
+
1052
+// display.modelParams0[0] = r;
1053
+// display.modelParams0[1] = g;
1054
+// display.modelParams0[2] = b;
1055
+//
1056
+// display.modelParams5[1] = opacity;
1057
+//
1058
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1059
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1060
+
1061
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1062
+ }
1063
+
1064
+ /// INTERFACE
1065
+
1066
+ void SetColor(Object3D obj, Vertex p0)
1067
+ {
1068
+ CameraPane display = this;
1069
+ BoundaryRep bRep = obj.bRep;
1070
+
1071
+ if (RENDERPROGRAM == 0)
1072
+ {
1073
+ float r = 0;
1074
+ if (bRep != null)
1075
+ {
1076
+ if (bRep.stripified)
1077
+ {
1078
+ r = 1;
1079
+ }
1080
+ }
1081
+ float g = 0;
1082
+ if (bRep != null)
1083
+ {
1084
+ if (bRep.trimmed)
1085
+ {
1086
+ g = 1;
1087
+ }
1088
+ }
1089
+ float b = 0;
1090
+ if (obj.support != null && obj.link2master)
1091
+ {
1092
+ b = 1;
1093
+ }
1094
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1095
+ return;
1096
+ }
1097
+
1098
+ if (display.DrawMode() != CameraPane.SHADOW)
1099
+ return;
1100
+
1101
+ javax.media.opengl.GL gl = display.GetGL();
1102
+// if (true) return;
1103
+// float ao = p.AO;
1104
+//
1105
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1106
+// // ao = 1;
1107
+//
1108
+// gl.glColor4f(ao, ao, ao, 1);
1109
+
1110
+// CameraPane.selectedpoint.
1111
+// getAverage(cStatic.point1, true);
1112
+ if (CameraPane.pointflow == null) // !random) // live)
1113
+ {
1114
+ return;
1115
+ }
1116
+
1117
+ cStatic.point1.set(0,0,0);
1118
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1119
+
1120
+ cStatic.point1.sub(p0);
1121
+
1122
+
1123
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1124
+// {
1125
+// return;
1126
+// }
1127
+
1128
+ //if (true)
1129
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1130
+ {
1131
+ return;
1132
+ }
1133
+
1134
+ float[] colorV = new float[3];
1135
+
1136
+ if (false) // marked)
1137
+ {
1138
+ // debug rigging weights
1139
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1140
+ {
1141
+ float weight = p0.weights[object] / p0.totalweight;
1142
+
1143
+ // if (weight < 0.1)
1144
+ // {
1145
+ // assert(weight == 0);
1146
+ // continue;
1147
+ // }
1148
+
1149
+ if (p0.vertexlinks[object] == -1)
1150
+ continue;
1151
+
1152
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1153
+
1154
+ int color = //1 << object; //
1155
+ //p.vertexlinks.length;
1156
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1157
+ colorV[2] += (color & 1) * weight;
1158
+ colorV[1] += ((color & 2) >> 1) * weight;
1159
+ colorV[0] += ((color & 4) >> 2) * weight;
1160
+ }
1161
+ }
1162
+ else
1163
+ {
1164
+ if (obj.drawingstarted)
1165
+ {
1166
+ // find next point
1167
+ if (bRep.GetVertex(0).faceindices == null)
1168
+ {
1169
+ bRep.InitFaceIndices();
1170
+ }
1171
+
1172
+ double ymin = p0.y;
1173
+
1174
+ Vertex newp = p0;
1175
+
1176
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1177
+ {
1178
+ int fi = p0.faceindices[fii];
1179
+
1180
+ if (fi == -1)
1181
+ break;
1182
+
1183
+ Face f = bRep.GetFace(fi);
1184
+
1185
+ Vertex p = bRep.GetVertex(f.p);
1186
+ Vertex q = bRep.GetVertex(f.q);
1187
+ Vertex r = bRep.GetVertex(f.r);
1188
+
1189
+ int swap = (int)(Math.random()*3);
1190
+
1191
+// for (int s=swap; --s>=0;)
1192
+// {
1193
+// Vertex t = p;
1194
+// p = q;
1195
+// q = r;
1196
+// r = t;
1197
+// }
1198
+ if (ymin > p.y)
1199
+ {
1200
+ ymin = p.y;
1201
+ newp = p;
1202
+// break;
1203
+ }
1204
+ if (ymin > q.y)
1205
+ {
1206
+ ymin = q.y;
1207
+ newp = q;
1208
+// break;
1209
+ }
1210
+ if (ymin > r.y)
1211
+ {
1212
+ ymin = r.y;
1213
+ newp = r;
1214
+// break;
1215
+ }
1216
+ }
1217
+
1218
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1219
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1220
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1221
+
1222
+ obj.drawingstarted = false;
1223
+
1224
+ // return;
1225
+ }
1226
+
1227
+ if (false) // CameraPane.DRAW
1228
+ {
1229
+ p0.AO = colorV[0] = 2;
1230
+ colorV[1] = 2;
1231
+ colorV[2] = 2;
1232
+ }
1233
+
1234
+ CameraPane.pointflow.add(p0);
1235
+ CameraPane.pointflow.Touch();
1236
+ }
1237
+
1238
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1239
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1240
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1241
+ }
1242
+
1243
+ void DrawMaterial(cMaterial material, boolean selected)
1244
+ {
1245
+ CameraPane display = this;
1246
+ //new Exception().printStackTrace();
1247
+
1248
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1249
+ {
1250
+ return;
1251
+ }
1252
+
1253
+ javax.media.opengl.GL gl = display.GetGL();
1254
+
1255
+ //Color col = Color.getHSBColor(color,modulation,1);
1256
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1257
+ if (!material.multiply)
1258
+ {
1259
+ display.color = color;
1260
+ display.saturation = material.modulation;
1261
+ }
1262
+ else
1263
+ {
1264
+ display.color *= color*2;
1265
+ display.saturation *= material.modulation*2;
1266
+ }
1267
+
1268
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1269
+
1270
+ float[] colorV = GrafreeD.colorV;
1271
+
1272
+ /**/
1273
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1274
+ {
1275
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1276
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1277
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1278
+ colorV[3] = material.opacity;
1279
+
1280
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1281
+ //System.out.println("Opacity = " + opacity);
1282
+
1283
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1284
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1285
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1286
+
1287
+ float amb = material.ambient;
1288
+ if (amb < material.cameralight)
1289
+ {
1290
+ amb = material.cameralight;
1291
+ }
1292
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1293
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1294
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1295
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1296
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1297
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1298
+
1299
+ /**/
1300
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1301
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1302
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1303
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1304
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1305
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1306
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1307
+ //System.out.println("shininess = " + colorV[0]);
1308
+ if (colorV[0] > 128)
1309
+ {
1310
+ colorV[0] = 128;
1311
+ }
1312
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1313
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1314
+ /**/
1315
+ }
1316
+ /**/
1317
+
1318
+ //selected = false;
1319
+ selected = selected && display.flash;
1320
+
1321
+ //display.modelParams0[0] = 0; // pigment.r;
1322
+ //display.modelParams0[1] = 0; // pigment.g;
1323
+ //display.modelParams0[2] = 0; // pigment.b;
1324
+ if (!material.multiply)
1325
+ {
1326
+ display.modelParams0[3] = material.metalness;
1327
+ display.modelParams1[0] = material.diffuse;
1328
+ display.modelParams1[1] = material.specular;
1329
+ display.modelParams1[2] = 1 / material.shininess;
1330
+ display.modelParams1[3] = material.shift;
1331
+ display.modelParams2[0] = material.ambient;
1332
+ display.modelParams2[1] = material.lightarea;
1333
+ //System.out.println("light area = " + lightarea);
1334
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1335
+ display.modelParams2[3] = material.velvet;
1336
+ display.modelParams3[0] = material.sheen;
1337
+ display.modelParams3[1] = material.subsurface;
1338
+ display.modelParams3[2] = material.bump; // backlit
1339
+ display.modelParams3[3] = material.aniso;
1340
+ display.modelParams4[0] = material.anisoV;
1341
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1342
+ //System.out.println("selected = " + selected);
1343
+ display.modelParams4[2] = material.diffuseness;
1344
+ display.modelParams4[3] = material.shadow;
1345
+ display.modelParams5[0] = material.texture;
1346
+ display.modelParams5[1] = material.opacity;
1347
+ display.modelParams5[2] = material.fakedepth;
1348
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1349
+ }
1350
+ else
1351
+ {
1352
+ display.modelParams0[3] *= material.metalness*2;
1353
+ display.modelParams1[0] *= material.diffuse*2;
1354
+ display.modelParams1[1] *= material.specular*2;
1355
+ display.modelParams1[2] *= material.shininess*2;
1356
+ display.modelParams1[3] *= material.shift*2;
1357
+ display.modelParams2[0] *= material.ambient*2;
1358
+ display.modelParams2[1] *= material.lightarea*2;
1359
+ display.modelParams2[2] *= material.factor*2;
1360
+ display.modelParams2[3] *= material.velvet*2;
1361
+ display.modelParams3[0] *= material.sheen*2;
1362
+ display.modelParams3[1] *= material.subsurface*2;
1363
+ display.modelParams3[2] *= material.bump*2;
1364
+ display.modelParams3[3] *= material.aniso*2;
1365
+ display.modelParams4[0] *= material.anisoV*2;
1366
+ display.modelParams4[1] *= material.cameralight*2;
1367
+ //System.out.println("selected = " + selected);
1368
+ display.modelParams4[2] *= material.diffuseness*2;
1369
+ display.modelParams4[3] *= material.shadow*2;
1370
+ display.modelParams5[0] *= material.texture*2;
1371
+ display.modelParams5[1] *= material.opacity*2;
1372
+ display.modelParams5[2] *= material.fakedepth*2;
1373
+ display.modelParams5[3] *= material.shadowbias*2;
1374
+ }
1375
+
1376
+ display.modelParams6[0] = 0;
1377
+ display.modelParams6[1] = 0;
1378
+ display.modelParams6[2] = 0;
1379
+ display.modelParams6[3] = 0;
1380
+
1381
+ display.modelParams7[0] = 0;
1382
+ display.modelParams7[1] = 1000;
1383
+ display.modelParams7[2] = 0;
1384
+ display.modelParams7[3] = 0;
1385
+
1386
+ display.modelParams6[0] = 100; // criss de bug de bump
1387
+
1388
+ Object3D.cVector2[] extparams = display.vector2buffer;
1389
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1390
+ {
1391
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1392
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1393
+ if (extparams.length > 1)
1394
+ {
1395
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1396
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1397
+ if (extparams.length > 2)
1398
+ {
1399
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1400
+ float x = extparams[2].y / 1000.0f;
1401
+ //if (x == 0)
1402
+ // x = 1f;
1403
+ 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
1404
+ if (extparams[2].y > 0)
1405
+ {
1406
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1407
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1408
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1409
+ }
1410
+ }
1411
+ }
1412
+ }
1413
+
1414
+ //if (display.modelParams6[2] != 0)
1415
+ /*
1416
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1417
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1418
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1419
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1420
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1421
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1422
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1423
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1424
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1425
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1426
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1427
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1428
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1429
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1430
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1431
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1432
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1433
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1434
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1435
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1436
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1437
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1438
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1439
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1440
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1441
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1442
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1443
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1444
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1445
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1446
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1447
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1448
+ /**/
1449
+ //assert (display.modelParams6[2] == 0);
1450
+
1451
+ //System.out.println("noise power = " + display.modelParams7[0]);
1452
+ //System.out.println("shadowbias = " + shadowbias);
1453
+
1454
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1455
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1456
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1457
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1458
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1459
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1460
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1461
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1462
+
1463
+ int mode = display.FP_SHADER;
1464
+
1465
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1466
+ {
1467
+ mode |= display.FP_ANISO;
1468
+ }
1469
+
1470
+ display.EnableProgram(mode);
1471
+
1472
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1473
+
1474
+ if (!material.multiply)
1475
+ {
1476
+ if (Globals.drawMode == CameraPane.SHADOW)
1477
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1478
+ else
1479
+ gl.glDepthMask(material.opacity >= 0.99);
1480
+ }
2081481 }
2091482
2101483 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,10 +1498,10 @@
2251498 currentGL.glMultMatrixd(model, 0);
2261499 }
2271500
228
- void PushMatrix(double[][] matrix, int count)
1501
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291502 {
2301503 matrixdepth++;
231
- // GraphreeD.tracein(matrix);
1504
+ // GrafreeD.tracein(matrix);
2321505 if (matrix == null)
2331506 return; // Identity
2341507
....@@ -253,13 +1526,13 @@
2531526
2541527 void PushMatrix(double[][] matrix)
2551528 {
256
- // GraphreeD.tracein(matrix);
1529
+ // GrafreeD.tracein(matrix);
2571530 PushMatrix(matrix,1);
2581531 }
2591532
2601533 void PushMatrix()
2611534 {
262
- // GraphreeD.tracein(null);
1535
+ // GrafreeD.tracein(null);
2631536 if (matrixdepth++ < MAXSTACK - 1)
2641537 {
2651538 currentGL.glPushMatrix();
....@@ -270,11 +1543,11 @@
2701543
2711544 double[][] tmpmat = new double[4][4];
2721545
273
- void PopMatrix(double[][] inverse)
1546
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741547 {
2751548 --matrixdepth;
2761549
277
- // GraphreeD.traceout(inverse);
1550
+ // GrafreeD.traceout(inverse);
2781551 if (inverse == null)
2791552 return; // Identity
2801553
....@@ -292,7 +1565,7 @@
2921565
2931566 void PopMatrix()
2941567 {
295
- // GraphreeD.traceout(null);
1568
+ // GrafreeD.traceout(null);
2961569 // inverse == null??
2971570 if (--matrixdepth < MAXSTACK - 1)
2981571 {
....@@ -310,7 +1583,7 @@
3101583 PushTextureMatrix(matrix, 1);
3111584 }
3121585
313
- void PushTextureMatrix(double[][] matrix, int count)
1586
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141587 {
3151588 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161589
....@@ -324,7 +1597,7 @@
3241597 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251598 }
3261599
327
- void PopTextureMatrix(double[][] inverse)
1600
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281601 {
3291602 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301603 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -356,10 +1629,10 @@
3561629 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571630 // return false;
3581631
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1632
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601633 {
3611634 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1635
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631636 {
3641637 // refuse the camera change
3651638 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +1640,7 @@
3671640 }
3681641 }
3691642
370
- camerachangeframe = framecount;
1643
+ camerachangeframe = Globals.framecount;
3711644
3721645 cam.hAspect = -1; // Read only
3731646
....@@ -398,7 +1671,7 @@
3981671 {
3991672 //System.err.println("Oeil on");
4001673 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1674
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4021675 // object.editWindow.ScreenFit(trackedobject);
4031676 //pingthread.StepToTarget(true);
4041677 }
....@@ -407,7 +1680,7 @@
4071680 {
4081681 //System.err.println("Oeil on");
4091682 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1683
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4111684 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4121685 //pingthread.StepToTarget(true);
4131686 }
....@@ -471,7 +1744,7 @@
4711744 {
4721745 frozen ^= true;
4731746 // Weird...
474
- lighttouched = true;
1747
+ Globals.lighttouched = true;
4751748 }
4761749
4771750 void ToggleDL()
....@@ -486,12 +1759,12 @@
4861759
4871760 void ToggleLive()
4881761 {
489
- setLIVE(isLIVE() ^ true);
1762
+ Globals.setLIVE(Globals.isLIVE() ^ true);
4901763
491
- System.err.println("LIVE = " + isLIVE());
1764
+ System.err.println("LIVE = " + Globals.isLIVE());
4921765
493
- if (!isLIVE()) // save sound
494
- GraphreeD.savesound = true; // wav.save();
1766
+ if (!Globals.isLIVE()) // save sound
1767
+ GrafreeD.savesound = true; // wav.save();
4951768 // else
4961769 repaint(); // start loop // may 2013
4971770 }
....@@ -513,7 +1786,7 @@
5131786
5141787 void ToggleCrowd()
5151788 {
516
- CROWD ^= true;
1789
+ Globals.CROWD ^= true;
5171790 }
5181791
5191792 void ToggleInertia()
....@@ -674,34 +1947,6 @@
6741947 lightCamera = cam;
6751948 }
6761949
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
-
7051950 private static void ApplyTransform(GL gl, Mat4f xform)
7061951 {
7071952 float[] data = new float[16];
....@@ -759,7 +2004,7 @@
7592004
7602005 GL currentGL;
7612006
762
- GL GetGL()
2007
+ public GL GetGL() // INTERFACE
7632008 {
7642009 return currentGL;
7652010 }
....@@ -768,6 +2013,8 @@
7682013 class CacheTexture
7692014 {
7702015 com.sun.opengl.util.texture.Texture texture;
2016
+ com.sun.opengl.util.texture.TextureData texturedata;
2017
+
7712018 int resolution;
7722019
7732020 CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
....@@ -1998,10 +3245,12 @@
19983245 */
19993246 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20003247 {
3248
+ int pixelformat = texturedata.getPixelFormat();
3249
+
20013250 int stride = 1;
2002
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
3251
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20033252 stride = 3;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
3253
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20053254 stride = 4;
20063255
20073256 int width = texturedata.getWidth();
....@@ -6267,7 +7516,7 @@
62677516 return null;
62687517 }
62697518
6270
- void ReleaseTextures(cTexture tex)
7519
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62717520 {
62727521 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62737522 {
....@@ -6305,7 +7554,7 @@
63057554
63067555 void ReleaseTexture(String tex, boolean bump)
63077556 {
6308
- if (// drawMode != 0 || /*tex == null ||*/
7557
+ if (// DrawMode() != 0 || /*tex == null ||*/
63097558 ambientOcclusion ) // || !textureon)
63107559 {
63117560 return;
....@@ -6331,7 +7580,7 @@
63317580 {
63327581 bumpdepth--;
63337582
6334
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7583
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63357584 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63367585 {
63377586 // assert (bumpstack[bumpdepth] == texture);
....@@ -6361,7 +7610,7 @@
63617610 {
63627611 pigmentdepth--;
63637612
6364
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7613
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63657614 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63667615 {
63677616 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6406,9 +7655,9 @@
64067655 }
64077656 }
64087657
6409
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7658
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64107659 {
6411
- if (// drawMode != 0 || /*tex == null ||*/
7660
+ if (// DrawMode() != 0 || /*tex == null ||*/
64127661 ambientOcclusion ) // || !textureon)
64137662 {
64147663 return; // false;
....@@ -6451,7 +7700,7 @@
64517700 return; // true;
64527701 }
64537702
6454
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
7703
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
64557704 {
64567705 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64577706
....@@ -6665,6 +7914,8 @@
66657914 thetex.texture.dispose();
66667915 textures.remove(texname);
66677916 }
7917
+
7918
+ texture.texturedata = texturedata;
66687919 textures.put(texname, texture);
66697920
66707921 // newtex = true;
....@@ -6681,18 +7932,32 @@
66817932 }
66827933 }
66837934
7935
+ return texture;
7936
+ }
7937
+
7938
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
7939
+ {
7940
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
7941
+
66847942 if (bump)
66857943 {
6686
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
7944
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66877945 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66887946 }
66897947 else
66907948 {
6691
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
7949
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
66927950 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
66937951 }
66947952
66957953 return texture!=null?texture.texture:null;
7954
+ }
7955
+
7956
+ com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
7957
+ {
7958
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
7959
+
7960
+ return texture!=null?texture.texturedata:null;
66967961 }
66977962
66987963 boolean BindTexture(String tex, boolean bump, int resolution)
....@@ -7292,9 +8557,9 @@
72928557 static boolean occlusionInitialized = false;
72938558 boolean selection = false;
72948559 boolean pointselection = false;
7295
- /*static*/ boolean lighttouched = true;
8560
+ ///*static*/ boolean lighttouched = true;
72968561 boolean deselect;
7297
- boolean ambientOcclusion = false;
8562
+ private boolean ambientOcclusion = false;
72988563 static boolean flash = false;
72998564 /*static*/ boolean wait = false;
73008565 boolean displaydone = false; // after repaint() calls
....@@ -7424,6 +8689,8 @@
74248689 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74258690 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74268691 double scale = lightCamera.SCALE / lightCamera.Distance();
8692
+// PATCH FILLE AUX JEANS
8693
+ //scale *= lightCamera.shaper_fovy / 25;
74278694 gl.glScaled(2 * scale, 2 * scale, -scale);
74288695 gl.glTranslated(0, 0, lightCamera.DECAL);
74298696
....@@ -7572,15 +8839,14 @@
75728839
75738840 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75748841 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
8842
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
8843
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75768844
75778845 static int imagecount = 0; // movie generation
75788846
75798847 static int jitter = 0;
75808848
75818849 boolean restartframe = false;
7582
-
7583
- static int framecount = 0; // general-purpose global count
75848850
75858851 void displayAntiAliased(javax.media.opengl.GL gl)
75868852 {
....@@ -7610,14 +8876,14 @@
76108876
76118877 //System.out.println("start frame");
76128878 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7613
- for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0)
8879
+ for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76148880 {
7615
- framecount++;
8881
+ Globals.framecount++;
76168882
76178883 if (CameraPane.tickcount > 0)
76188884 CameraPane.tickcount--;
76198885
7620
-// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
8886
+// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
76218887 // restartframe = true;
76228888 if (options1[2] > 100 && (jitter%2==0))
76238889 {
....@@ -7650,7 +8916,7 @@
76508916
76518917 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76528918 */
7653
- lighttouched = true;
8919
+ Globals.lighttouched = true;
76548920 //System.err.println(" shadowbuffer: " + jitter);
76558921 shadowbuffer.display();
76568922
....@@ -7672,7 +8938,7 @@
76728938
76738939 if (renderCamera != lightCamera)
76748940 for (int count = parentcam.GetTransformCount(); --count>=0;)
7675
- LA.matConcat(parentcam.toParent, matrix, matrix);
8941
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76768942
76778943 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76788944
....@@ -7688,7 +8954,7 @@
76888954
76898955 if (renderCamera != lightCamera)
76908956 for (int count = parentcam.GetTransformCount(); --count>=0;)
7691
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8957
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
76928958
76938959 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
76948960
....@@ -7905,7 +9171,7 @@
79059171
79069172 if (!BOXMODE)
79079173 {
7908
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
9174
+ System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
79099175 }
79109176
79119177 if (!BOXMODE)
....@@ -7933,7 +9199,7 @@
79339199 {
79349200 if (ACSIZE > 1)
79359201 {
7936
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
9202
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79379203 }
79389204 }
79399205
....@@ -7943,7 +9209,7 @@
79439209 ABORTED = false;
79449210 }
79459211 else
7946
- GraphreeD.wav.cursor += 735 * ACSIZE;
9212
+ GrafreeD.wav.cursor += 735 * ACSIZE;
79479213
79489214 if (false)
79499215 {
....@@ -8597,13 +9863,6 @@
85979863 }
85989864 }
85999865
8600
- boolean IsFrozen()
8601
- {
8602
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8603
-
8604
- return !selectmode && cameracount == 0; // != 0;
8605
- }
8606
-
86079866 boolean niceon = false;
86089867 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86099868 boolean currentlydrawing = false;
....@@ -8613,16 +9872,16 @@
86139872
86149873 public void display(GLAutoDrawable drawable)
86159874 {
8616
- if (GraphreeD.savesound && GraphreeD.hassound)
9875
+ if (GrafreeD.savesound && GrafreeD.hassound)
86179876 {
8618
- GraphreeD.wav.save();
8619
- GraphreeD.savesound = false;
8620
- GraphreeD.hassound = false;
9877
+ GrafreeD.wav.save();
9878
+ GrafreeD.savesound = false;
9879
+ GrafreeD.hassound = false;
86219880 }
86229881 // if (DEBUG_SELECTION)
86239882 // {
8624
-// if (drawMode != SELECTION)
8625
-// drawMode = SELECTION;
9883
+// if (DrawMode() != SELECTION)
9884
+// DrawMode() = SELECTION;
86269885 // }
86279886
86289887 if (!isRenderer)
....@@ -8678,9 +9937,9 @@
86789937
86799938 //ANTIALIAS = 0;
86809939
8681
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9940
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
86829941 {
8683
- if (niceon || isLIVE())
9942
+ if (niceon || Globals.isLIVE())
86849943 {
86859944 //if(active == 0)
86869945 // antialiaser = null;
....@@ -8705,7 +9964,7 @@
87059964 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87069965 */
87079966
8708
- if (drawMode == DEFAULT)
9967
+ if (DrawMode() == DEFAULT)
87099968 {
87109969 currentlydrawing = true;
87119970 }
....@@ -8736,18 +9995,18 @@
87369995
87379996 // if(Applet3D.clipboard != null)
87389997 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8739
-//drawMode = SELECTION;
9998
+//DrawMode() = SELECTION;
87409999 indexcount = 0;
874110000
8742
- if (drawMode == OCCLUSION)
10001
+ if (DrawMode() == OCCLUSION)
874310002 {
8744
- drawMode = DEFAULT;
10003
+ Globals.drawMode = DEFAULT; // WARNING
874510004 ambientOcclusion = true;
874610005 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
874710006 Object3D theobject = object;
874810007 Object3D theparent = object.parent;
874910008 object.parent = null;
8750
- object = (Object3D)GraphreeD.clone(object);
10009
+ object = (Object3D)GrafreeD.clone(object);
875110010 object.Stripify();
875210011 if (theobject.selection == null || theobject.selection.Size() == 0)
875310012 theobject.PreprocessOcclusion(this);
....@@ -8760,19 +10019,19 @@
876010019 ambientOcclusion = false;
876110020 }
876210021
8763
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10022
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
876410023 {
876510024 //if (RENDERSHADOW) // ?
876610025 if (!IsFrozen())
876710026 {
876810027 // dec 2012
8769
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10028
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
877010029 {
8771
- framecount++;
10030
+ Globals.framecount++;
877210031 shadowbuffer.display();
877310032 }
877410033 }
8775
- lighttouched = false; // ??
10034
+ Globals.lighttouched = false; // ??
877610035 //drawing = true;
877710036 //lighttouched = true;
877810037 }
....@@ -8793,9 +10052,9 @@
879310052 //eyeCamera.shaper_fovy = 1;
879410053 }
879510054
8796
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10055
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
879710056 {
8798
- //System.out.println("drawMode = " + drawMode);
10057
+ //System.out.println("DrawMode() = " + DrawMode());
879910058 vertexMode |= VP_PASS;
880010059 //vertexMode |= VP_PROJECTION;
880110060 if (!ambientOcclusion)
....@@ -8855,7 +10114,7 @@
885510114 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
885610115 //Camera lightcam = new Camera(light0);
885710116
8858
- if (drawMode == SHADOW)
10117
+ if (DrawMode() == SHADOW)
885910118 {
886010119 /*
886110120 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8894,7 +10153,7 @@
889410153 // if (parentcam != renderCamera) // not a light
889510154 if (cam != lightCamera)
889610155 for (int count = parentcam.GetTransformCount(); --count>=0;)
8897
- LA.matConcat(parentcam.toParent, matrix, matrix);
10156
+ LA.matConcat(matrix, parentcam.toParent, matrix);
889810157
889910158 for (int j = 0; j < 4; j++)
890010159 {
....@@ -8909,7 +10168,7 @@
890910168 // if (parentcam != renderCamera) // not a light
891010169 if (cam != lightCamera)
891110170 for (int count = parentcam.GetTransformCount(); --count>=0;)
8912
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10171
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
891310172
891410173 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
891510174
....@@ -8945,7 +10204,7 @@
894510204 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
894610205 } else
894710206 {
8948
- if (drawMode != DEFAULT)
10207
+ if (DrawMode() != DEFAULT)
894910208 {
895010209 gl.glClearColor(1, 1, 1, 0);
895110210 } // 1);
....@@ -9010,7 +10269,7 @@
901010269
901110270 fast &= !ambientOcclusion;
901210271
9013
- if (drawMode == DEFAULT)
10272
+ if (DrawMode() == DEFAULT)
901410273 {
901510274 //gl.glEnable(gl.GL_ALPHA_TEST);
901610275 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9071,6 +10330,8 @@
907110330 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
907210331 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
907310332 double scale = lightCamera.SCALE / lightCamera.Distance();
10333
+// PATCH FILLE AUX JEANS
10334
+ //scale *= lightCamera.shaper_fovy / 25;
907410335 gl.glScaled(2 * scale, 2 * scale, -scale);
907510336 gl.glTranslated(0, 0, lightCamera.DECAL);
907610337
....@@ -9206,10 +10467,12 @@
920610467 gl.glMatrixMode(gl.GL_PROJECTION);
920710468 gl.glLoadIdentity();
920810469
9209
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10470
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
921010471 {
921110472 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
921210473 double scale = lightCamera.SCALE / lightCamera.Distance();
10474
+// PATCH FILLE AUX JEANS
10475
+ //scale *= lightCamera.shaper_fovy / 25;
921310476 gl.glScaled(2 * scale, 2 * scale, -scale);
921410477 gl.glTranslated(0, 0, lightCamera.DECAL);
921510478 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9262,7 +10525,7 @@
926210525 //gl.glPushMatrix();
926310526 gl.glLoadIdentity();
926410527
9265
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10528
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
926610529 {
926710530 //LA.xformPos(light0, lightCamera.fromScreen, light);
926810531 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9349,7 +10612,7 @@
934910612 }
935010613
935110614 /**/
9352
- if (true) // drawMode == SELECTION) // != DEFAULT)
10615
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
935310616 gl.glDisable(gl.GL_LIGHTING);
935410617 else
935510618 gl.glEnable(gl.GL_LIGHTING);
....@@ -9361,12 +10624,13 @@
936110624
936210625 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
936310626 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
10627
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
936410628
936510629 options2[0] *= renderCamera.Distance();
936610630
936710631 lightslot = 64;
936810632
9369
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10633
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
937010634 {
937110635 DrawLights(object);
937210636 }
....@@ -9377,7 +10641,7 @@
937710641 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
937810642 //System.out.println("fragmentMode = " + fragmentMode);
937910643
9380
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10644
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
938110645 {
938210646 /*
938310647 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9410,7 +10674,7 @@
941010674 }
941110675 }
941210676
9413
- if (drawMode == DEFAULT)
10677
+ if (DrawMode() == DEFAULT)
941410678 {
941510679 if (WIREFRAME && !ambientOcclusion)
941610680 {
....@@ -9428,7 +10692,7 @@
942810692 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
942910693 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
943010694
9431
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10695
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
943210696 {
943310697 if (vertexMode != 0) // && !fast)
943410698 {
....@@ -9448,7 +10712,7 @@
944810712 }
944910713 }
945010714
9451
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10715
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
945210716 {
945310717 //gl.glDepthFunc(GL.GL_LEQUAL);
945410718 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9476,7 +10740,7 @@
947610740 //gl.glDepthMask(false);
947710741 }
947810742
9479
- if (false) // drawMode == SHADOW)
10743
+ if (false) // DrawMode() == SHADOW)
948010744 {
948110745 //SetColumnMajorData(cameraInverseTransform, view_1);
948210746 //System.out.println("light = " + cameraInverseTransform);
....@@ -9490,16 +10754,16 @@
949010754 //System.out.println("object = " + object);
949110755 if (!frozen && !imageLocked)
949210756 {
9493
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10757
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
949410758 {
949510759 displayAntiAliased(gl);
949610760 } else
949710761 {
949810762 programcount = 0;
9499
- int keepmode = drawMode;
10763
+ int keepmode = DrawMode();
950010764 // if (DEBUG_SELECTION)
950110765 // {
9502
-// drawMode = SELECTION;
10766
+// DrawMode() = SELECTION;
950310767 // }
950410768 // for point selection
950510769 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9509,10 +10773,10 @@
950910773 DrawObject(gl);
951010774
951110775 // jan 2013 System.err.println("RESET ABORT (display)");
9512
- // if (drawMode == DEFAULT)
10776
+ // if (DrawMode() == DEFAULT)
951310777 // ABORTED = false;
951410778 fullreset = false;
9515
- drawMode = keepmode;
10779
+ Globals.drawMode = keepmode; // WARNING
951610780 //System.out.println("PROGRAM SWITCH " + programcount);
951710781 }
951810782 }
....@@ -9520,11 +10784,11 @@
952010784 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
952110785 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
952210786
9523
- if (drawMode == DEFAULT)
10787
+ if (DrawMode() == DEFAULT)
952410788 {
952510789 ReleaseTexture(NOISE_TEXTURE, false);
952610790 }
9527
- //if (drawMode == DEFAULT)
10791
+ //if (DrawMode() == DEFAULT)
952810792 {
952910793
953010794 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9536,7 +10800,7 @@
953610800 //else
953710801 //gl.glDisable(gl.GL_TEXTURE_2D);
953810802 //gl.glPopMatrix();
9539
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10803
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
954010804 {
954110805 //new Exception().printStackTrace();
954210806 //System.out.println("Draw image " + width + ", " + height);
....@@ -9578,7 +10842,7 @@
957810842 //gl.glFlush();
957910843 }
958010844
9581
- if (flash && drawMode == DEFAULT)
10845
+ if (flash && DrawMode() == DEFAULT)
958210846 {
958310847 flash = false;
958410848 wait = true;
....@@ -9586,9 +10850,9 @@
958610850 }
958710851
958810852 //drawing = false;
9589
- //if(drawMode == DEFAULT)
10853
+ //if(DrawMode() == DEFAULT)
959010854 // niceon = false;
9591
- if (drawMode == DEFAULT)
10855
+ if (DrawMode() == DEFAULT)
959210856 {
959310857 currentlydrawing = false;
959410858 }
....@@ -9608,7 +10872,7 @@
960810872 repaint();
960910873 }
961010874
9611
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10875
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
961210876 repaint();
961310877
961410878 displaydone = true;
....@@ -9642,10 +10906,10 @@
964210906 e.printStackTrace();
964310907 }
964410908
9645
- if (GraphreeD.RENDERME > 0)
9646
- GraphreeD.RENDERME--; // mechante magouille
10909
+ if (GrafreeD.RENDERME > 0)
10910
+ GrafreeD.RENDERME--; // mechante magouille
964710911
9648
- ONESTEP = false;
10912
+ Globals.ONESTEP = false;
964910913 }
965010914
965110915 static boolean zoomonce = false;
....@@ -9653,11 +10917,11 @@
965310917 void DrawObject(GL gl, boolean draw)
965410918 {
965510919 //System.out.println("DRAW OBJECT " + mouseDown);
9656
-// drawMode = SELECTION;
10920
+// DrawMode() = SELECTION;
965710921 //GL gl = getGL();
965810922 if ((TRACK || SHADOWTRACK) || zoomonce)
965910923 {
9660
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10924
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
966110925 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
966210926 pingthread.StepToTarget(true); // true);
966310927 // zoomonce = false;
....@@ -9678,9 +10942,9 @@
967810942 callist = gl.glGenLists(1);
967910943 }
968010944
9681
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10945
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
968210946
9683
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10947
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
968410948
968510949 if (!mainDL || !active || touched)
968610950 {
....@@ -9707,7 +10971,7 @@
970710971 PushMatrix(ClickInfo.matbuffer);
970810972 }
970910973
9710
- if (drawMode == 0)
10974
+ if (DrawMode() == 0)
971110975 {
971210976 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
971310977
....@@ -9716,12 +10980,12 @@
971610980 BindTextures(DEFAULT_TEXTURES, 2);
971710981 }
971810982 //System.out.println("--> " + stackdepth);
9719
-// GraphreeD.traceon();
10983
+// GrafreeD.traceon();
972010984
972110985 // DRAW
972210986 object.draw(this, /*(Composite)*/ object, false, false);
972310987
9724
- if (drawMode == DEFAULT)
10988
+ if (DrawMode() == DEFAULT)
972510989 {
972610990 if (DEBUG)
972710991 {
....@@ -9732,34 +10996,48 @@
973210996 selectedpoint.radius = radius;
973310997 selectedpoint.recalculate();
973410998 selectedpoint.material = new cMaterial();
9735
- selectedpoint.material.color = 0.25f;
10999
+ selectedpoint.material.color = 0.15f; // Yellow
973611000 selectedpoint.material.modulation = 0.75f;
973711001
9738
- debugpoint.radius = radius;
9739
- debugpoint.recalculate();
9740
- debugpoint.material = new cMaterial();
9741
- debugpoint.material.color = 0.25f;
9742
- debugpoint.material.modulation = 0.75f;
11002
+ debugpointG.radius = radius;
11003
+ debugpointG.recalculate();
11004
+ debugpointG.material = new cMaterial();
11005
+ debugpointG.material.color = 0.25f; // Green
11006
+ debugpointG.material.modulation = 0.75f;
974311007
9744
- debugpoint2.radius = radius;
9745
- debugpoint2.recalculate();
9746
- debugpoint2.material = new cMaterial();
9747
- debugpoint2.material.color = 0.75f;
9748
- debugpoint2.material.modulation = 0.75f;
11008
+ debugpointP.radius = radius;
11009
+ debugpointP.recalculate();
11010
+ debugpointP.material = new cMaterial();
11011
+ debugpointP.material.color = 0.75f; // Purple
11012
+ debugpointP.material.modulation = 0.75f;
11013
+
11014
+ debugpointC.radius = radius;
11015
+ debugpointC.recalculate();
11016
+ debugpointC.material = new cMaterial();
11017
+ debugpointC.material.color = 0.5f; // Cyan
11018
+ debugpointC.material.modulation = 0.75f;
11019
+
11020
+ debugpointR.radius = radius;
11021
+ debugpointR.recalculate();
11022
+ debugpointR.material = new cMaterial();
11023
+ debugpointR.material.color = 0f; // Red
11024
+ debugpointR.material.modulation = 0.75f;
974911025
975011026 InitPoints(radius);
975111027 }
975211028 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9753
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9754
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9755
- DrawPoints(this);
11029
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11030
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11031
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11032
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
11033
+ // DrawPoints(this);
975611034 }
975711035
975811036 // debugstuff.draw(this, /*(Composite)*/ null, false);
975911037 }
9760
-// GraphreeD.traceoff();
11038
+// GrafreeD.traceoff();
976111039 //System.out.println(stackdepth);
9762
- if (drawMode == 0)
11040
+ if (DrawMode() == 0)
976311041 {
976411042 ReleaseTextures(DEFAULT_TEXTURES);
976511043
....@@ -9784,17 +11062,19 @@
978411062
978511063 checker = null;
978611064
9787
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11065
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
978811066 FindChecker(object);
978911067
9790
- if (checker != null && drawMode == DEFAULT)
11068
+ if (checker != null && DrawMode() == DEFAULT)
979111069 {
9792
- // BindTexture(IMMORTAL_TEXTURE);
11070
+ //BindTexture(IMMORTAL_TEXTURE);
11071
+ BindTextures(checker.GetTextures(), checker.texres);
979311072 // NEAREST
979411073 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
979511074 DrawChecker(gl);
979611075 //checker.Draw(this, null, false);
979711076 // ReleaseTexture(IMMORTAL_TEXTURE);
11077
+ ReleaseTextures(checker.GetTextures());
979811078 }
979911079
980011080 if (object.parent != null)
....@@ -9807,7 +11087,7 @@
980711087 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
980811088 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
980911089
9810
- if (DISPLAYTEXT && drawMode == DEFAULT)
11090
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
981111091 {
981211092 // Draw it once, then use the raster
981311093 Balloon(gl, balloon.createGraphics());
....@@ -9863,9 +11143,9 @@
986311143 int[] xs = new int[3];
986411144 int[] ys = new int[3];
986511145
9866
- void DrawString(Object3D obj) // String string)
11146
+ public void DrawString(Object3D obj) // String string) // INTERFACE
986711147 {
9868
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11148
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
986911149 {
987011150 return;
987111151 }
....@@ -10253,7 +11533,7 @@
1025311533 return;
1025411534 }
1025511535
10256
- if (obj instanceof CheckerIG)
11536
+ if (obj instanceof Checker)
1025711537 {
1025811538 checker = obj;
1025911539
....@@ -10325,11 +11605,13 @@
1032511605 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1032611606 "PARAM params7 = program.env[7];" + // noise power, opacity power
1032711607 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10328
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
11608
+ "PARAM options1 = program.env[62];" + // fog rgb color
11609
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1032911610 "PARAM pointlight = program.env[127];" + // ...
1033011611 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1033111612 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1033211613 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
11614
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1033311615 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1033411616 "PARAM ten = { 10, 10, 10, 1.0 };" +
1033511617 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10350,6 +11632,7 @@
1035011632 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1035111633 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1035211634 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11635
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1035311636 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1035411637 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1035511638 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10390,6 +11673,10 @@
1039011673 "TEMP R1;" +
1039111674 "TEMP R2;" +
1039211675 "TEMP R3;" +
11676
+ "TEMP min;" +
11677
+ "TEMP max;" +
11678
+ "TEMP average;" +
11679
+ "TEMP saturation;" +
1039311680 "TEMP keep1;" +
1039411681 "TEMP keep2;" +
1039511682 "TEMP keep3;" +
....@@ -10920,10 +12207,40 @@
1092012207
1092112208 // skin?
1092212209 // Saturation for skin
10923
- /**/ // c'est ici
10924
- (Skinshader? "DP3 temp.x, final,one;" +
12210
+ /**/
12211
+ (Skinshader?
12212
+ "DP3 average.x, final,one;" +
12213
+ "MUL average, one3rd.xxxx,average.xxxx;" +
12214
+
12215
+ "MIN min.x, final.x,final.y;" +
12216
+ "MIN min.x, min.x,final.z;" +
12217
+
12218
+ "MAX max.x, final.x,final.y;" +
12219
+ "MAX max.x, max.x,final.z;" +
12220
+ "MOV max, max.xxxx;" +
12221
+
12222
+ "SUB saturation, max, final;" +
12223
+
12224
+ "ADD temp.x, max.x, one10th.x;" +
12225
+ "RCP temp.x, temp.x;" +
12226
+ "MUL temp.x, temp.x, half.x;" +
12227
+ "MUL saturation, saturation, temp.xxxx;" +
12228
+
12229
+ "DP3 ndotl.x, normald, light;" +
12230
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
12231
+
12232
+ "SUB temp.x, one.x, ndotl.x;" +
12233
+ "ADD temp.x, temp.x, options2.z;" + // lightsheen
12234
+ "ADD temp.y, one.y, options2.y;" + // sursurface
12235
+ "MUL temp.x, temp.x, temp.y;" +
12236
+
12237
+ "MUL saturation, saturation, temp.xxxx;" +
12238
+ "SUB_SAT temp, max, saturation;" +
12239
+/**
12240
+ "DP3 temp.x, final,one;" +
1092512241 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10926
- "SUB temp, final,R2;" +
12242
+ "SUB temp, final, R2;" +
12243
+
1092712244 // using light angle
1092812245 "DP3 ndotl.x, normald,light;" +
1092912246 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10936,7 +12253,6 @@
1093612253 // using light intensity
1093712254 "MOV ndotl.z, R2.x;" +
1093812255 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10939
-
1094012256 // june 2014
1094112257 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1094212258 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10948,6 +12264,7 @@
1094812264 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1094912265
1095012266 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
12267
+/**/
1095112268
1095212269 // "ADD final, R2,temp;" +
1095312270 "MOV final, temp;"
....@@ -11037,7 +12354,7 @@
1103712354 /**/
1103812355 // HDR
1103912356 "MOV temp.z, final.a;" +
11040
- "MUL final, final,options1.w;" +
12357
+ "MUL final, final,options2.x;" +
1104112358 "MOV final.a, temp.z;" +
1104212359 /**/
1104312360
....@@ -11074,10 +12391,17 @@
1107412391 "MOV final.z, zero.x;" +
1107512392 "MOV final.a, one.w;":""
1107612393 ) +
12394
+ /*
1107712395 (NORMALdebug?"MOV final.x, normal.x;" +
1107812396 "MOV final.y, normal.y;" +
1107912397 "MOV final.z, normal.z;" +
1108012398 "MOV final.a, one.w;":""
12399
+ ) +
12400
+ */
12401
+ (NORMALdebug?"SUB final.x, one.x, final.x;" +
12402
+ "SUB final.y, one.x, final.y;" +
12403
+ "SUB final.z, one.x, final.z;" +
12404
+ "MOV final.a, final.a;":""
1108112405 ) +
1108212406 // "MOV final, bumpmap;" +
1108312407 "MOV result.color, final;" +
....@@ -11223,6 +12547,7 @@
1122312547 String Shadow(String depth, String shadow)
1122412548 {
1122512549 return "MAX temp.x, ndotl.x, one64th.x;" +
12550
+ "MIN temp.x, temp.x, ninetenth.x;" +
1122612551 /**/
1122712552 // Sine
1122812553 "MUL temp.y, temp.x, temp.x;" +
....@@ -11847,9 +13172,10 @@
1184713172 return;
1184813173 }
1184913174
13175
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1185013176
1185113177 // TIMER
11852
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13178
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1185313179 {
1185413180 keepboxmode = BOXMODE;
1185513181 keepsupport = SUPPORT;
....@@ -11978,7 +13304,7 @@
1197813304 // ObjEditor.tweenManager.update(1f / 60f);
1197913305
1198013306 // fev 2014???
11981
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13307
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1198213308 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1198313309 pingthread.StepToTarget(true); // true);
1198413310 }
....@@ -12090,6 +13416,11 @@
1209013416 cVector tmp = new cVector();
1209113417 cVector tmp2 = new cVector();
1209213418 boolean isMoving;
13419
+
13420
+ public cVector TargetLookAt()
13421
+ {
13422
+ return targetLookAt;
13423
+ }
1209313424
1209413425 class PingThread extends Thread
1209513426 {
....@@ -12229,7 +13560,7 @@
1222913560 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1223013561 if (lightMode)
1223113562 {
12232
- lighttouched = true;
13563
+ Globals.lighttouched = true;
1223313564 }
1223413565
1223513566 if (OEILONCE && OEIL)
....@@ -12287,7 +13618,7 @@
1228713618 mouseDown = false;
1228813619 if (lightMode)
1228913620 {
12290
- lighttouched = true;
13621
+ Globals.lighttouched = true;
1229113622 }
1229213623 repaint();
1229313624 alreadypainted = true;
....@@ -12295,7 +13626,7 @@
1229513626 isMoving = false;
1229613627 } //??
1229713628
12298
- if (isLIVE() && !alreadypainted)
13629
+ if (Globals.isLIVE() && !alreadypainted)
1229913630 {
1230013631 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1230113632 repaint();
....@@ -12307,7 +13638,7 @@
1230713638 {
1230813639 if (lightMode)
1230913640 {
12310
- lighttouched = true;
13641
+ Globals.lighttouched = true;
1231113642 }
1231213643 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1231313644 }
....@@ -12550,6 +13881,7 @@
1255013881 {
1255113882 manipCamera.Translate(dx, dy, getWidth());
1255213883 }
13884
+ else
1255313885 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1255413886 {
1255513887 manipCamera.RotateInterest(dx, dy);
....@@ -12560,7 +13892,7 @@
1256013892
1256113893 if (manipCamera == lightCamera)
1256213894 {
12563
- lighttouched = true;
13895
+ Globals.lighttouched = true;
1256413896 }
1256513897 /*
1256613898 switch (mode)
....@@ -12775,13 +14107,15 @@
1277514107 {
1277614108 mouseMode |= ZOOM;
1277714109 }
12778
- if ((modifiers & META) == META)
14110
+
14111
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14112
+ if (capsLocked || (modifiers & META) == META)
1277914113 {
1278014114 mouseMode |= VR; // BACKFORTH;
1278114115 }
1278214116 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1278314117 {
12784
- mouseMode |= SELECT; // BACKFORTH;
14118
+ mouseMode |= SELECT;
1278514119 }
1278614120 if ((modifiers & COMMAND) == COMMAND)
1278714121 {
....@@ -12789,6 +14123,7 @@
1278914123 }
1279014124 if ((modifiers & SHIFT) == SHIFT || forcetranslate)
1279114125 {
14126
+ mouseMode &= ~VR;
1279214127 mouseMode |= TRANSLATE;
1279314128 }
1279414129 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12945,7 +14280,7 @@
1294514280 case 'B':
1294614281 BRISMOOTH ^= true;
1294714282 SHADOWCULLFACE ^= true;
12948
- lighttouched = true;
14283
+ Globals.lighttouched = true;
1294914284 repaint();
1295014285 break;
1295114286 case 'b':
....@@ -13045,7 +14380,7 @@
1304514380 repaint();
1304614381 break;
1304714382 case 'O':
13048
- drawMode = OCCLUSION;
14383
+ Globals.drawMode = OCCLUSION; // WARNING
1304914384 repaint();
1305014385 break;
1305114386 case 'o':
....@@ -13136,7 +14471,7 @@
1313614471 break;
1313714472 case ' ':
1313814473 lightMode ^= true;
13139
- lighttouched = true;
14474
+ Globals.lighttouched = true;
1314014475 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1314114476 targetLookAt.set(manipCamera.lookAt);
1314214477 repaint();
....@@ -13148,11 +14483,11 @@
1314814483 repaint();
1314914484 break;
1315014485 case 'Z':
13151
- RESIZETEXTURE ^= true;
13152
- break;
14486
+ //RESIZETEXTURE ^= true;
14487
+ //break;
1315314488 case 'z':
1315414489 RENDERSHADOW ^= true;
13155
- lighttouched = true;
14490
+ Globals.lighttouched = true;
1315614491 repaint();
1315714492 break;
1315814493 //case UP:
....@@ -13178,7 +14513,8 @@
1317814513 FlipTransform();
1317914514 break;
1318014515 case ENTER:
13181
- object.editWindow.ScreenFit(); // Edit();
14516
+ // object.editWindow.ScreenFit(); // Edit();
14517
+ ToggleLive();
1318214518 break;
1318314519 case DELETE:
1318414520 ClearSelection();
....@@ -13753,6 +15089,7 @@
1375315089 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1375415090 }
1375515091
15092
+ // To avoid clear.
1375615093 public void update(Graphics g)
1375715094 {
1375815095 paint(g);
....@@ -14355,7 +15692,7 @@
1435515692 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1435615693 gl.glPushMatrix();
1435715694 gl.glLoadIdentity();
14358
- PushMatrix(checker.toParent);
15695
+ //PushMatrix(checker.toParent);
1435915696
1436015697 gl.glMatrixMode(GL.GL_TEXTURE);
1436115698 gl.glPushMatrix();
....@@ -14378,8 +15715,8 @@
1437815715
1437915716 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1438015717
14381
- float step = 0.1666f; //0.25f;
14382
- float stepv = step * 1652 / 998;
15718
+ float step = 2; // 0.1666f; //0.25f;
15719
+ float stepv = 2; // step * 1652 / 998;
1438315720
1438415721 int i0 = 0;
1438515722 /*
....@@ -14415,20 +15752,21 @@
1441515752 /**/
1441615753 //checker.GetMaterial().opacity = 1.1f;
1441715754 ////checker.GetMaterial().ambient = 0.99f;
14418
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14419
- Object3D.selectedstack[Object3D.materialdepth] = false;
14420
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15755
+ materialstack[materialdepth] = checker.material;
15756
+ selectedstack[materialdepth] = false;
15757
+ cStatic.objectstack[materialdepth++] = checker;
1442115758 //System.out.println("material " + material);
1442215759 //Applet3D.tracein(this, selected);
1442315760 vector2buffer = checker.projectedVertices;
1442415761
14425
- checker.GetMaterial().Draw(this, false); // true);
15762
+ //checker.GetMaterial().Draw(this, false); // true);
15763
+ DrawMaterial(checker.GetMaterial(), false); // true);
1442615764
14427
- Object3D.materialdepth -= 1;
14428
- if (Object3D.materialdepth > 0)
15765
+ materialdepth -= 1;
15766
+ if (materialdepth > 0)
1442915767 {
14430
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14431
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
15768
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15769
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1443215770 }
1443315771 //checker.GetMaterial().opacity = 1f;
1443415772 ////checker.GetMaterial().ambient = 1f;
....@@ -14449,15 +15787,27 @@
1444915787
1445015788 //float u = (i+1)/2;
1445115789 //float v = (j+1)/2;
14452
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
15790
+ if (checker.flipV)
15791
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
15792
+ else
15793
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1445315794 gl.glVertex3f(i, j, -0.5f);
1445415795
15796
+ if (checker.flipV)
15797
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
15798
+ else
1445515799 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1445615800 gl.glVertex3f(i + step, j, -0.5f);
1445715801
15802
+ if (checker.flipV)
15803
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
15804
+ else
1445815805 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1445915806 gl.glVertex3f(i + step, j + stepv, -0.5f);
1446015807
15808
+ if (checker.flipV)
15809
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
15810
+ else
1446115811 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1446215812 gl.glVertex3f(i, j + stepv, -0.5f);
1446315813 }
....@@ -14469,7 +15819,7 @@
1446915819 gl.glMatrixMode(GL.GL_PROJECTION);
1447015820 gl.glPopMatrix();
1447115821 gl.glMatrixMode(GL.GL_MODELVIEW);
14472
- PopMatrix(null); // checker.toParent); // null);
15822
+ //PopMatrix(null); // checker.toParent); // null);
1447315823 gl.glPopMatrix();
1447415824 PopTextureMatrix(checker.toParent);
1447515825 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14582,14 +15932,14 @@
1458215932
1458315933 //int tmp = selection_view;
1458415934 //selection_view = -1;
14585
- int temp = drawMode;
14586
- drawMode = SELECTION;
15935
+ int temp = DrawMode();
15936
+ Globals.drawMode = SELECTION; // WARNING
1458715937 indexcount = 0;
1458815938 parent.display(drawable);
1458915939 //selection_view = tmp;
1459015940 //if (temp == SELECTION)
1459115941 // temp = DEFAULT; // patch for selection debug
14592
- drawMode = temp;
15942
+ Globals.drawMode = temp; // WARNING
1459315943
1459415944 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1459515945
....@@ -14639,6 +15989,11 @@
1463915989 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1464015990 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1464115991
15992
+ // Will fit the mesh !!!
15993
+ selectedpoint.toParent[0][0] = 0.0001;
15994
+ selectedpoint.toParent[1][1] = 0.0001;
15995
+ selectedpoint.toParent[2][2] = 0.0001;
15996
+
1464215997 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1464315998
1464415999 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14682,16 +16037,16 @@
1468216037 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]));
1468316038 }
1468416039
14685
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
16040
+ previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
1468616041 }
1468716042 }
1468816043
1468916044 if (!movingcamera && !PAINTMODE)
1469016045 object.editWindow.ScreenFitPoint(); // fev 2014
1469116046
14692
- if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16047
+ if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1469316048 {
14694
- Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16049
+ Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1469516050
1469616051 Object3D group = new Object3D("inst" + paintcount++);
1469716052
....@@ -14857,14 +16212,14 @@
1485716212 //gl.glColorMask(false, false, false, false);
1485816213
1485916214 //render_scene_from_light_view(gl, drawable, 0, 0);
14860
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16215
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1486116216 {
1486216217 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1486316218
14864
- int temp = drawMode;
14865
- drawMode = SHADOW;
16219
+ int temp = DrawMode();
16220
+ Globals.drawMode = SHADOW; // WARNING
1486616221 parent.display(drawable);
14867
- drawMode = temp;
16222
+ Globals.drawMode = temp; // WARNING
1486816223 }
1486916224
1487016225 gl.glCullFace(gl.GL_BACK);
....@@ -14917,7 +16272,6 @@
1491716272
1491816273 class AntialiasBuffer implements GLEventListener
1491916274 {
14920
-
1492116275 CameraPane parent = null;
1492216276
1492316277 AntialiasBuffer(CameraPane p)
....@@ -15027,13 +16381,19 @@
1502716381 gl.glFlush();
1502816382
1502916383 /**/
15030
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16384
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1503116385
15032
- int[] pixels = occlusionsizebuffer.array();
16386
+ float[] pixels = occlusionsizebuffer.array();
1503316387
1503416388 double r = 0, g = 0, b = 0;
1503516389
1503616390 double count = 0;
16391
+
16392
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16393
+
16394
+ float mindepth = 1;
16395
+
16396
+ double FACTOR = 1;
1503716397
1503816398 for (int i = 0; i < pixels.length; i++)
1503916399 {
....@@ -15118,7 +16478,7 @@
1511816478
1511916479 double scale = ray.z; // 1; // cos
1512016480
15121
- int p = pixels[newindex];
16481
+ float depth = pixels[newindex];
1512216482
1512316483 /*
1512416484 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15142,10 +16502,23 @@
1514216502 scale = (1 - modu) * modv;
1514316503 */
1514416504
15145
- r += ((p >> 16) & 0xFF) * scale / 255;
15146
- g += ((p >> 8) & 0xFF) * scale / 255;
15147
- b += (p & 0xFF) * scale / 255;
16505
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16506
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16507
+ //b += (p & 0xFF) * scale / 255;
16508
+
16509
+ if (mindepth > depth)
16510
+ {
16511
+ mindepth = depth;
16512
+ }
1514816513
16514
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16515
+
16516
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16517
+
16518
+ r += factor * scale;
16519
+ g += factor * scale;
16520
+ b += factor * scale;
16521
+
1514916522 count += scale;
1515016523 }
1515116524
....@@ -15243,12 +16616,6 @@
1524316616 GLUT glut = new GLUT();
1524416617
1524516618
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;
1525216619 public boolean spherical = false;
1525316620 static boolean DEBUG_OCCLUSION = false;
1525416621 static boolean DEBUG_SELECTION = false;
....@@ -15261,10 +16628,12 @@
1526116628 int AAbuffersize = 0;
1526216629
1526316630 //double[] selectedpoint = new double[3];
15264
- static Sphere selectedpoint = new Sphere();
16631
+ static Superellipsoid selectedpoint = new Superellipsoid();
1526516632 static Sphere previousselectedpoint = null;
15266
- static Sphere debugpoint = new Sphere();
15267
- static Sphere debugpoint2 = new Sphere();
16633
+ static Sphere debugpointG = new Sphere();
16634
+ static Sphere debugpointP = new Sphere();
16635
+ static Sphere debugpointC = new Sphere();
16636
+ static Sphere debugpointR = new Sphere();
1526816637
1526916638 static Sphere debugpoints[] = new Sphere[8];
1527016639
....@@ -15295,7 +16664,7 @@
1529516664 }
1529616665 }
1529716666
15298
- static void DrawPoints(CameraPane cpane)
16667
+ static void DrawPoints(iCameraPane cpane)
1529916668 {
1530016669 for (int i=0; i<8; i++) // first and last are red
1530116670 {
....@@ -15317,7 +16686,8 @@
1531716686 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1531816687 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1531916688 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15320
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16689
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16690
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1532116691 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1532216692 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1532316693 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();