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
....@@ -7603,8 +8547,6 @@
76038547
76048548 boolean restartframe = false;
76058549
7606
- static int framecount = 0; // general-purpose global count
7607
-
76088550 void displayAntiAliased(javax.media.opengl.GL gl)
76098551 {
76108552 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7635,7 +8577,7 @@
76358577 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76368578 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76378579 {
7638
- framecount++;
8580
+ Globals.framecount++;
76398581
76408582 if (CameraPane.tickcount > 0)
76418583 CameraPane.tickcount--;
....@@ -7673,7 +8615,7 @@
76738615
76748616 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76758617 */
7676
- lighttouched = true;
8618
+ Globals.lighttouched = true;
76778619 //System.err.println(" shadowbuffer: " + jitter);
76788620 shadowbuffer.display();
76798621
....@@ -8620,13 +9562,6 @@
86209562 }
86219563 }
86229564
8623
- boolean IsFrozen()
8624
- {
8625
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8626
-
8627
- return !selectmode && cameracount == 0; // != 0;
8628
- }
8629
-
86309565 boolean niceon = false;
86319566 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86329567 boolean currentlydrawing = false;
....@@ -8644,8 +9579,8 @@
86449579 }
86459580 // if (DEBUG_SELECTION)
86469581 // {
8647
-// if (drawMode != SELECTION)
8648
-// drawMode = SELECTION;
9582
+// if (DrawMode() != SELECTION)
9583
+// DrawMode() = SELECTION;
86499584 // }
86509585
86519586 if (!isRenderer)
....@@ -8701,9 +9636,9 @@
87019636
87029637 //ANTIALIAS = 0;
87039638
8704
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9639
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
87059640 {
8706
- if (niceon || isLIVE())
9641
+ if (niceon || Globals.isLIVE())
87079642 {
87089643 //if(active == 0)
87099644 // antialiaser = null;
....@@ -8728,7 +9663,7 @@
87289663 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87299664 */
87309665
8731
- if (drawMode == DEFAULT)
9666
+ if (DrawMode() == DEFAULT)
87329667 {
87339668 currentlydrawing = true;
87349669 }
....@@ -8759,12 +9694,12 @@
87599694
87609695 // if(Applet3D.clipboard != null)
87619696 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8762
-//drawMode = SELECTION;
9697
+//DrawMode() = SELECTION;
87639698 indexcount = 0;
87649699
8765
- if (drawMode == OCCLUSION)
9700
+ if (DrawMode() == OCCLUSION)
87669701 {
8767
- drawMode = DEFAULT;
9702
+ Globals.drawMode = DEFAULT; // WARNING
87689703 ambientOcclusion = true;
87699704 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
87709705 Object3D theobject = object;
....@@ -8783,19 +9718,19 @@
87839718 ambientOcclusion = false;
87849719 }
87859720
8786
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
9721
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
87879722 {
87889723 //if (RENDERSHADOW) // ?
87899724 if (!IsFrozen())
87909725 {
87919726 // dec 2012
8792
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
9727
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
87939728 {
8794
- framecount++;
9729
+ Globals.framecount++;
87959730 shadowbuffer.display();
87969731 }
87979732 }
8798
- lighttouched = false; // ??
9733
+ Globals.lighttouched = false; // ??
87999734 //drawing = true;
88009735 //lighttouched = true;
88019736 }
....@@ -8816,9 +9751,9 @@
88169751 //eyeCamera.shaper_fovy = 1;
88179752 }
88189753
8819
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
9754
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
88209755 {
8821
- //System.out.println("drawMode = " + drawMode);
9756
+ //System.out.println("DrawMode() = " + DrawMode());
88229757 vertexMode |= VP_PASS;
88239758 //vertexMode |= VP_PROJECTION;
88249759 if (!ambientOcclusion)
....@@ -8878,7 +9813,7 @@
88789813 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
88799814 //Camera lightcam = new Camera(light0);
88809815
8881
- if (drawMode == SHADOW)
9816
+ if (DrawMode() == SHADOW)
88829817 {
88839818 /*
88849819 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8968,7 +9903,7 @@
89689903 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
89699904 } else
89709905 {
8971
- if (drawMode != DEFAULT)
9906
+ if (DrawMode() != DEFAULT)
89729907 {
89739908 gl.glClearColor(1, 1, 1, 0);
89749909 } // 1);
....@@ -9033,7 +9968,7 @@
90339968
90349969 fast &= !ambientOcclusion;
90359970
9036
- if (drawMode == DEFAULT)
9971
+ if (DrawMode() == DEFAULT)
90379972 {
90389973 //gl.glEnable(gl.GL_ALPHA_TEST);
90399974 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9231,7 +10166,7 @@
923110166 gl.glMatrixMode(gl.GL_PROJECTION);
923210167 gl.glLoadIdentity();
923310168
9234
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10169
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923510170 {
923610171 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923710172 double scale = lightCamera.SCALE / lightCamera.Distance();
....@@ -9289,7 +10224,7 @@
928910224 //gl.glPushMatrix();
929010225 gl.glLoadIdentity();
929110226
9292
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10227
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
929310228 {
929410229 //LA.xformPos(light0, lightCamera.fromScreen, light);
929510230 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9376,7 +10311,7 @@
937610311 }
937710312
937810313 /**/
9379
- if (true) // drawMode == SELECTION) // != DEFAULT)
10314
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
938010315 gl.glDisable(gl.GL_LIGHTING);
938110316 else
938210317 gl.glEnable(gl.GL_LIGHTING);
....@@ -9394,7 +10329,7 @@
939410329
939510330 lightslot = 64;
939610331
9397
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10332
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939810333 {
939910334 DrawLights(object);
940010335 }
....@@ -9405,7 +10340,7 @@
940510340 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940610341 //System.out.println("fragmentMode = " + fragmentMode);
940710342
9408
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10343
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
940910344 {
941010345 /*
941110346 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9438,7 +10373,7 @@
943810373 }
943910374 }
944010375
9441
- if (drawMode == DEFAULT)
10376
+ if (DrawMode() == DEFAULT)
944210377 {
944310378 if (WIREFRAME && !ambientOcclusion)
944410379 {
....@@ -9456,7 +10391,7 @@
945610391 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945710392 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945810393
9459
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10394
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
946010395 {
946110396 if (vertexMode != 0) // && !fast)
946210397 {
....@@ -9476,7 +10411,7 @@
947610411 }
947710412 }
947810413
9479
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10414
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
948010415 {
948110416 //gl.glDepthFunc(GL.GL_LEQUAL);
948210417 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9504,7 +10439,7 @@
950410439 //gl.glDepthMask(false);
950510440 }
950610441
9507
- if (false) // drawMode == SHADOW)
10442
+ if (false) // DrawMode() == SHADOW)
950810443 {
950910444 //SetColumnMajorData(cameraInverseTransform, view_1);
951010445 //System.out.println("light = " + cameraInverseTransform);
....@@ -9518,16 +10453,16 @@
951810453 //System.out.println("object = " + object);
951910454 if (!frozen && !imageLocked)
952010455 {
9521
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10456
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
952210457 {
952310458 displayAntiAliased(gl);
952410459 } else
952510460 {
952610461 programcount = 0;
9527
- int keepmode = drawMode;
10462
+ int keepmode = DrawMode();
952810463 // if (DEBUG_SELECTION)
952910464 // {
9530
-// drawMode = SELECTION;
10465
+// DrawMode() = SELECTION;
953110466 // }
953210467 // for point selection
953310468 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9537,10 +10472,10 @@
953710472 DrawObject(gl);
953810473
953910474 // jan 2013 System.err.println("RESET ABORT (display)");
9540
- // if (drawMode == DEFAULT)
10475
+ // if (DrawMode() == DEFAULT)
954110476 // ABORTED = false;
954210477 fullreset = false;
9543
- drawMode = keepmode;
10478
+ Globals.drawMode = keepmode; // WARNING
954410479 //System.out.println("PROGRAM SWITCH " + programcount);
954510480 }
954610481 }
....@@ -9548,11 +10483,11 @@
954810483 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954910484 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
955010485
9551
- if (drawMode == DEFAULT)
10486
+ if (DrawMode() == DEFAULT)
955210487 {
955310488 ReleaseTexture(NOISE_TEXTURE, false);
955410489 }
9555
- //if (drawMode == DEFAULT)
10490
+ //if (DrawMode() == DEFAULT)
955610491 {
955710492
955810493 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9564,7 +10499,7 @@
956410499 //else
956510500 //gl.glDisable(gl.GL_TEXTURE_2D);
956610501 //gl.glPopMatrix();
9567
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10502
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956810503 {
956910504 //new Exception().printStackTrace();
957010505 //System.out.println("Draw image " + width + ", " + height);
....@@ -9606,7 +10541,7 @@
960610541 //gl.glFlush();
960710542 }
960810543
9609
- if (flash && drawMode == DEFAULT)
10544
+ if (flash && DrawMode() == DEFAULT)
961010545 {
961110546 flash = false;
961210547 wait = true;
....@@ -9614,9 +10549,9 @@
961410549 }
961510550
961610551 //drawing = false;
9617
- //if(drawMode == DEFAULT)
10552
+ //if(DrawMode() == DEFAULT)
961810553 // niceon = false;
9619
- if (drawMode == DEFAULT)
10554
+ if (DrawMode() == DEFAULT)
962010555 {
962110556 currentlydrawing = false;
962210557 }
....@@ -9636,7 +10571,7 @@
963610571 repaint();
963710572 }
963810573
9639
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10574
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
964010575 repaint();
964110576
964210577 displaydone = true;
....@@ -9673,7 +10608,7 @@
967310608 if (GrafreeD.RENDERME > 0)
967410609 GrafreeD.RENDERME--; // mechante magouille
967510610
9676
- ONESTEP = false;
10611
+ Globals.ONESTEP = false;
967710612 }
967810613
967910614 static boolean zoomonce = false;
....@@ -9681,11 +10616,11 @@
968110616 void DrawObject(GL gl, boolean draw)
968210617 {
968310618 //System.out.println("DRAW OBJECT " + mouseDown);
9684
-// drawMode = SELECTION;
10619
+// DrawMode() = SELECTION;
968510620 //GL gl = getGL();
968610621 if ((TRACK || SHADOWTRACK) || zoomonce)
968710622 {
9688
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10623
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968910624 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
969010625 pingthread.StepToTarget(true); // true);
969110626 // zoomonce = false;
....@@ -9706,9 +10641,9 @@
970610641 callist = gl.glGenLists(1);
970710642 }
970810643
9709
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10644
+ boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
971010645
9711
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10646
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
971210647
971310648 if (!mainDL || !active || touched)
971410649 {
....@@ -9735,7 +10670,7 @@
973510670 PushMatrix(ClickInfo.matbuffer);
973610671 }
973710672
9738
- if (drawMode == 0)
10673
+ if (DrawMode() == 0)
973910674 {
974010675 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
974110676
....@@ -9749,7 +10684,7 @@
974910684 // DRAW
975010685 object.draw(this, /*(Composite)*/ object, false, false);
975110686
9752
- if (drawMode == DEFAULT)
10687
+ if (DrawMode() == DEFAULT)
975310688 {
975410689 if (DEBUG)
975510690 {
....@@ -9801,7 +10736,7 @@
980110736 }
980210737 // GrafreeD.traceoff();
980310738 //System.out.println(stackdepth);
9804
- if (drawMode == 0)
10739
+ if (DrawMode() == 0)
980510740 {
980610741 ReleaseTextures(DEFAULT_TEXTURES);
980710742
....@@ -9826,10 +10761,10 @@
982610761
982710762 checker = null;
982810763
9829
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
10764
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
983010765 FindChecker(object);
983110766
9832
- if (checker != null && drawMode == DEFAULT)
10767
+ if (checker != null && DrawMode() == DEFAULT)
983310768 {
983410769 //BindTexture(IMMORTAL_TEXTURE);
983510770 BindTextures(checker.GetTextures(), checker.texres);
....@@ -9851,7 +10786,7 @@
985110786 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
985210787 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
985310788
9854
- if (DISPLAYTEXT && drawMode == DEFAULT)
10789
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
985510790 {
985610791 // Draw it once, then use the raster
985710792 Balloon(gl, balloon.createGraphics());
....@@ -9907,9 +10842,9 @@
990710842 int[] xs = new int[3];
990810843 int[] ys = new int[3];
990910844
9910
- void DrawString(Object3D obj) // String string)
10845
+ public void DrawString(Object3D obj) // String string) // INTERFACE
991110846 {
9912
- if (!DISPLAYTEXT || drawMode != DEFAULT)
10847
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
991310848 {
991410849 return;
991510850 }
....@@ -11936,9 +12871,10 @@
1193612871 return;
1193712872 }
1193812873
12874
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1193912875
1194012876 // TIMER
11941
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
12877
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1194212878 {
1194312879 keepboxmode = BOXMODE;
1194412880 keepsupport = SUPPORT;
....@@ -12067,7 +13003,7 @@
1206713003 // ObjEditor.tweenManager.update(1f / 60f);
1206813004
1206913005 // fev 2014???
12070
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13006
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1207113007 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1207213008 pingthread.StepToTarget(true); // true);
1207313009 }
....@@ -12318,7 +13254,7 @@
1231813254 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1231913255 if (lightMode)
1232013256 {
12321
- lighttouched = true;
13257
+ Globals.lighttouched = true;
1232213258 }
1232313259
1232413260 if (OEILONCE && OEIL)
....@@ -12376,7 +13312,7 @@
1237613312 mouseDown = false;
1237713313 if (lightMode)
1237813314 {
12379
- lighttouched = true;
13315
+ Globals.lighttouched = true;
1238013316 }
1238113317 repaint();
1238213318 alreadypainted = true;
....@@ -12384,7 +13320,7 @@
1238413320 isMoving = false;
1238513321 } //??
1238613322
12387
- if (isLIVE() && !alreadypainted)
13323
+ if (Globals.isLIVE() && !alreadypainted)
1238813324 {
1238913325 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1239013326 repaint();
....@@ -12396,7 +13332,7 @@
1239613332 {
1239713333 if (lightMode)
1239813334 {
12399
- lighttouched = true;
13335
+ Globals.lighttouched = true;
1240013336 }
1240113337 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1240213338 }
....@@ -12639,6 +13575,7 @@
1263913575 {
1264013576 manipCamera.Translate(dx, dy, getWidth());
1264113577 }
13578
+ else
1264213579 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1264313580 {
1264413581 manipCamera.RotateInterest(dx, dy);
....@@ -12649,7 +13586,7 @@
1264913586
1265013587 if (manipCamera == lightCamera)
1265113588 {
12652
- lighttouched = true;
13589
+ Globals.lighttouched = true;
1265313590 }
1265413591 /*
1265513592 switch (mode)
....@@ -12872,7 +13809,7 @@
1287213809 }
1287313810 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1287413811 {
12875
- mouseMode |= SELECT; // BACKFORTH;
13812
+ mouseMode |= SELECT;
1287613813 }
1287713814 if ((modifiers & COMMAND) == COMMAND)
1287813815 {
....@@ -13037,7 +13974,7 @@
1303713974 case 'B':
1303813975 BRISMOOTH ^= true;
1303913976 SHADOWCULLFACE ^= true;
13040
- lighttouched = true;
13977
+ Globals.lighttouched = true;
1304113978 repaint();
1304213979 break;
1304313980 case 'b':
....@@ -13137,7 +14074,7 @@
1313714074 repaint();
1313814075 break;
1313914076 case 'O':
13140
- drawMode = OCCLUSION;
14077
+ Globals.drawMode = OCCLUSION; // WARNING
1314114078 repaint();
1314214079 break;
1314314080 case 'o':
....@@ -13228,7 +14165,7 @@
1322814165 break;
1322914166 case ' ':
1323014167 lightMode ^= true;
13231
- lighttouched = true;
14168
+ Globals.lighttouched = true;
1323214169 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1323314170 targetLookAt.set(manipCamera.lookAt);
1323414171 repaint();
....@@ -13240,11 +14177,11 @@
1324014177 repaint();
1324114178 break;
1324214179 case 'Z':
13243
- RESIZETEXTURE ^= true;
13244
- break;
14180
+ //RESIZETEXTURE ^= true;
14181
+ //break;
1324514182 case 'z':
1324614183 RENDERSHADOW ^= true;
13247
- lighttouched = true;
14184
+ Globals.lighttouched = true;
1324814185 repaint();
1324914186 break;
1325014187 //case UP:
....@@ -13846,6 +14783,7 @@
1384614783 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1384714784 }
1384814785
14786
+ // To avoid clear.
1384914787 public void update(Graphics g)
1385014788 {
1385114789 paint(g);
....@@ -14508,20 +15446,21 @@
1450815446 /**/
1450915447 //checker.GetMaterial().opacity = 1.1f;
1451015448 ////checker.GetMaterial().ambient = 0.99f;
14511
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14512
- Object3D.selectedstack[Object3D.materialdepth] = false;
14513
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15449
+ materialstack[materialdepth] = checker.material;
15450
+ selectedstack[materialdepth] = false;
15451
+ cStatic.objectstack[materialdepth++] = checker;
1451415452 //System.out.println("material " + material);
1451515453 //Applet3D.tracein(this, selected);
1451615454 vector2buffer = checker.projectedVertices;
1451715455
14518
- checker.GetMaterial().Draw(this, false); // true);
15456
+ //checker.GetMaterial().Draw(this, false); // true);
15457
+ DrawMaterial(checker.GetMaterial(), false); // true);
1451915458
14520
- Object3D.materialdepth -= 1;
14521
- if (Object3D.materialdepth > 0)
15459
+ materialdepth -= 1;
15460
+ if (materialdepth > 0)
1452215461 {
14523
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14524
- 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]);
1452515464 }
1452615465 //checker.GetMaterial().opacity = 1f;
1452715466 ////checker.GetMaterial().ambient = 1f;
....@@ -14687,14 +15626,14 @@
1468715626
1468815627 //int tmp = selection_view;
1468915628 //selection_view = -1;
14690
- int temp = drawMode;
14691
- drawMode = SELECTION;
15629
+ int temp = DrawMode();
15630
+ Globals.drawMode = SELECTION; // WARNING
1469215631 indexcount = 0;
1469315632 parent.display(drawable);
1469415633 //selection_view = tmp;
1469515634 //if (temp == SELECTION)
1469615635 // temp = DEFAULT; // patch for selection debug
14697
- drawMode = temp;
15636
+ Globals.drawMode = temp; // WARNING
1469815637
1469915638 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1470015639
....@@ -14967,14 +15906,14 @@
1496715906 //gl.glColorMask(false, false, false, false);
1496815907
1496915908 //render_scene_from_light_view(gl, drawable, 0, 0);
14970
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
15909
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1497115910 {
1497215911 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1497315912
14974
- int temp = drawMode;
14975
- drawMode = SHADOW;
15913
+ int temp = DrawMode();
15914
+ Globals.drawMode = SHADOW; // WARNING
1497615915 parent.display(drawable);
14977
- drawMode = temp;
15916
+ Globals.drawMode = temp; // WARNING
1497815917 }
1497915918
1498015919 gl.glCullFace(gl.GL_BACK);
....@@ -15372,12 +16311,6 @@
1537216311 GLUT glut = new GLUT();
1537316312
1537416313
15375
- static final public int DEFAULT = 0;
15376
- static final public int SELECTION = 1;
15377
- static final public int SHADOW = 2;
15378
- static final public int OCCLUSION = 3;
15379
- static
15380
- public int drawMode = DEFAULT;
1538116314 public boolean spherical = false;
1538216315 static boolean DEBUG_OCCLUSION = false;
1538316316 static boolean DEBUG_SELECTION = false;