Normand Briere
2019-06-17 13e9febe94aaeebad9c97f6d3e2aa4d73b2495c8
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
....@@ -70,8 +56,6 @@
7056 static int CURRENTANTIALIAS = 0; // 1;
7157 /*static*/ boolean RENDERSHADOW = true;
7258 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
73
- static boolean ANIMATION = false;
74
- static String filename;
7559
7660 boolean DISPLAYTEXT = false;
7761 //boolean REDUCETEXTURE = true;
....@@ -97,10 +81,8 @@
9781
9882 static boolean textureon = true;
9983 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10184 static boolean FULLSCREEN = false;
10285 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10486 static boolean INERTIA = true;
10587 static boolean FAST = false;
10688 static boolean SLOWPOSE = false;
....@@ -108,6 +90,8 @@
10890
10991 static int tickcount = 0; // slow pose issue
11092
93
+static boolean BUTTONLESSWHEEL = false;
94
+static boolean ZOOMBOXMODE = false;
11195 static boolean BOXMODE = false;
11296 static boolean IMAGEFLIP = false;
11397 static boolean SMOOTHFOCUS = false;
....@@ -122,7 +106,7 @@
122106 static boolean OEIL = true;
123107 static boolean OEILONCE = false; // do oeilon then oeiloff
124108 static boolean LOOKAT = true;
125
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
126110 static boolean HANDLES = false; // selection doesn't work!!
127111 static boolean PAINTMODE = false;
128112
....@@ -165,12 +149,41 @@
165149 defaultcaps.setAccumBlueBits(16);
166150 defaultcaps.setAccumAlphaBits(16);
167151 }
168
- static CameraPane theRenderer;
169
-
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154
+
170155 void SetAsGLRenderer(boolean b)
171156 {
172157 isRenderer = b;
173
- theRenderer = this;
158
+ Globals.theRenderer = this;
159
+ }
160
+
161
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
162
+ {
163
+ super(defaultcaps, null, withcontext?glcontext:null, null);
164
+
165
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
166
+ glcontext = getContext();
167
+
168
+ cameras = new Camera[2];
169
+ targetLookAts = new cVector[2];
170
+
171
+ SetCamera(cam);
172
+
173
+ SetLight(new Camera(new cVector(10, 10, -20)));
174
+
175
+ object = o;
176
+
177
+ setBackground(Color.white);
178
+
179
+ addKeyListener(this);
180
+ addMouseListener(this);
181
+ addMouseMotionListener(this);
182
+ addMouseWheelListener(this);
183
+ //System.out.println("addGLEventListener: " + this);
184
+ addGLEventListener(this);
185
+
186
+// pingthread.start(); // may 2013
174187 }
175188
176189 static boolean AntialiasingEnabled()
....@@ -178,12 +191,53 @@
178191 return CURRENTANTIALIAS > 0;
179192 }
180193
181
- void ClearDepth()
194
+ /// INTERFACE
195
+
196
+ public javax.media.opengl.GL GetGL0()
197
+ {
198
+ return null;
199
+ }
200
+
201
+ public int GenList()
202
+ {
203
+ javax.media.opengl.GL gl = GetGL();
204
+ return gl.glGenLists(1);
205
+ }
206
+
207
+ public void NewList(int id)
208
+ {
209
+ javax.media.opengl.GL gl = GetGL();
210
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
211
+ }
212
+
213
+ public void CallList(int id)
214
+ {
215
+ javax.media.opengl.GL gl = GetGL();
216
+ gl.glCallList(id);
217
+ }
218
+
219
+ public void EndList()
220
+ {
221
+ javax.media.opengl.GL gl = GetGL();
222
+ gl.glEndList();
223
+ }
224
+
225
+ public boolean IsBoxMode()
226
+ {
227
+ return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
233
+ }
234
+
235
+ public void ClearDepth()
182236 {
183237 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184238 }
185239
186
- void DepthTest(boolean depthtest)
240
+ public void DepthTest(boolean depthtest)
187241 {
188242 if (depthtest)
189243 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +245,7 @@
191245 GetGL().glDepthFunc(GL.GL_ALWAYS);
192246 }
193247
194
- void DepthWrite(boolean depthwrite)
248
+ public void DepthWrite(boolean depthwrite)
195249 {
196250 if (depthwrite)
197251 GetGL().glDepthMask(true);
....@@ -199,12 +253,1594 @@
199253 GetGL().glDepthMask(false);
200254 }
201255
202
- void BackFaceCull(boolean bfc)
256
+ public void BackFaceCull(boolean bfc)
203257 {
204258 if (bfc)
205259 GetGL().glEnable(GetGL().GL_CULL_FACE);
206260 else
207261 GetGL().glDisable(GetGL().GL_CULL_FACE);
262
+ }
263
+
264
+ public boolean BackFaceCullMode()
265
+ {
266
+ return this.CULLFACE;
267
+ }
268
+
269
+ public boolean IsAmbientOcclusionOn()
270
+ {
271
+ return this.ambientOcclusion;
272
+ }
273
+
274
+ public boolean IsDebugSelection()
275
+ {
276
+ return DEBUG_SELECTION;
277
+ }
278
+
279
+ public boolean IsFrozen()
280
+ {
281
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
282
+
283
+ return !selectmode && cameracount == 0; // != 0;
284
+ }
285
+
286
+ // Currently in Globals
287
+ public int DrawMode()
288
+ {
289
+ return Globals.DrawMode();
290
+ }
291
+
292
+ public Camera EyeCamera()
293
+ {
294
+ return eyeCamera;
295
+ }
296
+
297
+ public Camera LightCamera()
298
+ {
299
+ return lightCamera;
300
+ }
301
+
302
+ public Camera ManipCamera()
303
+ {
304
+ return manipCamera;
305
+ }
306
+
307
+ public Camera RenderCamera()
308
+ {
309
+ return renderCamera;
310
+ }
311
+
312
+ public Camera[] Cameras()
313
+ {
314
+ return cameras;
315
+ }
316
+
317
+ public void PushMaterial(Object3D obj, boolean selected)
318
+ {
319
+ CameraPane display = this;
320
+ javax.media.opengl.GL gl = display.GetGL();
321
+ cMaterial material = obj.material;
322
+
323
+ if (material != null)
324
+ {
325
+ materialstack[materialdepth] = material;
326
+ selectedstack[materialdepth] = selected;
327
+ cStatic.objectstack[materialdepth++] = obj;
328
+ //System.out.println("material " + material);
329
+ //Applet3D.tracein(this, selected);
330
+ display.vector2buffer = obj.projectedVertices;
331
+ if (obj instanceof Camera)
332
+ {
333
+ display.options1[0] = material.shift;
334
+ //System.out.println("shift " + material.shift);
335
+ display.options1[1] = material.lightarea;
336
+ display.options1[2] = material.shadowbias;
337
+ display.options1[3] = material.aniso;
338
+ display.options1[4] = material.anisoV;
339
+ display.options2[0] = material.opacity;
340
+ display.options2[1] = material.diffuse;
341
+ display.options2[2] = material.factor;
342
+
343
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
344
+ display.options4[0] = material.cameralight/0.2f;
345
+ display.options4[1] = material.subsurface;
346
+ display.options4[2] = material.sheen;
347
+
348
+ // if (display.CURRENTANTIALIAS > 0)
349
+ // display.options3[3] /= 4;
350
+
351
+ /*
352
+ System.out.println("Focus = " + display.options1[0]);
353
+ System.out.println("Aperture = " + display.options1[1]);
354
+ System.out.println("ShadowBlur = " + display.options1[2]);
355
+ System.out.println("Antialiasing = " + display.options1[3]);
356
+ System.out.println("Fog = " + display.options2[0]);
357
+ System.out.println("Intensity = " + display.options2[1]);
358
+ System.out.println("Elevation = " + display.options2[2]);
359
+ /**/
360
+ } else
361
+ {
362
+ DrawMaterial(material, selected);
363
+ }
364
+ } else
365
+ {
366
+ if (selected && CameraPane.flash)
367
+ {
368
+ display.modelParams4[1] = 100;
369
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
370
+ }
371
+ }
372
+ }
373
+
374
+ public void PushMaterial2(Object3D obj, boolean selected)
375
+ {
376
+ CameraPane display = this;
377
+ cMaterial material = obj.material;
378
+
379
+ if (material != null)
380
+ {
381
+ materialstack[materialdepth] = material;
382
+ selectedstack[materialdepth] = selected;
383
+ cStatic.objectstack[materialdepth++] = obj;
384
+ //System.out.println("material " + material);
385
+ //Applet3D.tracein("selected ", selected);
386
+ display.vector2buffer = obj.projectedVertices;
387
+ display.DrawMaterial(material, selected);
388
+ }
389
+ }
390
+
391
+ public void PopMaterial(Object3D obj, boolean selected)
392
+ {
393
+ CameraPane display = this;
394
+ javax.media.opengl.GL gl = display.GetGL();
395
+ cMaterial material = obj.material;
396
+
397
+ //if (parent != null && parent.GetMaterial() != null)
398
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
399
+ if (material != null)
400
+ {
401
+ materialdepth -= 1;
402
+ if (materialdepth > 0)
403
+ {
404
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
406
+ }
407
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
409
+ {
410
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
411
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
412
+ }
413
+ }
414
+
415
+ public void PopMaterial2(Object3D obj)
416
+ {
417
+ CameraPane display = this;
418
+ cMaterial material = obj.material;
419
+
420
+ if (material != null)
421
+ {
422
+ materialdepth -= 1;
423
+ if (materialdepth > 0)
424
+ {
425
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
427
+ }
428
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429
+ //else
430
+ //material.Draw(display, false);
431
+ }
432
+ }
433
+
434
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
435
+ {
436
+ CameraPane display = this;
437
+
438
+ if (pv.y == -10000 ||
439
+ qv.y == -10000 ||
440
+ rv.y == -10000)
441
+ return;
442
+
443
+// float b = f.nbiterations & 1;
444
+// float g = (f.nbiterations>>1) & 1;
445
+// float r = (f.nbiterations>>2) & 1;
446
+//
447
+// //if (f.weight == 10000)
448
+// //{
449
+// // r = 1; g = b = 0;
450
+// //}
451
+// //else
452
+// //{
453
+// // assert(f.weight < 10000);
454
+// r = g = b = (float)bRep.FaceWeight(f)*100;
455
+// if (r<0)
456
+// assert(r>=0);
457
+// //}
458
+
459
+ javax.media.opengl.GL gl = display.GetGL();
460
+
461
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
462
+
463
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
464
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465
+ {
466
+ //gl.glBegin(gl.GL_TRIANGLES);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
468
+ if (!hasnorm)
469
+ {
470
+ // System.out.println("FUCK!!");
471
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
474
+ LA.vecNormalize(obj.v2);
475
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
476
+ }
477
+
478
+ // P
479
+ float x = (float)pv.x;
480
+ float y = (float)pv.y;
481
+ float z = (float)pv.z;
482
+
483
+ if (hasnorm)
484
+ {
485
+// if (!pv.norm.normalized())
486
+// assert(pv.norm.normalized());
487
+
488
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
489
+ float nx = (float)pv.norm.x;
490
+ float ny = (float)pv.norm.y;
491
+ float nz = (float)pv.norm.z;
492
+
493
+ x += nx * obj.NORMALPUSH;
494
+ y += ny * obj.NORMALPUSH;
495
+ z += nz * obj.NORMALPUSH;
496
+
497
+ gl.glNormal3f(nx, ny, nz);
498
+ }
499
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
500
+ SetColor(obj, pv);
501
+ //gl.glColor4f(r, g, b, 1);
502
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
503
+ if (obj.flipV)
504
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
505
+ else
506
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
507
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
508
+
509
+ gl.glVertex3f(x, y, z);
510
+
511
+ // Q
512
+ x = (float)qv.x;
513
+ y = (float)qv.y;
514
+ z = (float)qv.z;
515
+
516
+// Print(pv);
517
+ if (hasnorm)
518
+ {
519
+// assert(qv.norm.normalized());
520
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
521
+ float nx = (float)qv.norm.x;
522
+ float ny = (float)qv.norm.y;
523
+ float nz = (float)qv.norm.z;
524
+
525
+ x += nx * obj.NORMALPUSH;
526
+ y += ny * obj.NORMALPUSH;
527
+ z += nz * obj.NORMALPUSH;
528
+
529
+ gl.glNormal3f(nx, ny, nz);
530
+ }
531
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
532
+ // boolean locked = false;
533
+ // float eps = 0.1f;
534
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
535
+
536
+ // int dot = 0; //*/ (int)f.dot;
537
+
538
+ // if ((dot&1) == 0)
539
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
540
+
541
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
542
+ if (obj.flipV)
543
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
544
+ else
545
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
546
+ // else
547
+ // {
548
+ // locked = true;
549
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
550
+ // }
551
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
552
+ SetColor(obj, qv);
553
+
554
+ gl.glVertex3f(x, y, z);
555
+ //gl.glColor4f(r, g, b, 1);
556
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
557
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
558
+// Print(qv);
559
+
560
+ // R
561
+ x = (float)rv.x;
562
+ y = (float)rv.y;
563
+ z = (float)rv.z;
564
+
565
+ if (hasnorm)
566
+ {
567
+// assert(rv.norm.normalized());
568
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
569
+ float nx = (float)rv.norm.x;
570
+ float ny = (float)rv.norm.y;
571
+ float nz = (float)rv.norm.z;
572
+
573
+ x += nx * obj.NORMALPUSH;
574
+ y += ny * obj.NORMALPUSH;
575
+ z += nz * obj.NORMALPUSH;
576
+
577
+ gl.glNormal3f(nx, ny, nz);
578
+ }
579
+
580
+ // if ((dot&4) == 0)
581
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
582
+
583
+ // if (wrap || !locked && (dot&8) != 0)
584
+ if (obj.flipV)
585
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
586
+ else
587
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
588
+ // else
589
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
590
+
591
+ // f.dot = dot;
592
+
593
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
594
+ SetColor(obj, rv);
595
+ //gl.glColor4f(r, g, b, 1);
596
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
597
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
598
+ gl.glVertex3f(x, y, z);
599
+// Print(rv);
600
+ //gl.glEnd();
601
+ }
602
+ else
603
+ {
604
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
605
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
606
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
607
+
608
+ }
609
+
610
+ if (false) // (attributes & WIREFRAME) != 0)
611
+ {
612
+ gl.glDisable(gl.GL_LIGHTING);
613
+
614
+ gl.glBegin(gl.GL_LINE_LOOP);
615
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
616
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
617
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
618
+ gl.glEnd();
619
+
620
+ gl.glEnable(gl.GL_LIGHTING);
621
+ }
622
+ }
623
+
624
+ /**
625
+ * <code>draw</code> renders a <code>TriMesh</code> object including
626
+ * it's normals, colors, textures and vertices.
627
+ *
628
+ * @see Renderer#draw(TriMesh)
629
+ * @param tris
630
+ * the mesh to render.
631
+ */
632
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
633
+ {
634
+ CameraPane display = this;
635
+
636
+ float r = display.modelParams0[0];
637
+ float g = display.modelParams0[1];
638
+ float b = display.modelParams0[2];
639
+ float opacity = display.modelParams5[1];
640
+
641
+ //final GL gl = GLU.getCurrentGL();
642
+ GL gl = display.GetGL(); // getGL();
643
+
644
+ FloatBuffer vertBuf = geo.vertBuf;
645
+
646
+ int v = vertBuf.capacity();
647
+
648
+ int count = 0;
649
+
650
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
651
+ gl.glEnable(gl.GL_CULL_FACE);
652
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
653
+ for (int i=0; i<v/3; i++)
654
+ {
655
+ int index3 = i*3;
656
+
657
+ if (geo.sizeBuf.get(index3+1) == 0)
658
+ continue;
659
+
660
+ count++;
661
+
662
+ int index4 = i*4;
663
+
664
+ float tx = vertBuf.get(index3);
665
+ float ty = vertBuf.get(index3+1);
666
+ float tz = vertBuf.get(index3+2);
667
+
668
+ // if (tx == 0 && ty == 0 && tz == 0)
669
+ // continue;
670
+
671
+ gl.glMatrixMode(gl.GL_TEXTURE);
672
+ gl.glPushMatrix();
673
+
674
+ float[] texmat = geo.texmat;
675
+ texmat[12] = texmat[13] = texmat[14] = i;
676
+
677
+ gl.glMultMatrixf(texmat, 0);
678
+
679
+ gl.glMatrixMode(gl.GL_MODELVIEW);
680
+ gl.glPushMatrix();
681
+
682
+ gl.glTranslatef(tx,ty,tz);
683
+
684
+ if (rotate)
685
+ gl.glRotatef(i, 0, 1, 0);
686
+
687
+ float size = geo.sizeBuf.get(index3) / 100;
688
+ gl.glScalef(size,size,size);
689
+
690
+ float cr = geo.colorBuf.get(index4);
691
+ float cg = geo.colorBuf.get(index4+1);
692
+ float cb = geo.colorBuf.get(index4+2);
693
+ float ca = geo.colorBuf.get(index4+3);
694
+
695
+ display.modelParams0[0] = r * cr;
696
+ display.modelParams0[1] = g * cg;
697
+ display.modelParams0[2] = b * cb;
698
+
699
+ display.modelParams5[1] = opacity * ca;
700
+
701
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
702
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
703
+
704
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
705
+ RandomNode.globalseed2 = RandomNode.globalseed;
706
+
707
+// gl.glColor4f(cr,cg,cb,ca);
708
+ // gl.glScalef(1024/16,1024/16,1024/16);
709
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
710
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
711
+ //gl.glTranslatef(-tx,-ty,-tz);
712
+ gl.glPopMatrix();
713
+
714
+ gl.glMatrixMode(gl.GL_TEXTURE);
715
+ gl.glPopMatrix();
716
+ }
717
+ // gl.glScalef(1024,1024,1024);
718
+ if (!cf)
719
+ gl.glDisable(gl.GL_CULL_FACE);
720
+
721
+ display.modelParams0[0] = r;
722
+ display.modelParams0[1] = g;
723
+ display.modelParams0[2] = b;
724
+
725
+ display.modelParams5[1] = opacity;
726
+
727
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
728
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
729
+
730
+ gl.glMatrixMode(gl.GL_MODELVIEW);
731
+
732
+// System.err.println("total = " + v/3 + "; displayed = " + count);
733
+ if (true)
734
+ return;
735
+
736
+//// if (!tris.predraw(this))
737
+//// {
738
+//// return;
739
+//// }
740
+//// if (Debug.stats)
741
+//// {
742
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
743
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
744
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
745
+//// }
746
+////
747
+//// if (tris.getDisplayListID() != -1)
748
+//// {
749
+//// renderDisplayList(tris);
750
+//// return;
751
+//// }
752
+////
753
+//// if (!generatingDisplayList)
754
+//// {
755
+//// applyStates(tris.states, tris);
756
+//// }
757
+//// if (Debug.stats)
758
+//// {
759
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
760
+//// }
761
+//// boolean transformed = doTransforms(tris);
762
+//
763
+// int glMode = GL.GL_TRIANGLES;
764
+// switch (getMode())
765
+// {
766
+// case Triangles:
767
+// glMode = GL.GL_TRIANGLES;
768
+// break;
769
+// case Strip:
770
+// glMode = GL.GL_TRIANGLE_STRIP;
771
+// break;
772
+// case Fan:
773
+// glMode = GL.GL_TRIANGLE_FAN;
774
+// break;
775
+// }
776
+//
777
+// if (!predrawGeometry(gl))
778
+// {
779
+// // make sure only the necessary indices are sent through on old
780
+// // cards.
781
+// IntBuffer indices = this.getIndexBuffer();
782
+// if (indices == null)
783
+// {
784
+// logger.severe("missing indices on geometry object: " + this.toString());
785
+// } else
786
+// {
787
+// indices.rewind();
788
+// indices.limit(this.getMaxIndex());
789
+//
790
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
791
+//
792
+// indices.clear();
793
+// }
794
+// } else
795
+// {
796
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
797
+// GL.GL_UNSIGNED_INT, 0);
798
+// }
799
+//
800
+//// postdrawGeometry(tris);
801
+//// if (transformed)
802
+//// {
803
+//// undoTransforms(tris);
804
+//// }
805
+////
806
+//// if (Debug.stats)
807
+//// {
808
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
809
+//// }
810
+//// tris.postdraw(this);
811
+ }
812
+
813
+ static Camera localcamera = new Camera();
814
+ static cVector from = new cVector();
815
+ static cVector to = new cVector();
816
+
817
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
818
+ {
819
+ CameraPane cp = this;
820
+
821
+ Camera keep = cp.RenderCamera();
822
+ cp.renderCamera = localcamera;
823
+
824
+ if (br.trimmed)
825
+ {
826
+ float[] colors = new float[br.positions.length / 3];
827
+
828
+ int i3 = 0;
829
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
830
+ {
831
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
832
+ continue;
833
+
834
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
835
+ to.set(br.positions[i3] + br.normals[i3],
836
+ br.positions[i3 + 1] + br.normals[i3 + 1],
837
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
838
+ LA.xformPos(from, transform, from);
839
+ LA.xformPos(to, transform, to); // RIGID ONLY
840
+ localcamera.setAim(from, to);
841
+
842
+ CameraPane.occlusionbuffer.display();
843
+
844
+ if (CameraPane.DEBUG_OCCLUSION)
845
+ cp.display(); // debug
846
+
847
+ colors[i] = cp.vertexOcclusion.r;
848
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
849
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
850
+
851
+ if ((i % 100) == 0 && i != 0)
852
+ {
853
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
854
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
855
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
856
+ }
857
+ }
858
+
859
+ br.colors = colors;
860
+ }
861
+ else
862
+ {
863
+ for (int i = 0; i < br.VertexCount(); i++)
864
+ {
865
+ Vertex v = br.GetVertex(i);
866
+
867
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
868
+ continue;
869
+
870
+ from.set(v.x, v.y, v.z);
871
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
872
+ LA.xformPos(from, transform, from);
873
+ LA.xformPos(to, transform, to); // RIGID ONLY
874
+ localcamera.setAim(from, to);
875
+
876
+ CameraPane.occlusionbuffer.display();
877
+
878
+ if (CameraPane.DEBUG_OCCLUSION)
879
+ cp.display(); // debug
880
+
881
+ v.AO = cp.vertexOcclusion.r;
882
+
883
+ if ((i % 100) == 0 && i != 0)
884
+ {
885
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
886
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
887
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
888
+ }
889
+ }
890
+ }
891
+
892
+ //System.out.println("done.");
893
+
894
+ cp.renderCamera = keep;
895
+ }
896
+
897
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
898
+ {
899
+ CameraPane display = this;
900
+ pointFlow.CreateHT();
901
+
902
+ float r = display.modelParams0[0];
903
+ float g = display.modelParams0[1];
904
+ float b = display.modelParams0[2];
905
+ float opacity = display.modelParams5[1];
906
+
907
+ //final GL gl = GLU.getCurrentGL();
908
+ GL gl = display.GetGL(); // getGL();
909
+
910
+ int s = pointFlow.points.size();
911
+
912
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
913
+ gl.glEnable(gl.GL_CULL_FACE);
914
+
915
+ for (int i=s; --i>=0;)
916
+ //for (int i=0; i<s; i++)
917
+ {
918
+ cVector v = pointFlow.points.get(i);
919
+
920
+ double mindist = Double.MAX_VALUE;
921
+
922
+ double size = pointFlow.minimumSize;
923
+
924
+ double distancenext = 0;
925
+
926
+ if (i > 0)
927
+ {
928
+ cVector w = pointFlow.points.get(i-1);
929
+
930
+ double dist = w.distance(v);
931
+
932
+ distancenext = dist;
933
+
934
+ if (mindist > dist)
935
+ {
936
+ mindist = dist;
937
+ size = mindist*pointFlow.resizefactor;
938
+ }
939
+ }
940
+
941
+ if (i < s-1)
942
+ {
943
+ cVector w = pointFlow.points.get(i+1);
944
+
945
+ double dist = w.distance(v);
946
+
947
+ if (mindist > dist)
948
+ {
949
+ mindist = dist;
950
+ size = mindist*pointFlow.resizefactor;
951
+ }
952
+ }
953
+
954
+ if (size < pointFlow.minimumSize)
955
+ size = pointFlow.minimumSize;
956
+ if (size > pointFlow.maximumSize)
957
+ size = pointFlow.maximumSize;
958
+
959
+ double tx = v.x;
960
+ double ty = v.y;
961
+ double tz = v.z;
962
+
963
+ // if (tx == 0 && ty == 0 && tz == 0)
964
+ // continue;
965
+
966
+ gl.glMatrixMode(gl.GL_TEXTURE);
967
+ gl.glPushMatrix();
968
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
969
+
970
+ gl.glMultMatrixf(pointFlow.texmat, 0);
971
+
972
+ gl.glMatrixMode(gl.GL_MODELVIEW);
973
+ gl.glPushMatrix();
974
+
975
+ gl.glTranslated(tx,ty,tz);
976
+
977
+ gl.glScaled(size,size,size);
978
+
979
+// float cr = colorBuf.get(index4);
980
+// float cg = colorBuf.get(index4+1);
981
+// float cb = colorBuf.get(index4+2);
982
+// float ca = colorBuf.get(index4+3);
983
+//
984
+// display.modelParams0[0] = r * cr;
985
+// display.modelParams0[1] = g * cg;
986
+// display.modelParams0[2] = b * cb;
987
+//
988
+// display.modelParams5[1] = opacity * ca;
989
+//
990
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
991
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
992
+//
993
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
994
+// RandomNode.globalseed2 = RandomNode.globalseed;
995
+//
996
+//// gl.glColor4f(cr,cg,cb,ca);
997
+// // gl.glScalef(1024/16,1024/16,1024/16);
998
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
999
+
1000
+ gl.glPopMatrix();
1001
+
1002
+ double step = size/4; //
1003
+
1004
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1005
+ continue;
1006
+
1007
+ int nbsteps = (int)(distancenext/step);
1008
+
1009
+ step = distancenext/nbsteps;
1010
+
1011
+ cVector next = pointFlow.points.get(i-1);
1012
+
1013
+ tmp.set(next);
1014
+ tmp.sub(v);
1015
+ tmp.normalize();
1016
+ tmp.mul(step);
1017
+
1018
+ // calculate next size
1019
+ mindist = Double.MAX_VALUE;
1020
+
1021
+ double nextsize = pointFlow.minimumSize;
1022
+
1023
+ if (i > 1)
1024
+ {
1025
+ cVector w = pointFlow.points.get(i-2);
1026
+
1027
+ double dist = w.distance(next);
1028
+
1029
+ if (mindist > dist)
1030
+ {
1031
+ mindist = dist;
1032
+ nextsize = mindist*pointFlow.resizefactor;
1033
+ }
1034
+ }
1035
+
1036
+ double dist = v.distance(next);
1037
+
1038
+ if (mindist > dist)
1039
+ {
1040
+ mindist = dist;
1041
+ nextsize = mindist*pointFlow.resizefactor;
1042
+ }
1043
+
1044
+ if (nextsize < pointFlow.minimumSize)
1045
+ nextsize = pointFlow.minimumSize;
1046
+ if (nextsize > pointFlow.maximumSize)
1047
+ nextsize = pointFlow.maximumSize;
1048
+ //
1049
+
1050
+ double count = 0;
1051
+
1052
+ while (distancenext > 0.000000001) // step
1053
+ {
1054
+ gl.glPushMatrix();
1055
+
1056
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1057
+
1058
+ double K = count/nbsteps;
1059
+
1060
+ double intersize = K*nextsize + (1-K)*size;
1061
+
1062
+ gl.glScaled(intersize,intersize,intersize);
1063
+
1064
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1065
+
1066
+ count++;
1067
+
1068
+ distancenext -= step;
1069
+
1070
+ gl.glPopMatrix();
1071
+ }
1072
+
1073
+ if (count != nbsteps)
1074
+ assert(count == nbsteps);
1075
+
1076
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1077
+ //gl.glTranslatef(-tx,-ty,-tz);
1078
+
1079
+ gl.glMatrixMode(gl.GL_TEXTURE);
1080
+ gl.glPopMatrix();
1081
+ }
1082
+
1083
+ if (!cf)
1084
+ gl.glDisable(gl.GL_CULL_FACE);
1085
+
1086
+// display.modelParams0[0] = r;
1087
+// display.modelParams0[1] = g;
1088
+// display.modelParams0[2] = b;
1089
+//
1090
+// display.modelParams5[1] = opacity;
1091
+//
1092
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1093
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1094
+
1095
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1096
+ }
1097
+
1098
+ public void DrawBox(cVector min, cVector max)
1099
+ {
1100
+ javax.media.opengl.GL gl = GetGL();
1101
+ gl.glBegin(gl.GL_LINES);
1102
+
1103
+ gl.glVertex3d(min.x, min.y, min.z);
1104
+ gl.glVertex3d(min.x, min.y, max.z);
1105
+ gl.glVertex3d(min.x, min.y, min.z);
1106
+ gl.glVertex3d(min.x, max.y, min.z);
1107
+ gl.glVertex3d(min.x, min.y, min.z);
1108
+ gl.glVertex3d(max.x, min.y, min.z);
1109
+
1110
+ gl.glVertex3d(max.x, max.y, max.z);
1111
+ gl.glVertex3d(min.x, max.y, max.z);
1112
+ gl.glVertex3d(max.x, max.y, max.z);
1113
+ gl.glVertex3d(max.x, min.y, max.z);
1114
+ gl.glVertex3d(max.x, max.y, max.z);
1115
+ gl.glVertex3d(max.x, max.y, min.z);
1116
+
1117
+ gl.glEnd();
1118
+ }
1119
+
1120
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1121
+ {
1122
+ int[] strips = bRep.getRawIndices();
1123
+
1124
+ javax.media.opengl.GL gl = GetGL();
1125
+
1126
+ // TRIANGLE STRIP ARRAY
1127
+ if (bRep.trimmed)
1128
+ {
1129
+ float[] v = bRep.getRawVertices();
1130
+ float[] n = bRep.getRawNormals();
1131
+ float[] c = bRep.getRawColors();
1132
+ float[] uv = bRep.getRawUVMap();
1133
+
1134
+ int count2 = 0;
1135
+ int count3 = 0;
1136
+
1137
+ if (n.length > 0)
1138
+ {
1139
+ for (int i = 0; i < strips.length; i++)
1140
+ {
1141
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1142
+
1143
+ /*
1144
+ boolean locked = false;
1145
+ float eps = 0.1f;
1146
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1147
+
1148
+ int dot = 0;
1149
+
1150
+ if ((dot&1) == 0)
1151
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1152
+
1153
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1154
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1155
+ else
1156
+ {
1157
+ locked = true;
1158
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1159
+ }
1160
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1161
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1162
+ if (hasnorm)
1163
+ {
1164
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1165
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1166
+ }
1167
+
1168
+ if ((dot&4) == 0)
1169
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1170
+
1171
+ if (wrap || !locked && (dot&8) != 0)
1172
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1173
+ else
1174
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1175
+
1176
+ f.dot = dot;
1177
+ */
1178
+
1179
+ if (!selectmode)
1180
+ {
1181
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1182
+ {
1183
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1184
+ } else
1185
+ {
1186
+ gl.glNormal3f(0, 0, 1);
1187
+ }
1188
+
1189
+ if (c != null)
1190
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1191
+ {
1192
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1193
+ }
1194
+ }
1195
+ if (flipV)
1196
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1197
+ else
1198
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1199
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1200
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1201
+
1202
+ count2 += 2;
1203
+ count3 += 3;
1204
+ if (!selectmode)
1205
+ {
1206
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1207
+ {
1208
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1209
+ } else
1210
+ {
1211
+ gl.glNormal3f(0, 0, 1);
1212
+ }
1213
+ if (c != null)
1214
+ {
1215
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1216
+ }
1217
+ }
1218
+ if (flipV)
1219
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1220
+ else
1221
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1222
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1223
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1224
+
1225
+ count2 += 2;
1226
+ count3 += 3;
1227
+ for (int j = 0; j < strips[i] - 2; j++)
1228
+ {
1229
+ //gl.glTexCoord2d(...);
1230
+ if (!selectmode)
1231
+ {
1232
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1233
+ {
1234
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1235
+ } else
1236
+ {
1237
+ gl.glNormal3f(0, 0, 1);
1238
+ }
1239
+ if (c != null)
1240
+ {
1241
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1242
+ }
1243
+ }
1244
+
1245
+ if (flipV)
1246
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1247
+ else
1248
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1249
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1250
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1251
+ count2 += 2;
1252
+ count3 += 3;
1253
+ }
1254
+
1255
+ gl.glEnd();
1256
+ }
1257
+ }
1258
+
1259
+ assert count3 == v.length;
1260
+ }
1261
+ else // !trimmed
1262
+ {
1263
+ int count = 0;
1264
+ for (int i = 0; i < strips.length; i++)
1265
+ {
1266
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1267
+
1268
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1269
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1270
+
1271
+ drawVertex(gl, p, flipV, selectmode);
1272
+ drawVertex(gl, q, flipV, selectmode);
1273
+
1274
+ for (int j = 0; j < strips[i] - 2; j++)
1275
+ {
1276
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1277
+
1278
+ // if (j%2 == 0)
1279
+ // drawFace(p, q, r, display, null);
1280
+ // else
1281
+ // drawFace(p, r, q, display, null);
1282
+
1283
+ // p = q;
1284
+ // q = r;
1285
+ drawVertex(gl, r, flipV, selectmode);
1286
+ }
1287
+
1288
+ gl.glEnd();
1289
+ }
1290
+ }
1291
+ }
1292
+
1293
+ static cSpring.Point3D temp = new cSpring.Point3D();
1294
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1295
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1296
+
1297
+ public void DrawDynamicMesh(cMesh mesh)
1298
+ {
1299
+ GL gl = GetGL(); // getGL();
1300
+
1301
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1302
+
1303
+ gl.glDisable(gl.GL_LIGHTING);
1304
+
1305
+ gl.glLineWidth(1);
1306
+ gl.glColor3f(1,1,1);
1307
+ gl.glBegin(gl.GL_LINES);
1308
+ double scale = 0;
1309
+ int count = 0;
1310
+ for (int s=0; s<Phys.allSprings.size(); s++)
1311
+ {
1312
+ cSpring.Spring spring = Phys.allSprings.get(s);
1313
+ if(s == 0)
1314
+ {
1315
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1316
+ }
1317
+ if (mesh.showsprings)
1318
+ {
1319
+ temp.set(spring.a.position);
1320
+ temp.add(spring.b.position);
1321
+ temp.mul(0.5);
1322
+ temp2.set(spring.a.position);
1323
+ temp2.sub(spring.b.position);
1324
+ temp2.mul(spring.restLength/2);
1325
+ temp.sub(temp2);
1326
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1327
+ temp.add(temp2);
1328
+ temp.add(temp2);
1329
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1330
+ }
1331
+
1332
+ if (spring.isHandle)
1333
+ continue;
1334
+
1335
+ //if (scale < spring.restLength)
1336
+ scale += spring.restLength;
1337
+ count++;
1338
+ }
1339
+ gl.glEnd();
1340
+
1341
+ if (count == 0)
1342
+ scale = 0.01;
1343
+ else
1344
+ scale /= count * 3;
1345
+
1346
+ //scale = 0.25;
1347
+
1348
+ if (mesh.ShowInfo())
1349
+ {
1350
+ gl.glLineWidth(4);
1351
+ for (int s=0; s<Phys.allNodes.size(); s++)
1352
+ {
1353
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1354
+ if (node.mass == 0)
1355
+ continue;
1356
+
1357
+ int i = node.springs==null?-1:node.springs.size();
1358
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1359
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1360
+ //temp.normalize();
1361
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1362
+ gl.glBegin(gl.GL_LINES);
1363
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1364
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1365
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1366
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1367
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1368
+ gl.glEnd();
1369
+ }
1370
+
1371
+ gl.glLineWidth(8);
1372
+ for (int s=0; s<Phys.allNodes.size(); s++)
1373
+ {
1374
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1375
+
1376
+ if (node.springs != null)
1377
+ {
1378
+ for (int i=0; i<node.springs.size(); i+=1)
1379
+ {
1380
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1381
+
1382
+ int c = i+1;
1383
+ // c = node.springs.get(i).nbcopies;
1384
+
1385
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1386
+ gl.glBegin(gl.GL_LINES);
1387
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1388
+ gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3);
1389
+ gl.glEnd();
1390
+ }
1391
+ }
1392
+ }
1393
+
1394
+ gl.glLineWidth(1);
1395
+ }
1396
+
1397
+ gl.glEnable(gl.GL_LIGHTING);
1398
+ }
1399
+
1400
+ /// INTERFACE
1401
+
1402
+ public void StartTriangles()
1403
+ {
1404
+ javax.media.opengl.GL gl = GetGL();
1405
+ gl.glBegin(gl.GL_TRIANGLES);
1406
+ }
1407
+
1408
+ public void EndTriangles()
1409
+ {
1410
+ GetGL().glEnd();
1411
+ }
1412
+
1413
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1414
+ {
1415
+ if (!selectmode)
1416
+ {
1417
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1418
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1419
+
1420
+ if (flipV)
1421
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1422
+ else
1423
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1424
+ }
1425
+
1426
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1427
+ }
1428
+
1429
+ void SetColor(Object3D obj, Vertex p0)
1430
+ {
1431
+ CameraPane display = this;
1432
+ BoundaryRep bRep = obj.bRep;
1433
+
1434
+ if (RENDERPROGRAM == 0)
1435
+ {
1436
+ float r = 0;
1437
+ if (bRep != null)
1438
+ {
1439
+ if (bRep.stripified)
1440
+ {
1441
+ r = 1;
1442
+ }
1443
+ }
1444
+ float g = 0;
1445
+ if (bRep != null)
1446
+ {
1447
+ if (bRep.trimmed)
1448
+ {
1449
+ g = 1;
1450
+ }
1451
+ }
1452
+ float b = 0;
1453
+ if (obj.support != null && obj.link2master)
1454
+ {
1455
+ b = 1;
1456
+ }
1457
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1458
+ return;
1459
+ }
1460
+
1461
+ if (display.DrawMode() != CameraPane.SHADOW)
1462
+ return;
1463
+
1464
+ javax.media.opengl.GL gl = display.GetGL();
1465
+// if (true) return;
1466
+// float ao = p.AO;
1467
+//
1468
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1469
+// // ao = 1;
1470
+//
1471
+// gl.glColor4f(ao, ao, ao, 1);
1472
+
1473
+// CameraPane.selectedpoint.
1474
+// getAverage(cStatic.point1, true);
1475
+ if (CameraPane.pointflow == null) // !random) // live)
1476
+ {
1477
+ return;
1478
+ }
1479
+
1480
+ cStatic.point1.set(0,0,0);
1481
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1482
+
1483
+ cStatic.point1.sub(p0);
1484
+
1485
+
1486
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1487
+// {
1488
+// return;
1489
+// }
1490
+
1491
+ //if (true)
1492
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1493
+ {
1494
+ return;
1495
+ }
1496
+
1497
+ float[] colorV = new float[3];
1498
+
1499
+ if (false) // marked)
1500
+ {
1501
+ // debug rigging weights
1502
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1503
+ {
1504
+ float weight = p0.weights[object] / p0.totalweight;
1505
+
1506
+ // if (weight < 0.1)
1507
+ // {
1508
+ // assert(weight == 0);
1509
+ // continue;
1510
+ // }
1511
+
1512
+ if (p0.vertexlinks[object] == -1)
1513
+ continue;
1514
+
1515
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1516
+
1517
+ int color = //1 << object; //
1518
+ //p.vertexlinks.length;
1519
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1520
+ colorV[2] += (color & 1) * weight;
1521
+ colorV[1] += ((color & 2) >> 1) * weight;
1522
+ colorV[0] += ((color & 4) >> 2) * weight;
1523
+ }
1524
+ }
1525
+ else
1526
+ {
1527
+ if (obj.drawingstarted)
1528
+ {
1529
+ // find next point
1530
+ if (bRep.GetVertex(0).faceindices == null)
1531
+ {
1532
+ bRep.InitFaceIndices();
1533
+ }
1534
+
1535
+ double ymin = p0.y;
1536
+
1537
+ Vertex newp = p0;
1538
+
1539
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1540
+ {
1541
+ int fi = p0.faceindices[fii];
1542
+
1543
+ if (fi == -1)
1544
+ break;
1545
+
1546
+ Face f = bRep.GetFace(fi);
1547
+
1548
+ Vertex p = bRep.GetVertex(f.p);
1549
+ Vertex q = bRep.GetVertex(f.q);
1550
+ Vertex r = bRep.GetVertex(f.r);
1551
+
1552
+ int swap = (int)(Math.random()*3);
1553
+
1554
+// for (int s=swap; --s>=0;)
1555
+// {
1556
+// Vertex t = p;
1557
+// p = q;
1558
+// q = r;
1559
+// r = t;
1560
+// }
1561
+ if (ymin > p.y)
1562
+ {
1563
+ ymin = p.y;
1564
+ newp = p;
1565
+// break;
1566
+ }
1567
+ if (ymin > q.y)
1568
+ {
1569
+ ymin = q.y;
1570
+ newp = q;
1571
+// break;
1572
+ }
1573
+ if (ymin > r.y)
1574
+ {
1575
+ ymin = r.y;
1576
+ newp = r;
1577
+// break;
1578
+ }
1579
+ }
1580
+
1581
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1582
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1583
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1584
+
1585
+ obj.drawingstarted = false;
1586
+
1587
+ // return;
1588
+ }
1589
+
1590
+ if (false) // CameraPane.DRAW
1591
+ {
1592
+ p0.AO = colorV[0] = 2;
1593
+ colorV[1] = 2;
1594
+ colorV[2] = 2;
1595
+ }
1596
+
1597
+ CameraPane.pointflow.add(p0);
1598
+ CameraPane.pointflow.Touch();
1599
+ }
1600
+
1601
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1602
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1603
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1604
+ }
1605
+
1606
+ void DrawMaterial(cMaterial material, boolean selected)
1607
+ {
1608
+ CameraPane display = this;
1609
+ //new Exception().printStackTrace();
1610
+
1611
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1612
+ {
1613
+ return;
1614
+ }
1615
+
1616
+ javax.media.opengl.GL gl = display.GetGL();
1617
+
1618
+ //Color col = Color.getHSBColor(color,modulation,1);
1619
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1620
+ if (!material.multiply)
1621
+ {
1622
+ display.color = material.color;
1623
+ display.saturation = material.modulation;
1624
+ }
1625
+ else
1626
+ {
1627
+ display.color *= material.color*2;
1628
+ display.saturation *= material.modulation*2;
1629
+ }
1630
+
1631
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1632
+
1633
+ float[] colorV = Grafreed.colorV;
1634
+
1635
+ /**/
1636
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1637
+ {
1638
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1639
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1640
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1641
+ colorV[3] = material.opacity;
1642
+
1643
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1644
+ //System.out.println("Opacity = " + opacity);
1645
+
1646
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1647
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1648
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1649
+
1650
+ float amb = material.ambient;
1651
+ if (amb < material.cameralight)
1652
+ {
1653
+ amb = material.cameralight;
1654
+ }
1655
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1656
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1657
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1658
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1659
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1660
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1661
+
1662
+ /**/
1663
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1664
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1665
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1666
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1667
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1668
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1669
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1670
+ //System.out.println("shininess = " + colorV[0]);
1671
+ if (colorV[0] > 128)
1672
+ {
1673
+ colorV[0] = 128;
1674
+ }
1675
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1676
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1677
+ /**/
1678
+ }
1679
+ /**/
1680
+
1681
+ //selected = false;
1682
+ selected = selected && display.flash;
1683
+
1684
+ //display.modelParams0[0] = 0; // pigment.r;
1685
+ //display.modelParams0[1] = 0; // pigment.g;
1686
+ //display.modelParams0[2] = 0; // pigment.b;
1687
+ if (!material.multiply)
1688
+ {
1689
+ display.modelParams0[3] = material.metalness;
1690
+ display.modelParams1[0] = material.diffuse;
1691
+ display.modelParams1[1] = material.specular;
1692
+ display.modelParams1[2] = 1 / material.shininess;
1693
+ display.modelParams1[3] = material.shift;
1694
+ display.modelParams2[0] = material.ambient;
1695
+ display.modelParams2[1] = material.lightarea;
1696
+ //System.out.println("light area = " + lightarea);
1697
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1698
+ display.modelParams2[3] = material.velvet;
1699
+ display.modelParams3[0] = material.sheen;
1700
+ display.modelParams3[1] = material.subsurface;
1701
+ display.modelParams3[2] = material.bump; // backlit
1702
+ display.modelParams3[3] = material.aniso;
1703
+ display.modelParams4[0] = material.anisoV;
1704
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1705
+ //System.out.println("selected = " + selected);
1706
+ display.modelParams4[2] = material.diffuseness;
1707
+ display.modelParams4[3] = material.shadow;
1708
+ display.modelParams5[0] = material.texture;
1709
+ display.modelParams5[1] = material.opacity;
1710
+ display.modelParams5[2] = material.fakedepth;
1711
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1712
+ }
1713
+ else
1714
+ {
1715
+ display.modelParams0[3] *= material.metalness*2;
1716
+ display.modelParams1[0] *= material.diffuse*2;
1717
+ display.modelParams1[1] *= material.specular*2;
1718
+ display.modelParams1[2] *= material.shininess*2;
1719
+ display.modelParams1[3] *= material.shift*2;
1720
+ display.modelParams2[0] *= material.ambient*2;
1721
+ display.modelParams2[1] *= material.lightarea*2;
1722
+ display.modelParams2[2] *= material.factor*2;
1723
+ display.modelParams2[3] *= material.velvet*2;
1724
+ display.modelParams3[0] *= material.sheen*2;
1725
+ display.modelParams3[1] *= material.subsurface*2;
1726
+ display.modelParams3[2] *= material.bump*2;
1727
+ display.modelParams3[3] *= material.aniso*2;
1728
+ display.modelParams4[0] *= material.anisoV*2;
1729
+ display.modelParams4[1] *= material.cameralight*2;
1730
+ //System.out.println("selected = " + selected);
1731
+ display.modelParams4[2] *= material.diffuseness*2;
1732
+ display.modelParams4[3] *= material.shadow*2;
1733
+ display.modelParams5[0] *= material.texture*2;
1734
+ display.modelParams5[1] *= material.opacity*2;
1735
+ display.modelParams5[2] *= material.fakedepth*2;
1736
+ display.modelParams5[3] *= material.shadowbias*2;
1737
+ }
1738
+
1739
+ display.modelParams6[0] = 0;
1740
+ display.modelParams6[1] = 0;
1741
+ display.modelParams6[2] = 0;
1742
+ display.modelParams6[3] = 0;
1743
+
1744
+ display.modelParams7[0] = 0;
1745
+ display.modelParams7[1] = 1000;
1746
+ display.modelParams7[2] = 0;
1747
+ display.modelParams7[3] = 0;
1748
+
1749
+ display.modelParams6[0] = 100; // criss de bug de bump
1750
+
1751
+ Object3D.cVector2[] extparams = display.vector2buffer;
1752
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1753
+ {
1754
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1755
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1756
+ if (extparams.length > 1)
1757
+ {
1758
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1759
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1760
+ if (extparams.length > 2)
1761
+ {
1762
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1763
+ float x = extparams[2].y / 1000.0f;
1764
+ //if (x == 0)
1765
+ // x = 1f;
1766
+ display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power
1767
+ if (extparams[2].y > 0)
1768
+ {
1769
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1770
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1771
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1772
+ }
1773
+ }
1774
+ }
1775
+ }
1776
+
1777
+ //if (display.modelParams6[2] != 0)
1778
+ /*
1779
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1780
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1781
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1782
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1783
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1784
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1785
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1786
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1787
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1788
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1789
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1790
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1791
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1792
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1793
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1794
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1795
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1796
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1797
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1798
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1799
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1800
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1801
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1802
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1803
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1804
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1805
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1806
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1807
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1808
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1809
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1810
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1811
+ /**/
1812
+ //assert (display.modelParams6[2] == 0);
1813
+
1814
+ //System.out.println("noise power = " + display.modelParams7[0]);
1815
+ //System.out.println("shadowbias = " + shadowbias);
1816
+
1817
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1818
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1819
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1820
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1821
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1822
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1823
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1824
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1825
+
1826
+ int mode = display.FP_SHADER;
1827
+
1828
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1829
+ {
1830
+ mode |= display.FP_ANISO;
1831
+ }
1832
+
1833
+ display.EnableProgram(mode);
1834
+
1835
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1836
+
1837
+ if (!material.multiply)
1838
+ {
1839
+ if (Globals.drawMode == CameraPane.SHADOW)
1840
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1841
+ else
1842
+ gl.glDepthMask(material.opacity >= 0.99);
1843
+ }
2081844 }
2091845
2101846 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1861,7 @@
2251861 currentGL.glMultMatrixd(model, 0);
2261862 }
2271863
228
- void PushMatrix(double[][] matrix, int count)
1864
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291865 {
2301866 matrixdepth++;
2311867 // GrafreeD.tracein(matrix);
....@@ -254,7 +1890,7 @@
2541890 void PushMatrix(double[][] matrix)
2551891 {
2561892 // GrafreeD.tracein(matrix);
257
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
2581894 }
2591895
2601896 void PushMatrix()
....@@ -270,7 +1906,7 @@
2701906
2711907 double[][] tmpmat = new double[4][4];
2721908
273
- void PopMatrix(double[][] inverse)
1909
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741910 {
2751911 --matrixdepth;
2761912
....@@ -310,7 +1946,7 @@
3101946 PushTextureMatrix(matrix, 1);
3111947 }
3121948
313
- void PushTextureMatrix(double[][] matrix, int count)
1949
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3141950 {
3151951 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3161952
....@@ -324,7 +1960,7 @@
3241960 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3251961 }
3261962
327
- void PopTextureMatrix(double[][] inverse)
1963
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3281964 {
3291965 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3301966 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -351,15 +1987,15 @@
3511987
3521988 static int camerachangeframe;
3531989
354
- boolean SetCamera(Camera cam)
1990
+ public boolean SetCamera(Camera cam)
3551991 {
3561992 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3571993 // return false;
3581994
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1995
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3601996 {
3611997 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1998
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3631999 {
3642000 // refuse the camera change
3652001 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +2003,7 @@
3672003 }
3682004 }
3692005
370
- camerachangeframe = framecount;
2006
+ camerachangeframe = Globals.framecount;
3712007
3722008 cam.hAspect = -1; // Read only
3732009
....@@ -398,7 +2034,7 @@
3982034 {
3992035 //System.err.println("Oeil on");
4002036 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2037
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022038 // object.editWindow.ScreenFit(trackedobject);
4032039 //pingthread.StepToTarget(true);
4042040 }
....@@ -407,7 +2043,7 @@
4072043 {
4082044 //System.err.println("Oeil on");
4092045 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2046
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4112047 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4122048 //pingthread.StepToTarget(true);
4132049 }
....@@ -471,39 +2107,12 @@
4712107 {
4722108 frozen ^= true;
4732109 // Weird...
474
- lighttouched = true;
2110
+ Globals.lighttouched = true;
4752111 }
4762112
4772113 void ToggleDL()
4782114 {
4792115 mainDL ^= true;
480
- }
481
-
482
- void ToggleTexture()
483
- {
484
- textureon ^= true;
485
- }
486
-
487
- void ToggleLive()
488
- {
489
- setLIVE(isLIVE() ^ true);
490
-
491
- System.err.println("LIVE = " + isLIVE());
492
-
493
- if (!isLIVE()) // save sound
494
- GrafreeD.savesound = true; // wav.save();
495
- // else
496
- repaint(); // start loop // may 2013
497
- }
498
-
499
- void ToggleSupport()
500
- {
501
- SUPPORT ^= true;
502
- }
503
-
504
- void ToggleAbort()
505
- {
506
- ABORTMODE ^= true;
5072116 }
5082117
5092118 void ToggleFullScreen()
....@@ -513,12 +2122,7 @@
5132122
5142123 void ToggleCrowd()
5152124 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2125
+ Globals.CROWD ^= true;
5222126 }
5232127
5242128 void ToggleLocal()
....@@ -526,62 +2130,89 @@
5262130 LOCALTRANSFORM ^= true;
5272131 }
5282132
529
- void ToggleFast()
2133
+ public void ToggleTexture()
2134
+ {
2135
+ textureon ^= true;
2136
+ }
2137
+
2138
+ public void ToggleLive()
2139
+ {
2140
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2141
+
2142
+ System.err.println("LIVE = " + Globals.isLIVE());
2143
+
2144
+ if (!Globals.isLIVE()) // save sound
2145
+ Grafreed.savesound = true; // wav.save();
2146
+ // else
2147
+ repaint(); // start loop // may 2013
2148
+ }
2149
+
2150
+ public void ToggleSupport()
2151
+ {
2152
+ SUPPORT ^= true;
2153
+ }
2154
+
2155
+ public void ToggleAbort()
2156
+ {
2157
+ ABORTMODE ^= true;
2158
+ }
2159
+
2160
+ public void ToggleInertia()
2161
+ {
2162
+ INERTIA ^= true;
2163
+ }
2164
+
2165
+ public void ToggleFast()
5302166 {
5312167 FAST ^= true;
5322168 }
5332169
534
- void ToggleSlowPose()
2170
+ public void ToggleSlowPose()
5352171 {
5362172 SLOWPOSE ^= true;
5372173 }
5382174
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2175
+ public void ToggleBoxMode()
5452176 {
5462177 BOXMODE ^= true;
5472178 }
5482179
549
- void ToggleSmoothFocus()
2180
+ public void ToggleZoomBoxMode()
2181
+ {
2182
+ ZOOMBOXMODE ^= true;
2183
+ }
2184
+
2185
+ public void ToggleSmoothFocus()
5502186 {
5512187 SMOOTHFOCUS ^= true;
5522188 }
5532189
554
- void ToggleImageFlip()
2190
+ public void ToggleImageFlip()
5552191 {
5562192 IMAGEFLIP ^= true;
5572193 }
5582194
559
- void ToggleSpeakerMocap()
2195
+ public void ToggleSpeakerMocap()
5602196 {
5612197 SPEAKERMOCAP ^= true;
5622198 }
5632199
564
- void ToggleSpeakerCamera()
2200
+ public void ToggleSpeakerCamera()
5652201 {
5662202 SPEAKERCAMERA ^= true;
5672203 }
5682204
569
- void ToggleSpeakerFocus()
2205
+ public void ToggleSpeakerFocus()
5702206 {
5712207 SPEAKERFOCUS ^= true;
5722208 }
5732209
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2210
+ public void ToggleFrustum()
5802211 {
5812212 FRUSTUM ^= true;
5822213 }
5832214
584
- void ToggleTrack()
2215
+ public void ToggleTrack()
5852216 {
5862217 TRACK ^= true;
5872218 if (TRACK)
....@@ -600,25 +2231,35 @@
6002231 repaint();
6012232 }
6022233
603
- void ToggleTrackOnce()
2234
+ public void ToggleTrackOnce()
6042235 {
6052236 TRACKONCE ^= true;
6062237 }
6072238
608
- void ToggleShadowTrack()
2239
+ public void ToggleShadowTrack()
6092240 {
6102241 SHADOWTRACK ^= true;
6112242 repaint();
6122243 }
6132244
614
- void ToggleOeil()
2245
+ public void ToggleOeil()
6152246 {
6162247 OEIL ^= true;
6172248 }
6182249
619
- void ToggleOeilOnce()
2250
+ public void ToggleOeilOnce()
6202251 {
6212252 OEILONCE ^= true;
2253
+ }
2254
+
2255
+ void ToggleFootContact()
2256
+ {
2257
+ FOOTCONTACT ^= true;
2258
+ }
2259
+
2260
+ void ToggleDebug()
2261
+ {
2262
+ DEBUG ^= true;
6222263 }
6232264
6242265 void ToggleLookAt()
....@@ -626,9 +2267,9 @@
6262267 LOOKAT ^= true;
6272268 }
6282269
629
- void ToggleRandom()
2270
+ void ToggleSwitch()
6302271 {
631
- RANDOM ^= true;
2272
+ SWITCH ^= true;
6322273 }
6332274
6342275 void ToggleHandles()
....@@ -672,34 +2313,6 @@
6722313 //assert (cam.hAspect == 0);
6732314 cam.hAspect = 0;
6742315 lightCamera = cam;
675
- }
676
-
677
- CameraPane(Object3D o, Camera cam, boolean withcontext)
678
- {
679
- super(defaultcaps, null, withcontext?glcontext:null, null);
680
-
681
- //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
682
- glcontext = getContext();
683
-
684
- cameras = new Camera[2];
685
- targetLookAts = new cVector[2];
686
-
687
- SetCamera(cam);
688
-
689
- SetLight(new Camera(new cVector(10, 10, -20)));
690
-
691
- object = o;
692
-
693
- setBackground(Color.white);
694
-
695
- addKeyListener(this);
696
- addMouseListener(this);
697
- addMouseMotionListener(this);
698
- addMouseWheelListener(this);
699
- //System.out.println("addGLEventListener: " + this);
700
- addGLEventListener(this);
701
-
702
-// pingthread.start(); // may 2013
7032316 }
7042317
7052318 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -759,11 +2372,11 @@
7592372
7602373 GL currentGL;
7612374
762
- GL GetGL()
2375
+ public GL GetGL() // INTERFACE
7632376 {
7642377 return currentGL;
7652378 }
766
-
2379
+
7672380 /**/
7682381 class CacheTexture
7692382 {
....@@ -2000,10 +3613,12 @@
20003613 */
20013614 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20023615 {
3616
+ int pixelformat = texturedata.getPixelFormat();
3617
+
20033618 int stride = 1;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
3619
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20053620 stride = 3;
2006
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
3621
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20073622 stride = 4;
20083623
20093624 int width = texturedata.getWidth();
....@@ -2593,6 +4208,7 @@
25934208
25944209 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25954210 {
4211
+ new Exception().printStackTrace();
25964212 System.exit(0);
25974213 com.sun.opengl.util.texture.Texture texture = null;
25984214
....@@ -6269,7 +7885,7 @@
62697885 return null;
62707886 }
62717887
6272
- void ReleaseTextures(cTexture tex)
7888
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62737889 {
62747890 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62757891 {
....@@ -6307,7 +7923,7 @@
63077923
63087924 void ReleaseTexture(String tex, boolean bump)
63097925 {
6310
- if (// drawMode != 0 || /*tex == null ||*/
7926
+ if (// DrawMode() != 0 || /*tex == null ||*/
63117927 ambientOcclusion ) // || !textureon)
63127928 {
63137929 return;
....@@ -6408,9 +8024,9 @@
64088024 }
64098025 }
64108026
6411
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64128028 {
6413
- if (// drawMode != 0 || /*tex == null ||*/
8029
+ if (// DrawMode() != 0 || /*tex == null ||*/
64148030 ambientOcclusion ) // || !textureon)
64158031 {
64168032 return; // false;
....@@ -6453,7 +8069,27 @@
64538069 return; // true;
64548070 }
64558071
6456
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8072
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8073
+
8074
+ private boolean FileExists(String tex)
8075
+ {
8076
+ if (missingTextures.contains(tex))
8077
+ {
8078
+ return false;
8079
+ }
8080
+
8081
+ boolean fileExists = new File(tex).exists();
8082
+
8083
+ if (!fileExists)
8084
+ {
8085
+ // If file exists, the "new File()" is not executed sgain
8086
+ missingTextures.add(tex);
8087
+ }
8088
+
8089
+ return fileExists;
8090
+ }
8091
+
8092
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
64578093 {
64588094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64598095
....@@ -6461,12 +8097,18 @@
64618097 {
64628098 String texname = tex;
64638099
6464
- String[] split = tex.split("Textures");
6465
- if (split.length > 1)
6466
- texname = "/Users/nbriere/Textures" + split[split.length-1];
6467
- else
6468
- if (!texname.startsWith("/"))
6469
- texname = "/Users/nbriere/Textures/" + texname;
8100
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8101
+
8102
+// String[] split = tex.split("Textures");
8103
+// if (split.length > 1)
8104
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8105
+// else
8106
+// if (!texname.startsWith("/"))
8107
+// texname = "/Users/nbriere/Textures/" + texname;
8108
+ if (!FileExists(tex))
8109
+ {
8110
+ texname = fallbackTextureName;
8111
+ }
64708112
64718113 if (CACHETEXTURE)
64728114 texture = textures.get(texname); // TEXTURE CACHE
....@@ -6535,7 +8177,7 @@
65358177 }
65368178
65378179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
6538
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
65398181 cachename = texname;
65408182 else
65418183 processbump = false; // don't process bump map again
....@@ -6557,7 +8199,7 @@
65578199 }
65588200
65598201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
6560
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
65618203 cachename = texname;
65628204 else
65638205 processbump = false; // don't process bump map again
....@@ -6566,7 +8208,9 @@
65668208 texturedata = GetFileTexture(cachename, processbump, resolution);
65678209
65688210
6569
- if (texturedata != null)
8211
+ if (texturedata == null)
8212
+ throw new Exception();
8213
+
65708214 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
65718215 //texture = GetTexture(tex, bump);
65728216 }
....@@ -6688,7 +8332,7 @@
66888332 return texture;
66898333 }
66908334
6691
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8335
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
66928336 {
66938337 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66948338
....@@ -6706,14 +8350,14 @@
67068350 return texture!=null?texture.texture:null;
67078351 }
67088352
6709
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8353
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
67108354 {
67118355 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67128356
67138357 return texture!=null?texture.texturedata:null;
67148358 }
67158359
6716
- boolean BindTexture(String tex, boolean bump, int resolution)
8360
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
67178361 {
67188362 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67198363 {
....@@ -7310,9 +8954,9 @@
73108954 static boolean occlusionInitialized = false;
73118955 boolean selection = false;
73128956 boolean pointselection = false;
7313
- /*static*/ boolean lighttouched = true;
8957
+ ///*static*/ boolean lighttouched = true;
73148958 boolean deselect;
7315
- boolean ambientOcclusion = false;
8959
+ private boolean ambientOcclusion = false;
73168960 static boolean flash = false;
73178961 /*static*/ boolean wait = false;
73188962 boolean displaydone = false; // after repaint() calls
....@@ -7442,6 +9086,8 @@
74429086 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74439087 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74449088 double scale = lightCamera.SCALE / lightCamera.Distance();
9089
+// PATCH FILLE AUX JEANS
9090
+ //scale *= lightCamera.shaper_fovy / 25;
74459091 gl.glScaled(2 * scale, 2 * scale, -scale);
74469092 gl.glTranslated(0, 0, lightCamera.DECAL);
74479093
....@@ -7590,15 +9236,14 @@
75909236
75919237 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75929238 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
9239
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
9240
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75949241
75959242 static int imagecount = 0; // movie generation
75969243
75979244 static int jitter = 0;
75989245
75999246 boolean restartframe = false;
7600
-
7601
- static int framecount = 0; // general-purpose global count
76029247
76039248 void displayAntiAliased(javax.media.opengl.GL gl)
76049249 {
....@@ -7630,7 +9275,7 @@
76309275 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76319276 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76329277 {
7633
- framecount++;
9278
+ Globals.framecount++;
76349279
76359280 if (CameraPane.tickcount > 0)
76369281 CameraPane.tickcount--;
....@@ -7668,7 +9313,7 @@
76689313
76699314 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76709315 */
7671
- lighttouched = true;
9316
+ Globals.lighttouched = true;
76729317 //System.err.println(" shadowbuffer: " + jitter);
76739318 shadowbuffer.display();
76749319
....@@ -7689,8 +9334,8 @@
76899334 assert (parentcam != renderCamera);
76909335
76919336 if (renderCamera != lightCamera)
7692
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7693
- LA.matConcat(parentcam.toParent, matrix, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
76949339
76959340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76969341
....@@ -7705,8 +9350,8 @@
77059350 LA.matCopy(renderCamera.fromScreen, matrix);
77069351
77079352 if (renderCamera != lightCamera)
7708
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7709
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
77109355
77119356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77129357
....@@ -7778,7 +9423,7 @@
77789423 //gl.glFlush();
77799424 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77809425
7781
- if (ANIMATION && ABORTED)
9426
+ if (Globals.ANIMATION && ABORTED)
77829427 {
77839428 System.err.println(" ABORTED FRAME");
77849429 break;
....@@ -7808,7 +9453,7 @@
78089453 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78099454
78109455 // save image
7811
- if (ANIMATION && !ABORTED)
9456
+ if (Globals.ANIMATION && !ABORTED)
78129457 {
78139458 VPwidth = viewport[2];
78149459 VPheight = viewport[3];
....@@ -7919,11 +9564,11 @@
79199564
79209565 // imagecount++;
79219566
7922
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9567
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
79239568
79249569 if (!BOXMODE)
79259570 {
7926
- System.out.println("image: " + fullname + " (" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9571
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
79279572 }
79289573
79299574 if (!BOXMODE)
....@@ -7961,7 +9606,7 @@
79619606 ABORTED = false;
79629607 }
79639608 else
7964
- GrafreeD.wav.cursor += 735 * ACSIZE;
9609
+ Grafreed.wav.cursor += 735 * ACSIZE;
79659610
79669611 if (false)
79679612 {
....@@ -8615,13 +10260,6 @@
861510260 }
861610261 }
861710262
8618
- boolean IsFrozen()
8619
- {
8620
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8621
-
8622
- return !selectmode && cameracount == 0; // != 0;
8623
- }
8624
-
862510263 boolean niceon = false;
862610264 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
862710265 boolean currentlydrawing = false;
....@@ -8631,16 +10269,16 @@
863110269
863210270 public void display(GLAutoDrawable drawable)
863310271 {
8634
- if (GrafreeD.savesound && GrafreeD.hassound)
10272
+ if (Grafreed.savesound && Grafreed.hassound)
863510273 {
8636
- GrafreeD.wav.save();
8637
- GrafreeD.savesound = false;
8638
- GrafreeD.hassound = false;
10274
+ Grafreed.wav.save();
10275
+ Grafreed.savesound = false;
10276
+ Grafreed.hassound = false;
863910277 }
864010278 // if (DEBUG_SELECTION)
864110279 // {
8642
-// if (drawMode != SELECTION)
8643
-// drawMode = SELECTION;
10280
+// if (DrawMode() != SELECTION)
10281
+// DrawMode() = SELECTION;
864410282 // }
864510283
864610284 if (!isRenderer)
....@@ -8696,9 +10334,9 @@
869610334
869710335 //ANTIALIAS = 0;
869810336
8699
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10337
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870010338 {
8701
- if (niceon || isLIVE())
10339
+ if (niceon || Globals.isLIVE())
870210340 {
870310341 //if(active == 0)
870410342 // antialiaser = null;
....@@ -8723,7 +10361,7 @@
872310361 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872410362 */
872510363
8726
- if (drawMode == DEFAULT)
10364
+ if (DrawMode() == DEFAULT)
872710365 {
872810366 currentlydrawing = true;
872910367 }
....@@ -8754,18 +10392,18 @@
875410392
875510393 // if(Applet3D.clipboard != null)
875610394 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8757
-//drawMode = SELECTION;
10395
+//DrawMode() = SELECTION;
875810396 indexcount = 0;
875910397
8760
- if (drawMode == OCCLUSION)
10398
+ if (DrawMode() == OCCLUSION)
876110399 {
8762
- drawMode = DEFAULT;
10400
+ Globals.drawMode = DEFAULT; // WARNING
876310401 ambientOcclusion = true;
876410402 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876510403 Object3D theobject = object;
876610404 Object3D theparent = object.parent;
876710405 object.parent = null;
8768
- object = (Object3D)GrafreeD.clone(object);
10406
+ object = (Object3D)Grafreed.clone(object);
876910407 object.Stripify();
877010408 if (theobject.selection == null || theobject.selection.Size() == 0)
877110409 theobject.PreprocessOcclusion(this);
....@@ -8778,19 +10416,19 @@
877810416 ambientOcclusion = false;
877910417 }
878010418
8781
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878210420 {
878310421 //if (RENDERSHADOW) // ?
878410422 if (!IsFrozen())
878510423 {
878610424 // dec 2012
8787
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
878810426 {
8789
- framecount++;
10427
+ Globals.framecount++;
879010428 shadowbuffer.display();
879110429 }
879210430 }
8793
- lighttouched = false; // ??
10431
+ Globals.lighttouched = false; // ??
879410432 //drawing = true;
879510433 //lighttouched = true;
879610434 }
....@@ -8811,9 +10449,9 @@
881110449 //eyeCamera.shaper_fovy = 1;
881210450 }
881310451
8814
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10452
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881510453 {
8816
- //System.out.println("drawMode = " + drawMode);
10454
+ //System.out.println("DrawMode() = " + DrawMode());
881710455 vertexMode |= VP_PASS;
881810456 //vertexMode |= VP_PROJECTION;
881910457 if (!ambientOcclusion)
....@@ -8873,7 +10511,7 @@
887310511 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887410512 //Camera lightcam = new Camera(light0);
887510513
8876
- if (drawMode == SHADOW)
10514
+ if (DrawMode() == SHADOW)
887710515 {
887810516 /*
887910517 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8911,8 +10549,8 @@
891110549
891210550 // if (parentcam != renderCamera) // not a light
891310551 if (cam != lightCamera)
8914
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8915
- LA.matConcat(parentcam.toParent, matrix, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
891610554
891710555 for (int j = 0; j < 4; j++)
891810556 {
....@@ -8926,8 +10564,8 @@
892610564
892710565 // if (parentcam != renderCamera) // not a light
892810566 if (cam != lightCamera)
8929
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8930
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
893110569
893210570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893310571
....@@ -8963,7 +10601,7 @@
896310601 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896410602 } else
896510603 {
8966
- if (drawMode != DEFAULT)
10604
+ if (DrawMode() != DEFAULT)
896710605 {
896810606 gl.glClearColor(1, 1, 1, 0);
896910607 } // 1);
....@@ -9028,7 +10666,7 @@
902810666
902910667 fast &= !ambientOcclusion;
903010668
9031
- if (drawMode == DEFAULT)
10669
+ if (DrawMode() == DEFAULT)
903210670 {
903310671 //gl.glEnable(gl.GL_ALPHA_TEST);
903410672 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9089,6 +10727,8 @@
908910727 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909010728 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909110729 double scale = lightCamera.SCALE / lightCamera.Distance();
10730
+// PATCH FILLE AUX JEANS
10731
+ //scale *= lightCamera.shaper_fovy / 25;
909210732 gl.glScaled(2 * scale, 2 * scale, -scale);
909310733 gl.glTranslated(0, 0, lightCamera.DECAL);
909410734
....@@ -9184,7 +10824,16 @@
918410824 // Bump noise
918510825 gl.glActiveTexture(GL.GL_TEXTURE6);
918610826 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9187
- BindTexture(NOISE_TEXTURE, false, 2);
10827
+
10828
+ try
10829
+ {
10830
+ BindTexture(NOISE_TEXTURE, false, 2);
10831
+ }
10832
+ catch (Exception e)
10833
+ {
10834
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10835
+ }
10836
+
918810837
918910838 gl.glActiveTexture(GL.GL_TEXTURE0);
919010839 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9224,10 +10873,12 @@
922410873 gl.glMatrixMode(gl.GL_PROJECTION);
922510874 gl.glLoadIdentity();
922610875
9227
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
10876
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
922810877 {
922910878 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923010879 double scale = lightCamera.SCALE / lightCamera.Distance();
10880
+// PATCH FILLE AUX JEANS
10881
+ //scale *= lightCamera.shaper_fovy / 25;
923110882 gl.glScaled(2 * scale, 2 * scale, -scale);
923210883 gl.glTranslated(0, 0, lightCamera.DECAL);
923310884 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9280,7 +10931,7 @@
928010931 //gl.glPushMatrix();
928110932 gl.glLoadIdentity();
928210933
9283
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10934
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928410935 {
928510936 //LA.xformPos(light0, lightCamera.fromScreen, light);
928610937 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9307,8 +10958,8 @@
930710958 System.err.println("parentcam != renderCamera");
930810959
930910960 // if (cam != lightCamera)
9310
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9311
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
10961
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
931210963 }
931310964
931410965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -9329,8 +10980,8 @@
932910980 if (true) // TODO
933010981 {
933110982 if (cam != lightCamera)
9332
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9333
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
10983
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
933410985 }
933510986
933610987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -9367,7 +11018,7 @@
936711018 }
936811019
936911020 /**/
9370
- if (true) // drawMode == SELECTION) // != DEFAULT)
11021
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937111022 gl.glDisable(gl.GL_LIGHTING);
937211023 else
937311024 gl.glEnable(gl.GL_LIGHTING);
....@@ -9379,12 +11030,13 @@
937911030
938011031 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
938111032 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
11033
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
938211034
938311035 options2[0] *= renderCamera.Distance();
938411036
938511037 lightslot = 64;
938611038
9387
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11039
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
938811040 {
938911041 DrawLights(object);
939011042 }
....@@ -9395,7 +11047,7 @@
939511047 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
939611048 //System.out.println("fragmentMode = " + fragmentMode);
939711049
9398
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11050
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
939911051 {
940011052 /*
940111053 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9428,7 +11080,7 @@
942811080 }
942911081 }
943011082
9431
- if (drawMode == DEFAULT)
11083
+ if (DrawMode() == DEFAULT)
943211084 {
943311085 if (WIREFRAME && !ambientOcclusion)
943411086 {
....@@ -9446,7 +11098,7 @@
944611098 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
944711099 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
944811100
9449
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11101
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945011102 {
945111103 if (vertexMode != 0) // && !fast)
945211104 {
....@@ -9466,7 +11118,7 @@
946611118 }
946711119 }
946811120
9469
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11121
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947011122 {
947111123 //gl.glDepthFunc(GL.GL_LEQUAL);
947211124 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9494,7 +11146,7 @@
949411146 //gl.glDepthMask(false);
949511147 }
949611148
9497
- if (false) // drawMode == SHADOW)
11149
+ if (false) // DrawMode() == SHADOW)
949811150 {
949911151 //SetColumnMajorData(cameraInverseTransform, view_1);
950011152 //System.out.println("light = " + cameraInverseTransform);
....@@ -9508,16 +11160,16 @@
950811160 //System.out.println("object = " + object);
950911161 if (!frozen && !imageLocked)
951011162 {
9511
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11163
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951211164 {
951311165 displayAntiAliased(gl);
951411166 } else
951511167 {
951611168 programcount = 0;
9517
- int keepmode = drawMode;
11169
+ int keepmode = DrawMode();
951811170 // if (DEBUG_SELECTION)
951911171 // {
9520
-// drawMode = SELECTION;
11172
+// DrawMode() = SELECTION;
952111173 // }
952211174 // for point selection
952311175 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9527,10 +11179,10 @@
952711179 DrawObject(gl);
952811180
952911181 // jan 2013 System.err.println("RESET ABORT (display)");
9530
- // if (drawMode == DEFAULT)
11182
+ // if (DrawMode() == DEFAULT)
953111183 // ABORTED = false;
953211184 fullreset = false;
9533
- drawMode = keepmode;
11185
+ Globals.drawMode = keepmode; // WARNING
953411186 //System.out.println("PROGRAM SWITCH " + programcount);
953511187 }
953611188 }
....@@ -9538,11 +11190,11 @@
953811190 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
953911191 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954011192
9541
- if (drawMode == DEFAULT)
11193
+ if (DrawMode() == DEFAULT)
954211194 {
954311195 ReleaseTexture(NOISE_TEXTURE, false);
954411196 }
9545
- //if (drawMode == DEFAULT)
11197
+ //if (DrawMode() == DEFAULT)
954611198 {
954711199
954811200 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9554,7 +11206,7 @@
955411206 //else
955511207 //gl.glDisable(gl.GL_TEXTURE_2D);
955611208 //gl.glPopMatrix();
9557
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11209
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
955811210 {
955911211 //new Exception().printStackTrace();
956011212 //System.out.println("Draw image " + width + ", " + height);
....@@ -9596,7 +11248,7 @@
959611248 //gl.glFlush();
959711249 }
959811250
9599
- if (flash && drawMode == DEFAULT)
11251
+ if (flash && DrawMode() == DEFAULT)
960011252 {
960111253 flash = false;
960211254 wait = true;
....@@ -9604,9 +11256,9 @@
960411256 }
960511257
960611258 //drawing = false;
9607
- //if(drawMode == DEFAULT)
11259
+ //if(DrawMode() == DEFAULT)
960811260 // niceon = false;
9609
- if (drawMode == DEFAULT)
11261
+ if (DrawMode() == DEFAULT)
961011262 {
961111263 currentlydrawing = false;
961211264 }
....@@ -9626,7 +11278,7 @@
962611278 repaint();
962711279 }
962811280
9629
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11281
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963011282 repaint();
963111283
963211284 displaydone = true;
....@@ -9645,8 +11297,14 @@
964511297 {
964611298 renderpass++;
964711299 // System.out.println("Draw object... ");
11300
+ STEP = 1;
964811301 if (FAST) // in case there is no script
9649
- STEP = 16;
11302
+ STEP = 8;
11303
+
11304
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11305
+ {
11306
+ STEP *= 4;
11307
+ }
965011308
965111309 //object.FullInvariants();
965211310
....@@ -9660,10 +11318,10 @@
966011318 e.printStackTrace();
966111319 }
966211320
9663
- if (GrafreeD.RENDERME > 0)
9664
- GrafreeD.RENDERME--; // mechante magouille
11321
+ if (Grafreed.RENDERME > 0)
11322
+ Grafreed.RENDERME--; // mechante magouille
966511323
9666
- ONESTEP = false;
11324
+ Globals.ONESTEP = false;
966711325 }
966811326
966911327 static boolean zoomonce = false;
....@@ -9671,11 +11329,11 @@
967111329 void DrawObject(GL gl, boolean draw)
967211330 {
967311331 //System.out.println("DRAW OBJECT " + mouseDown);
9674
-// drawMode = SELECTION;
11332
+// DrawMode() = SELECTION;
967511333 //GL gl = getGL();
967611334 if ((TRACK || SHADOWTRACK) || zoomonce)
967711335 {
9678
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
11336
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
967911337 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968011338 pingthread.StepToTarget(true); // true);
968111339 // zoomonce = false;
....@@ -9696,9 +11354,9 @@
969611354 callist = gl.glGenLists(1);
969711355 }
969811356
9699
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11357
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970011358
9701
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11359
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970211360
970311361 if (!mainDL || !active || touched)
970411362 {
....@@ -9725,13 +11383,20 @@
972511383 PushMatrix(ClickInfo.matbuffer);
972611384 }
972711385
9728
- if (drawMode == 0)
11386
+ if (DrawMode() == 0)
972911387 {
973011388 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973111389
973211390 usedtextures.clear();
973311391
9734
- BindTextures(DEFAULT_TEXTURES, 2);
11392
+ try
11393
+ {
11394
+ BindTextures(DEFAULT_TEXTURES, 2);
11395
+ }
11396
+ catch (Exception e)
11397
+ {
11398
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11399
+ }
973511400 }
973611401 //System.out.println("--> " + stackdepth);
973711402 // GrafreeD.traceon();
....@@ -9739,7 +11404,7 @@
973911404 // DRAW
974011405 object.draw(this, /*(Composite)*/ object, false, false);
974111406
9742
- if (drawMode == DEFAULT)
11407
+ if (DrawMode() == DEFAULT)
974311408 {
974411409 if (DEBUG)
974511410 {
....@@ -9750,40 +11415,40 @@
975011415 selectedpoint.radius = radius;
975111416 selectedpoint.recalculate();
975211417 selectedpoint.material = new cMaterial();
9753
- selectedpoint.material.color = 0.25f;
11418
+ selectedpoint.material.color = 0.15f; // Yellow
975411419 selectedpoint.material.modulation = 0.75f;
975511420
9756
- debugpoint.radius = radius;
9757
- debugpoint.recalculate();
9758
- debugpoint.material = new cMaterial();
9759
- debugpoint.material.color = 0.25f;
9760
- debugpoint.material.modulation = 0.75f;
11421
+ debugpointG.radius = radius;
11422
+ debugpointG.recalculate();
11423
+ debugpointG.material = new cMaterial();
11424
+ debugpointG.material.color = 0.25f; // Green
11425
+ debugpointG.material.modulation = 0.75f;
976111426
9762
- debugpoint2.radius = radius;
9763
- debugpoint2.recalculate();
9764
- debugpoint2.material = new cMaterial();
9765
- debugpoint2.material.color = 0.75f;
9766
- debugpoint2.material.modulation = 0.75f;
11427
+ debugpointP.radius = radius;
11428
+ debugpointP.recalculate();
11429
+ debugpointP.material = new cMaterial();
11430
+ debugpointP.material.color = 0.75f; // Purple
11431
+ debugpointP.material.modulation = 0.75f;
976711432
9768
- debugpoint3.radius = radius;
9769
- debugpoint3.recalculate();
9770
- debugpoint3.material = new cMaterial();
9771
- debugpoint3.material.color = 0.5f;
9772
- debugpoint3.material.modulation = 0.75f;
11433
+ debugpointC.radius = radius;
11434
+ debugpointC.recalculate();
11435
+ debugpointC.material = new cMaterial();
11436
+ debugpointC.material.color = 0.5f; // Cyan
11437
+ debugpointC.material.modulation = 0.75f;
977311438
9774
- debugpoint4.radius = radius;
9775
- debugpoint4.recalculate();
9776
- debugpoint4.material = new cMaterial();
9777
- debugpoint4.material.color = 0f;
9778
- debugpoint4.material.modulation = 0.75f;
11439
+ debugpointR.radius = radius;
11440
+ debugpointR.recalculate();
11441
+ debugpointR.material = new cMaterial();
11442
+ debugpointR.material.color = 0f; // Red
11443
+ debugpointR.material.modulation = 0.75f;
977911444
978011445 InitPoints(radius);
978111446 }
978211447 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9783
- debugpoint.draw(this, /*(Composite)*/ null, false,false);
9784
- debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9785
- debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9786
- debugpoint4.draw(this, /*(Composite)*/ null, false,false);
11448
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11449
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11450
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11451
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
978711452 // DrawPoints(this);
978811453 }
978911454
....@@ -9791,7 +11456,7 @@
979111456 }
979211457 // GrafreeD.traceoff();
979311458 //System.out.println(stackdepth);
9794
- if (drawMode == 0)
11459
+ if (DrawMode() == 0)
979511460 {
979611461 ReleaseTextures(DEFAULT_TEXTURES);
979711462
....@@ -9816,17 +11481,26 @@
981611481
981711482 checker = null;
981811483
9819
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11484
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982011485 FindChecker(object);
982111486
9822
- if (checker != null && drawMode == DEFAULT)
11487
+ if (checker != null && DrawMode() == DEFAULT)
982311488 {
9824
- // BindTexture(IMMORTAL_TEXTURE);
11489
+ //BindTexture(IMMORTAL_TEXTURE);
11490
+ try
11491
+ {
11492
+ BindTextures(checker.GetTextures(), checker.texres);
11493
+ }
11494
+ catch (Exception e)
11495
+ {
11496
+ System.err.println("FAILED: " + checker.GetTextures());
11497
+ }
982511498 // NEAREST
982611499 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
982711500 DrawChecker(gl);
982811501 //checker.Draw(this, null, false);
982911502 // ReleaseTexture(IMMORTAL_TEXTURE);
11503
+ ReleaseTextures(checker.GetTextures());
983011504 }
983111505
983211506 if (object.parent != null)
....@@ -9839,7 +11513,7 @@
983911513 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984011514 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984111515
9842
- if (DISPLAYTEXT && drawMode == DEFAULT)
11516
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984311517 {
984411518 // Draw it once, then use the raster
984511519 Balloon(gl, balloon.createGraphics());
....@@ -9895,14 +11569,14 @@
989511569 int[] xs = new int[3];
989611570 int[] ys = new int[3];
989711571
9898
- void DrawString(Object3D obj) // String string)
11572
+ public void DrawString(Object3D obj) // String string) // INTERFACE
989911573 {
9900
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11574
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990111575 {
990211576 return;
990311577 }
990411578
9905
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
990611580
990711581 GL gl = GetGL();
990811582
....@@ -10219,8 +11893,8 @@
1021911893 //obj.TransformToWorld(light, light);
1022011894 for (int i = tp.size(); --i >= 0;)
1022111895 {
10222
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
10223
- LA.xformPos(light, tp.get(i).toParent, light);
11896
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1022411898 }
1022511899
1022611900
....@@ -10237,8 +11911,8 @@
1023711911 parentcam = cameras[0];
1023811912 }
1023911913
10240
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10241
- LA.xformPos(light, parentcam.toParent, light); // may 2013
11914
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1024211916
1024311917 LA.xformPos(light, renderCamera.toScreen, light);
1024411918
....@@ -10357,11 +12031,13 @@
1035712031 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1035812032 "PARAM params7 = program.env[7];" + // noise power, opacity power
1035912033 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10360
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
12034
+ "PARAM options1 = program.env[62];" + // fog rgb color
12035
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1036112036 "PARAM pointlight = program.env[127];" + // ...
1036212037 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1036312038 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1036412039 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12040
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1036512041 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1036612042 "PARAM ten = { 10, 10, 10, 1.0 };" +
1036712043 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10382,6 +12058,7 @@
1038212058 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038312059 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1038412060 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
12061
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1038512062 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1038612063 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1038712064 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10422,6 +12099,10 @@
1042212099 "TEMP R1;" +
1042312100 "TEMP R2;" +
1042412101 "TEMP R3;" +
12102
+ "TEMP min;" +
12103
+ "TEMP max;" +
12104
+ "TEMP average;" +
12105
+ "TEMP saturation;" +
1042512106 "TEMP keep1;" +
1042612107 "TEMP keep2;" +
1042712108 "TEMP keep3;" +
....@@ -10845,8 +12526,8 @@
1084512526
1084612527 // display shadow only (bump == 0)
1084712528 "SUB temp.x, half.x, shadow.x;" +
10848
- "MOV temp.y, -params6.x;" +
10849
- "SLT temp.z, temp.y, zero.x;" +
12529
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12530
+ "SLT temp.z, temp.y, -one2048th.x;" +
1085012531 "SUB temp.y, one.x, temp.z;" +
1085112532 "MUL temp.x, temp.x, temp.y;" +
1085212533 "KIL temp.x;" +
....@@ -10952,10 +12633,42 @@
1095212633
1095312634 // skin?
1095412635 // Saturation for skin
10955
- /**/ // c'est ici
10956
- (Skinshader? "DP3 temp.x, final,one;" +
12636
+ /**/
12637
+ (Skinshader?
12638
+ "DP3 average.x, final,one;" +
12639
+ "MUL average, one3rd.xxxx,average.xxxx;" +
12640
+
12641
+ "MIN min.x, final.x,final.y;" +
12642
+ "MIN min.x, min.x,final.z;" +
12643
+
12644
+ "MAX max.x, final.x,final.y;" +
12645
+ "MAX max.x, max.x,final.z;" +
12646
+ "MOV max, max.xxxx;" +
12647
+
12648
+ "SUB saturation, max, final;" +
12649
+
12650
+ "ADD temp.x, max.x, one10th.x;" +
12651
+ "RCP temp.x, temp.x;" +
12652
+ "MUL temp.x, temp.x, half.x;" +
12653
+ "MUL saturation, saturation, temp.xxxx;" +
12654
+
12655
+ "DP3 ndotl.x, normald, light;" +
12656
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
12657
+
12658
+ "SUB temp.x, one.x, ndotl.x;" +
12659
+ // Tuning for default skin
12660
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12661
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12662
+ "ADD temp.y, one.y, options2.y;" + // subsurface
12663
+ "MUL temp.x, temp.x, temp.y;" +
12664
+
12665
+ "MUL saturation, saturation, temp.xxxx;" +
12666
+ "SUB_SAT temp, max, saturation;" +
12667
+/**
12668
+ "DP3 temp.x, final,one;" +
1095712669 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10958
- "SUB temp, final,R2;" +
12670
+ "SUB temp, final, R2;" +
12671
+
1095912672 // using light angle
1096012673 "DP3 ndotl.x, normald,light;" +
1096112674 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10968,7 +12681,6 @@
1096812681 // using light intensity
1096912682 "MOV ndotl.z, R2.x;" +
1097012683 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10971
-
1097212684 // june 2014
1097312685 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1097412686 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10980,6 +12692,7 @@
1098012692 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1098112693
1098212694 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
12695
+/**/
1098312696
1098412697 // "ADD final, R2,temp;" +
1098512698 "MOV final, temp;"
....@@ -11069,7 +12782,7 @@
1106912782 /**/
1107012783 // HDR
1107112784 "MOV temp.z, final.a;" +
11072
- "MUL final, final,options1.w;" +
12785
+ "MUL final, final,options2.x;" +
1107312786 "MOV final.a, temp.z;" +
1107412787 /**/
1107512788
....@@ -11145,7 +12858,7 @@
1114512858 //once = true;
1114612859 }
1114712860
11148
- System.out.print("Program #" + mode + "; length = " + program.length());
12861
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1114912862 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1115012863 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1115112864
....@@ -11262,6 +12975,7 @@
1126212975 String Shadow(String depth, String shadow)
1126312976 {
1126412977 return "MAX temp.x, ndotl.x, one64th.x;" +
12978
+ "MIN temp.x, temp.x, ninetenth.x;" +
1126512979 /**/
1126612980 // Sine
1126712981 "MUL temp.y, temp.x, temp.x;" +
....@@ -11277,12 +12991,16 @@
1127712991
1127812992 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1127912993 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12994
+
12995
+ // Compare fragment depth in light space with shadowmap.
1128012996 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1128112997 "SGE temp.y, temp.x, zero.x;" +
11282
- "SUB " + shadow + ".y, one.x, temp.y;" +
12998
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12999
+
13000
+ // Reverse comparison
1128313001 "SUB temp.x, one.x, temp.x;" +
1128413002 "MUL " + shadow + ".x, temp.x, temp.y;" +
11285
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13003
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1128613004 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1128713005
1128813006 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11296,6 +13014,10 @@
1129613014 // No shadow for backface
1129713015 "DP3 temp.x, normal, lightd;" +
1129813016 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13017
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13018
+
13019
+ // No shadow when out of frustrum
13020
+ "SGE temp.x, " + depth + ".z, one.z;" +
1129913021 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1130013022 "";
1130113023 }
....@@ -11854,7 +13576,7 @@
1185413576 public void mousePressed(MouseEvent e)
1185513577 {
1185613578 //System.out.println("mousePressed: " + e);
11857
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13579
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1185813580 }
1185913581
1186013582 static long prevtime = 0;
....@@ -11881,14 +13603,16 @@
1188113603
1188213604 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1188313605
13606
+ if (BUTTONLESSWHEEL)
1188413607 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1188513608 {
1188613609 return;
1188713610 }
1188813611
13612
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1188913613
1189013614 // TIMER
11891
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13615
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1189213616 {
1189313617 keepboxmode = BOXMODE;
1189413618 keepsupport = SUPPORT;
....@@ -11928,8 +13652,8 @@
1192813652 // mode |= META;
1192913653 //}
1193013654
11931
- SetMouseMode(WHEEL | e.getModifiersEx());
11932
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13655
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13656
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1193313657 anchorX = ax;
1193413658 anchorY = ay;
1193513659 prevX = px;
....@@ -11989,6 +13713,10 @@
1198913713 // wasliveok = true;
1199013714 // waslive = false;
1199113715
13716
+ // May 2019 Forget it:
13717
+ if (true)
13718
+ return;
13719
+
1199213720 // source == timer
1199313721 if (mouseDown)
1199413722 {
....@@ -12017,7 +13745,7 @@
1201713745 // ObjEditor.tweenManager.update(1f / 60f);
1201813746
1201913747 // fev 2014???
12020
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
13748
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1202113749 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1202213750 pingthread.StepToTarget(true); // true);
1202313751 }
....@@ -12027,7 +13755,7 @@
1202713755
1202813756 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1202913757
12030
- void clickStart(int x, int y, int modifiers)
13758
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1203113759 {
1203213760 if (!wasliveok)
1203313761 return;
....@@ -12044,7 +13772,7 @@
1204413772 // touched = true; // main DL
1204513773 if (isRenderer)
1204613774 {
12047
- SetMouseMode(modifiers);
13775
+ SetMouseMode(modifiers, modifiersex);
1204813776 }
1204913777
1205013778 selectX = anchorX = x;
....@@ -12057,7 +13785,7 @@
1205713785 clicked = true;
1205813786 hold = false;
1205913787
12060
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13788
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1206113789 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1206213790 {
1206313791 // System.out.println("RESTART II " + modifiers);
....@@ -12088,7 +13816,7 @@
1208813816 info.camera = renderCamera;
1208913817 info.x = x;
1209013818 info.y = y;
12091
- info.modifiers = modifiers;
13819
+ info.modifiers = modifiersex;
1209213820 editObj = object.doEditClick(info, 0);
1209313821 if (!editObj)
1209413822 {
....@@ -12105,11 +13833,14 @@
1210513833
1210613834 public void mouseDragged(MouseEvent e)
1210713835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
13838
+ //System.out.println("mouseDragged: " + e);
1210813839 if (isRenderer)
1210913840 movingcamera = true;
13841
+
1211013842 //if (drawing)
1211113843 //return;
12112
- //System.out.println("mouseDragged: " + e);
1211313844 if ((e.getModifiersEx() & CTRL) != 0
1211413845 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1211513846 {
....@@ -12117,7 +13848,7 @@
1211713848 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1211813849 }
1211913850 else
12120
- drag(e.getX(), e.getY(), e.getModifiersEx());
13851
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1212113852
1212213853 //try { Thread.sleep(1); } catch (Exception ex) {}
1212313854 }
....@@ -12129,6 +13860,11 @@
1212913860 cVector tmp = new cVector();
1213013861 cVector tmp2 = new cVector();
1213113862 boolean isMoving;
13863
+
13864
+ public cVector TargetLookAt()
13865
+ {
13866
+ return targetLookAt;
13867
+ }
1213213868
1213313869 class PingThread extends Thread
1213413870 {
....@@ -12268,7 +14004,7 @@
1226814004 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1226914005 if (lightMode)
1227014006 {
12271
- lighttouched = true;
14007
+ Globals.lighttouched = true;
1227214008 }
1227314009
1227414010 if (OEILONCE && OEIL)
....@@ -12285,6 +14021,7 @@
1228514021
1228614022 public void run()
1228714023 {
14024
+ new Exception().printStackTrace();
1228814025 System.exit(0);
1228914026 for (;;)
1229014027 {
....@@ -12326,7 +14063,7 @@
1232614063 mouseDown = false;
1232714064 if (lightMode)
1232814065 {
12329
- lighttouched = true;
14066
+ Globals.lighttouched = true;
1233014067 }
1233114068 repaint();
1233214069 alreadypainted = true;
....@@ -12334,7 +14071,7 @@
1233414071 isMoving = false;
1233514072 } //??
1233614073
12337
- if (isLIVE() && !alreadypainted)
14074
+ if (Globals.isLIVE() && !alreadypainted)
1233814075 {
1233914076 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1234014077 repaint();
....@@ -12346,9 +14083,9 @@
1234614083 {
1234714084 if (lightMode)
1234814085 {
12349
- lighttouched = true;
14086
+ Globals.lighttouched = true;
1235014087 }
12351
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14088
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1235214089 }
1235314090 //else
1235414091 }
....@@ -12448,7 +14185,7 @@
1244814185 int X, Y;
1244914186 boolean SX, SY;
1245014187
12451
- void drag(int x, int y, int modifiers)
14188
+ void drag(int x, int y, int modifiers, int modifiersex)
1245214189 {
1245314190 if (IsFrozen())
1245414191 {
....@@ -12457,17 +14194,17 @@
1245714194
1245814195 drag = true; // NEW
1245914196
12460
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14197
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1246114198
1246214199 X = x;
1246314200 Y = y;
1246414201 // floating state for animation
12465
- MODIFIERS = modifiers;
12466
- modifiers &= ~1024;
14202
+ MODIFIERS = modifiersex;
14203
+ modifiersex &= ~1024;
1246714204 if (false) // modifiers != 0)
1246814205 {
1246914206 //new Exception().printStackTrace();
12470
- System.out.println("mouseDragged: " + modifiers);
14207
+ System.out.println("mouseDragged: " + modifiersex);
1247114208 System.out.println("SHIFT = " + SHIFT);
1247214209 System.out.println("CONTROL = " + COMMAND);
1247314210 System.out.println("META = " + META);
....@@ -12487,7 +14224,7 @@
1248714224 info.camera = renderCamera;
1248814225 info.x = x;
1248914226 info.y = y;
12490
- object.editWindow.copy.doEditDrag(info);
14227
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1249114228 } else
1249214229 {
1249314230 if (x < startX)
....@@ -12589,6 +14326,7 @@
1258914326 {
1259014327 manipCamera.Translate(dx, dy, getWidth());
1259114328 }
14329
+ else
1259214330 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1259314331 {
1259414332 manipCamera.RotateInterest(dx, dy);
....@@ -12599,7 +14337,7 @@
1259914337
1260014338 if (manipCamera == lightCamera)
1260114339 {
12602
- lighttouched = true;
14340
+ Globals.lighttouched = true;
1260314341 }
1260414342 /*
1260514343 switch (mode)
....@@ -12638,7 +14376,6 @@
1263814376 public void mouseMoved(MouseEvent e)
1263914377 {
1264014378 //System.out.println("mouseMoved: " + e);
12641
-
1264214379 if (isRenderer)
1264314380 return;
1264414381
....@@ -12663,7 +14400,10 @@
1266314400
1266414401 public void mouseReleased(MouseEvent e)
1266514402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1266614405 movingcamera = false;
14406
+ X = Y = 0;
1266714407 //System.out.println("mouseReleased: " + e);
1266814408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1266914409 }
....@@ -12686,9 +14426,9 @@
1268614426 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1268714427 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1268814428
12689
- if (control || command || IsFrozen())
14429
+// No delay if (control || command || IsFrozen())
1269014430 timeout = true;
12691
- else
14431
+// ?? May 2019 else
1269214432 // timer.setDelay((modifiers & 128) != 0?0:350);
1269314433 mouseDown = false;
1269414434 if (!control && !command) // june 2013
....@@ -12798,7 +14538,7 @@
1279814538 System.out.println("keyReleased: " + e);
1279914539 }
1280014540
12801
- void SetMouseMode(int modifiers)
14541
+ void SetMouseMode(int modifiers, int modifiersex)
1280214542 {
1280314543 //System.out.println("SetMouseMode = " + modifiers);
1280414544 //modifiers &= ~1024;
....@@ -12810,24 +14550,27 @@
1281014550 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1281114551 // return;
1281214552 //System.out.println("SetMode = " + modifiers);
12813
- if ((modifiers & WHEEL) == WHEEL)
14553
+ if ((modifiersex & WHEEL) == WHEEL)
1281414554 {
1281514555 mouseMode |= ZOOM;
1281614556 }
12817
- if ((modifiers & META) == META)
14557
+
14558
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14559
+ if (capsLocked) // || (modifiers & META) == META)
1281814560 {
1281914561 mouseMode |= VR; // BACKFORTH;
1282014562 }
12821
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
12822
- {
12823
- mouseMode |= SELECT; // BACKFORTH;
12824
- }
12825
- if ((modifiers & COMMAND) == COMMAND)
14563
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1282614564 {
1282714565 mouseMode |= SELECT;
1282814566 }
12829
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14567
+ if ((modifiersex & COMMAND) == COMMAND)
1283014568 {
14569
+ mouseMode |= SELECT;
14570
+ }
14571
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
14572
+ {
14573
+ mouseMode &= ~VR;
1283114574 mouseMode |= TRANSLATE;
1283214575 }
1283314576 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12854,10 +14597,10 @@
1285414597
1285514598 if (isRenderer) //
1285614599 {
12857
- SetMouseMode(modifiers);
14600
+ SetMouseMode(0, modifiers);
1285814601 }
1285914602
12860
- theRenderer.keyPressed(key);
14603
+ Globals.theRenderer.keyPressed(key);
1286114604 }
1286214605
1286314606 int kompactbit = 4; // power bit
....@@ -12869,7 +14612,7 @@
1286914612 float SATPOW = 1; // 2; // 0.5f;
1287014613 float BRIPOW = 1; // 0.5f; // 0.5f;
1287114614
12872
- void keyPressed(int key)
14615
+ public void keyPressed(int key)
1287314616 {
1287414617 if (key >= '0' && key <= '5')
1287514618 clampbit = (key-'0');
....@@ -12984,7 +14727,7 @@
1298414727 case 'B':
1298514728 BRISMOOTH ^= true;
1298614729 SHADOWCULLFACE ^= true;
12987
- lighttouched = true;
14730
+ Globals.lighttouched = true;
1298814731 repaint();
1298914732 break;
1299014733 case 'b':
....@@ -13084,7 +14827,7 @@
1308414827 repaint();
1308514828 break;
1308614829 case 'O':
13087
- drawMode = OCCLUSION;
14830
+ Globals.drawMode = OCCLUSION; // WARNING
1308814831 repaint();
1308914832 break;
1309014833 case 'o':
....@@ -13175,7 +14918,7 @@
1317514918 break;
1317614919 case ' ':
1317714920 lightMode ^= true;
13178
- lighttouched = true;
14921
+ Globals.lighttouched = true;
1317914922 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1318014923 targetLookAt.set(manipCamera.lookAt);
1318114924 repaint();
....@@ -13187,11 +14930,11 @@
1318714930 repaint();
1318814931 break;
1318914932 case 'Z':
13190
- RESIZETEXTURE ^= true;
13191
- break;
14933
+ //RESIZETEXTURE ^= true;
14934
+ //break;
1319214935 case 'z':
13193
- RENDERSHADOW ^= true;
13194
- lighttouched = true;
14936
+ Globals.RENDERSHADOW ^= true;
14937
+ Globals.lighttouched = true;
1319514938 repaint();
1319614939 break;
1319714940 //case UP:
....@@ -13217,7 +14960,8 @@
1321714960 FlipTransform();
1321814961 break;
1321914962 case ENTER:
13220
- object.editWindow.ScreenFit(); // Edit();
14963
+ // object.editWindow.ScreenFit(); // Edit();
14964
+ ToggleLive();
1322114965 break;
1322214966 case DELETE:
1322314967 ClearSelection();
....@@ -13305,6 +15049,7 @@
1330515049 }
1330615050 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1330715051 }
15052
+
1330815053 static double OCCLUSIONBOOST = 1; // 0.5;
1330915054
1331015055 void keyReleased(int key, int modifiers)
....@@ -13312,11 +15057,11 @@
1331215057 //mode = ROTATE;
1331315058 if ((MODIFIERS & COMMAND) == 0) // VR??
1331415059 {
13315
- SetMouseMode(modifiers);
15060
+ SetMouseMode(0, modifiers);
1331615061 }
1331715062 }
1331815063
13319
- protected void processKeyEvent(KeyEvent e)
15064
+ public void processKeyEvent(KeyEvent e)
1332015065 {
1332115066 switch (e.getID())
1332215067 {
....@@ -13446,8 +15191,9 @@
1344615191
1344715192 protected void processMouseMotionEvent(MouseEvent e)
1344815193 {
13449
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13450
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15194
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15195
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15196
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1345115197 {
1345215198 mouseMoved(e);
1345315199 } else
....@@ -13477,6 +15223,7 @@
1347715223
1347815224 void SelectParent()
1347915225 {
15226
+ new Exception().printStackTrace();
1348015227 System.exit(0);
1348115228 Composite group = (Composite) object;
1348215229 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13500,6 +15247,7 @@
1350015247
1350115248 void SelectChildren()
1350215249 {
15250
+ new Exception().printStackTrace();
1350315251 System.exit(0);
1350415252 /*
1350515253 Composite group = (Composite) object;
....@@ -13664,7 +15412,9 @@
1366415412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1366515413 //Image img = CreateImage(width, height);
1366615414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1366715416 Graphics gr = g; // img.getGraphics();
15417
+
1366815418 if (!hasMarquee)
1366915419 {
1367015420 if (Xmin < Xmax) // !locked)
....@@ -13762,14 +15512,33 @@
1376215512 if (!isRenderer)
1376315513 {
1376415514 object.drawEditHandles(info, 0);
15515
+
15516
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15517
+ {
15518
+ switch (object.selection.get(0).hitSomething)
15519
+ {
15520
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15521
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15522
+ break;
15523
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15524
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15525
+ break;
15526
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15527
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15528
+ break;
15529
+ }
15530
+
15531
+ }
1376515532 }
1376615533 }
15534
+
1376715535 if (isRenderer)
1376815536 {
1376915537 //gr.setColor(Color.black);
1377015538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1377115539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1377215540 }
15541
+
1377315542 if (hasMarquee)
1377415543 {
1377515544 gr.setXORMode(Color.white);
....@@ -13792,6 +15561,7 @@
1379215561 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1379315562 }
1379415563
15564
+ // To avoid clear.
1379515565 public void update(Graphics g)
1379615566 {
1379715567 paint(g);
....@@ -13881,6 +15651,7 @@
1388115651 public boolean mouseDown(Event evt, int x, int y)
1388215652 {
1388315653 System.out.println("mouseDown: " + evt);
15654
+ System.exit(0);
1388415655 /*
1388515656 locked = true;
1388615657 drag = false;
....@@ -13924,7 +15695,7 @@
1392415695 {
1392515696 keyPressed(0, modifiers);
1392615697 }
13927
- clickStart(x, y, modifiers);
15698
+ // clickStart(x, y, modifiers);
1392815699 return true;
1392915700 }
1393015701
....@@ -14042,7 +15813,7 @@
1404215813 {
1404315814 keyReleased(0, 0);
1404415815 }
14045
- drag(x, y, modifiers);
15816
+ drag(x, y, 0, modifiers);
1404615817 return true;
1404715818 }
1404815819
....@@ -14174,7 +15945,7 @@
1417415945 Object3D object;
1417515946 static Object3D trackedobject;
1417615947 Camera renderCamera; // Light or Eye (or Occlusion)
14177
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1417815949 /*static*/ Camera eyeCamera;
1417915950 /*static*/ Camera lightCamera;
1418015951 int cameracount;
....@@ -14394,7 +16165,7 @@
1439416165 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1439516166 gl.glPushMatrix();
1439616167 gl.glLoadIdentity();
14397
- PushMatrix(checker.toParent);
16168
+ //PushMatrix(checker.toParent);
1439816169
1439916170 gl.glMatrixMode(GL.GL_TEXTURE);
1440016171 gl.glPushMatrix();
....@@ -14417,8 +16188,8 @@
1441716188
1441816189 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1441916190
14420
- float step = 0.1666f; //0.25f;
14421
- float stepv = step * 1652 / 998;
16191
+ float step = 2; // 0.1666f; //0.25f;
16192
+ float stepv = 2; // step * 1652 / 998;
1442216193
1442316194 int i0 = 0;
1442416195 /*
....@@ -14454,20 +16225,21 @@
1445416225 /**/
1445516226 //checker.GetMaterial().opacity = 1.1f;
1445616227 ////checker.GetMaterial().ambient = 0.99f;
14457
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14458
- Object3D.selectedstack[Object3D.materialdepth] = false;
14459
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16228
+ materialstack[materialdepth] = checker.material;
16229
+ selectedstack[materialdepth] = false;
16230
+ cStatic.objectstack[materialdepth++] = checker;
1446016231 //System.out.println("material " + material);
1446116232 //Applet3D.tracein(this, selected);
1446216233 vector2buffer = checker.projectedVertices;
1446316234
14464
- checker.GetMaterial().Draw(this, false); // true);
16235
+ //checker.GetMaterial().Draw(this, false); // true);
16236
+ DrawMaterial(checker.GetMaterial(), false); // true);
1446516237
14466
- Object3D.materialdepth -= 1;
14467
- if (Object3D.materialdepth > 0)
16238
+ materialdepth -= 1;
16239
+ if (materialdepth > 0)
1446816240 {
14469
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14470
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16241
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16242
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1447116243 }
1447216244 //checker.GetMaterial().opacity = 1f;
1447316245 ////checker.GetMaterial().ambient = 1f;
....@@ -14488,15 +16260,27 @@
1448816260
1448916261 //float u = (i+1)/2;
1449016262 //float v = (j+1)/2;
14491
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
16263
+ if (checker.flipV)
16264
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
16265
+ else
16266
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1449216267 gl.glVertex3f(i, j, -0.5f);
1449316268
16269
+ if (checker.flipV)
16270
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
16271
+ else
1449416272 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1449516273 gl.glVertex3f(i + step, j, -0.5f);
1449616274
16275
+ if (checker.flipV)
16276
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
16277
+ else
1449716278 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1449816279 gl.glVertex3f(i + step, j + stepv, -0.5f);
1449916280
16281
+ if (checker.flipV)
16282
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
16283
+ else
1450016284 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1450116285 gl.glVertex3f(i, j + stepv, -0.5f);
1450216286 }
....@@ -14508,7 +16292,7 @@
1450816292 gl.glMatrixMode(GL.GL_PROJECTION);
1450916293 gl.glPopMatrix();
1451016294 gl.glMatrixMode(GL.GL_MODELVIEW);
14511
- PopMatrix(null); // checker.toParent); // null);
16295
+ //PopMatrix(null); // checker.toParent); // null);
1451216296 gl.glPopMatrix();
1451316297 PopTextureMatrix(checker.toParent);
1451416298 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14599,6 +16383,7 @@
1459916383 {
1460016384 if (!selection)
1460116385 {
16386
+ new Exception().printStackTrace();
1460216387 System.exit(0);
1460316388 return;
1460416389 }
....@@ -14621,14 +16406,14 @@
1462116406
1462216407 //int tmp = selection_view;
1462316408 //selection_view = -1;
14624
- int temp = drawMode;
14625
- drawMode = SELECTION;
16409
+ int temp = DrawMode();
16410
+ Globals.drawMode = SELECTION; // WARNING
1462616411 indexcount = 0;
1462716412 parent.display(drawable);
1462816413 //selection_view = tmp;
1462916414 //if (temp == SELECTION)
1463016415 // temp = DEFAULT; // patch for selection debug
14631
- drawMode = temp;
16416
+ Globals.drawMode = temp; // WARNING
1463216417
1463316418 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1463416419
....@@ -14678,6 +16463,11 @@
1467816463 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1467916464 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1468016465
16466
+ // Will fit the mesh !!!
16467
+ selectedpoint.toParent[0][0] = 0.0001;
16468
+ selectedpoint.toParent[1][1] = 0.0001;
16469
+ selectedpoint.toParent[2][2] = 0.0001;
16470
+
1468116471 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1468216472
1468316473 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14721,16 +16511,16 @@
1472116511 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]));
1472216512 }
1472316513
14724
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16514
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1472516515 }
1472616516 }
1472716517
1472816518 if (!movingcamera && !PAINTMODE)
1472916519 object.editWindow.ScreenFitPoint(); // fev 2014
1473016520
14731
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16521
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1473216522 {
14733
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16523
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1473416524
1473516525 Object3D group = new Object3D("inst" + paintcount++);
1473616526
....@@ -14886,7 +16676,7 @@
1488616676 gl.glDisable(gl.GL_CULL_FACE);
1488716677 }
1488816678
14889
- if (!RENDERSHADOW)
16679
+ if (!Globals.RENDERSHADOW)
1489016680 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1489116681
1489216682 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14896,14 +16686,14 @@
1489616686 //gl.glColorMask(false, false, false, false);
1489716687
1489816688 //render_scene_from_light_view(gl, drawable, 0, 0);
14899
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
16689
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1490016690 {
1490116691 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1490216692
14903
- int temp = drawMode;
14904
- drawMode = SHADOW;
16693
+ int temp = DrawMode();
16694
+ Globals.drawMode = SHADOW; // WARNING
1490516695 parent.display(drawable);
14906
- drawMode = temp;
16696
+ Globals.drawMode = temp; // WARNING
1490716697 }
1490816698
1490916699 gl.glCullFace(gl.GL_BACK);
....@@ -14956,7 +16746,6 @@
1495616746
1495716747 class AntialiasBuffer implements GLEventListener
1495816748 {
14959
-
1496016749 CameraPane parent = null;
1496116750
1496216751 AntialiasBuffer(CameraPane p)
....@@ -15066,13 +16855,19 @@
1506616855 gl.glFlush();
1506716856
1506816857 /**/
15069
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
16858
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1507016859
15071
- int[] pixels = occlusionsizebuffer.array();
16860
+ float[] pixels = occlusionsizebuffer.array();
1507216861
1507316862 double r = 0, g = 0, b = 0;
1507416863
1507516864 double count = 0;
16865
+
16866
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
16867
+
16868
+ float mindepth = 1;
16869
+
16870
+ double FACTOR = 1;
1507616871
1507716872 for (int i = 0; i < pixels.length; i++)
1507816873 {
....@@ -15157,7 +16952,7 @@
1515716952
1515816953 double scale = ray.z; // 1; // cos
1515916954
15160
- int p = pixels[newindex];
16955
+ float depth = pixels[newindex];
1516116956
1516216957 /*
1516316958 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15181,10 +16976,23 @@
1518116976 scale = (1 - modu) * modv;
1518216977 */
1518316978
15184
- r += ((p >> 16) & 0xFF) * scale / 255;
15185
- g += ((p >> 8) & 0xFF) * scale / 255;
15186
- b += (p & 0xFF) * scale / 255;
16979
+ //r += ((p >> 16) & 0xFF) * scale / 255;
16980
+ //g += ((p >> 8) & 0xFF) * scale / 255;
16981
+ //b += (p & 0xFF) * scale / 255;
16982
+
16983
+ if (mindepth > depth)
16984
+ {
16985
+ mindepth = depth;
16986
+ }
1518716987
16988
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
16989
+
16990
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
16991
+
16992
+ r += factor * scale;
16993
+ g += factor * scale;
16994
+ b += factor * scale;
16995
+
1518816996 count += scale;
1518916997 }
1519016998
....@@ -15282,12 +17090,6 @@
1528217090 GLUT glut = new GLUT();
1528317091
1528417092
15285
- static final public int DEFAULT = 0;
15286
- static final public int SELECTION = 1;
15287
- static final public int SHADOW = 2;
15288
- static final public int OCCLUSION = 3;
15289
- static
15290
- public int drawMode = DEFAULT;
1529117093 public boolean spherical = false;
1529217094 static boolean DEBUG_OCCLUSION = false;
1529317095 static boolean DEBUG_SELECTION = false;
....@@ -15300,12 +17102,12 @@
1530017102 int AAbuffersize = 0;
1530117103
1530217104 //double[] selectedpoint = new double[3];
15303
- static Sphere selectedpoint = new Sphere();
17105
+ static Superellipsoid selectedpoint = new Superellipsoid();
1530417106 static Sphere previousselectedpoint = null;
15305
- static Sphere debugpoint = new Sphere();
15306
- static Sphere debugpoint2 = new Sphere();
15307
- static Sphere debugpoint3 = new Sphere();
15308
- static Sphere debugpoint4 = new Sphere();
17107
+ static Sphere debugpointG = new Sphere();
17108
+ static Sphere debugpointP = new Sphere();
17109
+ static Sphere debugpointC = new Sphere();
17110
+ static Sphere debugpointR = new Sphere();
1530917111
1531017112 static Sphere debugpoints[] = new Sphere[8];
1531117113
....@@ -15336,7 +17138,7 @@
1533617138 }
1533717139 }
1533817140
15339
- static void DrawPoints(CameraPane cpane)
17141
+ static void DrawPoints(iCameraPane cpane)
1534017142 {
1534117143 for (int i=0; i<8; i++) // first and last are red
1534217144 {
....@@ -15358,7 +17160,8 @@
1535817160 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1535917161 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1536017162 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15361
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17163
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17164
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1536217165 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1536317166 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1536417167 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15367,10 +17170,11 @@
1536717170 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1536817171 // Depth buffer format
1536917172 //private int depth_format;
15370
- static public void NextIndex(Object3D o, GL gl)
17173
+
17174
+ public void NextIndex()
1537117175 {
1537217176 indexcount+=16;
15373
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17177
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1537417178 //objects[indexcount] = o;
1537517179 //System.out.println("indexcount = " + indexcount);
1537617180 }