Normand Briere
2019-04-24 07750666120cf38c7ad4f3a3a583a8c4d582bb0e
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 }
....@@ -2000,10 +3601,12 @@
20003601 */
20013602 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20023603 {
3604
+ int pixelformat = texturedata.getPixelFormat();
3605
+
20033606 int stride = 1;
2004
- 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)
20053608 stride = 3;
2006
- 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)
20073610 stride = 4;
20083611
20093612 int width = texturedata.getWidth();
....@@ -6269,7 +7872,7 @@
62697872 return null;
62707873 }
62717874
6272
- void ReleaseTextures(cTexture tex)
7875
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62737876 {
62747877 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62757878 {
....@@ -6307,7 +7910,7 @@
63077910
63087911 void ReleaseTexture(String tex, boolean bump)
63097912 {
6310
- if (// drawMode != 0 || /*tex == null ||*/
7913
+ if (// DrawMode() != 0 || /*tex == null ||*/
63117914 ambientOcclusion ) // || !textureon)
63127915 {
63137916 return;
....@@ -6333,7 +7936,7 @@
63337936 {
63347937 bumpdepth--;
63357938
6336
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7939
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63377940 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63387941 {
63397942 // assert (bumpstack[bumpdepth] == texture);
....@@ -6363,7 +7966,7 @@
63637966 {
63647967 pigmentdepth--;
63657968
6366
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
7969
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63677970 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63687971 {
63697972 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6408,9 +8011,9 @@
64088011 }
64098012 }
64108013
6411
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8014
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64128015 {
6413
- if (// drawMode != 0 || /*tex == null ||*/
8016
+ if (// DrawMode() != 0 || /*tex == null ||*/
64148017 ambientOcclusion ) // || !textureon)
64158018 {
64168019 return; // false;
....@@ -6694,19 +8297,19 @@
66948297
66958298 if (bump)
66968299 {
6697
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
8300
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66988301 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66998302 }
67008303 else
67018304 {
6702
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
8305
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
67038306 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
67048307 }
67058308
67068309 return texture!=null?texture.texture:null;
67078310 }
67088311
6709
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8312
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
67108313 {
67118314 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67128315
....@@ -7310,9 +8913,9 @@
73108913 static boolean occlusionInitialized = false;
73118914 boolean selection = false;
73128915 boolean pointselection = false;
7313
- /*static*/ boolean lighttouched = true;
8916
+ ///*static*/ boolean lighttouched = true;
73148917 boolean deselect;
7315
- boolean ambientOcclusion = false;
8918
+ private boolean ambientOcclusion = false;
73168919 static boolean flash = false;
73178920 /*static*/ boolean wait = false;
73188921 boolean displaydone = false; // after repaint() calls
....@@ -7442,6 +9045,8 @@
74429045 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74439046 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74449047 double scale = lightCamera.SCALE / lightCamera.Distance();
9048
+// PATCH FILLE AUX JEANS
9049
+ //scale *= lightCamera.shaper_fovy / 25;
74459050 gl.glScaled(2 * scale, 2 * scale, -scale);
74469051 gl.glTranslated(0, 0, lightCamera.DECAL);
74479052
....@@ -7590,15 +9195,14 @@
75909195
75919196 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75929197 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
7593
- 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
75949200
75959201 static int imagecount = 0; // movie generation
75969202
75979203 static int jitter = 0;
75989204
75999205 boolean restartframe = false;
7600
-
7601
- static int framecount = 0; // general-purpose global count
76029206
76039207 void displayAntiAliased(javax.media.opengl.GL gl)
76049208 {
....@@ -7628,14 +9232,14 @@
76289232
76299233 //System.out.println("start frame");
76309234 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7631
- 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)
76329236 {
7633
- framecount++;
9237
+ Globals.framecount++;
76349238
76359239 if (CameraPane.tickcount > 0)
76369240 CameraPane.tickcount--;
76379241
7638
-// 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)
76399243 // restartframe = true;
76409244 if (options1[2] > 100 && (jitter%2==0))
76419245 {
....@@ -7668,7 +9272,7 @@
76689272
76699273 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76709274 */
7671
- lighttouched = true;
9275
+ Globals.lighttouched = true;
76729276 //System.err.println(" shadowbuffer: " + jitter);
76739277 shadowbuffer.display();
76749278
....@@ -7690,7 +9294,7 @@
76909294
76919295 if (renderCamera != lightCamera)
76929296 for (int count = parentcam.GetTransformCount(); --count>=0;)
7693
- LA.matConcat(parentcam.toParent, matrix, matrix);
9297
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76949298
76959299 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76969300
....@@ -7706,7 +9310,7 @@
77069310
77079311 if (renderCamera != lightCamera)
77089312 for (int count = parentcam.GetTransformCount(); --count>=0;)
7709
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9313
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77109314
77119315 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77129316
....@@ -7923,7 +9527,7 @@
79239527
79249528 if (!BOXMODE)
79259529 {
7926
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
9530
+ System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
79279531 }
79289532
79299533 if (!BOXMODE)
....@@ -7951,7 +9555,7 @@
79519555 {
79529556 if (ACSIZE > 1)
79539557 {
7954
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
9558
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79559559 }
79569560 }
79579561
....@@ -7961,7 +9565,7 @@
79619565 ABORTED = false;
79629566 }
79639567 else
7964
- GraphreeD.wav.cursor += 735 * ACSIZE;
9568
+ GrafreeD.wav.cursor += 735 * ACSIZE;
79659569
79669570 if (false)
79679571 {
....@@ -8615,13 +10219,6 @@
861510219 }
861610220 }
861710221
8618
- boolean IsFrozen()
8619
- {
8620
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8621
-
8622
- return !selectmode && cameracount == 0; // != 0;
8623
- }
8624
-
862510222 boolean niceon = false;
862610223 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
862710224 boolean currentlydrawing = false;
....@@ -8631,16 +10228,16 @@
863110228
863210229 public void display(GLAutoDrawable drawable)
863310230 {
8634
- if (GraphreeD.savesound && GraphreeD.hassound)
10231
+ if (GrafreeD.savesound && GrafreeD.hassound)
863510232 {
8636
- GraphreeD.wav.save();
8637
- GraphreeD.savesound = false;
8638
- GraphreeD.hassound = false;
10233
+ GrafreeD.wav.save();
10234
+ GrafreeD.savesound = false;
10235
+ GrafreeD.hassound = false;
863910236 }
864010237 // if (DEBUG_SELECTION)
864110238 // {
8642
-// if (drawMode != SELECTION)
8643
-// drawMode = SELECTION;
10239
+// if (DrawMode() != SELECTION)
10240
+// DrawMode() = SELECTION;
864410241 // }
864510242
864610243 if (!isRenderer)
....@@ -8696,9 +10293,9 @@
869610293
869710294 //ANTIALIAS = 0;
869810295
8699
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10296
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870010297 {
8701
- if (niceon || isLIVE())
10298
+ if (niceon || Globals.isLIVE())
870210299 {
870310300 //if(active == 0)
870410301 // antialiaser = null;
....@@ -8723,7 +10320,7 @@
872310320 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872410321 */
872510322
8726
- if (drawMode == DEFAULT)
10323
+ if (DrawMode() == DEFAULT)
872710324 {
872810325 currentlydrawing = true;
872910326 }
....@@ -8754,18 +10351,18 @@
875410351
875510352 // if(Applet3D.clipboard != null)
875610353 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8757
-//drawMode = SELECTION;
10354
+//DrawMode() = SELECTION;
875810355 indexcount = 0;
875910356
8760
- if (drawMode == OCCLUSION)
10357
+ if (DrawMode() == OCCLUSION)
876110358 {
8762
- drawMode = DEFAULT;
10359
+ Globals.drawMode = DEFAULT; // WARNING
876310360 ambientOcclusion = true;
876410361 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876510362 Object3D theobject = object;
876610363 Object3D theparent = object.parent;
876710364 object.parent = null;
8768
- object = (Object3D)GraphreeD.clone(object);
10365
+ object = (Object3D)GrafreeD.clone(object);
876910366 object.Stripify();
877010367 if (theobject.selection == null || theobject.selection.Size() == 0)
877110368 theobject.PreprocessOcclusion(this);
....@@ -8778,19 +10375,19 @@
877810375 ambientOcclusion = false;
877910376 }
878010377
8781
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10378
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
878210379 {
878310380 //if (RENDERSHADOW) // ?
878410381 if (!IsFrozen())
878510382 {
878610383 // dec 2012
8787
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10384
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
878810385 {
8789
- framecount++;
10386
+ Globals.framecount++;
879010387 shadowbuffer.display();
879110388 }
879210389 }
8793
- lighttouched = false; // ??
10390
+ Globals.lighttouched = false; // ??
879410391 //drawing = true;
879510392 //lighttouched = true;
879610393 }
....@@ -8811,9 +10408,9 @@
881110408 //eyeCamera.shaper_fovy = 1;
881210409 }
881310410
8814
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10411
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881510412 {
8816
- //System.out.println("drawMode = " + drawMode);
10413
+ //System.out.println("DrawMode() = " + DrawMode());
881710414 vertexMode |= VP_PASS;
881810415 //vertexMode |= VP_PROJECTION;
881910416 if (!ambientOcclusion)
....@@ -8873,7 +10470,7 @@
887310470 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887410471 //Camera lightcam = new Camera(light0);
887510472
8876
- if (drawMode == SHADOW)
10473
+ if (DrawMode() == SHADOW)
887710474 {
887810475 /*
887910476 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8912,7 +10509,7 @@
891210509 // if (parentcam != renderCamera) // not a light
891310510 if (cam != lightCamera)
891410511 for (int count = parentcam.GetTransformCount(); --count>=0;)
8915
- LA.matConcat(parentcam.toParent, matrix, matrix);
10512
+ LA.matConcat(matrix, parentcam.toParent, matrix);
891610513
891710514 for (int j = 0; j < 4; j++)
891810515 {
....@@ -8927,7 +10524,7 @@
892710524 // if (parentcam != renderCamera) // not a light
892810525 if (cam != lightCamera)
892910526 for (int count = parentcam.GetTransformCount(); --count>=0;)
8930
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10527
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
893110528
893210529 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893310530
....@@ -8963,7 +10560,7 @@
896310560 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896410561 } else
896510562 {
8966
- if (drawMode != DEFAULT)
10563
+ if (DrawMode() != DEFAULT)
896710564 {
896810565 gl.glClearColor(1, 1, 1, 0);
896910566 } // 1);
....@@ -9028,7 +10625,7 @@
902810625
902910626 fast &= !ambientOcclusion;
903010627
9031
- if (drawMode == DEFAULT)
10628
+ if (DrawMode() == DEFAULT)
903210629 {
903310630 //gl.glEnable(gl.GL_ALPHA_TEST);
903410631 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9089,6 +10686,8 @@
908910686 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909010687 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909110688 double scale = lightCamera.SCALE / lightCamera.Distance();
10689
+// PATCH FILLE AUX JEANS
10690
+ //scale *= lightCamera.shaper_fovy / 25;
909210691 gl.glScaled(2 * scale, 2 * scale, -scale);
909310692 gl.glTranslated(0, 0, lightCamera.DECAL);
909410693
....@@ -9224,10 +10823,12 @@
922410823 gl.glMatrixMode(gl.GL_PROJECTION);
922510824 gl.glLoadIdentity();
922610825
9227
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10826
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
922810827 {
922910828 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923010829 double scale = lightCamera.SCALE / lightCamera.Distance();
10830
+// PATCH FILLE AUX JEANS
10831
+ //scale *= lightCamera.shaper_fovy / 25;
923110832 gl.glScaled(2 * scale, 2 * scale, -scale);
923210833 gl.glTranslated(0, 0, lightCamera.DECAL);
923310834 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9280,7 +10881,7 @@
928010881 //gl.glPushMatrix();
928110882 gl.glLoadIdentity();
928210883
9283
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10884
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928410885 {
928510886 //LA.xformPos(light0, lightCamera.fromScreen, light);
928610887 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9367,7 +10968,7 @@
936710968 }
936810969
936910970 /**/
9370
- if (true) // drawMode == SELECTION) // != DEFAULT)
10971
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937110972 gl.glDisable(gl.GL_LIGHTING);
937210973 else
937310974 gl.glEnable(gl.GL_LIGHTING);
....@@ -9379,12 +10980,13 @@
937910980
938010981 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
938110982 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
10983
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
938210984
938310985 options2[0] *= renderCamera.Distance();
938410986
938510987 lightslot = 64;
938610988
9387
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10989
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
938810990 {
938910991 DrawLights(object);
939010992 }
....@@ -9395,7 +10997,7 @@
939510997 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
939610998 //System.out.println("fragmentMode = " + fragmentMode);
939710999
9398
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11000
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
939911001 {
940011002 /*
940111003 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9428,7 +11030,7 @@
942811030 }
942911031 }
943011032
9431
- if (drawMode == DEFAULT)
11033
+ if (DrawMode() == DEFAULT)
943211034 {
943311035 if (WIREFRAME && !ambientOcclusion)
943411036 {
....@@ -9446,7 +11048,7 @@
944611048 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
944711049 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
944811050
9449
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11051
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945011052 {
945111053 if (vertexMode != 0) // && !fast)
945211054 {
....@@ -9466,7 +11068,7 @@
946611068 }
946711069 }
946811070
9469
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11071
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947011072 {
947111073 //gl.glDepthFunc(GL.GL_LEQUAL);
947211074 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9494,7 +11096,7 @@
949411096 //gl.glDepthMask(false);
949511097 }
949611098
9497
- if (false) // drawMode == SHADOW)
11099
+ if (false) // DrawMode() == SHADOW)
949811100 {
949911101 //SetColumnMajorData(cameraInverseTransform, view_1);
950011102 //System.out.println("light = " + cameraInverseTransform);
....@@ -9508,16 +11110,16 @@
950811110 //System.out.println("object = " + object);
950911111 if (!frozen && !imageLocked)
951011112 {
9511
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11113
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951211114 {
951311115 displayAntiAliased(gl);
951411116 } else
951511117 {
951611118 programcount = 0;
9517
- int keepmode = drawMode;
11119
+ int keepmode = DrawMode();
951811120 // if (DEBUG_SELECTION)
951911121 // {
9520
-// drawMode = SELECTION;
11122
+// DrawMode() = SELECTION;
952111123 // }
952211124 // for point selection
952311125 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9527,10 +11129,10 @@
952711129 DrawObject(gl);
952811130
952911131 // jan 2013 System.err.println("RESET ABORT (display)");
9530
- // if (drawMode == DEFAULT)
11132
+ // if (DrawMode() == DEFAULT)
953111133 // ABORTED = false;
953211134 fullreset = false;
9533
- drawMode = keepmode;
11135
+ Globals.drawMode = keepmode; // WARNING
953411136 //System.out.println("PROGRAM SWITCH " + programcount);
953511137 }
953611138 }
....@@ -9538,11 +11140,11 @@
953811140 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
953911141 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954011142
9541
- if (drawMode == DEFAULT)
11143
+ if (DrawMode() == DEFAULT)
954211144 {
954311145 ReleaseTexture(NOISE_TEXTURE, false);
954411146 }
9545
- //if (drawMode == DEFAULT)
11147
+ //if (DrawMode() == DEFAULT)
954611148 {
954711149
954811150 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9554,7 +11156,7 @@
955411156 //else
955511157 //gl.glDisable(gl.GL_TEXTURE_2D);
955611158 //gl.glPopMatrix();
9557
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11159
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
955811160 {
955911161 //new Exception().printStackTrace();
956011162 //System.out.println("Draw image " + width + ", " + height);
....@@ -9596,7 +11198,7 @@
959611198 //gl.glFlush();
959711199 }
959811200
9599
- if (flash && drawMode == DEFAULT)
11201
+ if (flash && DrawMode() == DEFAULT)
960011202 {
960111203 flash = false;
960211204 wait = true;
....@@ -9604,9 +11206,9 @@
960411206 }
960511207
960611208 //drawing = false;
9607
- //if(drawMode == DEFAULT)
11209
+ //if(DrawMode() == DEFAULT)
960811210 // niceon = false;
9609
- if (drawMode == DEFAULT)
11211
+ if (DrawMode() == DEFAULT)
961011212 {
961111213 currentlydrawing = false;
961211214 }
....@@ -9626,7 +11228,7 @@
962611228 repaint();
962711229 }
962811230
9629
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11231
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963011232 repaint();
963111233
963211234 displaydone = true;
....@@ -9660,10 +11262,10 @@
966011262 e.printStackTrace();
966111263 }
966211264
9663
- if (GraphreeD.RENDERME > 0)
9664
- GraphreeD.RENDERME--; // mechante magouille
11265
+ if (GrafreeD.RENDERME > 0)
11266
+ GrafreeD.RENDERME--; // mechante magouille
966511267
9666
- ONESTEP = false;
11268
+ Globals.ONESTEP = false;
966711269 }
966811270
966911271 static boolean zoomonce = false;
....@@ -9671,11 +11273,11 @@
967111273 void DrawObject(GL gl, boolean draw)
967211274 {
967311275 //System.out.println("DRAW OBJECT " + mouseDown);
9674
-// drawMode = SELECTION;
11276
+// DrawMode() = SELECTION;
967511277 //GL gl = getGL();
967611278 if ((TRACK || SHADOWTRACK) || zoomonce)
967711279 {
9678
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11280
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
967911281 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968011282 pingthread.StepToTarget(true); // true);
968111283 // zoomonce = false;
....@@ -9696,9 +11298,9 @@
969611298 callist = gl.glGenLists(1);
969711299 }
969811300
9699
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11301
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970011302
9701
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11303
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970211304
970311305 if (!mainDL || !active || touched)
970411306 {
....@@ -9725,7 +11327,7 @@
972511327 PushMatrix(ClickInfo.matbuffer);
972611328 }
972711329
9728
- if (drawMode == 0)
11330
+ if (DrawMode() == 0)
972911331 {
973011332 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973111333
....@@ -9734,12 +11336,12 @@
973411336 BindTextures(DEFAULT_TEXTURES, 2);
973511337 }
973611338 //System.out.println("--> " + stackdepth);
9737
-// GraphreeD.traceon();
11339
+// GrafreeD.traceon();
973811340
973911341 // DRAW
974011342 object.draw(this, /*(Composite)*/ object, false, false);
974111343
9742
- if (drawMode == DEFAULT)
11344
+ if (DrawMode() == DEFAULT)
974311345 {
974411346 if (DEBUG)
974511347 {
....@@ -9750,34 +11352,48 @@
975011352 selectedpoint.radius = radius;
975111353 selectedpoint.recalculate();
975211354 selectedpoint.material = new cMaterial();
9753
- selectedpoint.material.color = 0.25f;
11355
+ selectedpoint.material.color = 0.15f; // Yellow
975411356 selectedpoint.material.modulation = 0.75f;
975511357
9756
- debugpoint.radius = radius;
9757
- debugpoint.recalculate();
9758
- debugpoint.material = new cMaterial();
9759
- debugpoint.material.color = 0.25f;
9760
- 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;
976111363
9762
- debugpoint2.radius = radius;
9763
- debugpoint2.recalculate();
9764
- debugpoint2.material = new cMaterial();
9765
- debugpoint2.material.color = 0.75f;
9766
- 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;
976711381
976811382 InitPoints(radius);
976911383 }
977011384 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9771
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9772
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9773
- 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);
977411390 }
977511391
977611392 // debugstuff.draw(this, /*(Composite)*/ null, false);
977711393 }
9778
-// GraphreeD.traceoff();
11394
+// GrafreeD.traceoff();
977911395 //System.out.println(stackdepth);
9780
- if (drawMode == 0)
11396
+ if (DrawMode() == 0)
978111397 {
978211398 ReleaseTextures(DEFAULT_TEXTURES);
978311399
....@@ -9802,17 +11418,19 @@
980211418
980311419 checker = null;
980411420
9805
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11421
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
980611422 FindChecker(object);
980711423
9808
- if (checker != null && drawMode == DEFAULT)
11424
+ if (checker != null && DrawMode() == DEFAULT)
980911425 {
9810
- // BindTexture(IMMORTAL_TEXTURE);
11426
+ //BindTexture(IMMORTAL_TEXTURE);
11427
+ BindTextures(checker.GetTextures(), checker.texres);
981111428 // NEAREST
981211429 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
981311430 DrawChecker(gl);
981411431 //checker.Draw(this, null, false);
981511432 // ReleaseTexture(IMMORTAL_TEXTURE);
11433
+ ReleaseTextures(checker.GetTextures());
981611434 }
981711435
981811436 if (object.parent != null)
....@@ -9825,7 +11443,7 @@
982511443 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
982611444 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
982711445
9828
- if (DISPLAYTEXT && drawMode == DEFAULT)
11446
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
982911447 {
983011448 // Draw it once, then use the raster
983111449 Balloon(gl, balloon.createGraphics());
....@@ -9881,9 +11499,9 @@
988111499 int[] xs = new int[3];
988211500 int[] ys = new int[3];
988311501
9884
- void DrawString(Object3D obj) // String string)
11502
+ public void DrawString(Object3D obj) // String string) // INTERFACE
988511503 {
9886
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11504
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
988711505 {
988811506 return;
988911507 }
....@@ -10343,11 +11961,13 @@
1034311961 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1034411962 "PARAM params7 = program.env[7];" + // noise power, opacity power
1034511963 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10346
- "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
1034711966 "PARAM pointlight = program.env[127];" + // ...
1034811967 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1034911968 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1035011969 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
11970
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1035111971 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1035211972 "PARAM ten = { 10, 10, 10, 1.0 };" +
1035311973 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10368,6 +11988,7 @@
1036811988 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1036911989 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1037011990 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
11991
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1037111992 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1037211993 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1037311994 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10408,6 +12029,10 @@
1040812029 "TEMP R1;" +
1040912030 "TEMP R2;" +
1041012031 "TEMP R3;" +
12032
+ "TEMP min;" +
12033
+ "TEMP max;" +
12034
+ "TEMP average;" +
12035
+ "TEMP saturation;" +
1041112036 "TEMP keep1;" +
1041212037 "TEMP keep2;" +
1041312038 "TEMP keep3;" +
....@@ -10938,10 +12563,40 @@
1093812563
1093912564 // skin?
1094012565 // Saturation for skin
10941
- /**/ // c'est ici
10942
- (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;" +
1094312597 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10944
- "SUB temp, final,R2;" +
12598
+ "SUB temp, final, R2;" +
12599
+
1094512600 // using light angle
1094612601 "DP3 ndotl.x, normald,light;" +
1094712602 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10954,7 +12609,6 @@
1095412609 // using light intensity
1095512610 "MOV ndotl.z, R2.x;" +
1095612611 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10957
-
1095812612 // june 2014
1095912613 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1096012614 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10966,6 +12620,7 @@
1096612620 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1096712621
1096812622 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
12623
+/**/
1096912624
1097012625 // "ADD final, R2,temp;" +
1097112626 "MOV final, temp;"
....@@ -11055,7 +12710,7 @@
1105512710 /**/
1105612711 // HDR
1105712712 "MOV temp.z, final.a;" +
11058
- "MUL final, final,options1.w;" +
12713
+ "MUL final, final,options2.x;" +
1105912714 "MOV final.a, temp.z;" +
1106012715 /**/
1106112716
....@@ -11092,10 +12747,17 @@
1109212747 "MOV final.z, zero.x;" +
1109312748 "MOV final.a, one.w;":""
1109412749 ) +
12750
+ /*
1109512751 (NORMALdebug?"MOV final.x, normal.x;" +
1109612752 "MOV final.y, normal.y;" +
1109712753 "MOV final.z, normal.z;" +
1109812754 "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;":""
1109912761 ) +
1110012762 // "MOV final, bumpmap;" +
1110112763 "MOV result.color, final;" +
....@@ -11241,6 +12903,7 @@
1124112903 String Shadow(String depth, String shadow)
1124212904 {
1124312905 return "MAX temp.x, ndotl.x, one64th.x;" +
12906
+ "MIN temp.x, temp.x, ninetenth.x;" +
1124412907 /**/
1124512908 // Sine
1124612909 "MUL temp.y, temp.x, temp.x;" +
....@@ -11865,9 +13528,10 @@
1186513528 return;
1186613529 }
1186713530
13531
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1186813532
1186913533 // TIMER
11870
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13534
+ if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1187113535 {
1187213536 keepboxmode = BOXMODE;
1187313537 keepsupport = SUPPORT;
....@@ -11996,7 +13660,7 @@
1199613660 // ObjEditor.tweenManager.update(1f / 60f);
1199713661
1199813662 // fev 2014???
11999
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13663
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1200013664 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1200113665 pingthread.StepToTarget(true); // true);
1200213666 }
....@@ -12108,6 +13772,11 @@
1210813772 cVector tmp = new cVector();
1210913773 cVector tmp2 = new cVector();
1211013774 boolean isMoving;
13775
+
13776
+ public cVector TargetLookAt()
13777
+ {
13778
+ return targetLookAt;
13779
+ }
1211113780
1211213781 class PingThread extends Thread
1211313782 {
....@@ -12247,7 +13916,7 @@
1224713916 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1224813917 if (lightMode)
1224913918 {
12250
- lighttouched = true;
13919
+ Globals.lighttouched = true;
1225113920 }
1225213921
1225313922 if (OEILONCE && OEIL)
....@@ -12305,7 +13974,7 @@
1230513974 mouseDown = false;
1230613975 if (lightMode)
1230713976 {
12308
- lighttouched = true;
13977
+ Globals.lighttouched = true;
1230913978 }
1231013979 repaint();
1231113980 alreadypainted = true;
....@@ -12313,7 +13982,7 @@
1231313982 isMoving = false;
1231413983 } //??
1231513984
12316
- if (isLIVE() && !alreadypainted)
13985
+ if (Globals.isLIVE() && !alreadypainted)
1231713986 {
1231813987 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1231913988 repaint();
....@@ -12325,7 +13994,7 @@
1232513994 {
1232613995 if (lightMode)
1232713996 {
12328
- lighttouched = true;
13997
+ Globals.lighttouched = true;
1232913998 }
1233013999 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1233114000 }
....@@ -12568,6 +14237,7 @@
1256814237 {
1256914238 manipCamera.Translate(dx, dy, getWidth());
1257014239 }
14240
+ else
1257114241 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1257214242 {
1257314243 manipCamera.RotateInterest(dx, dy);
....@@ -12578,7 +14248,7 @@
1257814248
1257914249 if (manipCamera == lightCamera)
1258014250 {
12581
- lighttouched = true;
14251
+ Globals.lighttouched = true;
1258214252 }
1258314253 /*
1258414254 switch (mode)
....@@ -12793,13 +14463,15 @@
1279314463 {
1279414464 mouseMode |= ZOOM;
1279514465 }
12796
- if ((modifiers & META) == META)
14466
+
14467
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
+ if (capsLocked || (modifiers & META) == META)
1279714469 {
1279814470 mouseMode |= VR; // BACKFORTH;
1279914471 }
1280014472 if ((modifiers & CTRLCLICK) == CTRLCLICK)
1280114473 {
12802
- mouseMode |= SELECT; // BACKFORTH;
14474
+ mouseMode |= SELECT;
1280314475 }
1280414476 if ((modifiers & COMMAND) == COMMAND)
1280514477 {
....@@ -12807,6 +14479,7 @@
1280714479 }
1280814480 if ((modifiers & SHIFT) == SHIFT || forcetranslate)
1280914481 {
14482
+ mouseMode &= ~VR;
1281014483 mouseMode |= TRANSLATE;
1281114484 }
1281214485 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12836,7 +14509,7 @@
1283614509 SetMouseMode(modifiers);
1283714510 }
1283814511
12839
- theRenderer.keyPressed(key);
14512
+ Globals.theRenderer.keyPressed(key);
1284014513 }
1284114514
1284214515 int kompactbit = 4; // power bit
....@@ -12848,7 +14521,7 @@
1284814521 float SATPOW = 1; // 2; // 0.5f;
1284914522 float BRIPOW = 1; // 0.5f; // 0.5f;
1285014523
12851
- void keyPressed(int key)
14524
+ public void keyPressed(int key)
1285214525 {
1285314526 if (key >= '0' && key <= '5')
1285414527 clampbit = (key-'0');
....@@ -12963,7 +14636,7 @@
1296314636 case 'B':
1296414637 BRISMOOTH ^= true;
1296514638 SHADOWCULLFACE ^= true;
12966
- lighttouched = true;
14639
+ Globals.lighttouched = true;
1296714640 repaint();
1296814641 break;
1296914642 case 'b':
....@@ -13063,7 +14736,7 @@
1306314736 repaint();
1306414737 break;
1306514738 case 'O':
13066
- drawMode = OCCLUSION;
14739
+ Globals.drawMode = OCCLUSION; // WARNING
1306714740 repaint();
1306814741 break;
1306914742 case 'o':
....@@ -13154,7 +14827,7 @@
1315414827 break;
1315514828 case ' ':
1315614829 lightMode ^= true;
13157
- lighttouched = true;
14830
+ Globals.lighttouched = true;
1315814831 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1315914832 targetLookAt.set(manipCamera.lookAt);
1316014833 repaint();
....@@ -13166,11 +14839,11 @@
1316614839 repaint();
1316714840 break;
1316814841 case 'Z':
13169
- RESIZETEXTURE ^= true;
13170
- break;
14842
+ //RESIZETEXTURE ^= true;
14843
+ //break;
1317114844 case 'z':
1317214845 RENDERSHADOW ^= true;
13173
- lighttouched = true;
14846
+ Globals.lighttouched = true;
1317414847 repaint();
1317514848 break;
1317614849 //case UP:
....@@ -13196,7 +14869,8 @@
1319614869 FlipTransform();
1319714870 break;
1319814871 case ENTER:
13199
- object.editWindow.ScreenFit(); // Edit();
14872
+ // object.editWindow.ScreenFit(); // Edit();
14873
+ ToggleLive();
1320014874 break;
1320114875 case DELETE:
1320214876 ClearSelection();
....@@ -13284,6 +14958,7 @@
1328414958 }
1328514959 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1328614960 }
14961
+
1328714962 static double OCCLUSIONBOOST = 1; // 0.5;
1328814963
1328914964 void keyReleased(int key, int modifiers)
....@@ -13295,7 +14970,7 @@
1329514970 }
1329614971 }
1329714972
13298
- protected void processKeyEvent(KeyEvent e)
14973
+ public void processKeyEvent(KeyEvent e)
1329914974 {
1330014975 switch (e.getID())
1330114976 {
....@@ -13771,6 +15446,7 @@
1377115446 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1377215447 }
1377315448
15449
+ // To avoid clear.
1377415450 public void update(Graphics g)
1377515451 {
1377615452 paint(g);
....@@ -14373,7 +16049,7 @@
1437316049 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1437416050 gl.glPushMatrix();
1437516051 gl.glLoadIdentity();
14376
- PushMatrix(checker.toParent);
16052
+ //PushMatrix(checker.toParent);
1437716053
1437816054 gl.glMatrixMode(GL.GL_TEXTURE);
1437916055 gl.glPushMatrix();
....@@ -14396,8 +16072,8 @@
1439616072
1439716073 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1439816074
14399
- float step = 0.1666f; //0.25f;
14400
- float stepv = step * 1652 / 998;
16075
+ float step = 2; // 0.1666f; //0.25f;
16076
+ float stepv = 2; // step * 1652 / 998;
1440116077
1440216078 int i0 = 0;
1440316079 /*
....@@ -14433,20 +16109,21 @@
1443316109 /**/
1443416110 //checker.GetMaterial().opacity = 1.1f;
1443516111 ////checker.GetMaterial().ambient = 0.99f;
14436
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14437
- Object3D.selectedstack[Object3D.materialdepth] = false;
14438
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16112
+ materialstack[materialdepth] = checker.material;
16113
+ selectedstack[materialdepth] = false;
16114
+ cStatic.objectstack[materialdepth++] = checker;
1443916115 //System.out.println("material " + material);
1444016116 //Applet3D.tracein(this, selected);
1444116117 vector2buffer = checker.projectedVertices;
1444216118
14443
- checker.GetMaterial().Draw(this, false); // true);
16119
+ //checker.GetMaterial().Draw(this, false); // true);
16120
+ DrawMaterial(checker.GetMaterial(), false); // true);
1444416121
14445
- Object3D.materialdepth -= 1;
14446
- if (Object3D.materialdepth > 0)
16122
+ materialdepth -= 1;
16123
+ if (materialdepth > 0)
1444716124 {
14448
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14449
- 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]);
1445016127 }
1445116128 //checker.GetMaterial().opacity = 1f;
1445216129 ////checker.GetMaterial().ambient = 1f;
....@@ -14467,15 +16144,27 @@
1446716144
1446816145 //float u = (i+1)/2;
1446916146 //float v = (j+1)/2;
14470
- 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);
1447116151 gl.glVertex3f(i, j, -0.5f);
1447216152
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
1447316156 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1447416157 gl.glVertex3f(i + step, j, -0.5f);
1447516158
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
1447616162 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1447716163 gl.glVertex3f(i + step, j + stepv, -0.5f);
1447816164
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
1447916168 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1448016169 gl.glVertex3f(i, j + stepv, -0.5f);
1448116170 }
....@@ -14487,7 +16176,7 @@
1448716176 gl.glMatrixMode(GL.GL_PROJECTION);
1448816177 gl.glPopMatrix();
1448916178 gl.glMatrixMode(GL.GL_MODELVIEW);
14490
- PopMatrix(null); // checker.toParent); // null);
16179
+ //PopMatrix(null); // checker.toParent); // null);
1449116180 gl.glPopMatrix();
1449216181 PopTextureMatrix(checker.toParent);
1449316182 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14600,14 +16289,14 @@
1460016289
1460116290 //int tmp = selection_view;
1460216291 //selection_view = -1;
14603
- int temp = drawMode;
14604
- drawMode = SELECTION;
16292
+ int temp = DrawMode();
16293
+ Globals.drawMode = SELECTION; // WARNING
1460516294 indexcount = 0;
1460616295 parent.display(drawable);
1460716296 //selection_view = tmp;
1460816297 //if (temp == SELECTION)
1460916298 // temp = DEFAULT; // patch for selection debug
14610
- drawMode = temp;
16299
+ Globals.drawMode = temp; // WARNING
1461116300
1461216301 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1461316302
....@@ -14657,6 +16346,11 @@
1465716346 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1465816347 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1465916348
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
+
1466016354 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1466116355
1466216356 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14700,16 +16394,16 @@
1470016394 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]));
1470116395 }
1470216396
14703
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
16397
+ previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
1470416398 }
1470516399 }
1470616400
1470716401 if (!movingcamera && !PAINTMODE)
1470816402 object.editWindow.ScreenFitPoint(); // fev 2014
1470916403
14710
- 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)
1471116405 {
14712
- 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);
1471316407
1471416408 Object3D group = new Object3D("inst" + paintcount++);
1471516409
....@@ -14875,14 +16569,14 @@
1487516569 //gl.glColorMask(false, false, false, false);
1487616570
1487716571 //render_scene_from_light_view(gl, drawable, 0, 0);
14878
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16572
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1487916573 {
1488016574 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1488116575
14882
- int temp = drawMode;
14883
- drawMode = SHADOW;
16576
+ int temp = DrawMode();
16577
+ Globals.drawMode = SHADOW; // WARNING
1488416578 parent.display(drawable);
14885
- drawMode = temp;
16579
+ Globals.drawMode = temp; // WARNING
1488616580 }
1488716581
1488816582 gl.glCullFace(gl.GL_BACK);
....@@ -14935,7 +16629,6 @@
1493516629
1493616630 class AntialiasBuffer implements GLEventListener
1493716631 {
14938
-
1493916632 CameraPane parent = null;
1494016633
1494116634 AntialiasBuffer(CameraPane p)
....@@ -15045,13 +16738,19 @@
1504516738 gl.glFlush();
1504616739
1504716740 /**/
15048
- 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);
1504916742
15050
- int[] pixels = occlusionsizebuffer.array();
16743
+ float[] pixels = occlusionsizebuffer.array();
1505116744
1505216745 double r = 0, g = 0, b = 0;
1505316746
1505416747 double count = 0;
16748
+
16749
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16750
+
16751
+ float mindepth = 1;
16752
+
16753
+ double FACTOR = 1;
1505516754
1505616755 for (int i = 0; i < pixels.length; i++)
1505716756 {
....@@ -15136,7 +16835,7 @@
1513616835
1513716836 double scale = ray.z; // 1; // cos
1513816837
15139
- int p = pixels[newindex];
16838
+ float depth = pixels[newindex];
1514016839
1514116840 /*
1514216841 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15160,10 +16859,23 @@
1516016859 scale = (1 - modu) * modv;
1516116860 */
1516216861
15163
- r += ((p >> 16) & 0xFF) * scale / 255;
15164
- g += ((p >> 8) & 0xFF) * scale / 255;
15165
- 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
+ }
1516616870
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
+
1516716879 count += scale;
1516816880 }
1516916881
....@@ -15261,12 +16973,6 @@
1526116973 GLUT glut = new GLUT();
1526216974
1526316975
15264
- static final public int DEFAULT = 0;
15265
- static final public int SELECTION = 1;
15266
- static final public int SHADOW = 2;
15267
- static final public int OCCLUSION = 3;
15268
- static
15269
- public int drawMode = DEFAULT;
1527016976 public boolean spherical = false;
1527116977 static boolean DEBUG_OCCLUSION = false;
1527216978 static boolean DEBUG_SELECTION = false;
....@@ -15279,10 +16985,12 @@
1527916985 int AAbuffersize = 0;
1528016986
1528116987 //double[] selectedpoint = new double[3];
15282
- static Sphere selectedpoint = new Sphere();
16988
+ static Superellipsoid selectedpoint = new Superellipsoid();
1528316989 static Sphere previousselectedpoint = null;
15284
- static Sphere debugpoint = new Sphere();
15285
- 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();
1528616994
1528716995 static Sphere debugpoints[] = new Sphere[8];
1528816996
....@@ -15313,7 +17021,7 @@
1531317021 }
1531417022 }
1531517023
15316
- static void DrawPoints(CameraPane cpane)
17024
+ static void DrawPoints(iCameraPane cpane)
1531717025 {
1531817026 for (int i=0; i<8; i++) // first and last are red
1531917027 {
....@@ -15335,7 +17043,8 @@
1533517043 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1533617044 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1533717045 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15338
- 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);
1533917048 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1534017049 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1534117050 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15344,10 +17053,11 @@
1534417053 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1534517054 // Depth buffer format
1534617055 //private int depth_format;
15347
- static public void NextIndex(Object3D o, GL gl)
17056
+
17057
+ public void NextIndex()
1534817058 {
1534917059 indexcount+=16;
15350
- 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);
1535117061 //objects[indexcount] = o;
1535217062 //System.out.println("indexcount = " + indexcount);
1535317063 }