Normand Briere
2019-04-24 92e4487d01f910c705211ffb5762a5c96bdd6d8c
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,39 @@
165149 defaultcaps.setAccumBlueBits(16);
166150 defaultcaps.setAccumAlphaBits(16);
167151 }
168
- static CameraPane theRenderer;
169
-
152
+
170153 void SetAsGLRenderer(boolean b)
171154 {
172155 isRenderer = b;
173
- theRenderer = this;
156
+ Globals.theRenderer = this;
157
+ }
158
+
159
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
160
+ {
161
+ super(defaultcaps, null, withcontext?glcontext:null, null);
162
+
163
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
164
+ glcontext = getContext();
165
+
166
+ cameras = new Camera[2];
167
+ targetLookAts = new cVector[2];
168
+
169
+ SetCamera(cam);
170
+
171
+ SetLight(new Camera(new cVector(10, 10, -20)));
172
+
173
+ object = o;
174
+
175
+ setBackground(Color.white);
176
+
177
+ addKeyListener(this);
178
+ addMouseListener(this);
179
+ addMouseMotionListener(this);
180
+ addMouseWheelListener(this);
181
+ //System.out.println("addGLEventListener: " + this);
182
+ addGLEventListener(this);
183
+
184
+// pingthread.start(); // may 2013
174185 }
175186
176187 static boolean AntialiasingEnabled()
....@@ -178,12 +189,48 @@
178189 return CURRENTANTIALIAS > 0;
179190 }
180191
181
- void ClearDepth()
192
+ /// INTERFACE
193
+
194
+ public javax.media.opengl.GL GetGL0()
195
+ {
196
+ return null;
197
+ }
198
+
199
+ public int GenList()
200
+ {
201
+ javax.media.opengl.GL gl = GetGL();
202
+ return gl.glGenLists(1);
203
+ }
204
+
205
+ public void NewList(int id)
206
+ {
207
+ javax.media.opengl.GL gl = GetGL();
208
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
209
+ }
210
+
211
+ public void CallList(int id)
212
+ {
213
+ javax.media.opengl.GL gl = GetGL();
214
+ gl.glCallList(id);
215
+ }
216
+
217
+ public void EndList()
218
+ {
219
+ javax.media.opengl.GL gl = GetGL();
220
+ gl.glEndList();
221
+ }
222
+
223
+ public boolean IsBoxMode()
224
+ {
225
+ return BOXMODE;
226
+ }
227
+
228
+ public void ClearDepth()
182229 {
183230 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184231 }
185232
186
- void DepthTest(boolean depthtest)
233
+ public void DepthTest(boolean depthtest)
187234 {
188235 if (depthtest)
189236 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +238,7 @@
191238 GetGL().glDepthFunc(GL.GL_ALWAYS);
192239 }
193240
194
- void DepthWrite(boolean depthwrite)
241
+ public void DepthWrite(boolean depthwrite)
195242 {
196243 if (depthwrite)
197244 GetGL().glDepthMask(true);
....@@ -199,12 +246,1594 @@
199246 GetGL().glDepthMask(false);
200247 }
201248
202
- void BackFaceCull(boolean bfc)
249
+ public void BackFaceCull(boolean bfc)
203250 {
204251 if (bfc)
205252 GetGL().glEnable(GetGL().GL_CULL_FACE);
206253 else
207254 GetGL().glDisable(GetGL().GL_CULL_FACE);
255
+ }
256
+
257
+ public boolean BackFaceCullMode()
258
+ {
259
+ return this.CULLFACE;
260
+ }
261
+
262
+ public boolean IsAmbientOcclusionOn()
263
+ {
264
+ return this.ambientOcclusion;
265
+ }
266
+
267
+ public boolean IsDebugSelection()
268
+ {
269
+ return DEBUG_SELECTION;
270
+ }
271
+
272
+ public boolean IsFrozen()
273
+ {
274
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
275
+
276
+ return !selectmode && cameracount == 0; // != 0;
277
+ }
278
+
279
+ // Currently in Globals
280
+ public int DrawMode()
281
+ {
282
+ return Globals.DrawMode();
283
+ }
284
+
285
+ public Camera EyeCamera()
286
+ {
287
+ return eyeCamera;
288
+ }
289
+
290
+ public Camera LightCamera()
291
+ {
292
+ return lightCamera;
293
+ }
294
+
295
+ public Camera ManipCamera()
296
+ {
297
+ return manipCamera;
298
+ }
299
+
300
+ public Camera RenderCamera()
301
+ {
302
+ return renderCamera;
303
+ }
304
+
305
+ public Camera[] Cameras()
306
+ {
307
+ return cameras;
308
+ }
309
+
310
+ public void PushMaterial(Object3D obj, boolean selected)
311
+ {
312
+ CameraPane display = this;
313
+ javax.media.opengl.GL gl = display.GetGL();
314
+ cMaterial material = obj.material;
315
+
316
+ if (material != null)
317
+ {
318
+ materialstack[materialdepth] = material;
319
+ selectedstack[materialdepth] = selected;
320
+ cStatic.objectstack[materialdepth++] = obj;
321
+ //System.out.println("material " + material);
322
+ //Applet3D.tracein(this, selected);
323
+ display.vector2buffer = obj.projectedVertices;
324
+ if (obj instanceof Camera)
325
+ {
326
+ display.options1[0] = material.shift;
327
+ //System.out.println("shift " + material.shift);
328
+ display.options1[1] = material.lightarea;
329
+ display.options1[2] = material.shadowbias;
330
+ display.options1[3] = material.aniso;
331
+ display.options1[4] = material.anisoV;
332
+ display.options2[0] = material.opacity;
333
+ display.options2[1] = material.diffuse;
334
+ display.options2[2] = material.factor;
335
+
336
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
337
+ display.options4[0] = material.cameralight/0.2f;
338
+ display.options4[1] = material.subsurface;
339
+ display.options4[2] = material.sheen;
340
+
341
+ // if (display.CURRENTANTIALIAS > 0)
342
+ // display.options3[3] /= 4;
343
+
344
+ /*
345
+ System.out.println("Focus = " + display.options1[0]);
346
+ System.out.println("Aperture = " + display.options1[1]);
347
+ System.out.println("ShadowBlur = " + display.options1[2]);
348
+ System.out.println("Antialiasing = " + display.options1[3]);
349
+ System.out.println("Fog = " + display.options2[0]);
350
+ System.out.println("Intensity = " + display.options2[1]);
351
+ System.out.println("Elevation = " + display.options2[2]);
352
+ /**/
353
+ } else
354
+ {
355
+ DrawMaterial(material, selected);
356
+ }
357
+ } else
358
+ {
359
+ if (selected && CameraPane.flash)
360
+ {
361
+ display.modelParams4[1] = 100;
362
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
363
+ }
364
+ }
365
+ }
366
+
367
+ public void PushMaterial2(Object3D obj, boolean selected)
368
+ {
369
+ CameraPane display = this;
370
+ cMaterial material = obj.material;
371
+
372
+ if (material != null)
373
+ {
374
+ materialstack[materialdepth] = material;
375
+ selectedstack[materialdepth] = selected;
376
+ cStatic.objectstack[materialdepth++] = obj;
377
+ //System.out.println("material " + material);
378
+ //Applet3D.tracein("selected ", selected);
379
+ display.vector2buffer = obj.projectedVertices;
380
+ display.DrawMaterial(material, selected);
381
+ }
382
+ }
383
+
384
+ public void PopMaterial(Object3D obj, boolean selected)
385
+ {
386
+ CameraPane display = this;
387
+ javax.media.opengl.GL gl = display.GetGL();
388
+ cMaterial material = obj.material;
389
+
390
+ //if (parent != null && parent.GetMaterial() != null)
391
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
392
+ if (material != null)
393
+ {
394
+ materialdepth -= 1;
395
+ if (materialdepth > 0)
396
+ {
397
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
398
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
399
+ }
400
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
401
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
402
+ {
403
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
404
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
405
+ }
406
+ }
407
+
408
+ public void PopMaterial2(Object3D obj)
409
+ {
410
+ CameraPane display = this;
411
+ cMaterial material = obj.material;
412
+
413
+ if (material != null)
414
+ {
415
+ materialdepth -= 1;
416
+ if (materialdepth > 0)
417
+ {
418
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
419
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
420
+ }
421
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
422
+ //else
423
+ //material.Draw(display, false);
424
+ }
425
+ }
426
+
427
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
428
+ {
429
+ CameraPane display = this;
430
+
431
+ if (pv.y == -10000 ||
432
+ qv.y == -10000 ||
433
+ rv.y == -10000)
434
+ return;
435
+
436
+// float b = f.nbiterations & 1;
437
+// float g = (f.nbiterations>>1) & 1;
438
+// float r = (f.nbiterations>>2) & 1;
439
+//
440
+// //if (f.weight == 10000)
441
+// //{
442
+// // r = 1; g = b = 0;
443
+// //}
444
+// //else
445
+// //{
446
+// // assert(f.weight < 10000);
447
+// r = g = b = (float)bRep.FaceWeight(f)*100;
448
+// if (r<0)
449
+// assert(r>=0);
450
+// //}
451
+
452
+ javax.media.opengl.GL gl = display.GetGL();
453
+
454
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
455
+
456
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
457
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
458
+ {
459
+ //gl.glBegin(gl.GL_TRIANGLES);
460
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
461
+ if (!hasnorm)
462
+ {
463
+ // System.out.println("FUCK!!");
464
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
465
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
466
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
467
+ LA.vecNormalize(obj.v2);
468
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
469
+ }
470
+
471
+ // P
472
+ float x = (float)pv.x;
473
+ float y = (float)pv.y;
474
+ float z = (float)pv.z;
475
+
476
+ if (hasnorm)
477
+ {
478
+// if (!pv.norm.normalized())
479
+// assert(pv.norm.normalized());
480
+
481
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
482
+ float nx = (float)pv.norm.x;
483
+ float ny = (float)pv.norm.y;
484
+ float nz = (float)pv.norm.z;
485
+
486
+ x += nx * obj.NORMALPUSH;
487
+ y += ny * obj.NORMALPUSH;
488
+ z += nz * obj.NORMALPUSH;
489
+
490
+ gl.glNormal3f(nx, ny, nz);
491
+ }
492
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
493
+ SetColor(obj, pv);
494
+ //gl.glColor4f(r, g, b, 1);
495
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
496
+ if (obj.flipV)
497
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
498
+ else
499
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
500
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
501
+
502
+ gl.glVertex3f(x, y, z);
503
+
504
+ // Q
505
+ x = (float)qv.x;
506
+ y = (float)qv.y;
507
+ z = (float)qv.z;
508
+
509
+// Print(pv);
510
+ if (hasnorm)
511
+ {
512
+// assert(qv.norm.normalized());
513
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
514
+ float nx = (float)qv.norm.x;
515
+ float ny = (float)qv.norm.y;
516
+ float nz = (float)qv.norm.z;
517
+
518
+ x += nx * obj.NORMALPUSH;
519
+ y += ny * obj.NORMALPUSH;
520
+ z += nz * obj.NORMALPUSH;
521
+
522
+ gl.glNormal3f(nx, ny, nz);
523
+ }
524
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
525
+ // boolean locked = false;
526
+ // float eps = 0.1f;
527
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
528
+
529
+ // int dot = 0; //*/ (int)f.dot;
530
+
531
+ // if ((dot&1) == 0)
532
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
533
+
534
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
535
+ if (obj.flipV)
536
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
537
+ else
538
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
539
+ // else
540
+ // {
541
+ // locked = true;
542
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
543
+ // }
544
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
545
+ SetColor(obj, qv);
546
+
547
+ gl.glVertex3f(x, y, z);
548
+ //gl.glColor4f(r, g, b, 1);
549
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
550
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
551
+// Print(qv);
552
+
553
+ // R
554
+ x = (float)rv.x;
555
+ y = (float)rv.y;
556
+ z = (float)rv.z;
557
+
558
+ if (hasnorm)
559
+ {
560
+// assert(rv.norm.normalized());
561
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
562
+ float nx = (float)rv.norm.x;
563
+ float ny = (float)rv.norm.y;
564
+ float nz = (float)rv.norm.z;
565
+
566
+ x += nx * obj.NORMALPUSH;
567
+ y += ny * obj.NORMALPUSH;
568
+ z += nz * obj.NORMALPUSH;
569
+
570
+ gl.glNormal3f(nx, ny, nz);
571
+ }
572
+
573
+ // if ((dot&4) == 0)
574
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
575
+
576
+ // if (wrap || !locked && (dot&8) != 0)
577
+ if (obj.flipV)
578
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
579
+ else
580
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
581
+ // else
582
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
583
+
584
+ // f.dot = dot;
585
+
586
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
587
+ SetColor(obj, rv);
588
+ //gl.glColor4f(r, g, b, 1);
589
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
590
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
591
+ gl.glVertex3f(x, y, z);
592
+// Print(rv);
593
+ //gl.glEnd();
594
+ }
595
+ else
596
+ {
597
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
598
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
599
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
600
+
601
+ }
602
+
603
+ if (false) // (attributes & WIREFRAME) != 0)
604
+ {
605
+ gl.glDisable(gl.GL_LIGHTING);
606
+
607
+ gl.glBegin(gl.GL_LINE_LOOP);
608
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
609
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
610
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
611
+ gl.glEnd();
612
+
613
+ gl.glEnable(gl.GL_LIGHTING);
614
+ }
615
+ }
616
+
617
+ /**
618
+ * <code>draw</code> renders a <code>TriMesh</code> object including
619
+ * it's normals, colors, textures and vertices.
620
+ *
621
+ * @see Renderer#draw(TriMesh)
622
+ * @param tris
623
+ * the mesh to render.
624
+ */
625
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
626
+ {
627
+ CameraPane display = this;
628
+
629
+ float r = display.modelParams0[0];
630
+ float g = display.modelParams0[1];
631
+ float b = display.modelParams0[2];
632
+ float opacity = display.modelParams5[1];
633
+
634
+ //final GL gl = GLU.getCurrentGL();
635
+ GL gl = display.GetGL(); // getGL();
636
+
637
+ FloatBuffer vertBuf = geo.vertBuf;
638
+
639
+ int v = vertBuf.capacity();
640
+
641
+ int count = 0;
642
+
643
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
644
+ gl.glEnable(gl.GL_CULL_FACE);
645
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
646
+ for (int i=0; i<v/3; i++)
647
+ {
648
+ int index3 = i*3;
649
+
650
+ if (geo.sizeBuf.get(index3+1) == 0)
651
+ continue;
652
+
653
+ count++;
654
+
655
+ int index4 = i*4;
656
+
657
+ float tx = vertBuf.get(index3);
658
+ float ty = vertBuf.get(index3+1);
659
+ float tz = vertBuf.get(index3+2);
660
+
661
+ // if (tx == 0 && ty == 0 && tz == 0)
662
+ // continue;
663
+
664
+ gl.glMatrixMode(gl.GL_TEXTURE);
665
+ gl.glPushMatrix();
666
+
667
+ float[] texmat = geo.texmat;
668
+ texmat[12] = texmat[13] = texmat[14] = i;
669
+
670
+ gl.glMultMatrixf(texmat, 0);
671
+
672
+ gl.glMatrixMode(gl.GL_MODELVIEW);
673
+ gl.glPushMatrix();
674
+
675
+ gl.glTranslatef(tx,ty,tz);
676
+
677
+ if (rotate)
678
+ gl.glRotatef(i, 0, 1, 0);
679
+
680
+ float size = geo.sizeBuf.get(index3) / 100;
681
+ gl.glScalef(size,size,size);
682
+
683
+ float cr = geo.colorBuf.get(index4);
684
+ float cg = geo.colorBuf.get(index4+1);
685
+ float cb = geo.colorBuf.get(index4+2);
686
+ float ca = geo.colorBuf.get(index4+3);
687
+
688
+ display.modelParams0[0] = r * cr;
689
+ display.modelParams0[1] = g * cg;
690
+ display.modelParams0[2] = b * cb;
691
+
692
+ display.modelParams5[1] = opacity * ca;
693
+
694
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
695
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
696
+
697
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
698
+ RandomNode.globalseed2 = RandomNode.globalseed;
699
+
700
+// gl.glColor4f(cr,cg,cb,ca);
701
+ // gl.glScalef(1024/16,1024/16,1024/16);
702
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
703
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
704
+ //gl.glTranslatef(-tx,-ty,-tz);
705
+ gl.glPopMatrix();
706
+
707
+ gl.glMatrixMode(gl.GL_TEXTURE);
708
+ gl.glPopMatrix();
709
+ }
710
+ // gl.glScalef(1024,1024,1024);
711
+ if (!cf)
712
+ gl.glDisable(gl.GL_CULL_FACE);
713
+
714
+ display.modelParams0[0] = r;
715
+ display.modelParams0[1] = g;
716
+ display.modelParams0[2] = b;
717
+
718
+ display.modelParams5[1] = opacity;
719
+
720
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
721
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
722
+
723
+ gl.glMatrixMode(gl.GL_MODELVIEW);
724
+
725
+// System.err.println("total = " + v/3 + "; displayed = " + count);
726
+ if (true)
727
+ return;
728
+
729
+//// if (!tris.predraw(this))
730
+//// {
731
+//// return;
732
+//// }
733
+//// if (Debug.stats)
734
+//// {
735
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
736
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
737
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
738
+//// }
739
+////
740
+//// if (tris.getDisplayListID() != -1)
741
+//// {
742
+//// renderDisplayList(tris);
743
+//// return;
744
+//// }
745
+////
746
+//// if (!generatingDisplayList)
747
+//// {
748
+//// applyStates(tris.states, tris);
749
+//// }
750
+//// if (Debug.stats)
751
+//// {
752
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
753
+//// }
754
+//// boolean transformed = doTransforms(tris);
755
+//
756
+// int glMode = GL.GL_TRIANGLES;
757
+// switch (getMode())
758
+// {
759
+// case Triangles:
760
+// glMode = GL.GL_TRIANGLES;
761
+// break;
762
+// case Strip:
763
+// glMode = GL.GL_TRIANGLE_STRIP;
764
+// break;
765
+// case Fan:
766
+// glMode = GL.GL_TRIANGLE_FAN;
767
+// break;
768
+// }
769
+//
770
+// if (!predrawGeometry(gl))
771
+// {
772
+// // make sure only the necessary indices are sent through on old
773
+// // cards.
774
+// IntBuffer indices = this.getIndexBuffer();
775
+// if (indices == null)
776
+// {
777
+// logger.severe("missing indices on geometry object: " + this.toString());
778
+// } else
779
+// {
780
+// indices.rewind();
781
+// indices.limit(this.getMaxIndex());
782
+//
783
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
784
+//
785
+// indices.clear();
786
+// }
787
+// } else
788
+// {
789
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
790
+// GL.GL_UNSIGNED_INT, 0);
791
+// }
792
+//
793
+//// postdrawGeometry(tris);
794
+//// if (transformed)
795
+//// {
796
+//// undoTransforms(tris);
797
+//// }
798
+////
799
+//// if (Debug.stats)
800
+//// {
801
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
802
+//// }
803
+//// tris.postdraw(this);
804
+ }
805
+
806
+ static Camera localcamera = new Camera();
807
+ static cVector from = new cVector();
808
+ static cVector to = new cVector();
809
+
810
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
811
+ {
812
+ CameraPane cp = this;
813
+
814
+ Camera keep = cp.RenderCamera();
815
+ cp.renderCamera = localcamera;
816
+
817
+ if (br.trimmed)
818
+ {
819
+ float[] colors = new float[br.positions.length / 3];
820
+
821
+ int i3 = 0;
822
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
823
+ {
824
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
825
+ continue;
826
+
827
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
828
+ to.set(br.positions[i3] + br.normals[i3],
829
+ br.positions[i3 + 1] + br.normals[i3 + 1],
830
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
831
+ LA.xformPos(from, transform, from);
832
+ LA.xformPos(to, transform, to); // RIGID ONLY
833
+ localcamera.setAim(from, to);
834
+
835
+ CameraPane.occlusionbuffer.display();
836
+
837
+ if (CameraPane.DEBUG_OCCLUSION)
838
+ cp.display(); // debug
839
+
840
+ colors[i] = cp.vertexOcclusion.r;
841
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
842
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
843
+
844
+ if ((i % 100) == 0 && i != 0)
845
+ {
846
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
847
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
848
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
849
+ }
850
+ }
851
+
852
+ br.colors = colors;
853
+ }
854
+ else
855
+ {
856
+ for (int i = 0; i < br.VertexCount(); i++)
857
+ {
858
+ Vertex v = br.GetVertex(i);
859
+
860
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
861
+ continue;
862
+
863
+ from.set(v.x, v.y, v.z);
864
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
865
+ LA.xformPos(from, transform, from);
866
+ LA.xformPos(to, transform, to); // RIGID ONLY
867
+ localcamera.setAim(from, to);
868
+
869
+ CameraPane.occlusionbuffer.display();
870
+
871
+ if (CameraPane.DEBUG_OCCLUSION)
872
+ cp.display(); // debug
873
+
874
+ v.AO = cp.vertexOcclusion.r;
875
+
876
+ if ((i % 100) == 0 && i != 0)
877
+ {
878
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
879
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
880
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
881
+ }
882
+ }
883
+ }
884
+
885
+ //System.out.println("done.");
886
+
887
+ cp.renderCamera = keep;
888
+ }
889
+
890
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
891
+ {
892
+ CameraPane display = this;
893
+ pointFlow.CreateHT();
894
+
895
+ float r = display.modelParams0[0];
896
+ float g = display.modelParams0[1];
897
+ float b = display.modelParams0[2];
898
+ float opacity = display.modelParams5[1];
899
+
900
+ //final GL gl = GLU.getCurrentGL();
901
+ GL gl = display.GetGL(); // getGL();
902
+
903
+ int s = pointFlow.points.size();
904
+
905
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
906
+ gl.glEnable(gl.GL_CULL_FACE);
907
+
908
+ for (int i=s; --i>=0;)
909
+ //for (int i=0; i<s; i++)
910
+ {
911
+ cVector v = pointFlow.points.get(i);
912
+
913
+ double mindist = Double.MAX_VALUE;
914
+
915
+ double size = pointFlow.minimumSize;
916
+
917
+ double distancenext = 0;
918
+
919
+ if (i > 0)
920
+ {
921
+ cVector w = pointFlow.points.get(i-1);
922
+
923
+ double dist = w.distance(v);
924
+
925
+ distancenext = dist;
926
+
927
+ if (mindist > dist)
928
+ {
929
+ mindist = dist;
930
+ size = mindist*pointFlow.resizefactor;
931
+ }
932
+ }
933
+
934
+ if (i < s-1)
935
+ {
936
+ cVector w = pointFlow.points.get(i+1);
937
+
938
+ double dist = w.distance(v);
939
+
940
+ if (mindist > dist)
941
+ {
942
+ mindist = dist;
943
+ size = mindist*pointFlow.resizefactor;
944
+ }
945
+ }
946
+
947
+ if (size < pointFlow.minimumSize)
948
+ size = pointFlow.minimumSize;
949
+ if (size > pointFlow.maximumSize)
950
+ size = pointFlow.maximumSize;
951
+
952
+ double tx = v.x;
953
+ double ty = v.y;
954
+ double tz = v.z;
955
+
956
+ // if (tx == 0 && ty == 0 && tz == 0)
957
+ // continue;
958
+
959
+ gl.glMatrixMode(gl.GL_TEXTURE);
960
+ gl.glPushMatrix();
961
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
962
+
963
+ gl.glMultMatrixf(pointFlow.texmat, 0);
964
+
965
+ gl.glMatrixMode(gl.GL_MODELVIEW);
966
+ gl.glPushMatrix();
967
+
968
+ gl.glTranslated(tx,ty,tz);
969
+
970
+ gl.glScaled(size,size,size);
971
+
972
+// float cr = colorBuf.get(index4);
973
+// float cg = colorBuf.get(index4+1);
974
+// float cb = colorBuf.get(index4+2);
975
+// float ca = colorBuf.get(index4+3);
976
+//
977
+// display.modelParams0[0] = r * cr;
978
+// display.modelParams0[1] = g * cg;
979
+// display.modelParams0[2] = b * cb;
980
+//
981
+// display.modelParams5[1] = opacity * ca;
982
+//
983
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
984
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
985
+//
986
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
987
+// RandomNode.globalseed2 = RandomNode.globalseed;
988
+//
989
+//// gl.glColor4f(cr,cg,cb,ca);
990
+// // gl.glScalef(1024/16,1024/16,1024/16);
991
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
992
+
993
+ gl.glPopMatrix();
994
+
995
+ double step = size/4; //
996
+
997
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
998
+ continue;
999
+
1000
+ int nbsteps = (int)(distancenext/step);
1001
+
1002
+ step = distancenext/nbsteps;
1003
+
1004
+ cVector next = pointFlow.points.get(i-1);
1005
+
1006
+ tmp.set(next);
1007
+ tmp.sub(v);
1008
+ tmp.normalize();
1009
+ tmp.mul(step);
1010
+
1011
+ // calculate next size
1012
+ mindist = Double.MAX_VALUE;
1013
+
1014
+ double nextsize = pointFlow.minimumSize;
1015
+
1016
+ if (i > 1)
1017
+ {
1018
+ cVector w = pointFlow.points.get(i-2);
1019
+
1020
+ double dist = w.distance(next);
1021
+
1022
+ if (mindist > dist)
1023
+ {
1024
+ mindist = dist;
1025
+ nextsize = mindist*pointFlow.resizefactor;
1026
+ }
1027
+ }
1028
+
1029
+ double dist = v.distance(next);
1030
+
1031
+ if (mindist > dist)
1032
+ {
1033
+ mindist = dist;
1034
+ nextsize = mindist*pointFlow.resizefactor;
1035
+ }
1036
+
1037
+ if (nextsize < pointFlow.minimumSize)
1038
+ nextsize = pointFlow.minimumSize;
1039
+ if (nextsize > pointFlow.maximumSize)
1040
+ nextsize = pointFlow.maximumSize;
1041
+ //
1042
+
1043
+ double count = 0;
1044
+
1045
+ while (distancenext > 0.000000001) // step
1046
+ {
1047
+ gl.glPushMatrix();
1048
+
1049
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1050
+
1051
+ double K = count/nbsteps;
1052
+
1053
+ double intersize = K*nextsize + (1-K)*size;
1054
+
1055
+ gl.glScaled(intersize,intersize,intersize);
1056
+
1057
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1058
+
1059
+ count++;
1060
+
1061
+ distancenext -= step;
1062
+
1063
+ gl.glPopMatrix();
1064
+ }
1065
+
1066
+ if (count != nbsteps)
1067
+ assert(count == nbsteps);
1068
+
1069
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1070
+ //gl.glTranslatef(-tx,-ty,-tz);
1071
+
1072
+ gl.glMatrixMode(gl.GL_TEXTURE);
1073
+ gl.glPopMatrix();
1074
+ }
1075
+
1076
+ if (!cf)
1077
+ gl.glDisable(gl.GL_CULL_FACE);
1078
+
1079
+// display.modelParams0[0] = r;
1080
+// display.modelParams0[1] = g;
1081
+// display.modelParams0[2] = b;
1082
+//
1083
+// display.modelParams5[1] = opacity;
1084
+//
1085
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1086
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1087
+
1088
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1089
+ }
1090
+
1091
+ public void DrawBox(cVector min, cVector max)
1092
+ {
1093
+ javax.media.opengl.GL gl = GetGL();
1094
+ gl.glBegin(gl.GL_LINES);
1095
+
1096
+ gl.glVertex3d(min.x, min.y, min.z);
1097
+ gl.glVertex3d(min.x, min.y, max.z);
1098
+ gl.glVertex3d(min.x, min.y, min.z);
1099
+ gl.glVertex3d(min.x, max.y, min.z);
1100
+ gl.glVertex3d(min.x, min.y, min.z);
1101
+ gl.glVertex3d(max.x, min.y, min.z);
1102
+
1103
+ gl.glVertex3d(max.x, max.y, max.z);
1104
+ gl.glVertex3d(min.x, max.y, max.z);
1105
+ gl.glVertex3d(max.x, max.y, max.z);
1106
+ gl.glVertex3d(max.x, min.y, max.z);
1107
+ gl.glVertex3d(max.x, max.y, max.z);
1108
+ gl.glVertex3d(max.x, max.y, min.z);
1109
+
1110
+ gl.glEnd();
1111
+ }
1112
+
1113
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1114
+ {
1115
+ int[] strips = bRep.getRawIndices();
1116
+
1117
+ javax.media.opengl.GL gl = GetGL();
1118
+
1119
+ // TRIANGLE STRIP ARRAY
1120
+ if (bRep.trimmed)
1121
+ {
1122
+ float[] v = bRep.getRawVertices();
1123
+ float[] n = bRep.getRawNormals();
1124
+ float[] c = bRep.getRawColors();
1125
+ float[] uv = bRep.getRawUVMap();
1126
+
1127
+ int count2 = 0;
1128
+ int count3 = 0;
1129
+
1130
+ if (n.length > 0)
1131
+ {
1132
+ for (int i = 0; i < strips.length; i++)
1133
+ {
1134
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1135
+
1136
+ /*
1137
+ boolean locked = false;
1138
+ float eps = 0.1f;
1139
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1140
+
1141
+ int dot = 0;
1142
+
1143
+ if ((dot&1) == 0)
1144
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1145
+
1146
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1147
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1148
+ else
1149
+ {
1150
+ locked = true;
1151
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1152
+ }
1153
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1154
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1155
+ if (hasnorm)
1156
+ {
1157
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1158
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1159
+ }
1160
+
1161
+ if ((dot&4) == 0)
1162
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1163
+
1164
+ if (wrap || !locked && (dot&8) != 0)
1165
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1166
+ else
1167
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1168
+
1169
+ f.dot = dot;
1170
+ */
1171
+
1172
+ if (!selectmode)
1173
+ {
1174
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1175
+ {
1176
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1177
+ } else
1178
+ {
1179
+ gl.glNormal3f(0, 0, 1);
1180
+ }
1181
+
1182
+ if (c != null)
1183
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1184
+ {
1185
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1186
+ }
1187
+ }
1188
+ if (flipV)
1189
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1190
+ else
1191
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1192
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1193
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1194
+
1195
+ count2 += 2;
1196
+ count3 += 3;
1197
+ if (!selectmode)
1198
+ {
1199
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1200
+ {
1201
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1202
+ } else
1203
+ {
1204
+ gl.glNormal3f(0, 0, 1);
1205
+ }
1206
+ if (c != null)
1207
+ {
1208
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1209
+ }
1210
+ }
1211
+ if (flipV)
1212
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1213
+ else
1214
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1216
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1217
+
1218
+ count2 += 2;
1219
+ count3 += 3;
1220
+ for (int j = 0; j < strips[i] - 2; j++)
1221
+ {
1222
+ //gl.glTexCoord2d(...);
1223
+ if (!selectmode)
1224
+ {
1225
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1226
+ {
1227
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1228
+ } else
1229
+ {
1230
+ gl.glNormal3f(0, 0, 1);
1231
+ }
1232
+ if (c != null)
1233
+ {
1234
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1235
+ }
1236
+ }
1237
+
1238
+ if (flipV)
1239
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1240
+ else
1241
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1242
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1243
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1244
+ count2 += 2;
1245
+ count3 += 3;
1246
+ }
1247
+
1248
+ gl.glEnd();
1249
+ }
1250
+ }
1251
+
1252
+ assert count3 == v.length;
1253
+ }
1254
+ else // !trimmed
1255
+ {
1256
+ int count = 0;
1257
+ for (int i = 0; i < strips.length; i++)
1258
+ {
1259
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1260
+
1261
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1262
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1263
+
1264
+ drawVertex(gl, p, flipV, selectmode);
1265
+ drawVertex(gl, q, flipV, selectmode);
1266
+
1267
+ for (int j = 0; j < strips[i] - 2; j++)
1268
+ {
1269
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1270
+
1271
+ // if (j%2 == 0)
1272
+ // drawFace(p, q, r, display, null);
1273
+ // else
1274
+ // drawFace(p, r, q, display, null);
1275
+
1276
+ // p = q;
1277
+ // q = r;
1278
+ drawVertex(gl, r, flipV, selectmode);
1279
+ }
1280
+
1281
+ gl.glEnd();
1282
+ }
1283
+ }
1284
+ }
1285
+
1286
+ static cSpring.Point3D temp = new cSpring.Point3D();
1287
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1288
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1289
+
1290
+ public void DrawDynamicMesh(cMesh mesh)
1291
+ {
1292
+ GL gl = GetGL(); // getGL();
1293
+
1294
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1295
+
1296
+ gl.glDisable(gl.GL_LIGHTING);
1297
+
1298
+ gl.glLineWidth(1);
1299
+ gl.glColor3f(1,1,1);
1300
+ gl.glBegin(gl.GL_LINES);
1301
+ double scale = 0;
1302
+ int count = 0;
1303
+ for (int s=0; s<Phys.allSprings.size(); s++)
1304
+ {
1305
+ cSpring.Spring spring = Phys.allSprings.get(s);
1306
+ if(s == 0)
1307
+ {
1308
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1309
+ }
1310
+ if (mesh.showsprings)
1311
+ {
1312
+ temp.set(spring.a.position);
1313
+ temp.add(spring.b.position);
1314
+ temp.mul(0.5);
1315
+ temp2.set(spring.a.position);
1316
+ temp2.sub(spring.b.position);
1317
+ temp2.mul(spring.restLength/2);
1318
+ temp.sub(temp2);
1319
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1320
+ temp.add(temp2);
1321
+ temp.add(temp2);
1322
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1323
+ }
1324
+
1325
+ if (spring.isHandle)
1326
+ continue;
1327
+
1328
+ //if (scale < spring.restLength)
1329
+ scale += spring.restLength;
1330
+ count++;
1331
+ }
1332
+ gl.glEnd();
1333
+
1334
+ if (count == 0)
1335
+ scale = 0.01;
1336
+ else
1337
+ scale /= count * 3;
1338
+
1339
+ //scale = 0.25;
1340
+
1341
+ if (mesh.ShowInfo())
1342
+ {
1343
+ gl.glLineWidth(4);
1344
+ for (int s=0; s<Phys.allNodes.size(); s++)
1345
+ {
1346
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1347
+ if (node.mass == 0)
1348
+ continue;
1349
+
1350
+ int i = node.springs==null?-1:node.springs.size();
1351
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1352
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1353
+ //temp.normalize();
1354
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1355
+ gl.glBegin(gl.GL_LINES);
1356
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1357
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1358
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1359
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1360
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1361
+ gl.glEnd();
1362
+ }
1363
+
1364
+ gl.glLineWidth(8);
1365
+ for (int s=0; s<Phys.allNodes.size(); s++)
1366
+ {
1367
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1368
+
1369
+ if (node.springs != null)
1370
+ {
1371
+ for (int i=0; i<node.springs.size(); i+=1)
1372
+ {
1373
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1374
+
1375
+ int c = i+1;
1376
+ // c = node.springs.get(i).nbcopies;
1377
+
1378
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1379
+ gl.glBegin(gl.GL_LINES);
1380
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1381
+ gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3);
1382
+ gl.glEnd();
1383
+ }
1384
+ }
1385
+ }
1386
+
1387
+ gl.glLineWidth(1);
1388
+ }
1389
+
1390
+ gl.glEnable(gl.GL_LIGHTING);
1391
+ }
1392
+
1393
+ /// INTERFACE
1394
+
1395
+ public void StartTriangles()
1396
+ {
1397
+ javax.media.opengl.GL gl = GetGL();
1398
+ gl.glBegin(gl.GL_TRIANGLES);
1399
+ }
1400
+
1401
+ public void EndTriangles()
1402
+ {
1403
+ GetGL().glEnd();
1404
+ }
1405
+
1406
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1407
+ {
1408
+ if (!selectmode)
1409
+ {
1410
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1411
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1412
+
1413
+ if (flipV)
1414
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1415
+ else
1416
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1417
+ }
1418
+
1419
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1420
+ }
1421
+
1422
+ void SetColor(Object3D obj, Vertex p0)
1423
+ {
1424
+ CameraPane display = this;
1425
+ BoundaryRep bRep = obj.bRep;
1426
+
1427
+ if (RENDERPROGRAM == 0)
1428
+ {
1429
+ float r = 0;
1430
+ if (bRep != null)
1431
+ {
1432
+ if (bRep.stripified)
1433
+ {
1434
+ r = 1;
1435
+ }
1436
+ }
1437
+ float g = 0;
1438
+ if (bRep != null)
1439
+ {
1440
+ if (bRep.trimmed)
1441
+ {
1442
+ g = 1;
1443
+ }
1444
+ }
1445
+ float b = 0;
1446
+ if (obj.support != null && obj.link2master)
1447
+ {
1448
+ b = 1;
1449
+ }
1450
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1451
+ return;
1452
+ }
1453
+
1454
+ if (display.DrawMode() != CameraPane.SHADOW)
1455
+ return;
1456
+
1457
+ javax.media.opengl.GL gl = display.GetGL();
1458
+// if (true) return;
1459
+// float ao = p.AO;
1460
+//
1461
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1462
+// // ao = 1;
1463
+//
1464
+// gl.glColor4f(ao, ao, ao, 1);
1465
+
1466
+// CameraPane.selectedpoint.
1467
+// getAverage(cStatic.point1, true);
1468
+ if (CameraPane.pointflow == null) // !random) // live)
1469
+ {
1470
+ return;
1471
+ }
1472
+
1473
+ cStatic.point1.set(0,0,0);
1474
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1475
+
1476
+ cStatic.point1.sub(p0);
1477
+
1478
+
1479
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1480
+// {
1481
+// return;
1482
+// }
1483
+
1484
+ //if (true)
1485
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1486
+ {
1487
+ return;
1488
+ }
1489
+
1490
+ float[] colorV = new float[3];
1491
+
1492
+ if (false) // marked)
1493
+ {
1494
+ // debug rigging weights
1495
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1496
+ {
1497
+ float weight = p0.weights[object] / p0.totalweight;
1498
+
1499
+ // if (weight < 0.1)
1500
+ // {
1501
+ // assert(weight == 0);
1502
+ // continue;
1503
+ // }
1504
+
1505
+ if (p0.vertexlinks[object] == -1)
1506
+ continue;
1507
+
1508
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1509
+
1510
+ int color = //1 << object; //
1511
+ //p.vertexlinks.length;
1512
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1513
+ colorV[2] += (color & 1) * weight;
1514
+ colorV[1] += ((color & 2) >> 1) * weight;
1515
+ colorV[0] += ((color & 4) >> 2) * weight;
1516
+ }
1517
+ }
1518
+ else
1519
+ {
1520
+ if (obj.drawingstarted)
1521
+ {
1522
+ // find next point
1523
+ if (bRep.GetVertex(0).faceindices == null)
1524
+ {
1525
+ bRep.InitFaceIndices();
1526
+ }
1527
+
1528
+ double ymin = p0.y;
1529
+
1530
+ Vertex newp = p0;
1531
+
1532
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1533
+ {
1534
+ int fi = p0.faceindices[fii];
1535
+
1536
+ if (fi == -1)
1537
+ break;
1538
+
1539
+ Face f = bRep.GetFace(fi);
1540
+
1541
+ Vertex p = bRep.GetVertex(f.p);
1542
+ Vertex q = bRep.GetVertex(f.q);
1543
+ Vertex r = bRep.GetVertex(f.r);
1544
+
1545
+ int swap = (int)(Math.random()*3);
1546
+
1547
+// for (int s=swap; --s>=0;)
1548
+// {
1549
+// Vertex t = p;
1550
+// p = q;
1551
+// q = r;
1552
+// r = t;
1553
+// }
1554
+ if (ymin > p.y)
1555
+ {
1556
+ ymin = p.y;
1557
+ newp = p;
1558
+// break;
1559
+ }
1560
+ if (ymin > q.y)
1561
+ {
1562
+ ymin = q.y;
1563
+ newp = q;
1564
+// break;
1565
+ }
1566
+ if (ymin > r.y)
1567
+ {
1568
+ ymin = r.y;
1569
+ newp = r;
1570
+// break;
1571
+ }
1572
+ }
1573
+
1574
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1575
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1576
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1577
+
1578
+ obj.drawingstarted = false;
1579
+
1580
+ // return;
1581
+ }
1582
+
1583
+ if (false) // CameraPane.DRAW
1584
+ {
1585
+ p0.AO = colorV[0] = 2;
1586
+ colorV[1] = 2;
1587
+ colorV[2] = 2;
1588
+ }
1589
+
1590
+ CameraPane.pointflow.add(p0);
1591
+ CameraPane.pointflow.Touch();
1592
+ }
1593
+
1594
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1595
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1596
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1597
+ }
1598
+
1599
+ void DrawMaterial(cMaterial material, boolean selected)
1600
+ {
1601
+ CameraPane display = this;
1602
+ //new Exception().printStackTrace();
1603
+
1604
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1605
+ {
1606
+ return;
1607
+ }
1608
+
1609
+ javax.media.opengl.GL gl = display.GetGL();
1610
+
1611
+ //Color col = Color.getHSBColor(color,modulation,1);
1612
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1613
+ if (!material.multiply)
1614
+ {
1615
+ display.color = color;
1616
+ display.saturation = material.modulation;
1617
+ }
1618
+ else
1619
+ {
1620
+ display.color *= color*2;
1621
+ display.saturation *= material.modulation*2;
1622
+ }
1623
+
1624
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1625
+
1626
+ float[] colorV = GrafreeD.colorV;
1627
+
1628
+ /**/
1629
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1630
+ {
1631
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1632
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1633
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1634
+ colorV[3] = material.opacity;
1635
+
1636
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1637
+ //System.out.println("Opacity = " + opacity);
1638
+
1639
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1640
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1641
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1642
+
1643
+ float amb = material.ambient;
1644
+ if (amb < material.cameralight)
1645
+ {
1646
+ amb = material.cameralight;
1647
+ }
1648
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1649
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1650
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1651
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1652
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1653
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1654
+
1655
+ /**/
1656
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1657
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1658
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1659
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1660
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1661
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1662
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1663
+ //System.out.println("shininess = " + colorV[0]);
1664
+ if (colorV[0] > 128)
1665
+ {
1666
+ colorV[0] = 128;
1667
+ }
1668
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1669
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1670
+ /**/
1671
+ }
1672
+ /**/
1673
+
1674
+ //selected = false;
1675
+ selected = selected && display.flash;
1676
+
1677
+ //display.modelParams0[0] = 0; // pigment.r;
1678
+ //display.modelParams0[1] = 0; // pigment.g;
1679
+ //display.modelParams0[2] = 0; // pigment.b;
1680
+ if (!material.multiply)
1681
+ {
1682
+ display.modelParams0[3] = material.metalness;
1683
+ display.modelParams1[0] = material.diffuse;
1684
+ display.modelParams1[1] = material.specular;
1685
+ display.modelParams1[2] = 1 / material.shininess;
1686
+ display.modelParams1[3] = material.shift;
1687
+ display.modelParams2[0] = material.ambient;
1688
+ display.modelParams2[1] = material.lightarea;
1689
+ //System.out.println("light area = " + lightarea);
1690
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1691
+ display.modelParams2[3] = material.velvet;
1692
+ display.modelParams3[0] = material.sheen;
1693
+ display.modelParams3[1] = material.subsurface;
1694
+ display.modelParams3[2] = material.bump; // backlit
1695
+ display.modelParams3[3] = material.aniso;
1696
+ display.modelParams4[0] = material.anisoV;
1697
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1698
+ //System.out.println("selected = " + selected);
1699
+ display.modelParams4[2] = material.diffuseness;
1700
+ display.modelParams4[3] = material.shadow;
1701
+ display.modelParams5[0] = material.texture;
1702
+ display.modelParams5[1] = material.opacity;
1703
+ display.modelParams5[2] = material.fakedepth;
1704
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1705
+ }
1706
+ else
1707
+ {
1708
+ display.modelParams0[3] *= material.metalness*2;
1709
+ display.modelParams1[0] *= material.diffuse*2;
1710
+ display.modelParams1[1] *= material.specular*2;
1711
+ display.modelParams1[2] *= material.shininess*2;
1712
+ display.modelParams1[3] *= material.shift*2;
1713
+ display.modelParams2[0] *= material.ambient*2;
1714
+ display.modelParams2[1] *= material.lightarea*2;
1715
+ display.modelParams2[2] *= material.factor*2;
1716
+ display.modelParams2[3] *= material.velvet*2;
1717
+ display.modelParams3[0] *= material.sheen*2;
1718
+ display.modelParams3[1] *= material.subsurface*2;
1719
+ display.modelParams3[2] *= material.bump*2;
1720
+ display.modelParams3[3] *= material.aniso*2;
1721
+ display.modelParams4[0] *= material.anisoV*2;
1722
+ display.modelParams4[1] *= material.cameralight*2;
1723
+ //System.out.println("selected = " + selected);
1724
+ display.modelParams4[2] *= material.diffuseness*2;
1725
+ display.modelParams4[3] *= material.shadow*2;
1726
+ display.modelParams5[0] *= material.texture*2;
1727
+ display.modelParams5[1] *= material.opacity*2;
1728
+ display.modelParams5[2] *= material.fakedepth*2;
1729
+ display.modelParams5[3] *= material.shadowbias*2;
1730
+ }
1731
+
1732
+ display.modelParams6[0] = 0;
1733
+ display.modelParams6[1] = 0;
1734
+ display.modelParams6[2] = 0;
1735
+ display.modelParams6[3] = 0;
1736
+
1737
+ display.modelParams7[0] = 0;
1738
+ display.modelParams7[1] = 1000;
1739
+ display.modelParams7[2] = 0;
1740
+ display.modelParams7[3] = 0;
1741
+
1742
+ display.modelParams6[0] = 100; // criss de bug de bump
1743
+
1744
+ Object3D.cVector2[] extparams = display.vector2buffer;
1745
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1746
+ {
1747
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1748
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1749
+ if (extparams.length > 1)
1750
+ {
1751
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1752
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1753
+ if (extparams.length > 2)
1754
+ {
1755
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1756
+ float x = extparams[2].y / 1000.0f;
1757
+ //if (x == 0)
1758
+ // x = 1f;
1759
+ 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
1760
+ if (extparams[2].y > 0)
1761
+ {
1762
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1763
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1764
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1765
+ }
1766
+ }
1767
+ }
1768
+ }
1769
+
1770
+ //if (display.modelParams6[2] != 0)
1771
+ /*
1772
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1773
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1774
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1775
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1776
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1777
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1778
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1779
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1780
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1781
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1782
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1783
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1784
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1785
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1786
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1787
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1788
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1789
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1790
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1791
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1792
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1793
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1794
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1795
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1796
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1797
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1798
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1799
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1800
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1801
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1802
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1803
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1804
+ /**/
1805
+ //assert (display.modelParams6[2] == 0);
1806
+
1807
+ //System.out.println("noise power = " + display.modelParams7[0]);
1808
+ //System.out.println("shadowbias = " + shadowbias);
1809
+
1810
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1811
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1812
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1813
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1814
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1815
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1816
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1817
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1818
+
1819
+ int mode = display.FP_SHADER;
1820
+
1821
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1822
+ {
1823
+ mode |= display.FP_ANISO;
1824
+ }
1825
+
1826
+ display.EnableProgram(mode);
1827
+
1828
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1829
+
1830
+ if (!material.multiply)
1831
+ {
1832
+ if (Globals.drawMode == CameraPane.SHADOW)
1833
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1834
+ else
1835
+ gl.glDepthMask(material.opacity >= 0.99);
1836
+ }
2081837 }
2091838
2101839 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,10 +1854,10 @@
2251854 currentGL.glMultMatrixd(model, 0);
2261855 }
2271856
228
- void PushMatrix(double[][] matrix, int count)
1857
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291858 {
2301859 matrixdepth++;
231
- // GraphreeD.tracein(matrix);
1860
+ // GrafreeD.tracein(matrix);
2321861 if (matrix == null)
2331862 return; // Identity
2341863
....@@ -253,13 +1882,13 @@
2531882
2541883 void PushMatrix(double[][] matrix)
2551884 {
256
- // GraphreeD.tracein(matrix);
1885
+ // GrafreeD.tracein(matrix);
2571886 PushMatrix(matrix,1);
2581887 }
2591888
2601889 void PushMatrix()
2611890 {
262
- // GraphreeD.tracein(null);
1891
+ // GrafreeD.tracein(null);
2631892 if (matrixdepth++ < MAXSTACK - 1)
2641893 {
2651894 currentGL.glPushMatrix();
....@@ -270,11 +1899,11 @@
2701899
2711900 double[][] tmpmat = new double[4][4];
2721901
273
- void PopMatrix(double[][] inverse)
1902
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741903 {
2751904 --matrixdepth;
2761905
277
- // GraphreeD.traceout(inverse);
1906
+ // GrafreeD.traceout(inverse);
2781907 if (inverse == null)
2791908 return; // Identity
2801909
....@@ -292,7 +1921,7 @@
2921921
2931922 void PopMatrix()
2941923 {
295
- // GraphreeD.traceout(null);
1924
+ // GrafreeD.traceout(null);
2961925 // inverse == null??
2971926 if (--matrixdepth < MAXSTACK - 1)
2981927 {
....@@ -310,7 +1939,7 @@
3101939 PushTextureMatrix(matrix, 1);
3111940 }
3121941
313
- void PushTextureMatrix(double[][] matrix, int count)
1942
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141943 {
3151944 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161945
....@@ -324,7 +1953,7 @@
3241953 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251954 }
3261955
327
- void PopTextureMatrix(double[][] inverse)
1956
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281957 {
3291958 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301959 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -351,15 +1980,15 @@
3511980
3521981 static int camerachangeframe;
3531982
354
- boolean SetCamera(Camera cam)
1983
+ public boolean SetCamera(Camera cam)
3551984 {
3561985 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571986 // return false;
3581987
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1988
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601989 {
3611990 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1991
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631992 {
3641993 // refuse the camera change
3651994 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +1996,7 @@
3671996 }
3681997 }
3691998
370
- camerachangeframe = framecount;
1999
+ camerachangeframe = Globals.framecount;
3712000
3722001 cam.hAspect = -1; // Read only
3732002
....@@ -398,7 +2027,7 @@
3982027 {
3992028 //System.err.println("Oeil on");
4002029 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2030
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022031 // object.editWindow.ScreenFit(trackedobject);
4032032 //pingthread.StepToTarget(true);
4042033 }
....@@ -407,7 +2036,7 @@
4072036 {
4082037 //System.err.println("Oeil on");
4092038 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2039
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4112040 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4122041 //pingthread.StepToTarget(true);
4132042 }
....@@ -471,39 +2100,12 @@
4712100 {
4722101 frozen ^= true;
4732102 // Weird...
474
- lighttouched = true;
2103
+ Globals.lighttouched = true;
4752104 }
4762105
4772106 void ToggleDL()
4782107 {
4792108 mainDL ^= true;
480
- }
481
-
482
- void ToggleTexture()
483
- {
484
- textureon ^= true;
485
- }
486
-
487
- void ToggleLive()
488
- {
489
- setLIVE(isLIVE() ^ true);
490
-
491
- System.err.println("LIVE = " + isLIVE());
492
-
493
- if (!isLIVE()) // save sound
494
- GraphreeD.savesound = true; // wav.save();
495
- // else
496
- repaint(); // start loop // may 2013
497
- }
498
-
499
- void ToggleSupport()
500
- {
501
- SUPPORT ^= true;
502
- }
503
-
504
- void ToggleAbort()
505
- {
506
- ABORTMODE ^= true;
5072109 }
5082110
5092111 void ToggleFullScreen()
....@@ -513,12 +2115,7 @@
5132115
5142116 void ToggleCrowd()
5152117 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2118
+ Globals.CROWD ^= true;
5222119 }
5232120
5242121 void ToggleLocal()
....@@ -526,62 +2123,84 @@
5262123 LOCALTRANSFORM ^= true;
5272124 }
5282125
529
- void ToggleFast()
2126
+ public void ToggleTexture()
2127
+ {
2128
+ textureon ^= true;
2129
+ }
2130
+
2131
+ public void ToggleLive()
2132
+ {
2133
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2134
+
2135
+ System.err.println("LIVE = " + Globals.isLIVE());
2136
+
2137
+ if (!Globals.isLIVE()) // save sound
2138
+ GrafreeD.savesound = true; // wav.save();
2139
+ // else
2140
+ repaint(); // start loop // may 2013
2141
+ }
2142
+
2143
+ public void ToggleSupport()
2144
+ {
2145
+ SUPPORT ^= true;
2146
+ }
2147
+
2148
+ public void ToggleAbort()
2149
+ {
2150
+ ABORTMODE ^= true;
2151
+ }
2152
+
2153
+ public void ToggleInertia()
2154
+ {
2155
+ INERTIA ^= true;
2156
+ }
2157
+
2158
+ public void ToggleFast()
5302159 {
5312160 FAST ^= true;
5322161 }
5332162
534
- void ToggleSlowPose()
2163
+ public void ToggleSlowPose()
5352164 {
5362165 SLOWPOSE ^= true;
5372166 }
5382167
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2168
+ public void ToggleBoxMode()
5452169 {
5462170 BOXMODE ^= true;
5472171 }
5482172
549
- void ToggleSmoothFocus()
2173
+ public void ToggleSmoothFocus()
5502174 {
5512175 SMOOTHFOCUS ^= true;
5522176 }
5532177
554
- void ToggleImageFlip()
2178
+ public void ToggleImageFlip()
5552179 {
5562180 IMAGEFLIP ^= true;
5572181 }
5582182
559
- void ToggleSpeakerMocap()
2183
+ public void ToggleSpeakerMocap()
5602184 {
5612185 SPEAKERMOCAP ^= true;
5622186 }
5632187
564
- void ToggleSpeakerCamera()
2188
+ public void ToggleSpeakerCamera()
5652189 {
5662190 SPEAKERCAMERA ^= true;
5672191 }
5682192
569
- void ToggleSpeakerFocus()
2193
+ public void ToggleSpeakerFocus()
5702194 {
5712195 SPEAKERFOCUS ^= true;
5722196 }
5732197
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2198
+ public void ToggleFrustum()
5802199 {
5812200 FRUSTUM ^= true;
5822201 }
5832202
584
- void ToggleTrack()
2203
+ public void ToggleTrack()
5852204 {
5862205 TRACK ^= true;
5872206 if (TRACK)
....@@ -600,25 +2219,35 @@
6002219 repaint();
6012220 }
6022221
603
- void ToggleTrackOnce()
2222
+ public void ToggleTrackOnce()
6042223 {
6052224 TRACKONCE ^= true;
6062225 }
6072226
608
- void ToggleShadowTrack()
2227
+ public void ToggleShadowTrack()
6092228 {
6102229 SHADOWTRACK ^= true;
6112230 repaint();
6122231 }
6132232
614
- void ToggleOeil()
2233
+ public void ToggleOeil()
6152234 {
6162235 OEIL ^= true;
6172236 }
6182237
619
- void ToggleOeilOnce()
2238
+ public void ToggleOeilOnce()
6202239 {
6212240 OEILONCE ^= true;
2241
+ }
2242
+
2243
+ void ToggleFootContact()
2244
+ {
2245
+ FOOTCONTACT ^= true;
2246
+ }
2247
+
2248
+ void ToggleDebug()
2249
+ {
2250
+ DEBUG ^= true;
6222251 }
6232252
6242253 void ToggleLookAt()
....@@ -672,34 +2301,6 @@
6722301 //assert (cam.hAspect == 0);
6732302 cam.hAspect = 0;
6742303 lightCamera = cam;
675
- }
676
-
677
- CameraPane(Object3D o, Camera cam, boolean withcontext)
678
- {
679
- super(defaultcaps, null, withcontext?glcontext:null, null);
680
-
681
- //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
682
- glcontext = getContext();
683
-
684
- cameras = new Camera[2];
685
- targetLookAts = new cVector[2];
686
-
687
- SetCamera(cam);
688
-
689
- SetLight(new Camera(new cVector(10, 10, -20)));
690
-
691
- object = o;
692
-
693
- setBackground(Color.white);
694
-
695
- addKeyListener(this);
696
- addMouseListener(this);
697
- addMouseMotionListener(this);
698
- addMouseWheelListener(this);
699
- //System.out.println("addGLEventListener: " + this);
700
- addGLEventListener(this);
701
-
702
-// pingthread.start(); // may 2013
7032304 }
7042305
7052306 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -759,7 +2360,7 @@
7592360
7602361 GL currentGL;
7612362
762
- GL GetGL()
2363
+ public GL GetGL() // INTERFACE
7632364 {
7642365 return currentGL;
7652366 }
....@@ -768,6 +2369,8 @@
7682369 class CacheTexture
7692370 {
7702371 com.sun.opengl.util.texture.Texture texture;
2372
+ com.sun.opengl.util.texture.TextureData texturedata;
2373
+
7712374 int resolution;
7722375
7732376 CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
....@@ -1998,10 +3601,12 @@
19983601 */
19993602 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20003603 {
3604
+ int pixelformat = texturedata.getPixelFormat();
3605
+
20013606 int stride = 1;
2002
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
3607
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20033608 stride = 3;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
3609
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20053610 stride = 4;
20063611
20073612 int width = texturedata.getWidth();
....@@ -6267,7 +7872,7 @@
62677872 return null;
62687873 }
62697874
6270
- void ReleaseTextures(cTexture tex)
7875
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62717876 {
62727877 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62737878 {
....@@ -6305,7 +7910,7 @@
63057910
63067911 void ReleaseTexture(String tex, boolean bump)
63077912 {
6308
- if (// drawMode != 0 || /*tex == null ||*/
7913
+ if (// DrawMode() != 0 || /*tex == null ||*/
63097914 ambientOcclusion ) // || !textureon)
63107915 {
63117916 return;
....@@ -6331,7 +7936,7 @@
63317936 {
63327937 bumpdepth--;
63337938
6334
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7939
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63357940 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63367941 {
63377942 // assert (bumpstack[bumpdepth] == texture);
....@@ -6361,7 +7966,7 @@
63617966 {
63627967 pigmentdepth--;
63637968
6364
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7969
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63657970 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63667971 {
63677972 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6406,9 +8011,9 @@
64068011 }
64078012 }
64088013
6409
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8014
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64108015 {
6411
- if (// drawMode != 0 || /*tex == null ||*/
8016
+ if (// DrawMode() != 0 || /*tex == null ||*/
64128017 ambientOcclusion ) // || !textureon)
64138018 {
64148019 return; // false;
....@@ -6451,7 +8056,7 @@
64518056 return; // true;
64528057 }
64538058
6454
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8059
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
64558060 {
64568061 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64578062
....@@ -6665,6 +8270,8 @@
66658270 thetex.texture.dispose();
66668271 textures.remove(texname);
66678272 }
8273
+
8274
+ texture.texturedata = texturedata;
66688275 textures.put(texname, texture);
66698276
66708277 // newtex = true;
....@@ -6681,18 +8288,32 @@
66818288 }
66828289 }
66838290
8291
+ return texture;
8292
+ }
8293
+
8294
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8295
+ {
8296
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8297
+
66848298 if (bump)
66858299 {
6686
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
8300
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66878301 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66888302 }
66898303 else
66908304 {
6691
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
8305
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
66928306 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
66938307 }
66948308
66958309 return texture!=null?texture.texture:null;
8310
+ }
8311
+
8312
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8313
+ {
8314
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8315
+
8316
+ return texture!=null?texture.texturedata:null;
66968317 }
66978318
66988319 boolean BindTexture(String tex, boolean bump, int resolution)
....@@ -7292,9 +8913,9 @@
72928913 static boolean occlusionInitialized = false;
72938914 boolean selection = false;
72948915 boolean pointselection = false;
7295
- /*static*/ boolean lighttouched = true;
8916
+ ///*static*/ boolean lighttouched = true;
72968917 boolean deselect;
7297
- boolean ambientOcclusion = false;
8918
+ private boolean ambientOcclusion = false;
72988919 static boolean flash = false;
72998920 /*static*/ boolean wait = false;
73008921 boolean displaydone = false; // after repaint() calls
....@@ -7424,6 +9045,8 @@
74249045 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74259046 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74269047 double scale = lightCamera.SCALE / lightCamera.Distance();
9048
+// PATCH FILLE AUX JEANS
9049
+ //scale *= lightCamera.shaper_fovy / 25;
74279050 gl.glScaled(2 * scale, 2 * scale, -scale);
74289051 gl.glTranslated(0, 0, lightCamera.DECAL);
74299052
....@@ -7572,15 +9195,14 @@
75729195
75739196 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75749197 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
9198
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
9199
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75769200
75779201 static int imagecount = 0; // movie generation
75789202
75799203 static int jitter = 0;
75809204
75819205 boolean restartframe = false;
7582
-
7583
- static int framecount = 0; // general-purpose global count
75849206
75859207 void displayAntiAliased(javax.media.opengl.GL gl)
75869208 {
....@@ -7610,14 +9232,14 @@
76109232
76119233 //System.out.println("start frame");
76129234 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7613
- for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0)
9235
+ for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76149236 {
7615
- framecount++;
9237
+ Globals.framecount++;
76169238
76179239 if (CameraPane.tickcount > 0)
76189240 CameraPane.tickcount--;
76199241
7620
-// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
9242
+// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
76219243 // restartframe = true;
76229244 if (options1[2] > 100 && (jitter%2==0))
76239245 {
....@@ -7650,7 +9272,7 @@
76509272
76519273 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76529274 */
7653
- lighttouched = true;
9275
+ Globals.lighttouched = true;
76549276 //System.err.println(" shadowbuffer: " + jitter);
76559277 shadowbuffer.display();
76569278
....@@ -7672,7 +9294,7 @@
76729294
76739295 if (renderCamera != lightCamera)
76749296 for (int count = parentcam.GetTransformCount(); --count>=0;)
7675
- LA.matConcat(parentcam.toParent, matrix, matrix);
9297
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76769298
76779299 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76789300
....@@ -7688,7 +9310,7 @@
76889310
76899311 if (renderCamera != lightCamera)
76909312 for (int count = parentcam.GetTransformCount(); --count>=0;)
7691
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9313
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
76929314
76939315 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
76949316
....@@ -7905,7 +9527,7 @@
79059527
79069528 if (!BOXMODE)
79079529 {
7908
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
9530
+ System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
79099531 }
79109532
79119533 if (!BOXMODE)
....@@ -7933,7 +9555,7 @@
79339555 {
79349556 if (ACSIZE > 1)
79359557 {
7936
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
9558
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79379559 }
79389560 }
79399561
....@@ -7943,7 +9565,7 @@
79439565 ABORTED = false;
79449566 }
79459567 else
7946
- GraphreeD.wav.cursor += 735 * ACSIZE;
9568
+ GrafreeD.wav.cursor += 735 * ACSIZE;
79479569
79489570 if (false)
79499571 {
....@@ -8597,13 +10219,6 @@
859710219 }
859810220 }
859910221
8600
- boolean IsFrozen()
8601
- {
8602
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8603
-
8604
- return !selectmode && cameracount == 0; // != 0;
8605
- }
8606
-
860710222 boolean niceon = false;
860810223 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
860910224 boolean currentlydrawing = false;
....@@ -8613,16 +10228,16 @@
861310228
861410229 public void display(GLAutoDrawable drawable)
861510230 {
8616
- if (GraphreeD.savesound && GraphreeD.hassound)
10231
+ if (GrafreeD.savesound && GrafreeD.hassound)
861710232 {
8618
- GraphreeD.wav.save();
8619
- GraphreeD.savesound = false;
8620
- GraphreeD.hassound = false;
10233
+ GrafreeD.wav.save();
10234
+ GrafreeD.savesound = false;
10235
+ GrafreeD.hassound = false;
862110236 }
862210237 // if (DEBUG_SELECTION)
862310238 // {
8624
-// if (drawMode != SELECTION)
8625
-// drawMode = SELECTION;
10239
+// if (DrawMode() != SELECTION)
10240
+// DrawMode() = SELECTION;
862610241 // }
862710242
862810243 if (!isRenderer)
....@@ -8678,9 +10293,9 @@
867810293
867910294 //ANTIALIAS = 0;
868010295
8681
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10296
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
868210297 {
8683
- if (niceon || isLIVE())
10298
+ if (niceon || Globals.isLIVE())
868410299 {
868510300 //if(active == 0)
868610301 // antialiaser = null;
....@@ -8705,7 +10320,7 @@
870510320 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
870610321 */
870710322
8708
- if (drawMode == DEFAULT)
10323
+ if (DrawMode() == DEFAULT)
870910324 {
871010325 currentlydrawing = true;
871110326 }
....@@ -8736,18 +10351,18 @@
873610351
873710352 // if(Applet3D.clipboard != null)
873810353 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8739
-//drawMode = SELECTION;
10354
+//DrawMode() = SELECTION;
874010355 indexcount = 0;
874110356
8742
- if (drawMode == OCCLUSION)
10357
+ if (DrawMode() == OCCLUSION)
874310358 {
8744
- drawMode = DEFAULT;
10359
+ Globals.drawMode = DEFAULT; // WARNING
874510360 ambientOcclusion = true;
874610361 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
874710362 Object3D theobject = object;
874810363 Object3D theparent = object.parent;
874910364 object.parent = null;
8750
- object = (Object3D)GraphreeD.clone(object);
10365
+ object = (Object3D)GrafreeD.clone(object);
875110366 object.Stripify();
875210367 if (theobject.selection == null || theobject.selection.Size() == 0)
875310368 theobject.PreprocessOcclusion(this);
....@@ -8760,19 +10375,19 @@
876010375 ambientOcclusion = false;
876110376 }
876210377
8763
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10378
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
876410379 {
876510380 //if (RENDERSHADOW) // ?
876610381 if (!IsFrozen())
876710382 {
876810383 // dec 2012
8769
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10384
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
877010385 {
8771
- framecount++;
10386
+ Globals.framecount++;
877210387 shadowbuffer.display();
877310388 }
877410389 }
8775
- lighttouched = false; // ??
10390
+ Globals.lighttouched = false; // ??
877610391 //drawing = true;
877710392 //lighttouched = true;
877810393 }
....@@ -8793,9 +10408,9 @@
879310408 //eyeCamera.shaper_fovy = 1;
879410409 }
879510410
8796
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10411
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
879710412 {
8798
- //System.out.println("drawMode = " + drawMode);
10413
+ //System.out.println("DrawMode() = " + DrawMode());
879910414 vertexMode |= VP_PASS;
880010415 //vertexMode |= VP_PROJECTION;
880110416 if (!ambientOcclusion)
....@@ -8855,7 +10470,7 @@
885510470 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
885610471 //Camera lightcam = new Camera(light0);
885710472
8858
- if (drawMode == SHADOW)
10473
+ if (DrawMode() == SHADOW)
885910474 {
886010475 /*
886110476 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8894,7 +10509,7 @@
889410509 // if (parentcam != renderCamera) // not a light
889510510 if (cam != lightCamera)
889610511 for (int count = parentcam.GetTransformCount(); --count>=0;)
8897
- LA.matConcat(parentcam.toParent, matrix, matrix);
10512
+ LA.matConcat(matrix, parentcam.toParent, matrix);
889810513
889910514 for (int j = 0; j < 4; j++)
890010515 {
....@@ -8909,7 +10524,7 @@
890910524 // if (parentcam != renderCamera) // not a light
891010525 if (cam != lightCamera)
891110526 for (int count = parentcam.GetTransformCount(); --count>=0;)
8912
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10527
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
891310528
891410529 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
891510530
....@@ -8945,7 +10560,7 @@
894510560 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
894610561 } else
894710562 {
8948
- if (drawMode != DEFAULT)
10563
+ if (DrawMode() != DEFAULT)
894910564 {
895010565 gl.glClearColor(1, 1, 1, 0);
895110566 } // 1);
....@@ -9010,7 +10625,7 @@
901010625
901110626 fast &= !ambientOcclusion;
901210627
9013
- if (drawMode == DEFAULT)
10628
+ if (DrawMode() == DEFAULT)
901410629 {
901510630 //gl.glEnable(gl.GL_ALPHA_TEST);
901610631 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9071,6 +10686,8 @@
907110686 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
907210687 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
907310688 double scale = lightCamera.SCALE / lightCamera.Distance();
10689
+// PATCH FILLE AUX JEANS
10690
+ //scale *= lightCamera.shaper_fovy / 25;
907410691 gl.glScaled(2 * scale, 2 * scale, -scale);
907510692 gl.glTranslated(0, 0, lightCamera.DECAL);
907610693
....@@ -9206,10 +10823,12 @@
920610823 gl.glMatrixMode(gl.GL_PROJECTION);
920710824 gl.glLoadIdentity();
920810825
9209
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10826
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
921010827 {
921110828 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
921210829 double scale = lightCamera.SCALE / lightCamera.Distance();
10830
+// PATCH FILLE AUX JEANS
10831
+ //scale *= lightCamera.shaper_fovy / 25;
921310832 gl.glScaled(2 * scale, 2 * scale, -scale);
921410833 gl.glTranslated(0, 0, lightCamera.DECAL);
921510834 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9262,7 +10881,7 @@
926210881 //gl.glPushMatrix();
926310882 gl.glLoadIdentity();
926410883
9265
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10884
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
926610885 {
926710886 //LA.xformPos(light0, lightCamera.fromScreen, light);
926810887 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9349,7 +10968,7 @@
934910968 }
935010969
935110970 /**/
9352
- if (true) // drawMode == SELECTION) // != DEFAULT)
10971
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
935310972 gl.glDisable(gl.GL_LIGHTING);
935410973 else
935510974 gl.glEnable(gl.GL_LIGHTING);
....@@ -9361,12 +10980,13 @@
936110980
936210981 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
936310982 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
10983
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
936410984
936510985 options2[0] *= renderCamera.Distance();
936610986
936710987 lightslot = 64;
936810988
9369
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10989
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
937010990 {
937110991 DrawLights(object);
937210992 }
....@@ -9377,7 +10997,7 @@
937710997 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
937810998 //System.out.println("fragmentMode = " + fragmentMode);
937910999
9380
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11000
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
938111001 {
938211002 /*
938311003 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9410,7 +11030,7 @@
941011030 }
941111031 }
941211032
9413
- if (drawMode == DEFAULT)
11033
+ if (DrawMode() == DEFAULT)
941411034 {
941511035 if (WIREFRAME && !ambientOcclusion)
941611036 {
....@@ -9428,7 +11048,7 @@
942811048 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
942911049 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
943011050
9431
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11051
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
943211052 {
943311053 if (vertexMode != 0) // && !fast)
943411054 {
....@@ -9448,7 +11068,7 @@
944811068 }
944911069 }
945011070
9451
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11071
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
945211072 {
945311073 //gl.glDepthFunc(GL.GL_LEQUAL);
945411074 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9476,7 +11096,7 @@
947611096 //gl.glDepthMask(false);
947711097 }
947811098
9479
- if (false) // drawMode == SHADOW)
11099
+ if (false) // DrawMode() == SHADOW)
948011100 {
948111101 //SetColumnMajorData(cameraInverseTransform, view_1);
948211102 //System.out.println("light = " + cameraInverseTransform);
....@@ -9490,16 +11110,16 @@
949011110 //System.out.println("object = " + object);
949111111 if (!frozen && !imageLocked)
949211112 {
9493
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11113
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
949411114 {
949511115 displayAntiAliased(gl);
949611116 } else
949711117 {
949811118 programcount = 0;
9499
- int keepmode = drawMode;
11119
+ int keepmode = DrawMode();
950011120 // if (DEBUG_SELECTION)
950111121 // {
9502
-// drawMode = SELECTION;
11122
+// DrawMode() = SELECTION;
950311123 // }
950411124 // for point selection
950511125 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9509,10 +11129,10 @@
950911129 DrawObject(gl);
951011130
951111131 // jan 2013 System.err.println("RESET ABORT (display)");
9512
- // if (drawMode == DEFAULT)
11132
+ // if (DrawMode() == DEFAULT)
951311133 // ABORTED = false;
951411134 fullreset = false;
9515
- drawMode = keepmode;
11135
+ Globals.drawMode = keepmode; // WARNING
951611136 //System.out.println("PROGRAM SWITCH " + programcount);
951711137 }
951811138 }
....@@ -9520,11 +11140,11 @@
952011140 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
952111141 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
952211142
9523
- if (drawMode == DEFAULT)
11143
+ if (DrawMode() == DEFAULT)
952411144 {
952511145 ReleaseTexture(NOISE_TEXTURE, false);
952611146 }
9527
- //if (drawMode == DEFAULT)
11147
+ //if (DrawMode() == DEFAULT)
952811148 {
952911149
953011150 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9536,7 +11156,7 @@
953611156 //else
953711157 //gl.glDisable(gl.GL_TEXTURE_2D);
953811158 //gl.glPopMatrix();
9539
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11159
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
954011160 {
954111161 //new Exception().printStackTrace();
954211162 //System.out.println("Draw image " + width + ", " + height);
....@@ -9578,7 +11198,7 @@
957811198 //gl.glFlush();
957911199 }
958011200
9581
- if (flash && drawMode == DEFAULT)
11201
+ if (flash && DrawMode() == DEFAULT)
958211202 {
958311203 flash = false;
958411204 wait = true;
....@@ -9586,9 +11206,9 @@
958611206 }
958711207
958811208 //drawing = false;
9589
- //if(drawMode == DEFAULT)
11209
+ //if(DrawMode() == DEFAULT)
959011210 // niceon = false;
9591
- if (drawMode == DEFAULT)
11211
+ if (DrawMode() == DEFAULT)
959211212 {
959311213 currentlydrawing = false;
959411214 }
....@@ -9608,7 +11228,7 @@
960811228 repaint();
960911229 }
961011230
9611
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11231
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
961211232 repaint();
961311233
961411234 displaydone = true;
....@@ -9642,10 +11262,10 @@
964211262 e.printStackTrace();
964311263 }
964411264
9645
- if (GraphreeD.RENDERME > 0)
9646
- GraphreeD.RENDERME--; // mechante magouille
11265
+ if (GrafreeD.RENDERME > 0)
11266
+ GrafreeD.RENDERME--; // mechante magouille
964711267
9648
- ONESTEP = false;
11268
+ Globals.ONESTEP = false;
964911269 }
965011270
965111271 static boolean zoomonce = false;
....@@ -9653,11 +11273,11 @@
965311273 void DrawObject(GL gl, boolean draw)
965411274 {
965511275 //System.out.println("DRAW OBJECT " + mouseDown);
9656
-// drawMode = SELECTION;
11276
+// DrawMode() = SELECTION;
965711277 //GL gl = getGL();
965811278 if ((TRACK || SHADOWTRACK) || zoomonce)
965911279 {
9660
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11280
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
966111281 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
966211282 pingthread.StepToTarget(true); // true);
966311283 // zoomonce = false;
....@@ -9678,9 +11298,9 @@
967811298 callist = gl.glGenLists(1);
967911299 }
968011300
9681
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11301
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
968211302
9683
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11303
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
968411304
968511305 if (!mainDL || !active || touched)
968611306 {
....@@ -9707,7 +11327,7 @@
970711327 PushMatrix(ClickInfo.matbuffer);
970811328 }
970911329
9710
- if (drawMode == 0)
11330
+ if (DrawMode() == 0)
971111331 {
971211332 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
971311333
....@@ -9716,12 +11336,12 @@
971611336 BindTextures(DEFAULT_TEXTURES, 2);
971711337 }
971811338 //System.out.println("--> " + stackdepth);
9719
-// GraphreeD.traceon();
11339
+// GrafreeD.traceon();
972011340
972111341 // DRAW
972211342 object.draw(this, /*(Composite)*/ object, false, false);
972311343
9724
- if (drawMode == DEFAULT)
11344
+ if (DrawMode() == DEFAULT)
972511345 {
972611346 if (DEBUG)
972711347 {
....@@ -9732,34 +11352,48 @@
973211352 selectedpoint.radius = radius;
973311353 selectedpoint.recalculate();
973411354 selectedpoint.material = new cMaterial();
9735
- selectedpoint.material.color = 0.25f;
11355
+ selectedpoint.material.color = 0.15f; // Yellow
973611356 selectedpoint.material.modulation = 0.75f;
973711357
9738
- debugpoint.radius = radius;
9739
- debugpoint.recalculate();
9740
- debugpoint.material = new cMaterial();
9741
- debugpoint.material.color = 0.25f;
9742
- debugpoint.material.modulation = 0.75f;
11358
+ debugpointG.radius = radius;
11359
+ debugpointG.recalculate();
11360
+ debugpointG.material = new cMaterial();
11361
+ debugpointG.material.color = 0.25f; // Green
11362
+ debugpointG.material.modulation = 0.75f;
974311363
9744
- debugpoint2.radius = radius;
9745
- debugpoint2.recalculate();
9746
- debugpoint2.material = new cMaterial();
9747
- debugpoint2.material.color = 0.75f;
9748
- debugpoint2.material.modulation = 0.75f;
11364
+ debugpointP.radius = radius;
11365
+ debugpointP.recalculate();
11366
+ debugpointP.material = new cMaterial();
11367
+ debugpointP.material.color = 0.75f; // Purple
11368
+ debugpointP.material.modulation = 0.75f;
11369
+
11370
+ debugpointC.radius = radius;
11371
+ debugpointC.recalculate();
11372
+ debugpointC.material = new cMaterial();
11373
+ debugpointC.material.color = 0.5f; // Cyan
11374
+ debugpointC.material.modulation = 0.75f;
11375
+
11376
+ debugpointR.radius = radius;
11377
+ debugpointR.recalculate();
11378
+ debugpointR.material = new cMaterial();
11379
+ debugpointR.material.color = 0f; // Red
11380
+ debugpointR.material.modulation = 0.75f;
974911381
975011382 InitPoints(radius);
975111383 }
975211384 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9753
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9754
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9755
- DrawPoints(this);
11385
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11386
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11387
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11388
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
11389
+ // DrawPoints(this);
975611390 }
975711391
975811392 // debugstuff.draw(this, /*(Composite)*/ null, false);
975911393 }
9760
-// GraphreeD.traceoff();
11394
+// GrafreeD.traceoff();
976111395 //System.out.println(stackdepth);
9762
- if (drawMode == 0)
11396
+ if (DrawMode() == 0)
976311397 {
976411398 ReleaseTextures(DEFAULT_TEXTURES);
976511399
....@@ -9784,17 +11418,19 @@
978411418
978511419 checker = null;
978611420
9787
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11421
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
978811422 FindChecker(object);
978911423
9790
- if (checker != null && drawMode == DEFAULT)
11424
+ if (checker != null && DrawMode() == DEFAULT)
979111425 {
9792
- // BindTexture(IMMORTAL_TEXTURE);
11426
+ //BindTexture(IMMORTAL_TEXTURE);
11427
+ BindTextures(checker.GetTextures(), checker.texres);
979311428 // NEAREST
979411429 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
979511430 DrawChecker(gl);
979611431 //checker.Draw(this, null, false);
979711432 // ReleaseTexture(IMMORTAL_TEXTURE);
11433
+ ReleaseTextures(checker.GetTextures());
979811434 }
979911435
980011436 if (object.parent != null)
....@@ -9807,7 +11443,7 @@
980711443 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
980811444 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
980911445
9810
- if (DISPLAYTEXT && drawMode == DEFAULT)
11446
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
981111447 {
981211448 // Draw it once, then use the raster
981311449 Balloon(gl, balloon.createGraphics());
....@@ -9863,9 +11499,9 @@
986311499 int[] xs = new int[3];
986411500 int[] ys = new int[3];
986511501
9866
- void DrawString(Object3D obj) // String string)
11502
+ public void DrawString(Object3D obj) // String string) // INTERFACE
986711503 {
9868
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11504
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
986911505 {
987011506 return;
987111507 }
....@@ -10253,7 +11889,7 @@
1025311889 return;
1025411890 }
1025511891
10256
- if (obj instanceof CheckerIG)
11892
+ if (obj instanceof Checker)
1025711893 {
1025811894 checker = obj;
1025911895
....@@ -10325,11 +11961,13 @@
1032511961 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1032611962 "PARAM params7 = program.env[7];" + // noise power, opacity power
1032711963 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10328
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
11964
+ "PARAM options1 = program.env[62];" + // fog rgb color
11965
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1032911966 "PARAM pointlight = program.env[127];" + // ...
1033011967 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1033111968 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1033211969 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
11970
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1033311971 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1033411972 "PARAM ten = { 10, 10, 10, 1.0 };" +
1033511973 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10350,6 +11988,7 @@
1035011988 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1035111989 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1035211990 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11991
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1035311992 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1035411993 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1035511994 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10390,6 +12029,10 @@
1039012029 "TEMP R1;" +
1039112030 "TEMP R2;" +
1039212031 "TEMP R3;" +
12032
+ "TEMP min;" +
12033
+ "TEMP max;" +
12034
+ "TEMP average;" +
12035
+ "TEMP saturation;" +
1039312036 "TEMP keep1;" +
1039412037 "TEMP keep2;" +
1039512038 "TEMP keep3;" +
....@@ -10920,10 +12563,40 @@
1092012563
1092112564 // skin?
1092212565 // Saturation for skin
10923
- /**/ // c'est ici
10924
- (Skinshader? "DP3 temp.x, final,one;" +
12566
+ /**/
12567
+ (Skinshader?
12568
+ "DP3 average.x, final,one;" +
12569
+ "MUL average, one3rd.xxxx,average.xxxx;" +
12570
+
12571
+ "MIN min.x, final.x,final.y;" +
12572
+ "MIN min.x, min.x,final.z;" +
12573
+
12574
+ "MAX max.x, final.x,final.y;" +
12575
+ "MAX max.x, max.x,final.z;" +
12576
+ "MOV max, max.xxxx;" +
12577
+
12578
+ "SUB saturation, max, final;" +
12579
+
12580
+ "ADD temp.x, max.x, one10th.x;" +
12581
+ "RCP temp.x, temp.x;" +
12582
+ "MUL temp.x, temp.x, half.x;" +
12583
+ "MUL saturation, saturation, temp.xxxx;" +
12584
+
12585
+ "DP3 ndotl.x, normald, light;" +
12586
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
12587
+
12588
+ "SUB temp.x, one.x, ndotl.x;" +
12589
+ "ADD temp.x, temp.x, options2.z;" + // lightsheen
12590
+ "ADD temp.y, one.y, options2.y;" + // sursurface
12591
+ "MUL temp.x, temp.x, temp.y;" +
12592
+
12593
+ "MUL saturation, saturation, temp.xxxx;" +
12594
+ "SUB_SAT temp, max, saturation;" +
12595
+/**
12596
+ "DP3 temp.x, final,one;" +
1092512597 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10926
- "SUB temp, final,R2;" +
12598
+ "SUB temp, final, R2;" +
12599
+
1092712600 // using light angle
1092812601 "DP3 ndotl.x, normald,light;" +
1092912602 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10936,7 +12609,6 @@
1093612609 // using light intensity
1093712610 "MOV ndotl.z, R2.x;" +
1093812611 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10939
-
1094012612 // june 2014
1094112613 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1094212614 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10948,6 +12620,7 @@
1094812620 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1094912621
1095012622 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
12623
+/**/
1095112624
1095212625 // "ADD final, R2,temp;" +
1095312626 "MOV final, temp;"
....@@ -11037,7 +12710,7 @@
1103712710 /**/
1103812711 // HDR
1103912712 "MOV temp.z, final.a;" +
11040
- "MUL final, final,options1.w;" +
12713
+ "MUL final, final,options2.x;" +
1104112714 "MOV final.a, temp.z;" +
1104212715 /**/
1104312716
....@@ -11074,10 +12747,17 @@
1107412747 "MOV final.z, zero.x;" +
1107512748 "MOV final.a, one.w;":""
1107612749 ) +
12750
+ /*
1107712751 (NORMALdebug?"MOV final.x, normal.x;" +
1107812752 "MOV final.y, normal.y;" +
1107912753 "MOV final.z, normal.z;" +
1108012754 "MOV final.a, one.w;":""
12755
+ ) +
12756
+ */
12757
+ (NORMALdebug?"SUB final.x, one.x, final.x;" +
12758
+ "SUB final.y, one.x, final.y;" +
12759
+ "SUB final.z, one.x, final.z;" +
12760
+ "MOV final.a, final.a;":""
1108112761 ) +
1108212762 // "MOV final, bumpmap;" +
1108312763 "MOV result.color, final;" +
....@@ -11223,6 +12903,7 @@
1122312903 String Shadow(String depth, String shadow)
1122412904 {
1122512905 return "MAX temp.x, ndotl.x, one64th.x;" +
12906
+ "MIN temp.x, temp.x, ninetenth.x;" +
1122612907 /**/
1122712908 // Sine
1122812909 "MUL temp.y, temp.x, temp.x;" +
....@@ -11847,9 +13528,10 @@
1184713528 return;
1184813529 }
1184913530
13531
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1185013532
1185113533 // TIMER
11852
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13534
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1185313535 {
1185413536 keepboxmode = BOXMODE;
1185513537 keepsupport = SUPPORT;
....@@ -11978,7 +13660,7 @@
1197813660 // ObjEditor.tweenManager.update(1f / 60f);
1197913661
1198013662 // fev 2014???
11981
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13663
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1198213664 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1198313665 pingthread.StepToTarget(true); // true);
1198413666 }
....@@ -12090,6 +13772,11 @@
1209013772 cVector tmp = new cVector();
1209113773 cVector tmp2 = new cVector();
1209213774 boolean isMoving;
13775
+
13776
+ public cVector TargetLookAt()
13777
+ {
13778
+ return targetLookAt;
13779
+ }
1209313780
1209413781 class PingThread extends Thread
1209513782 {
....@@ -12229,7 +13916,7 @@
1222913916 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1223013917 if (lightMode)
1223113918 {
12232
- lighttouched = true;
13919
+ Globals.lighttouched = true;
1223313920 }
1223413921
1223513922 if (OEILONCE && OEIL)
....@@ -12287,7 +13974,7 @@
1228713974 mouseDown = false;
1228813975 if (lightMode)
1228913976 {
12290
- lighttouched = true;
13977
+ Globals.lighttouched = true;
1229113978 }
1229213979 repaint();
1229313980 alreadypainted = true;
....@@ -12295,7 +13982,7 @@
1229513982 isMoving = false;
1229613983 } //??
1229713984
12298
- if (isLIVE() && !alreadypainted)
13985
+ if (Globals.isLIVE() && !alreadypainted)
1229913986 {
1230013987 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1230113988 repaint();
....@@ -12307,7 +13994,7 @@
1230713994 {
1230813995 if (lightMode)
1230913996 {
12310
- lighttouched = true;
13997
+ Globals.lighttouched = true;
1231113998 }
1231213999 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1231314000 }
....@@ -12550,6 +14237,7 @@
1255014237 {
1255114238 manipCamera.Translate(dx, dy, getWidth());
1255214239 }
14240
+ else
1255314241 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1255414242 {
1255514243 manipCamera.RotateInterest(dx, dy);
....@@ -12560,7 +14248,7 @@
1256014248
1256114249 if (manipCamera == lightCamera)
1256214250 {
12563
- lighttouched = true;
14251
+ Globals.lighttouched = true;
1256414252 }
1256514253 /*
1256614254 switch (mode)
....@@ -12775,13 +14463,15 @@
1277514463 {
1277614464 mouseMode |= ZOOM;
1277714465 }
12778
- if ((modifiers & META) == META)
14466
+
14467
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
+ if (capsLocked || (modifiers & META) == META)
1277914469 {
1278014470 mouseMode |= VR; // BACKFORTH;
1278114471 }
1278214472 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1278314473 {
12784
- mouseMode |= SELECT; // BACKFORTH;
14474
+ mouseMode |= SELECT;
1278514475 }
1278614476 if ((modifiers & COMMAND) == COMMAND)
1278714477 {
....@@ -12789,6 +14479,7 @@
1278914479 }
1279014480 if ((modifiers & SHIFT) == SHIFT || forcetranslate)
1279114481 {
14482
+ mouseMode &= ~VR;
1279214483 mouseMode |= TRANSLATE;
1279314484 }
1279414485 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12818,7 +14509,7 @@
1281814509 SetMouseMode(modifiers);
1281914510 }
1282014511
12821
- theRenderer.keyPressed(key);
14512
+ Globals.theRenderer.keyPressed(key);
1282214513 }
1282314514
1282414515 int kompactbit = 4; // power bit
....@@ -12830,7 +14521,7 @@
1283014521 float SATPOW = 1; // 2; // 0.5f;
1283114522 float BRIPOW = 1; // 0.5f; // 0.5f;
1283214523
12833
- void keyPressed(int key)
14524
+ public void keyPressed(int key)
1283414525 {
1283514526 if (key >= '0' && key <= '5')
1283614527 clampbit = (key-'0');
....@@ -12945,7 +14636,7 @@
1294514636 case 'B':
1294614637 BRISMOOTH ^= true;
1294714638 SHADOWCULLFACE ^= true;
12948
- lighttouched = true;
14639
+ Globals.lighttouched = true;
1294914640 repaint();
1295014641 break;
1295114642 case 'b':
....@@ -13045,7 +14736,7 @@
1304514736 repaint();
1304614737 break;
1304714738 case 'O':
13048
- drawMode = OCCLUSION;
14739
+ Globals.drawMode = OCCLUSION; // WARNING
1304914740 repaint();
1305014741 break;
1305114742 case 'o':
....@@ -13136,7 +14827,7 @@
1313614827 break;
1313714828 case ' ':
1313814829 lightMode ^= true;
13139
- lighttouched = true;
14830
+ Globals.lighttouched = true;
1314014831 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1314114832 targetLookAt.set(manipCamera.lookAt);
1314214833 repaint();
....@@ -13148,11 +14839,11 @@
1314814839 repaint();
1314914840 break;
1315014841 case 'Z':
13151
- RESIZETEXTURE ^= true;
13152
- break;
14842
+ //RESIZETEXTURE ^= true;
14843
+ //break;
1315314844 case 'z':
1315414845 RENDERSHADOW ^= true;
13155
- lighttouched = true;
14846
+ Globals.lighttouched = true;
1315614847 repaint();
1315714848 break;
1315814849 //case UP:
....@@ -13178,7 +14869,8 @@
1317814869 FlipTransform();
1317914870 break;
1318014871 case ENTER:
13181
- object.editWindow.ScreenFit(); // Edit();
14872
+ // object.editWindow.ScreenFit(); // Edit();
14873
+ ToggleLive();
1318214874 break;
1318314875 case DELETE:
1318414876 ClearSelection();
....@@ -13266,6 +14958,7 @@
1326614958 }
1326714959 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1326814960 }
14961
+
1326914962 static double OCCLUSIONBOOST = 1; // 0.5;
1327014963
1327114964 void keyReleased(int key, int modifiers)
....@@ -13277,7 +14970,7 @@
1327714970 }
1327814971 }
1327914972
13280
- protected void processKeyEvent(KeyEvent e)
14973
+ public void processKeyEvent(KeyEvent e)
1328114974 {
1328214975 switch (e.getID())
1328314976 {
....@@ -13753,6 +15446,7 @@
1375315446 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1375415447 }
1375515448
15449
+ // To avoid clear.
1375615450 public void update(Graphics g)
1375715451 {
1375815452 paint(g);
....@@ -14355,7 +16049,7 @@
1435516049 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1435616050 gl.glPushMatrix();
1435716051 gl.glLoadIdentity();
14358
- PushMatrix(checker.toParent);
16052
+ //PushMatrix(checker.toParent);
1435916053
1436016054 gl.glMatrixMode(GL.GL_TEXTURE);
1436116055 gl.glPushMatrix();
....@@ -14378,8 +16072,8 @@
1437816072
1437916073 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1438016074
14381
- float step = 0.1666f; //0.25f;
14382
- float stepv = step * 1652 / 998;
16075
+ float step = 2; // 0.1666f; //0.25f;
16076
+ float stepv = 2; // step * 1652 / 998;
1438316077
1438416078 int i0 = 0;
1438516079 /*
....@@ -14415,20 +16109,21 @@
1441516109 /**/
1441616110 //checker.GetMaterial().opacity = 1.1f;
1441716111 ////checker.GetMaterial().ambient = 0.99f;
14418
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14419
- Object3D.selectedstack[Object3D.materialdepth] = false;
14420
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16112
+ materialstack[materialdepth] = checker.material;
16113
+ selectedstack[materialdepth] = false;
16114
+ cStatic.objectstack[materialdepth++] = checker;
1442116115 //System.out.println("material " + material);
1442216116 //Applet3D.tracein(this, selected);
1442316117 vector2buffer = checker.projectedVertices;
1442416118
14425
- checker.GetMaterial().Draw(this, false); // true);
16119
+ //checker.GetMaterial().Draw(this, false); // true);
16120
+ DrawMaterial(checker.GetMaterial(), false); // true);
1442616121
14427
- Object3D.materialdepth -= 1;
14428
- if (Object3D.materialdepth > 0)
16122
+ materialdepth -= 1;
16123
+ if (materialdepth > 0)
1442916124 {
14430
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14431
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16125
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16126
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1443216127 }
1443316128 //checker.GetMaterial().opacity = 1f;
1443416129 ////checker.GetMaterial().ambient = 1f;
....@@ -14449,15 +16144,27 @@
1444916144
1445016145 //float u = (i+1)/2;
1445116146 //float v = (j+1)/2;
14452
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
16147
+ if (checker.flipV)
16148
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
16149
+ else
16150
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1445316151 gl.glVertex3f(i, j, -0.5f);
1445416152
16153
+ if (checker.flipV)
16154
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
16155
+ else
1445516156 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1445616157 gl.glVertex3f(i + step, j, -0.5f);
1445716158
16159
+ if (checker.flipV)
16160
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
16161
+ else
1445816162 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1445916163 gl.glVertex3f(i + step, j + stepv, -0.5f);
1446016164
16165
+ if (checker.flipV)
16166
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
16167
+ else
1446116168 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1446216169 gl.glVertex3f(i, j + stepv, -0.5f);
1446316170 }
....@@ -14469,7 +16176,7 @@
1446916176 gl.glMatrixMode(GL.GL_PROJECTION);
1447016177 gl.glPopMatrix();
1447116178 gl.glMatrixMode(GL.GL_MODELVIEW);
14472
- PopMatrix(null); // checker.toParent); // null);
16179
+ //PopMatrix(null); // checker.toParent); // null);
1447316180 gl.glPopMatrix();
1447416181 PopTextureMatrix(checker.toParent);
1447516182 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14582,14 +16289,14 @@
1458216289
1458316290 //int tmp = selection_view;
1458416291 //selection_view = -1;
14585
- int temp = drawMode;
14586
- drawMode = SELECTION;
16292
+ int temp = DrawMode();
16293
+ Globals.drawMode = SELECTION; // WARNING
1458716294 indexcount = 0;
1458816295 parent.display(drawable);
1458916296 //selection_view = tmp;
1459016297 //if (temp == SELECTION)
1459116298 // temp = DEFAULT; // patch for selection debug
14592
- drawMode = temp;
16299
+ Globals.drawMode = temp; // WARNING
1459316300
1459416301 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1459516302
....@@ -14639,6 +16346,11 @@
1463916346 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1464016347 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1464116348
16349
+ // Will fit the mesh !!!
16350
+ selectedpoint.toParent[0][0] = 0.0001;
16351
+ selectedpoint.toParent[1][1] = 0.0001;
16352
+ selectedpoint.toParent[2][2] = 0.0001;
16353
+
1464216354 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1464316355
1464416356 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14682,16 +16394,16 @@
1468216394 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]));
1468316395 }
1468416396
14685
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
16397
+ previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
1468616398 }
1468716399 }
1468816400
1468916401 if (!movingcamera && !PAINTMODE)
1469016402 object.editWindow.ScreenFitPoint(); // fev 2014
1469116403
14692
- if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16404
+ if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1469316405 {
14694
- Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16406
+ Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1469516407
1469616408 Object3D group = new Object3D("inst" + paintcount++);
1469716409
....@@ -14857,14 +16569,14 @@
1485716569 //gl.glColorMask(false, false, false, false);
1485816570
1485916571 //render_scene_from_light_view(gl, drawable, 0, 0);
14860
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16572
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1486116573 {
1486216574 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1486316575
14864
- int temp = drawMode;
14865
- drawMode = SHADOW;
16576
+ int temp = DrawMode();
16577
+ Globals.drawMode = SHADOW; // WARNING
1486616578 parent.display(drawable);
14867
- drawMode = temp;
16579
+ Globals.drawMode = temp; // WARNING
1486816580 }
1486916581
1487016582 gl.glCullFace(gl.GL_BACK);
....@@ -14917,7 +16629,6 @@
1491716629
1491816630 class AntialiasBuffer implements GLEventListener
1491916631 {
14920
-
1492116632 CameraPane parent = null;
1492216633
1492316634 AntialiasBuffer(CameraPane p)
....@@ -15027,13 +16738,19 @@
1502716738 gl.glFlush();
1502816739
1502916740 /**/
15030
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16741
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1503116742
15032
- int[] pixels = occlusionsizebuffer.array();
16743
+ float[] pixels = occlusionsizebuffer.array();
1503316744
1503416745 double r = 0, g = 0, b = 0;
1503516746
1503616747 double count = 0;
16748
+
16749
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16750
+
16751
+ float mindepth = 1;
16752
+
16753
+ double FACTOR = 1;
1503716754
1503816755 for (int i = 0; i < pixels.length; i++)
1503916756 {
....@@ -15118,7 +16835,7 @@
1511816835
1511916836 double scale = ray.z; // 1; // cos
1512016837
15121
- int p = pixels[newindex];
16838
+ float depth = pixels[newindex];
1512216839
1512316840 /*
1512416841 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15142,10 +16859,23 @@
1514216859 scale = (1 - modu) * modv;
1514316860 */
1514416861
15145
- r += ((p >> 16) & 0xFF) * scale / 255;
15146
- g += ((p >> 8) & 0xFF) * scale / 255;
15147
- b += (p & 0xFF) * scale / 255;
16862
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16863
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16864
+ //b += (p & 0xFF) * scale / 255;
16865
+
16866
+ if (mindepth > depth)
16867
+ {
16868
+ mindepth = depth;
16869
+ }
1514816870
16871
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16872
+
16873
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16874
+
16875
+ r += factor * scale;
16876
+ g += factor * scale;
16877
+ b += factor * scale;
16878
+
1514916879 count += scale;
1515016880 }
1515116881
....@@ -15243,12 +16973,6 @@
1524316973 GLUT glut = new GLUT();
1524416974
1524516975
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;
1525216976 public boolean spherical = false;
1525316977 static boolean DEBUG_OCCLUSION = false;
1525416978 static boolean DEBUG_SELECTION = false;
....@@ -15261,10 +16985,12 @@
1526116985 int AAbuffersize = 0;
1526216986
1526316987 //double[] selectedpoint = new double[3];
15264
- static Sphere selectedpoint = new Sphere();
16988
+ static Superellipsoid selectedpoint = new Superellipsoid();
1526516989 static Sphere previousselectedpoint = null;
15266
- static Sphere debugpoint = new Sphere();
15267
- static Sphere debugpoint2 = new Sphere();
16990
+ static Sphere debugpointG = new Sphere();
16991
+ static Sphere debugpointP = new Sphere();
16992
+ static Sphere debugpointC = new Sphere();
16993
+ static Sphere debugpointR = new Sphere();
1526816994
1526916995 static Sphere debugpoints[] = new Sphere[8];
1527016996
....@@ -15295,7 +17021,7 @@
1529517021 }
1529617022 }
1529717023
15298
- static void DrawPoints(CameraPane cpane)
17024
+ static void DrawPoints(iCameraPane cpane)
1529917025 {
1530017026 for (int i=0; i<8; i++) // first and last are red
1530117027 {
....@@ -15317,7 +17043,8 @@
1531717043 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1531817044 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1531917045 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15320
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17046
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17047
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1532117048 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1532217049 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1532317050 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15326,10 +17053,11 @@
1532617053 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1532717054 // Depth buffer format
1532817055 //private int depth_format;
15329
- static public void NextIndex(Object3D o, GL gl)
17056
+
17057
+ public void NextIndex()
1533017058 {
1533117059 indexcount+=16;
15332
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17060
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1533317061 //objects[indexcount] = o;
1533417062 //System.out.println("indexcount = " + indexcount);
1533517063 }