Normand Briere
2019-05-01 504890a7b930ab6b853c49de825ae848e0535339
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,17 +83,17 @@
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;
105
-static boolean FAST = false;
89
+static boolean FAST = true; // false;
10690 static boolean SLOWPOSE = false;
10791 static boolean FOOTCONTACT = true;
10892
10993 static int tickcount = 0; // slow pose issue
11094
95
+static boolean BUTTONLESSWHEEL = false;
96
+static boolean ZOOMBOXMODE = false;
11197 static boolean BOXMODE = false;
11298 static boolean IMAGEFLIP = false;
11399 static boolean SMOOTHFOCUS = false;
....@@ -165,12 +151,39 @@
165151 defaultcaps.setAccumBlueBits(16);
166152 defaultcaps.setAccumAlphaBits(16);
167153 }
168
- static CameraPane theRenderer;
169
-
154
+
170155 void SetAsGLRenderer(boolean b)
171156 {
172157 isRenderer = b;
173
- theRenderer = this;
158
+ Globals.theRenderer = this;
159
+ }
160
+
161
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
162
+ {
163
+ super(defaultcaps, null, withcontext?glcontext:null, null);
164
+
165
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
166
+ glcontext = getContext();
167
+
168
+ cameras = new Camera[2];
169
+ targetLookAts = new cVector[2];
170
+
171
+ SetCamera(cam);
172
+
173
+ SetLight(new Camera(new cVector(10, 10, -20)));
174
+
175
+ object = o;
176
+
177
+ setBackground(Color.white);
178
+
179
+ addKeyListener(this);
180
+ addMouseListener(this);
181
+ addMouseMotionListener(this);
182
+ addMouseWheelListener(this);
183
+ //System.out.println("addGLEventListener: " + this);
184
+ addGLEventListener(this);
185
+
186
+// pingthread.start(); // may 2013
174187 }
175188
176189 static boolean AntialiasingEnabled()
....@@ -178,12 +191,53 @@
178191 return CURRENTANTIALIAS > 0;
179192 }
180193
181
- void ClearDepth()
194
+ /// INTERFACE
195
+
196
+ public javax.media.opengl.GL GetGL0()
197
+ {
198
+ return null;
199
+ }
200
+
201
+ public int GenList()
202
+ {
203
+ javax.media.opengl.GL gl = GetGL();
204
+ return gl.glGenLists(1);
205
+ }
206
+
207
+ public void NewList(int id)
208
+ {
209
+ javax.media.opengl.GL gl = GetGL();
210
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
211
+ }
212
+
213
+ public void CallList(int id)
214
+ {
215
+ javax.media.opengl.GL gl = GetGL();
216
+ gl.glCallList(id);
217
+ }
218
+
219
+ public void EndList()
220
+ {
221
+ javax.media.opengl.GL gl = GetGL();
222
+ gl.glEndList();
223
+ }
224
+
225
+ public boolean IsBoxMode()
226
+ {
227
+ return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
233
+ }
234
+
235
+ public void ClearDepth()
182236 {
183237 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184238 }
185239
186
- void DepthTest(boolean depthtest)
240
+ public void DepthTest(boolean depthtest)
187241 {
188242 if (depthtest)
189243 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +245,7 @@
191245 GetGL().glDepthFunc(GL.GL_ALWAYS);
192246 }
193247
194
- void DepthWrite(boolean depthwrite)
248
+ public void DepthWrite(boolean depthwrite)
195249 {
196250 if (depthwrite)
197251 GetGL().glDepthMask(true);
....@@ -199,12 +253,1594 @@
199253 GetGL().glDepthMask(false);
200254 }
201255
202
- void BackFaceCull(boolean bfc)
256
+ public void BackFaceCull(boolean bfc)
203257 {
204258 if (bfc)
205259 GetGL().glEnable(GetGL().GL_CULL_FACE);
206260 else
207261 GetGL().glDisable(GetGL().GL_CULL_FACE);
262
+ }
263
+
264
+ public boolean BackFaceCullMode()
265
+ {
266
+ return this.CULLFACE;
267
+ }
268
+
269
+ public boolean IsAmbientOcclusionOn()
270
+ {
271
+ return this.ambientOcclusion;
272
+ }
273
+
274
+ public boolean IsDebugSelection()
275
+ {
276
+ return DEBUG_SELECTION;
277
+ }
278
+
279
+ public boolean IsFrozen()
280
+ {
281
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
282
+
283
+ return !selectmode && cameracount == 0; // != 0;
284
+ }
285
+
286
+ // Currently in Globals
287
+ public int DrawMode()
288
+ {
289
+ return Globals.DrawMode();
290
+ }
291
+
292
+ public Camera EyeCamera()
293
+ {
294
+ return eyeCamera;
295
+ }
296
+
297
+ public Camera LightCamera()
298
+ {
299
+ return lightCamera;
300
+ }
301
+
302
+ public Camera ManipCamera()
303
+ {
304
+ return manipCamera;
305
+ }
306
+
307
+ public Camera RenderCamera()
308
+ {
309
+ return renderCamera;
310
+ }
311
+
312
+ public Camera[] Cameras()
313
+ {
314
+ return cameras;
315
+ }
316
+
317
+ public void PushMaterial(Object3D obj, boolean selected)
318
+ {
319
+ CameraPane display = this;
320
+ javax.media.opengl.GL gl = display.GetGL();
321
+ cMaterial material = obj.material;
322
+
323
+ if (material != null)
324
+ {
325
+ materialstack[materialdepth] = material;
326
+ selectedstack[materialdepth] = selected;
327
+ cStatic.objectstack[materialdepth++] = obj;
328
+ //System.out.println("material " + material);
329
+ //Applet3D.tracein(this, selected);
330
+ display.vector2buffer = obj.projectedVertices;
331
+ if (obj instanceof Camera)
332
+ {
333
+ display.options1[0] = material.shift;
334
+ //System.out.println("shift " + material.shift);
335
+ display.options1[1] = material.lightarea;
336
+ display.options1[2] = material.shadowbias;
337
+ display.options1[3] = material.aniso;
338
+ display.options1[4] = material.anisoV;
339
+ display.options2[0] = material.opacity;
340
+ display.options2[1] = material.diffuse;
341
+ display.options2[2] = material.factor;
342
+
343
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
344
+ display.options4[0] = material.cameralight/0.2f;
345
+ display.options4[1] = material.subsurface;
346
+ display.options4[2] = material.sheen;
347
+
348
+ // if (display.CURRENTANTIALIAS > 0)
349
+ // display.options3[3] /= 4;
350
+
351
+ /*
352
+ System.out.println("Focus = " + display.options1[0]);
353
+ System.out.println("Aperture = " + display.options1[1]);
354
+ System.out.println("ShadowBlur = " + display.options1[2]);
355
+ System.out.println("Antialiasing = " + display.options1[3]);
356
+ System.out.println("Fog = " + display.options2[0]);
357
+ System.out.println("Intensity = " + display.options2[1]);
358
+ System.out.println("Elevation = " + display.options2[2]);
359
+ /**/
360
+ } else
361
+ {
362
+ DrawMaterial(material, selected);
363
+ }
364
+ } else
365
+ {
366
+ if (selected && CameraPane.flash)
367
+ {
368
+ display.modelParams4[1] = 100;
369
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
370
+ }
371
+ }
372
+ }
373
+
374
+ public void PushMaterial2(Object3D obj, boolean selected)
375
+ {
376
+ CameraPane display = this;
377
+ cMaterial material = obj.material;
378
+
379
+ if (material != null)
380
+ {
381
+ materialstack[materialdepth] = material;
382
+ selectedstack[materialdepth] = selected;
383
+ cStatic.objectstack[materialdepth++] = obj;
384
+ //System.out.println("material " + material);
385
+ //Applet3D.tracein("selected ", selected);
386
+ display.vector2buffer = obj.projectedVertices;
387
+ display.DrawMaterial(material, selected);
388
+ }
389
+ }
390
+
391
+ public void PopMaterial(Object3D obj, boolean selected)
392
+ {
393
+ CameraPane display = this;
394
+ javax.media.opengl.GL gl = display.GetGL();
395
+ cMaterial material = obj.material;
396
+
397
+ //if (parent != null && parent.GetMaterial() != null)
398
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
399
+ if (material != null)
400
+ {
401
+ materialdepth -= 1;
402
+ if (materialdepth > 0)
403
+ {
404
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
406
+ }
407
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
409
+ {
410
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
411
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
412
+ }
413
+ }
414
+
415
+ public void PopMaterial2(Object3D obj)
416
+ {
417
+ CameraPane display = this;
418
+ cMaterial material = obj.material;
419
+
420
+ if (material != null)
421
+ {
422
+ materialdepth -= 1;
423
+ if (materialdepth > 0)
424
+ {
425
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
427
+ }
428
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429
+ //else
430
+ //material.Draw(display, false);
431
+ }
432
+ }
433
+
434
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
435
+ {
436
+ CameraPane display = this;
437
+
438
+ if (pv.y == -10000 ||
439
+ qv.y == -10000 ||
440
+ rv.y == -10000)
441
+ return;
442
+
443
+// float b = f.nbiterations & 1;
444
+// float g = (f.nbiterations>>1) & 1;
445
+// float r = (f.nbiterations>>2) & 1;
446
+//
447
+// //if (f.weight == 10000)
448
+// //{
449
+// // r = 1; g = b = 0;
450
+// //}
451
+// //else
452
+// //{
453
+// // assert(f.weight < 10000);
454
+// r = g = b = (float)bRep.FaceWeight(f)*100;
455
+// if (r<0)
456
+// assert(r>=0);
457
+// //}
458
+
459
+ javax.media.opengl.GL gl = display.GetGL();
460
+
461
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
462
+
463
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
464
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465
+ {
466
+ //gl.glBegin(gl.GL_TRIANGLES);
467
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
468
+ if (!hasnorm)
469
+ {
470
+ // System.out.println("FUCK!!");
471
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
474
+ LA.vecNormalize(obj.v2);
475
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
476
+ }
477
+
478
+ // P
479
+ float x = (float)pv.x;
480
+ float y = (float)pv.y;
481
+ float z = (float)pv.z;
482
+
483
+ if (hasnorm)
484
+ {
485
+// if (!pv.norm.normalized())
486
+// assert(pv.norm.normalized());
487
+
488
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
489
+ float nx = (float)pv.norm.x;
490
+ float ny = (float)pv.norm.y;
491
+ float nz = (float)pv.norm.z;
492
+
493
+ x += nx * obj.NORMALPUSH;
494
+ y += ny * obj.NORMALPUSH;
495
+ z += nz * obj.NORMALPUSH;
496
+
497
+ gl.glNormal3f(nx, ny, nz);
498
+ }
499
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
500
+ SetColor(obj, pv);
501
+ //gl.glColor4f(r, g, b, 1);
502
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
503
+ if (obj.flipV)
504
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
505
+ else
506
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
507
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
508
+
509
+ gl.glVertex3f(x, y, z);
510
+
511
+ // Q
512
+ x = (float)qv.x;
513
+ y = (float)qv.y;
514
+ z = (float)qv.z;
515
+
516
+// Print(pv);
517
+ if (hasnorm)
518
+ {
519
+// assert(qv.norm.normalized());
520
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
521
+ float nx = (float)qv.norm.x;
522
+ float ny = (float)qv.norm.y;
523
+ float nz = (float)qv.norm.z;
524
+
525
+ x += nx * obj.NORMALPUSH;
526
+ y += ny * obj.NORMALPUSH;
527
+ z += nz * obj.NORMALPUSH;
528
+
529
+ gl.glNormal3f(nx, ny, nz);
530
+ }
531
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
532
+ // boolean locked = false;
533
+ // float eps = 0.1f;
534
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
535
+
536
+ // int dot = 0; //*/ (int)f.dot;
537
+
538
+ // if ((dot&1) == 0)
539
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
540
+
541
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
542
+ if (obj.flipV)
543
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
544
+ else
545
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
546
+ // else
547
+ // {
548
+ // locked = true;
549
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
550
+ // }
551
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
552
+ SetColor(obj, qv);
553
+
554
+ gl.glVertex3f(x, y, z);
555
+ //gl.glColor4f(r, g, b, 1);
556
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
557
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
558
+// Print(qv);
559
+
560
+ // R
561
+ x = (float)rv.x;
562
+ y = (float)rv.y;
563
+ z = (float)rv.z;
564
+
565
+ if (hasnorm)
566
+ {
567
+// assert(rv.norm.normalized());
568
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
569
+ float nx = (float)rv.norm.x;
570
+ float ny = (float)rv.norm.y;
571
+ float nz = (float)rv.norm.z;
572
+
573
+ x += nx * obj.NORMALPUSH;
574
+ y += ny * obj.NORMALPUSH;
575
+ z += nz * obj.NORMALPUSH;
576
+
577
+ gl.glNormal3f(nx, ny, nz);
578
+ }
579
+
580
+ // if ((dot&4) == 0)
581
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
582
+
583
+ // if (wrap || !locked && (dot&8) != 0)
584
+ if (obj.flipV)
585
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
586
+ else
587
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
588
+ // else
589
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
590
+
591
+ // f.dot = dot;
592
+
593
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
594
+ SetColor(obj, rv);
595
+ //gl.glColor4f(r, g, b, 1);
596
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
597
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
598
+ gl.glVertex3f(x, y, z);
599
+// Print(rv);
600
+ //gl.glEnd();
601
+ }
602
+ else
603
+ {
604
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
605
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
606
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
607
+
608
+ }
609
+
610
+ if (false) // (attributes & WIREFRAME) != 0)
611
+ {
612
+ gl.glDisable(gl.GL_LIGHTING);
613
+
614
+ gl.glBegin(gl.GL_LINE_LOOP);
615
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
616
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
617
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
618
+ gl.glEnd();
619
+
620
+ gl.glEnable(gl.GL_LIGHTING);
621
+ }
622
+ }
623
+
624
+ /**
625
+ * <code>draw</code> renders a <code>TriMesh</code> object including
626
+ * it's normals, colors, textures and vertices.
627
+ *
628
+ * @see Renderer#draw(TriMesh)
629
+ * @param tris
630
+ * the mesh to render.
631
+ */
632
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
633
+ {
634
+ CameraPane display = this;
635
+
636
+ float r = display.modelParams0[0];
637
+ float g = display.modelParams0[1];
638
+ float b = display.modelParams0[2];
639
+ float opacity = display.modelParams5[1];
640
+
641
+ //final GL gl = GLU.getCurrentGL();
642
+ GL gl = display.GetGL(); // getGL();
643
+
644
+ FloatBuffer vertBuf = geo.vertBuf;
645
+
646
+ int v = vertBuf.capacity();
647
+
648
+ int count = 0;
649
+
650
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
651
+ gl.glEnable(gl.GL_CULL_FACE);
652
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
653
+ for (int i=0; i<v/3; i++)
654
+ {
655
+ int index3 = i*3;
656
+
657
+ if (geo.sizeBuf.get(index3+1) == 0)
658
+ continue;
659
+
660
+ count++;
661
+
662
+ int index4 = i*4;
663
+
664
+ float tx = vertBuf.get(index3);
665
+ float ty = vertBuf.get(index3+1);
666
+ float tz = vertBuf.get(index3+2);
667
+
668
+ // if (tx == 0 && ty == 0 && tz == 0)
669
+ // continue;
670
+
671
+ gl.glMatrixMode(gl.GL_TEXTURE);
672
+ gl.glPushMatrix();
673
+
674
+ float[] texmat = geo.texmat;
675
+ texmat[12] = texmat[13] = texmat[14] = i;
676
+
677
+ gl.glMultMatrixf(texmat, 0);
678
+
679
+ gl.glMatrixMode(gl.GL_MODELVIEW);
680
+ gl.glPushMatrix();
681
+
682
+ gl.glTranslatef(tx,ty,tz);
683
+
684
+ if (rotate)
685
+ gl.glRotatef(i, 0, 1, 0);
686
+
687
+ float size = geo.sizeBuf.get(index3) / 100;
688
+ gl.glScalef(size,size,size);
689
+
690
+ float cr = geo.colorBuf.get(index4);
691
+ float cg = geo.colorBuf.get(index4+1);
692
+ float cb = geo.colorBuf.get(index4+2);
693
+ float ca = geo.colorBuf.get(index4+3);
694
+
695
+ display.modelParams0[0] = r * cr;
696
+ display.modelParams0[1] = g * cg;
697
+ display.modelParams0[2] = b * cb;
698
+
699
+ display.modelParams5[1] = opacity * ca;
700
+
701
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
702
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
703
+
704
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
705
+ RandomNode.globalseed2 = RandomNode.globalseed;
706
+
707
+// gl.glColor4f(cr,cg,cb,ca);
708
+ // gl.glScalef(1024/16,1024/16,1024/16);
709
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
710
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
711
+ //gl.glTranslatef(-tx,-ty,-tz);
712
+ gl.glPopMatrix();
713
+
714
+ gl.glMatrixMode(gl.GL_TEXTURE);
715
+ gl.glPopMatrix();
716
+ }
717
+ // gl.glScalef(1024,1024,1024);
718
+ if (!cf)
719
+ gl.glDisable(gl.GL_CULL_FACE);
720
+
721
+ display.modelParams0[0] = r;
722
+ display.modelParams0[1] = g;
723
+ display.modelParams0[2] = b;
724
+
725
+ display.modelParams5[1] = opacity;
726
+
727
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
728
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
729
+
730
+ gl.glMatrixMode(gl.GL_MODELVIEW);
731
+
732
+// System.err.println("total = " + v/3 + "; displayed = " + count);
733
+ if (true)
734
+ return;
735
+
736
+//// if (!tris.predraw(this))
737
+//// {
738
+//// return;
739
+//// }
740
+//// if (Debug.stats)
741
+//// {
742
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
743
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
744
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
745
+//// }
746
+////
747
+//// if (tris.getDisplayListID() != -1)
748
+//// {
749
+//// renderDisplayList(tris);
750
+//// return;
751
+//// }
752
+////
753
+//// if (!generatingDisplayList)
754
+//// {
755
+//// applyStates(tris.states, tris);
756
+//// }
757
+//// if (Debug.stats)
758
+//// {
759
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
760
+//// }
761
+//// boolean transformed = doTransforms(tris);
762
+//
763
+// int glMode = GL.GL_TRIANGLES;
764
+// switch (getMode())
765
+// {
766
+// case Triangles:
767
+// glMode = GL.GL_TRIANGLES;
768
+// break;
769
+// case Strip:
770
+// glMode = GL.GL_TRIANGLE_STRIP;
771
+// break;
772
+// case Fan:
773
+// glMode = GL.GL_TRIANGLE_FAN;
774
+// break;
775
+// }
776
+//
777
+// if (!predrawGeometry(gl))
778
+// {
779
+// // make sure only the necessary indices are sent through on old
780
+// // cards.
781
+// IntBuffer indices = this.getIndexBuffer();
782
+// if (indices == null)
783
+// {
784
+// logger.severe("missing indices on geometry object: " + this.toString());
785
+// } else
786
+// {
787
+// indices.rewind();
788
+// indices.limit(this.getMaxIndex());
789
+//
790
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
791
+//
792
+// indices.clear();
793
+// }
794
+// } else
795
+// {
796
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
797
+// GL.GL_UNSIGNED_INT, 0);
798
+// }
799
+//
800
+//// postdrawGeometry(tris);
801
+//// if (transformed)
802
+//// {
803
+//// undoTransforms(tris);
804
+//// }
805
+////
806
+//// if (Debug.stats)
807
+//// {
808
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
809
+//// }
810
+//// tris.postdraw(this);
811
+ }
812
+
813
+ static Camera localcamera = new Camera();
814
+ static cVector from = new cVector();
815
+ static cVector to = new cVector();
816
+
817
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
818
+ {
819
+ CameraPane cp = this;
820
+
821
+ Camera keep = cp.RenderCamera();
822
+ cp.renderCamera = localcamera;
823
+
824
+ if (br.trimmed)
825
+ {
826
+ float[] colors = new float[br.positions.length / 3];
827
+
828
+ int i3 = 0;
829
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
830
+ {
831
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
832
+ continue;
833
+
834
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
835
+ to.set(br.positions[i3] + br.normals[i3],
836
+ br.positions[i3 + 1] + br.normals[i3 + 1],
837
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
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
+ colors[i] = cp.vertexOcclusion.r;
848
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
849
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
850
+
851
+ if ((i % 100) == 0 && i != 0)
852
+ {
853
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
854
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
855
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
856
+ }
857
+ }
858
+
859
+ br.colors = colors;
860
+ }
861
+ else
862
+ {
863
+ for (int i = 0; i < br.VertexCount(); i++)
864
+ {
865
+ Vertex v = br.GetVertex(i);
866
+
867
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
868
+ continue;
869
+
870
+ from.set(v.x, v.y, v.z);
871
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
872
+ LA.xformPos(from, transform, from);
873
+ LA.xformPos(to, transform, to); // RIGID ONLY
874
+ localcamera.setAim(from, to);
875
+
876
+ CameraPane.occlusionbuffer.display();
877
+
878
+ if (CameraPane.DEBUG_OCCLUSION)
879
+ cp.display(); // debug
880
+
881
+ v.AO = cp.vertexOcclusion.r;
882
+
883
+ if ((i % 100) == 0 && i != 0)
884
+ {
885
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
886
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
887
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
888
+ }
889
+ }
890
+ }
891
+
892
+ //System.out.println("done.");
893
+
894
+ cp.renderCamera = keep;
895
+ }
896
+
897
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
898
+ {
899
+ CameraPane display = this;
900
+ pointFlow.CreateHT();
901
+
902
+ float r = display.modelParams0[0];
903
+ float g = display.modelParams0[1];
904
+ float b = display.modelParams0[2];
905
+ float opacity = display.modelParams5[1];
906
+
907
+ //final GL gl = GLU.getCurrentGL();
908
+ GL gl = display.GetGL(); // getGL();
909
+
910
+ int s = pointFlow.points.size();
911
+
912
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
913
+ gl.glEnable(gl.GL_CULL_FACE);
914
+
915
+ for (int i=s; --i>=0;)
916
+ //for (int i=0; i<s; i++)
917
+ {
918
+ cVector v = pointFlow.points.get(i);
919
+
920
+ double mindist = Double.MAX_VALUE;
921
+
922
+ double size = pointFlow.minimumSize;
923
+
924
+ double distancenext = 0;
925
+
926
+ if (i > 0)
927
+ {
928
+ cVector w = pointFlow.points.get(i-1);
929
+
930
+ double dist = w.distance(v);
931
+
932
+ distancenext = dist;
933
+
934
+ if (mindist > dist)
935
+ {
936
+ mindist = dist;
937
+ size = mindist*pointFlow.resizefactor;
938
+ }
939
+ }
940
+
941
+ if (i < s-1)
942
+ {
943
+ cVector w = pointFlow.points.get(i+1);
944
+
945
+ double dist = w.distance(v);
946
+
947
+ if (mindist > dist)
948
+ {
949
+ mindist = dist;
950
+ size = mindist*pointFlow.resizefactor;
951
+ }
952
+ }
953
+
954
+ if (size < pointFlow.minimumSize)
955
+ size = pointFlow.minimumSize;
956
+ if (size > pointFlow.maximumSize)
957
+ size = pointFlow.maximumSize;
958
+
959
+ double tx = v.x;
960
+ double ty = v.y;
961
+ double tz = v.z;
962
+
963
+ // if (tx == 0 && ty == 0 && tz == 0)
964
+ // continue;
965
+
966
+ gl.glMatrixMode(gl.GL_TEXTURE);
967
+ gl.glPushMatrix();
968
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
969
+
970
+ gl.glMultMatrixf(pointFlow.texmat, 0);
971
+
972
+ gl.glMatrixMode(gl.GL_MODELVIEW);
973
+ gl.glPushMatrix();
974
+
975
+ gl.glTranslated(tx,ty,tz);
976
+
977
+ gl.glScaled(size,size,size);
978
+
979
+// float cr = colorBuf.get(index4);
980
+// float cg = colorBuf.get(index4+1);
981
+// float cb = colorBuf.get(index4+2);
982
+// float ca = colorBuf.get(index4+3);
983
+//
984
+// display.modelParams0[0] = r * cr;
985
+// display.modelParams0[1] = g * cg;
986
+// display.modelParams0[2] = b * cb;
987
+//
988
+// display.modelParams5[1] = opacity * ca;
989
+//
990
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
991
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
992
+//
993
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
994
+// RandomNode.globalseed2 = RandomNode.globalseed;
995
+//
996
+//// gl.glColor4f(cr,cg,cb,ca);
997
+// // gl.glScalef(1024/16,1024/16,1024/16);
998
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
999
+
1000
+ gl.glPopMatrix();
1001
+
1002
+ double step = size/4; //
1003
+
1004
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1005
+ continue;
1006
+
1007
+ int nbsteps = (int)(distancenext/step);
1008
+
1009
+ step = distancenext/nbsteps;
1010
+
1011
+ cVector next = pointFlow.points.get(i-1);
1012
+
1013
+ tmp.set(next);
1014
+ tmp.sub(v);
1015
+ tmp.normalize();
1016
+ tmp.mul(step);
1017
+
1018
+ // calculate next size
1019
+ mindist = Double.MAX_VALUE;
1020
+
1021
+ double nextsize = pointFlow.minimumSize;
1022
+
1023
+ if (i > 1)
1024
+ {
1025
+ cVector w = pointFlow.points.get(i-2);
1026
+
1027
+ double dist = w.distance(next);
1028
+
1029
+ if (mindist > dist)
1030
+ {
1031
+ mindist = dist;
1032
+ nextsize = mindist*pointFlow.resizefactor;
1033
+ }
1034
+ }
1035
+
1036
+ double dist = v.distance(next);
1037
+
1038
+ if (mindist > dist)
1039
+ {
1040
+ mindist = dist;
1041
+ nextsize = mindist*pointFlow.resizefactor;
1042
+ }
1043
+
1044
+ if (nextsize < pointFlow.minimumSize)
1045
+ nextsize = pointFlow.minimumSize;
1046
+ if (nextsize > pointFlow.maximumSize)
1047
+ nextsize = pointFlow.maximumSize;
1048
+ //
1049
+
1050
+ double count = 0;
1051
+
1052
+ while (distancenext > 0.000000001) // step
1053
+ {
1054
+ gl.glPushMatrix();
1055
+
1056
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1057
+
1058
+ double K = count/nbsteps;
1059
+
1060
+ double intersize = K*nextsize + (1-K)*size;
1061
+
1062
+ gl.glScaled(intersize,intersize,intersize);
1063
+
1064
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1065
+
1066
+ count++;
1067
+
1068
+ distancenext -= step;
1069
+
1070
+ gl.glPopMatrix();
1071
+ }
1072
+
1073
+ if (count != nbsteps)
1074
+ assert(count == nbsteps);
1075
+
1076
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1077
+ //gl.glTranslatef(-tx,-ty,-tz);
1078
+
1079
+ gl.glMatrixMode(gl.GL_TEXTURE);
1080
+ gl.glPopMatrix();
1081
+ }
1082
+
1083
+ if (!cf)
1084
+ gl.glDisable(gl.GL_CULL_FACE);
1085
+
1086
+// display.modelParams0[0] = r;
1087
+// display.modelParams0[1] = g;
1088
+// display.modelParams0[2] = b;
1089
+//
1090
+// display.modelParams5[1] = opacity;
1091
+//
1092
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1093
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1094
+
1095
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1096
+ }
1097
+
1098
+ public void DrawBox(cVector min, cVector max)
1099
+ {
1100
+ javax.media.opengl.GL gl = GetGL();
1101
+ gl.glBegin(gl.GL_LINES);
1102
+
1103
+ gl.glVertex3d(min.x, min.y, min.z);
1104
+ gl.glVertex3d(min.x, min.y, max.z);
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(min.x, max.y, min.z);
1107
+ gl.glVertex3d(min.x, min.y, min.z);
1108
+ gl.glVertex3d(max.x, min.y, min.z);
1109
+
1110
+ gl.glVertex3d(max.x, max.y, max.z);
1111
+ gl.glVertex3d(min.x, max.y, max.z);
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(max.x, min.y, max.z);
1114
+ gl.glVertex3d(max.x, max.y, max.z);
1115
+ gl.glVertex3d(max.x, max.y, min.z);
1116
+
1117
+ gl.glEnd();
1118
+ }
1119
+
1120
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1121
+ {
1122
+ int[] strips = bRep.getRawIndices();
1123
+
1124
+ javax.media.opengl.GL gl = GetGL();
1125
+
1126
+ // TRIANGLE STRIP ARRAY
1127
+ if (bRep.trimmed)
1128
+ {
1129
+ float[] v = bRep.getRawVertices();
1130
+ float[] n = bRep.getRawNormals();
1131
+ float[] c = bRep.getRawColors();
1132
+ float[] uv = bRep.getRawUVMap();
1133
+
1134
+ int count2 = 0;
1135
+ int count3 = 0;
1136
+
1137
+ if (n.length > 0)
1138
+ {
1139
+ for (int i = 0; i < strips.length; i++)
1140
+ {
1141
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1142
+
1143
+ /*
1144
+ boolean locked = false;
1145
+ float eps = 0.1f;
1146
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1147
+
1148
+ int dot = 0;
1149
+
1150
+ if ((dot&1) == 0)
1151
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1152
+
1153
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1154
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1155
+ else
1156
+ {
1157
+ locked = true;
1158
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1159
+ }
1160
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1161
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1162
+ if (hasnorm)
1163
+ {
1164
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1165
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1166
+ }
1167
+
1168
+ if ((dot&4) == 0)
1169
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1170
+
1171
+ if (wrap || !locked && (dot&8) != 0)
1172
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1173
+ else
1174
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1175
+
1176
+ f.dot = dot;
1177
+ */
1178
+
1179
+ if (!selectmode)
1180
+ {
1181
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1182
+ {
1183
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1184
+ } else
1185
+ {
1186
+ gl.glNormal3f(0, 0, 1);
1187
+ }
1188
+
1189
+ if (c != null)
1190
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1191
+ {
1192
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1193
+ }
1194
+ }
1195
+ if (flipV)
1196
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1197
+ else
1198
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1199
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1200
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1201
+
1202
+ count2 += 2;
1203
+ count3 += 3;
1204
+ if (!selectmode)
1205
+ {
1206
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1207
+ {
1208
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1209
+ } else
1210
+ {
1211
+ gl.glNormal3f(0, 0, 1);
1212
+ }
1213
+ if (c != null)
1214
+ {
1215
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1216
+ }
1217
+ }
1218
+ if (flipV)
1219
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1220
+ else
1221
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1222
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1223
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1224
+
1225
+ count2 += 2;
1226
+ count3 += 3;
1227
+ for (int j = 0; j < strips[i] - 2; j++)
1228
+ {
1229
+ //gl.glTexCoord2d(...);
1230
+ if (!selectmode)
1231
+ {
1232
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1233
+ {
1234
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1235
+ } else
1236
+ {
1237
+ gl.glNormal3f(0, 0, 1);
1238
+ }
1239
+ if (c != null)
1240
+ {
1241
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1242
+ }
1243
+ }
1244
+
1245
+ if (flipV)
1246
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1247
+ else
1248
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1249
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1250
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1251
+ count2 += 2;
1252
+ count3 += 3;
1253
+ }
1254
+
1255
+ gl.glEnd();
1256
+ }
1257
+ }
1258
+
1259
+ assert count3 == v.length;
1260
+ }
1261
+ else // !trimmed
1262
+ {
1263
+ int count = 0;
1264
+ for (int i = 0; i < strips.length; i++)
1265
+ {
1266
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1267
+
1268
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1269
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1270
+
1271
+ drawVertex(gl, p, flipV, selectmode);
1272
+ drawVertex(gl, q, flipV, selectmode);
1273
+
1274
+ for (int j = 0; j < strips[i] - 2; j++)
1275
+ {
1276
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1277
+
1278
+ // if (j%2 == 0)
1279
+ // drawFace(p, q, r, display, null);
1280
+ // else
1281
+ // drawFace(p, r, q, display, null);
1282
+
1283
+ // p = q;
1284
+ // q = r;
1285
+ drawVertex(gl, r, flipV, selectmode);
1286
+ }
1287
+
1288
+ gl.glEnd();
1289
+ }
1290
+ }
1291
+ }
1292
+
1293
+ static cSpring.Point3D temp = new cSpring.Point3D();
1294
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1295
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1296
+
1297
+ public void DrawDynamicMesh(cMesh mesh)
1298
+ {
1299
+ GL gl = GetGL(); // getGL();
1300
+
1301
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1302
+
1303
+ gl.glDisable(gl.GL_LIGHTING);
1304
+
1305
+ gl.glLineWidth(1);
1306
+ gl.glColor3f(1,1,1);
1307
+ gl.glBegin(gl.GL_LINES);
1308
+ double scale = 0;
1309
+ int count = 0;
1310
+ for (int s=0; s<Phys.allSprings.size(); s++)
1311
+ {
1312
+ cSpring.Spring spring = Phys.allSprings.get(s);
1313
+ if(s == 0)
1314
+ {
1315
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1316
+ }
1317
+ if (mesh.showsprings)
1318
+ {
1319
+ temp.set(spring.a.position);
1320
+ temp.add(spring.b.position);
1321
+ temp.mul(0.5);
1322
+ temp2.set(spring.a.position);
1323
+ temp2.sub(spring.b.position);
1324
+ temp2.mul(spring.restLength/2);
1325
+ temp.sub(temp2);
1326
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1327
+ temp.add(temp2);
1328
+ temp.add(temp2);
1329
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1330
+ }
1331
+
1332
+ if (spring.isHandle)
1333
+ continue;
1334
+
1335
+ //if (scale < spring.restLength)
1336
+ scale += spring.restLength;
1337
+ count++;
1338
+ }
1339
+ gl.glEnd();
1340
+
1341
+ if (count == 0)
1342
+ scale = 0.01;
1343
+ else
1344
+ scale /= count * 3;
1345
+
1346
+ //scale = 0.25;
1347
+
1348
+ if (mesh.ShowInfo())
1349
+ {
1350
+ gl.glLineWidth(4);
1351
+ for (int s=0; s<Phys.allNodes.size(); s++)
1352
+ {
1353
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1354
+ if (node.mass == 0)
1355
+ continue;
1356
+
1357
+ int i = node.springs==null?-1:node.springs.size();
1358
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1359
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1360
+ //temp.normalize();
1361
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1362
+ gl.glBegin(gl.GL_LINES);
1363
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1364
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1365
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1366
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1367
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1368
+ gl.glEnd();
1369
+ }
1370
+
1371
+ gl.glLineWidth(8);
1372
+ for (int s=0; s<Phys.allNodes.size(); s++)
1373
+ {
1374
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1375
+
1376
+ if (node.springs != null)
1377
+ {
1378
+ for (int i=0; i<node.springs.size(); i+=1)
1379
+ {
1380
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1381
+
1382
+ int c = i+1;
1383
+ // c = node.springs.get(i).nbcopies;
1384
+
1385
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1386
+ gl.glBegin(gl.GL_LINES);
1387
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1388
+ gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3);
1389
+ gl.glEnd();
1390
+ }
1391
+ }
1392
+ }
1393
+
1394
+ gl.glLineWidth(1);
1395
+ }
1396
+
1397
+ gl.glEnable(gl.GL_LIGHTING);
1398
+ }
1399
+
1400
+ /// INTERFACE
1401
+
1402
+ public void StartTriangles()
1403
+ {
1404
+ javax.media.opengl.GL gl = GetGL();
1405
+ gl.glBegin(gl.GL_TRIANGLES);
1406
+ }
1407
+
1408
+ public void EndTriangles()
1409
+ {
1410
+ GetGL().glEnd();
1411
+ }
1412
+
1413
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1414
+ {
1415
+ if (!selectmode)
1416
+ {
1417
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1418
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1419
+
1420
+ if (flipV)
1421
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1422
+ else
1423
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1424
+ }
1425
+
1426
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1427
+ }
1428
+
1429
+ void SetColor(Object3D obj, Vertex p0)
1430
+ {
1431
+ CameraPane display = this;
1432
+ BoundaryRep bRep = obj.bRep;
1433
+
1434
+ if (RENDERPROGRAM == 0)
1435
+ {
1436
+ float r = 0;
1437
+ if (bRep != null)
1438
+ {
1439
+ if (bRep.stripified)
1440
+ {
1441
+ r = 1;
1442
+ }
1443
+ }
1444
+ float g = 0;
1445
+ if (bRep != null)
1446
+ {
1447
+ if (bRep.trimmed)
1448
+ {
1449
+ g = 1;
1450
+ }
1451
+ }
1452
+ float b = 0;
1453
+ if (obj.support != null && obj.link2master)
1454
+ {
1455
+ b = 1;
1456
+ }
1457
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1458
+ return;
1459
+ }
1460
+
1461
+ if (display.DrawMode() != CameraPane.SHADOW)
1462
+ return;
1463
+
1464
+ javax.media.opengl.GL gl = display.GetGL();
1465
+// if (true) return;
1466
+// float ao = p.AO;
1467
+//
1468
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1469
+// // ao = 1;
1470
+//
1471
+// gl.glColor4f(ao, ao, ao, 1);
1472
+
1473
+// CameraPane.selectedpoint.
1474
+// getAverage(cStatic.point1, true);
1475
+ if (CameraPane.pointflow == null) // !random) // live)
1476
+ {
1477
+ return;
1478
+ }
1479
+
1480
+ cStatic.point1.set(0,0,0);
1481
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1482
+
1483
+ cStatic.point1.sub(p0);
1484
+
1485
+
1486
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1487
+// {
1488
+// return;
1489
+// }
1490
+
1491
+ //if (true)
1492
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1493
+ {
1494
+ return;
1495
+ }
1496
+
1497
+ float[] colorV = new float[3];
1498
+
1499
+ if (false) // marked)
1500
+ {
1501
+ // debug rigging weights
1502
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1503
+ {
1504
+ float weight = p0.weights[object] / p0.totalweight;
1505
+
1506
+ // if (weight < 0.1)
1507
+ // {
1508
+ // assert(weight == 0);
1509
+ // continue;
1510
+ // }
1511
+
1512
+ if (p0.vertexlinks[object] == -1)
1513
+ continue;
1514
+
1515
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1516
+
1517
+ int color = //1 << object; //
1518
+ //p.vertexlinks.length;
1519
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1520
+ colorV[2] += (color & 1) * weight;
1521
+ colorV[1] += ((color & 2) >> 1) * weight;
1522
+ colorV[0] += ((color & 4) >> 2) * weight;
1523
+ }
1524
+ }
1525
+ else
1526
+ {
1527
+ if (obj.drawingstarted)
1528
+ {
1529
+ // find next point
1530
+ if (bRep.GetVertex(0).faceindices == null)
1531
+ {
1532
+ bRep.InitFaceIndices();
1533
+ }
1534
+
1535
+ double ymin = p0.y;
1536
+
1537
+ Vertex newp = p0;
1538
+
1539
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1540
+ {
1541
+ int fi = p0.faceindices[fii];
1542
+
1543
+ if (fi == -1)
1544
+ break;
1545
+
1546
+ Face f = bRep.GetFace(fi);
1547
+
1548
+ Vertex p = bRep.GetVertex(f.p);
1549
+ Vertex q = bRep.GetVertex(f.q);
1550
+ Vertex r = bRep.GetVertex(f.r);
1551
+
1552
+ int swap = (int)(Math.random()*3);
1553
+
1554
+// for (int s=swap; --s>=0;)
1555
+// {
1556
+// Vertex t = p;
1557
+// p = q;
1558
+// q = r;
1559
+// r = t;
1560
+// }
1561
+ if (ymin > p.y)
1562
+ {
1563
+ ymin = p.y;
1564
+ newp = p;
1565
+// break;
1566
+ }
1567
+ if (ymin > q.y)
1568
+ {
1569
+ ymin = q.y;
1570
+ newp = q;
1571
+// break;
1572
+ }
1573
+ if (ymin > r.y)
1574
+ {
1575
+ ymin = r.y;
1576
+ newp = r;
1577
+// break;
1578
+ }
1579
+ }
1580
+
1581
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1582
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1583
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1584
+
1585
+ obj.drawingstarted = false;
1586
+
1587
+ // return;
1588
+ }
1589
+
1590
+ if (false) // CameraPane.DRAW
1591
+ {
1592
+ p0.AO = colorV[0] = 2;
1593
+ colorV[1] = 2;
1594
+ colorV[2] = 2;
1595
+ }
1596
+
1597
+ CameraPane.pointflow.add(p0);
1598
+ CameraPane.pointflow.Touch();
1599
+ }
1600
+
1601
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1602
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1603
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1604
+ }
1605
+
1606
+ void DrawMaterial(cMaterial material, boolean selected)
1607
+ {
1608
+ CameraPane display = this;
1609
+ //new Exception().printStackTrace();
1610
+
1611
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1612
+ {
1613
+ return;
1614
+ }
1615
+
1616
+ javax.media.opengl.GL gl = display.GetGL();
1617
+
1618
+ //Color col = Color.getHSBColor(color,modulation,1);
1619
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1620
+ if (!material.multiply)
1621
+ {
1622
+ display.color = material.color;
1623
+ display.saturation = material.modulation;
1624
+ }
1625
+ else
1626
+ {
1627
+ display.color *= material.color*2;
1628
+ display.saturation *= material.modulation*2;
1629
+ }
1630
+
1631
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1632
+
1633
+ float[] colorV = GrafreeD.colorV;
1634
+
1635
+ /**/
1636
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1637
+ {
1638
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1639
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1640
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1641
+ colorV[3] = material.opacity;
1642
+
1643
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1644
+ //System.out.println("Opacity = " + opacity);
1645
+
1646
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1647
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1648
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1649
+
1650
+ float amb = material.ambient;
1651
+ if (amb < material.cameralight)
1652
+ {
1653
+ amb = material.cameralight;
1654
+ }
1655
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1656
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1657
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1658
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1659
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1660
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1661
+
1662
+ /**/
1663
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1664
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1665
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1666
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1667
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1668
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1669
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1670
+ //System.out.println("shininess = " + colorV[0]);
1671
+ if (colorV[0] > 128)
1672
+ {
1673
+ colorV[0] = 128;
1674
+ }
1675
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1676
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1677
+ /**/
1678
+ }
1679
+ /**/
1680
+
1681
+ //selected = false;
1682
+ selected = selected && display.flash;
1683
+
1684
+ //display.modelParams0[0] = 0; // pigment.r;
1685
+ //display.modelParams0[1] = 0; // pigment.g;
1686
+ //display.modelParams0[2] = 0; // pigment.b;
1687
+ if (!material.multiply)
1688
+ {
1689
+ display.modelParams0[3] = material.metalness;
1690
+ display.modelParams1[0] = material.diffuse;
1691
+ display.modelParams1[1] = material.specular;
1692
+ display.modelParams1[2] = 1 / material.shininess;
1693
+ display.modelParams1[3] = material.shift;
1694
+ display.modelParams2[0] = material.ambient;
1695
+ display.modelParams2[1] = material.lightarea;
1696
+ //System.out.println("light area = " + lightarea);
1697
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1698
+ display.modelParams2[3] = material.velvet;
1699
+ display.modelParams3[0] = material.sheen;
1700
+ display.modelParams3[1] = material.subsurface;
1701
+ display.modelParams3[2] = material.bump; // backlit
1702
+ display.modelParams3[3] = material.aniso;
1703
+ display.modelParams4[0] = material.anisoV;
1704
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1705
+ //System.out.println("selected = " + selected);
1706
+ display.modelParams4[2] = material.diffuseness;
1707
+ display.modelParams4[3] = material.shadow;
1708
+ display.modelParams5[0] = material.texture;
1709
+ display.modelParams5[1] = material.opacity;
1710
+ display.modelParams5[2] = material.fakedepth;
1711
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1712
+ }
1713
+ else
1714
+ {
1715
+ display.modelParams0[3] *= material.metalness*2;
1716
+ display.modelParams1[0] *= material.diffuse*2;
1717
+ display.modelParams1[1] *= material.specular*2;
1718
+ display.modelParams1[2] *= material.shininess*2;
1719
+ display.modelParams1[3] *= material.shift*2;
1720
+ display.modelParams2[0] *= material.ambient*2;
1721
+ display.modelParams2[1] *= material.lightarea*2;
1722
+ display.modelParams2[2] *= material.factor*2;
1723
+ display.modelParams2[3] *= material.velvet*2;
1724
+ display.modelParams3[0] *= material.sheen*2;
1725
+ display.modelParams3[1] *= material.subsurface*2;
1726
+ display.modelParams3[2] *= material.bump*2;
1727
+ display.modelParams3[3] *= material.aniso*2;
1728
+ display.modelParams4[0] *= material.anisoV*2;
1729
+ display.modelParams4[1] *= material.cameralight*2;
1730
+ //System.out.println("selected = " + selected);
1731
+ display.modelParams4[2] *= material.diffuseness*2;
1732
+ display.modelParams4[3] *= material.shadow*2;
1733
+ display.modelParams5[0] *= material.texture*2;
1734
+ display.modelParams5[1] *= material.opacity*2;
1735
+ display.modelParams5[2] *= material.fakedepth*2;
1736
+ display.modelParams5[3] *= material.shadowbias*2;
1737
+ }
1738
+
1739
+ display.modelParams6[0] = 0;
1740
+ display.modelParams6[1] = 0;
1741
+ display.modelParams6[2] = 0;
1742
+ display.modelParams6[3] = 0;
1743
+
1744
+ display.modelParams7[0] = 0;
1745
+ display.modelParams7[1] = 1000;
1746
+ display.modelParams7[2] = 0;
1747
+ display.modelParams7[3] = 0;
1748
+
1749
+ display.modelParams6[0] = 100; // criss de bug de bump
1750
+
1751
+ Object3D.cVector2[] extparams = display.vector2buffer;
1752
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1753
+ {
1754
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1755
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1756
+ if (extparams.length > 1)
1757
+ {
1758
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1759
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1760
+ if (extparams.length > 2)
1761
+ {
1762
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1763
+ float x = extparams[2].y / 1000.0f;
1764
+ //if (x == 0)
1765
+ // x = 1f;
1766
+ 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
1767
+ if (extparams[2].y > 0)
1768
+ {
1769
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1770
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1771
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1772
+ }
1773
+ }
1774
+ }
1775
+ }
1776
+
1777
+ //if (display.modelParams6[2] != 0)
1778
+ /*
1779
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1780
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1781
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1782
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1783
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1784
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1785
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1786
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1787
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1788
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1789
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1790
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1791
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1792
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1793
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1794
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1795
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1796
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1797
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1798
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1799
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1800
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1801
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1802
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1803
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1804
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1805
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1806
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1807
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1808
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1809
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1810
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1811
+ /**/
1812
+ //assert (display.modelParams6[2] == 0);
1813
+
1814
+ //System.out.println("noise power = " + display.modelParams7[0]);
1815
+ //System.out.println("shadowbias = " + shadowbias);
1816
+
1817
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1818
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1819
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1820
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1821
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1822
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1823
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1824
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1825
+
1826
+ int mode = display.FP_SHADER;
1827
+
1828
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1829
+ {
1830
+ mode |= display.FP_ANISO;
1831
+ }
1832
+
1833
+ display.EnableProgram(mode);
1834
+
1835
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1836
+
1837
+ if (!material.multiply)
1838
+ {
1839
+ if (Globals.drawMode == CameraPane.SHADOW)
1840
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1841
+ else
1842
+ gl.glDepthMask(material.opacity >= 0.99);
1843
+ }
2081844 }
2091845
2101846 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1861,7 @@
2251861 currentGL.glMultMatrixd(model, 0);
2261862 }
2271863
228
- void PushMatrix(double[][] matrix, int count)
1864
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291865 {
2301866 matrixdepth++;
2311867 // GrafreeD.tracein(matrix);
....@@ -270,7 +1906,7 @@
2701906
2711907 double[][] tmpmat = new double[4][4];
2721908
273
- void PopMatrix(double[][] inverse)
1909
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741910 {
2751911 --matrixdepth;
2761912
....@@ -310,7 +1946,7 @@
3101946 PushTextureMatrix(matrix, 1);
3111947 }
3121948
313
- void PushTextureMatrix(double[][] matrix, int count)
1949
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141950 {
3151951 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161952
....@@ -324,7 +1960,7 @@
3241960 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251961 }
3261962
327
- void PopTextureMatrix(double[][] inverse)
1963
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281964 {
3291965 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301966 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -351,15 +1987,15 @@
3511987
3521988 static int camerachangeframe;
3531989
354
- boolean SetCamera(Camera cam)
1990
+ public boolean SetCamera(Camera cam)
3551991 {
3561992 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571993 // return false;
3581994
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1995
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601996 {
3611997 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1998
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631999 {
3642000 // refuse the camera change
3652001 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +2003,7 @@
3672003 }
3682004 }
3692005
370
- camerachangeframe = framecount;
2006
+ camerachangeframe = Globals.framecount;
3712007
3722008 cam.hAspect = -1; // Read only
3732009
....@@ -398,7 +2034,7 @@
3982034 {
3992035 //System.err.println("Oeil on");
4002036 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2037
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022038 // object.editWindow.ScreenFit(trackedobject);
4032039 //pingthread.StepToTarget(true);
4042040 }
....@@ -407,7 +2043,7 @@
4072043 {
4082044 //System.err.println("Oeil on");
4092045 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2046
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4112047 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4122048 //pingthread.StepToTarget(true);
4132049 }
....@@ -471,39 +2107,12 @@
4712107 {
4722108 frozen ^= true;
4732109 // Weird...
474
- lighttouched = true;
2110
+ Globals.lighttouched = true;
4752111 }
4762112
4772113 void ToggleDL()
4782114 {
4792115 mainDL ^= true;
480
- }
481
-
482
- void ToggleTexture()
483
- {
484
- textureon ^= true;
485
- }
486
-
487
- void ToggleLive()
488
- {
489
- setLIVE(isLIVE() ^ true);
490
-
491
- System.err.println("LIVE = " + isLIVE());
492
-
493
- if (!isLIVE()) // save sound
494
- GrafreeD.savesound = true; // wav.save();
495
- // else
496
- repaint(); // start loop // may 2013
497
- }
498
-
499
- void ToggleSupport()
500
- {
501
- SUPPORT ^= true;
502
- }
503
-
504
- void ToggleAbort()
505
- {
506
- ABORTMODE ^= true;
5072116 }
5082117
5092118 void ToggleFullScreen()
....@@ -513,12 +2122,7 @@
5132122
5142123 void ToggleCrowd()
5152124 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2125
+ Globals.CROWD ^= true;
5222126 }
5232127
5242128 void ToggleLocal()
....@@ -526,62 +2130,89 @@
5262130 LOCALTRANSFORM ^= true;
5272131 }
5282132
529
- void ToggleFast()
2133
+ public void ToggleTexture()
2134
+ {
2135
+ textureon ^= true;
2136
+ }
2137
+
2138
+ public void ToggleLive()
2139
+ {
2140
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2141
+
2142
+ System.err.println("LIVE = " + Globals.isLIVE());
2143
+
2144
+ if (!Globals.isLIVE()) // save sound
2145
+ GrafreeD.savesound = true; // wav.save();
2146
+ // else
2147
+ repaint(); // start loop // may 2013
2148
+ }
2149
+
2150
+ public void ToggleSupport()
2151
+ {
2152
+ SUPPORT ^= true;
2153
+ }
2154
+
2155
+ public void ToggleAbort()
2156
+ {
2157
+ ABORTMODE ^= true;
2158
+ }
2159
+
2160
+ public void ToggleInertia()
2161
+ {
2162
+ INERTIA ^= true;
2163
+ }
2164
+
2165
+ public void ToggleFast()
5302166 {
5312167 FAST ^= true;
5322168 }
5332169
534
- void ToggleSlowPose()
2170
+ public void ToggleSlowPose()
5352171 {
5362172 SLOWPOSE ^= true;
5372173 }
5382174
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2175
+ public void ToggleBoxMode()
5452176 {
5462177 BOXMODE ^= true;
5472178 }
5482179
549
- void ToggleSmoothFocus()
2180
+ public void ToggleZoomBoxMode()
2181
+ {
2182
+ ZOOMBOXMODE ^= true;
2183
+ }
2184
+
2185
+ public void ToggleSmoothFocus()
5502186 {
5512187 SMOOTHFOCUS ^= true;
5522188 }
5532189
554
- void ToggleImageFlip()
2190
+ public void ToggleImageFlip()
5552191 {
5562192 IMAGEFLIP ^= true;
5572193 }
5582194
559
- void ToggleSpeakerMocap()
2195
+ public void ToggleSpeakerMocap()
5602196 {
5612197 SPEAKERMOCAP ^= true;
5622198 }
5632199
564
- void ToggleSpeakerCamera()
2200
+ public void ToggleSpeakerCamera()
5652201 {
5662202 SPEAKERCAMERA ^= true;
5672203 }
5682204
569
- void ToggleSpeakerFocus()
2205
+ public void ToggleSpeakerFocus()
5702206 {
5712207 SPEAKERFOCUS ^= true;
5722208 }
5732209
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2210
+ public void ToggleFrustum()
5802211 {
5812212 FRUSTUM ^= true;
5822213 }
5832214
584
- void ToggleTrack()
2215
+ public void ToggleTrack()
5852216 {
5862217 TRACK ^= true;
5872218 if (TRACK)
....@@ -600,25 +2231,35 @@
6002231 repaint();
6012232 }
6022233
603
- void ToggleTrackOnce()
2234
+ public void ToggleTrackOnce()
6042235 {
6052236 TRACKONCE ^= true;
6062237 }
6072238
608
- void ToggleShadowTrack()
2239
+ public void ToggleShadowTrack()
6092240 {
6102241 SHADOWTRACK ^= true;
6112242 repaint();
6122243 }
6132244
614
- void ToggleOeil()
2245
+ public void ToggleOeil()
6152246 {
6162247 OEIL ^= true;
6172248 }
6182249
619
- void ToggleOeilOnce()
2250
+ public void ToggleOeilOnce()
6202251 {
6212252 OEILONCE ^= true;
2253
+ }
2254
+
2255
+ void ToggleFootContact()
2256
+ {
2257
+ FOOTCONTACT ^= true;
2258
+ }
2259
+
2260
+ void ToggleDebug()
2261
+ {
2262
+ DEBUG ^= true;
6222263 }
6232264
6242265 void ToggleLookAt()
....@@ -672,34 +2313,6 @@
6722313 //assert (cam.hAspect == 0);
6732314 cam.hAspect = 0;
6742315 lightCamera = cam;
675
- }
676
-
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
7032316 }
7042317
7052318 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -759,7 +2372,7 @@
7592372
7602373 GL currentGL;
7612374
762
- GL GetGL()
2375
+ public GL GetGL() // INTERFACE
7632376 {
7642377 return currentGL;
7652378 }
....@@ -2595,6 +4208,7 @@
25954208
25964209 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25974210 {
4211
+ new Exception().printStackTrace();
25984212 System.exit(0);
25994213 com.sun.opengl.util.texture.Texture texture = null;
26004214
....@@ -6271,7 +7885,7 @@
62717885 return null;
62727886 }
62737887
6274
- void ReleaseTextures(cTexture tex)
7888
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757889 {
62767890 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777891 {
....@@ -6309,7 +7923,7 @@
63097923
63107924 void ReleaseTexture(String tex, boolean bump)
63117925 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
7926
+ if (// DrawMode() != 0 || /*tex == null ||*/
63137927 ambientOcclusion ) // || !textureon)
63147928 {
63157929 return;
....@@ -6410,9 +8024,9 @@
64108024 }
64118025 }
64128026
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64148028 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
8029
+ if (// DrawMode() != 0 || /*tex == null ||*/
64168030 ambientOcclusion ) // || !textureon)
64178031 {
64188032 return; // false;
....@@ -6708,7 +8322,7 @@
67088322 return texture!=null?texture.texture:null;
67098323 }
67108324
6711
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8325
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
67128326 {
67138327 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67148328
....@@ -7312,9 +8926,9 @@
73128926 static boolean occlusionInitialized = false;
73138927 boolean selection = false;
73148928 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
8929
+ ///*static*/ boolean lighttouched = true;
73168930 boolean deselect;
7317
- boolean ambientOcclusion = false;
8931
+ private boolean ambientOcclusion = false;
73188932 static boolean flash = false;
73198933 /*static*/ boolean wait = false;
73208934 boolean displaydone = false; // after repaint() calls
....@@ -7444,6 +9058,8 @@
74449058 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74459059 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74469060 double scale = lightCamera.SCALE / lightCamera.Distance();
9061
+// PATCH FILLE AUX JEANS
9062
+ //scale *= lightCamera.shaper_fovy / 25;
74479063 gl.glScaled(2 * scale, 2 * scale, -scale);
74489064 gl.glTranslated(0, 0, lightCamera.DECAL);
74499065
....@@ -7601,8 +9217,6 @@
76019217
76029218 boolean restartframe = false;
76039219
7604
- static int framecount = 0; // general-purpose global count
7605
-
76069220 void displayAntiAliased(javax.media.opengl.GL gl)
76079221 {
76089222 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7633,7 +9247,7 @@
76339247 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76349248 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76359249 {
7636
- framecount++;
9250
+ Globals.framecount++;
76379251
76389252 if (CameraPane.tickcount > 0)
76399253 CameraPane.tickcount--;
....@@ -7671,7 +9285,7 @@
76719285
76729286 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76739287 */
7674
- lighttouched = true;
9288
+ Globals.lighttouched = true;
76759289 //System.err.println(" shadowbuffer: " + jitter);
76769290 shadowbuffer.display();
76779291
....@@ -7693,7 +9307,7 @@
76939307
76949308 if (renderCamera != lightCamera)
76959309 for (int count = parentcam.GetTransformCount(); --count>=0;)
7696
- LA.matConcat(parentcam.toParent, matrix, matrix);
9310
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76979311
76989312 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76999313
....@@ -7709,7 +9323,7 @@
77099323
77109324 if (renderCamera != lightCamera)
77119325 for (int count = parentcam.GetTransformCount(); --count>=0;)
7712
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9326
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77139327
77149328 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77159329
....@@ -8618,13 +10232,6 @@
861810232 }
861910233 }
862010234
8621
- boolean IsFrozen()
8622
- {
8623
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8624
-
8625
- return !selectmode && cameracount == 0; // != 0;
8626
- }
8627
-
862810235 boolean niceon = false;
862910236 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
863010237 boolean currentlydrawing = false;
....@@ -8642,8 +10249,8 @@
864210249 }
864310250 // if (DEBUG_SELECTION)
864410251 // {
8645
-// if (drawMode != SELECTION)
8646
-// drawMode = SELECTION;
10252
+// if (DrawMode() != SELECTION)
10253
+// DrawMode() = SELECTION;
864710254 // }
864810255
864910256 if (!isRenderer)
....@@ -8699,9 +10306,9 @@
869910306
870010307 //ANTIALIAS = 0;
870110308
8702
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10309
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870310310 {
8704
- if (niceon || isLIVE())
10311
+ if (niceon || Globals.isLIVE())
870510312 {
870610313 //if(active == 0)
870710314 // antialiaser = null;
....@@ -8726,7 +10333,7 @@
872610333 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872710334 */
872810335
8729
- if (drawMode == DEFAULT)
10336
+ if (DrawMode() == DEFAULT)
873010337 {
873110338 currentlydrawing = true;
873210339 }
....@@ -8757,12 +10364,12 @@
875710364
875810365 // if(Applet3D.clipboard != null)
875910366 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8760
-//drawMode = SELECTION;
10367
+//DrawMode() = SELECTION;
876110368 indexcount = 0;
876210369
8763
- if (drawMode == OCCLUSION)
10370
+ if (DrawMode() == OCCLUSION)
876410371 {
8765
- drawMode = DEFAULT;
10372
+ Globals.drawMode = DEFAULT; // WARNING
876610373 ambientOcclusion = true;
876710374 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876810375 Object3D theobject = object;
....@@ -8781,19 +10388,19 @@
878110388 ambientOcclusion = false;
878210389 }
878310390
8784
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10391
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
878510392 {
878610393 //if (RENDERSHADOW) // ?
878710394 if (!IsFrozen())
878810395 {
878910396 // dec 2012
8790
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10397
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
879110398 {
8792
- framecount++;
10399
+ Globals.framecount++;
879310400 shadowbuffer.display();
879410401 }
879510402 }
8796
- lighttouched = false; // ??
10403
+ Globals.lighttouched = false; // ??
879710404 //drawing = true;
879810405 //lighttouched = true;
879910406 }
....@@ -8814,9 +10421,9 @@
881410421 //eyeCamera.shaper_fovy = 1;
881510422 }
881610423
8817
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10424
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881810425 {
8819
- //System.out.println("drawMode = " + drawMode);
10426
+ //System.out.println("DrawMode() = " + DrawMode());
882010427 vertexMode |= VP_PASS;
882110428 //vertexMode |= VP_PROJECTION;
882210429 if (!ambientOcclusion)
....@@ -8876,7 +10483,7 @@
887610483 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887710484 //Camera lightcam = new Camera(light0);
887810485
8879
- if (drawMode == SHADOW)
10486
+ if (DrawMode() == SHADOW)
888010487 {
888110488 /*
888210489 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8915,7 +10522,7 @@
891510522 // if (parentcam != renderCamera) // not a light
891610523 if (cam != lightCamera)
891710524 for (int count = parentcam.GetTransformCount(); --count>=0;)
8918
- LA.matConcat(parentcam.toParent, matrix, matrix);
10525
+ LA.matConcat(matrix, parentcam.toParent, matrix);
891910526
892010527 for (int j = 0; j < 4; j++)
892110528 {
....@@ -8930,7 +10537,7 @@
893010537 // if (parentcam != renderCamera) // not a light
893110538 if (cam != lightCamera)
893210539 for (int count = parentcam.GetTransformCount(); --count>=0;)
8933
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10540
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
893410541
893510542 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893610543
....@@ -8966,7 +10573,7 @@
896610573 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896710574 } else
896810575 {
8969
- if (drawMode != DEFAULT)
10576
+ if (DrawMode() != DEFAULT)
897010577 {
897110578 gl.glClearColor(1, 1, 1, 0);
897210579 } // 1);
....@@ -9031,7 +10638,7 @@
903110638
903210639 fast &= !ambientOcclusion;
903310640
9034
- if (drawMode == DEFAULT)
10641
+ if (DrawMode() == DEFAULT)
903510642 {
903610643 //gl.glEnable(gl.GL_ALPHA_TEST);
903710644 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9092,6 +10699,8 @@
909210699 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909310700 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909410701 double scale = lightCamera.SCALE / lightCamera.Distance();
10702
+// PATCH FILLE AUX JEANS
10703
+ //scale *= lightCamera.shaper_fovy / 25;
909510704 gl.glScaled(2 * scale, 2 * scale, -scale);
909610705 gl.glTranslated(0, 0, lightCamera.DECAL);
909710706
....@@ -9227,10 +10836,12 @@
922710836 gl.glMatrixMode(gl.GL_PROJECTION);
922810837 gl.glLoadIdentity();
922910838
9230
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10839
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923110840 {
923210841 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923310842 double scale = lightCamera.SCALE / lightCamera.Distance();
10843
+// PATCH FILLE AUX JEANS
10844
+ //scale *= lightCamera.shaper_fovy / 25;
923410845 gl.glScaled(2 * scale, 2 * scale, -scale);
923510846 gl.glTranslated(0, 0, lightCamera.DECAL);
923610847 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9283,7 +10894,7 @@
928310894 //gl.glPushMatrix();
928410895 gl.glLoadIdentity();
928510896
9286
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10897
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928710898 {
928810899 //LA.xformPos(light0, lightCamera.fromScreen, light);
928910900 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9370,7 +10981,7 @@
937010981 }
937110982
937210983 /**/
9373
- if (true) // drawMode == SELECTION) // != DEFAULT)
10984
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937410985 gl.glDisable(gl.GL_LIGHTING);
937510986 else
937610987 gl.glEnable(gl.GL_LIGHTING);
....@@ -9388,7 +10999,7 @@
938810999
938911000 lightslot = 64;
939011001
9391
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11002
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939211003 {
939311004 DrawLights(object);
939411005 }
....@@ -9399,7 +11010,7 @@
939911010 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940011011 //System.out.println("fragmentMode = " + fragmentMode);
940111012
9402
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11013
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
940311014 {
940411015 /*
940511016 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9432,7 +11043,7 @@
943211043 }
943311044 }
943411045
9435
- if (drawMode == DEFAULT)
11046
+ if (DrawMode() == DEFAULT)
943611047 {
943711048 if (WIREFRAME && !ambientOcclusion)
943811049 {
....@@ -9450,7 +11061,7 @@
945011061 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945111062 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945211063
9453
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11064
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945411065 {
945511066 if (vertexMode != 0) // && !fast)
945611067 {
....@@ -9470,7 +11081,7 @@
947011081 }
947111082 }
947211083
9473
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11084
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947411085 {
947511086 //gl.glDepthFunc(GL.GL_LEQUAL);
947611087 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9498,7 +11109,7 @@
949811109 //gl.glDepthMask(false);
949911110 }
950011111
9501
- if (false) // drawMode == SHADOW)
11112
+ if (false) // DrawMode() == SHADOW)
950211113 {
950311114 //SetColumnMajorData(cameraInverseTransform, view_1);
950411115 //System.out.println("light = " + cameraInverseTransform);
....@@ -9512,16 +11123,16 @@
951211123 //System.out.println("object = " + object);
951311124 if (!frozen && !imageLocked)
951411125 {
9515
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11126
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951611127 {
951711128 displayAntiAliased(gl);
951811129 } else
951911130 {
952011131 programcount = 0;
9521
- int keepmode = drawMode;
11132
+ int keepmode = DrawMode();
952211133 // if (DEBUG_SELECTION)
952311134 // {
9524
-// drawMode = SELECTION;
11135
+// DrawMode() = SELECTION;
952511136 // }
952611137 // for point selection
952711138 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9531,10 +11142,10 @@
953111142 DrawObject(gl);
953211143
953311144 // jan 2013 System.err.println("RESET ABORT (display)");
9534
- // if (drawMode == DEFAULT)
11145
+ // if (DrawMode() == DEFAULT)
953511146 // ABORTED = false;
953611147 fullreset = false;
9537
- drawMode = keepmode;
11148
+ Globals.drawMode = keepmode; // WARNING
953811149 //System.out.println("PROGRAM SWITCH " + programcount);
953911150 }
954011151 }
....@@ -9542,11 +11153,11 @@
954211153 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954311154 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954411155
9545
- if (drawMode == DEFAULT)
11156
+ if (DrawMode() == DEFAULT)
954611157 {
954711158 ReleaseTexture(NOISE_TEXTURE, false);
954811159 }
9549
- //if (drawMode == DEFAULT)
11160
+ //if (DrawMode() == DEFAULT)
955011161 {
955111162
955211163 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9558,7 +11169,7 @@
955811169 //else
955911170 //gl.glDisable(gl.GL_TEXTURE_2D);
956011171 //gl.glPopMatrix();
9561
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11172
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956211173 {
956311174 //new Exception().printStackTrace();
956411175 //System.out.println("Draw image " + width + ", " + height);
....@@ -9600,7 +11211,7 @@
960011211 //gl.glFlush();
960111212 }
960211213
9603
- if (flash && drawMode == DEFAULT)
11214
+ if (flash && DrawMode() == DEFAULT)
960411215 {
960511216 flash = false;
960611217 wait = true;
....@@ -9608,9 +11219,9 @@
960811219 }
960911220
961011221 //drawing = false;
9611
- //if(drawMode == DEFAULT)
11222
+ //if(DrawMode() == DEFAULT)
961211223 // niceon = false;
9613
- if (drawMode == DEFAULT)
11224
+ if (DrawMode() == DEFAULT)
961411225 {
961511226 currentlydrawing = false;
961611227 }
....@@ -9630,7 +11241,7 @@
963011241 repaint();
963111242 }
963211243
9633
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11244
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963411245 repaint();
963511246
963611247 displaydone = true;
....@@ -9667,7 +11278,7 @@
966711278 if (GrafreeD.RENDERME > 0)
966811279 GrafreeD.RENDERME--; // mechante magouille
966911280
9670
- ONESTEP = false;
11281
+ Globals.ONESTEP = false;
967111282 }
967211283
967311284 static boolean zoomonce = false;
....@@ -9675,11 +11286,11 @@
967511286 void DrawObject(GL gl, boolean draw)
967611287 {
967711288 //System.out.println("DRAW OBJECT " + mouseDown);
9678
-// drawMode = SELECTION;
11289
+// DrawMode() = SELECTION;
967911290 //GL gl = getGL();
968011291 if ((TRACK || SHADOWTRACK) || zoomonce)
968111292 {
9682
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11293
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968311294 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968411295 pingthread.StepToTarget(true); // true);
968511296 // zoomonce = false;
....@@ -9700,9 +11311,9 @@
970011311 callist = gl.glGenLists(1);
970111312 }
970211313
9703
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11314
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970411315
9705
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11316
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970611317
970711318 if (!mainDL || !active || touched)
970811319 {
....@@ -9729,7 +11340,7 @@
972911340 PushMatrix(ClickInfo.matbuffer);
973011341 }
973111342
9732
- if (drawMode == 0)
11343
+ if (DrawMode() == 0)
973311344 {
973411345 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973511346
....@@ -9743,7 +11354,7 @@
974311354 // DRAW
974411355 object.draw(this, /*(Composite)*/ object, false, false);
974511356
9746
- if (drawMode == DEFAULT)
11357
+ if (DrawMode() == DEFAULT)
974711358 {
974811359 if (DEBUG)
974911360 {
....@@ -9754,40 +11365,40 @@
975411365 selectedpoint.radius = radius;
975511366 selectedpoint.recalculate();
975611367 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.25f;
11368
+ selectedpoint.material.color = 0.15f; // Yellow
975811369 selectedpoint.material.modulation = 0.75f;
975911370
9760
- debugpoint.radius = radius;
9761
- debugpoint.recalculate();
9762
- debugpoint.material = new cMaterial();
9763
- debugpoint.material.color = 0.25f;
9764
- debugpoint.material.modulation = 0.75f;
11371
+ debugpointG.radius = radius;
11372
+ debugpointG.recalculate();
11373
+ debugpointG.material = new cMaterial();
11374
+ debugpointG.material.color = 0.25f; // Green
11375
+ debugpointG.material.modulation = 0.75f;
976511376
9766
- debugpoint2.radius = radius;
9767
- debugpoint2.recalculate();
9768
- debugpoint2.material = new cMaterial();
9769
- debugpoint2.material.color = 0.75f;
9770
- debugpoint2.material.modulation = 0.75f;
11377
+ debugpointP.radius = radius;
11378
+ debugpointP.recalculate();
11379
+ debugpointP.material = new cMaterial();
11380
+ debugpointP.material.color = 0.75f; // Purple
11381
+ debugpointP.material.modulation = 0.75f;
977111382
9772
- debugpoint3.radius = radius;
9773
- debugpoint3.recalculate();
9774
- debugpoint3.material = new cMaterial();
9775
- debugpoint3.material.color = 0.5f;
9776
- debugpoint3.material.modulation = 0.75f;
11383
+ debugpointC.radius = radius;
11384
+ debugpointC.recalculate();
11385
+ debugpointC.material = new cMaterial();
11386
+ debugpointC.material.color = 0.5f; // Cyan
11387
+ debugpointC.material.modulation = 0.75f;
977711388
9778
- debugpoint4.radius = radius;
9779
- debugpoint4.recalculate();
9780
- debugpoint4.material = new cMaterial();
9781
- debugpoint4.material.color = 0f;
9782
- debugpoint4.material.modulation = 0.75f;
11389
+ debugpointR.radius = radius;
11390
+ debugpointR.recalculate();
11391
+ debugpointR.material = new cMaterial();
11392
+ debugpointR.material.color = 0f; // Red
11393
+ debugpointR.material.modulation = 0.75f;
978311394
978411395 InitPoints(radius);
978511396 }
978611397 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9787
- debugpoint.draw(this, /*(Composite)*/ null, false,false);
9788
- debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9789
- debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9790
- debugpoint4.draw(this, /*(Composite)*/ null, false,false);
11398
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11399
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11400
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11401
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
979111402 // DrawPoints(this);
979211403 }
979311404
....@@ -9795,7 +11406,7 @@
979511406 }
979611407 // GrafreeD.traceoff();
979711408 //System.out.println(stackdepth);
9798
- if (drawMode == 0)
11409
+ if (DrawMode() == 0)
979911410 {
980011411 ReleaseTextures(DEFAULT_TEXTURES);
980111412
....@@ -9820,17 +11431,19 @@
982011431
982111432 checker = null;
982211433
9823
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11434
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982411435 FindChecker(object);
982511436
9826
- if (checker != null && drawMode == DEFAULT)
11437
+ if (checker != null && DrawMode() == DEFAULT)
982711438 {
9828
- // BindTexture(IMMORTAL_TEXTURE);
11439
+ //BindTexture(IMMORTAL_TEXTURE);
11440
+ BindTextures(checker.GetTextures(), checker.texres);
982911441 // NEAREST
983011442 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
983111443 DrawChecker(gl);
983211444 //checker.Draw(this, null, false);
983311445 // ReleaseTexture(IMMORTAL_TEXTURE);
11446
+ ReleaseTextures(checker.GetTextures());
983411447 }
983511448
983611449 if (object.parent != null)
....@@ -9843,7 +11456,7 @@
984311456 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984411457 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984511458
9846
- if (DISPLAYTEXT && drawMode == DEFAULT)
11459
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984711460 {
984811461 // Draw it once, then use the raster
984911462 Balloon(gl, balloon.createGraphics());
....@@ -9899,9 +11512,9 @@
989911512 int[] xs = new int[3];
990011513 int[] ys = new int[3];
990111514
9902
- void DrawString(Object3D obj) // String string)
11515
+ public void DrawString(Object3D obj) // String string) // INTERFACE
990311516 {
9904
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11517
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990511518 {
990611519 return;
990711520 }
....@@ -10388,6 +12001,7 @@
1038812001 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038912002 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1039012003 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
12004
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1039112005 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1039212006 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1039312007 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -11134,7 +12748,7 @@
1113412748 "MUL final.y, fragment.texcoord[0].x, c256;" +
1113512749 "FLR final.x, final.y;" +
1113612750 "SUB final.y, final.y, final.x;" +
11137
- "MUL final.x, final.x, c256i;" +
12751
+ //"MUL final.x, final.x, c256i;" +
1113812752 "MOV final.z, zero.x;" +
1113912753 "MOV final.a, one.w;":""
1114012754 ) +
....@@ -11142,7 +12756,7 @@
1114212756 "MUL final.y, fragment.texcoord[0].y, c256;" +
1114312757 "FLR final.x, final.y;" +
1114412758 "SUB final.y, final.y, final.x;" +
11145
- "MUL final.x, final.x, c256i;" +
12759
+ //"MUL final.x, final.x, c256i;" +
1114612760 "MOV final.z, zero.x;" +
1114712761 "MOV final.a, one.w;":""
1114812762 ) +
....@@ -11302,6 +12916,7 @@
1130212916 String Shadow(String depth, String shadow)
1130312917 {
1130412918 return "MAX temp.x, ndotl.x, one64th.x;" +
12919
+ "MIN temp.x, temp.x, ninetenth.x;" +
1130512920 /**/
1130612921 // Sine
1130712922 "MUL temp.y, temp.x, temp.x;" +
....@@ -11921,14 +13536,16 @@
1192113536
1192213537 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1192313538
13539
+ if (BUTTONLESSWHEEL)
1192413540 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1192513541 {
1192613542 return;
1192713543 }
1192813544
13545
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1192913546
1193013547 // TIMER
11931
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13548
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1193213549 {
1193313550 keepboxmode = BOXMODE;
1193413551 keepsupport = SUPPORT;
....@@ -12057,7 +13674,7 @@
1205713674 // ObjEditor.tweenManager.update(1f / 60f);
1205813675
1205913676 // fev 2014???
12060
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13677
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1206113678 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1206213679 pingthread.StepToTarget(true); // true);
1206313680 }
....@@ -12145,11 +13762,11 @@
1214513762
1214613763 public void mouseDragged(MouseEvent e)
1214713764 {
13765
+ //System.out.println("mouseDragged: " + e);
1214813766 if (isRenderer)
1214913767 movingcamera = true;
1215013768 //if (drawing)
1215113769 //return;
12152
- //System.out.println("mouseDragged: " + e);
1215313770 if ((e.getModifiersEx() & CTRL) != 0
1215413771 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1215513772 {
....@@ -12169,6 +13786,11 @@
1216913786 cVector tmp = new cVector();
1217013787 cVector tmp2 = new cVector();
1217113788 boolean isMoving;
13789
+
13790
+ public cVector TargetLookAt()
13791
+ {
13792
+ return targetLookAt;
13793
+ }
1217213794
1217313795 class PingThread extends Thread
1217413796 {
....@@ -12308,7 +13930,7 @@
1230813930 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1230913931 if (lightMode)
1231013932 {
12311
- lighttouched = true;
13933
+ Globals.lighttouched = true;
1231213934 }
1231313935
1231413936 if (OEILONCE && OEIL)
....@@ -12325,6 +13947,7 @@
1232513947
1232613948 public void run()
1232713949 {
13950
+ new Exception().printStackTrace();
1232813951 System.exit(0);
1232913952 for (;;)
1233013953 {
....@@ -12366,7 +13989,7 @@
1236613989 mouseDown = false;
1236713990 if (lightMode)
1236813991 {
12369
- lighttouched = true;
13992
+ Globals.lighttouched = true;
1237013993 }
1237113994 repaint();
1237213995 alreadypainted = true;
....@@ -12374,7 +13997,7 @@
1237413997 isMoving = false;
1237513998 } //??
1237613999
12377
- if (isLIVE() && !alreadypainted)
14000
+ if (Globals.isLIVE() && !alreadypainted)
1237814001 {
1237914002 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1238014003 repaint();
....@@ -12386,7 +14009,7 @@
1238614009 {
1238714010 if (lightMode)
1238814011 {
12389
- lighttouched = true;
14012
+ Globals.lighttouched = true;
1239014013 }
1239114014 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1239214015 }
....@@ -12629,6 +14252,7 @@
1262914252 {
1263014253 manipCamera.Translate(dx, dy, getWidth());
1263114254 }
14255
+ else
1263214256 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1263314257 {
1263414258 manipCamera.RotateInterest(dx, dy);
....@@ -12639,7 +14263,7 @@
1263914263
1264014264 if (manipCamera == lightCamera)
1264114265 {
12642
- lighttouched = true;
14266
+ Globals.lighttouched = true;
1264314267 }
1264414268 /*
1264514269 switch (mode)
....@@ -12678,7 +14302,6 @@
1267814302 public void mouseMoved(MouseEvent e)
1267914303 {
1268014304 //System.out.println("mouseMoved: " + e);
12681
-
1268214305 if (isRenderer)
1268314306 return;
1268414307
....@@ -12862,7 +14485,7 @@
1286214485 }
1286314486 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1286414487 {
12865
- mouseMode |= SELECT; // BACKFORTH;
14488
+ mouseMode |= SELECT;
1286614489 }
1286714490 if ((modifiers & COMMAND) == COMMAND)
1286814491 {
....@@ -12900,7 +14523,7 @@
1290014523 SetMouseMode(modifiers);
1290114524 }
1290214525
12903
- theRenderer.keyPressed(key);
14526
+ Globals.theRenderer.keyPressed(key);
1290414527 }
1290514528
1290614529 int kompactbit = 4; // power bit
....@@ -12912,7 +14535,7 @@
1291214535 float SATPOW = 1; // 2; // 0.5f;
1291314536 float BRIPOW = 1; // 0.5f; // 0.5f;
1291414537
12915
- void keyPressed(int key)
14538
+ public void keyPressed(int key)
1291614539 {
1291714540 if (key >= '0' && key <= '5')
1291814541 clampbit = (key-'0');
....@@ -13027,7 +14650,7 @@
1302714650 case 'B':
1302814651 BRISMOOTH ^= true;
1302914652 SHADOWCULLFACE ^= true;
13030
- lighttouched = true;
14653
+ Globals.lighttouched = true;
1303114654 repaint();
1303214655 break;
1303314656 case 'b':
....@@ -13127,7 +14750,7 @@
1312714750 repaint();
1312814751 break;
1312914752 case 'O':
13130
- drawMode = OCCLUSION;
14753
+ Globals.drawMode = OCCLUSION; // WARNING
1313114754 repaint();
1313214755 break;
1313314756 case 'o':
....@@ -13218,7 +14841,7 @@
1321814841 break;
1321914842 case ' ':
1322014843 lightMode ^= true;
13221
- lighttouched = true;
14844
+ Globals.lighttouched = true;
1322214845 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1322314846 targetLookAt.set(manipCamera.lookAt);
1322414847 repaint();
....@@ -13230,11 +14853,11 @@
1323014853 repaint();
1323114854 break;
1323214855 case 'Z':
13233
- RESIZETEXTURE ^= true;
13234
- break;
14856
+ //RESIZETEXTURE ^= true;
14857
+ //break;
1323514858 case 'z':
1323614859 RENDERSHADOW ^= true;
13237
- lighttouched = true;
14860
+ Globals.lighttouched = true;
1323814861 repaint();
1323914862 break;
1324014863 //case UP:
....@@ -13349,6 +14972,7 @@
1334914972 }
1335014973 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1335114974 }
14975
+
1335214976 static double OCCLUSIONBOOST = 1; // 0.5;
1335314977
1335414978 void keyReleased(int key, int modifiers)
....@@ -13360,7 +14984,7 @@
1336014984 }
1336114985 }
1336214986
13363
- protected void processKeyEvent(KeyEvent e)
14987
+ public void processKeyEvent(KeyEvent e)
1336414988 {
1336514989 switch (e.getID())
1336614990 {
....@@ -13490,8 +15114,9 @@
1349015114
1349115115 protected void processMouseMotionEvent(MouseEvent e)
1349215116 {
13493
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13494
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15118
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
1349515120 {
1349615121 mouseMoved(e);
1349715122 } else
....@@ -13521,6 +15146,7 @@
1352115146
1352215147 void SelectParent()
1352315148 {
15149
+ new Exception().printStackTrace();
1352415150 System.exit(0);
1352515151 Composite group = (Composite) object;
1352615152 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13544,6 +15170,7 @@
1354415170
1354515171 void SelectChildren()
1354615172 {
15173
+ new Exception().printStackTrace();
1354715174 System.exit(0);
1354815175 /*
1354915176 Composite group = (Composite) object;
....@@ -13836,6 +15463,7 @@
1383615463 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1383715464 }
1383815465
15466
+ // To avoid clear.
1383915467 public void update(Graphics g)
1384015468 {
1384115469 paint(g);
....@@ -14438,7 +16066,7 @@
1443816066 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1443916067 gl.glPushMatrix();
1444016068 gl.glLoadIdentity();
14441
- PushMatrix(checker.toParent);
16069
+ //PushMatrix(checker.toParent);
1444216070
1444316071 gl.glMatrixMode(GL.GL_TEXTURE);
1444416072 gl.glPushMatrix();
....@@ -14461,8 +16089,8 @@
1446116089
1446216090 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1446316091
14464
- float step = 0.1666f; //0.25f;
14465
- float stepv = step * 1652 / 998;
16092
+ float step = 2; // 0.1666f; //0.25f;
16093
+ float stepv = 2; // step * 1652 / 998;
1446616094
1446716095 int i0 = 0;
1446816096 /*
....@@ -14498,20 +16126,21 @@
1449816126 /**/
1449916127 //checker.GetMaterial().opacity = 1.1f;
1450016128 ////checker.GetMaterial().ambient = 0.99f;
14501
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14502
- Object3D.selectedstack[Object3D.materialdepth] = false;
14503
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16129
+ materialstack[materialdepth] = checker.material;
16130
+ selectedstack[materialdepth] = false;
16131
+ cStatic.objectstack[materialdepth++] = checker;
1450416132 //System.out.println("material " + material);
1450516133 //Applet3D.tracein(this, selected);
1450616134 vector2buffer = checker.projectedVertices;
1450716135
14508
- checker.GetMaterial().Draw(this, false); // true);
16136
+ //checker.GetMaterial().Draw(this, false); // true);
16137
+ DrawMaterial(checker.GetMaterial(), false); // true);
1450916138
14510
- Object3D.materialdepth -= 1;
14511
- if (Object3D.materialdepth > 0)
16139
+ materialdepth -= 1;
16140
+ if (materialdepth > 0)
1451216141 {
14513
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14514
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16142
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1451516144 }
1451616145 //checker.GetMaterial().opacity = 1f;
1451716146 ////checker.GetMaterial().ambient = 1f;
....@@ -14532,15 +16161,27 @@
1453216161
1453316162 //float u = (i+1)/2;
1453416163 //float v = (j+1)/2;
14535
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
16164
+ if (checker.flipV)
16165
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
16166
+ else
16167
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1453616168 gl.glVertex3f(i, j, -0.5f);
1453716169
16170
+ if (checker.flipV)
16171
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
16172
+ else
1453816173 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1453916174 gl.glVertex3f(i + step, j, -0.5f);
1454016175
16176
+ if (checker.flipV)
16177
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
16178
+ else
1454116179 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1454216180 gl.glVertex3f(i + step, j + stepv, -0.5f);
1454316181
16182
+ if (checker.flipV)
16183
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
16184
+ else
1454416185 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1454516186 gl.glVertex3f(i, j + stepv, -0.5f);
1454616187 }
....@@ -14552,7 +16193,7 @@
1455216193 gl.glMatrixMode(GL.GL_PROJECTION);
1455316194 gl.glPopMatrix();
1455416195 gl.glMatrixMode(GL.GL_MODELVIEW);
14555
- PopMatrix(null); // checker.toParent); // null);
16196
+ //PopMatrix(null); // checker.toParent); // null);
1455616197 gl.glPopMatrix();
1455716198 PopTextureMatrix(checker.toParent);
1455816199 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14643,6 +16284,7 @@
1464316284 {
1464416285 if (!selection)
1464516286 {
16287
+ new Exception().printStackTrace();
1464616288 System.exit(0);
1464716289 return;
1464816290 }
....@@ -14665,14 +16307,14 @@
1466516307
1466616308 //int tmp = selection_view;
1466716309 //selection_view = -1;
14668
- int temp = drawMode;
14669
- drawMode = SELECTION;
16310
+ int temp = DrawMode();
16311
+ Globals.drawMode = SELECTION; // WARNING
1467016312 indexcount = 0;
1467116313 parent.display(drawable);
1467216314 //selection_view = tmp;
1467316315 //if (temp == SELECTION)
1467416316 // temp = DEFAULT; // patch for selection debug
14675
- drawMode = temp;
16317
+ Globals.drawMode = temp; // WARNING
1467616318
1467716319 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1467816320
....@@ -14945,14 +16587,14 @@
1494516587 //gl.glColorMask(false, false, false, false);
1494616588
1494716589 //render_scene_from_light_view(gl, drawable, 0, 0);
14948
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16590
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1494916591 {
1495016592 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1495116593
14952
- int temp = drawMode;
14953
- drawMode = SHADOW;
16594
+ int temp = DrawMode();
16595
+ Globals.drawMode = SHADOW; // WARNING
1495416596 parent.display(drawable);
14955
- drawMode = temp;
16597
+ Globals.drawMode = temp; // WARNING
1495616598 }
1495716599
1495816600 gl.glCullFace(gl.GL_BACK);
....@@ -15005,7 +16647,6 @@
1500516647
1500616648 class AntialiasBuffer implements GLEventListener
1500716649 {
15008
-
1500916650 CameraPane parent = null;
1501016651
1501116652 AntialiasBuffer(CameraPane p)
....@@ -15115,13 +16756,19 @@
1511516756 gl.glFlush();
1511616757
1511716758 /**/
15118
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16759
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1511916760
15120
- int[] pixels = occlusionsizebuffer.array();
16761
+ float[] pixels = occlusionsizebuffer.array();
1512116762
1512216763 double r = 0, g = 0, b = 0;
1512316764
1512416765 double count = 0;
16766
+
16767
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16768
+
16769
+ float mindepth = 1;
16770
+
16771
+ double FACTOR = 1;
1512516772
1512616773 for (int i = 0; i < pixels.length; i++)
1512716774 {
....@@ -15206,7 +16853,7 @@
1520616853
1520716854 double scale = ray.z; // 1; // cos
1520816855
15209
- int p = pixels[newindex];
16856
+ float depth = pixels[newindex];
1521016857
1521116858 /*
1521216859 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15230,10 +16877,23 @@
1523016877 scale = (1 - modu) * modv;
1523116878 */
1523216879
15233
- r += ((p >> 16) & 0xFF) * scale / 255;
15234
- g += ((p >> 8) & 0xFF) * scale / 255;
15235
- b += (p & 0xFF) * scale / 255;
16880
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16881
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16882
+ //b += (p & 0xFF) * scale / 255;
16883
+
16884
+ if (mindepth > depth)
16885
+ {
16886
+ mindepth = depth;
16887
+ }
1523616888
16889
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16890
+
16891
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16892
+
16893
+ r += factor * scale;
16894
+ g += factor * scale;
16895
+ b += factor * scale;
16896
+
1523716897 count += scale;
1523816898 }
1523916899
....@@ -15331,12 +16991,6 @@
1533116991 GLUT glut = new GLUT();
1533216992
1533316993
15334
- static final public int DEFAULT = 0;
15335
- static final public int SELECTION = 1;
15336
- static final public int SHADOW = 2;
15337
- static final public int OCCLUSION = 3;
15338
- static
15339
- public int drawMode = DEFAULT;
1534016994 public boolean spherical = false;
1534116995 static boolean DEBUG_OCCLUSION = false;
1534216996 static boolean DEBUG_SELECTION = false;
....@@ -15351,10 +17005,10 @@
1535117005 //double[] selectedpoint = new double[3];
1535217006 static Superellipsoid selectedpoint = new Superellipsoid();
1535317007 static Sphere previousselectedpoint = null;
15354
- static Sphere debugpoint = new Sphere();
15355
- static Sphere debugpoint2 = new Sphere();
15356
- static Sphere debugpoint3 = new Sphere();
15357
- static Sphere debugpoint4 = new Sphere();
17008
+ static Sphere debugpointG = new Sphere();
17009
+ static Sphere debugpointP = new Sphere();
17010
+ static Sphere debugpointC = new Sphere();
17011
+ static Sphere debugpointR = new Sphere();
1535817012
1535917013 static Sphere debugpoints[] = new Sphere[8];
1536017014
....@@ -15385,7 +17039,7 @@
1538517039 }
1538617040 }
1538717041
15388
- static void DrawPoints(CameraPane cpane)
17042
+ static void DrawPoints(iCameraPane cpane)
1538917043 {
1539017044 for (int i=0; i<8; i++) // first and last are red
1539117045 {
....@@ -15407,7 +17061,8 @@
1540717061 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1540817062 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1540917063 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15410
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17064
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17065
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1541117066 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1541217067 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1541317068 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15416,10 +17071,11 @@
1541617071 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1541717072 // Depth buffer format
1541817073 //private int depth_format;
15419
- static public void NextIndex(Object3D o, GL gl)
17074
+
17075
+ public void NextIndex()
1542017076 {
1542117077 indexcount+=16;
15422
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17078
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1542317079 //objects[indexcount] = o;
1542417080 //System.out.println("indexcount = " + indexcount);
1542517081 }