Normand Briere
2019-04-22 c60a1ad4f6aa4904e80280586b440a584b5ff061
CameraPane.java
....@@ -31,8 +31,12 @@
3131
3232 import gleem.linalg.Mat4f;
3333
34
-class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
34
+class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3535 {
36
+ static cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3640 static boolean DEBUG = false;
3741 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3842
....@@ -42,25 +46,7 @@
4246
4347 static int STEP = 1;
4448
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
51
- {
52
- return LIVE || ONESTEP;
53
- }
54
-
55
- /**
56
- * @param aLIVE the LIVE to set
57
- */
58
- public static void setLIVE(boolean aLIVE)
59
- {
60
- LIVE = aLIVE;
61
- }
62
-
63
- /*static*/ boolean CULLFACE = false; // true;
49
+ /*static*/ private boolean CULLFACE = false; // true;
6450 /*static*/ boolean NEAREST = false; // true;
6551 /*static*/ boolean WIREFRAME = false; // true;
6652
....@@ -97,10 +83,8 @@
9783
9884 static boolean textureon = true;
9985 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10186 static boolean FULLSCREEN = false;
10287 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10488 static boolean INERTIA = true;
10589 static boolean FAST = false;
10690 static boolean SLOWPOSE = false;
....@@ -173,17 +157,52 @@
173157 theRenderer = this;
174158 }
175159
160
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
161
+ {
162
+ super(defaultcaps, null, withcontext?glcontext:null, null);
163
+
164
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
165
+ glcontext = getContext();
166
+
167
+ cameras = new Camera[2];
168
+ targetLookAts = new cVector[2];
169
+
170
+ SetCamera(cam);
171
+
172
+ SetLight(new Camera(new cVector(10, 10, -20)));
173
+
174
+ object = o;
175
+
176
+ setBackground(Color.white);
177
+
178
+ addKeyListener(this);
179
+ addMouseListener(this);
180
+ addMouseMotionListener(this);
181
+ addMouseWheelListener(this);
182
+ //System.out.println("addGLEventListener: " + this);
183
+ addGLEventListener(this);
184
+
185
+// pingthread.start(); // may 2013
186
+ }
187
+
176188 static boolean AntialiasingEnabled()
177189 {
178190 return CURRENTANTIALIAS > 0;
179191 }
180192
181
- void ClearDepth()
193
+ /// INTERFACE
194
+
195
+ public boolean IsBoxMode()
196
+ {
197
+ return BOXMODE;
198
+ }
199
+
200
+ public void ClearDepth()
182201 {
183202 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184203 }
185204
186
- void DepthTest(boolean depthtest)
205
+ public void DepthTest(boolean depthtest)
187206 {
188207 if (depthtest)
189208 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +210,7 @@
191210 GetGL().glDepthFunc(GL.GL_ALWAYS);
192211 }
193212
194
- void DepthWrite(boolean depthwrite)
213
+ public void DepthWrite(boolean depthwrite)
195214 {
196215 if (depthwrite)
197216 GetGL().glDepthMask(true);
....@@ -199,12 +218,965 @@
199218 GetGL().glDepthMask(false);
200219 }
201220
202
- void BackFaceCull(boolean bfc)
221
+ public void BackFaceCull(boolean bfc)
203222 {
204223 if (bfc)
205224 GetGL().glEnable(GetGL().GL_CULL_FACE);
206225 else
207226 GetGL().glDisable(GetGL().GL_CULL_FACE);
227
+ }
228
+
229
+ public boolean BackFaceCullMode()
230
+ {
231
+ return this.CULLFACE;
232
+ }
233
+
234
+ public boolean IsAmbientOcclusionOn()
235
+ {
236
+ return this.ambientOcclusion;
237
+ }
238
+
239
+ public boolean IsFrozen()
240
+ {
241
+ boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
242
+
243
+ return !selectmode && cameracount == 0; // != 0;
244
+ }
245
+
246
+ // Currently in Globals
247
+ public int DrawMode()
248
+ {
249
+ return Globals.DrawMode();
250
+ }
251
+
252
+ public Camera EyeCamera()
253
+ {
254
+ return eyeCamera;
255
+ }
256
+
257
+ public Camera LightCamera()
258
+ {
259
+ return lightCamera;
260
+ }
261
+
262
+ public Camera RenderCamera()
263
+ {
264
+ return renderCamera;
265
+ }
266
+
267
+ public void PushMaterial(Object3D obj, boolean selected)
268
+ {
269
+ CameraPane display = this;
270
+ javax.media.opengl.GL gl = display.GetGL();
271
+ cMaterial material = obj.material;
272
+
273
+ if (material != null)
274
+ {
275
+ materialstack[materialdepth] = material;
276
+ selectedstack[materialdepth] = selected;
277
+ cStatic.objectstack[materialdepth++] = obj;
278
+ //System.out.println("material " + material);
279
+ //Applet3D.tracein(this, selected);
280
+ display.vector2buffer = obj.projectedVertices;
281
+ if (obj instanceof Camera)
282
+ {
283
+ display.options1[0] = material.shift;
284
+ //System.out.println("shift " + material.shift);
285
+ display.options1[1] = material.lightarea;
286
+ display.options1[2] = material.shadowbias;
287
+ display.options1[3] = material.aniso;
288
+ display.options1[4] = material.anisoV;
289
+ display.options2[0] = material.opacity;
290
+ display.options2[1] = material.diffuse;
291
+ display.options2[2] = material.factor;
292
+
293
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
294
+ display.options4[0] = material.cameralight/0.2f;
295
+ display.options4[1] = material.subsurface;
296
+ display.options4[2] = material.sheen;
297
+
298
+ // if (display.CURRENTANTIALIAS > 0)
299
+ // display.options3[3] /= 4;
300
+
301
+ /*
302
+ System.out.println("Focus = " + display.options1[0]);
303
+ System.out.println("Aperture = " + display.options1[1]);
304
+ System.out.println("ShadowBlur = " + display.options1[2]);
305
+ System.out.println("Antialiasing = " + display.options1[3]);
306
+ System.out.println("Fog = " + display.options2[0]);
307
+ System.out.println("Intensity = " + display.options2[1]);
308
+ System.out.println("Elevation = " + display.options2[2]);
309
+ /**/
310
+ } else
311
+ {
312
+ DrawMaterial(material, selected);
313
+ }
314
+ } else
315
+ {
316
+ if (selected && CameraPane.flash)
317
+ {
318
+ display.modelParams4[1] = 100;
319
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
320
+ }
321
+ }
322
+ }
323
+
324
+ public void PushMaterial2(Object3D obj, boolean selected)
325
+ {
326
+ CameraPane display = this;
327
+ cMaterial material = obj.material;
328
+
329
+ if (material != null)
330
+ {
331
+ materialstack[materialdepth] = material;
332
+ selectedstack[materialdepth] = selected;
333
+ cStatic.objectstack[materialdepth++] = obj;
334
+ //System.out.println("material " + material);
335
+ //Applet3D.tracein("selected ", selected);
336
+ display.vector2buffer = obj.projectedVertices;
337
+ display.DrawMaterial(material, selected);
338
+ }
339
+ }
340
+
341
+ public void PopMaterial(Object3D obj, boolean selected)
342
+ {
343
+ CameraPane display = this;
344
+ javax.media.opengl.GL gl = display.GetGL();
345
+ cMaterial material = obj.material;
346
+
347
+ //if (parent != null && parent.GetMaterial() != null)
348
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
349
+ if (material != null)
350
+ {
351
+ materialdepth -= 1;
352
+ if (materialdepth > 0)
353
+ {
354
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
355
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
356
+ }
357
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
358
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
359
+ {
360
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
361
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
362
+ }
363
+ }
364
+
365
+ public void PopMaterial2(Object3D obj)
366
+ {
367
+ CameraPane display = this;
368
+ cMaterial material = obj.material;
369
+
370
+ if (material != null)
371
+ {
372
+ materialdepth -= 1;
373
+ if (materialdepth > 0)
374
+ {
375
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
376
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
377
+ }
378
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
379
+ //else
380
+ //material.Draw(display, false);
381
+ }
382
+ }
383
+
384
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
385
+ {
386
+ CameraPane display = this;
387
+
388
+ if (pv.y == -10000 ||
389
+ qv.y == -10000 ||
390
+ rv.y == -10000)
391
+ return;
392
+
393
+// float b = f.nbiterations & 1;
394
+// float g = (f.nbiterations>>1) & 1;
395
+// float r = (f.nbiterations>>2) & 1;
396
+//
397
+// //if (f.weight == 10000)
398
+// //{
399
+// // r = 1; g = b = 0;
400
+// //}
401
+// //else
402
+// //{
403
+// // assert(f.weight < 10000);
404
+// r = g = b = (float)bRep.FaceWeight(f)*100;
405
+// if (r<0)
406
+// assert(r>=0);
407
+// //}
408
+
409
+ javax.media.opengl.GL gl = display.GetGL();
410
+
411
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
412
+
413
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
414
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
415
+ {
416
+ //gl.glBegin(gl.GL_TRIANGLES);
417
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
418
+ if (!hasnorm)
419
+ {
420
+ // System.out.println("FUCK!!");
421
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
422
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
423
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
424
+ LA.vecNormalize(obj.v2);
425
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
426
+ }
427
+
428
+ // P
429
+ float x = (float)pv.x;
430
+ float y = (float)pv.y;
431
+ float z = (float)pv.z;
432
+
433
+ if (hasnorm)
434
+ {
435
+// if (!pv.norm.normalized())
436
+// assert(pv.norm.normalized());
437
+
438
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
439
+ float nx = (float)pv.norm.x;
440
+ float ny = (float)pv.norm.y;
441
+ float nz = (float)pv.norm.z;
442
+
443
+ x += nx * obj.NORMALPUSH;
444
+ y += ny * obj.NORMALPUSH;
445
+ z += nz * obj.NORMALPUSH;
446
+
447
+ gl.glNormal3f(nx, ny, nz);
448
+ }
449
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
450
+ SetColor(obj, pv);
451
+ //gl.glColor4f(r, g, b, 1);
452
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
453
+ if (obj.flipV)
454
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
455
+ else
456
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
457
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
458
+
459
+ gl.glVertex3f(x, y, z);
460
+
461
+ // Q
462
+ x = (float)qv.x;
463
+ y = (float)qv.y;
464
+ z = (float)qv.z;
465
+
466
+// Print(pv);
467
+ if (hasnorm)
468
+ {
469
+// assert(qv.norm.normalized());
470
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
471
+ float nx = (float)qv.norm.x;
472
+ float ny = (float)qv.norm.y;
473
+ float nz = (float)qv.norm.z;
474
+
475
+ x += nx * obj.NORMALPUSH;
476
+ y += ny * obj.NORMALPUSH;
477
+ z += nz * obj.NORMALPUSH;
478
+
479
+ gl.glNormal3f(nx, ny, nz);
480
+ }
481
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
482
+ // boolean locked = false;
483
+ // float eps = 0.1f;
484
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
485
+
486
+ // int dot = 0; //*/ (int)f.dot;
487
+
488
+ // if ((dot&1) == 0)
489
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
490
+
491
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
492
+ if (obj.flipV)
493
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
494
+ else
495
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
496
+ // else
497
+ // {
498
+ // locked = true;
499
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
500
+ // }
501
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
502
+ SetColor(obj, qv);
503
+
504
+ gl.glVertex3f(x, y, z);
505
+ //gl.glColor4f(r, g, b, 1);
506
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
507
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
508
+// Print(qv);
509
+
510
+ // R
511
+ x = (float)rv.x;
512
+ y = (float)rv.y;
513
+ z = (float)rv.z;
514
+
515
+ if (hasnorm)
516
+ {
517
+// assert(rv.norm.normalized());
518
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
519
+ float nx = (float)rv.norm.x;
520
+ float ny = (float)rv.norm.y;
521
+ float nz = (float)rv.norm.z;
522
+
523
+ x += nx * obj.NORMALPUSH;
524
+ y += ny * obj.NORMALPUSH;
525
+ z += nz * obj.NORMALPUSH;
526
+
527
+ gl.glNormal3f(nx, ny, nz);
528
+ }
529
+
530
+ // if ((dot&4) == 0)
531
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
532
+
533
+ // if (wrap || !locked && (dot&8) != 0)
534
+ if (obj.flipV)
535
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
536
+ else
537
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
538
+ // else
539
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
540
+
541
+ // f.dot = dot;
542
+
543
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
544
+ SetColor(obj, rv);
545
+ //gl.glColor4f(r, g, b, 1);
546
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
547
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
548
+ gl.glVertex3f(x, y, z);
549
+// Print(rv);
550
+ //gl.glEnd();
551
+ }
552
+ else
553
+ {
554
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
555
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
556
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
557
+
558
+ }
559
+
560
+ if (false) // (attributes & WIREFRAME) != 0)
561
+ {
562
+ gl.glDisable(gl.GL_LIGHTING);
563
+
564
+ gl.glBegin(gl.GL_LINE_LOOP);
565
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
566
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
567
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
568
+ gl.glEnd();
569
+
570
+ gl.glEnable(gl.GL_LIGHTING);
571
+ }
572
+ }
573
+
574
+ /**
575
+ * <code>draw</code> renders a <code>TriMesh</code> object including
576
+ * it's normals, colors, textures and vertices.
577
+ *
578
+ * @see Renderer#draw(TriMesh)
579
+ * @param tris
580
+ * the mesh to render.
581
+ */
582
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
583
+ {
584
+ CameraPane display = this;
585
+
586
+ float r = display.modelParams0[0];
587
+ float g = display.modelParams0[1];
588
+ float b = display.modelParams0[2];
589
+ float opacity = display.modelParams5[1];
590
+
591
+ //final GL gl = GLU.getCurrentGL();
592
+ GL gl = display.GetGL(); // getGL();
593
+
594
+ FloatBuffer vertBuf = geo.vertBuf;
595
+
596
+ int v = vertBuf.capacity();
597
+
598
+ int count = 0;
599
+
600
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
601
+ gl.glEnable(gl.GL_CULL_FACE);
602
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
603
+ for (int i=0; i<v/3; i++)
604
+ {
605
+ int index3 = i*3;
606
+
607
+ if (geo.sizeBuf.get(index3+1) == 0)
608
+ continue;
609
+
610
+ count++;
611
+
612
+ int index4 = i*4;
613
+
614
+ float tx = vertBuf.get(index3);
615
+ float ty = vertBuf.get(index3+1);
616
+ float tz = vertBuf.get(index3+2);
617
+
618
+ // if (tx == 0 && ty == 0 && tz == 0)
619
+ // continue;
620
+
621
+ gl.glMatrixMode(gl.GL_TEXTURE);
622
+ gl.glPushMatrix();
623
+
624
+ float[] texmat = geo.texmat;
625
+ texmat[12] = texmat[13] = texmat[14] = i;
626
+
627
+ gl.glMultMatrixf(texmat, 0);
628
+
629
+ gl.glMatrixMode(gl.GL_MODELVIEW);
630
+ gl.glPushMatrix();
631
+
632
+ gl.glTranslatef(tx,ty,tz);
633
+
634
+ if (rotate)
635
+ gl.glRotatef(i, 0, 1, 0);
636
+
637
+ float size = geo.sizeBuf.get(index3) / 100;
638
+ gl.glScalef(size,size,size);
639
+
640
+ float cr = geo.colorBuf.get(index4);
641
+ float cg = geo.colorBuf.get(index4+1);
642
+ float cb = geo.colorBuf.get(index4+2);
643
+ float ca = geo.colorBuf.get(index4+3);
644
+
645
+ display.modelParams0[0] = r * cr;
646
+ display.modelParams0[1] = g * cg;
647
+ display.modelParams0[2] = b * cb;
648
+
649
+ display.modelParams5[1] = opacity * ca;
650
+
651
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
652
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
653
+
654
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
655
+ RandomNode.globalseed2 = RandomNode.globalseed;
656
+
657
+// gl.glColor4f(cr,cg,cb,ca);
658
+ // gl.glScalef(1024/16,1024/16,1024/16);
659
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
660
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
661
+ //gl.glTranslatef(-tx,-ty,-tz);
662
+ gl.glPopMatrix();
663
+
664
+ gl.glMatrixMode(gl.GL_TEXTURE);
665
+ gl.glPopMatrix();
666
+ }
667
+ // gl.glScalef(1024,1024,1024);
668
+ if (!cf)
669
+ gl.glDisable(gl.GL_CULL_FACE);
670
+
671
+ display.modelParams0[0] = r;
672
+ display.modelParams0[1] = g;
673
+ display.modelParams0[2] = b;
674
+
675
+ display.modelParams5[1] = opacity;
676
+
677
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
678
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
679
+
680
+ gl.glMatrixMode(gl.GL_MODELVIEW);
681
+
682
+// System.err.println("total = " + v/3 + "; displayed = " + count);
683
+ if (true)
684
+ return;
685
+
686
+//// if (!tris.predraw(this))
687
+//// {
688
+//// return;
689
+//// }
690
+//// if (Debug.stats)
691
+//// {
692
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
693
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
694
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
695
+//// }
696
+////
697
+//// if (tris.getDisplayListID() != -1)
698
+//// {
699
+//// renderDisplayList(tris);
700
+//// return;
701
+//// }
702
+////
703
+//// if (!generatingDisplayList)
704
+//// {
705
+//// applyStates(tris.states, tris);
706
+//// }
707
+//// if (Debug.stats)
708
+//// {
709
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
710
+//// }
711
+//// boolean transformed = doTransforms(tris);
712
+//
713
+// int glMode = GL.GL_TRIANGLES;
714
+// switch (getMode())
715
+// {
716
+// case Triangles:
717
+// glMode = GL.GL_TRIANGLES;
718
+// break;
719
+// case Strip:
720
+// glMode = GL.GL_TRIANGLE_STRIP;
721
+// break;
722
+// case Fan:
723
+// glMode = GL.GL_TRIANGLE_FAN;
724
+// break;
725
+// }
726
+//
727
+// if (!predrawGeometry(gl))
728
+// {
729
+// // make sure only the necessary indices are sent through on old
730
+// // cards.
731
+// IntBuffer indices = this.getIndexBuffer();
732
+// if (indices == null)
733
+// {
734
+// logger.severe("missing indices on geometry object: " + this.toString());
735
+// } else
736
+// {
737
+// indices.rewind();
738
+// indices.limit(this.getMaxIndex());
739
+//
740
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
741
+//
742
+// indices.clear();
743
+// }
744
+// } else
745
+// {
746
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
747
+// GL.GL_UNSIGNED_INT, 0);
748
+// }
749
+//
750
+//// postdrawGeometry(tris);
751
+//// if (transformed)
752
+//// {
753
+//// undoTransforms(tris);
754
+//// }
755
+////
756
+//// if (Debug.stats)
757
+//// {
758
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
759
+//// }
760
+//// tris.postdraw(this);
761
+ }
762
+
763
+ /// INTERFACE
764
+
765
+ void SetColor(Object3D obj, Vertex p0)
766
+ {
767
+ CameraPane display = this;
768
+ BoundaryRep bRep = obj.bRep;
769
+
770
+ if (RENDERPROGRAM == 0)
771
+ {
772
+ float r = 0;
773
+ if (bRep != null)
774
+ {
775
+ if (bRep.stripified)
776
+ {
777
+ r = 1;
778
+ }
779
+ }
780
+ float g = 0;
781
+ if (bRep != null)
782
+ {
783
+ if (bRep.trimmed)
784
+ {
785
+ g = 1;
786
+ }
787
+ }
788
+ float b = 0;
789
+ if (obj.support != null && obj.link2master)
790
+ {
791
+ b = 1;
792
+ }
793
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
794
+ return;
795
+ }
796
+
797
+ if (display.DrawMode() != CameraPane.SHADOW)
798
+ return;
799
+
800
+ javax.media.opengl.GL gl = display.GetGL();
801
+// if (true) return;
802
+// float ao = p.AO;
803
+//
804
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
805
+// // ao = 1;
806
+//
807
+// gl.glColor4f(ao, ao, ao, 1);
808
+
809
+// CameraPane.selectedpoint.
810
+// getAverage(cStatic.point1, true);
811
+ if (CameraPane.pointflow == null) // !random) // live)
812
+ {
813
+ return;
814
+ }
815
+
816
+ cStatic.point1.set(0,0,0);
817
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
818
+
819
+ cStatic.point1.sub(p0);
820
+
821
+
822
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
823
+// {
824
+// return;
825
+// }
826
+
827
+ //if (true)
828
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
829
+ {
830
+ return;
831
+ }
832
+
833
+ float[] colorV = new float[3];
834
+
835
+ if (false) // marked)
836
+ {
837
+ // debug rigging weights
838
+ for (int object = 0; object < p0.vertexlinks.length; object++)
839
+ {
840
+ float weight = p0.weights[object] / p0.totalweight;
841
+
842
+ // if (weight < 0.1)
843
+ // {
844
+ // assert(weight == 0);
845
+ // continue;
846
+ // }
847
+
848
+ if (p0.vertexlinks[object] == -1)
849
+ continue;
850
+
851
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
852
+
853
+ int color = //1 << object; //
854
+ //p.vertexlinks.length;
855
+ obj.support.bRep.supports[p0.closestsupport].links[object];
856
+ colorV[2] += (color & 1) * weight;
857
+ colorV[1] += ((color & 2) >> 1) * weight;
858
+ colorV[0] += ((color & 4) >> 2) * weight;
859
+ }
860
+ }
861
+ else
862
+ {
863
+ if (obj.drawingstarted)
864
+ {
865
+ // find next point
866
+ if (bRep.GetVertex(0).faceindices == null)
867
+ {
868
+ bRep.InitFaceIndices();
869
+ }
870
+
871
+ double ymin = p0.y;
872
+
873
+ Vertex newp = p0;
874
+
875
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
876
+ {
877
+ int fi = p0.faceindices[fii];
878
+
879
+ if (fi == -1)
880
+ break;
881
+
882
+ Face f = bRep.GetFace(fi);
883
+
884
+ Vertex p = bRep.GetVertex(f.p);
885
+ Vertex q = bRep.GetVertex(f.q);
886
+ Vertex r = bRep.GetVertex(f.r);
887
+
888
+ int swap = (int)(Math.random()*3);
889
+
890
+// for (int s=swap; --s>=0;)
891
+// {
892
+// Vertex t = p;
893
+// p = q;
894
+// q = r;
895
+// r = t;
896
+// }
897
+ if (ymin > p.y)
898
+ {
899
+ ymin = p.y;
900
+ newp = p;
901
+// break;
902
+ }
903
+ if (ymin > q.y)
904
+ {
905
+ ymin = q.y;
906
+ newp = q;
907
+// break;
908
+ }
909
+ if (ymin > r.y)
910
+ {
911
+ ymin = r.y;
912
+ newp = r;
913
+// break;
914
+ }
915
+ }
916
+
917
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
918
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
919
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
920
+
921
+ obj.drawingstarted = false;
922
+
923
+ // return;
924
+ }
925
+
926
+ if (false) // CameraPane.DRAW
927
+ {
928
+ p0.AO = colorV[0] = 2;
929
+ colorV[1] = 2;
930
+ colorV[2] = 2;
931
+ }
932
+
933
+ CameraPane.pointflow.add(p0);
934
+ CameraPane.pointflow.Touch();
935
+ }
936
+
937
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
938
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
939
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
940
+ }
941
+
942
+ void DrawMaterial(cMaterial material, boolean selected)
943
+ {
944
+ CameraPane display = this;
945
+ //new Exception().printStackTrace();
946
+
947
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
948
+ {
949
+ return;
950
+ }
951
+
952
+ javax.media.opengl.GL gl = display.GetGL();
953
+
954
+ //Color col = Color.getHSBColor(color,modulation,1);
955
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
956
+ if (!material.multiply)
957
+ {
958
+ display.color = color;
959
+ display.saturation = material.modulation;
960
+ }
961
+ else
962
+ {
963
+ display.color *= color*2;
964
+ display.saturation *= material.modulation*2;
965
+ }
966
+
967
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
968
+
969
+ float[] colorV = GrafreeD.colorV;
970
+
971
+ /**/
972
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
973
+ {
974
+ colorV[0] = display.modelParams0[0] * material.diffuse;
975
+ colorV[1] = display.modelParams0[1] * material.diffuse;
976
+ colorV[2] = display.modelParams0[2] * material.diffuse;
977
+ colorV[3] = material.opacity;
978
+
979
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
980
+ //System.out.println("Opacity = " + opacity);
981
+
982
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
983
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
984
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
985
+
986
+ float amb = material.ambient;
987
+ if (amb < material.cameralight)
988
+ {
989
+ amb = material.cameralight;
990
+ }
991
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
992
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
993
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
994
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
995
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
996
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
997
+
998
+ /**/
999
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1000
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1001
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1002
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1003
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1004
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1005
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1006
+ //System.out.println("shininess = " + colorV[0]);
1007
+ if (colorV[0] > 128)
1008
+ {
1009
+ colorV[0] = 128;
1010
+ }
1011
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1012
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1013
+ /**/
1014
+ }
1015
+ /**/
1016
+
1017
+ //selected = false;
1018
+ selected = selected && display.flash;
1019
+
1020
+ //display.modelParams0[0] = 0; // pigment.r;
1021
+ //display.modelParams0[1] = 0; // pigment.g;
1022
+ //display.modelParams0[2] = 0; // pigment.b;
1023
+ if (!material.multiply)
1024
+ {
1025
+ display.modelParams0[3] = material.metalness;
1026
+ display.modelParams1[0] = material.diffuse;
1027
+ display.modelParams1[1] = material.specular;
1028
+ display.modelParams1[2] = 1 / material.shininess;
1029
+ display.modelParams1[3] = material.shift;
1030
+ display.modelParams2[0] = material.ambient;
1031
+ display.modelParams2[1] = material.lightarea;
1032
+ //System.out.println("light area = " + lightarea);
1033
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1034
+ display.modelParams2[3] = material.velvet;
1035
+ display.modelParams3[0] = material.sheen;
1036
+ display.modelParams3[1] = material.subsurface;
1037
+ display.modelParams3[2] = material.bump; // backlit
1038
+ display.modelParams3[3] = material.aniso;
1039
+ display.modelParams4[0] = material.anisoV;
1040
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1041
+ //System.out.println("selected = " + selected);
1042
+ display.modelParams4[2] = material.diffuseness;
1043
+ display.modelParams4[3] = material.shadow;
1044
+ display.modelParams5[0] = material.texture;
1045
+ display.modelParams5[1] = material.opacity;
1046
+ display.modelParams5[2] = material.fakedepth;
1047
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1048
+ }
1049
+ else
1050
+ {
1051
+ display.modelParams0[3] *= material.metalness*2;
1052
+ display.modelParams1[0] *= material.diffuse*2;
1053
+ display.modelParams1[1] *= material.specular*2;
1054
+ display.modelParams1[2] *= material.shininess*2;
1055
+ display.modelParams1[3] *= material.shift*2;
1056
+ display.modelParams2[0] *= material.ambient*2;
1057
+ display.modelParams2[1] *= material.lightarea*2;
1058
+ display.modelParams2[2] *= material.factor*2;
1059
+ display.modelParams2[3] *= material.velvet*2;
1060
+ display.modelParams3[0] *= material.sheen*2;
1061
+ display.modelParams3[1] *= material.subsurface*2;
1062
+ display.modelParams3[2] *= material.bump*2;
1063
+ display.modelParams3[3] *= material.aniso*2;
1064
+ display.modelParams4[0] *= material.anisoV*2;
1065
+ display.modelParams4[1] *= material.cameralight*2;
1066
+ //System.out.println("selected = " + selected);
1067
+ display.modelParams4[2] *= material.diffuseness*2;
1068
+ display.modelParams4[3] *= material.shadow*2;
1069
+ display.modelParams5[0] *= material.texture*2;
1070
+ display.modelParams5[1] *= material.opacity*2;
1071
+ display.modelParams5[2] *= material.fakedepth*2;
1072
+ display.modelParams5[3] *= material.shadowbias*2;
1073
+ }
1074
+
1075
+ display.modelParams6[0] = 0;
1076
+ display.modelParams6[1] = 0;
1077
+ display.modelParams6[2] = 0;
1078
+ display.modelParams6[3] = 0;
1079
+
1080
+ display.modelParams7[0] = 0;
1081
+ display.modelParams7[1] = 1000;
1082
+ display.modelParams7[2] = 0;
1083
+ display.modelParams7[3] = 0;
1084
+
1085
+ display.modelParams6[0] = 100; // criss de bug de bump
1086
+
1087
+ Object3D.cVector2[] extparams = display.vector2buffer;
1088
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1089
+ {
1090
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1091
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1092
+ if (extparams.length > 1)
1093
+ {
1094
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1095
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1096
+ if (extparams.length > 2)
1097
+ {
1098
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1099
+ float x = extparams[2].y / 1000.0f;
1100
+ //if (x == 0)
1101
+ // x = 1f;
1102
+ display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power
1103
+ if (extparams[2].y > 0)
1104
+ {
1105
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1106
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1107
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ //if (display.modelParams6[2] != 0)
1114
+ /*
1115
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1116
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1117
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1118
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1119
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1120
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1121
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1122
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1123
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1124
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1125
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1126
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1127
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1128
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1129
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1130
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1131
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1132
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1133
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1134
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1135
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1136
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1137
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1138
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1139
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1140
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1141
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1142
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1143
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1144
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1145
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1146
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1147
+ /**/
1148
+ //assert (display.modelParams6[2] == 0);
1149
+
1150
+ //System.out.println("noise power = " + display.modelParams7[0]);
1151
+ //System.out.println("shadowbias = " + shadowbias);
1152
+
1153
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1154
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1155
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1156
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1157
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1158
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1159
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1160
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1161
+
1162
+ int mode = display.FP_SHADER;
1163
+
1164
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1165
+ {
1166
+ mode |= display.FP_ANISO;
1167
+ }
1168
+
1169
+ display.EnableProgram(mode);
1170
+
1171
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1172
+
1173
+ if (!material.multiply)
1174
+ {
1175
+ if (Globals.drawMode == CameraPane.SHADOW)
1176
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1177
+ else
1178
+ gl.glDepthMask(material.opacity >= 0.99);
1179
+ }
2081180 }
2091181
2101182 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,10 +1197,10 @@
2251197 currentGL.glMultMatrixd(model, 0);
2261198 }
2271199
228
- void PushMatrix(double[][] matrix, int count)
1200
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291201 {
2301202 matrixdepth++;
231
- // GraphreeD.tracein(matrix);
1203
+ // GrafreeD.tracein(matrix);
2321204 if (matrix == null)
2331205 return; // Identity
2341206
....@@ -253,13 +1225,13 @@
2531225
2541226 void PushMatrix(double[][] matrix)
2551227 {
256
- // GraphreeD.tracein(matrix);
1228
+ // GrafreeD.tracein(matrix);
2571229 PushMatrix(matrix,1);
2581230 }
2591231
2601232 void PushMatrix()
2611233 {
262
- // GraphreeD.tracein(null);
1234
+ // GrafreeD.tracein(null);
2631235 if (matrixdepth++ < MAXSTACK - 1)
2641236 {
2651237 currentGL.glPushMatrix();
....@@ -270,11 +1242,11 @@
2701242
2711243 double[][] tmpmat = new double[4][4];
2721244
273
- void PopMatrix(double[][] inverse)
1245
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741246 {
2751247 --matrixdepth;
2761248
277
- // GraphreeD.traceout(inverse);
1249
+ // GrafreeD.traceout(inverse);
2781250 if (inverse == null)
2791251 return; // Identity
2801252
....@@ -292,7 +1264,7 @@
2921264
2931265 void PopMatrix()
2941266 {
295
- // GraphreeD.traceout(null);
1267
+ // GrafreeD.traceout(null);
2961268 // inverse == null??
2971269 if (--matrixdepth < MAXSTACK - 1)
2981270 {
....@@ -310,7 +1282,7 @@
3101282 PushTextureMatrix(matrix, 1);
3111283 }
3121284
313
- void PushTextureMatrix(double[][] matrix, int count)
1285
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141286 {
3151287 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161288
....@@ -324,7 +1296,7 @@
3241296 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251297 }
3261298
327
- void PopTextureMatrix(double[][] inverse)
1299
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281300 {
3291301 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301302 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -356,10 +1328,10 @@
3561328 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571329 // return false;
3581330
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1331
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601332 {
3611333 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1334
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631335 {
3641336 // refuse the camera change
3651337 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +1339,7 @@
3671339 }
3681340 }
3691341
370
- camerachangeframe = framecount;
1342
+ camerachangeframe = Globals.framecount;
3711343
3721344 cam.hAspect = -1; // Read only
3731345
....@@ -398,7 +1370,7 @@
3981370 {
3991371 //System.err.println("Oeil on");
4001372 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1373
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4021374 // object.editWindow.ScreenFit(trackedobject);
4031375 //pingthread.StepToTarget(true);
4041376 }
....@@ -407,7 +1379,7 @@
4071379 {
4081380 //System.err.println("Oeil on");
4091381 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1382
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4111383 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4121384 //pingthread.StepToTarget(true);
4131385 }
....@@ -471,7 +1443,7 @@
4711443 {
4721444 frozen ^= true;
4731445 // Weird...
474
- lighttouched = true;
1446
+ Globals.lighttouched = true;
4751447 }
4761448
4771449 void ToggleDL()
....@@ -486,12 +1458,12 @@
4861458
4871459 void ToggleLive()
4881460 {
489
- setLIVE(isLIVE() ^ true);
1461
+ Globals.setLIVE(Globals.isLIVE() ^ true);
4901462
491
- System.err.println("LIVE = " + isLIVE());
1463
+ System.err.println("LIVE = " + Globals.isLIVE());
4921464
493
- if (!isLIVE()) // save sound
494
- GraphreeD.savesound = true; // wav.save();
1465
+ if (!Globals.isLIVE()) // save sound
1466
+ GrafreeD.savesound = true; // wav.save();
4951467 // else
4961468 repaint(); // start loop // may 2013
4971469 }
....@@ -513,7 +1485,7 @@
5131485
5141486 void ToggleCrowd()
5151487 {
516
- CROWD ^= true;
1488
+ Globals.CROWD ^= true;
5171489 }
5181490
5191491 void ToggleInertia()
....@@ -674,34 +1646,6 @@
6741646 lightCamera = cam;
6751647 }
6761648
677
- CameraPane(Object3D o, Camera cam, boolean withcontext)
678
- {
679
- super(defaultcaps, null, withcontext?glcontext:null, null);
680
-
681
- //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
682
- glcontext = getContext();
683
-
684
- cameras = new Camera[2];
685
- targetLookAts = new cVector[2];
686
-
687
- SetCamera(cam);
688
-
689
- SetLight(new Camera(new cVector(10, 10, -20)));
690
-
691
- object = o;
692
-
693
- setBackground(Color.white);
694
-
695
- addKeyListener(this);
696
- addMouseListener(this);
697
- addMouseMotionListener(this);
698
- addMouseWheelListener(this);
699
- //System.out.println("addGLEventListener: " + this);
700
- addGLEventListener(this);
701
-
702
-// pingthread.start(); // may 2013
703
- }
704
-
7051649 private static void ApplyTransform(GL gl, Mat4f xform)
7061650 {
7071651 float[] data = new float[16];
....@@ -759,7 +1703,7 @@
7591703
7601704 GL currentGL;
7611705
762
- GL GetGL()
1706
+ public GL GetGL() // INTERFACE
7631707 {
7641708 return currentGL;
7651709 }
....@@ -768,6 +1712,8 @@
7681712 class CacheTexture
7691713 {
7701714 com.sun.opengl.util.texture.Texture texture;
1715
+ com.sun.opengl.util.texture.TextureData texturedata;
1716
+
7711717 int resolution;
7721718
7731719 CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
....@@ -1998,10 +2944,12 @@
19982944 */
19992945 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20002946 {
2947
+ int pixelformat = texturedata.getPixelFormat();
2948
+
20012949 int stride = 1;
2002
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
2950
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20032951 stride = 3;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
2952
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20052953 stride = 4;
20062954
20072955 int width = texturedata.getWidth();
....@@ -6267,7 +7215,7 @@
62677215 return null;
62687216 }
62697217
6270
- void ReleaseTextures(cTexture tex)
7218
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62717219 {
62727220 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62737221 {
....@@ -6305,7 +7253,7 @@
63057253
63067254 void ReleaseTexture(String tex, boolean bump)
63077255 {
6308
- if (// drawMode != 0 || /*tex == null ||*/
7256
+ if (// DrawMode() != 0 || /*tex == null ||*/
63097257 ambientOcclusion ) // || !textureon)
63107258 {
63117259 return;
....@@ -6331,7 +7279,7 @@
63317279 {
63327280 bumpdepth--;
63337281
6334
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7282
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63357283 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63367284 {
63377285 // assert (bumpstack[bumpdepth] == texture);
....@@ -6361,7 +7309,7 @@
63617309 {
63627310 pigmentdepth--;
63637311
6364
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7312
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63657313 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63667314 {
63677315 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6406,9 +7354,9 @@
64067354 }
64077355 }
64087356
6409
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7357
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64107358 {
6411
- if (// drawMode != 0 || /*tex == null ||*/
7359
+ if (// DrawMode() != 0 || /*tex == null ||*/
64127360 ambientOcclusion ) // || !textureon)
64137361 {
64147362 return; // false;
....@@ -6451,7 +7399,7 @@
64517399 return; // true;
64527400 }
64537401
6454
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
7402
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
64557403 {
64567404 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64577405
....@@ -6665,6 +7613,8 @@
66657613 thetex.texture.dispose();
66667614 textures.remove(texname);
66677615 }
7616
+
7617
+ texture.texturedata = texturedata;
66687618 textures.put(texname, texture);
66697619
66707620 // newtex = true;
....@@ -6681,18 +7631,32 @@
66817631 }
66827632 }
66837633
7634
+ return texture;
7635
+ }
7636
+
7637
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
7638
+ {
7639
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
7640
+
66847641 if (bump)
66857642 {
6686
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
7643
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66877644 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66887645 }
66897646 else
66907647 {
6691
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
7648
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
66927649 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
66937650 }
66947651
66957652 return texture!=null?texture.texture:null;
7653
+ }
7654
+
7655
+ com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
7656
+ {
7657
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
7658
+
7659
+ return texture!=null?texture.texturedata:null;
66967660 }
66977661
66987662 boolean BindTexture(String tex, boolean bump, int resolution)
....@@ -7292,9 +8256,9 @@
72928256 static boolean occlusionInitialized = false;
72938257 boolean selection = false;
72948258 boolean pointselection = false;
7295
- /*static*/ boolean lighttouched = true;
8259
+ ///*static*/ boolean lighttouched = true;
72968260 boolean deselect;
7297
- boolean ambientOcclusion = false;
8261
+ private boolean ambientOcclusion = false;
72988262 static boolean flash = false;
72998263 /*static*/ boolean wait = false;
73008264 boolean displaydone = false; // after repaint() calls
....@@ -7424,6 +8388,8 @@
74248388 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74258389 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74268390 double scale = lightCamera.SCALE / lightCamera.Distance();
8391
+// PATCH FILLE AUX JEANS
8392
+ //scale *= lightCamera.shaper_fovy / 25;
74278393 gl.glScaled(2 * scale, 2 * scale, -scale);
74288394 gl.glTranslated(0, 0, lightCamera.DECAL);
74298395
....@@ -7572,15 +8538,14 @@
75728538
75738539 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75748540 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
7575
- float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity
8541
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
8542
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75768543
75778544 static int imagecount = 0; // movie generation
75788545
75798546 static int jitter = 0;
75808547
75818548 boolean restartframe = false;
7582
-
7583
- static int framecount = 0; // general-purpose global count
75848549
75858550 void displayAntiAliased(javax.media.opengl.GL gl)
75868551 {
....@@ -7610,14 +8575,14 @@
76108575
76118576 //System.out.println("start frame");
76128577 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7613
- for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0)
8578
+ for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76148579 {
7615
- framecount++;
8580
+ Globals.framecount++;
76168581
76178582 if (CameraPane.tickcount > 0)
76188583 CameraPane.tickcount--;
76198584
7620
-// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
8585
+// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
76218586 // restartframe = true;
76228587 if (options1[2] > 100 && (jitter%2==0))
76238588 {
....@@ -7650,7 +8615,7 @@
76508615
76518616 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76528617 */
7653
- lighttouched = true;
8618
+ Globals.lighttouched = true;
76548619 //System.err.println(" shadowbuffer: " + jitter);
76558620 shadowbuffer.display();
76568621
....@@ -7672,7 +8637,7 @@
76728637
76738638 if (renderCamera != lightCamera)
76748639 for (int count = parentcam.GetTransformCount(); --count>=0;)
7675
- LA.matConcat(parentcam.toParent, matrix, matrix);
8640
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76768641
76778642 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76788643
....@@ -7688,7 +8653,7 @@
76888653
76898654 if (renderCamera != lightCamera)
76908655 for (int count = parentcam.GetTransformCount(); --count>=0;)
7691
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8656
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
76928657
76938658 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
76948659
....@@ -7905,7 +8870,7 @@
79058870
79068871 if (!BOXMODE)
79078872 {
7908
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
8873
+ System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
79098874 }
79108875
79118876 if (!BOXMODE)
....@@ -7933,7 +8898,7 @@
79338898 {
79348899 if (ACSIZE > 1)
79358900 {
7936
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
8901
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79378902 }
79388903 }
79398904
....@@ -7943,7 +8908,7 @@
79438908 ABORTED = false;
79448909 }
79458910 else
7946
- GraphreeD.wav.cursor += 735 * ACSIZE;
8911
+ GrafreeD.wav.cursor += 735 * ACSIZE;
79478912
79488913 if (false)
79498914 {
....@@ -8597,13 +9562,6 @@
85979562 }
85989563 }
85999564
8600
- boolean IsFrozen()
8601
- {
8602
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8603
-
8604
- return !selectmode && cameracount == 0; // != 0;
8605
- }
8606
-
86079565 boolean niceon = false;
86089566 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86099567 boolean currentlydrawing = false;
....@@ -8613,16 +9571,16 @@
86139571
86149572 public void display(GLAutoDrawable drawable)
86159573 {
8616
- if (GraphreeD.savesound && GraphreeD.hassound)
9574
+ if (GrafreeD.savesound && GrafreeD.hassound)
86179575 {
8618
- GraphreeD.wav.save();
8619
- GraphreeD.savesound = false;
8620
- GraphreeD.hassound = false;
9576
+ GrafreeD.wav.save();
9577
+ GrafreeD.savesound = false;
9578
+ GrafreeD.hassound = false;
86219579 }
86229580 // if (DEBUG_SELECTION)
86239581 // {
8624
-// if (drawMode != SELECTION)
8625
-// drawMode = SELECTION;
9582
+// if (DrawMode() != SELECTION)
9583
+// DrawMode() = SELECTION;
86269584 // }
86279585
86289586 if (!isRenderer)
....@@ -8678,9 +9636,9 @@
86789636
86799637 //ANTIALIAS = 0;
86809638
8681
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9639
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
86829640 {
8683
- if (niceon || isLIVE())
9641
+ if (niceon || Globals.isLIVE())
86849642 {
86859643 //if(active == 0)
86869644 // antialiaser = null;
....@@ -8705,7 +9663,7 @@
87059663 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87069664 */
87079665
8708
- if (drawMode == DEFAULT)
9666
+ if (DrawMode() == DEFAULT)
87099667 {
87109668 currentlydrawing = true;
87119669 }
....@@ -8736,18 +9694,18 @@
87369694
87379695 // if(Applet3D.clipboard != null)
87389696 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8739
-//drawMode = SELECTION;
9697
+//DrawMode() = SELECTION;
87409698 indexcount = 0;
87419699
8742
- if (drawMode == OCCLUSION)
9700
+ if (DrawMode() == OCCLUSION)
87439701 {
8744
- drawMode = DEFAULT;
9702
+ Globals.drawMode = DEFAULT; // WARNING
87459703 ambientOcclusion = true;
87469704 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
87479705 Object3D theobject = object;
87489706 Object3D theparent = object.parent;
87499707 object.parent = null;
8750
- object = (Object3D)GraphreeD.clone(object);
9708
+ object = (Object3D)GrafreeD.clone(object);
87519709 object.Stripify();
87529710 if (theobject.selection == null || theobject.selection.Size() == 0)
87539711 theobject.PreprocessOcclusion(this);
....@@ -8760,19 +9718,19 @@
87609718 ambientOcclusion = false;
87619719 }
87629720
8763
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
9721
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
87649722 {
87659723 //if (RENDERSHADOW) // ?
87669724 if (!IsFrozen())
87679725 {
87689726 // dec 2012
8769
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
9727
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
87709728 {
8771
- framecount++;
9729
+ Globals.framecount++;
87729730 shadowbuffer.display();
87739731 }
87749732 }
8775
- lighttouched = false; // ??
9733
+ Globals.lighttouched = false; // ??
87769734 //drawing = true;
87779735 //lighttouched = true;
87789736 }
....@@ -8793,9 +9751,9 @@
87939751 //eyeCamera.shaper_fovy = 1;
87949752 }
87959753
8796
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
9754
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
87979755 {
8798
- //System.out.println("drawMode = " + drawMode);
9756
+ //System.out.println("DrawMode() = " + DrawMode());
87999757 vertexMode |= VP_PASS;
88009758 //vertexMode |= VP_PROJECTION;
88019759 if (!ambientOcclusion)
....@@ -8855,7 +9813,7 @@
88559813 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
88569814 //Camera lightcam = new Camera(light0);
88579815
8858
- if (drawMode == SHADOW)
9816
+ if (DrawMode() == SHADOW)
88599817 {
88609818 /*
88619819 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8894,7 +9852,7 @@
88949852 // if (parentcam != renderCamera) // not a light
88959853 if (cam != lightCamera)
88969854 for (int count = parentcam.GetTransformCount(); --count>=0;)
8897
- LA.matConcat(parentcam.toParent, matrix, matrix);
9855
+ LA.matConcat(matrix, parentcam.toParent, matrix);
88989856
88999857 for (int j = 0; j < 4; j++)
89009858 {
....@@ -8909,7 +9867,7 @@
89099867 // if (parentcam != renderCamera) // not a light
89109868 if (cam != lightCamera)
89119869 for (int count = parentcam.GetTransformCount(); --count>=0;)
8912
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9870
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
89139871
89149872 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
89159873
....@@ -8945,7 +9903,7 @@
89459903 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
89469904 } else
89479905 {
8948
- if (drawMode != DEFAULT)
9906
+ if (DrawMode() != DEFAULT)
89499907 {
89509908 gl.glClearColor(1, 1, 1, 0);
89519909 } // 1);
....@@ -9010,7 +9968,7 @@
90109968
90119969 fast &= !ambientOcclusion;
90129970
9013
- if (drawMode == DEFAULT)
9971
+ if (DrawMode() == DEFAULT)
90149972 {
90159973 //gl.glEnable(gl.GL_ALPHA_TEST);
90169974 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9071,6 +10029,8 @@
907110029 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
907210030 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
907310031 double scale = lightCamera.SCALE / lightCamera.Distance();
10032
+// PATCH FILLE AUX JEANS
10033
+ //scale *= lightCamera.shaper_fovy / 25;
907410034 gl.glScaled(2 * scale, 2 * scale, -scale);
907510035 gl.glTranslated(0, 0, lightCamera.DECAL);
907610036
....@@ -9206,10 +10166,12 @@
920610166 gl.glMatrixMode(gl.GL_PROJECTION);
920710167 gl.glLoadIdentity();
920810168
9209
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10169
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
921010170 {
921110171 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
921210172 double scale = lightCamera.SCALE / lightCamera.Distance();
10173
+// PATCH FILLE AUX JEANS
10174
+ //scale *= lightCamera.shaper_fovy / 25;
921310175 gl.glScaled(2 * scale, 2 * scale, -scale);
921410176 gl.glTranslated(0, 0, lightCamera.DECAL);
921510177 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9262,7 +10224,7 @@
926210224 //gl.glPushMatrix();
926310225 gl.glLoadIdentity();
926410226
9265
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10227
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
926610228 {
926710229 //LA.xformPos(light0, lightCamera.fromScreen, light);
926810230 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9349,7 +10311,7 @@
934910311 }
935010312
935110313 /**/
9352
- if (true) // drawMode == SELECTION) // != DEFAULT)
10314
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
935310315 gl.glDisable(gl.GL_LIGHTING);
935410316 else
935510317 gl.glEnable(gl.GL_LIGHTING);
....@@ -9361,12 +10323,13 @@
936110323
936210324 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
936310325 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
10326
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
936410327
936510328 options2[0] *= renderCamera.Distance();
936610329
936710330 lightslot = 64;
936810331
9369
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10332
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
937010333 {
937110334 DrawLights(object);
937210335 }
....@@ -9377,7 +10340,7 @@
937710340 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
937810341 //System.out.println("fragmentMode = " + fragmentMode);
937910342
9380
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10343
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
938110344 {
938210345 /*
938310346 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9410,7 +10373,7 @@
941010373 }
941110374 }
941210375
9413
- if (drawMode == DEFAULT)
10376
+ if (DrawMode() == DEFAULT)
941410377 {
941510378 if (WIREFRAME && !ambientOcclusion)
941610379 {
....@@ -9428,7 +10391,7 @@
942810391 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
942910392 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
943010393
9431
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10394
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
943210395 {
943310396 if (vertexMode != 0) // && !fast)
943410397 {
....@@ -9448,7 +10411,7 @@
944810411 }
944910412 }
945010413
9451
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10414
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
945210415 {
945310416 //gl.glDepthFunc(GL.GL_LEQUAL);
945410417 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9476,7 +10439,7 @@
947610439 //gl.glDepthMask(false);
947710440 }
947810441
9479
- if (false) // drawMode == SHADOW)
10442
+ if (false) // DrawMode() == SHADOW)
948010443 {
948110444 //SetColumnMajorData(cameraInverseTransform, view_1);
948210445 //System.out.println("light = " + cameraInverseTransform);
....@@ -9490,16 +10453,16 @@
949010453 //System.out.println("object = " + object);
949110454 if (!frozen && !imageLocked)
949210455 {
9493
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10456
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
949410457 {
949510458 displayAntiAliased(gl);
949610459 } else
949710460 {
949810461 programcount = 0;
9499
- int keepmode = drawMode;
10462
+ int keepmode = DrawMode();
950010463 // if (DEBUG_SELECTION)
950110464 // {
9502
-// drawMode = SELECTION;
10465
+// DrawMode() = SELECTION;
950310466 // }
950410467 // for point selection
950510468 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9509,10 +10472,10 @@
950910472 DrawObject(gl);
951010473
951110474 // jan 2013 System.err.println("RESET ABORT (display)");
9512
- // if (drawMode == DEFAULT)
10475
+ // if (DrawMode() == DEFAULT)
951310476 // ABORTED = false;
951410477 fullreset = false;
9515
- drawMode = keepmode;
10478
+ Globals.drawMode = keepmode; // WARNING
951610479 //System.out.println("PROGRAM SWITCH " + programcount);
951710480 }
951810481 }
....@@ -9520,11 +10483,11 @@
952010483 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
952110484 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
952210485
9523
- if (drawMode == DEFAULT)
10486
+ if (DrawMode() == DEFAULT)
952410487 {
952510488 ReleaseTexture(NOISE_TEXTURE, false);
952610489 }
9527
- //if (drawMode == DEFAULT)
10490
+ //if (DrawMode() == DEFAULT)
952810491 {
952910492
953010493 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9536,7 +10499,7 @@
953610499 //else
953710500 //gl.glDisable(gl.GL_TEXTURE_2D);
953810501 //gl.glPopMatrix();
9539
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10502
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
954010503 {
954110504 //new Exception().printStackTrace();
954210505 //System.out.println("Draw image " + width + ", " + height);
....@@ -9578,7 +10541,7 @@
957810541 //gl.glFlush();
957910542 }
958010543
9581
- if (flash && drawMode == DEFAULT)
10544
+ if (flash && DrawMode() == DEFAULT)
958210545 {
958310546 flash = false;
958410547 wait = true;
....@@ -9586,9 +10549,9 @@
958610549 }
958710550
958810551 //drawing = false;
9589
- //if(drawMode == DEFAULT)
10552
+ //if(DrawMode() == DEFAULT)
959010553 // niceon = false;
9591
- if (drawMode == DEFAULT)
10554
+ if (DrawMode() == DEFAULT)
959210555 {
959310556 currentlydrawing = false;
959410557 }
....@@ -9608,7 +10571,7 @@
960810571 repaint();
960910572 }
961010573
9611
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10574
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
961210575 repaint();
961310576
961410577 displaydone = true;
....@@ -9642,10 +10605,10 @@
964210605 e.printStackTrace();
964310606 }
964410607
9645
- if (GraphreeD.RENDERME > 0)
9646
- GraphreeD.RENDERME--; // mechante magouille
10608
+ if (GrafreeD.RENDERME > 0)
10609
+ GrafreeD.RENDERME--; // mechante magouille
964710610
9648
- ONESTEP = false;
10611
+ Globals.ONESTEP = false;
964910612 }
965010613
965110614 static boolean zoomonce = false;
....@@ -9653,11 +10616,11 @@
965310616 void DrawObject(GL gl, boolean draw)
965410617 {
965510618 //System.out.println("DRAW OBJECT " + mouseDown);
9656
-// drawMode = SELECTION;
10619
+// DrawMode() = SELECTION;
965710620 //GL gl = getGL();
965810621 if ((TRACK || SHADOWTRACK) || zoomonce)
965910622 {
9660
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10623
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
966110624 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
966210625 pingthread.StepToTarget(true); // true);
966310626 // zoomonce = false;
....@@ -9678,9 +10641,9 @@
967810641 callist = gl.glGenLists(1);
967910642 }
968010643
9681
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10644
+ boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
968210645
9683
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10646
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
968410647
968510648 if (!mainDL || !active || touched)
968610649 {
....@@ -9707,7 +10670,7 @@
970710670 PushMatrix(ClickInfo.matbuffer);
970810671 }
970910672
9710
- if (drawMode == 0)
10673
+ if (DrawMode() == 0)
971110674 {
971210675 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
971310676
....@@ -9716,12 +10679,12 @@
971610679 BindTextures(DEFAULT_TEXTURES, 2);
971710680 }
971810681 //System.out.println("--> " + stackdepth);
9719
-// GraphreeD.traceon();
10682
+// GrafreeD.traceon();
972010683
972110684 // DRAW
972210685 object.draw(this, /*(Composite)*/ object, false, false);
972310686
9724
- if (drawMode == DEFAULT)
10687
+ if (DrawMode() == DEFAULT)
972510688 {
972610689 if (DEBUG)
972710690 {
....@@ -9732,34 +10695,48 @@
973210695 selectedpoint.radius = radius;
973310696 selectedpoint.recalculate();
973410697 selectedpoint.material = new cMaterial();
9735
- selectedpoint.material.color = 0.25f;
10698
+ selectedpoint.material.color = 0.15f; // Yellow
973610699 selectedpoint.material.modulation = 0.75f;
973710700
9738
- debugpoint.radius = radius;
9739
- debugpoint.recalculate();
9740
- debugpoint.material = new cMaterial();
9741
- debugpoint.material.color = 0.25f;
9742
- debugpoint.material.modulation = 0.75f;
10701
+ debugpointG.radius = radius;
10702
+ debugpointG.recalculate();
10703
+ debugpointG.material = new cMaterial();
10704
+ debugpointG.material.color = 0.25f; // Green
10705
+ debugpointG.material.modulation = 0.75f;
974310706
9744
- debugpoint2.radius = radius;
9745
- debugpoint2.recalculate();
9746
- debugpoint2.material = new cMaterial();
9747
- debugpoint2.material.color = 0.75f;
9748
- debugpoint2.material.modulation = 0.75f;
10707
+ debugpointP.radius = radius;
10708
+ debugpointP.recalculate();
10709
+ debugpointP.material = new cMaterial();
10710
+ debugpointP.material.color = 0.75f; // Purple
10711
+ debugpointP.material.modulation = 0.75f;
10712
+
10713
+ debugpointC.radius = radius;
10714
+ debugpointC.recalculate();
10715
+ debugpointC.material = new cMaterial();
10716
+ debugpointC.material.color = 0.5f; // Cyan
10717
+ debugpointC.material.modulation = 0.75f;
10718
+
10719
+ debugpointR.radius = radius;
10720
+ debugpointR.recalculate();
10721
+ debugpointR.material = new cMaterial();
10722
+ debugpointR.material.color = 0f; // Red
10723
+ debugpointR.material.modulation = 0.75f;
974910724
975010725 InitPoints(radius);
975110726 }
975210727 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9753
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9754
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9755
- DrawPoints(this);
10728
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
10729
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
10730
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
10731
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
10732
+ // DrawPoints(this);
975610733 }
975710734
975810735 // debugstuff.draw(this, /*(Composite)*/ null, false);
975910736 }
9760
-// GraphreeD.traceoff();
10737
+// GrafreeD.traceoff();
976110738 //System.out.println(stackdepth);
9762
- if (drawMode == 0)
10739
+ if (DrawMode() == 0)
976310740 {
976410741 ReleaseTextures(DEFAULT_TEXTURES);
976510742
....@@ -9784,17 +10761,19 @@
978410761
978510762 checker = null;
978610763
9787
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
10764
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
978810765 FindChecker(object);
978910766
9790
- if (checker != null && drawMode == DEFAULT)
10767
+ if (checker != null && DrawMode() == DEFAULT)
979110768 {
9792
- // BindTexture(IMMORTAL_TEXTURE);
10769
+ //BindTexture(IMMORTAL_TEXTURE);
10770
+ BindTextures(checker.GetTextures(), checker.texres);
979310771 // NEAREST
979410772 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
979510773 DrawChecker(gl);
979610774 //checker.Draw(this, null, false);
979710775 // ReleaseTexture(IMMORTAL_TEXTURE);
10776
+ ReleaseTextures(checker.GetTextures());
979810777 }
979910778
980010779 if (object.parent != null)
....@@ -9807,7 +10786,7 @@
980710786 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
980810787 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
980910788
9810
- if (DISPLAYTEXT && drawMode == DEFAULT)
10789
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
981110790 {
981210791 // Draw it once, then use the raster
981310792 Balloon(gl, balloon.createGraphics());
....@@ -9863,9 +10842,9 @@
986310842 int[] xs = new int[3];
986410843 int[] ys = new int[3];
986510844
9866
- void DrawString(Object3D obj) // String string)
10845
+ public void DrawString(Object3D obj) // String string) // INTERFACE
986710846 {
9868
- if (!DISPLAYTEXT || drawMode != DEFAULT)
10847
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
986910848 {
987010849 return;
987110850 }
....@@ -10253,7 +11232,7 @@
1025311232 return;
1025411233 }
1025511234
10256
- if (obj instanceof CheckerIG)
11235
+ if (obj instanceof Checker)
1025711236 {
1025811237 checker = obj;
1025911238
....@@ -10325,11 +11304,13 @@
1032511304 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1032611305 "PARAM params7 = program.env[7];" + // noise power, opacity power
1032711306 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10328
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
11307
+ "PARAM options1 = program.env[62];" + // fog rgb color
11308
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1032911309 "PARAM pointlight = program.env[127];" + // ...
1033011310 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1033111311 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1033211312 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
11313
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1033311314 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1033411315 "PARAM ten = { 10, 10, 10, 1.0 };" +
1033511316 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10350,6 +11331,7 @@
1035011331 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1035111332 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1035211333 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11334
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1035311335 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1035411336 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1035511337 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10390,6 +11372,10 @@
1039011372 "TEMP R1;" +
1039111373 "TEMP R2;" +
1039211374 "TEMP R3;" +
11375
+ "TEMP min;" +
11376
+ "TEMP max;" +
11377
+ "TEMP average;" +
11378
+ "TEMP saturation;" +
1039311379 "TEMP keep1;" +
1039411380 "TEMP keep2;" +
1039511381 "TEMP keep3;" +
....@@ -10920,10 +11906,40 @@
1092011906
1092111907 // skin?
1092211908 // Saturation for skin
10923
- /**/ // c'est ici
10924
- (Skinshader? "DP3 temp.x, final,one;" +
11909
+ /**/
11910
+ (Skinshader?
11911
+ "DP3 average.x, final,one;" +
11912
+ "MUL average, one3rd.xxxx,average.xxxx;" +
11913
+
11914
+ "MIN min.x, final.x,final.y;" +
11915
+ "MIN min.x, min.x,final.z;" +
11916
+
11917
+ "MAX max.x, final.x,final.y;" +
11918
+ "MAX max.x, max.x,final.z;" +
11919
+ "MOV max, max.xxxx;" +
11920
+
11921
+ "SUB saturation, max, final;" +
11922
+
11923
+ "ADD temp.x, max.x, one10th.x;" +
11924
+ "RCP temp.x, temp.x;" +
11925
+ "MUL temp.x, temp.x, half.x;" +
11926
+ "MUL saturation, saturation, temp.xxxx;" +
11927
+
11928
+ "DP3 ndotl.x, normald, light;" +
11929
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
11930
+
11931
+ "SUB temp.x, one.x, ndotl.x;" +
11932
+ "ADD temp.x, temp.x, options2.z;" + // lightsheen
11933
+ "ADD temp.y, one.y, options2.y;" + // sursurface
11934
+ "MUL temp.x, temp.x, temp.y;" +
11935
+
11936
+ "MUL saturation, saturation, temp.xxxx;" +
11937
+ "SUB_SAT temp, max, saturation;" +
11938
+/**
11939
+ "DP3 temp.x, final,one;" +
1092511940 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10926
- "SUB temp, final,R2;" +
11941
+ "SUB temp, final, R2;" +
11942
+
1092711943 // using light angle
1092811944 "DP3 ndotl.x, normald,light;" +
1092911945 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10936,7 +11952,6 @@
1093611952 // using light intensity
1093711953 "MOV ndotl.z, R2.x;" +
1093811954 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10939
-
1094011955 // june 2014
1094111956 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1094211957 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10948,6 +11963,7 @@
1094811963 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1094911964
1095011965 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
11966
+/**/
1095111967
1095211968 // "ADD final, R2,temp;" +
1095311969 "MOV final, temp;"
....@@ -11037,7 +12053,7 @@
1103712053 /**/
1103812054 // HDR
1103912055 "MOV temp.z, final.a;" +
11040
- "MUL final, final,options1.w;" +
12056
+ "MUL final, final,options2.x;" +
1104112057 "MOV final.a, temp.z;" +
1104212058 /**/
1104312059
....@@ -11074,10 +12090,17 @@
1107412090 "MOV final.z, zero.x;" +
1107512091 "MOV final.a, one.w;":""
1107612092 ) +
12093
+ /*
1107712094 (NORMALdebug?"MOV final.x, normal.x;" +
1107812095 "MOV final.y, normal.y;" +
1107912096 "MOV final.z, normal.z;" +
1108012097 "MOV final.a, one.w;":""
12098
+ ) +
12099
+ */
12100
+ (NORMALdebug?"SUB final.x, one.x, final.x;" +
12101
+ "SUB final.y, one.x, final.y;" +
12102
+ "SUB final.z, one.x, final.z;" +
12103
+ "MOV final.a, final.a;":""
1108112104 ) +
1108212105 // "MOV final, bumpmap;" +
1108312106 "MOV result.color, final;" +
....@@ -11223,6 +12246,7 @@
1122312246 String Shadow(String depth, String shadow)
1122412247 {
1122512248 return "MAX temp.x, ndotl.x, one64th.x;" +
12249
+ "MIN temp.x, temp.x, ninetenth.x;" +
1122612250 /**/
1122712251 // Sine
1122812252 "MUL temp.y, temp.x, temp.x;" +
....@@ -11847,9 +12871,10 @@
1184712871 return;
1184812872 }
1184912873
12874
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1185012875
1185112876 // TIMER
11852
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
12877
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1185312878 {
1185412879 keepboxmode = BOXMODE;
1185512880 keepsupport = SUPPORT;
....@@ -11978,7 +13003,7 @@
1197813003 // ObjEditor.tweenManager.update(1f / 60f);
1197913004
1198013005 // fev 2014???
11981
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13006
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1198213007 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1198313008 pingthread.StepToTarget(true); // true);
1198413009 }
....@@ -12229,7 +13254,7 @@
1222913254 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1223013255 if (lightMode)
1223113256 {
12232
- lighttouched = true;
13257
+ Globals.lighttouched = true;
1223313258 }
1223413259
1223513260 if (OEILONCE && OEIL)
....@@ -12287,7 +13312,7 @@
1228713312 mouseDown = false;
1228813313 if (lightMode)
1228913314 {
12290
- lighttouched = true;
13315
+ Globals.lighttouched = true;
1229113316 }
1229213317 repaint();
1229313318 alreadypainted = true;
....@@ -12295,7 +13320,7 @@
1229513320 isMoving = false;
1229613321 } //??
1229713322
12298
- if (isLIVE() && !alreadypainted)
13323
+ if (Globals.isLIVE() && !alreadypainted)
1229913324 {
1230013325 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1230113326 repaint();
....@@ -12307,7 +13332,7 @@
1230713332 {
1230813333 if (lightMode)
1230913334 {
12310
- lighttouched = true;
13335
+ Globals.lighttouched = true;
1231113336 }
1231213337 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1231313338 }
....@@ -12550,6 +13575,7 @@
1255013575 {
1255113576 manipCamera.Translate(dx, dy, getWidth());
1255213577 }
13578
+ else
1255313579 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1255413580 {
1255513581 manipCamera.RotateInterest(dx, dy);
....@@ -12560,7 +13586,7 @@
1256013586
1256113587 if (manipCamera == lightCamera)
1256213588 {
12563
- lighttouched = true;
13589
+ Globals.lighttouched = true;
1256413590 }
1256513591 /*
1256613592 switch (mode)
....@@ -12775,13 +13801,15 @@
1277513801 {
1277613802 mouseMode |= ZOOM;
1277713803 }
12778
- if ((modifiers & META) == META)
13804
+
13805
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
13806
+ if (capsLocked || (modifiers & META) == META)
1277913807 {
1278013808 mouseMode |= VR; // BACKFORTH;
1278113809 }
1278213810 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1278313811 {
12784
- mouseMode |= SELECT; // BACKFORTH;
13812
+ mouseMode |= SELECT;
1278513813 }
1278613814 if ((modifiers & COMMAND) == COMMAND)
1278713815 {
....@@ -12789,6 +13817,7 @@
1278913817 }
1279013818 if ((modifiers & SHIFT) == SHIFT || forcetranslate)
1279113819 {
13820
+ mouseMode &= ~VR;
1279213821 mouseMode |= TRANSLATE;
1279313822 }
1279413823 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12945,7 +13974,7 @@
1294513974 case 'B':
1294613975 BRISMOOTH ^= true;
1294713976 SHADOWCULLFACE ^= true;
12948
- lighttouched = true;
13977
+ Globals.lighttouched = true;
1294913978 repaint();
1295013979 break;
1295113980 case 'b':
....@@ -13045,7 +14074,7 @@
1304514074 repaint();
1304614075 break;
1304714076 case 'O':
13048
- drawMode = OCCLUSION;
14077
+ Globals.drawMode = OCCLUSION; // WARNING
1304914078 repaint();
1305014079 break;
1305114080 case 'o':
....@@ -13136,7 +14165,7 @@
1313614165 break;
1313714166 case ' ':
1313814167 lightMode ^= true;
13139
- lighttouched = true;
14168
+ Globals.lighttouched = true;
1314014169 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1314114170 targetLookAt.set(manipCamera.lookAt);
1314214171 repaint();
....@@ -13148,11 +14177,11 @@
1314814177 repaint();
1314914178 break;
1315014179 case 'Z':
13151
- RESIZETEXTURE ^= true;
13152
- break;
14180
+ //RESIZETEXTURE ^= true;
14181
+ //break;
1315314182 case 'z':
1315414183 RENDERSHADOW ^= true;
13155
- lighttouched = true;
14184
+ Globals.lighttouched = true;
1315614185 repaint();
1315714186 break;
1315814187 //case UP:
....@@ -13178,7 +14207,8 @@
1317814207 FlipTransform();
1317914208 break;
1318014209 case ENTER:
13181
- object.editWindow.ScreenFit(); // Edit();
14210
+ // object.editWindow.ScreenFit(); // Edit();
14211
+ ToggleLive();
1318214212 break;
1318314213 case DELETE:
1318414214 ClearSelection();
....@@ -13753,6 +14783,7 @@
1375314783 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1375414784 }
1375514785
14786
+ // To avoid clear.
1375614787 public void update(Graphics g)
1375714788 {
1375814789 paint(g);
....@@ -14355,7 +15386,7 @@
1435515386 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1435615387 gl.glPushMatrix();
1435715388 gl.glLoadIdentity();
14358
- PushMatrix(checker.toParent);
15389
+ //PushMatrix(checker.toParent);
1435915390
1436015391 gl.glMatrixMode(GL.GL_TEXTURE);
1436115392 gl.glPushMatrix();
....@@ -14378,8 +15409,8 @@
1437815409
1437915410 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1438015411
14381
- float step = 0.1666f; //0.25f;
14382
- float stepv = step * 1652 / 998;
15412
+ float step = 2; // 0.1666f; //0.25f;
15413
+ float stepv = 2; // step * 1652 / 998;
1438315414
1438415415 int i0 = 0;
1438515416 /*
....@@ -14415,20 +15446,21 @@
1441515446 /**/
1441615447 //checker.GetMaterial().opacity = 1.1f;
1441715448 ////checker.GetMaterial().ambient = 0.99f;
14418
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14419
- Object3D.selectedstack[Object3D.materialdepth] = false;
14420
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15449
+ materialstack[materialdepth] = checker.material;
15450
+ selectedstack[materialdepth] = false;
15451
+ cStatic.objectstack[materialdepth++] = checker;
1442115452 //System.out.println("material " + material);
1442215453 //Applet3D.tracein(this, selected);
1442315454 vector2buffer = checker.projectedVertices;
1442415455
14425
- checker.GetMaterial().Draw(this, false); // true);
15456
+ //checker.GetMaterial().Draw(this, false); // true);
15457
+ DrawMaterial(checker.GetMaterial(), false); // true);
1442615458
14427
- Object3D.materialdepth -= 1;
14428
- if (Object3D.materialdepth > 0)
15459
+ materialdepth -= 1;
15460
+ if (materialdepth > 0)
1442915461 {
14430
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14431
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
15462
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15463
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1443215464 }
1443315465 //checker.GetMaterial().opacity = 1f;
1443415466 ////checker.GetMaterial().ambient = 1f;
....@@ -14449,15 +15481,27 @@
1444915481
1445015482 //float u = (i+1)/2;
1445115483 //float v = (j+1)/2;
14452
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
15484
+ if (checker.flipV)
15485
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
15486
+ else
15487
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1445315488 gl.glVertex3f(i, j, -0.5f);
1445415489
15490
+ if (checker.flipV)
15491
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
15492
+ else
1445515493 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1445615494 gl.glVertex3f(i + step, j, -0.5f);
1445715495
15496
+ if (checker.flipV)
15497
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
15498
+ else
1445815499 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1445915500 gl.glVertex3f(i + step, j + stepv, -0.5f);
1446015501
15502
+ if (checker.flipV)
15503
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
15504
+ else
1446115505 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1446215506 gl.glVertex3f(i, j + stepv, -0.5f);
1446315507 }
....@@ -14469,7 +15513,7 @@
1446915513 gl.glMatrixMode(GL.GL_PROJECTION);
1447015514 gl.glPopMatrix();
1447115515 gl.glMatrixMode(GL.GL_MODELVIEW);
14472
- PopMatrix(null); // checker.toParent); // null);
15516
+ //PopMatrix(null); // checker.toParent); // null);
1447315517 gl.glPopMatrix();
1447415518 PopTextureMatrix(checker.toParent);
1447515519 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14582,14 +15626,14 @@
1458215626
1458315627 //int tmp = selection_view;
1458415628 //selection_view = -1;
14585
- int temp = drawMode;
14586
- drawMode = SELECTION;
15629
+ int temp = DrawMode();
15630
+ Globals.drawMode = SELECTION; // WARNING
1458715631 indexcount = 0;
1458815632 parent.display(drawable);
1458915633 //selection_view = tmp;
1459015634 //if (temp == SELECTION)
1459115635 // temp = DEFAULT; // patch for selection debug
14592
- drawMode = temp;
15636
+ Globals.drawMode = temp; // WARNING
1459315637
1459415638 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1459515639
....@@ -14639,6 +15683,11 @@
1463915683 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1464015684 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1464115685
15686
+ // Will fit the mesh !!!
15687
+ selectedpoint.toParent[0][0] = 0.0001;
15688
+ selectedpoint.toParent[1][1] = 0.0001;
15689
+ selectedpoint.toParent[2][2] = 0.0001;
15690
+
1464215691 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1464315692
1464415693 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14682,16 +15731,16 @@
1468215731 System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2]));
1468315732 }
1468415733
14685
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
15734
+ previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
1468615735 }
1468715736 }
1468815737
1468915738 if (!movingcamera && !PAINTMODE)
1469015739 object.editWindow.ScreenFitPoint(); // fev 2014
1469115740
14692
- if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
15741
+ if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1469315742 {
14694
- Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
15743
+ Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1469515744
1469615745 Object3D group = new Object3D("inst" + paintcount++);
1469715746
....@@ -14857,14 +15906,14 @@
1485715906 //gl.glColorMask(false, false, false, false);
1485815907
1485915908 //render_scene_from_light_view(gl, drawable, 0, 0);
14860
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
15909
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1486115910 {
1486215911 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1486315912
14864
- int temp = drawMode;
14865
- drawMode = SHADOW;
15913
+ int temp = DrawMode();
15914
+ Globals.drawMode = SHADOW; // WARNING
1486615915 parent.display(drawable);
14867
- drawMode = temp;
15916
+ Globals.drawMode = temp; // WARNING
1486815917 }
1486915918
1487015919 gl.glCullFace(gl.GL_BACK);
....@@ -15027,13 +16076,19 @@
1502716076 gl.glFlush();
1502816077
1502916078 /**/
15030
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16079
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1503116080
15032
- int[] pixels = occlusionsizebuffer.array();
16081
+ float[] pixels = occlusionsizebuffer.array();
1503316082
1503416083 double r = 0, g = 0, b = 0;
1503516084
1503616085 double count = 0;
16086
+
16087
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16088
+
16089
+ float mindepth = 1;
16090
+
16091
+ double FACTOR = 1;
1503716092
1503816093 for (int i = 0; i < pixels.length; i++)
1503916094 {
....@@ -15118,7 +16173,7 @@
1511816173
1511916174 double scale = ray.z; // 1; // cos
1512016175
15121
- int p = pixels[newindex];
16176
+ float depth = pixels[newindex];
1512216177
1512316178 /*
1512416179 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15142,10 +16197,23 @@
1514216197 scale = (1 - modu) * modv;
1514316198 */
1514416199
15145
- r += ((p >> 16) & 0xFF) * scale / 255;
15146
- g += ((p >> 8) & 0xFF) * scale / 255;
15147
- b += (p & 0xFF) * scale / 255;
16200
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16201
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16202
+ //b += (p & 0xFF) * scale / 255;
16203
+
16204
+ if (mindepth > depth)
16205
+ {
16206
+ mindepth = depth;
16207
+ }
1514816208
16209
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16210
+
16211
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16212
+
16213
+ r += factor * scale;
16214
+ g += factor * scale;
16215
+ b += factor * scale;
16216
+
1514916217 count += scale;
1515016218 }
1515116219
....@@ -15243,12 +16311,6 @@
1524316311 GLUT glut = new GLUT();
1524416312
1524516313
15246
- static final public int DEFAULT = 0;
15247
- static final public int SELECTION = 1;
15248
- static final public int SHADOW = 2;
15249
- static final public int OCCLUSION = 3;
15250
- static
15251
- public int drawMode = DEFAULT;
1525216314 public boolean spherical = false;
1525316315 static boolean DEBUG_OCCLUSION = false;
1525416316 static boolean DEBUG_SELECTION = false;
....@@ -15261,10 +16323,12 @@
1526116323 int AAbuffersize = 0;
1526216324
1526316325 //double[] selectedpoint = new double[3];
15264
- static Sphere selectedpoint = new Sphere();
16326
+ static Superellipsoid selectedpoint = new Superellipsoid();
1526516327 static Sphere previousselectedpoint = null;
15266
- static Sphere debugpoint = new Sphere();
15267
- static Sphere debugpoint2 = new Sphere();
16328
+ static Sphere debugpointG = new Sphere();
16329
+ static Sphere debugpointP = new Sphere();
16330
+ static Sphere debugpointC = new Sphere();
16331
+ static Sphere debugpointR = new Sphere();
1526816332
1526916333 static Sphere debugpoints[] = new Sphere[8];
1527016334
....@@ -15317,7 +16381,8 @@
1531716381 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1531816382 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1531916383 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15320
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16384
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
16385
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1532116386 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1532216387 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1532316388 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();