Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
CameraPane.java
....@@ -31,9 +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 boolean DEBUG = false;
36
+ static cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3740 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3841
3942 // camera change fix
....@@ -42,25 +45,40 @@
4245
4346 static int STEP = 1;
4447
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
48
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
5149 {
52
- return LIVE || ONESTEP;
50
+ int[] pixels = new int[bytes.length/3];
51
+ for (int i=pixels.length; --i>=0;)
52
+ {
53
+ int i3 = i*3;
54
+ pixels[i] = 0xFF;
55
+ pixels[i] <<= 8;
56
+ pixels[i] |= bytes[i3+2] & 0xFF;
57
+ pixels[i] <<= 8;
58
+ pixels[i] |= bytes[i3+1] & 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3] & 0xFF;
61
+ }
62
+ /*
63
+ int r=0,g=0,b=0,a=0;
64
+ for (int i=0; i<width; i++)
65
+ for (int j=0; j<height; j++)
66
+ {
67
+ int index = j*width+i;
68
+ int p = pixels[index];
69
+ a = ((p>>24) & 0xFF);
70
+ r = ((p>>16) & 0xFF);
71
+ g = ((p>>8) & 0xFF);
72
+ b = (p & 0xFF);
73
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
74
+ }
75
+ /**/
76
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
77
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
78
+ return rendImage;
5379 }
5480
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;
81
+ /*static*/ private boolean CULLFACE = false; // true;
6482 /*static*/ boolean NEAREST = false; // true;
6583 /*static*/ boolean WIREFRAME = false; // true;
6684
....@@ -70,14 +88,12 @@
7088 static int CURRENTANTIALIAS = 0; // 1;
7189 /*static*/ boolean RENDERSHADOW = true;
7290 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
73
- static boolean ANIMATION = false;
74
- static String filename;
7591
7692 boolean DISPLAYTEXT = false;
7793 //boolean REDUCETEXTURE = true;
7894 boolean CACHETEXTURE = true;
7995 boolean CLEANCACHE = false; // true;
80
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
8197 boolean COMPRESSTEXTURE = false;
8298 boolean KOMPACTTEXTURE = false; // true;
8399 boolean RESIZETEXTURE = false;
....@@ -97,10 +113,8 @@
97113
98114 static boolean textureon = true;
99115 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
101116 static boolean FULLSCREEN = false;
102117 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
104118 static boolean INERTIA = true;
105119 static boolean FAST = false;
106120 static boolean SLOWPOSE = false;
....@@ -108,6 +122,8 @@
108122
109123 static int tickcount = 0; // slow pose issue
110124
125
+static boolean BUTTONLESSWHEEL = false;
126
+static boolean ZOOMBOXMODE = false;
111127 static boolean BOXMODE = false;
112128 static boolean IMAGEFLIP = false;
113129 static boolean SMOOTHFOCUS = false;
....@@ -122,7 +138,7 @@
122138 static boolean OEIL = true;
123139 static boolean OEILONCE = false; // do oeilon then oeiloff
124140 static boolean LOOKAT = true;
125
-static boolean RANDOM = true; // false;
141
+static boolean SWITCH = true; // false;
126142 static boolean HANDLES = false; // selection doesn't work!!
127143 static boolean PAINTMODE = false;
128144
....@@ -165,12 +181,41 @@
165181 defaultcaps.setAccumBlueBits(16);
166182 defaultcaps.setAccumAlphaBits(16);
167183 }
168
- static CameraPane theRenderer;
169
-
184
+
185
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
186
+
170187 void SetAsGLRenderer(boolean b)
171188 {
172189 isRenderer = b;
173
- theRenderer = this;
190
+ Globals.theRenderer = this;
191
+ }
192
+
193
+ CameraPane(Object3D o, Camera cam, boolean withcontext)
194
+ {
195
+ super(defaultcaps, null, withcontext?glcontext:null, null);
196
+
197
+ //System.out.println("AMERICA AREA = " + (9458886 + 9210755 + 8480395 + 2736391 + 1943018 + 1289475 + 1141569 + 1069350 + 911559 + 721229 + 395886 + 377972 + 246700 + 211156 + 173985 + 141133 + 118279 + 112079 + 108523));
198
+ glcontext = getContext();
199
+
200
+ cameras = new Camera[2];
201
+ targetLookAts = new cVector[2];
202
+
203
+ SetCamera(cam);
204
+
205
+ SetLight(new Camera(new cVector(10, 10, -20)));
206
+
207
+ object = o;
208
+
209
+ setBackground(Color.white);
210
+
211
+ addKeyListener(this);
212
+ addMouseListener(this);
213
+ addMouseMotionListener(this);
214
+ addMouseWheelListener(this);
215
+ //System.out.println("addGLEventListener: " + this);
216
+ addGLEventListener(this);
217
+
218
+// pingthread.start(); // may 2013
174219 }
175220
176221 static boolean AntialiasingEnabled()
....@@ -178,12 +223,53 @@
178223 return CURRENTANTIALIAS > 0;
179224 }
180225
181
- void ClearDepth()
226
+ /// INTERFACE
227
+
228
+ public javax.media.opengl.GL GetGL0()
229
+ {
230
+ return null;
231
+ }
232
+
233
+ public int GenList()
234
+ {
235
+ javax.media.opengl.GL gl = GetGL();
236
+ return gl.glGenLists(1);
237
+ }
238
+
239
+ public void NewList(int id)
240
+ {
241
+ javax.media.opengl.GL gl = GetGL();
242
+ gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE);
243
+ }
244
+
245
+ public void CallList(int id)
246
+ {
247
+ javax.media.opengl.GL gl = GetGL();
248
+ gl.glCallList(id);
249
+ }
250
+
251
+ public void EndList()
252
+ {
253
+ javax.media.opengl.GL gl = GetGL();
254
+ gl.glEndList();
255
+ }
256
+
257
+ public boolean IsBoxMode()
258
+ {
259
+ return BOXMODE;
260
+ }
261
+
262
+ public boolean IsZoomBoxMode()
263
+ {
264
+ return ZOOMBOXMODE;
265
+ }
266
+
267
+ public void ClearDepth()
182268 {
183269 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
184270 }
185271
186
- void DepthTest(boolean depthtest)
272
+ public void DepthTest(boolean depthtest)
187273 {
188274 if (depthtest)
189275 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -191,7 +277,7 @@
191277 GetGL().glDepthFunc(GL.GL_ALWAYS);
192278 }
193279
194
- void DepthWrite(boolean depthwrite)
280
+ public void DepthWrite(boolean depthwrite)
195281 {
196282 if (depthwrite)
197283 GetGL().glDepthMask(true);
....@@ -199,12 +285,1616 @@
199285 GetGL().glDepthMask(false);
200286 }
201287
202
- void BackFaceCull(boolean bfc)
288
+ public void BackFaceCull(boolean bfc)
203289 {
204290 if (bfc)
205291 GetGL().glEnable(GetGL().GL_CULL_FACE);
206292 else
207293 GetGL().glDisable(GetGL().GL_CULL_FACE);
294
+ }
295
+
296
+ public boolean BackFaceCullMode()
297
+ {
298
+ return this.CULLFACE;
299
+ }
300
+
301
+ public boolean IsAmbientOcclusionOn()
302
+ {
303
+ return this.ambientOcclusion;
304
+ }
305
+
306
+ public boolean IsDebugSelection()
307
+ {
308
+ return DEBUG_SELECTION;
309
+ }
310
+
311
+ public boolean IsFrozen()
312
+ {
313
+ boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
314
+
315
+ return !selectmode && cameracount == 0; // != 0;
316
+ }
317
+
318
+ // Currently in Globals
319
+ public int DrawMode()
320
+ {
321
+ return Globals.DrawMode();
322
+ }
323
+
324
+ public Camera EyeCamera()
325
+ {
326
+ return eyeCamera;
327
+ }
328
+
329
+ public Camera LightCamera()
330
+ {
331
+ return lightCamera;
332
+ }
333
+
334
+ public Camera ManipCamera()
335
+ {
336
+ return manipCamera;
337
+ }
338
+
339
+ public Camera RenderCamera()
340
+ {
341
+ return renderCamera;
342
+ }
343
+
344
+ public Camera[] Cameras()
345
+ {
346
+ return cameras;
347
+ }
348
+
349
+ public void PushMaterial(Object3D obj, boolean selected)
350
+ {
351
+ CameraPane display = this;
352
+ javax.media.opengl.GL gl = display.GetGL();
353
+ cMaterial material = obj.material;
354
+
355
+ if (material != null)
356
+ {
357
+ materialstack[materialdepth] = material;
358
+ selectedstack[materialdepth] = selected;
359
+ cStatic.objectstack[materialdepth++] = obj;
360
+ //System.out.println("material " + material);
361
+ //Applet3D.tracein(this, selected);
362
+ //display.vector2buffer = obj.projectedVertices;
363
+ if (obj instanceof Camera)
364
+ {
365
+ display.options1[0] = material.shift;
366
+ //System.out.println("shift " + material.shift);
367
+ display.options1[1] = material.lightarea;
368
+ display.options1[2] = material.shadowbias;
369
+ display.options1[3] = material.aniso;
370
+ display.options1[4] = material.anisoV;
371
+// System.out.println("display.options1[0] " + display.options1[0]);
372
+// System.out.println("display.options1[1] " + display.options1[1]);
373
+// System.out.println("display.options1[2] " + display.options1[2]);
374
+// System.out.println("display.options1[3] " + display.options1[3]);
375
+// System.out.println("display.options1[4] " + display.options1[4]);
376
+ display.options2[0] = material.opacity;
377
+ display.options2[1] = material.diffuse;
378
+ display.options2[2] = material.factor;
379
+// System.out.println("display.options2[0] " + display.options2[0]);
380
+// System.out.println("display.options2[1] " + display.options2[1]);
381
+// System.out.println("display.options2[2] " + display.options2[2]);
382
+
383
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
384
+// System.out.println("display.options3[0] " + display.options3[0]);
385
+// System.out.println("display.options3[1] " + display.options3[1]);
386
+// System.out.println("display.options3[2] " + display.options3[2]);
387
+ display.options4[0] = material.cameralight/0.2f;
388
+ display.options4[1] = material.subsurface;
389
+ display.options4[2] = material.sheen;
390
+// System.out.println("display.options4[0] " + display.options4[0]);
391
+// System.out.println("display.options4[1] " + display.options4[1]);
392
+// System.out.println("display.options4[2] " + display.options4[2]);
393
+
394
+ // if (display.CURRENTANTIALIAS > 0)
395
+ // display.options3[3] /= 4;
396
+
397
+ /*
398
+ System.out.println("Focus = " + display.options1[0]);
399
+ System.out.println("Aperture = " + display.options1[1]);
400
+ System.out.println("ShadowBlur = " + display.options1[2]);
401
+ System.out.println("Antialiasing = " + display.options1[3]);
402
+ System.out.println("Fog = " + display.options2[0]);
403
+ System.out.println("Intensity = " + display.options2[1]);
404
+ System.out.println("Elevation = " + display.options2[2]);
405
+ /**/
406
+ } else
407
+ {
408
+ DrawMaterial(material, selected, obj.projectedVertices);
409
+ }
410
+ } else
411
+ {
412
+ if (selected && CameraPane.flash)
413
+ {
414
+ display.modelParams4[1] = 100;
415
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
416
+ }
417
+ }
418
+ }
419
+
420
+ public void PushMaterial2(Object3D obj, boolean selected)
421
+ {
422
+ CameraPane display = this;
423
+ cMaterial material = obj.material;
424
+
425
+ if (material != null)
426
+ {
427
+ materialstack[materialdepth] = material;
428
+ selectedstack[materialdepth] = selected;
429
+ cStatic.objectstack[materialdepth++] = obj;
430
+ //System.out.println("material " + material);
431
+ //Applet3D.tracein("selected ", selected);
432
+ //display.vector2buffer = obj.projectedVertices;
433
+ display.DrawMaterial(material, selected, obj.projectedVertices);
434
+ }
435
+ }
436
+
437
+ public void PopMaterial(Object3D obj, boolean selected)
438
+ {
439
+ CameraPane display = this;
440
+ javax.media.opengl.GL gl = display.GetGL();
441
+ cMaterial material = obj.material;
442
+
443
+ //if (parent != null && parent.GetMaterial() != null)
444
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
445
+ if (material != null)
446
+ {
447
+ materialdepth -= 1;
448
+ if (materialdepth > 0)
449
+ {
450
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
451
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
452
+ }
453
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
454
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
455
+ {
456
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
457
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
458
+ }
459
+ }
460
+
461
+ public void PopMaterial2(Object3D obj)
462
+ {
463
+ CameraPane display = this;
464
+ cMaterial material = obj.material;
465
+
466
+ if (material != null)
467
+ {
468
+ materialdepth -= 1;
469
+ if (materialdepth > 0)
470
+ {
471
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
472
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
473
+ }
474
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
475
+ //else
476
+ //material.Draw(display, false);
477
+ }
478
+ }
479
+
480
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
481
+ {
482
+ CameraPane display = this;
483
+
484
+ if (pv.y == -10000 ||
485
+ qv.y == -10000 ||
486
+ rv.y == -10000)
487
+ return;
488
+
489
+// float b = f.nbiterations & 1;
490
+// float g = (f.nbiterations>>1) & 1;
491
+// float r = (f.nbiterations>>2) & 1;
492
+//
493
+// //if (f.weight == 10000)
494
+// //{
495
+// // r = 1; g = b = 0;
496
+// //}
497
+// //else
498
+// //{
499
+// // assert(f.weight < 10000);
500
+// r = g = b = (float)bRep.FaceWeight(f)*100;
501
+// if (r<0)
502
+// assert(r>=0);
503
+// //}
504
+
505
+ javax.media.opengl.GL gl = display.GetGL();
506
+
507
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
508
+
509
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
510
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
511
+ {
512
+ //gl.glBegin(gl.GL_TRIANGLES);
513
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
514
+ // TEST LIVE NORMALS && !obj.dontselect
515
+ ;
516
+ if (!hasnorm)
517
+ {
518
+ // System.out.println("Mesh normal");
519
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
520
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
521
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
522
+ LA.vecNormalize(obj.v2);
523
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
524
+ }
525
+
526
+ // P
527
+ float x = (float)pv.x;
528
+ float y = (float)pv.y;
529
+ float z = (float)pv.z;
530
+
531
+ if (hasnorm)
532
+ {
533
+// if (!pv.norm.normalized())
534
+// assert(pv.norm.normalized());
535
+
536
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
537
+ float nx = (float)pv.norm.x;
538
+ float ny = (float)pv.norm.y;
539
+ float nz = (float)pv.norm.z;
540
+
541
+ x += nx * obj.NORMALPUSH;
542
+ y += ny * obj.NORMALPUSH;
543
+ z += nz * obj.NORMALPUSH;
544
+
545
+ gl.glNormal3f(nx, ny, nz);
546
+ }
547
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
548
+ SetColor(obj, pv);
549
+ //gl.glColor4f(r, g, b, 1);
550
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
551
+ if (obj.flipV)
552
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
553
+ else
554
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
555
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
556
+
557
+ gl.glVertex3f(x, y, z);
558
+
559
+ // Q
560
+ x = (float)qv.x;
561
+ y = (float)qv.y;
562
+ z = (float)qv.z;
563
+
564
+// Print(pv);
565
+ if (hasnorm)
566
+ {
567
+// assert(qv.norm.normalized());
568
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
569
+ float nx = (float)qv.norm.x;
570
+ float ny = (float)qv.norm.y;
571
+ float nz = (float)qv.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
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
580
+ // boolean locked = false;
581
+ // float eps = 0.1f;
582
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
583
+
584
+ // int dot = 0; //*/ (int)f.dot;
585
+
586
+ // if ((dot&1) == 0)
587
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
588
+
589
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
590
+ if (obj.flipV)
591
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
592
+ else
593
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
594
+ // else
595
+ // {
596
+ // locked = true;
597
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
598
+ // }
599
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
600
+ SetColor(obj, qv);
601
+
602
+ gl.glVertex3f(x, y, z);
603
+ //gl.glColor4f(r, g, b, 1);
604
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
605
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
606
+// Print(qv);
607
+
608
+ // R
609
+ x = (float)rv.x;
610
+ y = (float)rv.y;
611
+ z = (float)rv.z;
612
+
613
+ if (hasnorm)
614
+ {
615
+// assert(rv.norm.normalized());
616
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
617
+ float nx = (float)rv.norm.x;
618
+ float ny = (float)rv.norm.y;
619
+ float nz = (float)rv.norm.z;
620
+
621
+ x += nx * obj.NORMALPUSH;
622
+ y += ny * obj.NORMALPUSH;
623
+ z += nz * obj.NORMALPUSH;
624
+
625
+ gl.glNormal3f(nx, ny, nz);
626
+ }
627
+
628
+ // if ((dot&4) == 0)
629
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
630
+
631
+ // if (wrap || !locked && (dot&8) != 0)
632
+ if (obj.flipV)
633
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
634
+ else
635
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
636
+ // else
637
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
638
+
639
+ // f.dot = dot;
640
+
641
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
642
+ SetColor(obj, rv);
643
+ //gl.glColor4f(r, g, b, 1);
644
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
645
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
646
+ gl.glVertex3f(x, y, z);
647
+// Print(rv);
648
+ //gl.glEnd();
649
+ }
650
+ else
651
+ {
652
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
653
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
654
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
655
+
656
+ }
657
+
658
+ if (false) // (attributes & WIREFRAME) != 0)
659
+ {
660
+ gl.glDisable(gl.GL_LIGHTING);
661
+
662
+ gl.glBegin(gl.GL_LINE_LOOP);
663
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
664
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
665
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
666
+ gl.glEnd();
667
+
668
+ gl.glEnable(gl.GL_LIGHTING);
669
+ }
670
+ }
671
+
672
+ /**
673
+ * <code>draw</code> renders a <code>TriMesh</code> object including
674
+ * it's normals, colors, textures and vertices.
675
+ *
676
+ * @see Renderer#draw(TriMesh)
677
+ * @param tris
678
+ * the mesh to render.
679
+ */
680
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
681
+ {
682
+ CameraPane display = this;
683
+
684
+ float r = display.modelParams0[0];
685
+ float g = display.modelParams0[1];
686
+ float b = display.modelParams0[2];
687
+ float opacity = display.modelParams5[1];
688
+
689
+ //final GL gl = GLU.getCurrentGL();
690
+ GL gl = display.GetGL(); // getGL();
691
+
692
+ FloatBuffer vertBuf = geo.vertBuf;
693
+
694
+ int v = vertBuf.capacity();
695
+
696
+ int count = 0;
697
+
698
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
699
+ gl.glEnable(gl.GL_CULL_FACE);
700
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
701
+ for (int i=0; i<v/3; i++)
702
+ {
703
+ int index3 = i*3;
704
+
705
+ if (geo.sizeBuf.get(index3+1) == 0)
706
+ continue;
707
+
708
+ count++;
709
+
710
+ int index4 = i*4;
711
+
712
+ float tx = vertBuf.get(index3);
713
+ float ty = vertBuf.get(index3+1);
714
+ float tz = vertBuf.get(index3+2);
715
+
716
+ // if (tx == 0 && ty == 0 && tz == 0)
717
+ // continue;
718
+
719
+ gl.glMatrixMode(gl.GL_TEXTURE);
720
+ gl.glPushMatrix();
721
+
722
+ float[] texmat = geo.texmat;
723
+ texmat[12] = texmat[13] = texmat[14] = i;
724
+
725
+ gl.glMultMatrixf(texmat, 0);
726
+
727
+ gl.glMatrixMode(gl.GL_MODELVIEW);
728
+ gl.glPushMatrix();
729
+
730
+ gl.glTranslatef(tx,ty,tz);
731
+
732
+ if (rotate)
733
+ gl.glRotatef(i, 0, 1, 0);
734
+
735
+ float size = geo.sizeBuf.get(index3) / 100;
736
+ gl.glScalef(size,size,size);
737
+
738
+ float cr = geo.colorBuf.get(index4);
739
+ float cg = geo.colorBuf.get(index4+1);
740
+ float cb = geo.colorBuf.get(index4+2);
741
+ float ca = geo.colorBuf.get(index4+3);
742
+
743
+ display.modelParams0[0] = r * cr;
744
+ display.modelParams0[1] = g * cg;
745
+ display.modelParams0[2] = b * cb;
746
+
747
+ display.modelParams5[1] = opacity * ca;
748
+
749
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
750
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
751
+
752
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
753
+ RandomNode.globalseed2 = RandomNode.globalseed;
754
+
755
+// gl.glColor4f(cr,cg,cb,ca);
756
+ // gl.glScalef(1024/16,1024/16,1024/16);
757
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
758
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
759
+ //gl.glTranslatef(-tx,-ty,-tz);
760
+ gl.glPopMatrix();
761
+
762
+ gl.glMatrixMode(gl.GL_TEXTURE);
763
+ gl.glPopMatrix();
764
+ }
765
+ // gl.glScalef(1024,1024,1024);
766
+ if (!cf)
767
+ gl.glDisable(gl.GL_CULL_FACE);
768
+
769
+ display.modelParams0[0] = r;
770
+ display.modelParams0[1] = g;
771
+ display.modelParams0[2] = b;
772
+
773
+ display.modelParams5[1] = opacity;
774
+
775
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
776
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
777
+
778
+ gl.glMatrixMode(gl.GL_MODELVIEW);
779
+
780
+// System.err.println("total = " + v/3 + "; displayed = " + count);
781
+ if (true)
782
+ return;
783
+
784
+//// if (!tris.predraw(this))
785
+//// {
786
+//// return;
787
+//// }
788
+//// if (Debug.stats)
789
+//// {
790
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
791
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
792
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
793
+//// }
794
+////
795
+//// if (tris.getDisplayListID() != -1)
796
+//// {
797
+//// renderDisplayList(tris);
798
+//// return;
799
+//// }
800
+////
801
+//// if (!generatingDisplayList)
802
+//// {
803
+//// applyStates(tris.states, tris);
804
+//// }
805
+//// if (Debug.stats)
806
+//// {
807
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
808
+//// }
809
+//// boolean transformed = doTransforms(tris);
810
+//
811
+// int glMode = GL.GL_TRIANGLES;
812
+// switch (getMode())
813
+// {
814
+// case Triangles:
815
+// glMode = GL.GL_TRIANGLES;
816
+// break;
817
+// case Strip:
818
+// glMode = GL.GL_TRIANGLE_STRIP;
819
+// break;
820
+// case Fan:
821
+// glMode = GL.GL_TRIANGLE_FAN;
822
+// break;
823
+// }
824
+//
825
+// if (!predrawGeometry(gl))
826
+// {
827
+// // make sure only the necessary indices are sent through on old
828
+// // cards.
829
+// IntBuffer indices = this.getIndexBuffer();
830
+// if (indices == null)
831
+// {
832
+// logger.severe("missing indices on geometry object: " + this.toString());
833
+// } else
834
+// {
835
+// indices.rewind();
836
+// indices.limit(this.getMaxIndex());
837
+//
838
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
839
+//
840
+// indices.clear();
841
+// }
842
+// } else
843
+// {
844
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
845
+// GL.GL_UNSIGNED_INT, 0);
846
+// }
847
+//
848
+//// postdrawGeometry(tris);
849
+//// if (transformed)
850
+//// {
851
+//// undoTransforms(tris);
852
+//// }
853
+////
854
+//// if (Debug.stats)
855
+//// {
856
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
857
+//// }
858
+//// tris.postdraw(this);
859
+ }
860
+
861
+ static Camera localcamera = new Camera();
862
+ static cVector from = new cVector();
863
+ static cVector to = new cVector();
864
+
865
+ public void PrepOcclusion(BoundaryRep br, double[][] transform)
866
+ {
867
+ CameraPane cp = this;
868
+
869
+ Camera keep = cp.RenderCamera();
870
+ cp.renderCamera = localcamera;
871
+
872
+ if (br.trimmed)
873
+ {
874
+ float[] colors = new float[br.positions.length / 3];
875
+
876
+ int i3 = 0;
877
+ for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
878
+ {
879
+ if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
880
+ continue;
881
+
882
+ from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
883
+ to.set(br.positions[i3] + br.normals[i3],
884
+ br.positions[i3 + 1] + br.normals[i3 + 1],
885
+ br.positions[i3 + 2] + br.normals[i3 + 2]);
886
+ LA.xformPos(from, transform, from);
887
+ LA.xformPos(to, transform, to); // RIGID ONLY
888
+ localcamera.setAim(from, to);
889
+
890
+ CameraPane.occlusionbuffer.display();
891
+
892
+ if (CameraPane.DEBUG_OCCLUSION)
893
+ cp.display(); // debug
894
+
895
+ colors[i] = cp.vertexOcclusion.r;
896
+ //colors[i3 + 1] = cp.vertexOcclusion.g;
897
+ //colors[i3 + 2] = cp.vertexOcclusion.b;
898
+
899
+ if ((i % 100) == 0 && i != 0)
900
+ {
901
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
902
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
903
+ System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
904
+ }
905
+ }
906
+
907
+ br.colors = colors;
908
+ }
909
+ else
910
+ {
911
+ for (int i = 0; i < br.VertexCount(); i++)
912
+ {
913
+ Vertex v = br.GetVertex(i);
914
+
915
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
916
+ continue;
917
+
918
+ from.set(v.x, v.y, v.z);
919
+ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
920
+ LA.xformPos(from, transform, from);
921
+ LA.xformPos(to, transform, to); // RIGID ONLY
922
+ localcamera.setAim(from, to);
923
+
924
+ CameraPane.occlusionbuffer.display();
925
+
926
+ if (CameraPane.DEBUG_OCCLUSION)
927
+ cp.display(); // debug
928
+
929
+ v.AO = cp.vertexOcclusion.r;
930
+
931
+ if ((i % 100) == 0 && i != 0)
932
+ {
933
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
934
+ //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
935
+ System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
936
+ }
937
+ }
938
+ }
939
+
940
+ //System.out.println("done.");
941
+
942
+ cp.renderCamera = keep;
943
+ }
944
+
945
+ void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
946
+ {
947
+ CameraPane display = this;
948
+ pointFlow.CreateHT();
949
+
950
+ float r = display.modelParams0[0];
951
+ float g = display.modelParams0[1];
952
+ float b = display.modelParams0[2];
953
+ float opacity = display.modelParams5[1];
954
+
955
+ //final GL gl = GLU.getCurrentGL();
956
+ GL gl = display.GetGL(); // getGL();
957
+
958
+ int s = pointFlow.points.size();
959
+
960
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
961
+ gl.glEnable(gl.GL_CULL_FACE);
962
+
963
+ for (int i=s; --i>=0;)
964
+ //for (int i=0; i<s; i++)
965
+ {
966
+ cVector v = pointFlow.points.get(i);
967
+
968
+ double mindist = Double.MAX_VALUE;
969
+
970
+ double size = pointFlow.minimumSize;
971
+
972
+ double distancenext = 0;
973
+
974
+ if (i > 0)
975
+ {
976
+ cVector w = pointFlow.points.get(i-1);
977
+
978
+ double dist = w.distance(v);
979
+
980
+ distancenext = dist;
981
+
982
+ if (mindist > dist)
983
+ {
984
+ mindist = dist;
985
+ size = mindist*pointFlow.resizefactor;
986
+ }
987
+ }
988
+
989
+ if (i < s-1)
990
+ {
991
+ cVector w = pointFlow.points.get(i+1);
992
+
993
+ double dist = w.distance(v);
994
+
995
+ if (mindist > dist)
996
+ {
997
+ mindist = dist;
998
+ size = mindist*pointFlow.resizefactor;
999
+ }
1000
+ }
1001
+
1002
+ if (size < pointFlow.minimumSize)
1003
+ size = pointFlow.minimumSize;
1004
+ if (size > pointFlow.maximumSize)
1005
+ size = pointFlow.maximumSize;
1006
+
1007
+ double tx = v.x;
1008
+ double ty = v.y;
1009
+ double tz = v.z;
1010
+
1011
+ // if (tx == 0 && ty == 0 && tz == 0)
1012
+ // continue;
1013
+
1014
+ gl.glMatrixMode(gl.GL_TEXTURE);
1015
+ gl.glPushMatrix();
1016
+ pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
1017
+
1018
+ gl.glMultMatrixf(pointFlow.texmat, 0);
1019
+
1020
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1021
+ gl.glPushMatrix();
1022
+
1023
+ gl.glTranslated(tx,ty,tz);
1024
+
1025
+ gl.glScaled(size,size,size);
1026
+
1027
+// float cr = colorBuf.get(index4);
1028
+// float cg = colorBuf.get(index4+1);
1029
+// float cb = colorBuf.get(index4+2);
1030
+// float ca = colorBuf.get(index4+3);
1031
+//
1032
+// display.modelParams0[0] = r * cr;
1033
+// display.modelParams0[1] = g * cg;
1034
+// display.modelParams0[2] = b * cb;
1035
+//
1036
+// display.modelParams5[1] = opacity * ca;
1037
+//
1038
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1039
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1040
+//
1041
+// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
1042
+// RandomNode.globalseed2 = RandomNode.globalseed;
1043
+//
1044
+//// gl.glColor4f(cr,cg,cb,ca);
1045
+// // gl.glScalef(1024/16,1024/16,1024/16);
1046
+ pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
1047
+
1048
+ gl.glPopMatrix();
1049
+
1050
+ double step = size/4; //
1051
+
1052
+ if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
1053
+ continue;
1054
+
1055
+ int nbsteps = (int)(distancenext/step);
1056
+
1057
+ step = distancenext/nbsteps;
1058
+
1059
+ cVector next = pointFlow.points.get(i-1);
1060
+
1061
+ tmp.set(next);
1062
+ tmp.sub(v);
1063
+ tmp.normalize();
1064
+ tmp.mul(step);
1065
+
1066
+ // calculate next size
1067
+ mindist = Double.MAX_VALUE;
1068
+
1069
+ double nextsize = pointFlow.minimumSize;
1070
+
1071
+ if (i > 1)
1072
+ {
1073
+ cVector w = pointFlow.points.get(i-2);
1074
+
1075
+ double dist = w.distance(next);
1076
+
1077
+ if (mindist > dist)
1078
+ {
1079
+ mindist = dist;
1080
+ nextsize = mindist*pointFlow.resizefactor;
1081
+ }
1082
+ }
1083
+
1084
+ double dist = v.distance(next);
1085
+
1086
+ if (mindist > dist)
1087
+ {
1088
+ mindist = dist;
1089
+ nextsize = mindist*pointFlow.resizefactor;
1090
+ }
1091
+
1092
+ if (nextsize < pointFlow.minimumSize)
1093
+ nextsize = pointFlow.minimumSize;
1094
+ if (nextsize > pointFlow.maximumSize)
1095
+ nextsize = pointFlow.maximumSize;
1096
+ //
1097
+
1098
+ double count = 0;
1099
+
1100
+ while (distancenext > 0.000000001) // step
1101
+ {
1102
+ gl.glPushMatrix();
1103
+
1104
+ gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
1105
+
1106
+ double K = count/nbsteps;
1107
+
1108
+ double intersize = K*nextsize + (1-K)*size;
1109
+
1110
+ gl.glScaled(intersize,intersize,intersize);
1111
+
1112
+ pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
1113
+
1114
+ count++;
1115
+
1116
+ distancenext -= step;
1117
+
1118
+ gl.glPopMatrix();
1119
+ }
1120
+
1121
+ if (count != nbsteps)
1122
+ assert(count == nbsteps);
1123
+
1124
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
1125
+ //gl.glTranslatef(-tx,-ty,-tz);
1126
+
1127
+ gl.glMatrixMode(gl.GL_TEXTURE);
1128
+ gl.glPopMatrix();
1129
+ }
1130
+
1131
+ if (!cf)
1132
+ gl.glDisable(gl.GL_CULL_FACE);
1133
+
1134
+// display.modelParams0[0] = r;
1135
+// display.modelParams0[1] = g;
1136
+// display.modelParams0[2] = b;
1137
+//
1138
+// display.modelParams5[1] = opacity;
1139
+//
1140
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1141
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1142
+
1143
+ gl.glMatrixMode(gl.GL_MODELVIEW);
1144
+ }
1145
+
1146
+ public void DrawBox(cVector min, cVector max)
1147
+ {
1148
+ javax.media.opengl.GL gl = GetGL();
1149
+ gl.glBegin(gl.GL_LINES);
1150
+
1151
+ gl.glVertex3d(min.x, min.y, min.z);
1152
+ gl.glVertex3d(min.x, min.y, max.z);
1153
+ gl.glVertex3d(min.x, min.y, min.z);
1154
+ gl.glVertex3d(min.x, max.y, min.z);
1155
+ gl.glVertex3d(min.x, min.y, min.z);
1156
+ gl.glVertex3d(max.x, min.y, min.z);
1157
+
1158
+ gl.glVertex3d(max.x, max.y, max.z);
1159
+ gl.glVertex3d(min.x, max.y, max.z);
1160
+ gl.glVertex3d(max.x, max.y, max.z);
1161
+ gl.glVertex3d(max.x, min.y, max.z);
1162
+ gl.glVertex3d(max.x, max.y, max.z);
1163
+ gl.glVertex3d(max.x, max.y, min.z);
1164
+
1165
+ gl.glEnd();
1166
+ }
1167
+
1168
+ public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode)
1169
+ {
1170
+ int[] strips = bRep.getRawIndices();
1171
+
1172
+ javax.media.opengl.GL gl = GetGL();
1173
+
1174
+ // TRIANGLE STRIP ARRAY
1175
+ if (bRep.trimmed)
1176
+ {
1177
+ float[] v = bRep.getRawVertices();
1178
+ float[] n = bRep.getRawNormals();
1179
+ float[] c = bRep.getRawColors();
1180
+ float[] uv = bRep.getRawUVMap();
1181
+
1182
+ int count2 = 0;
1183
+ int count3 = 0;
1184
+
1185
+ if (n.length > 0)
1186
+ {
1187
+ for (int i = 0; i < strips.length; i++)
1188
+ {
1189
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1190
+
1191
+ /*
1192
+ boolean locked = false;
1193
+ float eps = 0.1f;
1194
+ boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
1195
+
1196
+ int dot = 0;
1197
+
1198
+ if ((dot&1) == 0)
1199
+ dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
1200
+
1201
+ if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
1202
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
1203
+ else
1204
+ {
1205
+ locked = true;
1206
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1207
+ }
1208
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
1209
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
1210
+ if (hasnorm)
1211
+ {
1212
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
1213
+ gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
1214
+ }
1215
+
1216
+ if ((dot&4) == 0)
1217
+ dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
1218
+
1219
+ if (wrap || !locked && (dot&8) != 0)
1220
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
1221
+ else
1222
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1223
+
1224
+ f.dot = dot;
1225
+ */
1226
+
1227
+ if (!selectmode)
1228
+ {
1229
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1230
+ {
1231
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1232
+ } else
1233
+ {
1234
+ gl.glNormal3f(0, 0, 1);
1235
+ }
1236
+
1237
+ if (c != null)
1238
+ //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
1239
+ {
1240
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1241
+ }
1242
+ }
1243
+
1244
+ if (flipV)
1245
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1246
+ else
1247
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1248
+
1249
+ //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1250
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1251
+
1252
+ count2 += 2;
1253
+ count3 += 3;
1254
+ if (!selectmode)
1255
+ {
1256
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1257
+ {
1258
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1259
+ } else
1260
+ {
1261
+ gl.glNormal3f(0, 0, 1);
1262
+ }
1263
+ if (c != null)
1264
+ {
1265
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1266
+ }
1267
+ }
1268
+
1269
+ if (flipV)
1270
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1271
+ else
1272
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1273
+
1274
+ //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
1275
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1276
+
1277
+ count2 += 2;
1278
+ count3 += 3;
1279
+ for (int j = 0; j < strips[i] - 2; j++)
1280
+ {
1281
+ //gl.glTexCoord2d(...);
1282
+ if (!selectmode)
1283
+ {
1284
+ if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
1285
+ {
1286
+ gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1287
+ } else
1288
+ {
1289
+ gl.glNormal3f(0, 0, 1);
1290
+ }
1291
+ if (c != null)
1292
+ {
1293
+ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
1294
+ }
1295
+ }
1296
+
1297
+ if (flipV)
1298
+ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
1299
+ else
1300
+ gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1301
+
1302
+ //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
1303
+ gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1304
+
1305
+ count2 += 2;
1306
+ count3 += 3;
1307
+ }
1308
+
1309
+ gl.glEnd();
1310
+ }
1311
+ }
1312
+
1313
+ assert count3 == v.length;
1314
+ }
1315
+ else // !trimmed
1316
+ {
1317
+ int count = 0;
1318
+ for (int i = 0; i < strips.length; i++)
1319
+ {
1320
+ gl.glBegin(gl.GL_TRIANGLE_STRIP);
1321
+
1322
+ Vertex p = bRep.GetVertex(bRep.indices[count++]);
1323
+ Vertex q = bRep.GetVertex(bRep.indices[count++]);
1324
+
1325
+ drawVertex(gl, p, flipV, selectmode);
1326
+ drawVertex(gl, q, flipV, selectmode);
1327
+
1328
+ for (int j = 0; j < strips[i] - 2; j++)
1329
+ {
1330
+ Vertex r = bRep.GetVertex(bRep.indices[count++]);
1331
+
1332
+ // if (j%2 == 0)
1333
+ // drawFace(p, q, r, display, null);
1334
+ // else
1335
+ // drawFace(p, r, q, display, null);
1336
+
1337
+ // p = q;
1338
+ // q = r;
1339
+ drawVertex(gl, r, flipV, selectmode);
1340
+ }
1341
+
1342
+ gl.glEnd();
1343
+ }
1344
+ }
1345
+ }
1346
+
1347
+ static cSpring.Point3D temp = new cSpring.Point3D();
1348
+ static cSpring.Point3D temp2 = new cSpring.Point3D();
1349
+ static cSpring.Point3D temp3 = new cSpring.Point3D();
1350
+
1351
+ public void DrawDynamicMesh(cMesh mesh)
1352
+ {
1353
+ GL gl = GetGL(); // getGL();
1354
+
1355
+ cSpring.PhysicsController3D Phys = mesh.Phys;
1356
+
1357
+ gl.glDisable(gl.GL_LIGHTING);
1358
+
1359
+ gl.glLineWidth(1);
1360
+ gl.glColor3f(1,1,1);
1361
+ gl.glBegin(gl.GL_LINES);
1362
+ double scale = 0;
1363
+ int count = 0;
1364
+ for (int s=0; s<Phys.allSprings.size(); s++)
1365
+ {
1366
+ cSpring.Spring spring = Phys.allSprings.get(s);
1367
+ if(s == 0)
1368
+ {
1369
+ //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
1370
+ }
1371
+ if (mesh.showsprings)
1372
+ {
1373
+ temp.set(spring.a.position);
1374
+ temp.add(spring.b.position);
1375
+ temp.mul(0.5);
1376
+ temp2.set(spring.a.position);
1377
+ temp2.sub(spring.b.position);
1378
+ temp2.mul(spring.restLength/2);
1379
+ temp.sub(temp2);
1380
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1381
+ temp.add(temp2);
1382
+ temp.add(temp2);
1383
+ gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
1384
+ }
1385
+
1386
+ if (spring.isHandle)
1387
+ continue;
1388
+
1389
+ //if (scale < spring.restLength)
1390
+ scale += spring.restLength;
1391
+ count++;
1392
+ }
1393
+ gl.glEnd();
1394
+
1395
+ if (count == 0)
1396
+ scale = 0.01;
1397
+ else
1398
+ scale /= count * 3;
1399
+
1400
+ //scale = 0.25;
1401
+
1402
+ if (mesh.ShowInfo())
1403
+ {
1404
+ gl.glLineWidth(4);
1405
+ for (int s=0; s<Phys.allNodes.size(); s++)
1406
+ {
1407
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1408
+ if (node.mass == 0)
1409
+ continue;
1410
+
1411
+ int i = node.springs==null?-1:node.springs.size();
1412
+ gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
1413
+ //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
1414
+ //temp.normalize();
1415
+ //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
1416
+ gl.glBegin(gl.GL_LINES);
1417
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1418
+ //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
1419
+ gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale,
1420
+ node.position.y + mesh.bRep.GetVertex(s).norm.y*scale,
1421
+ node.position.z + mesh.bRep.GetVertex(s).norm.z*scale);
1422
+ gl.glEnd();
1423
+ }
1424
+
1425
+ gl.glLineWidth(8);
1426
+ for (int s=0; s<Phys.allNodes.size(); s++)
1427
+ {
1428
+ cSpring.DynamicNode node = Phys.allNodes.get(s);
1429
+
1430
+ if (node.springs != null)
1431
+ {
1432
+ for (int i=0; i<node.springs.size(); i+=1)
1433
+ {
1434
+ cSpring.DynamicNode f = node.springs.get(i).GetOther(node);
1435
+
1436
+ int c = i+1;
1437
+ // c = node.springs.get(i).nbcopies;
1438
+
1439
+ gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
1440
+ gl.glBegin(gl.GL_LINES);
1441
+ gl.glVertex3d(node.position.x, node.position.y, node.position.z);
1442
+ 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);
1443
+ gl.glEnd();
1444
+ }
1445
+ }
1446
+ }
1447
+
1448
+ gl.glLineWidth(1);
1449
+ }
1450
+
1451
+ gl.glEnable(gl.GL_LIGHTING);
1452
+ }
1453
+
1454
+ /// INTERFACE
1455
+
1456
+ public void StartTriangles()
1457
+ {
1458
+ javax.media.opengl.GL gl = GetGL();
1459
+ gl.glBegin(gl.GL_TRIANGLES);
1460
+ }
1461
+
1462
+ public void EndTriangles()
1463
+ {
1464
+ GetGL().glEnd();
1465
+ }
1466
+
1467
+ void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode)
1468
+ {
1469
+ if (!selectmode)
1470
+ {
1471
+ gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1472
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
1473
+
1474
+ if (flipV)
1475
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
1476
+ else
1477
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
1478
+ }
1479
+
1480
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
1481
+ }
1482
+
1483
+ void SetColor(Object3D obj, Vertex p0)
1484
+ {
1485
+ CameraPane display = this;
1486
+ BoundaryRep bRep = obj.bRep;
1487
+
1488
+ if (RENDERPROGRAM == 0)
1489
+ {
1490
+ float r = 0;
1491
+ if (bRep != null)
1492
+ {
1493
+ if (bRep.stripified)
1494
+ {
1495
+ r = 1;
1496
+ }
1497
+ }
1498
+ float g = 0;
1499
+ if (bRep != null)
1500
+ {
1501
+ if (bRep.trimmed)
1502
+ {
1503
+ g = 1;
1504
+ }
1505
+ }
1506
+ float b = 0;
1507
+ if (obj.support != null && obj.link2master)
1508
+ {
1509
+ b = 1;
1510
+ }
1511
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
1512
+ return;
1513
+ }
1514
+
1515
+ if (display.DrawMode() != CameraPane.SHADOW)
1516
+ return;
1517
+
1518
+ javax.media.opengl.GL gl = display.GetGL();
1519
+// if (true) return;
1520
+// float ao = p.AO;
1521
+//
1522
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
1523
+// // ao = 1;
1524
+//
1525
+// gl.glColor4f(ao, ao, ao, 1);
1526
+
1527
+// CameraPane.selectedpoint.
1528
+// getAverage(cStatic.point1, true);
1529
+ if (CameraPane.pointflow == null) // !random) // live)
1530
+ {
1531
+ return;
1532
+ }
1533
+
1534
+ cStatic.point1.set(0,0,0);
1535
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
1536
+
1537
+ cStatic.point1.sub(p0);
1538
+
1539
+
1540
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
1541
+// {
1542
+// return;
1543
+// }
1544
+
1545
+ //if (true)
1546
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
1547
+ {
1548
+ return;
1549
+ }
1550
+
1551
+ float[] colorV = new float[3];
1552
+
1553
+ if (false) // marked)
1554
+ {
1555
+ // debug rigging weights
1556
+ for (int object = 0; object < p0.vertexlinks.length; object++)
1557
+ {
1558
+ float weight = p0.weights[object] / p0.totalweight;
1559
+
1560
+ // if (weight < 0.1)
1561
+ // {
1562
+ // assert(weight == 0);
1563
+ // continue;
1564
+ // }
1565
+
1566
+ if (p0.vertexlinks[object] == -1)
1567
+ continue;
1568
+
1569
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
1570
+
1571
+ int color = //1 << object; //
1572
+ //p.vertexlinks.length;
1573
+ obj.support.bRep.supports[p0.closestsupport].links[object];
1574
+ colorV[2] += (color & 1) * weight;
1575
+ colorV[1] += ((color & 2) >> 1) * weight;
1576
+ colorV[0] += ((color & 4) >> 2) * weight;
1577
+ }
1578
+ }
1579
+ else
1580
+ {
1581
+ if (obj.drawingstarted)
1582
+ {
1583
+ // find next point
1584
+ if (bRep.GetVertex(0).faceindices == null)
1585
+ {
1586
+ bRep.InitFaceIndices();
1587
+ }
1588
+
1589
+ double ymin = p0.y;
1590
+
1591
+ Vertex newp = p0;
1592
+
1593
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
1594
+ {
1595
+ int fi = p0.faceindices[fii];
1596
+
1597
+ if (fi == -1)
1598
+ break;
1599
+
1600
+ Face f = bRep.GetFace(fi);
1601
+
1602
+ Vertex p = bRep.GetVertex(f.p);
1603
+ Vertex q = bRep.GetVertex(f.q);
1604
+ Vertex r = bRep.GetVertex(f.r);
1605
+
1606
+ int swap = (int)(Math.random()*3);
1607
+
1608
+// for (int s=swap; --s>=0;)
1609
+// {
1610
+// Vertex t = p;
1611
+// p = q;
1612
+// q = r;
1613
+// r = t;
1614
+// }
1615
+ if (ymin > p.y)
1616
+ {
1617
+ ymin = p.y;
1618
+ newp = p;
1619
+// break;
1620
+ }
1621
+ if (ymin > q.y)
1622
+ {
1623
+ ymin = q.y;
1624
+ newp = q;
1625
+// break;
1626
+ }
1627
+ if (ymin > r.y)
1628
+ {
1629
+ ymin = r.y;
1630
+ newp = r;
1631
+// break;
1632
+ }
1633
+ }
1634
+
1635
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
1636
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
1637
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
1638
+
1639
+ obj.drawingstarted = false;
1640
+
1641
+ // return;
1642
+ }
1643
+
1644
+ if (false) // CameraPane.DRAW
1645
+ {
1646
+ p0.AO = colorV[0] = 2;
1647
+ colorV[1] = 2;
1648
+ colorV[2] = 2;
1649
+ }
1650
+
1651
+ CameraPane.pointflow.add(p0);
1652
+ CameraPane.pointflow.Touch();
1653
+ }
1654
+
1655
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
1656
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1657
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1658
+ }
1659
+
1660
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
1661
+ {
1662
+ CameraPane display = this;
1663
+ //new Exception().printStackTrace();
1664
+
1665
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
1666
+ {
1667
+ return;
1668
+ }
1669
+
1670
+ javax.media.opengl.GL gl = display.GetGL();
1671
+
1672
+ //Color col = Color.getHSBColor(color,modulation,1);
1673
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
1674
+ if (!material.multiply)
1675
+ {
1676
+ display.color = material.color;
1677
+ display.saturation = material.modulation;
1678
+ }
1679
+ else
1680
+ {
1681
+ display.color *= material.color*2;
1682
+ display.saturation *= material.modulation*2;
1683
+ }
1684
+
1685
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
1686
+
1687
+ float[] colorV = Grafreed.colorV;
1688
+
1689
+ /**/
1690
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
1691
+ {
1692
+ colorV[0] = display.modelParams0[0] * material.diffuse;
1693
+ colorV[1] = display.modelParams0[1] * material.diffuse;
1694
+ colorV[2] = display.modelParams0[2] * material.diffuse;
1695
+ colorV[3] = 1; // material.opacity;
1696
+
1697
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
1698
+ //System.out.println("Opacity = " + opacity);
1699
+
1700
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
1701
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1702
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
1703
+
1704
+ float amb = material.ambient;
1705
+ if (amb < material.cameralight)
1706
+ {
1707
+ amb = material.cameralight;
1708
+ }
1709
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
1710
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
1711
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
1712
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
1713
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1714
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
1715
+
1716
+ /**/
1717
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
1718
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
1719
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
1720
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
1721
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
1722
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
1723
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
1724
+ //System.out.println("shininess = " + colorV[0]);
1725
+ if (colorV[0] > 128)
1726
+ {
1727
+ colorV[0] = 128;
1728
+ }
1729
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
1730
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
1731
+ /**/
1732
+ }
1733
+ /**/
1734
+
1735
+ //selected = false;
1736
+ selected = selected && display.flash;
1737
+
1738
+ //display.modelParams0[0] = 0; // pigment.r;
1739
+ //display.modelParams0[1] = 0; // pigment.g;
1740
+ //display.modelParams0[2] = 0; // pigment.b;
1741
+ if (!material.multiply)
1742
+ {
1743
+ display.modelParams0[3] = material.metalness;
1744
+ display.modelParams1[0] = material.diffuse;
1745
+ display.modelParams1[1] = material.specular;
1746
+ display.modelParams1[2] = 1 / material.shininess;
1747
+ display.modelParams1[3] = material.shift;
1748
+ display.modelParams2[0] = material.ambient;
1749
+ display.modelParams2[1] = material.lightarea;
1750
+ //System.out.println("light area = " + lightarea);
1751
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
1752
+ display.modelParams2[3] = material.velvet;
1753
+ display.modelParams3[0] = material.sheen;
1754
+ display.modelParams3[1] = material.subsurface;
1755
+ display.modelParams3[2] = material.bump; // backlit
1756
+ display.modelParams3[3] = material.aniso;
1757
+ display.modelParams4[0] = material.anisoV;
1758
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
1759
+ //System.out.println("selected = " + selected);
1760
+ display.modelParams4[2] = material.diffuseness;
1761
+ display.modelParams4[3] = material.shadow;
1762
+ display.modelParams5[0] = material.texture;
1763
+ display.modelParams5[1] = material.opacity;
1764
+ display.modelParams5[2] = material.fakedepth;
1765
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
1766
+ }
1767
+ else
1768
+ {
1769
+ display.modelParams0[3] *= material.metalness*2;
1770
+ display.modelParams1[0] *= material.diffuse*2;
1771
+ display.modelParams1[1] *= material.specular*2;
1772
+ display.modelParams1[2] *= material.shininess*2;
1773
+ display.modelParams1[3] *= material.shift*2;
1774
+ display.modelParams2[0] *= material.ambient*2;
1775
+ display.modelParams2[1] *= material.lightarea*2;
1776
+ display.modelParams2[2] *= material.factor*2;
1777
+ display.modelParams2[3] *= material.velvet*2;
1778
+ display.modelParams3[0] *= material.sheen*2;
1779
+ display.modelParams3[1] *= material.subsurface*2;
1780
+ display.modelParams3[2] *= material.bump*2;
1781
+ display.modelParams3[3] *= material.aniso*2;
1782
+ display.modelParams4[0] *= material.anisoV*2;
1783
+ display.modelParams4[1] *= material.cameralight*2;
1784
+ //System.out.println("selected = " + selected);
1785
+ display.modelParams4[2] *= material.diffuseness*2;
1786
+ display.modelParams4[3] *= material.shadow*2;
1787
+ display.modelParams5[0] *= material.texture*2;
1788
+ display.modelParams5[1] *= material.opacity*2;
1789
+ display.modelParams5[2] *= material.fakedepth*2;
1790
+ display.modelParams5[3] *= material.shadowbias*2;
1791
+ }
1792
+
1793
+ display.modelParams6[0] = 0;
1794
+ display.modelParams6[1] = 0;
1795
+ display.modelParams6[2] = 0;
1796
+ display.modelParams6[3] = 0;
1797
+
1798
+ display.modelParams7[0] = 0;
1799
+ display.modelParams7[1] = 1000;
1800
+ display.modelParams7[2] = 0;
1801
+ display.modelParams7[3] = 0;
1802
+
1803
+ //display.modelParams6[0] = 100; // criss de bug de bump
1804
+
1805
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
1806
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
1807
+ {
1808
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
1809
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
1810
+ if (extparams.length > 1)
1811
+ {
1812
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
1813
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
1814
+ if (extparams.length > 2)
1815
+ {
1816
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
1817
+ float x = extparams[2].y / 1000.0f;
1818
+ //if (x == 0)
1819
+ // x = 1f;
1820
+ 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
1821
+ if (extparams[2].y > 0)
1822
+ {
1823
+ //System.out.println("extparams[1].y = " + extparams[1].y);
1824
+ //System.out.println("extparams[2].y = " + extparams[2].y);
1825
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1826
+ }
1827
+ }
1828
+ }
1829
+ }
1830
+
1831
+ //if (display.modelParams6[2] != 0)
1832
+ /*
1833
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
1834
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
1835
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
1836
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
1837
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
1838
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
1839
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
1840
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
1841
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
1842
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
1843
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
1844
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
1845
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
1846
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
1847
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
1848
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
1849
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
1850
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
1851
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
1852
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
1853
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
1854
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
1855
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
1856
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
1857
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
1858
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
1859
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
1860
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
1861
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
1862
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
1863
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
1864
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
1865
+ /**/
1866
+ //assert (display.modelParams6[2] == 0);
1867
+
1868
+ //System.out.println("noise power = " + display.modelParams7[0]);
1869
+ //System.out.println("shadowbias = " + shadowbias);
1870
+
1871
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
1872
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
1873
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
1874
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
1875
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
1876
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
1877
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
1878
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
1879
+
1880
+ int mode = display.FP_SHADER;
1881
+
1882
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
1883
+ {
1884
+ mode |= display.FP_ANISO;
1885
+ }
1886
+
1887
+ display.EnableProgram(mode);
1888
+
1889
+ //System.out.println("opacity power = " + display.modelParams7[1]);
1890
+
1891
+ if (!material.multiply)
1892
+ {
1893
+ if (Globals.drawMode == CameraPane.SHADOW)
1894
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
1895
+ else
1896
+ gl.glDepthMask(material.opacity >= 0.99);
1897
+ }
2081898 }
2091899
2101900 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -225,7 +1915,7 @@
2251915 currentGL.glMultMatrixd(model, 0);
2261916 }
2271917
228
- void PushMatrix(double[][] matrix, int count)
1918
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2291919 {
2301920 matrixdepth++;
2311921 // GrafreeD.tracein(matrix);
....@@ -254,7 +1944,7 @@
2541944 void PushMatrix(double[][] matrix)
2551945 {
2561946 // GrafreeD.tracein(matrix);
257
- PushMatrix(matrix,1);
1947
+ PushMatrix(matrix, 1);
2581948 }
2591949
2601950 void PushMatrix()
....@@ -270,7 +1960,7 @@
2701960
2711961 double[][] tmpmat = new double[4][4];
2721962
273
- void PopMatrix(double[][] inverse)
1963
+ public void PopMatrix(double[][] inverse) // INTERFACE
2741964 {
2751965 --matrixdepth;
2761966
....@@ -310,7 +2000,7 @@
3102000 PushTextureMatrix(matrix, 1);
3112001 }
3122002
313
- void PushTextureMatrix(double[][] matrix, int count)
2003
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3142004 {
3152005 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3162006
....@@ -324,7 +2014,7 @@
3242014 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3252015 }
3262016
327
- void PopTextureMatrix(double[][] inverse)
2017
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3282018 {
3292019 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3302020 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -351,15 +2041,15 @@
3512041
3522042 static int camerachangeframe;
3532043
354
- boolean SetCamera(Camera cam)
2044
+ public boolean SetCamera(Camera cam)
3552045 {
3562046 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3572047 // return false;
3582048
359
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
2049
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3602050 {
3612051 // check for last change
362
- if (framecount < camerachangeframe + 400) // 120 == 1 second
2052
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3632053 {
3642054 // refuse the camera change
3652055 System.err.println("Camera " + cam + " REFUSED");
....@@ -367,7 +2057,7 @@
3672057 }
3682058 }
3692059
370
- camerachangeframe = framecount;
2060
+ camerachangeframe = Globals.framecount;
3712061
3722062 cam.hAspect = -1; // Read only
3732063
....@@ -398,7 +2088,7 @@
3982088 {
3992089 //System.err.println("Oeil on");
4002090 TRACK = true;
401
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
2091
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4022092 // object.editWindow.ScreenFit(trackedobject);
4032093 //pingthread.StepToTarget(true);
4042094 }
....@@ -407,8 +2097,8 @@
4072097 {
4082098 //System.err.println("Oeil on");
4092099 OEIL = true;
410
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
411
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2100
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4122102 //pingthread.StepToTarget(true);
4132103 }
4142104
....@@ -471,39 +2161,12 @@
4712161 {
4722162 frozen ^= true;
4732163 // Weird...
474
- lighttouched = true;
2164
+ Globals.lighttouched = true;
4752165 }
4762166
4772167 void ToggleDL()
4782168 {
4792169 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;
5072170 }
5082171
5092172 void ToggleFullScreen()
....@@ -513,12 +2176,7 @@
5132176
5142177 void ToggleCrowd()
5152178 {
516
- CROWD ^= true;
517
- }
518
-
519
- void ToggleInertia()
520
- {
521
- INERTIA ^= true;
2179
+ Globals.CROWD ^= true;
5222180 }
5232181
5242182 void ToggleLocal()
....@@ -526,62 +2184,89 @@
5262184 LOCALTRANSFORM ^= true;
5272185 }
5282186
529
- void ToggleFast()
2187
+ public void ToggleTexture()
2188
+ {
2189
+ textureon ^= true;
2190
+ }
2191
+
2192
+ public void ToggleLive()
2193
+ {
2194
+ Globals.setLIVE(Globals.isLIVE() ^ true);
2195
+
2196
+ System.err.println("LIVE = " + Globals.isLIVE());
2197
+
2198
+ if (!Globals.isLIVE()) // save sound
2199
+ Grafreed.savesound = true; // wav.save();
2200
+ // else
2201
+ repaint(); // start loop // may 2013
2202
+ }
2203
+
2204
+ public void ToggleSupport()
2205
+ {
2206
+ SUPPORT ^= true;
2207
+ }
2208
+
2209
+ public void ToggleAbort()
2210
+ {
2211
+ ABORTMODE ^= true;
2212
+ }
2213
+
2214
+ public void ToggleInertia()
2215
+ {
2216
+ INERTIA ^= true;
2217
+ }
2218
+
2219
+ public void ToggleFast()
5302220 {
5312221 FAST ^= true;
5322222 }
5332223
534
- void ToggleSlowPose()
2224
+ public void ToggleSlowPose()
5352225 {
5362226 SLOWPOSE ^= true;
5372227 }
5382228
539
- void ToggleFootContact()
540
- {
541
- FOOTCONTACT ^= true;
542
- }
543
-
544
- void ToggleBoxMode()
2229
+ public void ToggleBoxMode()
5452230 {
5462231 BOXMODE ^= true;
5472232 }
5482233
549
- void ToggleSmoothFocus()
2234
+ public void ToggleZoomBoxMode()
2235
+ {
2236
+ ZOOMBOXMODE ^= true;
2237
+ }
2238
+
2239
+ public void ToggleSmoothFocus()
5502240 {
5512241 SMOOTHFOCUS ^= true;
5522242 }
5532243
554
- void ToggleImageFlip()
2244
+ public void ToggleImageFlip()
5552245 {
5562246 IMAGEFLIP ^= true;
5572247 }
5582248
559
- void ToggleSpeakerMocap()
2249
+ public void ToggleSpeakerMocap()
5602250 {
5612251 SPEAKERMOCAP ^= true;
5622252 }
5632253
564
- void ToggleSpeakerCamera()
2254
+ public void ToggleSpeakerCamera()
5652255 {
5662256 SPEAKERCAMERA ^= true;
5672257 }
5682258
569
- void ToggleSpeakerFocus()
2259
+ public void ToggleSpeakerFocus()
5702260 {
5712261 SPEAKERFOCUS ^= true;
5722262 }
5732263
574
- void ToggleDebug()
575
- {
576
- DEBUG ^= true;
577
- }
578
-
579
- void ToggleFrustum()
2264
+ public void ToggleFrustum()
5802265 {
5812266 FRUSTUM ^= true;
5822267 }
5832268
584
- void ToggleTrack()
2269
+ public void ToggleTrack()
5852270 {
5862271 TRACK ^= true;
5872272 if (TRACK)
....@@ -600,25 +2285,35 @@
6002285 repaint();
6012286 }
6022287
603
- void ToggleTrackOnce()
2288
+ public void ToggleTrackOnce()
6042289 {
6052290 TRACKONCE ^= true;
6062291 }
6072292
608
- void ToggleShadowTrack()
2293
+ public void ToggleShadowTrack()
6092294 {
6102295 SHADOWTRACK ^= true;
6112296 repaint();
6122297 }
6132298
614
- void ToggleOeil()
2299
+ public void ToggleOeil()
6152300 {
6162301 OEIL ^= true;
6172302 }
6182303
619
- void ToggleOeilOnce()
2304
+ public void ToggleOeilOnce()
6202305 {
6212306 OEILONCE ^= true;
2307
+ }
2308
+
2309
+ void ToggleFootContact()
2310
+ {
2311
+ FOOTCONTACT ^= true;
2312
+ }
2313
+
2314
+ void ToggleDebug()
2315
+ {
2316
+ Globals.DEBUG ^= true;
6222317 }
6232318
6242319 void ToggleLookAt()
....@@ -626,9 +2321,9 @@
6262321 LOOKAT ^= true;
6272322 }
6282323
629
- void ToggleRandom()
2324
+ void ToggleSwitch()
6302325 {
631
- RANDOM ^= true;
2326
+ SWITCH ^= true;
6322327 }
6332328
6342329 void ToggleHandles()
....@@ -636,10 +2331,17 @@
6362331 HANDLES ^= true;
6372332 }
6382333
2334
+ Object3D paintFolder;
2335
+
6392336 void TogglePaint()
6402337 {
6412338 PAINTMODE ^= true;
6422339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
6432345 }
6442346
6452347 void SwapCamera(int a, int b)
....@@ -672,34 +2374,6 @@
6722374 //assert (cam.hAspect == 0);
6732375 cam.hAspect = 0;
6742376 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
7032377 }
7042378
7052379 private static void ApplyTransform(GL gl, Mat4f xform)
....@@ -759,11 +2433,26 @@
7592433
7602434 GL currentGL;
7612435
762
- GL GetGL()
2436
+ public GL GetGL() // INTERFACE
7632437 {
7642438 return currentGL;
7652439 }
766
-
2440
+
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
2442
+ {
2443
+ Grafreed.Assert(texturedata != null);
2444
+
2445
+ int width = texturedata.getWidth();
2446
+ int height = texturedata.getHeight();
2447
+
2448
+ Buffer buffer = texturedata.getBuffer();
2449
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2450
+
2451
+ byte[] bytes = bytebuf.array();
2452
+
2453
+ return CreateBim(bytes, width, height);
2454
+ }
2455
+
7672456 /**/
7682457 class CacheTexture
7692458 {
....@@ -772,28 +2461,31 @@
7722461
7732462 int resolution;
7742463
775
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
7762465 {
777
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
7782468 resolution = res;
7792469 }
7802470 }
7812471 /**/
7822472
7832473 // TEXTURE static Texture texture;
784
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
785
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
786
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2474
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2475
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2476
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2477
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2478
+
7872479 int pigmentdepth = 0;
7882480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
7892481 int bumpdepth = 0;
7902482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
7912483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
7922484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
793
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
7942486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
7952487
796
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
7972489 {
7982490 TextureData texturedata = null;
7992491
....@@ -812,13 +2504,34 @@
8122504 if (bump)
8132505 texturedata = ConvertBump(texturedata, false);
8142506
815
- com.sun.opengl.util.texture.Texture texture =
816
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2507
+// com.sun.opengl.util.texture.Texture texture =
2508
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
8172509
818
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
819
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2510
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2511
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
8202512
821
- return texture;
2513
+ return texturedata;
2514
+ }
2515
+
2516
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2517
+ {
2518
+ TextureData texturedata = null;
2519
+
2520
+ try
2521
+ {
2522
+ texturedata =
2523
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2524
+ bim,
2525
+ true);
2526
+ } catch (Exception e)
2527
+ {
2528
+ throw new javax.media.opengl.GLException(e);
2529
+ }
2530
+
2531
+ if (bump)
2532
+ texturedata = ConvertBump(texturedata, false);
2533
+
2534
+ return texturedata;
8222535 }
8232536
8242537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -1891,6 +3604,8 @@
18913604
18923605 System.out.println("LOADING TEXTURE : " + name);
18933606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
18943609 //
18953610 if (false) // compressbit > 0)
18963611 {
....@@ -2000,10 +3715,12 @@
20003715 */
20013716 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20023717 {
3718
+ int pixelformat = texturedata.getPixelFormat();
3719
+
20033720 int stride = 1;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
3721
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20053722 stride = 3;
2006
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
3723
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20073724 stride = 4;
20083725
20093726 int width = texturedata.getWidth();
....@@ -2593,6 +4310,7 @@
25934310
25944311 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
25954312 {
4313
+ new Exception().printStackTrace();
25964314 System.exit(0);
25974315 com.sun.opengl.util.texture.Texture texture = null;
25984316
....@@ -6269,7 +7987,7 @@
62697987 return null;
62707988 }
62717989
6272
- void ReleaseTextures(cTexture tex)
7990
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62737991 {
62747992 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62757993 {
....@@ -6286,7 +8004,7 @@
62868004 String pigment = Object3D.GetPigment(tex);
62878005 String bump = Object3D.GetBump(tex);
62888006
6289
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
62908008 {
62918009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
62928010 // System.out.println("; bump = " + bump);
....@@ -6301,13 +8019,71 @@
63018019 pigment = null;
63028020 }
63038021
6304
- ReleaseTexture(bump, true);
6305
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
63068024 }
63078025
6308
- void ReleaseTexture(String tex, boolean bump)
8026
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
63098027 {
6310
- if (// drawMode != 0 || /*tex == null ||*/
8028
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8029
+ {
8030
+ return;
8031
+ }
8032
+
8033
+ if (tex == null)
8034
+ {
8035
+ ReleaseTexture(null, false);
8036
+ return;
8037
+ }
8038
+
8039
+ String pigment = Object3D.GetPigment(tex);
8040
+
8041
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ {
8043
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8044
+ // System.out.println("; bump = " + bump);
8045
+ }
8046
+
8047
+ if (pigment.equals(""))
8048
+ {
8049
+ pigment = null;
8050
+ }
8051
+
8052
+ ReleaseTexture(tex, false);
8053
+ }
8054
+
8055
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8056
+ {
8057
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8058
+ {
8059
+ return;
8060
+ }
8061
+
8062
+ if (tex == null)
8063
+ {
8064
+ ReleaseTexture(null, true);
8065
+ return;
8066
+ }
8067
+
8068
+ String bump = Object3D.GetBump(tex);
8069
+
8070
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8071
+ {
8072
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8073
+ // System.out.println("; bump = " + bump);
8074
+ }
8075
+
8076
+ if (bump.equals(""))
8077
+ {
8078
+ bump = null;
8079
+ }
8080
+
8081
+ ReleaseTexture(tex, true);
8082
+ }
8083
+
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
8085
+ {
8086
+ if (// DrawMode() != 0 || /*tex == null ||*/
63118087 ambientOcclusion ) // || !textureon)
63128088 {
63138089 return;
....@@ -6316,7 +8092,7 @@
63168092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
63178093
63188094 if (tex != null)
6319
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
63208096
63218097 // //assert( texture != null );
63228098 // if (texture == null)
....@@ -6408,9 +8184,57 @@
64088184 }
64098185 }
64108186
6411
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
8187
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
64128188 {
6413
- if (// drawMode != 0 || /*tex == null ||*/
8189
+// if (// DrawMode() != 0 || /*tex == null ||*/
8190
+// ambientOcclusion ) // || !textureon)
8191
+// {
8192
+// return; // false;
8193
+// }
8194
+//
8195
+// if (tex == null)
8196
+// {
8197
+// BindTexture(null,false,resolution);
8198
+// BindTexture(null,true,resolution);
8199
+// return;
8200
+// }
8201
+//
8202
+// String pigment = Object3D.GetPigment(tex);
8203
+// String bump = Object3D.GetBump(tex);
8204
+//
8205
+// usedtextures.add(pigment);
8206
+// usedtextures.add(bump);
8207
+//
8208
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8209
+// {
8210
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8211
+// // System.out.println("; bump = " + bump);
8212
+// }
8213
+//
8214
+// if (bump.equals(""))
8215
+// {
8216
+// bump = null;
8217
+// }
8218
+// if (pigment.equals(""))
8219
+// {
8220
+// pigment = null;
8221
+// }
8222
+//
8223
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8224
+// BindTexture(pigment, false, resolution);
8225
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8226
+// BindTexture(bump, true, resolution);
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+//
8229
+// return; // true;
8230
+
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
8233
+ }
8234
+
8235
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8236
+ {
8237
+ if (// DrawMode() != 0 || /*tex == null ||*/
64148238 ambientOcclusion ) // || !textureon)
64158239 {
64168240 return; // false;
....@@ -6419,17 +8243,47 @@
64198243 if (tex == null)
64208244 {
64218245 BindTexture(null,false,resolution);
6422
- BindTexture(null,true,resolution);
64238246 return;
64248247 }
64258248
64268249 String pigment = Object3D.GetPigment(tex);
8250
+
8251
+ usedtextures.add(tex);
8252
+
8253
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8254
+ {
8255
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8256
+ // System.out.println("; bump = " + bump);
8257
+ }
8258
+
8259
+ if (pigment.equals(""))
8260
+ {
8261
+ pigment = null;
8262
+ }
8263
+
8264
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8265
+ BindTexture(tex, false, resolution);
8266
+ }
8267
+
8268
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8269
+ {
8270
+ if (// DrawMode() != 0 || /*tex == null ||*/
8271
+ ambientOcclusion ) // || !textureon)
8272
+ {
8273
+ return; // false;
8274
+ }
8275
+
8276
+ if (tex == null)
8277
+ {
8278
+ BindTexture(null,true,resolution);
8279
+ return;
8280
+ }
8281
+
64278282 String bump = Object3D.GetBump(tex);
64288283
6429
- usedtextures.put(pigment, pigment);
6430
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
64318285
6432
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
64338287 {
64348288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
64358289 // System.out.println("; bump = " + bump);
....@@ -6439,43 +8293,82 @@
64398293 {
64408294 bump = null;
64418295 }
6442
- if (pigment.equals(""))
6443
- {
6444
- pigment = null;
6445
- }
64468296
6447
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
6448
- BindTexture(pigment, false, resolution);
64498297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
6450
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
64518299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
6452
-
6453
- return; // true;
64548300 }
64558301
6456
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8302
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8303
+
8304
+ private boolean FileExists(String tex)
64578305 {
6458
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8306
+ if (missingTextures.contains(tex))
8307
+ {
8308
+ return false;
8309
+ }
8310
+
8311
+ boolean fileExists = new File(tex).exists();
8312
+
8313
+ if (!fileExists)
8314
+ {
8315
+ // If file exists, the "new File()" is not executed sgain
8316
+ missingTextures.add(tex);
8317
+ }
8318
+
8319
+ return fileExists;
8320
+ }
8321
+
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8323
+ {
8324
+ CacheTexture texturecache = null;
64598325
64608326 if (tex != null)
64618327 {
6462
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
64638330
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;
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
8335
+
8336
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8337
+
8338
+// String[] split = tex.split("Textures");
8339
+// if (split.length > 1)
8340
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8341
+// else
8342
+// if (!texname.startsWith("/"))
8343
+// texname = "/Users/nbriere/Textures/" + texname;
8344
+ if (!FileExists(texname))
8345
+ {
8346
+ texname = fallbackTextureName;
8347
+ }
64708348
64718349 if (CACHETEXTURE)
6472
- texture = textures.get(texname); // TEXTURE CACHE
6473
-
6474
- TextureData texturedata = null;
6475
-
6476
- if (texture == null || texture.resolution < resolution)
64778350 {
6478
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8351
+ if (texdata == null)
8352
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8353
+ else
8354
+ texturecache = bimtextures.get(texdata);
8355
+ }
8356
+
8357
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8358
+ {
8359
+ TextureData texturedata = null;
8360
+
8361
+ if (texdata != null)
8362
+ {
8363
+ BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8364
+
8365
+ CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8366
+
8367
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8368
+ bimtextures.put(texdata, texturecache);
8369
+ }
8370
+ else
8371
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
64798372 {
64808373 assert(!bump);
64818374 // if (bump)
....@@ -6486,19 +8379,23 @@
64868379 // }
64878380 // else
64888381 // {
6489
- texture = textures.get(tex);
6490
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
64918384 {
6492
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
64938386 }
8387
+ else
8388
+ new Exception().printStackTrace();
64948389 // }
64958390 } else
6496
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
64978392 {
64988393 assert(bump);
6499
- texture = textures.get(tex);
6500
- if (texture == null)
6501
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8394
+ // texturecache = textures.get(texname); // suspicious
8395
+ if (texturecache == null)
8396
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8397
+ else
8398
+ new Exception().printStackTrace();
65028399 } else
65038400 {
65048401 //if (tex.equals("IMMORTAL"))
....@@ -6506,11 +8403,13 @@
65068403 // texture = GetResourceTexture("default.png");
65078404 //} else
65088405 //{
6509
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
65108407 {
6511
- texture = textures.get(tex);
6512
- if (texture == null)
6513
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8408
+ // texturecache = textures.get(texname); // suspicious
8409
+ if (texturecache == null)
8410
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8411
+ else
8412
+ new Exception().printStackTrace();
65148413 } else
65158414 {
65168415 if (textureon)
....@@ -6535,7 +8434,7 @@
65358434 }
65368435
65378436 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
6538
- if (!new File(cachename).exists())
8437
+ if (!FileExists(cachename))
65398438 cachename = texname;
65408439 else
65418440 processbump = false; // don't process bump map again
....@@ -6557,7 +8456,7 @@
65578456 }
65588457
65598458 cachename = texname.substring(0, texname.length()-4)+ext+".png";
6560
- if (!new File(cachename).exists())
8459
+ if (!FileExists(cachename))
65618460 cachename = texname;
65628461 else
65638462 processbump = false; // don't process bump map again
....@@ -6566,20 +8465,22 @@
65668465 texturedata = GetFileTexture(cachename, processbump, resolution);
65678466
65688467
6569
- if (texturedata != null)
6570
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8468
+ if (texturedata == null)
8469
+ throw new Exception();
8470
+
8471
+ texturecache = new CacheTexture(texturedata,resolution);
65718472 //texture = GetTexture(tex, bump);
65728473 }
65738474 }
65748475 //}
65758476 }
65768477
6577
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
65788479 {
65798480 //return false;
65808481
65818482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
6582
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
65838484 {
65848485 // String ext = "_highres";
65858486 // if (REDUCETEXTURE)
....@@ -6596,52 +8497,17 @@
65968497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
65978498 if (!cachefile.exists())
65988499 {
6599
- // cache to disk
6600
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
6601
- //buffers[0].
6602
-
6603
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
6604
- int[] pixels = new int[bytebuf.capacity()/3];
6605
-
6606
- // squared size heuristic...
6607
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
66088501 {
6609
- for (int i=pixels.length; --i>=0;)
6610
- {
6611
- int i3 = i*3;
6612
- pixels[i] = 0xFF;
6613
- pixels[i] <<= 8;
6614
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
6615
- pixels[i] <<= 8;
6616
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
6617
- pixels[i] <<= 8;
6618
- pixels[i] |= bytebuf.get(i3) & 0xFF;
6619
- }
6620
-
6621
- /*
6622
- int r=0,g=0,b=0,a=0;
6623
- for (int i=0; i<width; i++)
6624
- for (int j=0; j<height; j++)
6625
- {
6626
- int index = j*width+i;
6627
- int p = pixels[index];
6628
- a = ((p>>24) & 0xFF);
6629
- r = ((p>>16) & 0xFF);
6630
- g = ((p>>8) & 0xFF);
6631
- b = (p & 0xFF);
6632
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
6633
- }
6634
- /**/
6635
- int width = (int)Math.sqrt(pixels.length); // squared
6636
- int height = width;
6637
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
6638
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
66398504 ImageWriter writer = null;
66408505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
66418506 if (iter.hasNext()) {
66428507 writer = (ImageWriter)iter.next();
66438508 }
6644
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
66458511 try
66468512 {
66478513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -6658,18 +8524,20 @@
66588524 }
66598525 }
66608526 }
6661
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
66628530 //System.out.println("Texture = " + tex);
6663
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
66648532 {
6665
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
66668534 thetex.texture.disable();
66678535 thetex.texture.dispose();
6668
- textures.remove(texname);
8536
+ textures.remove(tex);
66698537 }
66708538
6671
- texture.texturedata = texturedata;
6672
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
66738541
66748542 // newtex = true;
66758543 }
....@@ -6685,10 +8553,41 @@
66858553 }
66868554 }
66878555
6688
- return texture;
8556
+ return texturecache;
66898557 }
66908558
6691
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8559
+ static void EmbedTextures(cTexture tex)
8560
+ {
8561
+ if (tex.pigmentdata == null)
8562
+ {
8563
+ String texname = Object3D.GetPigment(tex);
8564
+
8565
+ CacheTexture texturecache = texturepigment.get(tex);
8566
+
8567
+ if (texturecache != null)
8568
+ {
8569
+ tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8570
+ tex.pw = texturecache.texturedata.getWidth();
8571
+ tex.ph = texturecache.texturedata.getHeight();
8572
+ }
8573
+ }
8574
+
8575
+ if (tex.bumpdata == null)
8576
+ {
8577
+ String texname = Object3D.GetBump(tex);
8578
+
8579
+ CacheTexture texturecache = texturebump.get(tex);
8580
+
8581
+ if (texturecache != null)
8582
+ {
8583
+ tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8584
+ tex.bw = texturecache.texturedata.getWidth();
8585
+ tex.bh = texturecache.texturedata.getHeight();
8586
+ }
8587
+ }
8588
+ }
8589
+
8590
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
66928591 {
66938592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
66948593
....@@ -6706,21 +8605,21 @@
67068605 return texture!=null?texture.texture:null;
67078606 }
67088607
6709
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8608
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
67108609 {
67118610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
67128611
67138612 return texture!=null?texture.texturedata:null;
67148613 }
67158614
6716
- boolean BindTexture(String tex, boolean bump, int resolution)
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
67178616 {
67188617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
67198618 {
67208619 return false;
67218620 }
67228621
6723
- boolean newtex = false;
8622
+ //boolean newtex = false;
67248623
67258624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
67268625
....@@ -6752,7 +8651,7 @@
67528651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
67538652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
67548653
6755
- return newtex;
8654
+ return true; // Warning: not used.
67568655 }
67578656
67588657 ShadowBuffer shadowPBuf;
....@@ -7310,9 +9209,9 @@
73109209 static boolean occlusionInitialized = false;
73119210 boolean selection = false;
73129211 boolean pointselection = false;
7313
- /*static*/ boolean lighttouched = true;
9212
+ ///*static*/ boolean lighttouched = true;
73149213 boolean deselect;
7315
- boolean ambientOcclusion = false;
9214
+ private boolean ambientOcclusion = false;
73169215 static boolean flash = false;
73179216 /*static*/ boolean wait = false;
73189217 boolean displaydone = false; // after repaint() calls
....@@ -7442,6 +9341,8 @@
74429341 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74439342 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74449343 double scale = lightCamera.SCALE / lightCamera.Distance();
9344
+// PATCH FILLE AUX JEANS
9345
+ //scale *= lightCamera.shaper_fovy / 25;
74459346 gl.glScaled(2 * scale, 2 * scale, -scale);
74469347 gl.glTranslated(0, 0, lightCamera.DECAL);
74479348
....@@ -7588,17 +9489,40 @@
75889489 jy8[3] = 0.5f;
75899490 }
75909491
7591
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9492
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75929493 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
9494
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
9495
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75949496
9497
+ void ResetOptions()
9498
+ {
9499
+ options1[0] = 100;
9500
+ options1[1] = 0.025f;
9501
+ options1[2] = 0.01f;
9502
+ options1[3] = 0;
9503
+ options1[4] = 0;
9504
+
9505
+ options2[0] = 0;
9506
+ options2[1] = 0.75f;
9507
+ options2[2] = 0;
9508
+ options2[3] = 0;
9509
+
9510
+ options3[0] = 1;
9511
+ options3[1] = 1;
9512
+ options3[2] = 1;
9513
+ options3[3] = 0;
9514
+
9515
+ options4[0] = 1;
9516
+ options4[1] = 0;
9517
+ options4[2] = 1;
9518
+ options4[3] = 0;
9519
+ }
9520
+
75959521 static int imagecount = 0; // movie generation
75969522
75979523 static int jitter = 0;
75989524
75999525 boolean restartframe = false;
7600
-
7601
- static int framecount = 0; // general-purpose global count
76029526
76039527 void displayAntiAliased(javax.media.opengl.GL gl)
76049528 {
....@@ -7630,7 +9554,7 @@
76309554 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76319555 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76329556 {
7633
- framecount++;
9557
+ Globals.framecount++;
76349558
76359559 if (CameraPane.tickcount > 0)
76369560 CameraPane.tickcount--;
....@@ -7668,7 +9592,7 @@
76689592
76699593 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76709594 */
7671
- lighttouched = true;
9595
+ Globals.lighttouched = true;
76729596 //System.err.println(" shadowbuffer: " + jitter);
76739597 shadowbuffer.display();
76749598
....@@ -7689,8 +9613,8 @@
76899613 assert (parentcam != renderCamera);
76909614
76919615 if (renderCamera != lightCamera)
7692
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7693
- LA.matConcat(parentcam.toParent, matrix, matrix);
9616
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
76949618
76959619 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76969620
....@@ -7705,8 +9629,8 @@
77059629 LA.matCopy(renderCamera.fromScreen, matrix);
77069630
77079631 if (renderCamera != lightCamera)
7708
- for (int count = parentcam.GetTransformCount(); --count>=0;)
7709
- LA.matConcat(matrix, parentcam.fromParent, matrix);
9632
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
77109634
77119635 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77129636
....@@ -7778,7 +9702,7 @@
77789702 //gl.glFlush();
77799703 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
77809704
7781
- if (ANIMATION && ABORTED)
9705
+ if (Globals.ANIMATION && ABORTED)
77829706 {
77839707 System.err.println(" ABORTED FRAME");
77849708 break;
....@@ -7808,7 +9732,7 @@
78089732 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
78099733
78109734 // save image
7811
- if (ANIMATION && !ABORTED)
9735
+ if (Globals.ANIMATION && !ABORTED)
78129736 {
78139737 VPwidth = viewport[2];
78149738 VPheight = viewport[3];
....@@ -7919,11 +9843,11 @@
79199843
79209844 // imagecount++;
79219845
7922
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9846
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
79239847
79249848 if (!BOXMODE)
79259849 {
7926
- System.out.println("image: " + fullname + " (" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9850
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
79279851 }
79289852
79299853 if (!BOXMODE)
....@@ -7961,7 +9885,7 @@
79619885 ABORTED = false;
79629886 }
79639887 else
7964
- GrafreeD.wav.cursor += 735 * ACSIZE;
9888
+ Grafreed.wav.cursor += 735 * ACSIZE;
79659889
79669890 if (false)
79679891 {
....@@ -8615,13 +10539,6 @@
861510539 }
861610540 }
861710541
8618
- boolean IsFrozen()
8619
- {
8620
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8621
-
8622
- return !selectmode && cameracount == 0; // != 0;
8623
- }
8624
-
862510542 boolean niceon = false;
862610543 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
862710544 boolean currentlydrawing = false;
....@@ -8631,16 +10548,16 @@
863110548
863210549 public void display(GLAutoDrawable drawable)
863310550 {
8634
- if (GrafreeD.savesound && GrafreeD.hassound)
10551
+ if (Grafreed.savesound && Grafreed.hassound)
863510552 {
8636
- GrafreeD.wav.save();
8637
- GrafreeD.savesound = false;
8638
- GrafreeD.hassound = false;
10553
+ Grafreed.wav.save();
10554
+ Grafreed.savesound = false;
10555
+ Grafreed.hassound = false;
863910556 }
864010557 // if (DEBUG_SELECTION)
864110558 // {
8642
-// if (drawMode != SELECTION)
8643
-// drawMode = SELECTION;
10559
+// if (DrawMode() != SELECTION)
10560
+// DrawMode() = SELECTION;
864410561 // }
864510562
864610563 if (!isRenderer)
....@@ -8696,9 +10613,9 @@
869610613
869710614 //ANTIALIAS = 0;
869810615
8699
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
10616
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
870010617 {
8701
- if (niceon || isLIVE())
10618
+ if (niceon || Globals.isLIVE())
870210619 {
870310620 //if(active == 0)
870410621 // antialiaser = null;
....@@ -8711,6 +10628,7 @@
871110628 ANTIALIAS = 0;
871210629 //System.out.println("RESTART");
871310630 AAtimer.restart();
10631
+ Globals.TIMERRUNNING = true;
871410632 }
871510633 }
871610634 }
....@@ -8723,7 +10641,7 @@
872310641 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
872410642 */
872510643
8726
- if (drawMode == DEFAULT)
10644
+ if (DrawMode() == DEFAULT)
872710645 {
872810646 currentlydrawing = true;
872910647 }
....@@ -8754,18 +10672,18 @@
875410672
875510673 // if(Applet3D.clipboard != null)
875610674 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8757
-//drawMode = SELECTION;
10675
+//DrawMode() = SELECTION;
875810676 indexcount = 0;
875910677
8760
- if (drawMode == OCCLUSION)
10678
+ if (DrawMode() == OCCLUSION)
876110679 {
8762
- drawMode = DEFAULT;
10680
+ Globals.drawMode = DEFAULT; // WARNING
876310681 ambientOcclusion = true;
876410682 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
876510683 Object3D theobject = object;
876610684 Object3D theparent = object.parent;
876710685 object.parent = null;
8768
- object = (Object3D)GrafreeD.clone(object);
10686
+ object = (Object3D)Grafreed.clone(object);
876910687 object.Stripify();
877010688 if (theobject.selection == null || theobject.selection.Size() == 0)
877110689 theobject.PreprocessOcclusion(this);
....@@ -8778,19 +10696,20 @@
877810696 ambientOcclusion = false;
877910697 }
878010698
8781
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
10699
+ if (//Globals.lighttouched &&
10700
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
878210701 {
878310702 //if (RENDERSHADOW) // ?
878410703 if (!IsFrozen())
878510704 {
878610705 // dec 2012
8787
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
10706
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
878810707 {
8789
- framecount++;
10708
+ Globals.framecount++;
879010709 shadowbuffer.display();
879110710 }
879210711 }
8793
- lighttouched = false; // ??
10712
+ Globals.lighttouched = false; // ??
879410713 //drawing = true;
879510714 //lighttouched = true;
879610715 }
....@@ -8811,9 +10730,9 @@
881110730 //eyeCamera.shaper_fovy = 1;
881210731 }
881310732
8814
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
10733
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
881510734 {
8816
- //System.out.println("drawMode = " + drawMode);
10735
+ //System.out.println("DrawMode() = " + DrawMode());
881710736 vertexMode |= VP_PASS;
881810737 //vertexMode |= VP_PROJECTION;
881910738 if (!ambientOcclusion)
....@@ -8873,7 +10792,7 @@
887310792 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
887410793 //Camera lightcam = new Camera(light0);
887510794
8876
- if (drawMode == SHADOW)
10795
+ if (DrawMode() == SHADOW)
887710796 {
887810797 /*
887910798 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8911,8 +10830,8 @@
891110830
891210831 // if (parentcam != renderCamera) // not a light
891310832 if (cam != lightCamera)
8914
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8915
- LA.matConcat(parentcam.toParent, matrix, matrix);
10833
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
891610835
891710836 for (int j = 0; j < 4; j++)
891810837 {
....@@ -8926,8 +10845,8 @@
892610845
892710846 // if (parentcam != renderCamera) // not a light
892810847 if (cam != lightCamera)
8929
- for (int count = parentcam.GetTransformCount(); --count>=0;)
8930
- LA.matConcat(matrix, parentcam.fromParent, matrix);
10848
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
893110850
893210851 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
893310852
....@@ -8963,7 +10882,7 @@
896310882 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
896410883 } else
896510884 {
8966
- if (drawMode != DEFAULT)
10885
+ if (DrawMode() != DEFAULT)
896710886 {
896810887 gl.glClearColor(1, 1, 1, 0);
896910888 } // 1);
....@@ -9028,7 +10947,7 @@
902810947
902910948 fast &= !ambientOcclusion;
903010949
9031
- if (drawMode == DEFAULT)
10950
+ if (DrawMode() == DEFAULT)
903210951 {
903310952 //gl.glEnable(gl.GL_ALPHA_TEST);
903410953 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9089,6 +11008,8 @@
908911008 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
909011009 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
909111010 double scale = lightCamera.SCALE / lightCamera.Distance();
11011
+// PATCH FILLE AUX JEANS
11012
+ //scale *= lightCamera.shaper_fovy / 25;
909211013 gl.glScaled(2 * scale, 2 * scale, -scale);
909311014 gl.glTranslated(0, 0, lightCamera.DECAL);
909411015
....@@ -9184,7 +11105,16 @@
918411105 // Bump noise
918511106 gl.glActiveTexture(GL.GL_TEXTURE6);
918611107 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
9187
- BindTexture(NOISE_TEXTURE, false, 2);
11108
+
11109
+ try
11110
+ {
11111
+ BindTexture(NOISE_TEXTURE, false, 2);
11112
+ }
11113
+ catch (Exception e)
11114
+ {
11115
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11116
+ }
11117
+
918811118
918911119 gl.glActiveTexture(GL.GL_TEXTURE0);
919011120 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -9207,9 +11137,9 @@
920711137
920811138 gl.glMatrixMode(GL.GL_MODELVIEW);
920911139
9210
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
9211
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
9212
-//gl.glEnable(gl.GL_MULTISAMPLE);
11140
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11141
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11142
+gl.glEnable(gl.GL_MULTISAMPLE);
921311143 } else
921411144 {
921511145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -9220,14 +11150,16 @@
922011150 //System.out.println("BLENDING ON");
922111151 gl.glEnable(GL.GL_BLEND);
922211152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
9223
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
922411154 gl.glMatrixMode(gl.GL_PROJECTION);
922511155 gl.glLoadIdentity();
922611156
9227
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
11157
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
922811158 {
922911159 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
923011160 double scale = lightCamera.SCALE / lightCamera.Distance();
11161
+// PATCH FILLE AUX JEANS
11162
+ //scale *= lightCamera.shaper_fovy / 25;
923111163 gl.glScaled(2 * scale, 2 * scale, -scale);
923211164 gl.glTranslated(0, 0, lightCamera.DECAL);
923311165 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9280,7 +11212,7 @@
928011212 //gl.glPushMatrix();
928111213 gl.glLoadIdentity();
928211214
9283
- if (!ambientOcclusion) // drawMode != OCCLUSION)
11215
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
928411216 {
928511217 //LA.xformPos(light0, lightCamera.fromScreen, light);
928611218 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9307,8 +11239,8 @@
930711239 System.err.println("parentcam != renderCamera");
930811240
930911241 // if (cam != lightCamera)
9310
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9311
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11242
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11243
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
931211244 }
931311245
931411246 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -9329,8 +11261,8 @@
932911261 if (true) // TODO
933011262 {
933111263 if (cam != lightCamera)
9332
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9333
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11264
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11265
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
933411266 }
933511267
933611268 LA.xformPos(light0, cam.toScreen, light0);
....@@ -9367,7 +11299,7 @@
936711299 }
936811300
936911301 /**/
9370
- if (true) // drawMode == SELECTION) // != DEFAULT)
11302
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
937111303 gl.glDisable(gl.GL_LIGHTING);
937211304 else
937311305 gl.glEnable(gl.GL_LIGHTING);
....@@ -9379,12 +11311,13 @@
937911311
938011312 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
938111313 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
11314
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
938211315
938311316 options2[0] *= renderCamera.Distance();
938411317
938511318 lightslot = 64;
938611319
9387
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
11320
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
938811321 {
938911322 DrawLights(object);
939011323 }
....@@ -9395,7 +11328,7 @@
939511328 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
939611329 //System.out.println("fragmentMode = " + fragmentMode);
939711330
9398
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
11331
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
939911332 {
940011333 /*
940111334 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9428,7 +11361,7 @@
942811361 }
942911362 }
943011363
9431
- if (drawMode == DEFAULT)
11364
+ if (DrawMode() == DEFAULT)
943211365 {
943311366 if (WIREFRAME && !ambientOcclusion)
943411367 {
....@@ -9446,7 +11379,7 @@
944611379 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
944711380 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
944811381
9449
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
11382
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
945011383 {
945111384 if (vertexMode != 0) // && !fast)
945211385 {
....@@ -9466,7 +11399,7 @@
946611399 }
946711400 }
946811401
9469
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
11402
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
947011403 {
947111404 //gl.glDepthFunc(GL.GL_LEQUAL);
947211405 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9494,7 +11427,7 @@
949411427 //gl.glDepthMask(false);
949511428 }
949611429
9497
- if (false) // drawMode == SHADOW)
11430
+ if (false) // DrawMode() == SHADOW)
949811431 {
949911432 //SetColumnMajorData(cameraInverseTransform, view_1);
950011433 //System.out.println("light = " + cameraInverseTransform);
....@@ -9508,16 +11441,16 @@
950811441 //System.out.println("object = " + object);
950911442 if (!frozen && !imageLocked)
951011443 {
9511
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
11444
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
951211445 {
951311446 displayAntiAliased(gl);
951411447 } else
951511448 {
951611449 programcount = 0;
9517
- int keepmode = drawMode;
11450
+ int keepmode = DrawMode();
951811451 // if (DEBUG_SELECTION)
951911452 // {
9520
-// drawMode = SELECTION;
11453
+// DrawMode() = SELECTION;
952111454 // }
952211455 // for point selection
952311456 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9527,10 +11460,10 @@
952711460 DrawObject(gl);
952811461
952911462 // jan 2013 System.err.println("RESET ABORT (display)");
9530
- // if (drawMode == DEFAULT)
11463
+ // if (DrawMode() == DEFAULT)
953111464 // ABORTED = false;
953211465 fullreset = false;
9533
- drawMode = keepmode;
11466
+ Globals.drawMode = keepmode; // WARNING
953411467 //System.out.println("PROGRAM SWITCH " + programcount);
953511468 }
953611469 }
....@@ -9538,11 +11471,11 @@
953811471 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
953911472 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
954011473
9541
- if (drawMode == DEFAULT)
11474
+ if (DrawMode() == DEFAULT)
954211475 {
954311476 ReleaseTexture(NOISE_TEXTURE, false);
954411477 }
9545
- //if (drawMode == DEFAULT)
11478
+ //if (DrawMode() == DEFAULT)
954611479 {
954711480
954811481 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9554,7 +11487,7 @@
955411487 //else
955511488 //gl.glDisable(gl.GL_TEXTURE_2D);
955611489 //gl.glPopMatrix();
9557
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
11490
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
955811491 {
955911492 //new Exception().printStackTrace();
956011493 //System.out.println("Draw image " + width + ", " + height);
....@@ -9596,7 +11529,7 @@
959611529 //gl.glFlush();
959711530 }
959811531
9599
- if (flash && drawMode == DEFAULT)
11532
+ if (flash && DrawMode() == DEFAULT)
960011533 {
960111534 flash = false;
960211535 wait = true;
....@@ -9604,9 +11537,9 @@
960411537 }
960511538
960611539 //drawing = false;
9607
- //if(drawMode == DEFAULT)
11540
+ //if(DrawMode() == DEFAULT)
960811541 // niceon = false;
9609
- if (drawMode == DEFAULT)
11542
+ if (DrawMode() == DEFAULT)
961011543 {
961111544 currentlydrawing = false;
961211545 }
....@@ -9626,7 +11559,7 @@
962611559 repaint();
962711560 }
962811561
9629
- if (isLIVE() && drawMode == DEFAULT) // may 2013
11562
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
963011563 repaint();
963111564
963211565 displaydone = true;
....@@ -9645,8 +11578,14 @@
964511578 {
964611579 renderpass++;
964711580 // System.out.println("Draw object... ");
11581
+ STEP = 1;
964811582 if (FAST) // in case there is no script
9649
- STEP = 16;
11583
+ STEP = 8;
11584
+
11585
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11586
+ {
11587
+ STEP *= 4;
11588
+ }
965011589
965111590 //object.FullInvariants();
965211591
....@@ -9660,23 +11599,44 @@
966011599 e.printStackTrace();
966111600 }
966211601
9663
- if (GrafreeD.RENDERME > 0)
9664
- GrafreeD.RENDERME--; // mechante magouille
11602
+ if (Grafreed.RENDERME > 0)
11603
+ Grafreed.RENDERME--; // mechante magouille
966511604
9666
- ONESTEP = false;
11605
+ Globals.ONESTEP = false;
966711606 }
966811607
966911608 static boolean zoomonce = false;
967011609
11610
+ static void CreateSelectedPoint()
11611
+ {
11612
+ if (selectedpoint == null)
11613
+ {
11614
+ debugpointG = new Sphere();
11615
+ debugpointP = new Sphere();
11616
+ debugpointC = new Sphere();
11617
+ debugpointR = new Sphere();
11618
+
11619
+ selectedpoint = new Superellipsoid();
11620
+
11621
+ for (int i=0; i<8; i++)
11622
+ {
11623
+ debugpoints[i] = new Sphere();
11624
+ }
11625
+ }
11626
+ }
11627
+
967111628 void DrawObject(GL gl, boolean draw)
967211629 {
11630
+ // To clear camera values
11631
+ ResetOptions();
11632
+
967311633 //System.out.println("DRAW OBJECT " + mouseDown);
9674
-// drawMode = SELECTION;
11634
+// DrawMode() = SELECTION;
967511635 //GL gl = getGL();
967611636 if ((TRACK || SHADOWTRACK) || zoomonce)
967711637 {
9678
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
9679
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11638
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
968011640 pingthread.StepToTarget(true); // true);
968111641 // zoomonce = false;
968211642 }
....@@ -9696,9 +11656,9 @@
969611656 callist = gl.glGenLists(1);
969711657 }
969811658
9699
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
11659
+ boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
970011660
9701
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
11661
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
970211662
970311663 if (!mainDL || !active || touched)
970411664 {
....@@ -9725,13 +11685,20 @@
972511685 PushMatrix(ClickInfo.matbuffer);
972611686 }
972711687
9728
- if (drawMode == 0)
11688
+ if (DrawMode() == 0)
972911689 {
973011690 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
973111691
973211692 usedtextures.clear();
973311693
9734
- BindTextures(DEFAULT_TEXTURES, 2);
11694
+ try
11695
+ {
11696
+ BindTextures(DEFAULT_TEXTURES, 2);
11697
+ }
11698
+ catch (Exception e)
11699
+ {
11700
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11701
+ }
973511702 }
973611703 //System.out.println("--> " + stackdepth);
973711704 // GrafreeD.traceon();
....@@ -9739,10 +11706,11 @@
973911706 // DRAW
974011707 object.draw(this, /*(Composite)*/ object, false, false);
974111708
9742
- if (drawMode == DEFAULT)
11709
+ if (DrawMode() == DEFAULT)
974311710 {
9744
- if (DEBUG)
11711
+ if (Globals.DEBUG)
974511712 {
11713
+ CreateSelectedPoint();
974611714 float radius = 0.05f;
974711715 if (selectedpoint.radius != radius)
974811716 {
....@@ -9750,40 +11718,40 @@
975011718 selectedpoint.radius = radius;
975111719 selectedpoint.recalculate();
975211720 selectedpoint.material = new cMaterial();
9753
- selectedpoint.material.color = 0.25f;
11721
+ selectedpoint.material.color = 0.15f; // Yellow
975411722 selectedpoint.material.modulation = 0.75f;
975511723
9756
- debugpoint.radius = radius;
9757
- debugpoint.recalculate();
9758
- debugpoint.material = new cMaterial();
9759
- debugpoint.material.color = 0.25f;
9760
- debugpoint.material.modulation = 0.75f;
11724
+ debugpointG.radius = radius;
11725
+ debugpointG.recalculate();
11726
+ debugpointG.material = new cMaterial();
11727
+ debugpointG.material.color = 0.25f; // Green
11728
+ debugpointG.material.modulation = 0.75f;
976111729
9762
- debugpoint2.radius = radius;
9763
- debugpoint2.recalculate();
9764
- debugpoint2.material = new cMaterial();
9765
- debugpoint2.material.color = 0.75f;
9766
- debugpoint2.material.modulation = 0.75f;
11730
+ debugpointP.radius = radius;
11731
+ debugpointP.recalculate();
11732
+ debugpointP.material = new cMaterial();
11733
+ debugpointP.material.color = 0.75f; // Purple
11734
+ debugpointP.material.modulation = 0.75f;
976711735
9768
- debugpoint3.radius = radius;
9769
- debugpoint3.recalculate();
9770
- debugpoint3.material = new cMaterial();
9771
- debugpoint3.material.color = 0.5f;
9772
- debugpoint3.material.modulation = 0.75f;
11736
+ debugpointC.radius = radius;
11737
+ debugpointC.recalculate();
11738
+ debugpointC.material = new cMaterial();
11739
+ debugpointC.material.color = 0.5f; // Cyan
11740
+ debugpointC.material.modulation = 0.75f;
977311741
9774
- debugpoint4.radius = radius;
9775
- debugpoint4.recalculate();
9776
- debugpoint4.material = new cMaterial();
9777
- debugpoint4.material.color = 0f;
9778
- debugpoint4.material.modulation = 0.75f;
11742
+ debugpointR.radius = radius;
11743
+ debugpointR.recalculate();
11744
+ debugpointR.material = new cMaterial();
11745
+ debugpointR.material.color = 0f; // Red
11746
+ debugpointR.material.modulation = 0.75f;
977911747
978011748 InitPoints(radius);
978111749 }
978211750 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);
11751
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
11752
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
11753
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
11754
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
978711755 // DrawPoints(this);
978811756 }
978911757
....@@ -9791,42 +11759,63 @@
979111759 }
979211760 // GrafreeD.traceoff();
979311761 //System.out.println(stackdepth);
9794
- if (drawMode == 0)
11762
+ if (DrawMode() == 0)
979511763 {
979611764 ReleaseTextures(DEFAULT_TEXTURES);
979711765
979811766 if (CLEANCACHE)
9799
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
980011768 {
9801
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
980211770
980311771 // System.out.println("Texture --------- " + tex);
980411772
9805
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
980611774 continue;
980711775
9808
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
980911777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
981011779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
9811
- textures.get(tex).texture.dispose();
9812
- textures.remove(tex);
11780
+ if (gettex != null)
11781
+ {
11782
+ gettex.texture.dispose();
11783
+ texturepigment.remove(tex);
11784
+ }
11785
+
11786
+ gettex = texturebump.get(tex);
11787
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11788
+ if (gettex != null)
11789
+ {
11790
+ gettex.texture.dispose();
11791
+ texturebump.remove(tex);
11792
+ }
981311793 }
981411794 }
981511795 }
981611796
981711797 checker = null;
981811798
9819
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
11799
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
982011800 FindChecker(object);
982111801
9822
- if (checker != null && drawMode == DEFAULT)
11802
+ if (checker != null && DrawMode() == DEFAULT)
982311803 {
9824
- // BindTexture(IMMORTAL_TEXTURE);
11804
+ //BindTexture(IMMORTAL_TEXTURE);
11805
+ try
11806
+ {
11807
+ BindTextures(checker.GetTextures(), checker.texres);
11808
+ }
11809
+ catch (Exception e)
11810
+ {
11811
+ System.err.println("FAILED: " + checker.GetTextures());
11812
+ }
982511813 // NEAREST
982611814 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
982711815 DrawChecker(gl);
982811816 //checker.Draw(this, null, false);
982911817 // ReleaseTexture(IMMORTAL_TEXTURE);
11818
+ ReleaseTextures(checker.GetTextures());
983011819 }
983111820
983211821 if (object.parent != null)
....@@ -9839,7 +11828,7 @@
983911828 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
984011829 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
984111830
9842
- if (DISPLAYTEXT && drawMode == DEFAULT)
11831
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
984311832 {
984411833 // Draw it once, then use the raster
984511834 Balloon(gl, balloon.createGraphics());
....@@ -9895,14 +11884,14 @@
989511884 int[] xs = new int[3];
989611885 int[] ys = new int[3];
989711886
9898
- void DrawString(Object3D obj) // String string)
11887
+ public void DrawString(Object3D obj) // String string) // INTERFACE
989911888 {
9900
- if (!DISPLAYTEXT || drawMode != DEFAULT)
11889
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
990111890 {
990211891 return;
990311892 }
990411893
9905
- String string = obj.GetToolTip();
11894
+ String string = obj.toString(); //.GetToolTip();
990611895
990711896 GL gl = GetGL();
990811897
....@@ -10219,8 +12208,8 @@
1021912208 //obj.TransformToWorld(light, light);
1022012209 for (int i = tp.size(); --i >= 0;)
1022112210 {
10222
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
10223
- LA.xformPos(light, tp.get(i).toParent, light);
12211
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12212
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1022412213 }
1022512214
1022612215
....@@ -10237,8 +12226,8 @@
1023712226 parentcam = cameras[0];
1023812227 }
1023912228
10240
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10241
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12229
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12230
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1024212231
1024312232 LA.xformPos(light, renderCamera.toScreen, light);
1024412233
....@@ -10357,11 +12346,13 @@
1035712346 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1035812347 "PARAM params7 = program.env[7];" + // noise power, opacity power
1035912348 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10360
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
12349
+ "PARAM options1 = program.env[62];" + // fog rgb color
12350
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1036112351 "PARAM pointlight = program.env[127];" + // ...
1036212352 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1036312353 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1036412354 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
12355
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1036512356 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1036612357 "PARAM ten = { 10, 10, 10, 1.0 };" +
1036712358 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10382,6 +12373,7 @@
1038212373 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038312374 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1038412375 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
12376
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1038512377 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1038612378 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1038712379 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -10422,6 +12414,10 @@
1042212414 "TEMP R1;" +
1042312415 "TEMP R2;" +
1042412416 "TEMP R3;" +
12417
+ "TEMP min;" +
12418
+ "TEMP max;" +
12419
+ "TEMP average;" +
12420
+ "TEMP saturation;" +
1042512421 "TEMP keep1;" +
1042612422 "TEMP keep2;" +
1042712423 "TEMP keep3;" +
....@@ -10845,8 +12841,8 @@
1084512841
1084612842 // display shadow only (bump == 0)
1084712843 "SUB temp.x, half.x, shadow.x;" +
10848
- "MOV temp.y, -params6.x;" +
10849
- "SLT temp.z, temp.y, zero.x;" +
12844
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12845
+ "SLT temp.z, temp.y, -one2048th.x;" +
1085012846 "SUB temp.y, one.x, temp.z;" +
1085112847 "MUL temp.x, temp.x, temp.y;" +
1085212848 "KIL temp.x;" +
....@@ -10952,10 +12948,42 @@
1095212948
1095312949 // skin?
1095412950 // Saturation for skin
10955
- /**/ // c'est ici
10956
- (Skinshader? "DP3 temp.x, final,one;" +
12951
+ /**/
12952
+ (Skinshader?
12953
+ "DP3 average.x, final,one;" +
12954
+ "MUL average, one3rd.xxxx,average.xxxx;" +
12955
+
12956
+ "MIN min.x, final.x,final.y;" +
12957
+ "MIN min.x, min.x,final.z;" +
12958
+
12959
+ "MAX max.x, final.x,final.y;" +
12960
+ "MAX max.x, max.x,final.z;" +
12961
+ "MOV max, max.xxxx;" +
12962
+
12963
+ "SUB saturation, max, final;" +
12964
+
12965
+ "ADD temp.x, max.x, one10th.x;" +
12966
+ "RCP temp.x, temp.x;" +
12967
+ "MUL temp.x, temp.x, half.x;" +
12968
+ "MUL saturation, saturation, temp.xxxx;" +
12969
+
12970
+ "DP3 ndotl.x, normald, light;" +
12971
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
12972
+
12973
+ "SUB temp.x, one.x, ndotl.x;" +
12974
+ // Tuning for default skin
12975
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12976
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12977
+ "ADD temp.y, one.y, options2.y;" + // subsurface
12978
+ "MUL temp.x, temp.x, temp.y;" +
12979
+
12980
+ "MUL saturation, saturation, temp.xxxx;" +
12981
+ "SUB_SAT temp, max, saturation;" +
12982
+/**
12983
+ "DP3 temp.x, final,one;" +
1095712984 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10958
- "SUB temp, final,R2;" +
12985
+ "SUB temp, final, R2;" +
12986
+
1095912987 // using light angle
1096012988 "DP3 ndotl.x, normald,light;" +
1096112989 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10968,7 +12996,6 @@
1096812996 // using light intensity
1096912997 "MOV ndotl.z, R2.x;" +
1097012998 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10971
-
1097212999 // june 2014
1097313000 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1097413001 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10980,6 +13007,7 @@
1098013007 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1098113008
1098213009 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
13010
+/**/
1098313011
1098413012 // "ADD final, R2,temp;" +
1098513013 "MOV final, temp;"
....@@ -11069,7 +13097,7 @@
1106913097 /**/
1107013098 // HDR
1107113099 "MOV temp.z, final.a;" +
11072
- "MUL final, final,options1.w;" +
13100
+ "MUL final, final,options2.x;" +
1107313101 "MOV final.a, temp.z;" +
1107413102 /**/
1107513103
....@@ -11145,7 +13173,7 @@
1114513173 //once = true;
1114613174 }
1114713175
11148
- System.out.print("Program #" + mode + "; length = " + program.length());
13176
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1114913177 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1115013178 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1115113179
....@@ -11262,6 +13290,7 @@
1126213290 String Shadow(String depth, String shadow)
1126313291 {
1126413292 return "MAX temp.x, ndotl.x, one64th.x;" +
13293
+ "MIN temp.x, temp.x, ninetenth.x;" +
1126513294 /**/
1126613295 // Sine
1126713296 "MUL temp.y, temp.x, temp.x;" +
....@@ -11277,12 +13306,16 @@
1127713306
1127813307 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1127913308 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13309
+
13310
+ // Compare fragment depth in light space with shadowmap.
1128013311 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1128113312 "SGE temp.y, temp.x, zero.x;" +
11282
- "SUB " + shadow + ".y, one.x, temp.y;" +
13313
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13314
+
13315
+ // Reverse comparison
1128313316 "SUB temp.x, one.x, temp.x;" +
1128413317 "MUL " + shadow + ".x, temp.x, temp.y;" +
11285
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13318
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1128613319 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1128713320
1128813321 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -11296,6 +13329,10 @@
1129613329 // No shadow for backface
1129713330 "DP3 temp.x, normal, lightd;" +
1129813331 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13332
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13333
+
13334
+ // No shadow when out of frustrum
13335
+ "SGE temp.x, " + depth + ".z, one.z;" +
1129913336 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1130013337 "";
1130113338 }
....@@ -11442,7 +13479,8 @@
1144213479 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1144313480 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1144413481 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
11445
- Object3D.cVector2[] vector2buffer;
13482
+
13483
+ //Object3D.cVector2[] vector2buffer;
1144613484
1144713485 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1144813486 // OUT : diff, spec
....@@ -11458,9 +13496,10 @@
1145813496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1145913497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1146013498 //"MOV " + dest + ".w," + "normal.z;" +
11461
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
11462
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
11463
- //"MOV " + dest + ".z," + "params2.w;" +
13499
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13500
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13501
+
13502
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1146413503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1146513504 "RCP " + dest + ".w," + dest + ".w;" +
1146613505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -11854,7 +13893,7 @@
1185413893 public void mousePressed(MouseEvent e)
1185513894 {
1185613895 //System.out.println("mousePressed: " + e);
11857
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13896
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1185813897 }
1185913898
1186013899 static long prevtime = 0;
....@@ -11881,14 +13920,16 @@
1188113920
1188213921 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1188313922
13923
+ if (BUTTONLESSWHEEL)
1188413924 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1188513925 {
1188613926 return;
1188713927 }
1188813928
13929
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1188913930
1189013931 // TIMER
11891
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0) // VR
13932
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1189213933 {
1189313934 keepboxmode = BOXMODE;
1189413935 keepsupport = SUPPORT;
....@@ -11928,8 +13969,8 @@
1192813969 // mode |= META;
1192913970 //}
1193013971
11931
- SetMouseMode(WHEEL | e.getModifiersEx());
11932
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13972
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13973
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1193313974 anchorX = ax;
1193413975 anchorY = ay;
1193513976 prevX = px;
....@@ -11963,6 +14004,7 @@
1196314004 else
1196414005 if (evt.getSource() == AAtimer)
1196514006 {
14007
+ Globals.TIMERRUNNING = false;
1196614008 if (mouseDown)
1196714009 {
1196814010 //new Exception().printStackTrace();
....@@ -11988,6 +14030,10 @@
1198814030 // LIVE = waslive;
1198914031 // wasliveok = true;
1199014032 // waslive = false;
14033
+
14034
+ // May 2019 Forget it:
14035
+ if (true)
14036
+ return;
1199114037
1199214038 // source == timer
1199314039 if (mouseDown)
....@@ -12017,8 +14063,8 @@
1201714063 // ObjEditor.tweenManager.update(1f / 60f);
1201814064
1201914065 // fev 2014???
12020
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
12021
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14066
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1202214068 pingthread.StepToTarget(true); // true);
1202314069 }
1202414070 // if (!LIVE)
....@@ -12027,12 +14073,13 @@
1202714073
1202814074 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1202914075
12030
- void clickStart(int x, int y, int modifiers)
14076
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1203114077 {
1203214078 if (!wasliveok)
1203314079 return;
1203414080
1203514081 AAtimer.restart(); //
14082
+ Globals.TIMERRUNNING = true;
1203614083
1203714084 // waslive = LIVE;
1203814085 // LIVE = false;
....@@ -12044,7 +14091,7 @@
1204414091 // touched = true; // main DL
1204514092 if (isRenderer)
1204614093 {
12047
- SetMouseMode(modifiers);
14094
+ SetMouseMode(modifiers, modifiersex);
1204814095 }
1204914096
1205014097 selectX = anchorX = x;
....@@ -12057,7 +14104,7 @@
1205714104 clicked = true;
1205814105 hold = false;
1205914106
12060
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14107
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1206114108 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1206214109 {
1206314110 // System.out.println("RESTART II " + modifiers);
....@@ -12088,7 +14135,7 @@
1208814135 info.camera = renderCamera;
1208914136 info.x = x;
1209014137 info.y = y;
12091
- info.modifiers = modifiers;
14138
+ info.modifiers = modifiersex;
1209214139 editObj = object.doEditClick(info, 0);
1209314140 if (!editObj)
1209414141 {
....@@ -12105,11 +14152,14 @@
1210514152
1210614153 public void mouseDragged(MouseEvent e)
1210714154 {
14155
+ Globals.MOUSEDRAGGED = true;
14156
+
14157
+ //System.out.println("mouseDragged: " + e);
1210814158 if (isRenderer)
1210914159 movingcamera = true;
14160
+
1211014161 //if (drawing)
1211114162 //return;
12112
- //System.out.println("mouseDragged: " + e);
1211314163 if ((e.getModifiersEx() & CTRL) != 0
1211414164 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1211514165 {
....@@ -12117,7 +14167,7 @@
1211714167 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1211814168 }
1211914169 else
12120
- drag(e.getX(), e.getY(), e.getModifiersEx());
14170
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1212114171
1212214172 //try { Thread.sleep(1); } catch (Exception ex) {}
1212314173 }
....@@ -12129,6 +14179,11 @@
1212914179 cVector tmp = new cVector();
1213014180 cVector tmp2 = new cVector();
1213114181 boolean isMoving;
14182
+
14183
+ public cVector TargetLookAt()
14184
+ {
14185
+ return targetLookAt;
14186
+ }
1213214187
1213314188 class PingThread extends Thread
1213414189 {
....@@ -12268,7 +14323,7 @@
1226814323 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1226914324 if (lightMode)
1227014325 {
12271
- lighttouched = true;
14326
+ Globals.lighttouched = true;
1227214327 }
1227314328
1227414329 if (OEILONCE && OEIL)
....@@ -12285,6 +14340,7 @@
1228514340
1228614341 public void run()
1228714342 {
14343
+ new Exception().printStackTrace();
1228814344 System.exit(0);
1228914345 for (;;)
1229014346 {
....@@ -12326,7 +14382,7 @@
1232614382 mouseDown = false;
1232714383 if (lightMode)
1232814384 {
12329
- lighttouched = true;
14385
+ Globals.lighttouched = true;
1233014386 }
1233114387 repaint();
1233214388 alreadypainted = true;
....@@ -12334,7 +14390,7 @@
1233414390 isMoving = false;
1233514391 } //??
1233614392
12337
- if (isLIVE() && !alreadypainted)
14393
+ if (Globals.isLIVE() && !alreadypainted)
1233814394 {
1233914395 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1234014396 repaint();
....@@ -12346,9 +14402,9 @@
1234614402 {
1234714403 if (lightMode)
1234814404 {
12349
- lighttouched = true;
14405
+ Globals.lighttouched = true;
1235014406 }
12351
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14407
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1235214408 }
1235314409 //else
1235414410 }
....@@ -12362,12 +14418,12 @@
1236214418 void GoDown(int mod)
1236314419 {
1236414420 MODIFIERS |= COMMAND;
12365
- /*
14421
+ /**/
1236614422 if((mod&SHIFT) == SHIFT)
1236714423 manipCamera.RotatePosition(0, -speed);
1236814424 else
12369
- manipCamera.BackForth(0, -speed*delta, getWidth());
12370
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1237114427 if ((mod & SHIFT) == SHIFT)
1237214428 {
1237314429 mouseMode = mouseMode; // VR??
....@@ -12383,12 +14439,12 @@
1238314439 void GoUp(int mod)
1238414440 {
1238514441 MODIFIERS |= COMMAND;
12386
- /*
14442
+ /**/
1238714443 if((mod&SHIFT) == SHIFT)
1238814444 manipCamera.RotatePosition(0, speed);
1238914445 else
12390
- manipCamera.BackForth(0, speed*delta, getWidth());
12391
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1239214448 if ((mod & SHIFT) == SHIFT)
1239314449 {
1239414450 mouseMode = mouseMode;
....@@ -12404,12 +14460,12 @@
1240414460 void GoLeft(int mod)
1240514461 {
1240614462 MODIFIERS |= COMMAND;
12407
- /*
14463
+ /**/
1240814464 if((mod&SHIFT) == SHIFT)
12409
- manipCamera.RotatePosition(speed, 0);
12410
- else
1241114465 manipCamera.Translate(speed*delta, 0, getWidth());
12412
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1241314469 if ((mod & SHIFT) == SHIFT)
1241414470 {
1241514471 mouseMode = mouseMode;
....@@ -12425,12 +14481,12 @@
1242514481 void GoRight(int mod)
1242614482 {
1242714483 MODIFIERS |= COMMAND;
12428
- /*
14484
+ /**/
1242914485 if((mod&SHIFT) == SHIFT)
12430
- manipCamera.RotatePosition(-speed, 0);
12431
- else
1243214486 manipCamera.Translate(-speed*delta, 0, getWidth());
12433
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1243414490 if ((mod & SHIFT) == SHIFT)
1243514491 {
1243614492 mouseMode = mouseMode;
....@@ -12448,7 +14504,7 @@
1244814504 int X, Y;
1244914505 boolean SX, SY;
1245014506
12451
- void drag(int x, int y, int modifiers)
14507
+ void drag(int x, int y, int modifiers, int modifiersex)
1245214508 {
1245314509 if (IsFrozen())
1245414510 {
....@@ -12457,17 +14513,17 @@
1245714513
1245814514 drag = true; // NEW
1245914515
12460
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14516
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1246114517
1246214518 X = x;
1246314519 Y = y;
1246414520 // floating state for animation
12465
- MODIFIERS = modifiers;
12466
- modifiers &= ~1024;
14521
+ MODIFIERS = modifiersex;
14522
+ modifiersex &= ~1024;
1246714523 if (false) // modifiers != 0)
1246814524 {
1246914525 //new Exception().printStackTrace();
12470
- System.out.println("mouseDragged: " + modifiers);
14526
+ System.out.println("mouseDragged: " + modifiersex);
1247114527 System.out.println("SHIFT = " + SHIFT);
1247214528 System.out.println("CONTROL = " + COMMAND);
1247314529 System.out.println("META = " + META);
....@@ -12487,7 +14543,8 @@
1248714543 info.camera = renderCamera;
1248814544 info.x = x;
1248914545 info.y = y;
12490
- object.editWindow.copy.doEditDrag(info);
14546
+ object.GetWindow().copy
14547
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1249114548 } else
1249214549 {
1249314550 if (x < startX)
....@@ -12589,6 +14646,7 @@
1258914646 {
1259014647 manipCamera.Translate(dx, dy, getWidth());
1259114648 }
14649
+ else
1259214650 if ((mouseMode & ZOOM) == 0 && (mouseMode & VR) != 0)
1259314651 {
1259414652 manipCamera.RotateInterest(dx, dy);
....@@ -12599,7 +14657,7 @@
1259914657
1260014658 if (manipCamera == lightCamera)
1260114659 {
12602
- lighttouched = true;
14660
+ Globals.lighttouched = true;
1260314661 }
1260414662 /*
1260514663 switch (mode)
....@@ -12638,7 +14696,6 @@
1263814696 public void mouseMoved(MouseEvent e)
1263914697 {
1264014698 //System.out.println("mouseMoved: " + e);
12641
-
1264214699 if (isRenderer)
1264314700 return;
1264414701
....@@ -12651,7 +14708,9 @@
1265114708 ci.camera = renderCamera;
1265214709 if (!isRenderer)
1265314710 {
12654
- if (object.editWindow.copy.doEditClick(ci, 0))
14711
+ //ObjEditor editWindow = object.editWindow;
14712
+ //Object3D copy = editWindow.copy;
14713
+ if (object.doEditClick(ci, 0))
1265514714 {
1265614715 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1265714716 } else
....@@ -12663,7 +14722,11 @@
1266314722
1266414723 public void mouseReleased(MouseEvent e)
1266514724 {
14725
+ Globals.MOUSEDRAGGED = false;
14726
+
1266614727 movingcamera = false;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1266714730 //System.out.println("mouseReleased: " + e);
1266814731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1266914732 }
....@@ -12686,9 +14749,9 @@
1268614749 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1268714750 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1268814751
12689
- if (control || command || IsFrozen())
14752
+// No delay if (control || command || IsFrozen())
1269014753 timeout = true;
12691
- else
14754
+// ?? May 2019 else
1269214755 // timer.setDelay((modifiers & 128) != 0?0:350);
1269314756 mouseDown = false;
1269414757 if (!control && !command) // june 2013
....@@ -12798,7 +14861,7 @@
1279814861 System.out.println("keyReleased: " + e);
1279914862 }
1280014863
12801
- void SetMouseMode(int modifiers)
14864
+ void SetMouseMode(int modifiers, int modifiersex)
1280214865 {
1280314866 //System.out.println("SetMouseMode = " + modifiers);
1280414867 //modifiers &= ~1024;
....@@ -12810,24 +14873,27 @@
1281014873 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1281114874 // return;
1281214875 //System.out.println("SetMode = " + modifiers);
12813
- if ((modifiers & WHEEL) == WHEEL)
14876
+ if ((modifiersex & WHEEL) == WHEEL)
1281414877 {
1281514878 mouseMode |= ZOOM;
1281614879 }
12817
- if ((modifiers & META) == META)
14880
+
14881
+ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14882
+ if (capsLocked) // || (modifiers & META) == META)
1281814883 {
1281914884 mouseMode |= VR; // BACKFORTH;
1282014885 }
12821
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
12822
- {
12823
- mouseMode |= SELECT; // BACKFORTH;
12824
- }
12825
- if ((modifiers & COMMAND) == COMMAND)
14886
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1282614887 {
1282714888 mouseMode |= SELECT;
1282814889 }
12829
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14890
+ if ((modifiersex & COMMAND) == COMMAND)
1283014891 {
14892
+ mouseMode |= SELECT;
14893
+ }
14894
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
14895
+ {
14896
+ mouseMode &= ~VR;
1283114897 mouseMode |= TRANSLATE;
1283214898 }
1283314899 // if ((modifiers & SHIFT_META) == SHIFT_META)
....@@ -12854,10 +14920,10 @@
1285414920
1285514921 if (isRenderer) //
1285614922 {
12857
- SetMouseMode(modifiers);
14923
+ SetMouseMode(0, modifiers);
1285814924 }
1285914925
12860
- theRenderer.keyPressed(key);
14926
+ Globals.theRenderer.keyPressed(key);
1286114927 }
1286214928
1286314929 int kompactbit = 4; // power bit
....@@ -12869,7 +14935,7 @@
1286914935 float SATPOW = 1; // 2; // 0.5f;
1287014936 float BRIPOW = 1; // 0.5f; // 0.5f;
1287114937
12872
- void keyPressed(int key)
14938
+ public void keyPressed(int key)
1287314939 {
1287414940 if (key >= '0' && key <= '5')
1287514941 clampbit = (key-'0');
....@@ -12916,7 +14982,8 @@
1291614982 // break;
1291714983 case 'T':
1291814984 CACHETEXTURE ^= true;
12919
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1292014987 // repaint();
1292114988 break;
1292214989 case 'Y':
....@@ -12984,7 +15051,7 @@
1298415051 case 'B':
1298515052 BRISMOOTH ^= true;
1298615053 SHADOWCULLFACE ^= true;
12987
- lighttouched = true;
15054
+ Globals.lighttouched = true;
1298815055 repaint();
1298915056 break;
1299015057 case 'b':
....@@ -13001,7 +15068,9 @@
1300115068 case 'E' : COMPACT ^= true;
1300215069 repaint();
1300315070 break;
13004
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1300515074 repaint();
1300615075 break;
1300715076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -13026,8 +15095,8 @@
1302615095 RevertCamera();
1302715096 repaint();
1302815097 break;
13029
- case 'L':
1303015098 case 'l':
15099
+ //case 'L':
1303115100 if (lightMode)
1303215101 {
1303315102 lightMode = false;
....@@ -13084,7 +15153,7 @@
1308415153 repaint();
1308515154 break;
1308615155 case 'O':
13087
- drawMode = OCCLUSION;
15156
+ Globals.drawMode = OCCLUSION; // WARNING
1308815157 repaint();
1308915158 break;
1309015159 case 'o':
....@@ -13170,12 +15239,12 @@
1317015239 case '_':
1317115240 kompactbit = 5;
1317215241 break;
13173
- case '+':
13174
- kompactbit = 6;
13175
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1317615245 case ' ':
1317715246 lightMode ^= true;
13178
- lighttouched = true;
15247
+ Globals.lighttouched = true;
1317915248 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1318015249 targetLookAt.set(manipCamera.lookAt);
1318115250 repaint();
....@@ -13184,14 +15253,15 @@
1318415253 case ESC:
1318515254 RENDERPROGRAM += 1;
1318615255 RENDERPROGRAM %= 3;
15256
+
1318715257 repaint();
1318815258 break;
1318915259 case 'Z':
13190
- RESIZETEXTURE ^= true;
13191
- break;
15260
+ //RESIZETEXTURE ^= true;
15261
+ //break;
1319215262 case 'z':
13193
- RENDERSHADOW ^= true;
13194
- lighttouched = true;
15263
+ Globals.RENDERSHADOW ^= true;
15264
+ Globals.lighttouched = true;
1319515265 repaint();
1319615266 break;
1319715267 //case UP:
....@@ -13217,13 +15287,15 @@
1321715287 FlipTransform();
1321815288 break;
1321915289 case ENTER:
13220
- object.editWindow.ScreenFit(); // Edit();
15290
+ // object.editWindow.ScreenFit(); // Edit();
15291
+ ToggleLive();
1322115292 break;
1322215293 case DELETE:
1322315294 ClearSelection();
1322415295 break;
13225
- /*
1322615296 case '+':
15297
+
15298
+ /*
1322715299 //fontsize += 1;
1322815300 bbzoom *= 2;
1322915301 repaint();
....@@ -13240,17 +15312,17 @@
1324015312 case '=':
1324115313 IncDepth();
1324215314 //fontsize += 1;
13243
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1324415316 maskbit = 6;
1324515317 break;
1324615318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1324715319 DecDepth();
1324815320 maskbit = 5;
1324915321 //if(fontsize > 1) fontsize -= 1;
13250
- if (object.editWindow == null)
13251
- new Exception().printStackTrace();
13252
- else
13253
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1325415326 break;
1325515327 case '{':
1325615328 manipCamera.shaper_fovy /= 1.1;
....@@ -13305,6 +15377,7 @@
1330515377 }
1330615378 //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
1330715379 }
15380
+
1330815381 static double OCCLUSIONBOOST = 1; // 0.5;
1330915382
1331015383 void keyReleased(int key, int modifiers)
....@@ -13312,11 +15385,11 @@
1331215385 //mode = ROTATE;
1331315386 if ((MODIFIERS & COMMAND) == 0) // VR??
1331415387 {
13315
- SetMouseMode(modifiers);
15388
+ SetMouseMode(0, modifiers);
1331615389 }
1331715390 }
1331815391
13319
- protected void processKeyEvent(KeyEvent e)
15392
+ public void processKeyEvent(KeyEvent e)
1332015393 {
1332115394 switch (e.getID())
1332215395 {
....@@ -13446,8 +15519,9 @@
1344615519
1344715520 protected void processMouseMotionEvent(MouseEvent e)
1344815521 {
13449
- //System.out.println("processMouseMotionEvent: " + mouseMode);
13450
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15522
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15523
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15524
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1345115525 {
1345215526 mouseMoved(e);
1345315527 } else
....@@ -13472,11 +15546,12 @@
1347215546 }
1347315547 */
1347415548
13475
- object.editWindow.EditSelection();
15549
+ object.GetWindow().EditSelection(false);
1347615550 }
1347715551
1347815552 void SelectParent()
1347915553 {
15554
+ new Exception().printStackTrace();
1348015555 System.exit(0);
1348115556 Composite group = (Composite) object;
1348215557 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -13488,10 +15563,10 @@
1348815563 {
1348915564 //selectees.remove(i);
1349015565 System.out.println("select parent of " + elem);
13491
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1349215567 } else
1349315568 {
13494
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1349515570 }
1349615571
1349715572 first = false;
....@@ -13500,6 +15575,7 @@
1350015575
1350115576 void SelectChildren()
1350215577 {
15578
+ new Exception().printStackTrace();
1350315579 System.exit(0);
1350415580 /*
1350515581 Composite group = (Composite) object;
....@@ -13532,12 +15608,12 @@
1353215608 for (int j = 0; j < group.children.size(); j++)
1353315609 {
1353415610 elem = (Object3D) group.children.elementAt(j);
13535
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1353615612 first = false;
1353715613 }
1353815614 } else
1353915615 {
13540
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1354115617 }
1354215618
1354315619 first = false;
....@@ -13548,21 +15624,21 @@
1354815624 {
1354915625 //Composite group = (Composite) object;
1355015626 Object3D group = object;
13551
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1355215628 }
1355315629
1355415630 void ResetTransform(int mask)
1355515631 {
1355615632 //Composite group = (Composite) object;
1355715633 Object3D group = object;
13558
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1355915635 }
1356015636
1356115637 void FlipTransform()
1356215638 {
1356315639 //Composite group = (Composite) object;
1356415640 Object3D group = object;
13565
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1356615642 // group.editWindow.ReduceMesh(true);
1356715643 }
1356815644
....@@ -13570,7 +15646,7 @@
1357015646 {
1357115647 //Composite group = (Composite) object;
1357215648 Object3D group = object;
13573
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1357415650 // group.editWindow.ReduceMesh(true);
1357515651 }
1357615652
....@@ -13578,7 +15654,7 @@
1357815654 {
1357915655 //Composite group = (Composite) object;
1358015656 Object3D group = object;
13581
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1358215658 }
1358315659
1358415660 void IncDepth()
....@@ -13664,7 +15740,9 @@
1366415740 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1366515741 //Image img = CreateImage(width, height);
1366615742 //System.out.println("width = " + width + "; height = " + height + "\n");
15743
+
1366715744 Graphics gr = g; // img.getGraphics();
15745
+
1366815746 if (!hasMarquee)
1366915747 {
1367015748 if (Xmin < Xmax) // !locked)
....@@ -13752,6 +15830,7 @@
1375215830 info.bounds.y += (height - desired) / 2;
1375315831 }
1375415832 }
15833
+
1375515834 info.g = gr;
1375615835 info.camera = renderCamera;
1375715836 /*
....@@ -13761,15 +15840,55 @@
1376115840 */
1376215841 if (!isRenderer)
1376315842 {
13764
- object.drawEditHandles(info, 0);
15843
+ Grafreed.Assert(object != null);
15844
+ Grafreed.Assert(object.selection != null);
15845
+ if (object.selection.Size() > 0)
15846
+ {
15847
+ int hitSomething = object.selection.get(0).hitSomething;
15848
+
15849
+ info.DX = 0;
15850
+ info.DY = 0;
15851
+ info.W = 1;
15852
+ if (hitSomething == Object3D.hitCenter)
15853
+ {
15854
+ info.DX = X;
15855
+ if (X != 0)
15856
+ info.DX -= info.bounds.width/2;
15857
+
15858
+ info.DY = Y;
15859
+ if (Y != 0)
15860
+ info.DY -= info.bounds.height/2;
15861
+ }
15862
+
15863
+ object.drawEditHandles(info, 0);
15864
+
15865
+ if (drag && (X != 0 || Y != 0))
15866
+ {
15867
+ switch (hitSomething)
15868
+ {
15869
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15870
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15871
+ break;
15872
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15873
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15874
+ break;
15875
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15876
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15877
+ break;
15878
+ }
15879
+
15880
+ }
15881
+ }
1376515882 }
1376615883 }
15884
+
1376715885 if (isRenderer)
1376815886 {
1376915887 //gr.setColor(Color.black);
1377015888 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1377115889 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1377215890 }
15891
+
1377315892 if (hasMarquee)
1377415893 {
1377515894 gr.setXORMode(Color.white);
....@@ -13792,6 +15911,7 @@
1379215911 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1379315912 }
1379415913
15914
+ // To avoid clear.
1379515915 public void update(Graphics g)
1379615916 {
1379715917 paint(g);
....@@ -13881,6 +16001,7 @@
1388116001 public boolean mouseDown(Event evt, int x, int y)
1388216002 {
1388316003 System.out.println("mouseDown: " + evt);
16004
+ System.exit(0);
1388416005 /*
1388516006 locked = true;
1388616007 drag = false;
....@@ -13924,7 +16045,7 @@
1392416045 {
1392516046 keyPressed(0, modifiers);
1392616047 }
13927
- clickStart(x, y, modifiers);
16048
+ // clickStart(x, y, modifiers);
1392816049 return true;
1392916050 }
1393016051
....@@ -14042,7 +16163,7 @@
1404216163 {
1404316164 keyReleased(0, 0);
1404416165 }
14045
- drag(x, y, modifiers);
16166
+ drag(x, y, 0, modifiers);
1404616167 return true;
1404716168 }
1404816169
....@@ -14174,7 +16295,7 @@
1417416295 Object3D object;
1417516296 static Object3D trackedobject;
1417616297 Camera renderCamera; // Light or Eye (or Occlusion)
14177
- /*static*/ Camera manipCamera; // Light or Eye
16298
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1417816299 /*static*/ Camera eyeCamera;
1417916300 /*static*/ Camera lightCamera;
1418016301 int cameracount;
....@@ -14394,7 +16515,7 @@
1439416515 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1439516516 gl.glPushMatrix();
1439616517 gl.glLoadIdentity();
14397
- PushMatrix(checker.toParent);
16518
+ //PushMatrix(checker.toParent);
1439816519
1439916520 gl.glMatrixMode(GL.GL_TEXTURE);
1440016521 gl.glPushMatrix();
....@@ -14417,8 +16538,8 @@
1441716538
1441816539 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1441916540
14420
- float step = 0.1666f; //0.25f;
14421
- float stepv = step * 1652 / 998;
16541
+ float step = 2; // 0.1666f; //0.25f;
16542
+ float stepv = 2; // step * 1652 / 998;
1442216543
1442316544 int i0 = 0;
1442416545 /*
....@@ -14454,20 +16575,21 @@
1445416575 /**/
1445516576 //checker.GetMaterial().opacity = 1.1f;
1445616577 ////checker.GetMaterial().ambient = 0.99f;
14457
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14458
- Object3D.selectedstack[Object3D.materialdepth] = false;
14459
- cStatic.objectstack[Object3D.materialdepth++] = checker;
16578
+ materialstack[materialdepth] = checker.material;
16579
+ selectedstack[materialdepth] = false;
16580
+ cStatic.objectstack[materialdepth++] = checker;
1446016581 //System.out.println("material " + material);
1446116582 //Applet3D.tracein(this, selected);
14462
- vector2buffer = checker.projectedVertices;
16583
+ //vector2buffer = checker.projectedVertices;
1446316584
14464
- checker.GetMaterial().Draw(this, false); // true);
16585
+ //checker.GetMaterial().Draw(this, false); // true);
16586
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1446516587
14466
- Object3D.materialdepth -= 1;
14467
- if (Object3D.materialdepth > 0)
16588
+ materialdepth -= 1;
16589
+ if (materialdepth > 0)
1446816590 {
14469
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14470
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
16591
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16592
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1447116593 }
1447216594 //checker.GetMaterial().opacity = 1f;
1447316595 ////checker.GetMaterial().ambient = 1f;
....@@ -14488,15 +16610,27 @@
1448816610
1448916611 //float u = (i+1)/2;
1449016612 //float v = (j+1)/2;
14491
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
16613
+ if (checker.flipV)
16614
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
16615
+ else
16616
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1449216617 gl.glVertex3f(i, j, -0.5f);
1449316618
16619
+ if (checker.flipV)
16620
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
16621
+ else
1449416622 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1449516623 gl.glVertex3f(i + step, j, -0.5f);
1449616624
16625
+ if (checker.flipV)
16626
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
16627
+ else
1449716628 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1449816629 gl.glVertex3f(i + step, j + stepv, -0.5f);
1449916630
16631
+ if (checker.flipV)
16632
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
16633
+ else
1450016634 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1450116635 gl.glVertex3f(i, j + stepv, -0.5f);
1450216636 }
....@@ -14508,7 +16642,7 @@
1450816642 gl.glMatrixMode(GL.GL_PROJECTION);
1450916643 gl.glPopMatrix();
1451016644 gl.glMatrixMode(GL.GL_MODELVIEW);
14511
- PopMatrix(null); // checker.toParent); // null);
16645
+ //PopMatrix(null); // checker.toParent); // null);
1451216646 gl.glPopMatrix();
1451316647 PopTextureMatrix(checker.toParent);
1451416648 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -14541,6 +16675,14 @@
1454116675 }
1454216676 }
1454316677
16678
+ private Object3D GetFolder()
16679
+ {
16680
+ Object3D folder = object.GetWindow().copy;
16681
+ if (object.GetWindow().copy.selection.Size() > 0)
16682
+ folder = object.GetWindow().copy.selection.elementAt(0);
16683
+ return folder;
16684
+ }
16685
+
1454416686 class SelectBuffer implements GLEventListener
1454516687 {
1454616688
....@@ -14599,6 +16741,7 @@
1459916741 {
1460016742 if (!selection)
1460116743 {
16744
+ new Exception().printStackTrace();
1460216745 System.exit(0);
1460316746 return;
1460416747 }
....@@ -14619,17 +16762,39 @@
1461916762
1462016763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1462116764
16765
+ if (PAINTMODE)
16766
+ {
16767
+ if (object.GetWindow().copy.selection.Size() > 0)
16768
+ {
16769
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16770
+
16771
+ // Make what you paint not selectable.
16772
+ paintobj.ResetSelectable();
16773
+ }
16774
+ }
16775
+
1462216776 //int tmp = selection_view;
1462316777 //selection_view = -1;
14624
- int temp = drawMode;
14625
- drawMode = SELECTION;
16778
+ int temp = DrawMode();
16779
+ Globals.drawMode = SELECTION; // WARNING
1462616780 indexcount = 0;
1462716781 parent.display(drawable);
1462816782 //selection_view = tmp;
1462916783 //if (temp == SELECTION)
1463016784 // temp = DEFAULT; // patch for selection debug
14631
- drawMode = temp;
16785
+ Globals.drawMode = temp; // WARNING
1463216786
16787
+ if (PAINTMODE)
16788
+ {
16789
+ if (object.GetWindow().copy.selection.Size() > 0)
16790
+ {
16791
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16792
+
16793
+ // Revert.
16794
+ paintobj.RestoreSelectable();
16795
+ }
16796
+ }
16797
+
1463316798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1463416799
1463516800 // trying different ways of getting the depth info over
....@@ -14678,6 +16843,13 @@
1467816843 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1467916844 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1468016845
16846
+ CreateSelectedPoint();
16847
+
16848
+ // Will fit the mesh !!!
16849
+ selectedpoint.toParent[0][0] = 0.0001;
16850
+ selectedpoint.toParent[1][1] = 0.0001;
16851
+ selectedpoint.toParent[2][2] = 0.0001;
16852
+
1468116853 glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0);
1468216854
1468316855 // if (object.selection != null && object.selection.Size() > 0)
....@@ -14721,34 +16893,36 @@
1472116893 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]));
1472216894 }
1472316895
14724
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16896
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1472516897 }
1472616898 }
1472716899
1472816900 if (!movingcamera && !PAINTMODE)
14729
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1473016902
14731
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16903
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1473216904 {
14733
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16905
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1473416906
14735
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1473616910
14737
- group.CreateMaterial(); // use a void leaf to select instances
14738
-
14739
- group.add(paintobj); // link
14740
-
14741
- object.editWindow.SnapObject(group);
14742
-
14743
- Object3D folder = object.editWindow.copy;
14744
-
14745
- if (object.editWindow.copy.selection.Size() > 0)
14746
- folder = object.editWindow.copy.selection.elementAt(0);
14747
-
14748
- folder.add(group);
14749
-
14750
- object.editWindow.ResetModel();
14751
- object.editWindow.refreshContents();
16911
+ Object3D inst = new Object3D("inst" + paintcount++);
16912
+
16913
+ inst.CreateMaterial(); // use a void leaf to select instances
16914
+
16915
+ inst.add(paintobj); // link
16916
+
16917
+ object.GetWindow().SnapObject(inst);
16918
+
16919
+ Object3D folder = paintFolder; // GetFolder();
16920
+
16921
+ folder.add(inst);
16922
+
16923
+ object.GetWindow().ResetModel();
16924
+ object.GetWindow().refreshContents();
16925
+ }
1475216926 }
1475316927 else
1475416928 paintcount = 0;
....@@ -14787,6 +16961,11 @@
1478716961 //System.out.println("objects[color] = " + objects[color]);
1478816962 //objects[color].Select();
1478916963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1479016969 object.Select(color, deselect);
1479116970 }
1479216971
....@@ -14886,7 +17065,7 @@
1488617065 gl.glDisable(gl.GL_CULL_FACE);
1488717066 }
1488817067
14889
- if (!RENDERSHADOW)
17068
+ if (!Globals.RENDERSHADOW)
1489017069 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1489117070
1489217071 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -14896,14 +17075,14 @@
1489617075 //gl.glColorMask(false, false, false, false);
1489717076
1489817077 //render_scene_from_light_view(gl, drawable, 0, 0);
14899
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
17078
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1490017079 {
1490117080 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1490217081
14903
- int temp = drawMode;
14904
- drawMode = SHADOW;
17082
+ int temp = DrawMode();
17083
+ Globals.drawMode = SHADOW; // WARNING
1490517084 parent.display(drawable);
14906
- drawMode = temp;
17085
+ Globals.drawMode = temp; // WARNING
1490717086 }
1490817087
1490917088 gl.glCullFace(gl.GL_BACK);
....@@ -14956,7 +17135,6 @@
1495617135
1495717136 class AntialiasBuffer implements GLEventListener
1495817137 {
14959
-
1496017138 CameraPane parent = null;
1496117139
1496217140 AntialiasBuffer(CameraPane p)
....@@ -15066,13 +17244,19 @@
1506617244 gl.glFlush();
1506717245
1506817246 /**/
15069
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
17247
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1507017248
15071
- int[] pixels = occlusionsizebuffer.array();
17249
+ float[] pixels = occlusionsizebuffer.array();
1507217250
1507317251 double r = 0, g = 0, b = 0;
1507417252
1507517253 double count = 0;
17254
+
17255
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
17256
+
17257
+ float mindepth = 1;
17258
+
17259
+ double FACTOR = 1;
1507617260
1507717261 for (int i = 0; i < pixels.length; i++)
1507817262 {
....@@ -15157,7 +17341,7 @@
1515717341
1515817342 double scale = ray.z; // 1; // cos
1515917343
15160
- int p = pixels[newindex];
17344
+ float depth = pixels[newindex];
1516117345
1516217346 /*
1516317347 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15181,10 +17365,23 @@
1518117365 scale = (1 - modu) * modv;
1518217366 */
1518317367
15184
- r += ((p >> 16) & 0xFF) * scale / 255;
15185
- g += ((p >> 8) & 0xFF) * scale / 255;
15186
- b += (p & 0xFF) * scale / 255;
17368
+ //r += ((p >> 16) & 0xFF) * scale / 255;
17369
+ //g += ((p >> 8) & 0xFF) * scale / 255;
17370
+ //b += (p & 0xFF) * scale / 255;
17371
+
17372
+ if (mindepth > depth)
17373
+ {
17374
+ mindepth = depth;
17375
+ }
1518717376
17377
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
17378
+
17379
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
17380
+
17381
+ r += factor * scale;
17382
+ g += factor * scale;
17383
+ b += factor * scale;
17384
+
1518817385 count += scale;
1518917386 }
1519017387
....@@ -15282,12 +17479,6 @@
1528217479 GLUT glut = new GLUT();
1528317480
1528417481
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;
1529117482 public boolean spherical = false;
1529217483 static boolean DEBUG_OCCLUSION = false;
1529317484 static boolean DEBUG_SELECTION = false;
....@@ -15300,23 +17491,15 @@
1530017491 int AAbuffersize = 0;
1530117492
1530217493 //double[] selectedpoint = new double[3];
15303
- static Sphere selectedpoint = new Sphere();
17494
+ static Superellipsoid selectedpoint;
1530417495 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();
17496
+ static Sphere debugpointG;
17497
+ static Sphere debugpointP;
17498
+ static Sphere debugpointC;
17499
+ static Sphere debugpointR;
1530917500
1531017501 static Sphere debugpoints[] = new Sphere[8];
1531117502
15312
- static
15313
- {
15314
- for (int i=0; i<8; i++)
15315
- {
15316
- debugpoints[i] = new Sphere();
15317
- }
15318
- }
15319
-
1532017503 static void InitPoints(float radius)
1532117504 {
1532217505 for (int i=0; i<8; i++)
....@@ -15336,7 +17519,7 @@
1533617519 }
1533717520 }
1533817521
15339
- static void DrawPoints(CameraPane cpane)
17522
+ static void DrawPoints(iCameraPane cpane)
1534017523 {
1534117524 for (int i=0; i<8; i++) // first and last are red
1534217525 {
....@@ -15358,7 +17541,8 @@
1535817541 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1535917542 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1536017543 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15361
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17544
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17545
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1536217546 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1536317547 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1536417548 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();
....@@ -15367,10 +17551,11 @@
1536717551 static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT);
1536817552 // Depth buffer format
1536917553 //private int depth_format;
15370
- static public void NextIndex(Object3D o, GL gl)
17554
+
17555
+ public void NextIndex()
1537117556 {
1537217557 indexcount+=16;
15373
- gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
17558
+ GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0);
1537417559 //objects[indexcount] = o;
1537517560 //System.out.println("indexcount = " + indexcount);
1537617561 }