Normand Briere
2019-04-22 3c4c16e0a4ca3949a7a37a24607df7f89abfe7ea
CameraPane.java
....@@ -31,8 +31,12 @@
3131
3232 import gleem.linalg.Mat4f;
3333
34
-class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
34
+class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3535 {
36
+ static cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3640 static boolean DEBUG = false;
3741 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3842
....@@ -42,25 +46,7 @@
4246
4347 static int STEP = 1;
4448
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
51
- {
52
- return LIVE || ONESTEP;
53
- }
54
-
55
- /**
56
- * @param aLIVE the LIVE to set
57
- */
58
- public static void setLIVE(boolean aLIVE)
59
- {
60
- LIVE = aLIVE;
61
- }
62
-
63
- /*static*/ boolean CULLFACE = false; // true;
49
+ /*static*/ private boolean CULLFACE = false; // true;
6450 /*static*/ boolean NEAREST = false; // true;
6551 /*static*/ boolean WIREFRAME = false; // true;
6652
....@@ -97,10 +83,8 @@
9783
9884 static boolean textureon = true;
9985 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10186 static boolean FULLSCREEN = false;
10287 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10488 static boolean INERTIA = true;
10589 static boolean FAST = false;
10690 static boolean SLOWPOSE = false;
....@@ -165,12 +149,41 @@
165149 defaultcaps.setAccumBlueBits(16);
166150 defaultcaps.setAccumAlphaBits(16);
167151 }
152
+
168153 static CameraPane theRenderer;
169
-
154
+
170155 void SetAsGLRenderer(boolean b)
171156 {
172157 isRenderer = b;
173158 theRenderer = this;
159
+ }
160
+
161
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
162
+ {
163
+ super(defaultcaps, null, withcontext?glcontext:null, null);
164
+
165
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
166
+ glcontext = getContext();
167
+
168
+ cameras = new Camera[2];
169
+ targetLookAts = new cVector[2];
170
+
171
+ SetCamera(cam);
172
+
173
+ SetLight(new Camera(new cVector(10, 10, -20)));
174
+
175
+ object = o;
176
+
177
+ setBackground(Color.white);
178
+
179
+ addKeyListener(this);
180
+ addMouseListener(this);
181
+ addMouseMotionListener(this);
182
+ addMouseWheelListener(this);
183
+ //System.out.println("addGLEventListener: " + this);
184
+ addGLEventListener(this);
185
+
186
+// pingthread.start(); // may 2013
174187 }
175188
176189 static boolean AntialiasingEnabled()
....@@ -178,12 +191,19 @@
178191 return CURRENTANTIALIAS > 0;
179192 }
180193
181
- void ClearDepth()
194
+ /// INTERFACE
195
+
196
+ public boolean IsBoxMode()
197
+ {
198
+ return BOXMODE;
199
+ }
200
+
201
+ public void ClearDepth()
182202 {
183203 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184204 }
185205
186
- void DepthTest(boolean depthtest)
206
+ public void DepthTest(boolean depthtest)
187207 {
188208 if (depthtest)
189209 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +211,7 @@
191211 GetGL().glDepthFunc(GL.GL_ALWAYS);
192212 }
193213
194
- void DepthWrite(boolean depthwrite)
214
+ public void DepthWrite(boolean depthwrite)
195215 {
196216 if (depthwrite)
197217 GetGL().glDepthMask(true);
....@@ -199,12 +219,1265 @@
199219 GetGL().glDepthMask(false);
200220 }
201221
202
- void BackFaceCull(boolean bfc)
222
+ public void BackFaceCull(boolean bfc)
203223 {
204224 if (bfc)
205225 GetGL().glEnable(GetGL().GL_CULL_FACE);
206226 else
207227 GetGL().glDisable(GetGL().GL_CULL_FACE);
228
+ }
229
+
230
+ public boolean BackFaceCullMode()
231
+ {
232
+ return this.CULLFACE;
233
+ }
234
+
235
+ public boolean IsAmbientOcclusionOn()
236
+ {
237
+ return this.ambientOcclusion;
238
+ }
239
+
240
+ public boolean IsDebugSelection()
241
+ {
242
+ return DEBUG_SELECTION;
243
+ }
244
+
245
+ public boolean IsFrozen()
246
+ {
247
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
248
+
249
+ return !selectmode && cameracount == 0; // != 0;
250
+ }
251
+
252
+ // Currently in Globals
253
+ public int DrawMode()
254
+ {
255
+ return Globals.DrawMode();
256
+ }
257
+
258
+ public Camera EyeCamera()
259
+ {
260
+ return eyeCamera;
261
+ }
262
+
263
+ public Camera LightCamera()
264
+ {
265
+ return lightCamera;
266
+ }
267
+
268
+ public Camera ManipCamera()
269
+ {
270
+ return manipCamera;
271
+ }
272
+
273
+ public Camera RenderCamera()
274
+ {
275
+ return renderCamera;
276
+ }
277
+
278
+ public Camera[] Cameras()
279
+ {
280
+ return cameras;
281
+ }
282
+
283
+ public void PushMaterial(Object3D obj, boolean selected)
284
+ {
285
+ CameraPane display = this;
286
+ javax.media.opengl.GL gl = display.GetGL();
287
+ cMaterial material = obj.material;
288
+
289
+ if (material != null)
290
+ {
291
+ materialstack[materialdepth] = material;
292
+ selectedstack[materialdepth] = selected;
293
+ cStatic.objectstack[materialdepth++] = obj;
294
+ //System.out.println("material " + material);
295
+ //Applet3D.tracein(this, selected);
296
+ display.vector2buffer = obj.projectedVertices;
297
+ if (obj instanceof Camera)
298
+ {
299
+ display.options1[0] = material.shift;
300
+ //System.out.println("shift " + material.shift);
301
+ display.options1[1] = material.lightarea;
302
+ display.options1[2] = material.shadowbias;
303
+ display.options1[3] = material.aniso;
304
+ display.options1[4] = material.anisoV;
305
+ display.options2[0] = material.opacity;
306
+ display.options2[1] = material.diffuse;
307
+ display.options2[2] = material.factor;
308
+
309
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
310
+ display.options4[0] = material.cameralight/0.2f;
311
+ display.options4[1] = material.subsurface;
312
+ display.options4[2] = material.sheen;
313
+
314
+ // if (display.CURRENTANTIALIAS > 0)
315
+ // display.options3[3] /= 4;
316
+
317
+ /*
318
+ System.out.println("Focus = " + display.options1[0]);
319
+ System.out.println("Aperture = " + display.options1[1]);
320
+ System.out.println("ShadowBlur = " + display.options1[2]);
321
+ System.out.println("Antialiasing = " + display.options1[3]);
322
+ System.out.println("Fog = " + display.options2[0]);
323
+ System.out.println("Intensity = " + display.options2[1]);
324
+ System.out.println("Elevation = " + display.options2[2]);
325
+ /**/
326
+ } else
327
+ {
328
+ DrawMaterial(material, selected);
329
+ }
330
+ } else
331
+ {
332
+ if (selected && CameraPane.flash)
333
+ {
334
+ display.modelParams4[1] = 100;
335
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
336
+ }
337
+ }
338
+ }
339
+
340
+ public void PushMaterial2(Object3D obj, boolean selected)
341
+ {
342
+ CameraPane display = this;
343
+ cMaterial material = obj.material;
344
+
345
+ if (material != null)
346
+ {
347
+ materialstack[materialdepth] = material;
348
+ selectedstack[materialdepth] = selected;
349
+ cStatic.objectstack[materialdepth++] = obj;
350
+ //System.out.println("material " + material);
351
+ //Applet3D.tracein("selected ", selected);
352
+ display.vector2buffer = obj.projectedVertices;
353
+ display.DrawMaterial(material, selected);
354
+ }
355
+ }
356
+
357
+ public void PopMaterial(Object3D obj, boolean selected)
358
+ {
359
+ CameraPane display = this;
360
+ javax.media.opengl.GL gl = display.GetGL();
361
+ cMaterial material = obj.material;
362
+
363
+ //if (parent != null && parent.GetMaterial() != null)
364
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
365
+ if (material != null)
366
+ {
367
+ materialdepth -= 1;
368
+ if (materialdepth > 0)
369
+ {
370
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
371
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
372
+ }
373
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
374
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
375
+ {
376
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
377
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
378
+ }
379
+ }
380
+
381
+ public void PopMaterial2(Object3D obj)
382
+ {
383
+ CameraPane display = this;
384
+ cMaterial material = obj.material;
385
+
386
+ if (material != null)
387
+ {
388
+ materialdepth -= 1;
389
+ if (materialdepth > 0)
390
+ {
391
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
392
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
393
+ }
394
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
395
+ //else
396
+ //material.Draw(display, false);
397
+ }
398
+ }
399
+
400
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
401
+ {
402
+ CameraPane display = this;
403
+
404
+ if (pv.y == -10000 ||
405
+ qv.y == -10000 ||
406
+ rv.y == -10000)
407
+ return;
408
+
409
+// float b = f.nbiterations & 1;
410
+// float g = (f.nbiterations>>1) & 1;
411
+// float r = (f.nbiterations>>2) & 1;
412
+//
413
+// //if (f.weight == 10000)
414
+// //{
415
+// // r = 1; g = b = 0;
416
+// //}
417
+// //else
418
+// //{
419
+// // assert(f.weight < 10000);
420
+// r = g = b = (float)bRep.FaceWeight(f)*100;
421
+// if (r<0)
422
+// assert(r>=0);
423
+// //}
424
+
425
+ javax.media.opengl.GL gl = display.GetGL();
426
+
427
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
428
+
429
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
430
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
431
+ {
432
+ //gl.glBegin(gl.GL_TRIANGLES);
433
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
434
+ if (!hasnorm)
435
+ {
436
+ // System.out.println("FUCK!!");
437
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
438
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
439
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
440
+ LA.vecNormalize(obj.v2);
441
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
442
+ }
443
+
444
+ // P
445
+ float x = (float)pv.x;
446
+ float y = (float)pv.y;
447
+ float z = (float)pv.z;
448
+
449
+ if (hasnorm)
450
+ {
451
+// if (!pv.norm.normalized())
452
+// assert(pv.norm.normalized());
453
+
454
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
455
+ float nx = (float)pv.norm.x;
456
+ float ny = (float)pv.norm.y;
457
+ float nz = (float)pv.norm.z;
458
+
459
+ x += nx * obj.NORMALPUSH;
460
+ y += ny * obj.NORMALPUSH;
461
+ z += nz * obj.NORMALPUSH;
462
+
463
+ gl.glNormal3f(nx, ny, nz);
464
+ }
465
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
466
+ SetColor(obj, pv);
467
+ //gl.glColor4f(r, g, b, 1);
468
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
469
+ if (obj.flipV)
470
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
471
+ else
472
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
473
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
474
+
475
+ gl.glVertex3f(x, y, z);
476
+
477
+ // Q
478
+ x = (float)qv.x;
479
+ y = (float)qv.y;
480
+ z = (float)qv.z;
481
+
482
+// Print(pv);
483
+ if (hasnorm)
484
+ {
485
+// assert(qv.norm.normalized());
486
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
487
+ float nx = (float)qv.norm.x;
488
+ float ny = (float)qv.norm.y;
489
+ float nz = (float)qv.norm.z;
490
+
491
+ x += nx * obj.NORMALPUSH;
492
+ y += ny * obj.NORMALPUSH;
493
+ z += nz * obj.NORMALPUSH;
494
+
495
+ gl.glNormal3f(nx, ny, nz);
496
+ }
497
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
498
+ // boolean locked = false;
499
+ // float eps = 0.1f;
500
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
501
+
502
+ // int dot = 0; //*/ (int)f.dot;
503
+
504
+ // if ((dot&1) == 0)
505
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
506
+
507
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
508
+ if (obj.flipV)
509
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
510
+ else
511
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
512
+ // else
513
+ // {
514
+ // locked = true;
515
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
516
+ // }
517
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
518
+ SetColor(obj, qv);
519
+
520
+ gl.glVertex3f(x, y, z);
521
+ //gl.glColor4f(r, g, b, 1);
522
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
523
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
524
+// Print(qv);
525
+
526
+ // R
527
+ x = (float)rv.x;
528
+ y = (float)rv.y;
529
+ z = (float)rv.z;
530
+
531
+ if (hasnorm)
532
+ {
533
+// assert(rv.norm.normalized());
534
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
535
+ float nx = (float)rv.norm.x;
536
+ float ny = (float)rv.norm.y;
537
+ float nz = (float)rv.norm.z;
538
+
539
+ x += nx * obj.NORMALPUSH;
540
+ y += ny * obj.NORMALPUSH;
541
+ z += nz * obj.NORMALPUSH;
542
+
543
+ gl.glNormal3f(nx, ny, nz);
544
+ }
545
+
546
+ // if ((dot&4) == 0)
547
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
548
+
549
+ // if (wrap || !locked && (dot&8) != 0)
550
+ if (obj.flipV)
551
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
552
+ else
553
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
554
+ // else
555
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
556
+
557
+ // f.dot = dot;
558
+
559
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
560
+ SetColor(obj, rv);
561
+ //gl.glColor4f(r, g, b, 1);
562
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
563
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
564
+ gl.glVertex3f(x, y, z);
565
+// Print(rv);
566
+ //gl.glEnd();
567
+ }
568
+ else
569
+ {
570
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
571
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
572
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
573
+
574
+ }
575
+
576
+ if (false) // (attributes & WIREFRAME) != 0)
577
+ {
578
+ gl.glDisable(gl.GL_LIGHTING);
579
+
580
+ gl.glBegin(gl.GL_LINE_LOOP);
581
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
582
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
583
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
584
+ gl.glEnd();
585
+
586
+ gl.glEnable(gl.GL_LIGHTING);
587
+ }
588
+ }
589
+
590
+ /**
591
+ * <code>draw</code> renders a <code>TriMesh</code> object including
592
+ * it's normals, colors, textures and vertices.
593
+ *
594
+ * @see Renderer#draw(TriMesh)
595
+ * @param tris
596
+ * the mesh to render.
597
+ */
598
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
599
+ {
600
+ CameraPane display = this;
601
+
602
+ float r = display.modelParams0[0];
603
+ float g = display.modelParams0[1];
604
+ float b = display.modelParams0[2];
605
+ float opacity = display.modelParams5[1];
606
+
607
+ //final GL gl = GLU.getCurrentGL();
608
+ GL gl = display.GetGL(); // getGL();
609
+
610
+ FloatBuffer vertBuf = geo.vertBuf;
611
+
612
+ int v = vertBuf.capacity();
613
+
614
+ int count = 0;
615
+
616
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
617
+ gl.glEnable(gl.GL_CULL_FACE);
618
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
619
+ for (int i=0; i<v/3; i++)
620
+ {
621
+ int index3 = i*3;
622
+
623
+ if (geo.sizeBuf.get(index3+1) == 0)
624
+ continue;
625
+
626
+ count++;
627
+
628
+ int index4 = i*4;
629
+
630
+ float tx = vertBuf.get(index3);
631
+ float ty = vertBuf.get(index3+1);
632
+ float tz = vertBuf.get(index3+2);
633
+
634
+ // if (tx == 0 && ty == 0 && tz == 0)
635
+ // continue;
636
+
637
+ gl.glMatrixMode(gl.GL_TEXTURE);
638
+ gl.glPushMatrix();
639
+
640
+ float[] texmat = geo.texmat;
641
+ texmat[12] = texmat[13] = texmat[14] = i;
642
+
643
+ gl.glMultMatrixf(texmat, 0);
644
+
645
+ gl.glMatrixMode(gl.GL_MODELVIEW);
646
+ gl.glPushMatrix();
647
+
648
+ gl.glTranslatef(tx,ty,tz);
649
+
650
+ if (rotate)
651
+ gl.glRotatef(i, 0, 1, 0);
652
+
653
+ float size = geo.sizeBuf.get(index3) / 100;
654
+ gl.glScalef(size,size,size);
655
+
656
+ float cr = geo.colorBuf.get(index4);
657
+ float cg = geo.colorBuf.get(index4+1);
658
+ float cb = geo.colorBuf.get(index4+2);
659
+ float ca = geo.colorBuf.get(index4+3);
660
+
661
+ display.modelParams0[0] = r * cr;
662
+ display.modelParams0[1] = g * cg;
663
+ display.modelParams0[2] = b * cb;
664
+
665
+ display.modelParams5[1] = opacity * ca;
666
+
667
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
668
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
669
+
670
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
671
+ RandomNode.globalseed2 = RandomNode.globalseed;
672
+
673
+// gl.glColor4f(cr,cg,cb,ca);
674
+ // gl.glScalef(1024/16,1024/16,1024/16);
675
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
676
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
677
+ //gl.glTranslatef(-tx,-ty,-tz);
678
+ gl.glPopMatrix();
679
+
680
+ gl.glMatrixMode(gl.GL_TEXTURE);
681
+ gl.glPopMatrix();
682
+ }
683
+ // gl.glScalef(1024,1024,1024);
684
+ if (!cf)
685
+ gl.glDisable(gl.GL_CULL_FACE);
686
+
687
+ display.modelParams0[0] = r;
688
+ display.modelParams0[1] = g;
689
+ display.modelParams0[2] = b;
690
+
691
+ display.modelParams5[1] = opacity;
692
+
693
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
694
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
695
+
696
+ gl.glMatrixMode(gl.GL_MODELVIEW);
697
+
698
+// System.err.println("total = " + v/3 + "; displayed = " + count);
699
+ if (true)
700
+ return;
701
+
702
+//// if (!tris.predraw(this))
703
+//// {
704
+//// return;
705
+//// }
706
+//// if (Debug.stats)
707
+//// {
708
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
709
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
710
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
711
+//// }
712
+////
713
+//// if (tris.getDisplayListID() != -1)
714
+//// {
715
+//// renderDisplayList(tris);
716
+//// return;
717
+//// }
718
+////
719
+//// if (!generatingDisplayList)
720
+//// {
721
+//// applyStates(tris.states, tris);
722
+//// }
723
+//// if (Debug.stats)
724
+//// {
725
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
726
+//// }
727
+//// boolean transformed = doTransforms(tris);
728
+//
729
+// int glMode = GL.GL_TRIANGLES;
730
+// switch (getMode())
731
+// {
732
+// case Triangles:
733
+// glMode = GL.GL_TRIANGLES;
734
+// break;
735
+// case Strip:
736
+// glMode = GL.GL_TRIANGLE_STRIP;
737
+// break;
738
+// case Fan:
739
+// glMode = GL.GL_TRIANGLE_FAN;
740
+// break;
741
+// }
742
+//
743
+// if (!predrawGeometry(gl))
744
+// {
745
+// // make sure only the necessary indices are sent through on old
746
+// // cards.
747
+// IntBuffer indices = this.getIndexBuffer();
748
+// if (indices == null)
749
+// {
750
+// logger.severe("missing indices on geometry object: " + this.toString());
751
+// } else
752
+// {
753
+// indices.rewind();
754
+// indices.limit(this.getMaxIndex());
755
+//
756
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
757
+//
758
+// indices.clear();
759
+// }
760
+// } else
761
+// {
762
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
763
+// GL.GL_UNSIGNED_INT, 0);
764
+// }
765
+//
766
+//// postdrawGeometry(tris);
767
+//// if (transformed)
768
+//// {
769
+//// undoTransforms(tris);
770
+//// }
771
+////
772
+//// if (Debug.stats)
773
+//// {
774
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
775
+//// }
776
+//// tris.postdraw(this);
777
+ }
778
+
779
+ static Camera localcamera = new Camera();
780
+ static cVector from = new cVector();
781
+ static cVector to = new cVector();
782
+
783
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
784
+ {
785
+ CameraPane cp = this;
786
+
787
+ Camera keep = cp.RenderCamera();
788
+ cp.renderCamera = localcamera;
789
+
790
+ if (br.trimmed)
791
+ {
792
+ float[] colors = new float[br.positions.length / 3];
793
+
794
+ int i3 = 0;
795
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
796
+ {
797
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
798
+ continue;
799
+
800
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
801
+ to.set(br.positions[i3] + br.normals[i3],
802
+ br.positions[i3 + 1] + br.normals[i3 + 1],
803
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
804
+ LA.xformPos(from, transform, from);
805
+ LA.xformPos(to, transform, to); // RIGID ONLY
806
+ localcamera.setAim(from, to);
807
+
808
+ CameraPane.occlusionbuffer.display();
809
+
810
+ if (CameraPane.DEBUG_OCCLUSION)
811
+ cp.display(); // debug
812
+
813
+ colors[i] = cp.vertexOcclusion.r;
814
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
815
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
816
+
817
+ if ((i % 100) == 0 && i != 0)
818
+ {
819
+ CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
820
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
821
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
822
+ }
823
+ }
824
+
825
+ br.colors = colors;
826
+ }
827
+ else
828
+ {
829
+ for (int i = 0; i < br.VertexCount(); i++)
830
+ {
831
+ Vertex v = br.GetVertex(i);
832
+
833
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
834
+ continue;
835
+
836
+ from.set(v.x, v.y, v.z);
837
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
838
+ LA.xformPos(from, transform, from);
839
+ LA.xformPos(to, transform, to); // RIGID ONLY
840
+ localcamera.setAim(from, to);
841
+
842
+ CameraPane.occlusionbuffer.display();
843
+
844
+ if (CameraPane.DEBUG_OCCLUSION)
845
+ cp.display(); // debug
846
+
847
+ v.AO = cp.vertexOcclusion.r;
848
+
849
+ if ((i % 100) == 0 && i != 0)
850
+ {
851
+ CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
852
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
853
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
854
+ }
855
+ }
856
+ }
857
+
858
+ //System.out.println("done.");
859
+
860
+ cp.renderCamera = keep;
861
+ }
862
+
863
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
864
+ {
865
+ CameraPane display = this;
866
+ pointFlow.CreateHT();
867
+
868
+ float r = display.modelParams0[0];
869
+ float g = display.modelParams0[1];
870
+ float b = display.modelParams0[2];
871
+ float opacity = display.modelParams5[1];
872
+
873
+ //final GL gl = GLU.getCurrentGL();
874
+ GL gl = display.GetGL(); // getGL();
875
+
876
+ int s = pointFlow.points.size();
877
+
878
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
879
+ gl.glEnable(gl.GL_CULL_FACE);
880
+
881
+ for (int i=s; --i>=0;)
882
+ //for (int i=0; i<s; i++)
883
+ {
884
+ cVector v = pointFlow.points.get(i);
885
+
886
+ double mindist = Double.MAX_VALUE;
887
+
888
+ double size = pointFlow.minimumSize;
889
+
890
+ double distancenext = 0;
891
+
892
+ if (i > 0)
893
+ {
894
+ cVector w = pointFlow.points.get(i-1);
895
+
896
+ double dist = w.distance(v);
897
+
898
+ distancenext = dist;
899
+
900
+ if (mindist > dist)
901
+ {
902
+ mindist = dist;
903
+ size = mindist*pointFlow.resizefactor;
904
+ }
905
+ }
906
+
907
+ if (i < s-1)
908
+ {
909
+ cVector w = pointFlow.points.get(i+1);
910
+
911
+ double dist = w.distance(v);
912
+
913
+ if (mindist > dist)
914
+ {
915
+ mindist = dist;
916
+ size = mindist*pointFlow.resizefactor;
917
+ }
918
+ }
919
+
920
+ if (size < pointFlow.minimumSize)
921
+ size = pointFlow.minimumSize;
922
+ if (size > pointFlow.maximumSize)
923
+ size = pointFlow.maximumSize;
924
+
925
+ double tx = v.x;
926
+ double ty = v.y;
927
+ double tz = v.z;
928
+
929
+ // if (tx == 0 && ty == 0 && tz == 0)
930
+ // continue;
931
+
932
+ gl.glMatrixMode(gl.GL_TEXTURE);
933
+ gl.glPushMatrix();
934
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
935
+
936
+ gl.glMultMatrixf(pointFlow.texmat, 0);
937
+
938
+ gl.glMatrixMode(gl.GL_MODELVIEW);
939
+ gl.glPushMatrix();
940
+
941
+ gl.glTranslated(tx,ty,tz);
942
+
943
+ gl.glScaled(size,size,size);
944
+
945
+// float cr = colorBuf.get(index4);
946
+// float cg = colorBuf.get(index4+1);
947
+// float cb = colorBuf.get(index4+2);
948
+// float ca = colorBuf.get(index4+3);
949
+//
950
+// display.modelParams0[0] = r * cr;
951
+// display.modelParams0[1] = g * cg;
952
+// display.modelParams0[2] = b * cb;
953
+//
954
+// display.modelParams5[1] = opacity * ca;
955
+//
956
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
957
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
958
+//
959
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
960
+// RandomNode.globalseed2 = RandomNode.globalseed;
961
+//
962
+//// gl.glColor4f(cr,cg,cb,ca);
963
+// // gl.glScalef(1024/16,1024/16,1024/16);
964
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
965
+
966
+ gl.glPopMatrix();
967
+
968
+ double step = size/4; //
969
+
970
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
971
+ continue;
972
+
973
+ int nbsteps = (int)(distancenext/step);
974
+
975
+ step = distancenext/nbsteps;
976
+
977
+ cVector next = pointFlow.points.get(i-1);
978
+
979
+ tmp.set(next);
980
+ tmp.sub(v);
981
+ tmp.normalize();
982
+ tmp.mul(step);
983
+
984
+ // calculate next size
985
+ mindist = Double.MAX_VALUE;
986
+
987
+ double nextsize = pointFlow.minimumSize;
988
+
989
+ if (i > 1)
990
+ {
991
+ cVector w = pointFlow.points.get(i-2);
992
+
993
+ double dist = w.distance(next);
994
+
995
+ if (mindist > dist)
996
+ {
997
+ mindist = dist;
998
+ nextsize = mindist*pointFlow.resizefactor;
999
+ }
1000
+ }
1001
+
1002
+ double dist = v.distance(next);
1003
+
1004
+ if (mindist > dist)
1005
+ {
1006
+ mindist = dist;
1007
+ nextsize = mindist*pointFlow.resizefactor;
1008
+ }
1009
+
1010
+ if (nextsize < pointFlow.minimumSize)
1011
+ nextsize = pointFlow.minimumSize;
1012
+ if (nextsize > pointFlow.maximumSize)
1013
+ nextsize = pointFlow.maximumSize;
1014
+ //
1015
+
1016
+ double count = 0;
1017
+
1018
+ while (distancenext > 0.000000001) // step
1019
+ {
1020
+ gl.glPushMatrix();
1021
+
1022
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1023
+
1024
+ double K = count/nbsteps;
1025
+
1026
+ double intersize = K*nextsize + (1-K)*size;
1027
+
1028
+ gl.glScaled(intersize,intersize,intersize);
1029
+
1030
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1031
+
1032
+ count++;
1033
+
1034
+ distancenext -= step;
1035
+
1036
+ gl.glPopMatrix();
1037
+ }
1038
+
1039
+ if (count != nbsteps)
1040
+ assert(count == nbsteps);
1041
+
1042
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1043
+ //gl.glTranslatef(-tx,-ty,-tz);
1044
+
1045
+ gl.glMatrixMode(gl.GL_TEXTURE);
1046
+ gl.glPopMatrix();
1047
+ }
1048
+
1049
+ if (!cf)
1050
+ gl.glDisable(gl.GL_CULL_FACE);
1051
+
1052
+// display.modelParams0[0] = r;
1053
+// display.modelParams0[1] = g;
1054
+// display.modelParams0[2] = b;
1055
+//
1056
+// display.modelParams5[1] = opacity;
1057
+//
1058
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1059
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1060
+
1061
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1062
+ }
1063
+
1064
+ /// INTERFACE
1065
+
1066
+ void SetColor(Object3D obj, Vertex p0)
1067
+ {
1068
+ CameraPane display = this;
1069
+ BoundaryRep bRep = obj.bRep;
1070
+
1071
+ if (RENDERPROGRAM == 0)
1072
+ {
1073
+ float r = 0;
1074
+ if (bRep != null)
1075
+ {
1076
+ if (bRep.stripified)
1077
+ {
1078
+ r = 1;
1079
+ }
1080
+ }
1081
+ float g = 0;
1082
+ if (bRep != null)
1083
+ {
1084
+ if (bRep.trimmed)
1085
+ {
1086
+ g = 1;
1087
+ }
1088
+ }
1089
+ float b = 0;
1090
+ if (obj.support != null && obj.link2master)
1091
+ {
1092
+ b = 1;
1093
+ }
1094
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1095
+ return;
1096
+ }
1097
+
1098
+ if (display.DrawMode() != CameraPane.SHADOW)
1099
+ return;
1100
+
1101
+ javax.media.opengl.GL gl = display.GetGL();
1102
+// if (true) return;
1103
+// float ao = p.AO;
1104
+//
1105
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1106
+// // ao = 1;
1107
+//
1108
+// gl.glColor4f(ao, ao, ao, 1);
1109
+
1110
+// CameraPane.selectedpoint.
1111
+// getAverage(cStatic.point1, true);
1112
+ if (CameraPane.pointflow == null) // !random) // live)
1113
+ {
1114
+ return;
1115
+ }
1116
+
1117
+ cStatic.point1.set(0,0,0);
1118
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1119
+
1120
+ cStatic.point1.sub(p0);
1121
+
1122
+
1123
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1124
+// {
1125
+// return;
1126
+// }
1127
+
1128
+ //if (true)
1129
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1130
+ {
1131
+ return;
1132
+ }
1133
+
1134
+ float[] colorV = new float[3];
1135
+
1136
+ if (false) // marked)
1137
+ {
1138
+ // debug rigging weights
1139
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1140
+ {
1141
+ float weight = p0.weights[object] / p0.totalweight;
1142
+
1143
+ // if (weight < 0.1)
1144
+ // {
1145
+ // assert(weight == 0);
1146
+ // continue;
1147
+ // }
1148
+
1149
+ if (p0.vertexlinks[object] == -1)
1150
+ continue;
1151
+
1152
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1153
+
1154
+ int color = //1 << object; //
1155
+ //p.vertexlinks.length;
1156
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1157
+ colorV[2] += (color & 1) * weight;
1158
+ colorV[1] += ((color & 2) >> 1) * weight;
1159
+ colorV[0] += ((color & 4) >> 2) * weight;
1160
+ }
1161
+ }
1162
+ else
1163
+ {
1164
+ if (obj.drawingstarted)
1165
+ {
1166
+ // find next point
1167
+ if (bRep.GetVertex(0).faceindices == null)
1168
+ {
1169
+ bRep.InitFaceIndices();
1170
+ }
1171
+
1172
+ double ymin = p0.y;
1173
+
1174
+ Vertex newp = p0;
1175
+
1176
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1177
+ {
1178
+ int fi = p0.faceindices[fii];
1179
+
1180
+ if (fi == -1)
1181
+ break;
1182
+
1183
+ Face f = bRep.GetFace(fi);
1184
+
1185
+ Vertex p = bRep.GetVertex(f.p);
1186
+ Vertex q = bRep.GetVertex(f.q);
1187
+ Vertex r = bRep.GetVertex(f.r);
1188
+
1189
+ int swap = (int)(Math.random()*3);
1190
+
1191
+// for (int s=swap; --s>=0;)
1192
+// {
1193
+// Vertex t = p;
1194
+// p = q;
1195
+// q = r;
1196
+// r = t;
1197
+// }
1198
+ if (ymin > p.y)
1199
+ {
1200
+ ymin = p.y;
1201
+ newp = p;
1202
+// break;
1203
+ }
1204
+ if (ymin > q.y)
1205
+ {
1206
+ ymin = q.y;
1207
+ newp = q;
1208
+// break;
1209
+ }
1210
+ if (ymin > r.y)
1211
+ {
1212
+ ymin = r.y;
1213
+ newp = r;
1214
+// break;
1215
+ }
1216
+ }
1217
+
1218
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1219
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1220
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1221
+
1222
+ obj.drawingstarted = false;
1223
+
1224
+ // return;
1225
+ }
1226
+
1227
+ if (false) // CameraPane.DRAW
1228
+ {
1229
+ p0.AO = colorV[0] = 2;
1230
+ colorV[1] = 2;
1231
+ colorV[2] = 2;
1232
+ }
1233
+
1234
+ CameraPane.pointflow.add(p0);
1235
+ CameraPane.pointflow.Touch();
1236
+ }
1237
+
1238
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1239
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1240
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1241
+ }
1242
+
1243
+ void DrawMaterial(cMaterial material, boolean selected)
1244
+ {
1245
+ CameraPane display = this;
1246
+ //new Exception().printStackTrace();
1247
+
1248
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1249
+ {
1250
+ return;
1251
+ }
1252
+
1253
+ javax.media.opengl.GL gl = display.GetGL();
1254
+
1255
+ //Color col = Color.getHSBColor(color,modulation,1);
1256
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1257
+ if (!material.multiply)
1258
+ {
1259
+ display.color = color;
1260
+ display.saturation = material.modulation;
1261
+ }
1262
+ else
1263
+ {
1264
+ display.color *= color*2;
1265
+ display.saturation *= material.modulation*2;
1266
+ }
1267
+
1268
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1269
+
1270
+ float[] colorV = GrafreeD.colorV;
1271
+
1272
+ /**/
1273
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1274
+ {
1275
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1276
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1277
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1278
+ colorV[3] = material.opacity;
1279
+
1280
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1281
+ //System.out.println("Opacity = " + opacity);
1282
+
1283
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1284
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1285
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1286
+
1287
+ float amb = material.ambient;
1288
+ if (amb < material.cameralight)
1289
+ {
1290
+ amb = material.cameralight;
1291
+ }
1292
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1293
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1294
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1295
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1296
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1297
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1298
+
1299
+ /**/
1300
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1301
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1302
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1303
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1304
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1305
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1306
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1307
+ //System.out.println("shininess = " + colorV[0]);
1308
+ if (colorV[0] > 128)
1309
+ {
1310
+ colorV[0] = 128;
1311
+ }
1312
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1313
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1314
+ /**/
1315
+ }
1316
+ /**/
1317
+
1318
+ //selected = false;
1319
+ selected = selected && display.flash;
1320
+
1321
+ //display.modelParams0[0] = 0; // pigment.r;
1322
+ //display.modelParams0[1] = 0; // pigment.g;
1323
+ //display.modelParams0[2] = 0; // pigment.b;
1324
+ if (!material.multiply)
1325
+ {
1326
+ display.modelParams0[3] = material.metalness;
1327
+ display.modelParams1[0] = material.diffuse;
1328
+ display.modelParams1[1] = material.specular;
1329
+ display.modelParams1[2] = 1 / material.shininess;
1330
+ display.modelParams1[3] = material.shift;
1331
+ display.modelParams2[0] = material.ambient;
1332
+ display.modelParams2[1] = material.lightarea;
1333
+ //System.out.println("light area = " + lightarea);
1334
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1335
+ display.modelParams2[3] = material.velvet;
1336
+ display.modelParams3[0] = material.sheen;
1337
+ display.modelParams3[1] = material.subsurface;
1338
+ display.modelParams3[2] = material.bump; // backlit
1339
+ display.modelParams3[3] = material.aniso;
1340
+ display.modelParams4[0] = material.anisoV;
1341
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1342
+ //System.out.println("selected = " + selected);
1343
+ display.modelParams4[2] = material.diffuseness;
1344
+ display.modelParams4[3] = material.shadow;
1345
+ display.modelParams5[0] = material.texture;
1346
+ display.modelParams5[1] = material.opacity;
1347
+ display.modelParams5[2] = material.fakedepth;
1348
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1349
+ }
1350
+ else
1351
+ {
1352
+ display.modelParams0[3] *= material.metalness*2;
1353
+ display.modelParams1[0] *= material.diffuse*2;
1354
+ display.modelParams1[1] *= material.specular*2;
1355
+ display.modelParams1[2] *= material.shininess*2;
1356
+ display.modelParams1[3] *= material.shift*2;
1357
+ display.modelParams2[0] *= material.ambient*2;
1358
+ display.modelParams2[1] *= material.lightarea*2;
1359
+ display.modelParams2[2] *= material.factor*2;
1360
+ display.modelParams2[3] *= material.velvet*2;
1361
+ display.modelParams3[0] *= material.sheen*2;
1362
+ display.modelParams3[1] *= material.subsurface*2;
1363
+ display.modelParams3[2] *= material.bump*2;
1364
+ display.modelParams3[3] *= material.aniso*2;
1365
+ display.modelParams4[0] *= material.anisoV*2;
1366
+ display.modelParams4[1] *= material.cameralight*2;
1367
+ //System.out.println("selected = " + selected);
1368
+ display.modelParams4[2] *= material.diffuseness*2;
1369
+ display.modelParams4[3] *= material.shadow*2;
1370
+ display.modelParams5[0] *= material.texture*2;
1371
+ display.modelParams5[1] *= material.opacity*2;
1372
+ display.modelParams5[2] *= material.fakedepth*2;
1373
+ display.modelParams5[3] *= material.shadowbias*2;
1374
+ }
1375
+
1376
+ display.modelParams6[0] = 0;
1377
+ display.modelParams6[1] = 0;
1378
+ display.modelParams6[2] = 0;
1379
+ display.modelParams6[3] = 0;
1380
+
1381
+ display.modelParams7[0] = 0;
1382
+ display.modelParams7[1] = 1000;
1383
+ display.modelParams7[2] = 0;
1384
+ display.modelParams7[3] = 0;
1385
+
1386
+ display.modelParams6[0] = 100; // criss de bug de bump
1387
+
1388
+ Object3D.cVector2[] extparams = display.vector2buffer;
1389
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1390
+ {
1391
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1392
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1393
+ if (extparams.length > 1)
1394
+ {
1395
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1396
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1397
+ if (extparams.length > 2)
1398
+ {
1399
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1400
+ float x = extparams[2].y / 1000.0f;
1401
+ //if (x == 0)
1402
+ // x = 1f;
1403
+ display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power
1404
+ if (extparams[2].y > 0)
1405
+ {
1406
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1407
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1408
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1409
+ }
1410
+ }
1411
+ }
1412
+ }
1413
+
1414
+ //if (display.modelParams6[2] != 0)
1415
+ /*
1416
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1417
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1418
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1419
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1420
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1421
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1422
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1423
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1424
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1425
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1426
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1427
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1428
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1429
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1430
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1431
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1432
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1433
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1434
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1435
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1436
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1437
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1438
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1439
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1440
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1441
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1442
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1443
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1444
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1445
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1446
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1447
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1448
+ /**/
1449
+ //assert (display.modelParams6[2] == 0);
1450
+
1451
+ //System.out.println("noise power = " + display.modelParams7[0]);
1452
+ //System.out.println("shadowbias = " + shadowbias);
1453
+
1454
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1455
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1456
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1457
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1458
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1459
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1460
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1461
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1462
+
1463
+ int mode = display.FP_SHADER;
1464
+
1465
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1466
+ {
1467
+ mode |= display.FP_ANISO;
1468
+ }
1469
+
1470
+ display.EnableProgram(mode);
1471
+
1472
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1473
+
1474
+ if (!material.multiply)
1475
+ {
1476
+ if (Globals.drawMode == CameraPane.SHADOW)
1477
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1478
+ else
1479
+ gl.glDepthMask(material.opacity >= 0.99);
1480
+ }
2081481 }
2091482
2101483 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1498,7 @@
2251498 currentGL.glMultMatrixd(model, 0);
2261499 }
2271500
228
- void PushMatrix(double[][] matrix, int count)
1501
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291502 {
2301503 matrixdepth++;
2311504 // GrafreeD.tracein(matrix);
....@@ -270,7 +1543,7 @@
2701543
2711544 double[][] tmpmat = new double[4][4];
2721545
273
- void PopMatrix(double[][] inverse)
1546
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741547 {
2751548 --matrixdepth;
2761549
....@@ -310,7 +1583,7 @@
3101583 PushTextureMatrix(matrix, 1);
3111584 }
3121585
313
- void PushTextureMatrix(double[][] matrix, int count)
1586
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141587 {
3151588 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161589
....@@ -324,7 +1597,7 @@
3241597 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251598 }
3261599
327
- void PopTextureMatrix(double[][] inverse)
1600
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281601 {
3291602 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301603 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -356,10 +1629,10 @@
3561629 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571630 // return false;
3581631
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1632
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601633 {
3611634 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1635
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631636 {
3641637 // refuse the camera change
3651638 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +1640,7 @@
3671640 }
3681641 }
3691642
370
- camerachangeframe = framecount;
1643
+ camerachangeframe = Globals.framecount;
3711644
3721645 cam.hAspect = -1; // Read only
3731646
....@@ -398,7 +1671,7 @@
3981671 {
3991672 //System.err.println("Oeil on");
4001673 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1674
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4021675 // object.editWindow.ScreenFit(trackedobject);
4031676 //pingthread.StepToTarget(true);
4041677 }
....@@ -407,7 +1680,7 @@
4071680 {
4081681 //System.err.println("Oeil on");
4091682 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1683
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4111684 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4121685 //pingthread.StepToTarget(true);
4131686 }
....@@ -471,7 +1744,7 @@
4711744 {
4721745 frozen ^= true;
4731746 // Weird...
474
- lighttouched = true;
1747
+ Globals.lighttouched = true;
4751748 }
4761749
4771750 void ToggleDL()
....@@ -486,11 +1759,11 @@
4861759
4871760 void ToggleLive()
4881761 {
489
- setLIVE(isLIVE() ^ true);
1762
+ Globals.setLIVE(Globals.isLIVE() ^ true);
4901763
491
- System.err.println("LIVE = " + isLIVE());
1764
+ System.err.println("LIVE = " + Globals.isLIVE());
4921765
493
- if (!isLIVE()) // save sound
1766
+ if (!Globals.isLIVE()) // save sound
4941767 GrafreeD.savesound = true; // wav.save();
4951768 // else
4961769 repaint(); // start loop // may 2013
....@@ -513,7 +1786,7 @@
5131786
5141787 void ToggleCrowd()
5151788 {
516
- CROWD ^= true;
1789
+ Globals.CROWD ^= true;
5171790 }
5181791
5191792 void ToggleInertia()
....@@ -674,34 +1947,6 @@
6741947 lightCamera = cam;
6751948 }
6761949
677
- CameraPane(Object3D o, Camera cam, boolean withcontext)
678
- {
679
- super(defaultcaps, null, withcontext?glcontext:null, null);
680
-
681
- //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
682
- glcontext = getContext();
683
-
684
- cameras = new Camera[2];
685
- targetLookAts = new cVector[2];
686
-
687
- SetCamera(cam);
688
-
689
- SetLight(new Camera(new cVector(10, 10, -20)));
690
-
691
- object = o;
692
-
693
- setBackground(Color.white);
694
-
695
- addKeyListener(this);
696
- addMouseListener(this);
697
- addMouseMotionListener(this);
698
- addMouseWheelListener(this);
699
- //System.out.println("addGLEventListener: " + this);
700
- addGLEventListener(this);
701
-
702
-// pingthread.start(); // may 2013
703
- }
704
-
7051950 private static void ApplyTransform(GL gl, Mat4f xform)
7061951 {
7071952 float[] data = new float[16];
....@@ -759,7 +2004,7 @@
7592004
7602005 GL currentGL;
7612006
762
- GL GetGL()
2007
+ public GL GetGL() // INTERFACE
7632008 {
7642009 return currentGL;
7652010 }
....@@ -6271,7 +7516,7 @@
62717516 return null;
62727517 }
62737518
6274
- void ReleaseTextures(cTexture tex)
7519
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757520 {
62767521 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777522 {
....@@ -6309,7 +7554,7 @@
63097554
63107555 void ReleaseTexture(String tex, boolean bump)
63117556 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
7557
+ if (// DrawMode() != 0 || /*tex == null ||*/
63137558 ambientOcclusion ) // || !textureon)
63147559 {
63157560 return;
....@@ -6410,9 +7655,9 @@
64107655 }
64117656 }
64127657
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7658
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64147659 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
7660
+ if (// DrawMode() != 0 || /*tex == null ||*/
64167661 ambientOcclusion ) // || !textureon)
64177662 {
64187663 return; // false;
....@@ -7312,9 +8557,9 @@
73128557 static boolean occlusionInitialized = false;
73138558 boolean selection = false;
73148559 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
8560
+ ///*static*/ boolean lighttouched = true;
73168561 boolean deselect;
7317
- boolean ambientOcclusion = false;
8562
+ private boolean ambientOcclusion = false;
73188563 static boolean flash = false;
73198564 /*static*/ boolean wait = false;
73208565 boolean displaydone = false; // after repaint() calls
....@@ -7444,6 +8689,8 @@
74448689 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74458690 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74468691 double scale = lightCamera.SCALE / lightCamera.Distance();
8692
+// PATCH FILLE AUX JEANS
8693
+ //scale *= lightCamera.shaper_fovy / 25;
74478694 gl.glScaled(2 * scale, 2 * scale, -scale);
74488695 gl.glTranslated(0, 0, lightCamera.DECAL);
74498696
....@@ -7601,8 +8848,6 @@
76018848
76028849 boolean restartframe = false;
76038850
7604
- static int framecount = 0; // general-purpose global count
7605
-
76068851 void displayAntiAliased(javax.media.opengl.GL gl)
76078852 {
76088853 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7633,7 +8878,7 @@
76338878 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76348879 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76358880 {
7636
- framecount++;
8881
+ Globals.framecount++;
76378882
76388883 if (CameraPane.tickcount > 0)
76398884 CameraPane.tickcount--;
....@@ -7671,7 +8916,7 @@
76718916
76728917 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76738918 */
7674
- lighttouched = true;
8919
+ Globals.lighttouched = true;
76758920 //System.err.println(" shadowbuffer: " + jitter);
76768921 shadowbuffer.display();
76778922
....@@ -7693,7 +8938,7 @@
76938938
76948939 if (renderCamera != lightCamera)
76958940 for (int count = parentcam.GetTransformCount(); --count>=0;)
7696
- LA.matConcat(parentcam.toParent, matrix, matrix);
8941
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76978942
76988943 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76998944
....@@ -7709,7 +8954,7 @@
77098954
77108955 if (renderCamera != lightCamera)
77118956 for (int count = parentcam.GetTransformCount(); --count>=0;)
7712
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8957
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77138958
77148959 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77158960
....@@ -8618,13 +9863,6 @@
86189863 }
86199864 }
86209865
8621
- boolean IsFrozen()
8622
- {
8623
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8624
-
8625
- return !selectmode && cameracount == 0; // != 0;
8626
- }
8627
-
86289866 boolean niceon = false;
86299867 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86309868 boolean currentlydrawing = false;
....@@ -8642,8 +9880,8 @@
86429880 }
86439881 // if (DEBUG_SELECTION)
86449882 // {
8645
-// if (drawMode != SELECTION)
8646
-// drawMode = SELECTION;
9883
+// if (DrawMode() != SELECTION)
9884
+// DrawMode() = SELECTION;
86479885 // }
86489886
86499887 if (!isRenderer)
....@@ -8699,9 +9937,9 @@
86999937
87009938 //ANTIALIAS = 0;
87019939
8702
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9940
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
87039941 {
8704
- if (niceon || isLIVE())
9942
+ if (niceon || Globals.isLIVE())
87059943 {
87069944 //if(active == 0)
87079945 // antialiaser = null;
....@@ -8726,7 +9964,7 @@
87269964 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87279965 */
87289966
8729
- if (drawMode == DEFAULT)
9967
+ if (DrawMode() == DEFAULT)
87309968 {
87319969 currentlydrawing = true;
87329970 }
....@@ -8757,12 +9995,12 @@
87579995
87589996 // if(Applet3D.clipboard != null)
87599997 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8760
-//drawMode = SELECTION;
9998
+//DrawMode() = SELECTION;
87619999 indexcount = 0;
876210000
8763
- if (drawMode == OCCLUSION)
10001
+ if (DrawMode() == OCCLUSION)
876410002 {
8765
- drawMode = DEFAULT;
10003
+ Globals.drawMode = DEFAULT; // WARNING
876610004 ambientOcclusion = true;
876710005 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876810006 Object3D theobject = object;
....@@ -8781,19 +10019,19 @@
878110019 ambientOcclusion = false;
878210020 }
878310021
8784
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10022
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
878510023 {
878610024 //if (RENDERSHADOW) // ?
878710025 if (!IsFrozen())
878810026 {
878910027 // dec 2012
8790
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10028
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
879110029 {
8792
- framecount++;
10030
+ Globals.framecount++;
879310031 shadowbuffer.display();
879410032 }
879510033 }
8796
- lighttouched = false; // ??
10034
+ Globals.lighttouched = false; // ??
879710035 //drawing = true;
879810036 //lighttouched = true;
879910037 }
....@@ -8814,9 +10052,9 @@
881410052 //eyeCamera.shaper_fovy = 1;
881510053 }
881610054
8817
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10055
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881810056 {
8819
- //System.out.println("drawMode = " + drawMode);
10057
+ //System.out.println("DrawMode() = " + DrawMode());
882010058 vertexMode |= VP_PASS;
882110059 //vertexMode |= VP_PROJECTION;
882210060 if (!ambientOcclusion)
....@@ -8876,7 +10114,7 @@
887610114 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887710115 //Camera lightcam = new Camera(light0);
887810116
8879
- if (drawMode == SHADOW)
10117
+ if (DrawMode() == SHADOW)
888010118 {
888110119 /*
888210120 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8915,7 +10153,7 @@
891510153 // if (parentcam != renderCamera) // not a light
891610154 if (cam != lightCamera)
891710155 for (int count = parentcam.GetTransformCount(); --count>=0;)
8918
- LA.matConcat(parentcam.toParent, matrix, matrix);
10156
+ LA.matConcat(matrix, parentcam.toParent, matrix);
891910157
892010158 for (int j = 0; j < 4; j++)
892110159 {
....@@ -8930,7 +10168,7 @@
893010168 // if (parentcam != renderCamera) // not a light
893110169 if (cam != lightCamera)
893210170 for (int count = parentcam.GetTransformCount(); --count>=0;)
8933
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10171
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
893410172
893510173 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893610174
....@@ -8966,7 +10204,7 @@
896610204 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896710205 } else
896810206 {
8969
- if (drawMode != DEFAULT)
10207
+ if (DrawMode() != DEFAULT)
897010208 {
897110209 gl.glClearColor(1, 1, 1, 0);
897210210 } // 1);
....@@ -9031,7 +10269,7 @@
903110269
903210270 fast &= !ambientOcclusion;
903310271
9034
- if (drawMode == DEFAULT)
10272
+ if (DrawMode() == DEFAULT)
903510273 {
903610274 //gl.glEnable(gl.GL_ALPHA_TEST);
903710275 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9092,6 +10330,8 @@
909210330 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909310331 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909410332 double scale = lightCamera.SCALE / lightCamera.Distance();
10333
+// PATCH FILLE AUX JEANS
10334
+ //scale *= lightCamera.shaper_fovy / 25;
909510335 gl.glScaled(2 * scale, 2 * scale, -scale);
909610336 gl.glTranslated(0, 0, lightCamera.DECAL);
909710337
....@@ -9227,10 +10467,12 @@
922710467 gl.glMatrixMode(gl.GL_PROJECTION);
922810468 gl.glLoadIdentity();
922910469
9230
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10470
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
923110471 {
923210472 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923310473 double scale = lightCamera.SCALE / lightCamera.Distance();
10474
+// PATCH FILLE AUX JEANS
10475
+ //scale *= lightCamera.shaper_fovy / 25;
923410476 gl.glScaled(2 * scale, 2 * scale, -scale);
923510477 gl.glTranslated(0, 0, lightCamera.DECAL);
923610478 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9283,7 +10525,7 @@
928310525 //gl.glPushMatrix();
928410526 gl.glLoadIdentity();
928510527
9286
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10528
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928710529 {
928810530 //LA.xformPos(light0, lightCamera.fromScreen, light);
928910531 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9370,7 +10612,7 @@
937010612 }
937110613
937210614 /**/
9373
- if (true) // drawMode == SELECTION) // != DEFAULT)
10615
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937410616 gl.glDisable(gl.GL_LIGHTING);
937510617 else
937610618 gl.glEnable(gl.GL_LIGHTING);
....@@ -9388,7 +10630,7 @@
938810630
938910631 lightslot = 64;
939010632
9391
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10633
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939210634 {
939310635 DrawLights(object);
939410636 }
....@@ -9399,7 +10641,7 @@
939910641 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940010642 //System.out.println("fragmentMode = " + fragmentMode);
940110643
9402
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10644
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
940310645 {
940410646 /*
940510647 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9432,7 +10674,7 @@
943210674 }
943310675 }
943410676
9435
- if (drawMode == DEFAULT)
10677
+ if (DrawMode() == DEFAULT)
943610678 {
943710679 if (WIREFRAME && !ambientOcclusion)
943810680 {
....@@ -9450,7 +10692,7 @@
945010692 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945110693 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945210694
9453
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10695
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945410696 {
945510697 if (vertexMode != 0) // && !fast)
945610698 {
....@@ -9470,7 +10712,7 @@
947010712 }
947110713 }
947210714
9473
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10715
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947410716 {
947510717 //gl.glDepthFunc(GL.GL_LEQUAL);
947610718 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9498,7 +10740,7 @@
949810740 //gl.glDepthMask(false);
949910741 }
950010742
9501
- if (false) // drawMode == SHADOW)
10743
+ if (false) // DrawMode() == SHADOW)
950210744 {
950310745 //SetColumnMajorData(cameraInverseTransform, view_1);
950410746 //System.out.println("light = " + cameraInverseTransform);
....@@ -9512,16 +10754,16 @@
951210754 //System.out.println("object = " + object);
951310755 if (!frozen && !imageLocked)
951410756 {
9515
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10757
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951610758 {
951710759 displayAntiAliased(gl);
951810760 } else
951910761 {
952010762 programcount = 0;
9521
- int keepmode = drawMode;
10763
+ int keepmode = DrawMode();
952210764 // if (DEBUG_SELECTION)
952310765 // {
9524
-// drawMode = SELECTION;
10766
+// DrawMode() = SELECTION;
952510767 // }
952610768 // for point selection
952710769 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9531,10 +10773,10 @@
953110773 DrawObject(gl);
953210774
953310775 // jan 2013 System.err.println("RESET ABORT (display)");
9534
- // if (drawMode == DEFAULT)
10776
+ // if (DrawMode() == DEFAULT)
953510777 // ABORTED = false;
953610778 fullreset = false;
9537
- drawMode = keepmode;
10779
+ Globals.drawMode = keepmode; // WARNING
953810780 //System.out.println("PROGRAM SWITCH " + programcount);
953910781 }
954010782 }
....@@ -9542,11 +10784,11 @@
954210784 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954310785 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954410786
9545
- if (drawMode == DEFAULT)
10787
+ if (DrawMode() == DEFAULT)
954610788 {
954710789 ReleaseTexture(NOISE_TEXTURE, false);
954810790 }
9549
- //if (drawMode == DEFAULT)
10791
+ //if (DrawMode() == DEFAULT)
955010792 {
955110793
955210794 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9558,7 +10800,7 @@
955810800 //else
955910801 //gl.glDisable(gl.GL_TEXTURE_2D);
956010802 //gl.glPopMatrix();
9561
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10803
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956210804 {
956310805 //new Exception().printStackTrace();
956410806 //System.out.println("Draw image " + width + ", " + height);
....@@ -9600,7 +10842,7 @@
960010842 //gl.glFlush();
960110843 }
960210844
9603
- if (flash && drawMode == DEFAULT)
10845
+ if (flash && DrawMode() == DEFAULT)
960410846 {
960510847 flash = false;
960610848 wait = true;
....@@ -9608,9 +10850,9 @@
960810850 }
960910851
961010852 //drawing = false;
9611
- //if(drawMode == DEFAULT)
10853
+ //if(DrawMode() == DEFAULT)
961210854 // niceon = false;
9613
- if (drawMode == DEFAULT)
10855
+ if (DrawMode() == DEFAULT)
961410856 {
961510857 currentlydrawing = false;
961610858 }
....@@ -9630,7 +10872,7 @@
963010872 repaint();
963110873 }
963210874
9633
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10875
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963410876 repaint();
963510877
963610878 displaydone = true;
....@@ -9667,7 +10909,7 @@
966710909 if (GrafreeD.RENDERME > 0)
966810910 GrafreeD.RENDERME--; // mechante magouille
966910911
9670
- ONESTEP = false;
10912
+ Globals.ONESTEP = false;
967110913 }
967210914
967310915 static boolean zoomonce = false;
....@@ -9675,11 +10917,11 @@
967510917 void DrawObject(GL gl, boolean draw)
967610918 {
967710919 //System.out.println("DRAW OBJECT " + mouseDown);
9678
-// drawMode = SELECTION;
10920
+// DrawMode() = SELECTION;
967910921 //GL gl = getGL();
968010922 if ((TRACK || SHADOWTRACK) || zoomonce)
968110923 {
9682
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10924
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968310925 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968410926 pingthread.StepToTarget(true); // true);
968510927 // zoomonce = false;
....@@ -9700,9 +10942,9 @@
970010942 callist = gl.glGenLists(1);
970110943 }
970210944
9703
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10945
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970410946
9705
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10947
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970610948
970710949 if (!mainDL || !active || touched)
970810950 {
....@@ -9729,7 +10971,7 @@
972910971 PushMatrix(ClickInfo.matbuffer);
973010972 }
973110973
9732
- if (drawMode == 0)
10974
+ if (DrawMode() == 0)
973310975 {
973410976 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973510977
....@@ -9743,7 +10985,7 @@
974310985 // DRAW
974410986 object.draw(this, /*(Composite)*/ object, false, false);
974510987
9746
- if (drawMode == DEFAULT)
10988
+ if (DrawMode() == DEFAULT)
974710989 {
974810990 if (DEBUG)
974910991 {
....@@ -9754,40 +10996,40 @@
975410996 selectedpoint.radius = radius;
975510997 selectedpoint.recalculate();
975610998 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.15f;
10999
+ selectedpoint.material.color = 0.15f; // Yellow
975811000 selectedpoint.material.modulation = 0.75f;
975911001
9760
- debugpoint.radius = radius;
9761
- debugpoint.recalculate();
9762
- debugpoint.material = new cMaterial();
9763
- debugpoint.material.color = 0.25f;
9764
- debugpoint.material.modulation = 0.75f;
11002
+ debugpointG.radius = radius;
11003
+ debugpointG.recalculate();
11004
+ debugpointG.material = new cMaterial();
11005
+ debugpointG.material.color = 0.25f; // Green
11006
+ debugpointG.material.modulation = 0.75f;
976511007
9766
- debugpoint2.radius = radius;
9767
- debugpoint2.recalculate();
9768
- debugpoint2.material = new cMaterial();
9769
- debugpoint2.material.color = 0.75f;
9770
- debugpoint2.material.modulation = 0.75f;
11008
+ debugpointP.radius = radius;
11009
+ debugpointP.recalculate();
11010
+ debugpointP.material = new cMaterial();
11011
+ debugpointP.material.color = 0.75f; // Purple
11012
+ debugpointP.material.modulation = 0.75f;
977111013
9772
- debugpoint3.radius = radius;
9773
- debugpoint3.recalculate();
9774
- debugpoint3.material = new cMaterial();
9775
- debugpoint3.material.color = 0.5f;
9776
- debugpoint3.material.modulation = 0.75f;
11014
+ debugpointC.radius = radius;
11015
+ debugpointC.recalculate();
11016
+ debugpointC.material = new cMaterial();
11017
+ debugpointC.material.color = 0.5f; // Cyan
11018
+ debugpointC.material.modulation = 0.75f;
977711019
9778
- debugpoint4.radius = radius;
9779
- debugpoint4.recalculate();
9780
- debugpoint4.material = new cMaterial();
9781
- debugpoint4.material.color = 0f;
9782
- debugpoint4.material.modulation = 0.75f;
11020
+ debugpointR.radius = radius;
11021
+ debugpointR.recalculate();
11022
+ debugpointR.material = new cMaterial();
11023
+ debugpointR.material.color = 0f; // Red
11024
+ debugpointR.material.modulation = 0.75f;
978311025
978411026 InitPoints(radius);
978511027 }
978611028 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);
11029
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11030
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11031
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11032
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
979111033 // DrawPoints(this);
979211034 }
979311035
....@@ -9795,7 +11037,7 @@
979511037 }
979611038 // GrafreeD.traceoff();
979711039 //System.out.println(stackdepth);
9798
- if (drawMode == 0)
11040
+ if (DrawMode() == 0)
979911041 {
980011042 ReleaseTextures(DEFAULT_TEXTURES);
980111043
....@@ -9820,17 +11062,19 @@
982011062
982111063 checker = null;
982211064
9823
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11065
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982411066 FindChecker(object);
982511067
9826
- if (checker != null && drawMode == DEFAULT)
11068
+ if (checker != null && DrawMode() == DEFAULT)
982711069 {
9828
- // BindTexture(IMMORTAL_TEXTURE);
11070
+ //BindTexture(IMMORTAL_TEXTURE);
11071
+ BindTextures(checker.GetTextures(), checker.texres);
982911072 // NEAREST
983011073 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
983111074 DrawChecker(gl);
983211075 //checker.Draw(this, null, false);
983311076 // ReleaseTexture(IMMORTAL_TEXTURE);
11077
+ ReleaseTextures(checker.GetTextures());
983411078 }
983511079
983611080 if (object.parent != null)
....@@ -9843,7 +11087,7 @@
984311087 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984411088 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984511089
9846
- if (DISPLAYTEXT && drawMode == DEFAULT)
11090
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984711091 {
984811092 // Draw it once, then use the raster
984911093 Balloon(gl, balloon.createGraphics());
....@@ -9899,9 +11143,9 @@
989911143 int[] xs = new int[3];
990011144 int[] ys = new int[3];
990111145
9902
- void DrawString(Object3D obj) // String string)
11146
+ public void DrawString(Object3D obj) // String string) // INTERFACE
990311147 {
9904
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11148
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990511149 {
990611150 return;
990711151 }
....@@ -10388,6 +11632,7 @@
1038811632 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038911633 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1039011634 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11635
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1039111636 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1039211637 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1039311638 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -11302,6 +12547,7 @@
1130212547 String Shadow(String depth, String shadow)
1130312548 {
1130412549 return "MAX temp.x, ndotl.x, one64th.x;" +
12550
+ "MIN temp.x, temp.x, ninetenth.x;" +
1130512551 /**/
1130612552 // Sine
1130712553 "MUL temp.y, temp.x, temp.x;" +
....@@ -11926,9 +13172,10 @@
1192613172 return;
1192713173 }
1192813174
13175
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1192913176
1193013177 // TIMER
11931
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13178
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1193213179 {
1193313180 keepboxmode = BOXMODE;
1193413181 keepsupport = SUPPORT;
....@@ -12057,7 +13304,7 @@
1205713304 // ObjEditor.tweenManager.update(1f / 60f);
1205813305
1205913306 // fev 2014???
12060
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13307
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1206113308 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1206213309 pingthread.StepToTarget(true); // true);
1206313310 }
....@@ -12169,6 +13416,11 @@
1216913416 cVector tmp = new cVector();
1217013417 cVector tmp2 = new cVector();
1217113418 boolean isMoving;
13419
+
13420
+ public cVector TargetLookAt()
13421
+ {
13422
+ return targetLookAt;
13423
+ }
1217213424
1217313425 class PingThread extends Thread
1217413426 {
....@@ -12308,7 +13560,7 @@
1230813560 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1230913561 if (lightMode)
1231013562 {
12311
- lighttouched = true;
13563
+ Globals.lighttouched = true;
1231213564 }
1231313565
1231413566 if (OEILONCE && OEIL)
....@@ -12366,7 +13618,7 @@
1236613618 mouseDown = false;
1236713619 if (lightMode)
1236813620 {
12369
- lighttouched = true;
13621
+ Globals.lighttouched = true;
1237013622 }
1237113623 repaint();
1237213624 alreadypainted = true;
....@@ -12374,7 +13626,7 @@
1237413626 isMoving = false;
1237513627 } //??
1237613628
12377
- if (isLIVE() && !alreadypainted)
13629
+ if (Globals.isLIVE() && !alreadypainted)
1237813630 {
1237913631 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1238013632 repaint();
....@@ -12386,7 +13638,7 @@
1238613638 {
1238713639 if (lightMode)
1238813640 {
12389
- lighttouched = true;
13641
+ Globals.lighttouched = true;
1239013642 }
1239113643 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1239213644 }
....@@ -12629,6 +13881,7 @@
1262913881 {
1263013882 manipCamera.Translate(dx, dy, getWidth());
1263113883 }
13884
+ else
1263213885 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1263313886 {
1263413887 manipCamera.RotateInterest(dx, dy);
....@@ -12639,7 +13892,7 @@
1263913892
1264013893 if (manipCamera == lightCamera)
1264113894 {
12642
- lighttouched = true;
13895
+ Globals.lighttouched = true;
1264313896 }
1264413897 /*
1264513898 switch (mode)
....@@ -12862,7 +14115,7 @@
1286214115 }
1286314116 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1286414117 {
12865
- mouseMode |= SELECT; // BACKFORTH;
14118
+ mouseMode |= SELECT;
1286614119 }
1286714120 if ((modifiers & COMMAND) == COMMAND)
1286814121 {
....@@ -13027,7 +14280,7 @@
1302714280 case 'B':
1302814281 BRISMOOTH ^= true;
1302914282 SHADOWCULLFACE ^= true;
13030
- lighttouched = true;
14283
+ Globals.lighttouched = true;
1303114284 repaint();
1303214285 break;
1303314286 case 'b':
....@@ -13127,7 +14380,7 @@
1312714380 repaint();
1312814381 break;
1312914382 case 'O':
13130
- drawMode = OCCLUSION;
14383
+ Globals.drawMode = OCCLUSION; // WARNING
1313114384 repaint();
1313214385 break;
1313314386 case 'o':
....@@ -13218,7 +14471,7 @@
1321814471 break;
1321914472 case ' ':
1322014473 lightMode ^= true;
13221
- lighttouched = true;
14474
+ Globals.lighttouched = true;
1322214475 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1322314476 targetLookAt.set(manipCamera.lookAt);
1322414477 repaint();
....@@ -13230,11 +14483,11 @@
1323014483 repaint();
1323114484 break;
1323214485 case 'Z':
13233
- RESIZETEXTURE ^= true;
13234
- break;
14486
+ //RESIZETEXTURE ^= true;
14487
+ //break;
1323514488 case 'z':
1323614489 RENDERSHADOW ^= true;
13237
- lighttouched = true;
14490
+ Globals.lighttouched = true;
1323814491 repaint();
1323914492 break;
1324014493 //case UP:
....@@ -13836,6 +15089,7 @@
1383615089 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1383715090 }
1383815091
15092
+ // To avoid clear.
1383915093 public void update(Graphics g)
1384015094 {
1384115095 paint(g);
....@@ -14438,7 +15692,7 @@
1443815692 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1443915693 gl.glPushMatrix();
1444015694 gl.glLoadIdentity();
14441
- PushMatrix(checker.toParent);
15695
+ //PushMatrix(checker.toParent);
1444215696
1444315697 gl.glMatrixMode(GL.GL_TEXTURE);
1444415698 gl.glPushMatrix();
....@@ -14461,8 +15715,8 @@
1446115715
1446215716 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1446315717
14464
- float step = 0.1666f; //0.25f;
14465
- float stepv = step * 1652 / 998;
15718
+ float step = 2; // 0.1666f; //0.25f;
15719
+ float stepv = 2; // step * 1652 / 998;
1446615720
1446715721 int i0 = 0;
1446815722 /*
....@@ -14498,20 +15752,21 @@
1449815752 /**/
1449915753 //checker.GetMaterial().opacity = 1.1f;
1450015754 ////checker.GetMaterial().ambient = 0.99f;
14501
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14502
- Object3D.selectedstack[Object3D.materialdepth] = false;
14503
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15755
+ materialstack[materialdepth] = checker.material;
15756
+ selectedstack[materialdepth] = false;
15757
+ cStatic.objectstack[materialdepth++] = checker;
1450415758 //System.out.println("material " + material);
1450515759 //Applet3D.tracein(this, selected);
1450615760 vector2buffer = checker.projectedVertices;
1450715761
14508
- checker.GetMaterial().Draw(this, false); // true);
15762
+ //checker.GetMaterial().Draw(this, false); // true);
15763
+ DrawMaterial(checker.GetMaterial(), false); // true);
1450915764
14510
- Object3D.materialdepth -= 1;
14511
- if (Object3D.materialdepth > 0)
15765
+ materialdepth -= 1;
15766
+ if (materialdepth > 0)
1451215767 {
14513
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14514
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
15768
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15769
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1451515770 }
1451615771 //checker.GetMaterial().opacity = 1f;
1451715772 ////checker.GetMaterial().ambient = 1f;
....@@ -14532,15 +15787,27 @@
1453215787
1453315788 //float u = (i+1)/2;
1453415789 //float v = (j+1)/2;
14535
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
15790
+ if (checker.flipV)
15791
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
15792
+ else
15793
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1453615794 gl.glVertex3f(i, j, -0.5f);
1453715795
15796
+ if (checker.flipV)
15797
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
15798
+ else
1453815799 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1453915800 gl.glVertex3f(i + step, j, -0.5f);
1454015801
15802
+ if (checker.flipV)
15803
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
15804
+ else
1454115805 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1454215806 gl.glVertex3f(i + step, j + stepv, -0.5f);
1454315807
15808
+ if (checker.flipV)
15809
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
15810
+ else
1454415811 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1454515812 gl.glVertex3f(i, j + stepv, -0.5f);
1454615813 }
....@@ -14552,7 +15819,7 @@
1455215819 gl.glMatrixMode(GL.GL_PROJECTION);
1455315820 gl.glPopMatrix();
1455415821 gl.glMatrixMode(GL.GL_MODELVIEW);
14555
- PopMatrix(null); // checker.toParent); // null);
15822
+ //PopMatrix(null); // checker.toParent); // null);
1455615823 gl.glPopMatrix();
1455715824 PopTextureMatrix(checker.toParent);
1455815825 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14665,14 +15932,14 @@
1466515932
1466615933 //int tmp = selection_view;
1466715934 //selection_view = -1;
14668
- int temp = drawMode;
14669
- drawMode = SELECTION;
15935
+ int temp = DrawMode();
15936
+ Globals.drawMode = SELECTION; // WARNING
1467015937 indexcount = 0;
1467115938 parent.display(drawable);
1467215939 //selection_view = tmp;
1467315940 //if (temp == SELECTION)
1467415941 // temp = DEFAULT; // patch for selection debug
14675
- drawMode = temp;
15942
+ Globals.drawMode = temp; // WARNING
1467615943
1467715944 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1467815945
....@@ -14945,14 +16212,14 @@
1494516212 //gl.glColorMask(false, false, false, false);
1494616213
1494716214 //render_scene_from_light_view(gl, drawable, 0, 0);
14948
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16215
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1494916216 {
1495016217 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1495116218
14952
- int temp = drawMode;
14953
- drawMode = SHADOW;
16219
+ int temp = DrawMode();
16220
+ Globals.drawMode = SHADOW; // WARNING
1495416221 parent.display(drawable);
14955
- drawMode = temp;
16222
+ Globals.drawMode = temp; // WARNING
1495616223 }
1495716224
1495816225 gl.glCullFace(gl.GL_BACK);
....@@ -15005,7 +16272,6 @@
1500516272
1500616273 class AntialiasBuffer implements GLEventListener
1500716274 {
15008
-
1500916275 CameraPane parent = null;
1501016276
1501116277 AntialiasBuffer(CameraPane p)
....@@ -15115,13 +16381,19 @@
1511516381 gl.glFlush();
1511616382
1511716383 /**/
15118
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16384
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1511916385
15120
- int[] pixels = occlusionsizebuffer.array();
16386
+ float[] pixels = occlusionsizebuffer.array();
1512116387
1512216388 double r = 0, g = 0, b = 0;
1512316389
1512416390 double count = 0;
16391
+
16392
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16393
+
16394
+ float mindepth = 1;
16395
+
16396
+ double FACTOR = 1;
1512516397
1512616398 for (int i = 0; i < pixels.length; i++)
1512716399 {
....@@ -15206,7 +16478,7 @@
1520616478
1520716479 double scale = ray.z; // 1; // cos
1520816480
15209
- int p = pixels[newindex];
16481
+ float depth = pixels[newindex];
1521016482
1521116483 /*
1521216484 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15230,10 +16502,23 @@
1523016502 scale = (1 - modu) * modv;
1523116503 */
1523216504
15233
- r += ((p >> 16) & 0xFF) * scale / 255;
15234
- g += ((p >> 8) & 0xFF) * scale / 255;
15235
- b += (p & 0xFF) * scale / 255;
16505
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16506
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16507
+ //b += (p & 0xFF) * scale / 255;
16508
+
16509
+ if (mindepth > depth)
16510
+ {
16511
+ mindepth = depth;
16512
+ }
1523616513
16514
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16515
+
16516
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16517
+
16518
+ r += factor * scale;
16519
+ g += factor * scale;
16520
+ b += factor * scale;
16521
+
1523716522 count += scale;
1523816523 }
1523916524
....@@ -15331,12 +16616,6 @@
1533116616 GLUT glut = new GLUT();
1533216617
1533316618
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;
1534016619 public boolean spherical = false;
1534116620 static boolean DEBUG_OCCLUSION = false;
1534216621 static boolean DEBUG_SELECTION = false;
....@@ -15351,10 +16630,10 @@
1535116630 //double[] selectedpoint = new double[3];
1535216631 static Superellipsoid selectedpoint = new Superellipsoid();
1535316632 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();
16633
+ static Sphere debugpointG = new Sphere();
16634
+ static Sphere debugpointP = new Sphere();
16635
+ static Sphere debugpointC = new Sphere();
16636
+ static Sphere debugpointR = new Sphere();
1535816637
1535916638 static Sphere debugpoints[] = new Sphere[8];
1536016639
....@@ -15385,7 +16664,7 @@
1538516664 }
1538616665 }
1538716666
15388
- static void DrawPoints(CameraPane cpane)
16667
+ static void DrawPoints(iCameraPane cpane)
1538916668 {
1539016669 for (int i=0; i<8; i++) // first and last are red
1539116670 {
....@@ -15407,7 +16686,8 @@
1540716686 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1540816687 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1540916688 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15410
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16689
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16690
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1541116691 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1541216692 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1541316693 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();