Normand Briere
2019-04-22 c60a1ad4f6aa4904e80280586b440a584b5ff061
CameraPane.java
....@@ -31,8 +31,12 @@
3131
3232 import gleem.linalg.Mat4f;
3333
34
-class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
34
+class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3535 {
36
+ static cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3640 static boolean DEBUG = false;
3741 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3842
....@@ -42,25 +46,7 @@
4246
4347 static int STEP = 1;
4448
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
51
- {
52
- return LIVE || ONESTEP;
53
- }
54
-
55
- /**
56
- * @param aLIVE the LIVE to set
57
- */
58
- public static void setLIVE(boolean aLIVE)
59
- {
60
- LIVE = aLIVE;
61
- }
62
-
63
- /*static*/ boolean CULLFACE = false; // true;
49
+ /*static*/ private boolean CULLFACE = false; // true;
6450 /*static*/ boolean NEAREST = false; // true;
6551 /*static*/ boolean WIREFRAME = false; // true;
6652
....@@ -97,10 +83,8 @@
9783
9884 static boolean textureon = true;
9985 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10186 static boolean FULLSCREEN = false;
10287 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10488 static boolean INERTIA = true;
10589 static boolean FAST = false;
10690 static boolean SLOWPOSE = false;
....@@ -173,17 +157,52 @@
173157 theRenderer = this;
174158 }
175159
160
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
161
+ {
162
+ super(defaultcaps, null, withcontext?glcontext:null, null);
163
+
164
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
165
+ glcontext = getContext();
166
+
167
+ cameras = new Camera[2];
168
+ targetLookAts = new cVector[2];
169
+
170
+ SetCamera(cam);
171
+
172
+ SetLight(new Camera(new cVector(10, 10, -20)));
173
+
174
+ object = o;
175
+
176
+ setBackground(Color.white);
177
+
178
+ addKeyListener(this);
179
+ addMouseListener(this);
180
+ addMouseMotionListener(this);
181
+ addMouseWheelListener(this);
182
+ //System.out.println("addGLEventListener: " + this);
183
+ addGLEventListener(this);
184
+
185
+// pingthread.start(); // may 2013
186
+ }
187
+
176188 static boolean AntialiasingEnabled()
177189 {
178190 return CURRENTANTIALIAS > 0;
179191 }
180192
181
- void ClearDepth()
193
+ /// INTERFACE
194
+
195
+ public boolean IsBoxMode()
196
+ {
197
+ return BOXMODE;
198
+ }
199
+
200
+ public void ClearDepth()
182201 {
183202 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184203 }
185204
186
- void DepthTest(boolean depthtest)
205
+ public void DepthTest(boolean depthtest)
187206 {
188207 if (depthtest)
189208 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +210,7 @@
191210 GetGL().glDepthFunc(GL.GL_ALWAYS);
192211 }
193212
194
- void DepthWrite(boolean depthwrite)
213
+ public void DepthWrite(boolean depthwrite)
195214 {
196215 if (depthwrite)
197216 GetGL().glDepthMask(true);
....@@ -199,12 +218,965 @@
199218 GetGL().glDepthMask(false);
200219 }
201220
202
- void BackFaceCull(boolean bfc)
221
+ public void BackFaceCull(boolean bfc)
203222 {
204223 if (bfc)
205224 GetGL().glEnable(GetGL().GL_CULL_FACE);
206225 else
207226 GetGL().glDisable(GetGL().GL_CULL_FACE);
227
+ }
228
+
229
+ public boolean BackFaceCullMode()
230
+ {
231
+ return this.CULLFACE;
232
+ }
233
+
234
+ public boolean IsAmbientOcclusionOn()
235
+ {
236
+ return this.ambientOcclusion;
237
+ }
238
+
239
+ public boolean IsFrozen()
240
+ {
241
+ boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
242
+
243
+ return !selectmode && cameracount == 0; // != 0;
244
+ }
245
+
246
+ // Currently in Globals
247
+ public int DrawMode()
248
+ {
249
+ return Globals.DrawMode();
250
+ }
251
+
252
+ public Camera EyeCamera()
253
+ {
254
+ return eyeCamera;
255
+ }
256
+
257
+ public Camera LightCamera()
258
+ {
259
+ return lightCamera;
260
+ }
261
+
262
+ public Camera RenderCamera()
263
+ {
264
+ return renderCamera;
265
+ }
266
+
267
+ public void PushMaterial(Object3D obj, boolean selected)
268
+ {
269
+ CameraPane display = this;
270
+ javax.media.opengl.GL gl = display.GetGL();
271
+ cMaterial material = obj.material;
272
+
273
+ if (material != null)
274
+ {
275
+ materialstack[materialdepth] = material;
276
+ selectedstack[materialdepth] = selected;
277
+ cStatic.objectstack[materialdepth++] = obj;
278
+ //System.out.println("material " + material);
279
+ //Applet3D.tracein(this, selected);
280
+ display.vector2buffer = obj.projectedVertices;
281
+ if (obj instanceof Camera)
282
+ {
283
+ display.options1[0] = material.shift;
284
+ //System.out.println("shift " + material.shift);
285
+ display.options1[1] = material.lightarea;
286
+ display.options1[2] = material.shadowbias;
287
+ display.options1[3] = material.aniso;
288
+ display.options1[4] = material.anisoV;
289
+ display.options2[0] = material.opacity;
290
+ display.options2[1] = material.diffuse;
291
+ display.options2[2] = material.factor;
292
+
293
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
294
+ display.options4[0] = material.cameralight/0.2f;
295
+ display.options4[1] = material.subsurface;
296
+ display.options4[2] = material.sheen;
297
+
298
+ // if (display.CURRENTANTIALIAS > 0)
299
+ // display.options3[3] /= 4;
300
+
301
+ /*
302
+ System.out.println("Focus = " + display.options1[0]);
303
+ System.out.println("Aperture = " + display.options1[1]);
304
+ System.out.println("ShadowBlur = " + display.options1[2]);
305
+ System.out.println("Antialiasing = " + display.options1[3]);
306
+ System.out.println("Fog = " + display.options2[0]);
307
+ System.out.println("Intensity = " + display.options2[1]);
308
+ System.out.println("Elevation = " + display.options2[2]);
309
+ /**/
310
+ } else
311
+ {
312
+ DrawMaterial(material, selected);
313
+ }
314
+ } else
315
+ {
316
+ if (selected && CameraPane.flash)
317
+ {
318
+ display.modelParams4[1] = 100;
319
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
320
+ }
321
+ }
322
+ }
323
+
324
+ public void PushMaterial2(Object3D obj, boolean selected)
325
+ {
326
+ CameraPane display = this;
327
+ cMaterial material = obj.material;
328
+
329
+ if (material != null)
330
+ {
331
+ materialstack[materialdepth] = material;
332
+ selectedstack[materialdepth] = selected;
333
+ cStatic.objectstack[materialdepth++] = obj;
334
+ //System.out.println("material " + material);
335
+ //Applet3D.tracein("selected ", selected);
336
+ display.vector2buffer = obj.projectedVertices;
337
+ display.DrawMaterial(material, selected);
338
+ }
339
+ }
340
+
341
+ public void PopMaterial(Object3D obj, boolean selected)
342
+ {
343
+ CameraPane display = this;
344
+ javax.media.opengl.GL gl = display.GetGL();
345
+ cMaterial material = obj.material;
346
+
347
+ //if (parent != null && parent.GetMaterial() != null)
348
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
349
+ if (material != null)
350
+ {
351
+ materialdepth -= 1;
352
+ if (materialdepth > 0)
353
+ {
354
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
355
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
356
+ }
357
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
358
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
359
+ {
360
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
361
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
362
+ }
363
+ }
364
+
365
+ public void PopMaterial2(Object3D obj)
366
+ {
367
+ CameraPane display = this;
368
+ cMaterial material = obj.material;
369
+
370
+ if (material != null)
371
+ {
372
+ materialdepth -= 1;
373
+ if (materialdepth > 0)
374
+ {
375
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
376
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
377
+ }
378
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
379
+ //else
380
+ //material.Draw(display, false);
381
+ }
382
+ }
383
+
384
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
385
+ {
386
+ CameraPane display = this;
387
+
388
+ if (pv.y == -10000 ||
389
+ qv.y == -10000 ||
390
+ rv.y == -10000)
391
+ return;
392
+
393
+// float b = f.nbiterations & 1;
394
+// float g = (f.nbiterations>>1) & 1;
395
+// float r = (f.nbiterations>>2) & 1;
396
+//
397
+// //if (f.weight == 10000)
398
+// //{
399
+// // r = 1; g = b = 0;
400
+// //}
401
+// //else
402
+// //{
403
+// // assert(f.weight < 10000);
404
+// r = g = b = (float)bRep.FaceWeight(f)*100;
405
+// if (r<0)
406
+// assert(r>=0);
407
+// //}
408
+
409
+ javax.media.opengl.GL gl = display.GetGL();
410
+
411
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
412
+
413
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
415
+ {
416
+ //gl.glBegin(gl.GL_TRIANGLES);
417
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
418
+ if (!hasnorm)
419
+ {
420
+ // System.out.println("FUCK!!");
421
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
422
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
423
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
424
+ LA.vecNormalize(obj.v2);
425
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
426
+ }
427
+
428
+ // P
429
+ float x = (float)pv.x;
430
+ float y = (float)pv.y;
431
+ float z = (float)pv.z;
432
+
433
+ if (hasnorm)
434
+ {
435
+// if (!pv.norm.normalized())
436
+// assert(pv.norm.normalized());
437
+
438
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
439
+ float nx = (float)pv.norm.x;
440
+ float ny = (float)pv.norm.y;
441
+ float nz = (float)pv.norm.z;
442
+
443
+ x += nx * obj.NORMALPUSH;
444
+ y += ny * obj.NORMALPUSH;
445
+ z += nz * obj.NORMALPUSH;
446
+
447
+ gl.glNormal3f(nx, ny, nz);
448
+ }
449
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
450
+ SetColor(obj, pv);
451
+ //gl.glColor4f(r, g, b, 1);
452
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
453
+ if (obj.flipV)
454
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
455
+ else
456
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
457
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
458
+
459
+ gl.glVertex3f(x, y, z);
460
+
461
+ // Q
462
+ x = (float)qv.x;
463
+ y = (float)qv.y;
464
+ z = (float)qv.z;
465
+
466
+// Print(pv);
467
+ if (hasnorm)
468
+ {
469
+// assert(qv.norm.normalized());
470
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
471
+ float nx = (float)qv.norm.x;
472
+ float ny = (float)qv.norm.y;
473
+ float nz = (float)qv.norm.z;
474
+
475
+ x += nx * obj.NORMALPUSH;
476
+ y += ny * obj.NORMALPUSH;
477
+ z += nz * obj.NORMALPUSH;
478
+
479
+ gl.glNormal3f(nx, ny, nz);
480
+ }
481
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
482
+ // boolean locked = false;
483
+ // float eps = 0.1f;
484
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
485
+
486
+ // int dot = 0; //*/ (int)f.dot;
487
+
488
+ // if ((dot&1) == 0)
489
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
490
+
491
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
492
+ if (obj.flipV)
493
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
494
+ else
495
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
496
+ // else
497
+ // {
498
+ // locked = true;
499
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
500
+ // }
501
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
502
+ SetColor(obj, qv);
503
+
504
+ gl.glVertex3f(x, y, z);
505
+ //gl.glColor4f(r, g, b, 1);
506
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
507
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
508
+// Print(qv);
509
+
510
+ // R
511
+ x = (float)rv.x;
512
+ y = (float)rv.y;
513
+ z = (float)rv.z;
514
+
515
+ if (hasnorm)
516
+ {
517
+// assert(rv.norm.normalized());
518
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
519
+ float nx = (float)rv.norm.x;
520
+ float ny = (float)rv.norm.y;
521
+ float nz = (float)rv.norm.z;
522
+
523
+ x += nx * obj.NORMALPUSH;
524
+ y += ny * obj.NORMALPUSH;
525
+ z += nz * obj.NORMALPUSH;
526
+
527
+ gl.glNormal3f(nx, ny, nz);
528
+ }
529
+
530
+ // if ((dot&4) == 0)
531
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
532
+
533
+ // if (wrap || !locked && (dot&8) != 0)
534
+ if (obj.flipV)
535
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
536
+ else
537
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
538
+ // else
539
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
540
+
541
+ // f.dot = dot;
542
+
543
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
544
+ SetColor(obj, rv);
545
+ //gl.glColor4f(r, g, b, 1);
546
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
547
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
548
+ gl.glVertex3f(x, y, z);
549
+// Print(rv);
550
+ //gl.glEnd();
551
+ }
552
+ else
553
+ {
554
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
555
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
556
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
557
+
558
+ }
559
+
560
+ if (false) // (attributes & WIREFRAME) != 0)
561
+ {
562
+ gl.glDisable(gl.GL_LIGHTING);
563
+
564
+ gl.glBegin(gl.GL_LINE_LOOP);
565
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
566
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
567
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
568
+ gl.glEnd();
569
+
570
+ gl.glEnable(gl.GL_LIGHTING);
571
+ }
572
+ }
573
+
574
+ /**
575
+ * <code>draw</code> renders a <code>TriMesh</code> object including
576
+ * it's normals, colors, textures and vertices.
577
+ *
578
+ * @see Renderer#draw(TriMesh)
579
+ * @param tris
580
+ * the mesh to render.
581
+ */
582
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
583
+ {
584
+ CameraPane display = this;
585
+
586
+ float r = display.modelParams0[0];
587
+ float g = display.modelParams0[1];
588
+ float b = display.modelParams0[2];
589
+ float opacity = display.modelParams5[1];
590
+
591
+ //final GL gl = GLU.getCurrentGL();
592
+ GL gl = display.GetGL(); // getGL();
593
+
594
+ FloatBuffer vertBuf = geo.vertBuf;
595
+
596
+ int v = vertBuf.capacity();
597
+
598
+ int count = 0;
599
+
600
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
601
+ gl.glEnable(gl.GL_CULL_FACE);
602
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
603
+ for (int i=0; i<v/3; i++)
604
+ {
605
+ int index3 = i*3;
606
+
607
+ if (geo.sizeBuf.get(index3+1) == 0)
608
+ continue;
609
+
610
+ count++;
611
+
612
+ int index4 = i*4;
613
+
614
+ float tx = vertBuf.get(index3);
615
+ float ty = vertBuf.get(index3+1);
616
+ float tz = vertBuf.get(index3+2);
617
+
618
+ // if (tx == 0 && ty == 0 && tz == 0)
619
+ // continue;
620
+
621
+ gl.glMatrixMode(gl.GL_TEXTURE);
622
+ gl.glPushMatrix();
623
+
624
+ float[] texmat = geo.texmat;
625
+ texmat[12] = texmat[13] = texmat[14] = i;
626
+
627
+ gl.glMultMatrixf(texmat, 0);
628
+
629
+ gl.glMatrixMode(gl.GL_MODELVIEW);
630
+ gl.glPushMatrix();
631
+
632
+ gl.glTranslatef(tx,ty,tz);
633
+
634
+ if (rotate)
635
+ gl.glRotatef(i, 0, 1, 0);
636
+
637
+ float size = geo.sizeBuf.get(index3) / 100;
638
+ gl.glScalef(size,size,size);
639
+
640
+ float cr = geo.colorBuf.get(index4);
641
+ float cg = geo.colorBuf.get(index4+1);
642
+ float cb = geo.colorBuf.get(index4+2);
643
+ float ca = geo.colorBuf.get(index4+3);
644
+
645
+ display.modelParams0[0] = r * cr;
646
+ display.modelParams0[1] = g * cg;
647
+ display.modelParams0[2] = b * cb;
648
+
649
+ display.modelParams5[1] = opacity * ca;
650
+
651
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
652
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
653
+
654
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
655
+ RandomNode.globalseed2 = RandomNode.globalseed;
656
+
657
+// gl.glColor4f(cr,cg,cb,ca);
658
+ // gl.glScalef(1024/16,1024/16,1024/16);
659
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
660
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
661
+ //gl.glTranslatef(-tx,-ty,-tz);
662
+ gl.glPopMatrix();
663
+
664
+ gl.glMatrixMode(gl.GL_TEXTURE);
665
+ gl.glPopMatrix();
666
+ }
667
+ // gl.glScalef(1024,1024,1024);
668
+ if (!cf)
669
+ gl.glDisable(gl.GL_CULL_FACE);
670
+
671
+ display.modelParams0[0] = r;
672
+ display.modelParams0[1] = g;
673
+ display.modelParams0[2] = b;
674
+
675
+ display.modelParams5[1] = opacity;
676
+
677
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
678
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
679
+
680
+ gl.glMatrixMode(gl.GL_MODELVIEW);
681
+
682
+// System.err.println("total = " + v/3 + "; displayed = " + count);
683
+ if (true)
684
+ return;
685
+
686
+//// if (!tris.predraw(this))
687
+//// {
688
+//// return;
689
+//// }
690
+//// if (Debug.stats)
691
+//// {
692
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
693
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
694
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
695
+//// }
696
+////
697
+//// if (tris.getDisplayListID() != -1)
698
+//// {
699
+//// renderDisplayList(tris);
700
+//// return;
701
+//// }
702
+////
703
+//// if (!generatingDisplayList)
704
+//// {
705
+//// applyStates(tris.states, tris);
706
+//// }
707
+//// if (Debug.stats)
708
+//// {
709
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
710
+//// }
711
+//// boolean transformed = doTransforms(tris);
712
+//
713
+// int glMode = GL.GL_TRIANGLES;
714
+// switch (getMode())
715
+// {
716
+// case Triangles:
717
+// glMode = GL.GL_TRIANGLES;
718
+// break;
719
+// case Strip:
720
+// glMode = GL.GL_TRIANGLE_STRIP;
721
+// break;
722
+// case Fan:
723
+// glMode = GL.GL_TRIANGLE_FAN;
724
+// break;
725
+// }
726
+//
727
+// if (!predrawGeometry(gl))
728
+// {
729
+// // make sure only the necessary indices are sent through on old
730
+// // cards.
731
+// IntBuffer indices = this.getIndexBuffer();
732
+// if (indices == null)
733
+// {
734
+// logger.severe("missing indices on geometry object: " + this.toString());
735
+// } else
736
+// {
737
+// indices.rewind();
738
+// indices.limit(this.getMaxIndex());
739
+//
740
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
741
+//
742
+// indices.clear();
743
+// }
744
+// } else
745
+// {
746
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
747
+// GL.GL_UNSIGNED_INT, 0);
748
+// }
749
+//
750
+//// postdrawGeometry(tris);
751
+//// if (transformed)
752
+//// {
753
+//// undoTransforms(tris);
754
+//// }
755
+////
756
+//// if (Debug.stats)
757
+//// {
758
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
759
+//// }
760
+//// tris.postdraw(this);
761
+ }
762
+
763
+ /// INTERFACE
764
+
765
+ void SetColor(Object3D obj, Vertex p0)
766
+ {
767
+ CameraPane display = this;
768
+ BoundaryRep bRep = obj.bRep;
769
+
770
+ if (RENDERPROGRAM == 0)
771
+ {
772
+ float r = 0;
773
+ if (bRep != null)
774
+ {
775
+ if (bRep.stripified)
776
+ {
777
+ r = 1;
778
+ }
779
+ }
780
+ float g = 0;
781
+ if (bRep != null)
782
+ {
783
+ if (bRep.trimmed)
784
+ {
785
+ g = 1;
786
+ }
787
+ }
788
+ float b = 0;
789
+ if (obj.support != null && obj.link2master)
790
+ {
791
+ b = 1;
792
+ }
793
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
794
+ return;
795
+ }
796
+
797
+ if (display.DrawMode() != CameraPane.SHADOW)
798
+ return;
799
+
800
+ javax.media.opengl.GL gl = display.GetGL();
801
+// if (true) return;
802
+// float ao = p.AO;
803
+//
804
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
805
+// // ao = 1;
806
+//
807
+// gl.glColor4f(ao, ao, ao, 1);
808
+
809
+// CameraPane.selectedpoint.
810
+// getAverage(cStatic.point1, true);
811
+ if (CameraPane.pointflow == null) // !random) // live)
812
+ {
813
+ return;
814
+ }
815
+
816
+ cStatic.point1.set(0,0,0);
817
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
818
+
819
+ cStatic.point1.sub(p0);
820
+
821
+
822
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
823
+// {
824
+// return;
825
+// }
826
+
827
+ //if (true)
828
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
829
+ {
830
+ return;
831
+ }
832
+
833
+ float[] colorV = new float[3];
834
+
835
+ if (false) // marked)
836
+ {
837
+ // debug rigging weights
838
+ for (int object = 0; object < p0.vertexlinks.length; object++)
839
+ {
840
+ float weight = p0.weights[object] / p0.totalweight;
841
+
842
+ // if (weight < 0.1)
843
+ // {
844
+ // assert(weight == 0);
845
+ // continue;
846
+ // }
847
+
848
+ if (p0.vertexlinks[object] == -1)
849
+ continue;
850
+
851
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
852
+
853
+ int color = //1 << object; //
854
+ //p.vertexlinks.length;
855
+ obj.support.bRep.supports[p0.closestsupport].links[object];
856
+ colorV[2] += (color & 1) * weight;
857
+ colorV[1] += ((color & 2) >> 1) * weight;
858
+ colorV[0] += ((color & 4) >> 2) * weight;
859
+ }
860
+ }
861
+ else
862
+ {
863
+ if (obj.drawingstarted)
864
+ {
865
+ // find next point
866
+ if (bRep.GetVertex(0).faceindices == null)
867
+ {
868
+ bRep.InitFaceIndices();
869
+ }
870
+
871
+ double ymin = p0.y;
872
+
873
+ Vertex newp = p0;
874
+
875
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
876
+ {
877
+ int fi = p0.faceindices[fii];
878
+
879
+ if (fi == -1)
880
+ break;
881
+
882
+ Face f = bRep.GetFace(fi);
883
+
884
+ Vertex p = bRep.GetVertex(f.p);
885
+ Vertex q = bRep.GetVertex(f.q);
886
+ Vertex r = bRep.GetVertex(f.r);
887
+
888
+ int swap = (int)(Math.random()*3);
889
+
890
+// for (int s=swap; --s>=0;)
891
+// {
892
+// Vertex t = p;
893
+// p = q;
894
+// q = r;
895
+// r = t;
896
+// }
897
+ if (ymin > p.y)
898
+ {
899
+ ymin = p.y;
900
+ newp = p;
901
+// break;
902
+ }
903
+ if (ymin > q.y)
904
+ {
905
+ ymin = q.y;
906
+ newp = q;
907
+// break;
908
+ }
909
+ if (ymin > r.y)
910
+ {
911
+ ymin = r.y;
912
+ newp = r;
913
+// break;
914
+ }
915
+ }
916
+
917
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
918
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
919
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
920
+
921
+ obj.drawingstarted = false;
922
+
923
+ // return;
924
+ }
925
+
926
+ if (false) // CameraPane.DRAW
927
+ {
928
+ p0.AO = colorV[0] = 2;
929
+ colorV[1] = 2;
930
+ colorV[2] = 2;
931
+ }
932
+
933
+ CameraPane.pointflow.add(p0);
934
+ CameraPane.pointflow.Touch();
935
+ }
936
+
937
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
938
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
939
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
940
+ }
941
+
942
+ void DrawMaterial(cMaterial material, boolean selected)
943
+ {
944
+ CameraPane display = this;
945
+ //new Exception().printStackTrace();
946
+
947
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
948
+ {
949
+ return;
950
+ }
951
+
952
+ javax.media.opengl.GL gl = display.GetGL();
953
+
954
+ //Color col = Color.getHSBColor(color,modulation,1);
955
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
956
+ if (!material.multiply)
957
+ {
958
+ display.color = color;
959
+ display.saturation = material.modulation;
960
+ }
961
+ else
962
+ {
963
+ display.color *= color*2;
964
+ display.saturation *= material.modulation*2;
965
+ }
966
+
967
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
968
+
969
+ float[] colorV = GrafreeD.colorV;
970
+
971
+ /**/
972
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
973
+ {
974
+ colorV[0] = display.modelParams0[0] * material.diffuse;
975
+ colorV[1] = display.modelParams0[1] * material.diffuse;
976
+ colorV[2] = display.modelParams0[2] * material.diffuse;
977
+ colorV[3] = material.opacity;
978
+
979
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
980
+ //System.out.println("Opacity = " + opacity);
981
+
982
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
983
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
984
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
985
+
986
+ float amb = material.ambient;
987
+ if (amb < material.cameralight)
988
+ {
989
+ amb = material.cameralight;
990
+ }
991
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
992
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
993
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
994
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
995
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
996
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
997
+
998
+ /**/
999
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1000
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1001
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1002
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1003
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1004
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1005
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1006
+ //System.out.println("shininess = " + colorV[0]);
1007
+ if (colorV[0] > 128)
1008
+ {
1009
+ colorV[0] = 128;
1010
+ }
1011
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1012
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1013
+ /**/
1014
+ }
1015
+ /**/
1016
+
1017
+ //selected = false;
1018
+ selected = selected && display.flash;
1019
+
1020
+ //display.modelParams0[0] = 0; // pigment.r;
1021
+ //display.modelParams0[1] = 0; // pigment.g;
1022
+ //display.modelParams0[2] = 0; // pigment.b;
1023
+ if (!material.multiply)
1024
+ {
1025
+ display.modelParams0[3] = material.metalness;
1026
+ display.modelParams1[0] = material.diffuse;
1027
+ display.modelParams1[1] = material.specular;
1028
+ display.modelParams1[2] = 1 / material.shininess;
1029
+ display.modelParams1[3] = material.shift;
1030
+ display.modelParams2[0] = material.ambient;
1031
+ display.modelParams2[1] = material.lightarea;
1032
+ //System.out.println("light area = " + lightarea);
1033
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1034
+ display.modelParams2[3] = material.velvet;
1035
+ display.modelParams3[0] = material.sheen;
1036
+ display.modelParams3[1] = material.subsurface;
1037
+ display.modelParams3[2] = material.bump; // backlit
1038
+ display.modelParams3[3] = material.aniso;
1039
+ display.modelParams4[0] = material.anisoV;
1040
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1041
+ //System.out.println("selected = " + selected);
1042
+ display.modelParams4[2] = material.diffuseness;
1043
+ display.modelParams4[3] = material.shadow;
1044
+ display.modelParams5[0] = material.texture;
1045
+ display.modelParams5[1] = material.opacity;
1046
+ display.modelParams5[2] = material.fakedepth;
1047
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1048
+ }
1049
+ else
1050
+ {
1051
+ display.modelParams0[3] *= material.metalness*2;
1052
+ display.modelParams1[0] *= material.diffuse*2;
1053
+ display.modelParams1[1] *= material.specular*2;
1054
+ display.modelParams1[2] *= material.shininess*2;
1055
+ display.modelParams1[3] *= material.shift*2;
1056
+ display.modelParams2[0] *= material.ambient*2;
1057
+ display.modelParams2[1] *= material.lightarea*2;
1058
+ display.modelParams2[2] *= material.factor*2;
1059
+ display.modelParams2[3] *= material.velvet*2;
1060
+ display.modelParams3[0] *= material.sheen*2;
1061
+ display.modelParams3[1] *= material.subsurface*2;
1062
+ display.modelParams3[2] *= material.bump*2;
1063
+ display.modelParams3[3] *= material.aniso*2;
1064
+ display.modelParams4[0] *= material.anisoV*2;
1065
+ display.modelParams4[1] *= material.cameralight*2;
1066
+ //System.out.println("selected = " + selected);
1067
+ display.modelParams4[2] *= material.diffuseness*2;
1068
+ display.modelParams4[3] *= material.shadow*2;
1069
+ display.modelParams5[0] *= material.texture*2;
1070
+ display.modelParams5[1] *= material.opacity*2;
1071
+ display.modelParams5[2] *= material.fakedepth*2;
1072
+ display.modelParams5[3] *= material.shadowbias*2;
1073
+ }
1074
+
1075
+ display.modelParams6[0] = 0;
1076
+ display.modelParams6[1] = 0;
1077
+ display.modelParams6[2] = 0;
1078
+ display.modelParams6[3] = 0;
1079
+
1080
+ display.modelParams7[0] = 0;
1081
+ display.modelParams7[1] = 1000;
1082
+ display.modelParams7[2] = 0;
1083
+ display.modelParams7[3] = 0;
1084
+
1085
+ display.modelParams6[0] = 100; // criss de bug de bump
1086
+
1087
+ Object3D.cVector2[] extparams = display.vector2buffer;
1088
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1089
+ {
1090
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1091
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1092
+ if (extparams.length > 1)
1093
+ {
1094
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1095
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1096
+ if (extparams.length > 2)
1097
+ {
1098
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1099
+ float x = extparams[2].y / 1000.0f;
1100
+ //if (x == 0)
1101
+ // x = 1f;
1102
+ 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
1103
+ if (extparams[2].y > 0)
1104
+ {
1105
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1106
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1107
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ //if (display.modelParams6[2] != 0)
1114
+ /*
1115
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1116
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1117
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1118
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1119
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1120
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1121
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1122
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1123
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1124
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1125
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1126
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1127
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1128
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1129
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1130
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1131
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1132
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1133
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1134
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1135
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1136
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1137
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1138
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1139
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1140
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1141
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1142
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1143
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1144
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1145
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1146
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1147
+ /**/
1148
+ //assert (display.modelParams6[2] == 0);
1149
+
1150
+ //System.out.println("noise power = " + display.modelParams7[0]);
1151
+ //System.out.println("shadowbias = " + shadowbias);
1152
+
1153
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1154
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1155
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1156
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1157
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1158
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1159
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1160
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1161
+
1162
+ int mode = display.FP_SHADER;
1163
+
1164
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1165
+ {
1166
+ mode |= display.FP_ANISO;
1167
+ }
1168
+
1169
+ display.EnableProgram(mode);
1170
+
1171
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1172
+
1173
+ if (!material.multiply)
1174
+ {
1175
+ if (Globals.drawMode == CameraPane.SHADOW)
1176
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1177
+ else
1178
+ gl.glDepthMask(material.opacity >= 0.99);
1179
+ }
2081180 }
2091181
2101182 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1197,7 @@
2251197 currentGL.glMultMatrixd(model, 0);
2261198 }
2271199
228
- void PushMatrix(double[][] matrix, int count)
1200
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291201 {
2301202 matrixdepth++;
2311203 // GrafreeD.tracein(matrix);
....@@ -270,7 +1242,7 @@
2701242
2711243 double[][] tmpmat = new double[4][4];
2721244
273
- void PopMatrix(double[][] inverse)
1245
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741246 {
2751247 --matrixdepth;
2761248
....@@ -310,7 +1282,7 @@
3101282 PushTextureMatrix(matrix, 1);
3111283 }
3121284
313
- void PushTextureMatrix(double[][] matrix, int count)
1285
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141286 {
3151287 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161288
....@@ -324,7 +1296,7 @@
3241296 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251297 }
3261298
327
- void PopTextureMatrix(double[][] inverse)
1299
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281300 {
3291301 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301302 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -356,10 +1328,10 @@
3561328 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571329 // return false;
3581330
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1331
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601332 {
3611333 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1334
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631335 {
3641336 // refuse the camera change
3651337 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +1339,7 @@
3671339 }
3681340 }
3691341
370
- camerachangeframe = framecount;
1342
+ camerachangeframe = Globals.framecount;
3711343
3721344 cam.hAspect = -1; // Read only
3731345
....@@ -398,7 +1370,7 @@
3981370 {
3991371 //System.err.println("Oeil on");
4001372 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1373
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4021374 // object.editWindow.ScreenFit(trackedobject);
4031375 //pingthread.StepToTarget(true);
4041376 }
....@@ -407,7 +1379,7 @@
4071379 {
4081380 //System.err.println("Oeil on");
4091381 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1382
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4111383 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4121384 //pingthread.StepToTarget(true);
4131385 }
....@@ -471,7 +1443,7 @@
4711443 {
4721444 frozen ^= true;
4731445 // Weird...
474
- lighttouched = true;
1446
+ Globals.lighttouched = true;
4751447 }
4761448
4771449 void ToggleDL()
....@@ -486,11 +1458,11 @@
4861458
4871459 void ToggleLive()
4881460 {
489
- setLIVE(isLIVE() ^ true);
1461
+ Globals.setLIVE(Globals.isLIVE() ^ true);
4901462
491
- System.err.println("LIVE = " + isLIVE());
1463
+ System.err.println("LIVE = " + Globals.isLIVE());
4921464
493
- if (!isLIVE()) // save sound
1465
+ if (!Globals.isLIVE()) // save sound
4941466 GrafreeD.savesound = true; // wav.save();
4951467 // else
4961468 repaint(); // start loop // may 2013
....@@ -513,7 +1485,7 @@
5131485
5141486 void ToggleCrowd()
5151487 {
516
- CROWD ^= true;
1488
+ Globals.CROWD ^= true;
5171489 }
5181490
5191491 void ToggleInertia()
....@@ -674,34 +1646,6 @@
6741646 lightCamera = cam;
6751647 }
6761648
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
-
7051649 private static void ApplyTransform(GL gl, Mat4f xform)
7061650 {
7071651 float[] data = new float[16];
....@@ -759,7 +1703,7 @@
7591703
7601704 GL currentGL;
7611705
762
- GL GetGL()
1706
+ public GL GetGL() // INTERFACE
7631707 {
7641708 return currentGL;
7651709 }
....@@ -6271,7 +7215,7 @@
62717215 return null;
62727216 }
62737217
6274
- void ReleaseTextures(cTexture tex)
7218
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757219 {
62767220 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777221 {
....@@ -6309,7 +7253,7 @@
63097253
63107254 void ReleaseTexture(String tex, boolean bump)
63117255 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
7256
+ if (// DrawMode() != 0 || /*tex == null ||*/
63137257 ambientOcclusion ) // || !textureon)
63147258 {
63157259 return;
....@@ -6410,9 +7354,9 @@
64107354 }
64117355 }
64127356
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7357
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64147358 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
7359
+ if (// DrawMode() != 0 || /*tex == null ||*/
64167360 ambientOcclusion ) // || !textureon)
64177361 {
64187362 return; // false;
....@@ -7312,9 +8256,9 @@
73128256 static boolean occlusionInitialized = false;
73138257 boolean selection = false;
73148258 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
8259
+ ///*static*/ boolean lighttouched = true;
73168260 boolean deselect;
7317
- boolean ambientOcclusion = false;
8261
+ private boolean ambientOcclusion = false;
73188262 static boolean flash = false;
73198263 /*static*/ boolean wait = false;
73208264 boolean displaydone = false; // after repaint() calls
....@@ -7444,6 +8388,8 @@
74448388 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74458389 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74468390 double scale = lightCamera.SCALE / lightCamera.Distance();
8391
+// PATCH FILLE AUX JEANS
8392
+ //scale *= lightCamera.shaper_fovy / 25;
74478393 gl.glScaled(2 * scale, 2 * scale, -scale);
74488394 gl.glTranslated(0, 0, lightCamera.DECAL);
74498395
....@@ -7601,8 +8547,6 @@
76018547
76028548 boolean restartframe = false;
76038549
7604
- static int framecount = 0; // general-purpose global count
7605
-
76068550 void displayAntiAliased(javax.media.opengl.GL gl)
76078551 {
76088552 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7633,7 +8577,7 @@
76338577 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76348578 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76358579 {
7636
- framecount++;
8580
+ Globals.framecount++;
76378581
76388582 if (CameraPane.tickcount > 0)
76398583 CameraPane.tickcount--;
....@@ -7671,7 +8615,7 @@
76718615
76728616 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76738617 */
7674
- lighttouched = true;
8618
+ Globals.lighttouched = true;
76758619 //System.err.println(" shadowbuffer: " + jitter);
76768620 shadowbuffer.display();
76778621
....@@ -8618,13 +9562,6 @@
86189562 }
86199563 }
86209564
8621
- boolean IsFrozen()
8622
- {
8623
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8624
-
8625
- return !selectmode && cameracount == 0; // != 0;
8626
- }
8627
-
86289565 boolean niceon = false;
86299566 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86309567 boolean currentlydrawing = false;
....@@ -8642,8 +9579,8 @@
86429579 }
86439580 // if (DEBUG_SELECTION)
86449581 // {
8645
-// if (drawMode != SELECTION)
8646
-// drawMode = SELECTION;
9582
+// if (DrawMode() != SELECTION)
9583
+// DrawMode() = SELECTION;
86479584 // }
86489585
86499586 if (!isRenderer)
....@@ -8699,9 +9636,9 @@
86999636
87009637 //ANTIALIAS = 0;
87019638
8702
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9639
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
87039640 {
8704
- if (niceon || isLIVE())
9641
+ if (niceon || Globals.isLIVE())
87059642 {
87069643 //if(active == 0)
87079644 // antialiaser = null;
....@@ -8726,7 +9663,7 @@
87269663 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87279664 */
87289665
8729
- if (drawMode == DEFAULT)
9666
+ if (DrawMode() == DEFAULT)
87309667 {
87319668 currentlydrawing = true;
87329669 }
....@@ -8757,12 +9694,12 @@
87579694
87589695 // if(Applet3D.clipboard != null)
87599696 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8760
-//drawMode = SELECTION;
9697
+//DrawMode() = SELECTION;
87619698 indexcount = 0;
87629699
8763
- if (drawMode == OCCLUSION)
9700
+ if (DrawMode() == OCCLUSION)
87649701 {
8765
- drawMode = DEFAULT;
9702
+ Globals.drawMode = DEFAULT; // WARNING
87669703 ambientOcclusion = true;
87679704 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
87689705 Object3D theobject = object;
....@@ -8781,19 +9718,19 @@
87819718 ambientOcclusion = false;
87829719 }
87839720
8784
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
9721
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
87859722 {
87869723 //if (RENDERSHADOW) // ?
87879724 if (!IsFrozen())
87889725 {
87899726 // dec 2012
8790
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
9727
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
87919728 {
8792
- framecount++;
9729
+ Globals.framecount++;
87939730 shadowbuffer.display();
87949731 }
87959732 }
8796
- lighttouched = false; // ??
9733
+ Globals.lighttouched = false; // ??
87979734 //drawing = true;
87989735 //lighttouched = true;
87999736 }
....@@ -8814,9 +9751,9 @@
88149751 //eyeCamera.shaper_fovy = 1;
88159752 }
88169753
8817
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
9754
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
88189755 {
8819
- //System.out.println("drawMode = " + drawMode);
9756
+ //System.out.println("DrawMode() = " + DrawMode());
88209757 vertexMode |= VP_PASS;
88219758 //vertexMode |= VP_PROJECTION;
88229759 if (!ambientOcclusion)
....@@ -8876,7 +9813,7 @@
88769813 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
88779814 //Camera lightcam = new Camera(light0);
88789815
8879
- if (drawMode == SHADOW)
9816
+ if (DrawMode() == SHADOW)
88809817 {
88819818 /*
88829819 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8966,7 +9903,7 @@
89669903 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
89679904 } else
89689905 {
8969
- if (drawMode != DEFAULT)
9906
+ if (DrawMode() != DEFAULT)
89709907 {
89719908 gl.glClearColor(1, 1, 1, 0);
89729909 } // 1);
....@@ -9031,7 +9968,7 @@
90319968
90329969 fast &= !ambientOcclusion;
90339970
9034
- if (drawMode == DEFAULT)
9971
+ if (DrawMode() == DEFAULT)
90359972 {
90369973 //gl.glEnable(gl.GL_ALPHA_TEST);
90379974 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9092,6 +10029,8 @@
909210029 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909310030 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909410031 double scale = lightCamera.SCALE / lightCamera.Distance();
10032
+// PATCH FILLE AUX JEANS
10033
+ //scale *= lightCamera.shaper_fovy / 25;
909510034 gl.glScaled(2 * scale, 2 * scale, -scale);
909610035 gl.glTranslated(0, 0, lightCamera.DECAL);
909710036
....@@ -9227,10 +10166,12 @@
922710166 gl.glMatrixMode(gl.GL_PROJECTION);
922810167 gl.glLoadIdentity();
922910168
9230
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10169
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923110170 {
923210171 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923310172 double scale = lightCamera.SCALE / lightCamera.Distance();
10173
+// PATCH FILLE AUX JEANS
10174
+ //scale *= lightCamera.shaper_fovy / 25;
923410175 gl.glScaled(2 * scale, 2 * scale, -scale);
923510176 gl.glTranslated(0, 0, lightCamera.DECAL);
923610177 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9283,7 +10224,7 @@
928310224 //gl.glPushMatrix();
928410225 gl.glLoadIdentity();
928510226
9286
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10227
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928710228 {
928810229 //LA.xformPos(light0, lightCamera.fromScreen, light);
928910230 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9370,7 +10311,7 @@
937010311 }
937110312
937210313 /**/
9373
- if (true) // drawMode == SELECTION) // != DEFAULT)
10314
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937410315 gl.glDisable(gl.GL_LIGHTING);
937510316 else
937610317 gl.glEnable(gl.GL_LIGHTING);
....@@ -9388,7 +10329,7 @@
938810329
938910330 lightslot = 64;
939010331
9391
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10332
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939210333 {
939310334 DrawLights(object);
939410335 }
....@@ -9399,7 +10340,7 @@
939910340 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940010341 //System.out.println("fragmentMode = " + fragmentMode);
940110342
9402
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10343
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
940310344 {
940410345 /*
940510346 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9432,7 +10373,7 @@
943210373 }
943310374 }
943410375
9435
- if (drawMode == DEFAULT)
10376
+ if (DrawMode() == DEFAULT)
943610377 {
943710378 if (WIREFRAME && !ambientOcclusion)
943810379 {
....@@ -9450,7 +10391,7 @@
945010391 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945110392 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945210393
9453
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10394
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945410395 {
945510396 if (vertexMode != 0) // && !fast)
945610397 {
....@@ -9470,7 +10411,7 @@
947010411 }
947110412 }
947210413
9473
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10414
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947410415 {
947510416 //gl.glDepthFunc(GL.GL_LEQUAL);
947610417 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9498,7 +10439,7 @@
949810439 //gl.glDepthMask(false);
949910440 }
950010441
9501
- if (false) // drawMode == SHADOW)
10442
+ if (false) // DrawMode() == SHADOW)
950210443 {
950310444 //SetColumnMajorData(cameraInverseTransform, view_1);
950410445 //System.out.println("light = " + cameraInverseTransform);
....@@ -9512,16 +10453,16 @@
951210453 //System.out.println("object = " + object);
951310454 if (!frozen && !imageLocked)
951410455 {
9515
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10456
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951610457 {
951710458 displayAntiAliased(gl);
951810459 } else
951910460 {
952010461 programcount = 0;
9521
- int keepmode = drawMode;
10462
+ int keepmode = DrawMode();
952210463 // if (DEBUG_SELECTION)
952310464 // {
9524
-// drawMode = SELECTION;
10465
+// DrawMode() = SELECTION;
952510466 // }
952610467 // for point selection
952710468 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9531,10 +10472,10 @@
953110472 DrawObject(gl);
953210473
953310474 // jan 2013 System.err.println("RESET ABORT (display)");
9534
- // if (drawMode == DEFAULT)
10475
+ // if (DrawMode() == DEFAULT)
953510476 // ABORTED = false;
953610477 fullreset = false;
9537
- drawMode = keepmode;
10478
+ Globals.drawMode = keepmode; // WARNING
953810479 //System.out.println("PROGRAM SWITCH " + programcount);
953910480 }
954010481 }
....@@ -9542,11 +10483,11 @@
954210483 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954310484 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954410485
9545
- if (drawMode == DEFAULT)
10486
+ if (DrawMode() == DEFAULT)
954610487 {
954710488 ReleaseTexture(NOISE_TEXTURE, false);
954810489 }
9549
- //if (drawMode == DEFAULT)
10490
+ //if (DrawMode() == DEFAULT)
955010491 {
955110492
955210493 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9558,7 +10499,7 @@
955810499 //else
955910500 //gl.glDisable(gl.GL_TEXTURE_2D);
956010501 //gl.glPopMatrix();
9561
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10502
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956210503 {
956310504 //new Exception().printStackTrace();
956410505 //System.out.println("Draw image " + width + ", " + height);
....@@ -9600,7 +10541,7 @@
960010541 //gl.glFlush();
960110542 }
960210543
9603
- if (flash && drawMode == DEFAULT)
10544
+ if (flash && DrawMode() == DEFAULT)
960410545 {
960510546 flash = false;
960610547 wait = true;
....@@ -9608,9 +10549,9 @@
960810549 }
960910550
961010551 //drawing = false;
9611
- //if(drawMode == DEFAULT)
10552
+ //if(DrawMode() == DEFAULT)
961210553 // niceon = false;
9613
- if (drawMode == DEFAULT)
10554
+ if (DrawMode() == DEFAULT)
961410555 {
961510556 currentlydrawing = false;
961610557 }
....@@ -9630,7 +10571,7 @@
963010571 repaint();
963110572 }
963210573
9633
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10574
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963410575 repaint();
963510576
963610577 displaydone = true;
....@@ -9667,7 +10608,7 @@
966710608 if (GrafreeD.RENDERME > 0)
966810609 GrafreeD.RENDERME--; // mechante magouille
966910610
9670
- ONESTEP = false;
10611
+ Globals.ONESTEP = false;
967110612 }
967210613
967310614 static boolean zoomonce = false;
....@@ -9675,11 +10616,11 @@
967510616 void DrawObject(GL gl, boolean draw)
967610617 {
967710618 //System.out.println("DRAW OBJECT " + mouseDown);
9678
-// drawMode = SELECTION;
10619
+// DrawMode() = SELECTION;
967910620 //GL gl = getGL();
968010621 if ((TRACK || SHADOWTRACK) || zoomonce)
968110622 {
9682
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10623
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968310624 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968410625 pingthread.StepToTarget(true); // true);
968510626 // zoomonce = false;
....@@ -9700,9 +10641,9 @@
970010641 callist = gl.glGenLists(1);
970110642 }
970210643
9703
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10644
+ boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
970410645
9705
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10646
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970610647
970710648 if (!mainDL || !active || touched)
970810649 {
....@@ -9729,7 +10670,7 @@
972910670 PushMatrix(ClickInfo.matbuffer);
973010671 }
973110672
9732
- if (drawMode == 0)
10673
+ if (DrawMode() == 0)
973310674 {
973410675 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973510676
....@@ -9743,7 +10684,7 @@
974310684 // DRAW
974410685 object.draw(this, /*(Composite)*/ object, false, false);
974510686
9746
- if (drawMode == DEFAULT)
10687
+ if (DrawMode() == DEFAULT)
974710688 {
974810689 if (DEBUG)
974910690 {
....@@ -9754,40 +10695,40 @@
975410695 selectedpoint.radius = radius;
975510696 selectedpoint.recalculate();
975610697 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.15f;
10698
+ selectedpoint.material.color = 0.15f; // Yellow
975810699 selectedpoint.material.modulation = 0.75f;
975910700
9760
- debugpoint.radius = radius;
9761
- debugpoint.recalculate();
9762
- debugpoint.material = new cMaterial();
9763
- debugpoint.material.color = 0.25f;
9764
- debugpoint.material.modulation = 0.75f;
10701
+ debugpointG.radius = radius;
10702
+ debugpointG.recalculate();
10703
+ debugpointG.material = new cMaterial();
10704
+ debugpointG.material.color = 0.25f; // Green
10705
+ debugpointG.material.modulation = 0.75f;
976510706
9766
- debugpoint2.radius = radius;
9767
- debugpoint2.recalculate();
9768
- debugpoint2.material = new cMaterial();
9769
- debugpoint2.material.color = 0.75f;
9770
- debugpoint2.material.modulation = 0.75f;
10707
+ debugpointP.radius = radius;
10708
+ debugpointP.recalculate();
10709
+ debugpointP.material = new cMaterial();
10710
+ debugpointP.material.color = 0.75f; // Purple
10711
+ debugpointP.material.modulation = 0.75f;
977110712
9772
- debugpoint3.radius = radius;
9773
- debugpoint3.recalculate();
9774
- debugpoint3.material = new cMaterial();
9775
- debugpoint3.material.color = 0.5f;
9776
- debugpoint3.material.modulation = 0.75f;
10713
+ debugpointC.radius = radius;
10714
+ debugpointC.recalculate();
10715
+ debugpointC.material = new cMaterial();
10716
+ debugpointC.material.color = 0.5f; // Cyan
10717
+ debugpointC.material.modulation = 0.75f;
977710718
9778
- debugpoint4.radius = radius;
9779
- debugpoint4.recalculate();
9780
- debugpoint4.material = new cMaterial();
9781
- debugpoint4.material.color = 0f;
9782
- debugpoint4.material.modulation = 0.75f;
10719
+ debugpointR.radius = radius;
10720
+ debugpointR.recalculate();
10721
+ debugpointR.material = new cMaterial();
10722
+ debugpointR.material.color = 0f; // Red
10723
+ debugpointR.material.modulation = 0.75f;
978310724
978410725 InitPoints(radius);
978510726 }
978610727 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9787
- debugpoint.draw(this, /*(Composite)*/ null, false,false);
9788
- debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9789
- debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9790
- debugpoint4.draw(this, /*(Composite)*/ null, false,false);
10728
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
10729
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
10730
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
10731
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
979110732 // DrawPoints(this);
979210733 }
979310734
....@@ -9795,7 +10736,7 @@
979510736 }
979610737 // GrafreeD.traceoff();
979710738 //System.out.println(stackdepth);
9798
- if (drawMode == 0)
10739
+ if (DrawMode() == 0)
979910740 {
980010741 ReleaseTextures(DEFAULT_TEXTURES);
980110742
....@@ -9820,17 +10761,19 @@
982010761
982110762 checker = null;
982210763
9823
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
10764
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982410765 FindChecker(object);
982510766
9826
- if (checker != null && drawMode == DEFAULT)
10767
+ if (checker != null && DrawMode() == DEFAULT)
982710768 {
9828
- // BindTexture(IMMORTAL_TEXTURE);
10769
+ //BindTexture(IMMORTAL_TEXTURE);
10770
+ BindTextures(checker.GetTextures(), checker.texres);
982910771 // NEAREST
983010772 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
983110773 DrawChecker(gl);
983210774 //checker.Draw(this, null, false);
983310775 // ReleaseTexture(IMMORTAL_TEXTURE);
10776
+ ReleaseTextures(checker.GetTextures());
983410777 }
983510778
983610779 if (object.parent != null)
....@@ -9843,7 +10786,7 @@
984310786 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984410787 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984510788
9846
- if (DISPLAYTEXT && drawMode == DEFAULT)
10789
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984710790 {
984810791 // Draw it once, then use the raster
984910792 Balloon(gl, balloon.createGraphics());
....@@ -9899,9 +10842,9 @@
989910842 int[] xs = new int[3];
990010843 int[] ys = new int[3];
990110844
9902
- void DrawString(Object3D obj) // String string)
10845
+ public void DrawString(Object3D obj) // String string) // INTERFACE
990310846 {
9904
- if (!DISPLAYTEXT || drawMode != DEFAULT)
10847
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990510848 {
990610849 return;
990710850 }
....@@ -10388,6 +11331,7 @@
1038811331 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038911332 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1039011333 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11334
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1039111335 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1039211336 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1039311337 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -11302,6 +12246,7 @@
1130212246 String Shadow(String depth, String shadow)
1130312247 {
1130412248 return "MAX temp.x, ndotl.x, one64th.x;" +
12249
+ "MIN temp.x, temp.x, ninetenth.x;" +
1130512250 /**/
1130612251 // Sine
1130712252 "MUL temp.y, temp.x, temp.x;" +
....@@ -11926,9 +12871,10 @@
1192612871 return;
1192712872 }
1192812873
12874
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1192912875
1193012876 // TIMER
11931
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
12877
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1193212878 {
1193312879 keepboxmode = BOXMODE;
1193412880 keepsupport = SUPPORT;
....@@ -12057,7 +13003,7 @@
1205713003 // ObjEditor.tweenManager.update(1f / 60f);
1205813004
1205913005 // fev 2014???
12060
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13006
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1206113007 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1206213008 pingthread.StepToTarget(true); // true);
1206313009 }
....@@ -12308,7 +13254,7 @@
1230813254 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1230913255 if (lightMode)
1231013256 {
12311
- lighttouched = true;
13257
+ Globals.lighttouched = true;
1231213258 }
1231313259
1231413260 if (OEILONCE && OEIL)
....@@ -12366,7 +13312,7 @@
1236613312 mouseDown = false;
1236713313 if (lightMode)
1236813314 {
12369
- lighttouched = true;
13315
+ Globals.lighttouched = true;
1237013316 }
1237113317 repaint();
1237213318 alreadypainted = true;
....@@ -12374,7 +13320,7 @@
1237413320 isMoving = false;
1237513321 } //??
1237613322
12377
- if (isLIVE() && !alreadypainted)
13323
+ if (Globals.isLIVE() && !alreadypainted)
1237813324 {
1237913325 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1238013326 repaint();
....@@ -12386,7 +13332,7 @@
1238613332 {
1238713333 if (lightMode)
1238813334 {
12389
- lighttouched = true;
13335
+ Globals.lighttouched = true;
1239013336 }
1239113337 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1239213338 }
....@@ -12629,6 +13575,7 @@
1262913575 {
1263013576 manipCamera.Translate(dx, dy, getWidth());
1263113577 }
13578
+ else
1263213579 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1263313580 {
1263413581 manipCamera.RotateInterest(dx, dy);
....@@ -12639,7 +13586,7 @@
1263913586
1264013587 if (manipCamera == lightCamera)
1264113588 {
12642
- lighttouched = true;
13589
+ Globals.lighttouched = true;
1264313590 }
1264413591 /*
1264513592 switch (mode)
....@@ -12862,7 +13809,7 @@
1286213809 }
1286313810 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1286413811 {
12865
- mouseMode |= SELECT; // BACKFORTH;
13812
+ mouseMode |= SELECT;
1286613813 }
1286713814 if ((modifiers & COMMAND) == COMMAND)
1286813815 {
....@@ -13027,7 +13974,7 @@
1302713974 case 'B':
1302813975 BRISMOOTH ^= true;
1302913976 SHADOWCULLFACE ^= true;
13030
- lighttouched = true;
13977
+ Globals.lighttouched = true;
1303113978 repaint();
1303213979 break;
1303313980 case 'b':
....@@ -13127,7 +14074,7 @@
1312714074 repaint();
1312814075 break;
1312914076 case 'O':
13130
- drawMode = OCCLUSION;
14077
+ Globals.drawMode = OCCLUSION; // WARNING
1313114078 repaint();
1313214079 break;
1313314080 case 'o':
....@@ -13218,7 +14165,7 @@
1321814165 break;
1321914166 case ' ':
1322014167 lightMode ^= true;
13221
- lighttouched = true;
14168
+ Globals.lighttouched = true;
1322214169 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1322314170 targetLookAt.set(manipCamera.lookAt);
1322414171 repaint();
....@@ -13230,11 +14177,11 @@
1323014177 repaint();
1323114178 break;
1323214179 case 'Z':
13233
- RESIZETEXTURE ^= true;
13234
- break;
14180
+ //RESIZETEXTURE ^= true;
14181
+ //break;
1323514182 case 'z':
1323614183 RENDERSHADOW ^= true;
13237
- lighttouched = true;
14184
+ Globals.lighttouched = true;
1323814185 repaint();
1323914186 break;
1324014187 //case UP:
....@@ -13836,6 +14783,7 @@
1383614783 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1383714784 }
1383814785
14786
+ // To avoid clear.
1383914787 public void update(Graphics g)
1384014788 {
1384114789 paint(g);
....@@ -14438,7 +15386,7 @@
1443815386 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1443915387 gl.glPushMatrix();
1444015388 gl.glLoadIdentity();
14441
- PushMatrix(checker.toParent);
15389
+ //PushMatrix(checker.toParent);
1444215390
1444315391 gl.glMatrixMode(GL.GL_TEXTURE);
1444415392 gl.glPushMatrix();
....@@ -14461,8 +15409,8 @@
1446115409
1446215410 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1446315411
14464
- float step = 0.1666f; //0.25f;
14465
- float stepv = step * 1652 / 998;
15412
+ float step = 2; // 0.1666f; //0.25f;
15413
+ float stepv = 2; // step * 1652 / 998;
1446615414
1446715415 int i0 = 0;
1446815416 /*
....@@ -14498,20 +15446,21 @@
1449815446 /**/
1449915447 //checker.GetMaterial().opacity = 1.1f;
1450015448 ////checker.GetMaterial().ambient = 0.99f;
14501
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14502
- Object3D.selectedstack[Object3D.materialdepth] = false;
14503
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15449
+ materialstack[materialdepth] = checker.material;
15450
+ selectedstack[materialdepth] = false;
15451
+ cStatic.objectstack[materialdepth++] = checker;
1450415452 //System.out.println("material " + material);
1450515453 //Applet3D.tracein(this, selected);
1450615454 vector2buffer = checker.projectedVertices;
1450715455
14508
- checker.GetMaterial().Draw(this, false); // true);
15456
+ //checker.GetMaterial().Draw(this, false); // true);
15457
+ DrawMaterial(checker.GetMaterial(), false); // true);
1450915458
14510
- Object3D.materialdepth -= 1;
14511
- if (Object3D.materialdepth > 0)
15459
+ materialdepth -= 1;
15460
+ if (materialdepth > 0)
1451215461 {
14513
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14514
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
15462
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15463
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1451515464 }
1451615465 //checker.GetMaterial().opacity = 1f;
1451715466 ////checker.GetMaterial().ambient = 1f;
....@@ -14532,15 +15481,27 @@
1453215481
1453315482 //float u = (i+1)/2;
1453415483 //float v = (j+1)/2;
14535
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
15484
+ if (checker.flipV)
15485
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
15486
+ else
15487
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1453615488 gl.glVertex3f(i, j, -0.5f);
1453715489
15490
+ if (checker.flipV)
15491
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
15492
+ else
1453815493 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1453915494 gl.glVertex3f(i + step, j, -0.5f);
1454015495
15496
+ if (checker.flipV)
15497
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
15498
+ else
1454115499 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1454215500 gl.glVertex3f(i + step, j + stepv, -0.5f);
1454315501
15502
+ if (checker.flipV)
15503
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
15504
+ else
1454415505 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1454515506 gl.glVertex3f(i, j + stepv, -0.5f);
1454615507 }
....@@ -14552,7 +15513,7 @@
1455215513 gl.glMatrixMode(GL.GL_PROJECTION);
1455315514 gl.glPopMatrix();
1455415515 gl.glMatrixMode(GL.GL_MODELVIEW);
14555
- PopMatrix(null); // checker.toParent); // null);
15516
+ //PopMatrix(null); // checker.toParent); // null);
1455615517 gl.glPopMatrix();
1455715518 PopTextureMatrix(checker.toParent);
1455815519 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14665,14 +15626,14 @@
1466515626
1466615627 //int tmp = selection_view;
1466715628 //selection_view = -1;
14668
- int temp = drawMode;
14669
- drawMode = SELECTION;
15629
+ int temp = DrawMode();
15630
+ Globals.drawMode = SELECTION; // WARNING
1467015631 indexcount = 0;
1467115632 parent.display(drawable);
1467215633 //selection_view = tmp;
1467315634 //if (temp == SELECTION)
1467415635 // temp = DEFAULT; // patch for selection debug
14675
- drawMode = temp;
15636
+ Globals.drawMode = temp; // WARNING
1467615637
1467715638 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1467815639
....@@ -14945,14 +15906,14 @@
1494515906 //gl.glColorMask(false, false, false, false);
1494615907
1494715908 //render_scene_from_light_view(gl, drawable, 0, 0);
14948
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
15909
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1494915910 {
1495015911 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1495115912
14952
- int temp = drawMode;
14953
- drawMode = SHADOW;
15913
+ int temp = DrawMode();
15914
+ Globals.drawMode = SHADOW; // WARNING
1495415915 parent.display(drawable);
14955
- drawMode = temp;
15916
+ Globals.drawMode = temp; // WARNING
1495615917 }
1495715918
1495815919 gl.glCullFace(gl.GL_BACK);
....@@ -15115,13 +16076,19 @@
1511516076 gl.glFlush();
1511616077
1511716078 /**/
15118
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16079
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1511916080
15120
- int[] pixels = occlusionsizebuffer.array();
16081
+ float[] pixels = occlusionsizebuffer.array();
1512116082
1512216083 double r = 0, g = 0, b = 0;
1512316084
1512416085 double count = 0;
16086
+
16087
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16088
+
16089
+ float mindepth = 1;
16090
+
16091
+ double FACTOR = 1;
1512516092
1512616093 for (int i = 0; i < pixels.length; i++)
1512716094 {
....@@ -15206,7 +16173,7 @@
1520616173
1520716174 double scale = ray.z; // 1; // cos
1520816175
15209
- int p = pixels[newindex];
16176
+ float depth = pixels[newindex];
1521016177
1521116178 /*
1521216179 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15230,10 +16197,23 @@
1523016197 scale = (1 - modu) * modv;
1523116198 */
1523216199
15233
- r += ((p >> 16) & 0xFF) * scale / 255;
15234
- g += ((p >> 8) & 0xFF) * scale / 255;
15235
- b += (p & 0xFF) * scale / 255;
16200
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16201
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16202
+ //b += (p & 0xFF) * scale / 255;
16203
+
16204
+ if (mindepth > depth)
16205
+ {
16206
+ mindepth = depth;
16207
+ }
1523616208
16209
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16210
+
16211
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16212
+
16213
+ r += factor * scale;
16214
+ g += factor * scale;
16215
+ b += factor * scale;
16216
+
1523716217 count += scale;
1523816218 }
1523916219
....@@ -15331,12 +16311,6 @@
1533116311 GLUT glut = new GLUT();
1533216312
1533316313
15334
- static final public int DEFAULT = 0;
15335
- static final public int SELECTION = 1;
15336
- static final public int SHADOW = 2;
15337
- static final public int OCCLUSION = 3;
15338
- static
15339
- public int drawMode = DEFAULT;
1534016314 public boolean spherical = false;
1534116315 static boolean DEBUG_OCCLUSION = false;
1534216316 static boolean DEBUG_SELECTION = false;
....@@ -15351,10 +16325,10 @@
1535116325 //double[] selectedpoint = new double[3];
1535216326 static Superellipsoid selectedpoint = new Superellipsoid();
1535316327 static Sphere previousselectedpoint = null;
15354
- static Sphere debugpoint = new Sphere();
15355
- static Sphere debugpoint2 = new Sphere();
15356
- static Sphere debugpoint3 = new Sphere();
15357
- static Sphere debugpoint4 = new Sphere();
16328
+ static Sphere debugpointG = new Sphere();
16329
+ static Sphere debugpointP = new Sphere();
16330
+ static Sphere debugpointC = new Sphere();
16331
+ static Sphere debugpointR = new Sphere();
1535816332
1535916333 static Sphere debugpoints[] = new Sphere[8];
1536016334
....@@ -15407,7 +16381,8 @@
1540716381 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1540816382 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1540916383 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15410
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16384
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16385
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1541116386 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1541216387 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1541316388 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();