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,8 +149,9 @@
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;
....@@ -206,12 +191,19 @@
206191 return CURRENTANTIALIAS > 0;
207192 }
208193
209
- void ClearDepth()
194
+ /// INTERFACE
195
+
196
+ public boolean IsBoxMode()
197
+ {
198
+ return BOXMODE;
199
+ }
200
+
201
+ public void ClearDepth()
210202 {
211203 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
212204 }
213205
214
- void DepthTest(boolean depthtest)
206
+ public void DepthTest(boolean depthtest)
215207 {
216208 if (depthtest)
217209 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -219,7 +211,7 @@
219211 GetGL().glDepthFunc(GL.GL_ALWAYS);
220212 }
221213
222
- void DepthWrite(boolean depthwrite)
214
+ public void DepthWrite(boolean depthwrite)
223215 {
224216 if (depthwrite)
225217 GetGL().glDepthMask(true);
....@@ -227,12 +219,1265 @@
227219 GetGL().glDepthMask(false);
228220 }
229221
230
- void BackFaceCull(boolean bfc)
222
+ public void BackFaceCull(boolean bfc)
231223 {
232224 if (bfc)
233225 GetGL().glEnable(GetGL().GL_CULL_FACE);
234226 else
235227 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
+ }
2361481 }
2371482
2381483 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -253,7 +1498,7 @@
2531498 currentGL.glMultMatrixd(model, 0);
2541499 }
2551500
256
- void PushMatrix(double[][] matrix, int count)
1501
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2571502 {
2581503 matrixdepth++;
2591504 // GrafreeD.tracein(matrix);
....@@ -298,7 +1543,7 @@
2981543
2991544 double[][] tmpmat = new double[4][4];
3001545
301
- void PopMatrix(double[][] inverse)
1546
+ public void PopMatrix(double[][] inverse) // INTERFACE
3021547 {
3031548 --matrixdepth;
3041549
....@@ -338,7 +1583,7 @@
3381583 PushTextureMatrix(matrix, 1);
3391584 }
3401585
341
- void PushTextureMatrix(double[][] matrix, int count)
1586
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3421587 {
3431588 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3441589
....@@ -352,7 +1597,7 @@
3521597 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3531598 }
3541599
355
- void PopTextureMatrix(double[][] inverse)
1600
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3561601 {
3571602 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3581603 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -384,10 +1629,10 @@
3841629 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3851630 // return false;
3861631
387
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1632
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3881633 {
3891634 // check for last change
390
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1635
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3911636 {
3921637 // refuse the camera change
3931638 System.err.println("Camera " + cam + " REFUSED");
....@@ -395,7 +1640,7 @@
3951640 }
3961641 }
3971642
398
- camerachangeframe = framecount;
1643
+ camerachangeframe = Globals.framecount;
3991644
4001645 cam.hAspect = -1; // Read only
4011646
....@@ -426,7 +1671,7 @@
4261671 {
4271672 //System.err.println("Oeil on");
4281673 TRACK = true;
429
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1674
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4301675 // object.editWindow.ScreenFit(trackedobject);
4311676 //pingthread.StepToTarget(true);
4321677 }
....@@ -435,7 +1680,7 @@
4351680 {
4361681 //System.err.println("Oeil on");
4371682 OEIL = true;
438
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1683
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4391684 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4401685 //pingthread.StepToTarget(true);
4411686 }
....@@ -499,7 +1744,7 @@
4991744 {
5001745 frozen ^= true;
5011746 // Weird...
502
- lighttouched = true;
1747
+ Globals.lighttouched = true;
5031748 }
5041749
5051750 void ToggleDL()
....@@ -514,11 +1759,11 @@
5141759
5151760 void ToggleLive()
5161761 {
517
- setLIVE(isLIVE() ^ true);
1762
+ Globals.setLIVE(Globals.isLIVE() ^ true);
5181763
519
- System.err.println("LIVE = " + isLIVE());
1764
+ System.err.println("LIVE = " + Globals.isLIVE());
5201765
521
- if (!isLIVE()) // save sound
1766
+ if (!Globals.isLIVE()) // save sound
5221767 GrafreeD.savesound = true; // wav.save();
5231768 // else
5241769 repaint(); // start loop // may 2013
....@@ -541,7 +1786,7 @@
5411786
5421787 void ToggleCrowd()
5431788 {
544
- CROWD ^= true;
1789
+ Globals.CROWD ^= true;
5451790 }
5461791
5471792 void ToggleInertia()
....@@ -759,7 +2004,7 @@
7592004
7602005 GL currentGL;
7612006
762
- GL GetGL()
2007
+ public GL GetGL() // INTERFACE
7632008 {
7642009 return currentGL;
7652010 }
....@@ -6271,7 +7516,7 @@
62717516 return null;
62727517 }
62737518
6274
- void ReleaseTextures(cTexture tex)
7519
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757520 {
62767521 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777522 {
....@@ -6309,7 +7554,7 @@
63097554
63107555 void ReleaseTexture(String tex, boolean bump)
63117556 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
7557
+ if (// DrawMode() != 0 || /*tex == null ||*/
63137558 ambientOcclusion ) // || !textureon)
63147559 {
63157560 return;
....@@ -6410,9 +7655,9 @@
64107655 }
64117656 }
64127657
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7658
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64147659 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
7660
+ if (// DrawMode() != 0 || /*tex == null ||*/
64167661 ambientOcclusion ) // || !textureon)
64177662 {
64187663 return; // false;
....@@ -7312,9 +8557,9 @@
73128557 static boolean occlusionInitialized = false;
73138558 boolean selection = false;
73148559 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
8560
+ ///*static*/ boolean lighttouched = true;
73168561 boolean deselect;
7317
- boolean ambientOcclusion = false;
8562
+ private boolean ambientOcclusion = false;
73188563 static boolean flash = false;
73198564 /*static*/ boolean wait = false;
73208565 boolean displaydone = false; // after repaint() calls
....@@ -7603,8 +8848,6 @@
76038848
76048849 boolean restartframe = false;
76058850
7606
- static int framecount = 0; // general-purpose global count
7607
-
76088851 void displayAntiAliased(javax.media.opengl.GL gl)
76098852 {
76108853 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7635,7 +8878,7 @@
76358878 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76368879 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76378880 {
7638
- framecount++;
8881
+ Globals.framecount++;
76398882
76408883 if (CameraPane.tickcount > 0)
76418884 CameraPane.tickcount--;
....@@ -7673,7 +8916,7 @@
76738916
76748917 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76758918 */
7676
- lighttouched = true;
8919
+ Globals.lighttouched = true;
76778920 //System.err.println(" shadowbuffer: " + jitter);
76788921 shadowbuffer.display();
76798922
....@@ -8620,13 +9863,6 @@
86209863 }
86219864 }
86229865
8623
- boolean IsFrozen()
8624
- {
8625
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8626
-
8627
- return !selectmode && cameracount == 0; // != 0;
8628
- }
8629
-
86309866 boolean niceon = false;
86319867 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86329868 boolean currentlydrawing = false;
....@@ -8644,8 +9880,8 @@
86449880 }
86459881 // if (DEBUG_SELECTION)
86469882 // {
8647
-// if (drawMode != SELECTION)
8648
-// drawMode = SELECTION;
9883
+// if (DrawMode() != SELECTION)
9884
+// DrawMode() = SELECTION;
86499885 // }
86509886
86519887 if (!isRenderer)
....@@ -8701,9 +9937,9 @@
87019937
87029938 //ANTIALIAS = 0;
87039939
8704
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9940
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
87059941 {
8706
- if (niceon || isLIVE())
9942
+ if (niceon || Globals.isLIVE())
87079943 {
87089944 //if(active == 0)
87099945 // antialiaser = null;
....@@ -8728,7 +9964,7 @@
87289964 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87299965 */
87309966
8731
- if (drawMode == DEFAULT)
9967
+ if (DrawMode() == DEFAULT)
87329968 {
87339969 currentlydrawing = true;
87349970 }
....@@ -8759,12 +9995,12 @@
87599995
87609996 // if(Applet3D.clipboard != null)
87619997 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8762
-//drawMode = SELECTION;
9998
+//DrawMode() = SELECTION;
87639999 indexcount = 0;
876410000
8765
- if (drawMode == OCCLUSION)
10001
+ if (DrawMode() == OCCLUSION)
876610002 {
8767
- drawMode = DEFAULT;
10003
+ Globals.drawMode = DEFAULT; // WARNING
876810004 ambientOcclusion = true;
876910005 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
877010006 Object3D theobject = object;
....@@ -8783,19 +10019,19 @@
878310019 ambientOcclusion = false;
878410020 }
878510021
8786
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10022
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
878710023 {
878810024 //if (RENDERSHADOW) // ?
878910025 if (!IsFrozen())
879010026 {
879110027 // dec 2012
8792
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10028
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
879310029 {
8794
- framecount++;
10030
+ Globals.framecount++;
879510031 shadowbuffer.display();
879610032 }
879710033 }
8798
- lighttouched = false; // ??
10034
+ Globals.lighttouched = false; // ??
879910035 //drawing = true;
880010036 //lighttouched = true;
880110037 }
....@@ -8816,9 +10052,9 @@
881610052 //eyeCamera.shaper_fovy = 1;
881710053 }
881810054
8819
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10055
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
882010056 {
8821
- //System.out.println("drawMode = " + drawMode);
10057
+ //System.out.println("DrawMode() = " + DrawMode());
882210058 vertexMode |= VP_PASS;
882310059 //vertexMode |= VP_PROJECTION;
882410060 if (!ambientOcclusion)
....@@ -8878,7 +10114,7 @@
887810114 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887910115 //Camera lightcam = new Camera(light0);
888010116
8881
- if (drawMode == SHADOW)
10117
+ if (DrawMode() == SHADOW)
888210118 {
888310119 /*
888410120 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8968,7 +10204,7 @@
896810204 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896910205 } else
897010206 {
8971
- if (drawMode != DEFAULT)
10207
+ if (DrawMode() != DEFAULT)
897210208 {
897310209 gl.glClearColor(1, 1, 1, 0);
897410210 } // 1);
....@@ -9033,7 +10269,7 @@
903310269
903410270 fast &= !ambientOcclusion;
903510271
9036
- if (drawMode == DEFAULT)
10272
+ if (DrawMode() == DEFAULT)
903710273 {
903810274 //gl.glEnable(gl.GL_ALPHA_TEST);
903910275 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9231,7 +10467,7 @@
923110467 gl.glMatrixMode(gl.GL_PROJECTION);
923210468 gl.glLoadIdentity();
923310469
9234
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10470
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923510471 {
923610472 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923710473 double scale = lightCamera.SCALE / lightCamera.Distance();
....@@ -9289,7 +10525,7 @@
928910525 //gl.glPushMatrix();
929010526 gl.glLoadIdentity();
929110527
9292
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10528
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
929310529 {
929410530 //LA.xformPos(light0, lightCamera.fromScreen, light);
929510531 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9376,7 +10612,7 @@
937610612 }
937710613
937810614 /**/
9379
- if (true) // drawMode == SELECTION) // != DEFAULT)
10615
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
938010616 gl.glDisable(gl.GL_LIGHTING);
938110617 else
938210618 gl.glEnable(gl.GL_LIGHTING);
....@@ -9394,7 +10630,7 @@
939410630
939510631 lightslot = 64;
939610632
9397
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10633
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939810634 {
939910635 DrawLights(object);
940010636 }
....@@ -9405,7 +10641,7 @@
940510641 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940610642 //System.out.println("fragmentMode = " + fragmentMode);
940710643
9408
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10644
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
940910645 {
941010646 /*
941110647 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9438,7 +10674,7 @@
943810674 }
943910675 }
944010676
9441
- if (drawMode == DEFAULT)
10677
+ if (DrawMode() == DEFAULT)
944210678 {
944310679 if (WIREFRAME && !ambientOcclusion)
944410680 {
....@@ -9456,7 +10692,7 @@
945610692 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945710693 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945810694
9459
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10695
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
946010696 {
946110697 if (vertexMode != 0) // && !fast)
946210698 {
....@@ -9476,7 +10712,7 @@
947610712 }
947710713 }
947810714
9479
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10715
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
948010716 {
948110717 //gl.glDepthFunc(GL.GL_LEQUAL);
948210718 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9504,7 +10740,7 @@
950410740 //gl.glDepthMask(false);
950510741 }
950610742
9507
- if (false) // drawMode == SHADOW)
10743
+ if (false) // DrawMode() == SHADOW)
950810744 {
950910745 //SetColumnMajorData(cameraInverseTransform, view_1);
951010746 //System.out.println("light = " + cameraInverseTransform);
....@@ -9518,16 +10754,16 @@
951810754 //System.out.println("object = " + object);
951910755 if (!frozen && !imageLocked)
952010756 {
9521
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10757
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
952210758 {
952310759 displayAntiAliased(gl);
952410760 } else
952510761 {
952610762 programcount = 0;
9527
- int keepmode = drawMode;
10763
+ int keepmode = DrawMode();
952810764 // if (DEBUG_SELECTION)
952910765 // {
9530
-// drawMode = SELECTION;
10766
+// DrawMode() = SELECTION;
953110767 // }
953210768 // for point selection
953310769 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9537,10 +10773,10 @@
953710773 DrawObject(gl);
953810774
953910775 // jan 2013 System.err.println("RESET ABORT (display)");
9540
- // if (drawMode == DEFAULT)
10776
+ // if (DrawMode() == DEFAULT)
954110777 // ABORTED = false;
954210778 fullreset = false;
9543
- drawMode = keepmode;
10779
+ Globals.drawMode = keepmode; // WARNING
954410780 //System.out.println("PROGRAM SWITCH " + programcount);
954510781 }
954610782 }
....@@ -9548,11 +10784,11 @@
954810784 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954910785 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
955010786
9551
- if (drawMode == DEFAULT)
10787
+ if (DrawMode() == DEFAULT)
955210788 {
955310789 ReleaseTexture(NOISE_TEXTURE, false);
955410790 }
9555
- //if (drawMode == DEFAULT)
10791
+ //if (DrawMode() == DEFAULT)
955610792 {
955710793
955810794 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9564,7 +10800,7 @@
956410800 //else
956510801 //gl.glDisable(gl.GL_TEXTURE_2D);
956610802 //gl.glPopMatrix();
9567
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10803
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956810804 {
956910805 //new Exception().printStackTrace();
957010806 //System.out.println("Draw image " + width + ", " + height);
....@@ -9606,7 +10842,7 @@
960610842 //gl.glFlush();
960710843 }
960810844
9609
- if (flash && drawMode == DEFAULT)
10845
+ if (flash && DrawMode() == DEFAULT)
961010846 {
961110847 flash = false;
961210848 wait = true;
....@@ -9614,9 +10850,9 @@
961410850 }
961510851
961610852 //drawing = false;
9617
- //if(drawMode == DEFAULT)
10853
+ //if(DrawMode() == DEFAULT)
961810854 // niceon = false;
9619
- if (drawMode == DEFAULT)
10855
+ if (DrawMode() == DEFAULT)
962010856 {
962110857 currentlydrawing = false;
962210858 }
....@@ -9636,7 +10872,7 @@
963610872 repaint();
963710873 }
963810874
9639
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10875
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
964010876 repaint();
964110877
964210878 displaydone = true;
....@@ -9673,7 +10909,7 @@
967310909 if (GrafreeD.RENDERME > 0)
967410910 GrafreeD.RENDERME--; // mechante magouille
967510911
9676
- ONESTEP = false;
10912
+ Globals.ONESTEP = false;
967710913 }
967810914
967910915 static boolean zoomonce = false;
....@@ -9681,11 +10917,11 @@
968110917 void DrawObject(GL gl, boolean draw)
968210918 {
968310919 //System.out.println("DRAW OBJECT " + mouseDown);
9684
-// drawMode = SELECTION;
10920
+// DrawMode() = SELECTION;
968510921 //GL gl = getGL();
968610922 if ((TRACK || SHADOWTRACK) || zoomonce)
968710923 {
9688
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10924
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968910925 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
969010926 pingthread.StepToTarget(true); // true);
969110927 // zoomonce = false;
....@@ -9706,9 +10942,9 @@
970610942 callist = gl.glGenLists(1);
970710943 }
970810944
9709
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10945
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
971010946
9711
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10947
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
971210948
971310949 if (!mainDL || !active || touched)
971410950 {
....@@ -9735,7 +10971,7 @@
973510971 PushMatrix(ClickInfo.matbuffer);
973610972 }
973710973
9738
- if (drawMode == 0)
10974
+ if (DrawMode() == 0)
973910975 {
974010976 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
974110977
....@@ -9749,7 +10985,7 @@
974910985 // DRAW
975010986 object.draw(this, /*(Composite)*/ object, false, false);
975110987
9752
- if (drawMode == DEFAULT)
10988
+ if (DrawMode() == DEFAULT)
975310989 {
975410990 if (DEBUG)
975510991 {
....@@ -9801,7 +11037,7 @@
980111037 }
980211038 // GrafreeD.traceoff();
980311039 //System.out.println(stackdepth);
9804
- if (drawMode == 0)
11040
+ if (DrawMode() == 0)
980511041 {
980611042 ReleaseTextures(DEFAULT_TEXTURES);
980711043
....@@ -9826,10 +11062,10 @@
982611062
982711063 checker = null;
982811064
9829
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11065
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
983011066 FindChecker(object);
983111067
9832
- if (checker != null && drawMode == DEFAULT)
11068
+ if (checker != null && DrawMode() == DEFAULT)
983311069 {
983411070 //BindTexture(IMMORTAL_TEXTURE);
983511071 BindTextures(checker.GetTextures(), checker.texres);
....@@ -9851,7 +11087,7 @@
985111087 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
985211088 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
985311089
9854
- if (DISPLAYTEXT && drawMode == DEFAULT)
11090
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
985511091 {
985611092 // Draw it once, then use the raster
985711093 Balloon(gl, balloon.createGraphics());
....@@ -9907,9 +11143,9 @@
990711143 int[] xs = new int[3];
990811144 int[] ys = new int[3];
990911145
9910
- void DrawString(Object3D obj) // String string)
11146
+ public void DrawString(Object3D obj) // String string) // INTERFACE
991111147 {
9912
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11148
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
991311149 {
991411150 return;
991511151 }
....@@ -12068,7 +13304,7 @@
1206813304 // ObjEditor.tweenManager.update(1f / 60f);
1206913305
1207013306 // fev 2014???
12071
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13307
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1207213308 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1207313309 pingthread.StepToTarget(true); // true);
1207413310 }
....@@ -12180,6 +13416,11 @@
1218013416 cVector tmp = new cVector();
1218113417 cVector tmp2 = new cVector();
1218213418 boolean isMoving;
13419
+
13420
+ public cVector TargetLookAt()
13421
+ {
13422
+ return targetLookAt;
13423
+ }
1218313424
1218413425 class PingThread extends Thread
1218513426 {
....@@ -12319,7 +13560,7 @@
1231913560 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1232013561 if (lightMode)
1232113562 {
12322
- lighttouched = true;
13563
+ Globals.lighttouched = true;
1232313564 }
1232413565
1232513566 if (OEILONCE && OEIL)
....@@ -12377,7 +13618,7 @@
1237713618 mouseDown = false;
1237813619 if (lightMode)
1237913620 {
12380
- lighttouched = true;
13621
+ Globals.lighttouched = true;
1238113622 }
1238213623 repaint();
1238313624 alreadypainted = true;
....@@ -12385,7 +13626,7 @@
1238513626 isMoving = false;
1238613627 } //??
1238713628
12388
- if (isLIVE() && !alreadypainted)
13629
+ if (Globals.isLIVE() && !alreadypainted)
1238913630 {
1239013631 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1239113632 repaint();
....@@ -12397,7 +13638,7 @@
1239713638 {
1239813639 if (lightMode)
1239913640 {
12400
- lighttouched = true;
13641
+ Globals.lighttouched = true;
1240113642 }
1240213643 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1240313644 }
....@@ -12651,7 +13892,7 @@
1265113892
1265213893 if (manipCamera == lightCamera)
1265313894 {
12654
- lighttouched = true;
13895
+ Globals.lighttouched = true;
1265513896 }
1265613897 /*
1265713898 switch (mode)
....@@ -13039,7 +14280,7 @@
1303914280 case 'B':
1304014281 BRISMOOTH ^= true;
1304114282 SHADOWCULLFACE ^= true;
13042
- lighttouched = true;
14283
+ Globals.lighttouched = true;
1304314284 repaint();
1304414285 break;
1304514286 case 'b':
....@@ -13139,7 +14380,7 @@
1313914380 repaint();
1314014381 break;
1314114382 case 'O':
13142
- drawMode = OCCLUSION;
14383
+ Globals.drawMode = OCCLUSION; // WARNING
1314314384 repaint();
1314414385 break;
1314514386 case 'o':
....@@ -13230,7 +14471,7 @@
1323014471 break;
1323114472 case ' ':
1323214473 lightMode ^= true;
13233
- lighttouched = true;
14474
+ Globals.lighttouched = true;
1323414475 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1323514476 targetLookAt.set(manipCamera.lookAt);
1323614477 repaint();
....@@ -13246,7 +14487,7 @@
1324614487 //break;
1324714488 case 'z':
1324814489 RENDERSHADOW ^= true;
13249
- lighttouched = true;
14490
+ Globals.lighttouched = true;
1325014491 repaint();
1325114492 break;
1325214493 //case UP:
....@@ -13848,6 +15089,7 @@
1384815089 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1384915090 }
1385015091
15092
+ // To avoid clear.
1385115093 public void update(Graphics g)
1385215094 {
1385315095 paint(g);
....@@ -14510,20 +15752,21 @@
1451015752 /**/
1451115753 //checker.GetMaterial().opacity = 1.1f;
1451215754 ////checker.GetMaterial().ambient = 0.99f;
14513
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14514
- Object3D.selectedstack[Object3D.materialdepth] = false;
14515
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15755
+ materialstack[materialdepth] = checker.material;
15756
+ selectedstack[materialdepth] = false;
15757
+ cStatic.objectstack[materialdepth++] = checker;
1451615758 //System.out.println("material " + material);
1451715759 //Applet3D.tracein(this, selected);
1451815760 vector2buffer = checker.projectedVertices;
1451915761
14520
- checker.GetMaterial().Draw(this, false); // true);
15762
+ //checker.GetMaterial().Draw(this, false); // true);
15763
+ DrawMaterial(checker.GetMaterial(), false); // true);
1452115764
14522
- Object3D.materialdepth -= 1;
14523
- if (Object3D.materialdepth > 0)
15765
+ materialdepth -= 1;
15766
+ if (materialdepth > 0)
1452415767 {
14525
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14526
- 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]);
1452715770 }
1452815771 //checker.GetMaterial().opacity = 1f;
1452915772 ////checker.GetMaterial().ambient = 1f;
....@@ -14689,14 +15932,14 @@
1468915932
1469015933 //int tmp = selection_view;
1469115934 //selection_view = -1;
14692
- int temp = drawMode;
14693
- drawMode = SELECTION;
15935
+ int temp = DrawMode();
15936
+ Globals.drawMode = SELECTION; // WARNING
1469415937 indexcount = 0;
1469515938 parent.display(drawable);
1469615939 //selection_view = tmp;
1469715940 //if (temp == SELECTION)
1469815941 // temp = DEFAULT; // patch for selection debug
14699
- drawMode = temp;
15942
+ Globals.drawMode = temp; // WARNING
1470015943
1470115944 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1470215945
....@@ -14969,14 +16212,14 @@
1496916212 //gl.glColorMask(false, false, false, false);
1497016213
1497116214 //render_scene_from_light_view(gl, drawable, 0, 0);
14972
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16215
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1497316216 {
1497416217 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1497516218
14976
- int temp = drawMode;
14977
- drawMode = SHADOW;
16219
+ int temp = DrawMode();
16220
+ Globals.drawMode = SHADOW; // WARNING
1497816221 parent.display(drawable);
14979
- drawMode = temp;
16222
+ Globals.drawMode = temp; // WARNING
1498016223 }
1498116224
1498216225 gl.glCullFace(gl.GL_BACK);
....@@ -15029,7 +16272,6 @@
1502916272
1503016273 class AntialiasBuffer implements GLEventListener
1503116274 {
15032
-
1503316275 CameraPane parent = null;
1503416276
1503516277 AntialiasBuffer(CameraPane p)
....@@ -15374,12 +16616,6 @@
1537416616 GLUT glut = new GLUT();
1537516617
1537616618
15377
- static final public int DEFAULT = 0;
15378
- static final public int SELECTION = 1;
15379
- static final public int SHADOW = 2;
15380
- static final public int OCCLUSION = 3;
15381
- static
15382
- public int drawMode = DEFAULT;
1538316619 public boolean spherical = false;
1538416620 static boolean DEBUG_OCCLUSION = false;
1538516621 static boolean DEBUG_SELECTION = false;
....@@ -15428,7 +16664,7 @@
1542816664 }
1542916665 }
1543016666
15431
- static void DrawPoints(CameraPane cpane)
16667
+ static void DrawPoints(iCameraPane cpane)
1543216668 {
1543316669 for (int i=0; i<8; i++) // first and last are red
1543416670 {