Normand Briere
2019-04-22 91106535bc5aa5e67cbb02a67cf6de1519cba0e4
iCameraPane refactoring phase 1.
25 files modified
2 files added
2194 ■■■■■ changed files
Attribute.java 6 ●●●● patch | view | raw | blame | history
BezierPatch.java 2 ●●● patch | view | raw | blame | history
BezierSurface.java 2 ●●● patch | view | raw | blame | history
BillboardNode.java 4 ●●●● patch | view | raw | blame | history
Biparam.java 2 ●●● patch | view | raw | blame | history
BlobComponent.java 2 ●●● patch | view | raw | blame | history
BoundaryRep.java 6 ●●●● patch | view | raw | blame | history
CameraPane.java 1017 ●●●● patch | view | raw | blame | history
Composite.java 6 ●●●● patch | view | raw | blame | history
GenericJoint.java 2 ●●● patch | view | raw | blame | history
Globals.java 26 ●●●●● patch | view | raw | blame | history
GroupEditor.java 15 ●●●● patch | view | raw | blame | history
Mocap.java 8 ●●●● patch | view | raw | blame | history
MorphNode.java 2 ●●● patch | view | raw | blame | history
ObjEditor.java 5 ●●●●● patch | view | raw | blame | history
Object3D.java 524 ●●●●● patch | view | raw | blame | history
ParticleNode.java 4 ●●●● patch | view | raw | blame | history
PhysicsNode.java 2 ●●● patch | view | raw | blame | history
ScriptNode.java 6 ●●●● patch | view | raw | blame | history
SwitchNode.java 4 ●●●● patch | view | raw | blame | history
VehicleDemo.java 2 ●●● patch | view | raw | blame | history
cFileSystemPane.java 2 ●●● patch | view | raw | blame | history
cLinker.java 6 ●●●● patch | view | raw | blame | history
cMaterial.java 476 ●●●● patch | view | raw | blame | history
cMesh.java 2 ●●● patch | view | raw | blame | history
cSpring.java 8 ●●●● patch | view | raw | blame | history
iCameraPane.java 53 ●●●●● patch | view | raw | blame | history
Attribute.java
....@@ -45,13 +45,13 @@
4545 editWindow = objectUI.GetEditor();
4646 }
4747
48
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
48
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
4949 {
5050 if (hide)
5151 return;
5252
5353 // super.draw(display, root, selected);
54
- if (display.ambientOcclusion)
54
+ if (display.IsAmbientOcclusionOn())
5555 return;
5656
5757 if (cleardepth)
....@@ -64,7 +64,7 @@
6464 if (backfacecull)
6565 display.BackFaceCull(true);
6666 else
67
- display.BackFaceCull(display.CULLFACE);
67
+ display.BackFaceCull(display.BackFaceCullMode());
6868 }
6969
7070 boolean cleardepth;
BezierPatch.java
....@@ -60,7 +60,7 @@
6060 }
6161
6262 /**/
63
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
63
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6464 {
6565 //recalculate();
6666 //System.out.println();
BezierSurface.java
....@@ -67,7 +67,7 @@
6767 return l;
6868 }
6969
70
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
70
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
7171 {
7272 // ((BezierSurface)parent.parent).currentHandle = (Sphere)this;
7373 // parent.parent.recalculate();
BillboardNode.java
....@@ -21,9 +21,9 @@
2121
2222 cVector pos = new cVector();
2323
24
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
24
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
2525 {
26
- cVector eye = display.eyeCamera.location;
26
+ cVector eye = display.EyeCamera().location;
2727
2828 GlobalTransformInv();
2929
Biparam.java
....@@ -16,7 +16,7 @@
1616 CreateMaterial();
1717 }
1818
19
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
19
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
2020 {
2121 //System.out.println("#vertices = " + bRep.VertexCount());
2222 if(false)
BlobComponent.java
....@@ -140,7 +140,7 @@
140140 info.g.drawArc(spot.x + 1, spot.y + 1, spot.width - 2, spot.height - 2, 0, 360);
141141 }
142142
143
- void draw(CameraPane display, boolean selected)
143
+ void draw(iCameraPane display, boolean selected)
144144 {
145145 }
146146 */
BoundaryRep.java
....@@ -790,7 +790,7 @@
790790 v.weights[k] = other.ComputeWeight(v, toRoot, k); // (float)(supportsize * normalweight * nz / Math.pow(tx*tx+ty*ty+tz*tz, 1));
791791 v.totalweight += v.weights[k];
792792
793
- if (CameraPane.CROWD)
793
+ if (Globals.CROWD)
794794 {
795795 // System.out.print("weight = " + v.weights[k]);
796796 // System.out.println("; totalweight = " + v.totalweight);
....@@ -2668,11 +2668,11 @@
26682668 tmp.set(v);
26692669 tmp.sub(eye);
26702670
2671
- if (CameraPane.framecount - lastsoundtime > 30) // 0.25 secs
2671
+ if (Globals.framecount - lastsoundtime > 30) // 0.25 secs
26722672 {
26732673 GrafreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1);
26742674
2675
- lastsoundtime = CameraPane.framecount;
2675
+ lastsoundtime = Globals.framecount;
26762676 }
26772677
26782678 stepout = false;
CameraPane.java
....@@ -31,8 +31,12 @@
3131
3232 import gleem.linalg.Mat4f;
3333
34
-class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
34
+class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3535 {
36
+ static cMaterial[] materialstack = new cMaterial[65536];
37
+ static boolean[] selectedstack = new boolean[65536];
38
+ static int materialdepth = 0;
39
+
3640 static boolean DEBUG = false;
3741 static boolean FRUSTUM = false; // still bogus true; // frustum culling
3842
....@@ -42,25 +46,7 @@
4246
4347 static int STEP = 1;
4448
45
- static boolean ONESTEP = false; // do LIVE once
46
-
47
- /**
48
- * @return the LIVE
49
- */
50
- public static boolean isLIVE()
51
- {
52
- return LIVE || ONESTEP;
53
- }
54
-
55
- /**
56
- * @param aLIVE the LIVE to set
57
- */
58
- public static void setLIVE(boolean aLIVE)
59
- {
60
- LIVE = aLIVE;
61
- }
62
-
63
- /*static*/ boolean CULLFACE = false; // true;
49
+ /*static*/ private boolean CULLFACE = false; // true;
6450 /*static*/ boolean NEAREST = false; // true;
6551 /*static*/ boolean WIREFRAME = false; // true;
6652
....@@ -97,10 +83,8 @@
9783
9884 static boolean textureon = true;
9985 static boolean LOCALTRANSFORM = false;
100
-private static boolean LIVE = false;
10186 static boolean FULLSCREEN = false;
10287 static boolean SUPPORT = true;
103
-static boolean CROWD = false;
10488 static boolean INERTIA = true;
10589 static boolean FAST = false;
10690 static boolean SLOWPOSE = false;
....@@ -206,12 +190,14 @@
206190 return CURRENTANTIALIAS > 0;
207191 }
208192
209
- void ClearDepth()
193
+ /// INTERFACE
194
+
195
+ public void ClearDepth()
210196 {
211197 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
212198 }
213199
214
- void DepthTest(boolean depthtest)
200
+ public void DepthTest(boolean depthtest)
215201 {
216202 if (depthtest)
217203 GetGL().glDepthFunc(GL.GL_LEQUAL);
....@@ -219,7 +205,7 @@
219205 GetGL().glDepthFunc(GL.GL_ALWAYS);
220206 }
221207
222
- void DepthWrite(boolean depthwrite)
208
+ public void DepthWrite(boolean depthwrite)
223209 {
224210 if (depthwrite)
225211 GetGL().glDepthMask(true);
....@@ -227,12 +213,776 @@
227213 GetGL().glDepthMask(false);
228214 }
229215
230
- void BackFaceCull(boolean bfc)
216
+ public void BackFaceCull(boolean bfc)
231217 {
232218 if (bfc)
233219 GetGL().glEnable(GetGL().GL_CULL_FACE);
234220 else
235221 GetGL().glDisable(GetGL().GL_CULL_FACE);
222
+ }
223
+
224
+ public boolean BackFaceCullMode()
225
+ {
226
+ return this.CULLFACE;
227
+ }
228
+
229
+ public boolean IsAmbientOcclusionOn()
230
+ {
231
+ return this.ambientOcclusion;
232
+ }
233
+
234
+ public boolean IsFrozen()
235
+ {
236
+ boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
237
+
238
+ return !selectmode && cameracount == 0; // != 0;
239
+ }
240
+
241
+ // Currently in Globals
242
+ public int DrawMode()
243
+ {
244
+ return Globals.DrawMode();
245
+ }
246
+
247
+ public Camera EyeCamera()
248
+ {
249
+ return eyeCamera;
250
+ }
251
+
252
+ public Camera LightCamera()
253
+ {
254
+ return lightCamera;
255
+ }
256
+
257
+ public Camera RenderCamera()
258
+ {
259
+ return renderCamera;
260
+ }
261
+
262
+ public void PushMaterial(Object3D obj, boolean selected)
263
+ {
264
+ CameraPane display = this;
265
+ javax.media.opengl.GL gl = display.GetGL();
266
+ cMaterial material = obj.material;
267
+
268
+ if (material != null)
269
+ {
270
+ materialstack[materialdepth] = material;
271
+ selectedstack[materialdepth] = selected;
272
+ cStatic.objectstack[materialdepth++] = obj;
273
+ //System.out.println("material " + material);
274
+ //Applet3D.tracein(this, selected);
275
+ display.vector2buffer = obj.projectedVertices;
276
+ if (obj instanceof Camera)
277
+ {
278
+ display.options1[0] = material.shift;
279
+ //System.out.println("shift " + material.shift);
280
+ display.options1[1] = material.lightarea;
281
+ display.options1[2] = material.shadowbias;
282
+ display.options1[3] = material.aniso;
283
+ display.options1[4] = material.anisoV;
284
+ display.options2[0] = material.opacity;
285
+ display.options2[1] = material.diffuse;
286
+ display.options2[2] = material.factor;
287
+
288
+ cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
289
+ display.options4[0] = material.cameralight/0.2f;
290
+ display.options4[1] = material.subsurface;
291
+ display.options4[2] = material.sheen;
292
+
293
+ // if (display.CURRENTANTIALIAS > 0)
294
+ // display.options3[3] /= 4;
295
+
296
+ /*
297
+ System.out.println("Focus = " + display.options1[0]);
298
+ System.out.println("Aperture = " + display.options1[1]);
299
+ System.out.println("ShadowBlur = " + display.options1[2]);
300
+ System.out.println("Antialiasing = " + display.options1[3]);
301
+ System.out.println("Fog = " + display.options2[0]);
302
+ System.out.println("Intensity = " + display.options2[1]);
303
+ System.out.println("Elevation = " + display.options2[2]);
304
+ /**/
305
+ } else
306
+ {
307
+ DrawMaterial(material, selected);
308
+ }
309
+ } else
310
+ {
311
+ if (selected && CameraPane.flash)
312
+ {
313
+ display.modelParams4[1] = 100;
314
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
315
+ }
316
+ }
317
+ }
318
+
319
+ public void PushMaterial2(Object3D obj, boolean selected)
320
+ {
321
+ CameraPane display = this;
322
+ cMaterial material = obj.material;
323
+
324
+ if (material != null)
325
+ {
326
+ materialstack[materialdepth] = material;
327
+ selectedstack[materialdepth] = selected;
328
+ cStatic.objectstack[materialdepth++] = obj;
329
+ //System.out.println("material " + material);
330
+ //Applet3D.tracein("selected ", selected);
331
+ display.vector2buffer = obj.projectedVertices;
332
+ display.DrawMaterial(material, selected);
333
+ }
334
+ }
335
+
336
+ public void PopMaterial(Object3D obj, boolean selected)
337
+ {
338
+ CameraPane display = this;
339
+ javax.media.opengl.GL gl = display.GetGL();
340
+ cMaterial material = obj.material;
341
+
342
+ //if (parent != null && parent.GetMaterial() != null)
343
+ // parent.GetMaterial().Draw(display, parent.IsSelected(this));
344
+ if (material != null)
345
+ {
346
+ materialdepth -= 1;
347
+ if (materialdepth > 0)
348
+ {
349
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
350
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
351
+ }
352
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
353
+ } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
354
+ {
355
+ display.modelParams4[1] = obj.GetMaterial().cameralight;
356
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
357
+ }
358
+ }
359
+
360
+ public void PopMaterial2(Object3D obj)
361
+ {
362
+ CameraPane display = this;
363
+ cMaterial material = obj.material;
364
+
365
+ if (material != null)
366
+ {
367
+ materialdepth -= 1;
368
+ if (materialdepth > 0)
369
+ {
370
+ display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
371
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
372
+ }
373
+ //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
374
+ //else
375
+ //material.Draw(display, false);
376
+ }
377
+ }
378
+
379
+ public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face)
380
+ {
381
+ CameraPane display = this;
382
+
383
+ if (pv.y == -10000 ||
384
+ qv.y == -10000 ||
385
+ rv.y == -10000)
386
+ return;
387
+
388
+// float b = f.nbiterations & 1;
389
+// float g = (f.nbiterations>>1) & 1;
390
+// float r = (f.nbiterations>>2) & 1;
391
+//
392
+// //if (f.weight == 10000)
393
+// //{
394
+// // r = 1; g = b = 0;
395
+// //}
396
+// //else
397
+// //{
398
+// // assert(f.weight < 10000);
399
+// r = g = b = (float)bRep.FaceWeight(f)*100;
400
+// if (r<0)
401
+// assert(r>=0);
402
+// //}
403
+
404
+ javax.media.opengl.GL gl = display.GetGL();
405
+
406
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
407
+
408
+ //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
409
+ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
410
+ {
411
+ //gl.glBegin(gl.GL_TRIANGLES);
412
+ boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
413
+ if (!hasnorm)
414
+ {
415
+ // System.out.println("FUCK!!");
416
+ LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
417
+ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
418
+ LA.vecCross(obj.v0, obj.v1, obj.v2);
419
+ LA.vecNormalize(obj.v2);
420
+ gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
421
+ }
422
+
423
+ // P
424
+ float x = (float)pv.x;
425
+ float y = (float)pv.y;
426
+ float z = (float)pv.z;
427
+
428
+ if (hasnorm)
429
+ {
430
+// if (!pv.norm.normalized())
431
+// assert(pv.norm.normalized());
432
+
433
+ //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
434
+ float nx = (float)pv.norm.x;
435
+ float ny = (float)pv.norm.y;
436
+ float nz = (float)pv.norm.z;
437
+
438
+ x += nx * obj.NORMALPUSH;
439
+ y += ny * obj.NORMALPUSH;
440
+ z += nz * obj.NORMALPUSH;
441
+
442
+ gl.glNormal3f(nx, ny, nz);
443
+ }
444
+ gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
445
+ SetColor(obj, pv);
446
+ //gl.glColor4f(r, g, b, 1);
447
+ //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
448
+ if (obj.flipV)
449
+ gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
450
+ else
451
+ gl.glTexCoord2f((float) pv.s, (float) pv.t);
452
+ //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
453
+
454
+ gl.glVertex3f(x, y, z);
455
+
456
+ // Q
457
+ x = (float)qv.x;
458
+ y = (float)qv.y;
459
+ z = (float)qv.z;
460
+
461
+// Print(pv);
462
+ if (hasnorm)
463
+ {
464
+// assert(qv.norm.normalized());
465
+ //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
466
+ float nx = (float)qv.norm.x;
467
+ float ny = (float)qv.norm.y;
468
+ float nz = (float)qv.norm.z;
469
+
470
+ x += nx * obj.NORMALPUSH;
471
+ y += ny * obj.NORMALPUSH;
472
+ z += nz * obj.NORMALPUSH;
473
+
474
+ gl.glNormal3f(nx, ny, nz);
475
+ }
476
+ //System.out.println("vertexq = " + qv.s + ", " + qv.t);
477
+ // boolean locked = false;
478
+ // float eps = 0.1f;
479
+ // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
480
+
481
+ // int dot = 0; //*/ (int)f.dot;
482
+
483
+ // if ((dot&1) == 0)
484
+ // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
485
+
486
+ // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
487
+ if (obj.flipV)
488
+ gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
489
+ else
490
+ gl.glTexCoord2f((float) qv.s, (float) qv.t);
491
+ // else
492
+ // {
493
+ // locked = true;
494
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
495
+ // }
496
+ gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
497
+ SetColor(obj, qv);
498
+
499
+ gl.glVertex3f(x, y, z);
500
+ //gl.glColor4f(r, g, b, 1);
501
+ //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
502
+ //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
503
+// Print(qv);
504
+
505
+ // R
506
+ x = (float)rv.x;
507
+ y = (float)rv.y;
508
+ z = (float)rv.z;
509
+
510
+ if (hasnorm)
511
+ {
512
+// assert(rv.norm.normalized());
513
+ //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
514
+ float nx = (float)rv.norm.x;
515
+ float ny = (float)rv.norm.y;
516
+ float nz = (float)rv.norm.z;
517
+
518
+ x += nx * obj.NORMALPUSH;
519
+ y += ny * obj.NORMALPUSH;
520
+ z += nz * obj.NORMALPUSH;
521
+
522
+ gl.glNormal3f(nx, ny, nz);
523
+ }
524
+
525
+ // if ((dot&4) == 0)
526
+ // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
527
+
528
+ // if (wrap || !locked && (dot&8) != 0)
529
+ if (obj.flipV)
530
+ gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
531
+ else
532
+ gl.glTexCoord2f((float) rv.s, (float) rv.t);
533
+ // else
534
+ // gl.glTexCoord2f((float) pv.s, (float) pv.t);
535
+
536
+ // f.dot = dot;
537
+
538
+ gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
539
+ SetColor(obj, rv);
540
+ //gl.glColor4f(r, g, b, 1);
541
+ //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
542
+ //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
543
+ gl.glVertex3f(x, y, z);
544
+// Print(rv);
545
+ //gl.glEnd();
546
+ }
547
+ else
548
+ {
549
+ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
550
+ gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
551
+ gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
552
+
553
+ }
554
+
555
+ if (false) // (attributes & WIREFRAME) != 0)
556
+ {
557
+ gl.glDisable(gl.GL_LIGHTING);
558
+
559
+ gl.glBegin(gl.GL_LINE_LOOP);
560
+ gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
561
+ gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
562
+ gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
563
+ gl.glEnd();
564
+
565
+ gl.glEnable(gl.GL_LIGHTING);
566
+ }
567
+ }
568
+
569
+ /// INTERFACE
570
+
571
+ void SetColor(Object3D obj, Vertex p0)
572
+ {
573
+ CameraPane display = this;
574
+ BoundaryRep bRep = obj.bRep;
575
+
576
+ if (RENDERPROGRAM == 0)
577
+ {
578
+ float r = 0;
579
+ if (bRep != null)
580
+ {
581
+ if (bRep.stripified)
582
+ {
583
+ r = 1;
584
+ }
585
+ }
586
+ float g = 0;
587
+ if (bRep != null)
588
+ {
589
+ if (bRep.trimmed)
590
+ {
591
+ g = 1;
592
+ }
593
+ }
594
+ float b = 0;
595
+ if (obj.support != null && obj.link2master)
596
+ {
597
+ b = 1;
598
+ }
599
+ display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
600
+ return;
601
+ }
602
+
603
+ if (display.DrawMode() != CameraPane.SHADOW)
604
+ return;
605
+
606
+ javax.media.opengl.GL gl = display.GetGL();
607
+// if (true) return;
608
+// float ao = p.AO;
609
+//
610
+// // if (ao == 0 && !bRep.AOdone) // transient problem!
611
+// // ao = 1;
612
+//
613
+// gl.glColor4f(ao, ao, ao, 1);
614
+
615
+// CameraPane.selectedpoint.
616
+// getAverage(cStatic.point1, true);
617
+ if (CameraPane.pointflow == null) // !random) // live)
618
+ {
619
+ return;
620
+ }
621
+
622
+ cStatic.point1.set(0,0,0);
623
+ LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
624
+
625
+ cStatic.point1.sub(p0);
626
+
627
+
628
+// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
629
+// {
630
+// return;
631
+// }
632
+
633
+ //if (true)
634
+ if (cStatic.point1.dot(cStatic.point1) > 0.000001)
635
+ {
636
+ return;
637
+ }
638
+
639
+ float[] colorV = new float[3];
640
+
641
+ if (false) // marked)
642
+ {
643
+ // debug rigging weights
644
+ for (int object = 0; object < p0.vertexlinks.length; object++)
645
+ {
646
+ float weight = p0.weights[object] / p0.totalweight;
647
+
648
+ // if (weight < 0.1)
649
+ // {
650
+ // assert(weight == 0);
651
+ // continue;
652
+ // }
653
+
654
+ if (p0.vertexlinks[object] == -1)
655
+ continue;
656
+
657
+ Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]);
658
+
659
+ int color = //1 << object; //
660
+ //p.vertexlinks.length;
661
+ obj.support.bRep.supports[p0.closestsupport].links[object];
662
+ colorV[2] += (color & 1) * weight;
663
+ colorV[1] += ((color & 2) >> 1) * weight;
664
+ colorV[0] += ((color & 4) >> 2) * weight;
665
+ }
666
+ }
667
+ else
668
+ {
669
+ if (obj.drawingstarted)
670
+ {
671
+ // find next point
672
+ if (bRep.GetVertex(0).faceindices == null)
673
+ {
674
+ bRep.InitFaceIndices();
675
+ }
676
+
677
+ double ymin = p0.y;
678
+
679
+ Vertex newp = p0;
680
+
681
+ for (int fii = 0; fii < p0.faceindices.length; fii++)
682
+ {
683
+ int fi = p0.faceindices[fii];
684
+
685
+ if (fi == -1)
686
+ break;
687
+
688
+ Face f = bRep.GetFace(fi);
689
+
690
+ Vertex p = bRep.GetVertex(f.p);
691
+ Vertex q = bRep.GetVertex(f.q);
692
+ Vertex r = bRep.GetVertex(f.r);
693
+
694
+ int swap = (int)(Math.random()*3);
695
+
696
+// for (int s=swap; --s>=0;)
697
+// {
698
+// Vertex t = p;
699
+// p = q;
700
+// q = r;
701
+// r = t;
702
+// }
703
+ if (ymin > p.y)
704
+ {
705
+ ymin = p.y;
706
+ newp = p;
707
+// break;
708
+ }
709
+ if (ymin > q.y)
710
+ {
711
+ ymin = q.y;
712
+ newp = q;
713
+// break;
714
+ }
715
+ if (ymin > r.y)
716
+ {
717
+ ymin = r.y;
718
+ newp = r;
719
+// break;
720
+ }
721
+ }
722
+
723
+ CameraPane.selectedpoint.toParent[3][0] = newp.x;
724
+ CameraPane.selectedpoint.toParent[3][1] = newp.y;
725
+ CameraPane.selectedpoint.toParent[3][2] = newp.z;
726
+
727
+ obj.drawingstarted = false;
728
+
729
+ // return;
730
+ }
731
+
732
+ if (false) // CameraPane.DRAW
733
+ {
734
+ p0.AO = colorV[0] = 2;
735
+ colorV[1] = 2;
736
+ colorV[2] = 2;
737
+ }
738
+
739
+ CameraPane.pointflow.add(p0);
740
+ CameraPane.pointflow.Touch();
741
+ }
742
+
743
+// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
744
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
745
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
746
+ }
747
+
748
+ void DrawMaterial(cMaterial material, boolean selected)
749
+ {
750
+ CameraPane display = this;
751
+ //new Exception().printStackTrace();
752
+
753
+ if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
754
+ {
755
+ return;
756
+ }
757
+
758
+ javax.media.opengl.GL gl = display.GetGL();
759
+
760
+ //Color col = Color.getHSBColor(color,modulation,1);
761
+ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
762
+ if (!material.multiply)
763
+ {
764
+ display.color = color;
765
+ display.saturation = material.modulation;
766
+ }
767
+ else
768
+ {
769
+ display.color *= color*2;
770
+ display.saturation *= material.modulation*2;
771
+ }
772
+
773
+ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
774
+
775
+ float[] colorV = GrafreeD.colorV;
776
+
777
+ /**/
778
+ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
779
+ {
780
+ colorV[0] = display.modelParams0[0] * material.diffuse;
781
+ colorV[1] = display.modelParams0[1] * material.diffuse;
782
+ colorV[2] = display.modelParams0[2] * material.diffuse;
783
+ colorV[3] = material.opacity;
784
+
785
+ gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
786
+ //System.out.println("Opacity = " + opacity);
787
+
788
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
789
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
790
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
791
+
792
+ float amb = material.ambient;
793
+ if (amb < material.cameralight)
794
+ {
795
+ amb = material.cameralight;
796
+ }
797
+ colorV[0] = display.modelParams0[0] * material.diffuse * amb;
798
+ colorV[1] = display.modelParams0[1] * material.diffuse * amb;
799
+ colorV[2] = display.modelParams0[2] * material.diffuse * amb;
800
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
801
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
802
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
803
+
804
+ /**/
805
+ colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular;
806
+ colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular;
807
+ colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular;
808
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
809
+ //color[0] /= 2; color[1] /= 2; color[2] /= 2;
810
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
811
+ colorV[0] = 10 / material.shininess; // 1/0.005f;
812
+ //System.out.println("shininess = " + colorV[0]);
813
+ if (colorV[0] > 128)
814
+ {
815
+ colorV[0] = 128;
816
+ }
817
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
818
+ gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
819
+ /**/
820
+ }
821
+ /**/
822
+
823
+ //selected = false;
824
+ selected = selected && display.flash;
825
+
826
+ //display.modelParams0[0] = 0; // pigment.r;
827
+ //display.modelParams0[1] = 0; // pigment.g;
828
+ //display.modelParams0[2] = 0; // pigment.b;
829
+ if (!material.multiply)
830
+ {
831
+ display.modelParams0[3] = material.metalness;
832
+ display.modelParams1[0] = material.diffuse;
833
+ display.modelParams1[1] = material.specular;
834
+ display.modelParams1[2] = 1 / material.shininess;
835
+ display.modelParams1[3] = material.shift;
836
+ display.modelParams2[0] = material.ambient;
837
+ display.modelParams2[1] = material.lightarea;
838
+ //System.out.println("light area = " + lightarea);
839
+ display.modelParams2[2] = 1 / material.factor; // diffuseness
840
+ display.modelParams2[3] = material.velvet;
841
+ display.modelParams3[0] = material.sheen;
842
+ display.modelParams3[1] = material.subsurface;
843
+ display.modelParams3[2] = material.bump; // backlit
844
+ display.modelParams3[3] = material.aniso;
845
+ display.modelParams4[0] = material.anisoV;
846
+ display.modelParams4[1] = selected ? 100 : material.cameralight;
847
+ //System.out.println("selected = " + selected);
848
+ display.modelParams4[2] = material.diffuseness;
849
+ display.modelParams4[3] = material.shadow;
850
+ display.modelParams5[0] = material.texture;
851
+ display.modelParams5[1] = material.opacity;
852
+ display.modelParams5[2] = material.fakedepth;
853
+ display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10;
854
+ }
855
+ else
856
+ {
857
+ display.modelParams0[3] *= material.metalness*2;
858
+ display.modelParams1[0] *= material.diffuse*2;
859
+ display.modelParams1[1] *= material.specular*2;
860
+ display.modelParams1[2] *= material.shininess*2;
861
+ display.modelParams1[3] *= material.shift*2;
862
+ display.modelParams2[0] *= material.ambient*2;
863
+ display.modelParams2[1] *= material.lightarea*2;
864
+ display.modelParams2[2] *= material.factor*2;
865
+ display.modelParams2[3] *= material.velvet*2;
866
+ display.modelParams3[0] *= material.sheen*2;
867
+ display.modelParams3[1] *= material.subsurface*2;
868
+ display.modelParams3[2] *= material.bump*2;
869
+ display.modelParams3[3] *= material.aniso*2;
870
+ display.modelParams4[0] *= material.anisoV*2;
871
+ display.modelParams4[1] *= material.cameralight*2;
872
+ //System.out.println("selected = " + selected);
873
+ display.modelParams4[2] *= material.diffuseness*2;
874
+ display.modelParams4[3] *= material.shadow*2;
875
+ display.modelParams5[0] *= material.texture*2;
876
+ display.modelParams5[1] *= material.opacity*2;
877
+ display.modelParams5[2] *= material.fakedepth*2;
878
+ display.modelParams5[3] *= material.shadowbias*2;
879
+ }
880
+
881
+ display.modelParams6[0] = 0;
882
+ display.modelParams6[1] = 0;
883
+ display.modelParams6[2] = 0;
884
+ display.modelParams6[3] = 0;
885
+
886
+ display.modelParams7[0] = 0;
887
+ display.modelParams7[1] = 1000;
888
+ display.modelParams7[2] = 0;
889
+ display.modelParams7[3] = 0;
890
+
891
+ display.modelParams6[0] = 100; // criss de bug de bump
892
+
893
+ Object3D.cVector2[] extparams = display.vector2buffer;
894
+ if (extparams != null && extparams.length > 0 && extparams[0] != null)
895
+ {
896
+ display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
897
+ display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
898
+ if (extparams.length > 1)
899
+ {
900
+ display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
901
+ display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
902
+ if (extparams.length > 2)
903
+ {
904
+ display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
905
+ float x = extparams[2].y / 1000.0f;
906
+ //if (x == 0)
907
+ // x = 1f;
908
+ 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
909
+ if (extparams[2].y > 0)
910
+ {
911
+ //System.out.println("extparams[1].y = " + extparams[1].y);
912
+ //System.out.println("extparams[2].y = " + extparams[2].y);
913
+ //System.out.println("opacity power = " + display.modelParams7[1]);
914
+ }
915
+ }
916
+ }
917
+ }
918
+
919
+ //if (display.modelParams6[2] != 0)
920
+ /*
921
+ System.out.println("modelParams0[0] = " + display.modelParams0[0]);
922
+ System.out.println("modelParams0[1] = " + display.modelParams0[1]);
923
+ System.out.println("modelParams0[2] = " + display.modelParams0[2]);
924
+ System.out.println("modelParams0[3] = " + display.modelParams0[3]);
925
+ System.out.println("modelParams1[0] = " + display.modelParams1[0]);
926
+ System.out.println("modelParams1[1] = " + display.modelParams1[1]);
927
+ System.out.println("modelParams1[2] = " + display.modelParams1[2]);
928
+ System.out.println("modelParams1[3] = " + display.modelParams1[3]);
929
+ System.out.println("modelParams2[0] = " + display.modelParams2[0]);
930
+ System.out.println("modelParams2[1] = " + display.modelParams2[1]);
931
+ System.out.println("modelParams2[2] = " + display.modelParams2[2]);
932
+ System.out.println("modelParams2[3] = " + display.modelParams2[3]);
933
+ System.out.println("modelParams3[0] = " + display.modelParams3[0]);
934
+ System.out.println("modelParams3[1] = " + display.modelParams3[1]);
935
+ System.out.println("modelParams3[2] = " + display.modelParams3[2]);
936
+ System.out.println("modelParams3[3] = " + display.modelParams3[3]);
937
+ System.out.println("modelParams4[0] = " + display.modelParams4[0]);
938
+ System.out.println("modelParams4[1] = " + display.modelParams4[1]);
939
+ System.out.println("modelParams4[2] = " + display.modelParams4[2]);
940
+ System.out.println("modelParams4[3] = " + display.modelParams4[3]);
941
+ System.out.println("modelParams5[0] = " + display.modelParams5[0]);
942
+ System.out.println("modelParams5[1] = " + display.modelParams5[1]);
943
+ System.out.println("modelParams5[2] = " + display.modelParams5[2]);
944
+ System.out.println("modelParams5[3] = " + display.modelParams5[3]);
945
+ System.out.println("modelParams6[0] = " + display.modelParams6[0]);
946
+ System.out.println("modelParams6[1] = " + display.modelParams6[1]);
947
+ System.out.println("modelParams6[2] = " + display.modelParams6[2]);
948
+ System.out.println("modelParams6[3] = " + display.modelParams6[3]);
949
+ System.out.println("modelParams7[0] = " + display.modelParams7[0]);
950
+ System.out.println("modelParams7[1] = " + display.modelParams7[1]);
951
+ System.out.println("modelParams7[2] = " + display.modelParams7[2]);
952
+ System.out.println("modelParams7[3] = " + display.modelParams7[3]);
953
+ /**/
954
+ //assert (display.modelParams6[2] == 0);
955
+
956
+ //System.out.println("noise power = " + display.modelParams7[0]);
957
+ //System.out.println("shadowbias = " + shadowbias);
958
+
959
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
960
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
961
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
962
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
963
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
964
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
965
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
966
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
967
+
968
+ int mode = display.FP_SHADER;
969
+
970
+ if (material.aniso != material.anisoV || material.aniso > 0.002)
971
+ {
972
+ mode |= display.FP_ANISO;
973
+ }
974
+
975
+ display.EnableProgram(mode);
976
+
977
+ //System.out.println("opacity power = " + display.modelParams7[1]);
978
+
979
+ if (!material.multiply)
980
+ {
981
+ if (Globals.drawMode == CameraPane.SHADOW)
982
+ gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1);
983
+ else
984
+ gl.glDepthMask(material.opacity >= 0.99);
985
+ }
236986 }
237987
238988 int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0;
....@@ -253,7 +1003,7 @@
2531003 currentGL.glMultMatrixd(model, 0);
2541004 }
2551005
256
- void PushMatrix(double[][] matrix, int count)
1006
+ public void PushMatrix(double[][] matrix, int count) // INTERFACE
2571007 {
2581008 matrixdepth++;
2591009 // GrafreeD.tracein(matrix);
....@@ -298,7 +1048,7 @@
2981048
2991049 double[][] tmpmat = new double[4][4];
3001050
301
- void PopMatrix(double[][] inverse)
1051
+ public void PopMatrix(double[][] inverse) // INTERFACE
3021052 {
3031053 --matrixdepth;
3041054
....@@ -338,7 +1088,7 @@
3381088 PushTextureMatrix(matrix, 1);
3391089 }
3401090
341
- void PushTextureMatrix(double[][] matrix, int count)
1091
+ public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE
3421092 {
3431093 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3441094
....@@ -352,7 +1102,7 @@
3521102 currentGL.glMatrixMode(GetGL().GL_MODELVIEW);
3531103 }
3541104
355
- void PopTextureMatrix(double[][] inverse)
1105
+ public void PopTextureMatrix(double[][] inverse) // INTERFACE
3561106 {
3571107 currentGL.glActiveTexture(GetGL().GL_TEXTURE0);
3581108 currentGL.glMatrixMode(GetGL().GL_TEXTURE);
....@@ -384,10 +1134,10 @@
3841134 // may 2014 if (cam == cameras[0] || cam == cameras[1])
3851135 // return false;
3861136
387
- if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount)
1137
+ if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount)
3881138 {
3891139 // check for last change
390
- if (framecount < camerachangeframe + 400) // 120 == 1 second
1140
+ if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second
3911141 {
3921142 // refuse the camera change
3931143 System.err.println("Camera " + cam + " REFUSED");
....@@ -395,7 +1145,7 @@
3951145 }
3961146 }
3971147
398
- camerachangeframe = framecount;
1148
+ camerachangeframe = Globals.framecount;
3991149
4001150 cam.hAspect = -1; // Read only
4011151
....@@ -426,7 +1176,7 @@
4261176 {
4271177 //System.err.println("Oeil on");
4281178 TRACK = true;
429
-// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1179
+// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4301180 // object.editWindow.ScreenFit(trackedobject);
4311181 //pingthread.StepToTarget(true);
4321182 }
....@@ -435,7 +1185,7 @@
4351185 {
4361186 //System.err.println("Oeil on");
4371187 OEIL = true;
438
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
1188
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
4391189 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
4401190 //pingthread.StepToTarget(true);
4411191 }
....@@ -499,7 +1249,7 @@
4991249 {
5001250 frozen ^= true;
5011251 // Weird...
502
- lighttouched = true;
1252
+ Globals.lighttouched = true;
5031253 }
5041254
5051255 void ToggleDL()
....@@ -514,11 +1264,11 @@
5141264
5151265 void ToggleLive()
5161266 {
517
- setLIVE(isLIVE() ^ true);
1267
+ Globals.setLIVE(Globals.isLIVE() ^ true);
5181268
519
- System.err.println("LIVE = " + isLIVE());
1269
+ System.err.println("LIVE = " + Globals.isLIVE());
5201270
521
- if (!isLIVE()) // save sound
1271
+ if (!Globals.isLIVE()) // save sound
5221272 GrafreeD.savesound = true; // wav.save();
5231273 // else
5241274 repaint(); // start loop // may 2013
....@@ -541,7 +1291,7 @@
5411291
5421292 void ToggleCrowd()
5431293 {
544
- CROWD ^= true;
1294
+ Globals.CROWD ^= true;
5451295 }
5461296
5471297 void ToggleInertia()
....@@ -759,7 +1509,7 @@
7591509
7601510 GL currentGL;
7611511
762
- GL GetGL()
1512
+ public GL GetGL() // INTERFACE
7631513 {
7641514 return currentGL;
7651515 }
....@@ -6271,7 +7021,7 @@
62717021 return null;
62727022 }
62737023
6274
- void ReleaseTextures(cTexture tex)
7024
+ public void ReleaseTextures(cTexture tex) // INTERFACE
62757025 {
62767026 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
62777027 {
....@@ -6309,7 +7059,7 @@
63097059
63107060 void ReleaseTexture(String tex, boolean bump)
63117061 {
6312
- if (// drawMode != 0 || /*tex == null ||*/
7062
+ if (// DrawMode() != 0 || /*tex == null ||*/
63137063 ambientOcclusion ) // || !textureon)
63147064 {
63157065 return;
....@@ -6410,9 +7160,9 @@
64107160 }
64117161 }
64127162
6413
- /*boolean*/ void BindTextures(cTexture tex, int resolution)
7163
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
64147164 {
6415
- if (// drawMode != 0 || /*tex == null ||*/
7165
+ if (// DrawMode() != 0 || /*tex == null ||*/
64167166 ambientOcclusion ) // || !textureon)
64177167 {
64187168 return; // false;
....@@ -7312,9 +8062,9 @@
73128062 static boolean occlusionInitialized = false;
73138063 boolean selection = false;
73148064 boolean pointselection = false;
7315
- /*static*/ boolean lighttouched = true;
8065
+ ///*static*/ boolean lighttouched = true;
73168066 boolean deselect;
7317
- boolean ambientOcclusion = false;
8067
+ private boolean ambientOcclusion = false;
73188068 static boolean flash = false;
73198069 /*static*/ boolean wait = false;
73208070 boolean displaydone = false; // after repaint() calls
....@@ -7603,8 +8353,6 @@
76038353
76048354 boolean restartframe = false;
76058355
7606
- static int framecount = 0; // general-purpose global count
7607
-
76088356 void displayAntiAliased(javax.media.opengl.GL gl)
76098357 {
76108358 //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0);
....@@ -7635,7 +8383,7 @@
76358383 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
76368384 for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76378385 {
7638
- framecount++;
8386
+ Globals.framecount++;
76398387
76408388 if (CameraPane.tickcount > 0)
76418389 CameraPane.tickcount--;
....@@ -7673,7 +8421,7 @@
76738421
76748422 gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0);
76758423 */
7676
- lighttouched = true;
8424
+ Globals.lighttouched = true;
76778425 //System.err.println(" shadowbuffer: " + jitter);
76788426 shadowbuffer.display();
76798427
....@@ -8620,13 +9368,6 @@
86209368 }
86219369 }
86229370
8623
- boolean IsFrozen()
8624
- {
8625
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
8626
-
8627
- return !selectmode && cameracount == 0; // != 0;
8628
- }
8629
-
86309371 boolean niceon = false;
86319372 javax.swing.Timer AAtimer = new javax.swing.Timer(750, this);
86329373 boolean currentlydrawing = false;
....@@ -8644,8 +9385,8 @@
86449385 }
86459386 // if (DEBUG_SELECTION)
86469387 // {
8647
-// if (drawMode != SELECTION)
8648
-// drawMode = SELECTION;
9388
+// if (DrawMode() != SELECTION)
9389
+// DrawMode() = SELECTION;
86499390 // }
86509391
86519392 if (!isRenderer)
....@@ -8701,9 +9442,9 @@
87019442
87029443 //ANTIALIAS = 0;
87039444
8704
- if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0)
9445
+ if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0)
87059446 {
8706
- if (niceon || isLIVE())
9447
+ if (niceon || Globals.isLIVE())
87079448 {
87089449 //if(active == 0)
87099450 // antialiaser = null;
....@@ -8728,7 +9469,7 @@
87289469 assert eyeCamera.shaper_zFar == 1E5f; // 500.0f;
87299470 */
87309471
8731
- if (drawMode == DEFAULT)
9472
+ if (DrawMode() == DEFAULT)
87329473 {
87339474 currentlydrawing = true;
87349475 }
....@@ -8759,12 +9500,12 @@
87599500
87609501 // if(Applet3D.clipboard != null)
87619502 // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent);
8762
-//drawMode = SELECTION;
9503
+//DrawMode() = SELECTION;
87639504 indexcount = 0;
87649505
8765
- if (drawMode == OCCLUSION)
9506
+ if (DrawMode() == OCCLUSION)
87669507 {
8767
- drawMode = DEFAULT;
9508
+ Globals.drawMode = DEFAULT; // WARNING
87689509 ambientOcclusion = true;
87699510 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
87709511 Object3D theobject = object;
....@@ -8783,19 +9524,19 @@
87839524 ambientOcclusion = false;
87849525 }
87859526
8786
- if (lighttouched && drawMode == DEFAULT && !lightMode) // && !FROZEN)
9527
+ if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
87879528 {
87889529 //if (RENDERSHADOW) // ?
87899530 if (!IsFrozen())
87909531 {
87919532 // dec 2012
8792
- if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
9533
+ if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
87939534 {
8794
- framecount++;
9535
+ Globals.framecount++;
87959536 shadowbuffer.display();
87969537 }
87979538 }
8798
- lighttouched = false; // ??
9539
+ Globals.lighttouched = false; // ??
87999540 //drawing = true;
88009541 //lighttouched = true;
88019542 }
....@@ -8816,9 +9557,9 @@
88169557 //eyeCamera.shaper_fovy = 1;
88179558 }
88189559
8819
- if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION)
9560
+ if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION)
88209561 {
8821
- //System.out.println("drawMode = " + drawMode);
9562
+ //System.out.println("DrawMode() = " + DrawMode());
88229563 vertexMode |= VP_PASS;
88239564 //vertexMode |= VP_PROJECTION;
88249565 if (!ambientOcclusion)
....@@ -8878,7 +9619,7 @@
88789619 Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera;
88799620 //Camera lightcam = new Camera(light0);
88809621
8881
- if (drawMode == SHADOW)
9622
+ if (DrawMode() == SHADOW)
88829623 {
88839624 /*
88849625 gl.glMatrixMode(GL.GL_MODELVIEW);
....@@ -8968,7 +9709,7 @@
89689709 gl.glClear(gl.GL_DEPTH_BUFFER_BIT);
89699710 } else
89709711 {
8971
- if (drawMode != DEFAULT)
9712
+ if (DrawMode() != DEFAULT)
89729713 {
89739714 gl.glClearColor(1, 1, 1, 0);
89749715 } // 1);
....@@ -9033,7 +9774,7 @@
90339774
90349775 fast &= !ambientOcclusion;
90359776
9036
- if (drawMode == DEFAULT)
9777
+ if (DrawMode() == DEFAULT)
90379778 {
90389779 //gl.glEnable(gl.GL_ALPHA_TEST);
90399780 //gl.glActiveTexture(GL.GL_TEXTURE0);
....@@ -9231,7 +9972,7 @@
92319972 gl.glMatrixMode(gl.GL_PROJECTION);
92329973 gl.glLoadIdentity();
92339974
9234
- if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
9975
+ if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0)
92359976 {
92369977 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
92379978 double scale = lightCamera.SCALE / lightCamera.Distance();
....@@ -9289,7 +10030,7 @@
928910030 //gl.glPushMatrix();
929010031 gl.glLoadIdentity();
929110032
9292
- if (!ambientOcclusion) // drawMode != OCCLUSION)
10033
+ if (!ambientOcclusion) // DrawMode() != OCCLUSION)
929310034 {
929410035 //LA.xformPos(light0, lightCamera.fromScreen, light);
929510036 LA.xformDir(dirlight, lightCamera.fromScreen, lightposition);
....@@ -9376,7 +10117,7 @@
937610117 }
937710118
937810119 /**/
9379
- if (true) // drawMode == SELECTION) // != DEFAULT)
10120
+ if (true) // DrawMode() == SELECTION) // != DEFAULT)
938010121 gl.glDisable(gl.GL_LIGHTING);
938110122 else
938210123 gl.glEnable(gl.GL_LIGHTING);
....@@ -9394,7 +10135,7 @@
939410135
939510136 lightslot = 64;
939610137
9397
- if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT)
10138
+ if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT)
939810139 {
939910140 DrawLights(object);
940010141 }
....@@ -9405,7 +10146,7 @@
940510146 fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
940610147 //System.out.println("fragmentMode = " + fragmentMode);
940710148
9408
- if (drawMode == DEFAULT || drawMode == SELECTION || DEBUG_SELECTION)
10149
+ if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
940910150 {
941010151 /*
941110152 if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
....@@ -9438,7 +10179,7 @@
943810179 }
943910180 }
944010181
9441
- if (drawMode == DEFAULT)
10182
+ if (DrawMode() == DEFAULT)
944210183 {
944310184 if (WIREFRAME && !ambientOcclusion)
944410185 {
....@@ -9456,7 +10197,7 @@
945610197 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
945710198 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
945810199
9459
- if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) //
10200
+ if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) //
946010201 {
946110202 if (vertexMode != 0) // && !fast)
946210203 {
....@@ -9476,7 +10217,7 @@
947610217 }
947710218 }
947810219
9479
- if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion)
10220
+ if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
948010221 {
948110222 //gl.glDepthFunc(GL.GL_LEQUAL);
948210223 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -9504,7 +10245,7 @@
950410245 //gl.glDepthMask(false);
950510246 }
950610247
9507
- if (false) // drawMode == SHADOW)
10248
+ if (false) // DrawMode() == SHADOW)
950810249 {
950910250 //SetColumnMajorData(cameraInverseTransform, view_1);
951010251 //System.out.println("light = " + cameraInverseTransform);
....@@ -9518,16 +10259,16 @@
951810259 //System.out.println("object = " + object);
951910260 if (!frozen && !imageLocked)
952010261 {
9521
- if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)
10262
+ if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)
952210263 {
952310264 displayAntiAliased(gl);
952410265 } else
952510266 {
952610267 programcount = 0;
9527
- int keepmode = drawMode;
10268
+ int keepmode = DrawMode();
952810269 // if (DEBUG_SELECTION)
952910270 // {
9530
-// drawMode = SELECTION;
10271
+// DrawMode() = SELECTION;
953110272 // }
953210273 // for point selection
953310274 // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0);
....@@ -9537,10 +10278,10 @@
953710278 DrawObject(gl);
953810279
953910280 // jan 2013 System.err.println("RESET ABORT (display)");
9540
- // if (drawMode == DEFAULT)
10281
+ // if (DrawMode() == DEFAULT)
954110282 // ABORTED = false;
954210283 fullreset = false;
9543
- drawMode = keepmode;
10284
+ Globals.drawMode = keepmode; // WARNING
954410285 //System.out.println("PROGRAM SWITCH " + programcount);
954510286 }
954610287 }
....@@ -9548,11 +10289,11 @@
954810289 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
954910290 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
955010291
9551
- if (drawMode == DEFAULT)
10292
+ if (DrawMode() == DEFAULT)
955210293 {
955310294 ReleaseTexture(NOISE_TEXTURE, false);
955410295 }
9555
- //if (drawMode == DEFAULT)
10296
+ //if (DrawMode() == DEFAULT)
955610297 {
955710298
955810299 gl.glActiveTexture(GL.GL_TEXTURE1);
....@@ -9564,7 +10305,7 @@
956410305 //else
956510306 //gl.glDisable(gl.GL_TEXTURE_2D);
956610307 //gl.glPopMatrix();
9567
- if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion)
10308
+ if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion)
956810309 {
956910310 //new Exception().printStackTrace();
957010311 //System.out.println("Draw image " + width + ", " + height);
....@@ -9606,7 +10347,7 @@
960610347 //gl.glFlush();
960710348 }
960810349
9609
- if (flash && drawMode == DEFAULT)
10350
+ if (flash && DrawMode() == DEFAULT)
961010351 {
961110352 flash = false;
961210353 wait = true;
....@@ -9614,9 +10355,9 @@
961410355 }
961510356
961610357 //drawing = false;
9617
- //if(drawMode == DEFAULT)
10358
+ //if(DrawMode() == DEFAULT)
961810359 // niceon = false;
9619
- if (drawMode == DEFAULT)
10360
+ if (DrawMode() == DEFAULT)
962010361 {
962110362 currentlydrawing = false;
962210363 }
....@@ -9636,7 +10377,7 @@
963610377 repaint();
963710378 }
963810379
9639
- if (isLIVE() && drawMode == DEFAULT) // may 2013
10380
+ if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
964010381 repaint();
964110382
964210383 displaydone = true;
....@@ -9673,7 +10414,7 @@
967310414 if (GrafreeD.RENDERME > 0)
967410415 GrafreeD.RENDERME--; // mechante magouille
967510416
9676
- ONESTEP = false;
10417
+ Globals.ONESTEP = false;
967710418 }
967810419
967910420 static boolean zoomonce = false;
....@@ -9681,11 +10422,11 @@
968110422 void DrawObject(GL gl, boolean draw)
968210423 {
968310424 //System.out.println("DRAW OBJECT " + mouseDown);
9684
-// drawMode = SELECTION;
10425
+// DrawMode() = SELECTION;
968510426 //GL gl = getGL();
968610427 if ((TRACK || SHADOWTRACK) || zoomonce)
968710428 {
9688
- if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode)
10429
+ if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
968910430 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
969010431 pingthread.StepToTarget(true); // true);
969110432 // zoomonce = false;
....@@ -9706,9 +10447,9 @@
970610447 callist = gl.glGenLists(1);
970710448 }
970810449
9709
- boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION;
10450
+ boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
971010451
9711
- boolean active = !selectmode; // drawMode != SELECTION; // mouseDown;
10452
+ boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
971210453
971310454 if (!mainDL || !active || touched)
971410455 {
....@@ -9735,7 +10476,7 @@
973510476 PushMatrix(ClickInfo.matbuffer);
973610477 }
973710478
9738
- if (drawMode == 0)
10479
+ if (DrawMode() == 0)
973910480 {
974010481 // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++");
974110482
....@@ -9749,7 +10490,7 @@
974910490 // DRAW
975010491 object.draw(this, /*(Composite)*/ object, false, false);
975110492
9752
- if (drawMode == DEFAULT)
10493
+ if (DrawMode() == DEFAULT)
975310494 {
975410495 if (DEBUG)
975510496 {
....@@ -9801,7 +10542,7 @@
980110542 }
980210543 // GrafreeD.traceoff();
980310544 //System.out.println(stackdepth);
9804
- if (drawMode == 0)
10545
+ if (DrawMode() == 0)
980510546 {
980610547 ReleaseTextures(DEFAULT_TEXTURES);
980710548
....@@ -9826,10 +10567,10 @@
982610567
982710568 checker = null;
982810569
9829
- if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT)
10570
+ if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT)
983010571 FindChecker(object);
983110572
9832
- if (checker != null && drawMode == DEFAULT)
10573
+ if (checker != null && DrawMode() == DEFAULT)
983310574 {
983410575 //BindTexture(IMMORTAL_TEXTURE);
983510576 BindTextures(checker.GetTextures(), checker.texres);
....@@ -9851,7 +10592,7 @@
985110592 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
985210593 //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
985310594
9854
- if (DISPLAYTEXT && drawMode == DEFAULT)
10595
+ if (DISPLAYTEXT && DrawMode() == DEFAULT)
985510596 {
985610597 // Draw it once, then use the raster
985710598 Balloon(gl, balloon.createGraphics());
....@@ -9907,9 +10648,9 @@
990710648 int[] xs = new int[3];
990810649 int[] ys = new int[3];
990910650
9910
- void DrawString(Object3D obj) // String string)
10651
+ public void DrawString(Object3D obj) // String string) // INTERFACE
991110652 {
9912
- if (!DISPLAYTEXT || drawMode != DEFAULT)
10653
+ if (!DISPLAYTEXT || DrawMode() != DEFAULT)
991310654 {
991410655 return;
991510656 }
....@@ -12068,7 +12809,7 @@
1206812809 // ObjEditor.tweenManager.update(1f / 60f);
1206912810
1207012811 // fev 2014???
12071
- if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode)
12812
+ if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1207212813 object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1207312814 pingthread.StepToTarget(true); // true);
1207412815 }
....@@ -12319,7 +13060,7 @@
1231913060 //System.out.println("---------------- ---------- Paint " + tmp.length2());
1232013061 if (lightMode)
1232113062 {
12322
- lighttouched = true;
13063
+ Globals.lighttouched = true;
1232313064 }
1232413065
1232513066 if (OEILONCE && OEIL)
....@@ -12377,7 +13118,7 @@
1237713118 mouseDown = false;
1237813119 if (lightMode)
1237913120 {
12380
- lighttouched = true;
13121
+ Globals.lighttouched = true;
1238113122 }
1238213123 repaint();
1238313124 alreadypainted = true;
....@@ -12385,7 +13126,7 @@
1238513126 isMoving = false;
1238613127 } //??
1238713128
12388
- if (isLIVE() && !alreadypainted)
13129
+ if (Globals.isLIVE() && !alreadypainted)
1238913130 {
1239013131 // FOR DEBUG BREAKPOINT USING PAUSE: while (true)
1239113132 repaint();
....@@ -12397,7 +13138,7 @@
1239713138 {
1239813139 if (lightMode)
1239913140 {
12400
- lighttouched = true;
13141
+ Globals.lighttouched = true;
1240113142 }
1240213143 drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
1240313144 }
....@@ -12651,7 +13392,7 @@
1265113392
1265213393 if (manipCamera == lightCamera)
1265313394 {
12654
- lighttouched = true;
13395
+ Globals.lighttouched = true;
1265513396 }
1265613397 /*
1265713398 switch (mode)
....@@ -13039,7 +13780,7 @@
1303913780 case 'B':
1304013781 BRISMOOTH ^= true;
1304113782 SHADOWCULLFACE ^= true;
13042
- lighttouched = true;
13783
+ Globals.lighttouched = true;
1304313784 repaint();
1304413785 break;
1304513786 case 'b':
....@@ -13139,7 +13880,7 @@
1313913880 repaint();
1314013881 break;
1314113882 case 'O':
13142
- drawMode = OCCLUSION;
13883
+ Globals.drawMode = OCCLUSION; // WARNING
1314313884 repaint();
1314413885 break;
1314513886 case 'o':
....@@ -13230,7 +13971,7 @@
1323013971 break;
1323113972 case ' ':
1323213973 lightMode ^= true;
13233
- lighttouched = true;
13974
+ Globals.lighttouched = true;
1323413975 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
1323513976 targetLookAt.set(manipCamera.lookAt);
1323613977 repaint();
....@@ -13246,7 +13987,7 @@
1324613987 //break;
1324713988 case 'z':
1324813989 RENDERSHADOW ^= true;
13249
- lighttouched = true;
13990
+ Globals.lighttouched = true;
1325013991 repaint();
1325113992 break;
1325213993 //case UP:
....@@ -13848,6 +14589,7 @@
1384814589 //if (g != gr) g.drawImage(img, 0, 0, width, height, null);
1384914590 }
1385014591
14592
+ // To avoid clear.
1385114593 public void update(Graphics g)
1385214594 {
1385314595 paint(g);
....@@ -14510,20 +15252,21 @@
1451015252 /**/
1451115253 //checker.GetMaterial().opacity = 1.1f;
1451215254 ////checker.GetMaterial().ambient = 0.99f;
14513
- Object3D.materialstack[Object3D.materialdepth] = checker.material;
14514
- Object3D.selectedstack[Object3D.materialdepth] = false;
14515
- cStatic.objectstack[Object3D.materialdepth++] = checker;
15255
+ materialstack[materialdepth] = checker.material;
15256
+ selectedstack[materialdepth] = false;
15257
+ cStatic.objectstack[materialdepth++] = checker;
1451615258 //System.out.println("material " + material);
1451715259 //Applet3D.tracein(this, selected);
1451815260 vector2buffer = checker.projectedVertices;
1451915261
14520
- checker.GetMaterial().Draw(this, false); // true);
15262
+ //checker.GetMaterial().Draw(this, false); // true);
15263
+ DrawMaterial(checker.GetMaterial(), false); // true);
1452115264
14522
- Object3D.materialdepth -= 1;
14523
- if (Object3D.materialdepth > 0)
15265
+ materialdepth -= 1;
15266
+ if (materialdepth > 0)
1452415267 {
14525
- vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices;
14526
- Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]);
15268
+ vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
15269
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
1452715270 }
1452815271 //checker.GetMaterial().opacity = 1f;
1452915272 ////checker.GetMaterial().ambient = 1f;
....@@ -14689,14 +15432,14 @@
1468915432
1469015433 //int tmp = selection_view;
1469115434 //selection_view = -1;
14692
- int temp = drawMode;
14693
- drawMode = SELECTION;
15435
+ int temp = DrawMode();
15436
+ Globals.drawMode = SELECTION; // WARNING
1469415437 indexcount = 0;
1469515438 parent.display(drawable);
1469615439 //selection_view = tmp;
1469715440 //if (temp == SELECTION)
1469815441 // temp = DEFAULT; // patch for selection debug
14699
- drawMode = temp;
15442
+ Globals.drawMode = temp; // WARNING
1470015443
1470115444 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1470215445
....@@ -14969,14 +15712,14 @@
1496915712 //gl.glColorMask(false, false, false, false);
1497015713
1497115714 //render_scene_from_light_view(gl, drawable, 0, 0);
14972
- if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed())
15715
+ if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
1497315716 {
1497415717 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1497515718
14976
- int temp = drawMode;
14977
- drawMode = SHADOW;
15719
+ int temp = DrawMode();
15720
+ Globals.drawMode = SHADOW; // WARNING
1497815721 parent.display(drawable);
14979
- drawMode = temp;
15722
+ Globals.drawMode = temp; // WARNING
1498015723 }
1498115724
1498215725 gl.glCullFace(gl.GL_BACK);
....@@ -15374,12 +16117,6 @@
1537416117 GLUT glut = new GLUT();
1537516118
1537616119
15377
- static final public int DEFAULT = 0;
15378
- static final public int SELECTION = 1;
15379
- static final public int SHADOW = 2;
15380
- static final public int OCCLUSION = 3;
15381
- static
15382
- public int drawMode = DEFAULT;
1538316120 public boolean spherical = false;
1538416121 static boolean DEBUG_OCCLUSION = false;
1538516122 static boolean DEBUG_SELECTION = false;
Composite.java
....@@ -822,7 +822,7 @@
822822
823823 }
824824
825
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
825
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
826826 {
827827 if (this instanceof BezierPatch)
828828 {
....@@ -837,7 +837,7 @@
837837 }
838838
839839 if ((//display.drawMode == CameraPane.SHADOW ||
840
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) &&
840
+ display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) &&
841841 //HasTransparency())
842842 // SERIAL PATCH
843843 // if (viewCode == -1)
....@@ -855,7 +855,7 @@
855855
856856 cTexture tex = null;
857857
858
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
858
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
859859
860860 if (//display.drawMode != display.SHADOW &&
861861 !selectmode // display.drawMode != display.SELECTION
GenericJoint.java
....@@ -339,7 +339,7 @@
339339
340340 // assert(bRep != null);
341341
342
- if (display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK
342
+ if (Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK
343343 {
344344 // float ms = getDeltaTimeMicroseconds();
345345 // float minFPS = 1000000f / 60f;
Globals.java
....@@ -0,0 +1,26 @@
1
+
2
+public class Globals
3
+{
4
+static boolean CROWD = false;
5
+ static public int drawMode = iCameraPane.DEFAULT; // WARNING
6
+ static public boolean lighttouched = false; // WARNING
7
+
8
+ static int framecount = 0; // general-purpose global count
9
+ private static boolean LIVE = false;
10
+ static boolean ONESTEP = false; // do LIVE once
11
+
12
+ public static boolean isLIVE()
13
+ {
14
+ return LIVE || ONESTEP;
15
+ }
16
+
17
+ public static void setLIVE(boolean aLIVE)
18
+ {
19
+ LIVE = aLIVE;
20
+ }
21
+
22
+ public static int DrawMode()
23
+ {
24
+ return drawMode;
25
+ }
26
+}
GroupEditor.java
....@@ -437,7 +437,7 @@
437437 oe.aConstraints.gridwidth = 1;
438438 oe.aConstraints.gridx = 0;
439439
440
- oe.toolbarPanel.add(liveCB = new cCheckBox("Live", CameraPane.isLIVE()), oe.aConstraints);
440
+ oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE()), oe.aConstraints);
441441 liveCB.addItemListener(this);
442442
443443 oe.aConstraints.gridx += 1;
....@@ -449,7 +449,7 @@
449449 // localCB.addItemListener(this);
450450
451451 oe.aConstraints.gridx += 1;
452
- oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", CameraPane.CROWD), oe.aConstraints);
452
+ oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD), oe.aConstraints);
453453 crowdCB.addItemListener(this);
454454
455455 oe.aConstraints.gridx += 1;
....@@ -1782,7 +1782,7 @@
17821782 } else
17831783 if (event.getSource() == computeAOItem)
17841784 {
1785
- CameraPane.drawMode = CameraPane.OCCLUSION;
1785
+ Globals.drawMode = CameraPane.OCCLUSION;
17861786 CameraPane.theRenderer.repaint();
17871787 } else
17881788 if (event.getSource() == recompileItem)
....@@ -2920,7 +2920,8 @@
29202920 cameraView.cameras[cameraView.cameracount] = radio.camera;
29212921 cameraView.targetLookAt.set(radio.camera.lookAt);
29222922 cameraView.object = group;
2923
- cameraView.lighttouched = true;
2923
+ //cameraView.lighttouched = true;
2924
+ Globals.lighttouched = true;
29242925 topView.object = group;
29252926 frontView.object = group;
29262927 sideView.object = group;
....@@ -2956,7 +2957,7 @@
29562957 if (useclient)
29572958 {
29582959 cameraView.object = client;
2959
- cameraView.lighttouched = true;
2960
+ Globals.lighttouched = true;
29602961 //topView.object = client;
29612962 //frontView.object = client;
29622963 //sideView.object = client;
....@@ -2964,7 +2965,7 @@
29642965 else
29652966 {
29662967 cameraView.object = group;
2967
- cameraView.lighttouched = true;
2968
+ Globals.lighttouched = true;
29682969 //topView.object = group;
29692970 //frontView.object = group;
29702971 //sideView.object = group;
....@@ -4058,7 +4059,7 @@
40584059
40594060 objEditor.SetText(); // jan 2014
40604061
4061
- if (flashIt && !CameraPane.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))
4062
+ if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))
40624063 CameraPane.flash = true;
40634064
40644065 if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera)
Mocap.java
....@@ -1564,7 +1564,7 @@
15641564 //GraphreeD.
15651565 wav.play(volume * usedvolume); //, mywave);
15661566
1567
- lastsoundtime = CameraPane.framecount;
1567
+ lastsoundtime = Globals.framecount;
15681568
15691569 GrafreeD.hassound = true;
15701570 }
....@@ -3289,7 +3289,7 @@
32893289 "; fullname = " + fullname);
32903290
32913291 //int delta = frame - baseframe;
3292
- if (CameraPane.CROWD)
3292
+ if (Globals.CROWD)
32933293 {
32943294 baseframe = GetFirstFrame(); // 0 initial point
32953295 }
....@@ -3871,7 +3871,7 @@
38713871 // return;
38723872
38733873 if (!restarted && /*display.restartframe &&*/
3874
- display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK
3874
+ Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK
38753875 {
38763876 //display.restartframe = false;
38773877 restarted = true;
....@@ -3879,7 +3879,7 @@
38793879 }
38803880 else
38813881 {
3882
- if (display.isLIVE() && live && display.drawMode != display.SHADOW)
3882
+ if (Globals.isLIVE() && live && display.DrawMode() != display.SHADOW)
38833883 restarted = false;
38843884 }
38853885
MorphNode.java
....@@ -59,7 +59,7 @@
5959 // bRep = (BoundaryRep) GrafreeD.clone(morphobject.get(0).bRep);
6060 // }
6161
62
- if (CameraPane.SUPPORT && display.drawMode == display.SHADOW)
62
+ if (CameraPane.SUPPORT && display.DrawMode() == display.SHADOW)
6363 {
6464 for (int i=0; i<morphobject.Size(); i++)
6565 {
ObjEditor.java
....@@ -311,7 +311,7 @@
311311 toggleTextureItem.setState(CameraPane.textureon);
312312 cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
313313 toggleLiveItem.addItemListener(this);
314
- toggleLiveItem.setState(CameraPane.isLIVE());
314
+ toggleLiveItem.setState(Globals.isLIVE());
315315 cameraMenu.add(stepItem = new MenuItem("Step"));
316316 stepItem.addActionListener(this);
317317 // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
....@@ -3139,7 +3139,8 @@
31393139 objEditor.refreshContents();
31403140 } else if (event.getSource() == stepItem)
31413141 {
3142
- cameraView.ONESTEP = true;
3142
+ //cameraView.ONESTEP = true;
3143
+ Globals.ONESTEP = true;
31433144 cameraView.repaint();
31443145 return;
31453146 } else if (event.getSource() == stepButton)
Object3D.java
....@@ -760,7 +760,7 @@
760760
761761 int GetTransformCount()
762762 {
763
- // marde pour serialization de Texture
763
+ // patch pour serialization de Texture
764764 resetmaxcount();
765765 resettransformcount();
766766 resetstep();
....@@ -794,12 +794,12 @@
794794 // factor = CameraPane.STEP;
795795 // }
796796
797
- if (marked && CameraPane.isLIVE() && live &&
797
+ if (marked && Globals.isLIVE() && live &&
798798 //TEMP21aug2018
799
- CameraPane.drawMode == CameraPane.SHADOW &&
800
- currentframe != CameraPane.framecount)
799
+ Globals.DrawMode() == iCameraPane.SHADOW &&
800
+ currentframe != Globals.framecount)
801801 {
802
- currentframe = CameraPane.framecount;
802
+ currentframe = Globals.framecount;
803803
804804 // System.err.println("transformcount = " + transformcount);
805805 // System.err.println("factor = " + factor);
....@@ -5001,7 +5001,8 @@
50015001 } else //
50025002 if (editWindow != null)
50035003 {
5004
- editWindow.cameraView.lighttouched = true;
5004
+ //editWindow.cameraView.lighttouched = true;
5005
+ Globals.lighttouched = true;
50055006 }
50065007 }
50075008
....@@ -5313,25 +5314,21 @@
53135314 }
53145315 }
53155316
5316
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5317
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53175318 {
53185319 Draw(display, root, selected, blocked);
53195320 }
53205321
5321
- static cMaterial[] materialstack = new cMaterial[65536];
5322
- static boolean[] selectedstack = new boolean[65536];
5323
- static int materialdepth = 0;
5324
-
53255322 boolean NeedSupport()
53265323 {
53275324 return
53285325 CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
53295326 // PROBLEM with CROWD!!
5330
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5327
+ && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
53315328 }
53325329
53335330
5334
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5331
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53355332 {
53365333 Invariants(); // june 2013
53375334
....@@ -5340,7 +5337,7 @@
53405337 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53415338 }
53425339
5343
- if (display.drawMode == CameraPane.SELECTION &&
5340
+ if (display.DrawMode() == iCameraPane.SELECTION &&
53445341 hide)
53455342 return;
53465343
....@@ -5359,7 +5356,7 @@
53595356 if (this instanceof Checker)
53605357 return;
53615358
5362
- if (display.drawMode == display.SHADOW && PASSTEST)
5359
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53635360 return;
53645361
53655362 if (count <= 0)
....@@ -5367,8 +5364,8 @@
53675364 return;
53685365 }
53695366
5370
- if ((//display.drawMode == CameraPane.SHADOW ||
5371
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5367
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
+ display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
53725369 {
53735370 return;
53745371 }
....@@ -5409,15 +5406,15 @@
54095406
54105407 boolean compiled = false;
54115408
5412
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5409
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
54135410
5414
- if (!selectmode && //display.drawMode != display.SELECTION &&
5411
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
54155412 (touched || (bRep != null && bRep.displaylist <= 0)))
54165413 {
5417
- display.lighttouched = true;
5414
+ Globals.lighttouched = true;
54185415 } // all panes...
5419
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5420
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5416
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5417
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54215418 (touched || (bRep != null && bRep.displaylist <= 0)))
54225419 {
54235420 if (!(this instanceof Composite))
....@@ -5448,7 +5445,7 @@
54485445 }
54495446 //gl.glDrawBuffer(gl.GL_BACK);
54505447 // XXX touched = false;
5451
- display.lighttouched = true; // all panes...
5448
+ Globals.lighttouched = true; // all panes...
54525449 }
54535450
54545451 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5487,12 +5484,12 @@
54875484
54885485 // frustum culling
54895486 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5490
- && display.drawMode != CameraPane.SELECTION)
5487
+ && display.DrawMode() != CameraPane.SELECTION)
54915488 {
5492
- if (display.drawMode == CameraPane.SHADOW)
5489
+ if (display.DrawMode() == CameraPane.SHADOW)
54935490 {
54945491 if (!link2master // tricky to cull in shadow mode.
5495
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5492
+ && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
54965493 {
54975494 //System.out.print("CULLED");
54985495 culled = true;
....@@ -5500,7 +5497,7 @@
55005497 }
55015498 else
55025499 //GetBRep().getBounds(v0, v1, this);
5503
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5500
+ if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
55045501 culled = true;
55055502
55065503 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5536,7 +5533,7 @@
55365533
55375534
55385535 if (!culled)
5539
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5536
+ if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
55405537 {
55415538 if (GetBRep() != null)
55425539 {
....@@ -5562,55 +5559,7 @@
55625559 color[2] /= 2;
55635560 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55645561 */
5565
- if (material != null)
5566
- {
5567
- materialstack[materialdepth] = material;
5568
- selectedstack[materialdepth] = selected;
5569
- cStatic.objectstack[materialdepth++] = this;
5570
- //System.out.println("material " + material);
5571
- //Applet3D.tracein(this, selected);
5572
- display.vector2buffer = projectedVertices;
5573
- if (this instanceof Camera)
5574
- {
5575
- display.options1[0] = material.shift;
5576
- //System.out.println("shift " + material.shift);
5577
- display.options1[1] = material.lightarea;
5578
- display.options1[2] = material.shadowbias;
5579
- display.options1[3] = material.aniso;
5580
- display.options1[4] = material.anisoV;
5581
- display.options2[0] = material.opacity;
5582
- display.options2[1] = material.diffuse;
5583
- display.options2[2] = material.factor;
5584
-
5585
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5586
- display.options4[0] = material.cameralight/0.2f;
5587
- display.options4[1] = material.subsurface;
5588
- display.options4[2] = material.sheen;
5589
-
5590
- // if (display.CURRENTANTIALIAS > 0)
5591
- // display.options3[3] /= 4;
5592
-
5593
- /*
5594
- System.out.println("Focus = " + display.options1[0]);
5595
- System.out.println("Aperture = " + display.options1[1]);
5596
- System.out.println("ShadowBlur = " + display.options1[2]);
5597
- System.out.println("Antialiasing = " + display.options1[3]);
5598
- System.out.println("Fog = " + display.options2[0]);
5599
- System.out.println("Intensity = " + display.options2[1]);
5600
- System.out.println("Elevation = " + display.options2[2]);
5601
- /**/
5602
- } else
5603
- {
5604
- material.Draw(display, selected);
5605
- }
5606
- } else
5607
- {
5608
- if (selected && CameraPane.flash)
5609
- {
5610
- display.modelParams4[1] = 100;
5611
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5612
- }
5613
- }
5562
+ display.PushMaterial(this, selected);
56145563
56155564 //System.out.println("call list " + list);
56165565 //System.out.println();
....@@ -5652,23 +5601,8 @@
56525601 }
56535602
56545603 display.ReleaseTextures(tex);
5655
-
5656
- //if (parent != null && parent.GetMaterial() != null)
5657
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5658
- if (material != null)
5659
- {
5660
- materialdepth -= 1;
5661
- if (materialdepth > 0)
5662
- {
5663
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5664
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5665
- }
5666
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5667
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5668
- {
5669
- display.modelParams4[1] = GetMaterial().cameralight;
5670
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5671
- }
5604
+
5605
+ display.PopMaterial(this, selected);
56725606 }
56735607
56745608 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5710,7 +5644,7 @@
57105644 // resetMasterNode();
57115645 }
57125646
5713
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5647
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57145648 {
57155649 if (GetBRep() == null)
57165650 {
....@@ -5793,7 +5727,7 @@
57935727 boolean flipV = false; // true;
57945728 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57955729
5796
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5730
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57975731 {
57985732 if (hide)
57995733 return;
....@@ -5852,16 +5786,7 @@
58525786 // // ??????????????????????????? Touch();
58535787 // }
58545788
5855
- if (material != null)
5856
- {
5857
- materialstack[materialdepth] = material;
5858
- selectedstack[materialdepth] = selected;
5859
- cStatic.objectstack[materialdepth++] = this;
5860
- //System.out.println("material " + material);
5861
- //Applet3D.tracein("selected ", selected);
5862
- display.vector2buffer = projectedVertices;
5863
- material.Draw(display, selected);
5864
- }
5789
+display.PushMaterial2(this, selected);
58655790
58665791 Object3D child;
58675792 boolean sel;
....@@ -5913,19 +5838,7 @@
59135838 */
59145839 //depth += 1;
59155840
5916
- if (material != null)
5917
- {
5918
- materialdepth -= 1;
5919
- if (materialdepth > 0)
5920
- {
5921
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5922
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5923
- }
5924
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5925
- //else
5926
- //material.Draw(display, false);
5927
- }
5928
-
5841
+display.PopMaterial2(this);
59295842 /*
59305843 display.ReleaseTextures(tex);
59315844 */
....@@ -5936,9 +5849,9 @@
59365849
59375850 //static cVector min,max;
59385851
5939
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
5852
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59405853 {
5941
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
5854
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59425855 return; // no shadow for transparent objects
59435856
59445857 if (hide)
....@@ -6060,7 +5973,7 @@
60605973 {
60615974 //throw new Error();
60625975
6063
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5976
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
60645977
60655978 int[] strips = bRep.getRawIndices();
60665979
....@@ -6304,7 +6217,7 @@
63046217 // // r.norm.dot(v3) > -0.5)
63056218 // // continue;
63066219
6307
- drawFace(p, q, r, display, face);
6220
+ display.DrawFace(this, p, q, r, face);
63086221 }
63096222 gl.glEnd();
63106223 }
....@@ -6348,7 +6261,7 @@
63486261 Vertex q = bRep.GetVertex(face.q);
63496262 Vertex r = bRep.GetVertex(face.r);
63506263
6351
- drawFace(p, q, r, display, face);
6264
+ display.DrawFace(this, p, q, r, face);
63526265 }
63536266 gl.glEnd();
63546267 }
....@@ -6488,180 +6401,6 @@
64886401
64896402 transient FaceCompare[] facescompare = null;
64906403
6491
- void SetColor(CameraPane display, Vertex p0)
6492
- {
6493
- if (display.RENDERPROGRAM == 0)
6494
- {
6495
- float r = 0;
6496
- if (bRep != null)
6497
- {
6498
- if (bRep.stripified)
6499
- {
6500
- r = 1;
6501
- }
6502
- }
6503
- float g = 0;
6504
- if (bRep != null)
6505
- {
6506
- if (bRep.trimmed)
6507
- {
6508
- g = 1;
6509
- }
6510
- }
6511
- float b = 0;
6512
- if (support != null && link2master)
6513
- {
6514
- b = 1;
6515
- }
6516
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6517
- return;
6518
- }
6519
-
6520
- if (display.drawMode != CameraPane.SHADOW)
6521
- return;
6522
-
6523
- javax.media.opengl.GL gl = display.GetGL();
6524
-// if (true) return;
6525
-// float ao = p.AO;
6526
-//
6527
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6528
-// // ao = 1;
6529
-//
6530
-// gl.glColor4f(ao, ao, ao, 1);
6531
-
6532
-// CameraPane.selectedpoint.
6533
-// getAverage(cStatic.point1, true);
6534
- if (CameraPane.pointflow == null) // !random) // live)
6535
- {
6536
- return;
6537
- }
6538
-
6539
- cStatic.point1.set(0,0,0);
6540
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6541
-
6542
- cStatic.point1.sub(p0);
6543
-
6544
-
6545
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6546
-// {
6547
-// return;
6548
-// }
6549
-
6550
- //if (true)
6551
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6552
- {
6553
- return;
6554
- }
6555
-
6556
- float[] colorV = new float[3];
6557
-
6558
- if (false) // marked)
6559
- {
6560
- // debug rigging weights
6561
- for (int object = 0; object < p0.vertexlinks.length; object++)
6562
- {
6563
- float weight = p0.weights[object] / p0.totalweight;
6564
-
6565
- // if (weight < 0.1)
6566
- // {
6567
- // assert(weight == 0);
6568
- // continue;
6569
- // }
6570
-
6571
- if (p0.vertexlinks[object] == -1)
6572
- continue;
6573
-
6574
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6575
-
6576
- int color = //1 << object; //
6577
- //p.vertexlinks.length;
6578
- support.bRep.supports[p0.closestsupport].links[object];
6579
- colorV[2] += (color & 1) * weight;
6580
- colorV[1] += ((color & 2) >> 1) * weight;
6581
- colorV[0] += ((color & 4) >> 2) * weight;
6582
- }
6583
- }
6584
- else
6585
- {
6586
- if (drawingstarted)
6587
- {
6588
- // find next point
6589
- if (bRep.GetVertex(0).faceindices == null)
6590
- {
6591
- bRep.InitFaceIndices();
6592
- }
6593
-
6594
- double ymin = p0.y;
6595
-
6596
- Vertex newp = p0;
6597
-
6598
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6599
- {
6600
- int fi = p0.faceindices[fii];
6601
-
6602
- if (fi == -1)
6603
- break;
6604
-
6605
- Face f = bRep.GetFace(fi);
6606
-
6607
- Vertex p = bRep.GetVertex(f.p);
6608
- Vertex q = bRep.GetVertex(f.q);
6609
- Vertex r = bRep.GetVertex(f.r);
6610
-
6611
- int swap = (int)(Math.random()*3);
6612
-
6613
-// for (int s=swap; --s>=0;)
6614
-// {
6615
-// Vertex t = p;
6616
-// p = q;
6617
-// q = r;
6618
-// r = t;
6619
-// }
6620
- if (ymin > p.y)
6621
- {
6622
- ymin = p.y;
6623
- newp = p;
6624
-// break;
6625
- }
6626
- if (ymin > q.y)
6627
- {
6628
- ymin = q.y;
6629
- newp = q;
6630
-// break;
6631
- }
6632
- if (ymin > r.y)
6633
- {
6634
- ymin = r.y;
6635
- newp = r;
6636
-// break;
6637
- }
6638
- }
6639
-
6640
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6641
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6642
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6643
-
6644
- drawingstarted = false;
6645
-
6646
- // return;
6647
- }
6648
-
6649
- if (false) // CameraPane.DRAW
6650
- {
6651
- p0.AO = colorV[0] = 2;
6652
- colorV[1] = 2;
6653
- colorV[2] = 2;
6654
- }
6655
-
6656
- CameraPane.pointflow.add(p0);
6657
- CameraPane.pointflow.Touch();
6658
- }
6659
-
6660
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6661
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6662
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6663
- }
6664
-
66656404 void Print(Vertex v)
66666405 {
66676406 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
....@@ -6683,195 +6422,6 @@
66836422 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
66846423 }
66856424
6686
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6687
- CameraPane display, Face face)
6688
- {
6689
- if (pv.y == -10000 ||
6690
- qv.y == -10000 ||
6691
- rv.y == -10000)
6692
- return;
6693
-
6694
-// float b = f.nbiterations & 1;
6695
-// float g = (f.nbiterations>>1) & 1;
6696
-// float r = (f.nbiterations>>2) & 1;
6697
-//
6698
-// //if (f.weight == 10000)
6699
-// //{
6700
-// // r = 1; g = b = 0;
6701
-// //}
6702
-// //else
6703
-// //{
6704
-// // assert(f.weight < 10000);
6705
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6706
-// if (r<0)
6707
-// assert(r>=0);
6708
-// //}
6709
-
6710
- javax.media.opengl.GL gl = display.GetGL();
6711
-
6712
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6713
-
6714
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6715
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6716
- {
6717
- //gl.glBegin(gl.GL_TRIANGLES);
6718
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6719
- if (!hasnorm)
6720
- {
6721
- // System.out.println("FUCK!!");
6722
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6723
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6724
- LA.vecCross(v0, v1, v2);
6725
- LA.vecNormalize(v2);
6726
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6727
- }
6728
-
6729
- // P
6730
- float x = (float)pv.x;
6731
- float y = (float)pv.y;
6732
- float z = (float)pv.z;
6733
-
6734
- if (hasnorm)
6735
- {
6736
-// if (!pv.norm.normalized())
6737
-// assert(pv.norm.normalized());
6738
-
6739
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6740
- float nx = (float)pv.norm.x;
6741
- float ny = (float)pv.norm.y;
6742
- float nz = (float)pv.norm.z;
6743
-
6744
- x += nx * NORMALPUSH;
6745
- y += ny * NORMALPUSH;
6746
- z += nz * NORMALPUSH;
6747
-
6748
- gl.glNormal3f(nx, ny, nz);
6749
- }
6750
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6751
- SetColor(display, pv);
6752
- //gl.glColor4f(r, g, b, 1);
6753
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6754
- if (flipV)
6755
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6756
- else
6757
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6758
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6759
-
6760
- gl.glVertex3f(x, y, z);
6761
-
6762
- // Q
6763
- x = (float)qv.x;
6764
- y = (float)qv.y;
6765
- z = (float)qv.z;
6766
-
6767
-// Print(pv);
6768
- if (hasnorm)
6769
- {
6770
-// assert(qv.norm.normalized());
6771
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6772
- float nx = (float)qv.norm.x;
6773
- float ny = (float)qv.norm.y;
6774
- float nz = (float)qv.norm.z;
6775
-
6776
- x += nx * NORMALPUSH;
6777
- y += ny * NORMALPUSH;
6778
- z += nz * NORMALPUSH;
6779
-
6780
- gl.glNormal3f(nx, ny, nz);
6781
- }
6782
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6783
- // boolean locked = false;
6784
- // float eps = 0.1f;
6785
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6786
-
6787
- // int dot = 0; //*/ (int)f.dot;
6788
-
6789
- // if ((dot&1) == 0)
6790
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6791
-
6792
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6793
- if (flipV)
6794
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6795
- else
6796
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6797
- // else
6798
- // {
6799
- // locked = true;
6800
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6801
- // }
6802
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6803
- SetColor(display, qv);
6804
-
6805
- gl.glVertex3f(x, y, z);
6806
- //gl.glColor4f(r, g, b, 1);
6807
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6808
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6809
-// Print(qv);
6810
-
6811
- // R
6812
- x = (float)rv.x;
6813
- y = (float)rv.y;
6814
- z = (float)rv.z;
6815
-
6816
- if (hasnorm)
6817
- {
6818
-// assert(rv.norm.normalized());
6819
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6820
- float nx = (float)rv.norm.x;
6821
- float ny = (float)rv.norm.y;
6822
- float nz = (float)rv.norm.z;
6823
-
6824
- x += nx * NORMALPUSH;
6825
- y += ny * NORMALPUSH;
6826
- z += nz * NORMALPUSH;
6827
-
6828
- gl.glNormal3f(nx, ny, nz);
6829
- }
6830
-
6831
- // if ((dot&4) == 0)
6832
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6833
-
6834
- // if (wrap || !locked && (dot&8) != 0)
6835
- if (flipV)
6836
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6837
- else
6838
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6839
- // else
6840
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6841
-
6842
- // f.dot = dot;
6843
-
6844
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6845
- SetColor(display, rv);
6846
- //gl.glColor4f(r, g, b, 1);
6847
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6848
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6849
- gl.glVertex3f(x, y, z);
6850
-// Print(rv);
6851
- //gl.glEnd();
6852
- }
6853
- else
6854
- {
6855
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6856
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6857
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6858
-
6859
- }
6860
-
6861
- if (false) // (attributes & WIREFRAME) != 0)
6862
- {
6863
- gl.glDisable(gl.GL_LIGHTING);
6864
-
6865
- gl.glBegin(gl.GL_LINE_LOOP);
6866
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6867
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6868
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6869
- gl.glEnd();
6870
-
6871
- gl.glEnable(gl.GL_LIGHTING);
6872
- }
6873
- }
6874
-
68756425 void drawSelf(ClickInfo info, int level, boolean select)
68766426 {
68776427 if (bRep == null)
ParticleNode.java
....@@ -346,7 +346,7 @@
346346
347347 void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
348348 {
349
- if (display.drawMode == display.SELECTION || display.BOXMODE)
349
+ if (display.DrawMode() == display.SELECTION || display.BOXMODE)
350350 return; // hum...
351351
352352 Object3D geo = test;
....@@ -354,7 +354,7 @@
354354 if (support != null && link2master)
355355 geo = support;
356356
357
- if (live && display.isLIVE() && display.drawMode == display.SHADOW) // june 2013
357
+ if (live && Globals.isLIVE() && display.DrawMode() == display.SHADOW) // june 2013
358358 {
359359 Step();
360360 }
PhysicsNode.java
....@@ -110,7 +110,7 @@
110110
111111 void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
112112 {
113
- if (display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK
113
+ if (Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK
114114 {
115115 float ms = getDeltaTimeMicroseconds();
116116 float minFPS = 1000000f / 60f;
ScriptNode.java
....@@ -538,13 +538,13 @@
538538 }
539539 if (command.equals("stoplive") || command.equals("liveoff"))
540540 {
541
- if (CameraPane.isLIVE())
541
+ if (Globals.isLIVE())
542542 CameraPane.theRenderer.ToggleLive();
543543 return;
544544 }
545545 if (command.equals("startlive") || command.equals("liveon"))
546546 {
547
- if (!CameraPane.isLIVE())
547
+ if (!Globals.isLIVE())
548548 CameraPane.theRenderer.ToggleLive();
549549 return;
550550 }
....@@ -1793,7 +1793,7 @@
17931793 return;
17941794 }
17951795
1796
- if (isLive() && display.isLIVE() && display.drawMode == display.SHADOW)
1796
+ if (isLive() && Globals.isLIVE() && Globals.drawMode == display.SHADOW)
17971797 {
17981798 if (reader == null)
17991799 Init();
SwitchNode.java
....@@ -57,7 +57,7 @@
5757 parent = super.parent;
5858
5959 }
60
- if (live && display.isLIVE() && display.drawMode == display.SHADOW)
60
+ if (live && Globals.isLIVE() && display.DrawMode() == display.SHADOW)
6161 {
6262 if (countspeed == 0)
6363 {
....@@ -100,7 +100,7 @@
100100 bRep = (BoundaryRep) GrafreeD.clone(switchobject.get(0).bRep);
101101 }
102102
103
- if (CameraPane.SUPPORT && display.drawMode == display.SHADOW)
103
+ if (CameraPane.SUPPORT && display.DrawMode() == display.SHADOW)
104104 {
105105 Update();
106106 }
VehicleDemo.java
....@@ -490,7 +490,7 @@
490490
491491 renderme(display);
492492
493
- if (display.isLIVE()) // && display.drawMode != display.SHADOW)
493
+ if (Globals.isLIVE()) // && display.drawMode != display.SHADOW)
494494 {
495495 float ms = getDeltaTimeMicroseconds();
496496 float minFPS = 1000000f / 60f;
cFileSystemPane.java
....@@ -235,7 +235,7 @@
235235 System.out.println("drop2 = " + dtde + "; drop : " + target);
236236
237237 //assert dropTarget == dtde.getSource();
238
- if (target instanceof CameraPane)
238
+ if (target instanceof iCameraPane)
239239 {
240240 Object object = null;
241241 try
cLinker.java
....@@ -29,12 +29,12 @@
2929 editWindow = objectUI.GetEditor();
3030 }
3131
32
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
32
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
3333 {
3434 //if(count <= 0)
3535 // return;
3636
37
- if(display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
37
+ if(display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
3838 {
3939 super.draw(display, root, selected, blocked);
4040 return;
....@@ -134,7 +134,7 @@
134134 //System.out.println("point = " + cStatic.point7);
135135 LA.matConcat(cStatic.matrix1, cStatic.cone[d].toParent, cStatic.cone[d].toParent);
136136
137
- if (display.matrixdepth >= display.MAXSTACK)
137
+ if (false) // TODO display.matrixdepth >= display.MAXSTACK)
138138 {
139139 LA.matRotate(cStatic.cone[d].fromParent, cStatic.point8, cStatic.point7);
140140 LA.matRotate(cStatic.sphere[d].fromParent, cStatic.point8, cStatic.point7);
cMaterial.java
....@@ -118,244 +118,244 @@
118118 return current / anchor;
119119 }
120120
121
- void Draw(CameraPane display, boolean selected)
122
- {
123
- //new Exception().printStackTrace();
124
-
125
- if (display.IsFrozen() && !selected || display.ambientOcclusion) // || display.drawMode == display.SHADOW)
126
- {
127
- return;
128
- }
129
-
130
- javax.media.opengl.GL gl = display.GetGL();
131
-
132
- //Color col = Color.getHSBColor(color,modulation,1);
133
- //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
134
- if (!multiply)
135
- {
136
- display.color = color;
137
- display.saturation = modulation;
138
- }
139
- else
140
- {
141
- display.color *= color*2;
142
- display.saturation *= modulation*2;
143
- }
144
-
145
- cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
146
-
147
- float[] colorV = GrafreeD.colorV;
148
-
149
- /**/
150
- if (display.drawMode == display.DEFAULT) // && display.RENDERPROGRAM == 0)
151
- {
152
- colorV[0] = display.modelParams0[0] * diffuse;
153
- colorV[1] = display.modelParams0[1] * diffuse;
154
- colorV[2] = display.modelParams0[2] * diffuse;
155
- colorV[3] = opacity;
156
-
157
- gl.glColor4f(colorV[0], colorV[1], colorV[2], opacity);
158
- //System.out.println("Opacity = " + opacity);
159
-
160
- gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
161
- //color[0] /= 2; color[1] /= 2; color[2] /= 2;
162
- gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
163
-
164
- float amb = ambient;
165
- if (amb < cameralight)
166
- {
167
- amb = cameralight;
168
- }
169
- colorV[0] = display.modelParams0[0] * diffuse * amb;
170
- colorV[1] = display.modelParams0[1] * diffuse * amb;
171
- colorV[2] = display.modelParams0[2] * diffuse * amb;
172
- gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
173
- //color[0] /= 2; color[1] /= 2; color[2] /= 2;
174
- gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
175
-
176
- /**/
177
- colorV[0] = ((1 - metalness) + display.modelParams0[0] * metalness) * specular;
178
- colorV[1] = ((1 - metalness) + display.modelParams0[1] * metalness) * specular;
179
- colorV[2] = ((1 - metalness) + display.modelParams0[2] * metalness) * specular;
180
- gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
181
- //color[0] /= 2; color[1] /= 2; color[2] /= 2;
182
- gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
183
- colorV[0] = 10 / shininess; // 1/0.005f;
184
- //System.out.println("shininess = " + colorV[0]);
185
- if (colorV[0] > 128)
186
- {
187
- colorV[0] = 128;
188
- }
189
- gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
190
- gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
191
- /**/
192
- }
193
- /**/
194
-
195
- //selected = false;
196
- selected = selected && display.flash;
197
-
198
- //display.modelParams0[0] = 0; // pigment.r;
199
- //display.modelParams0[1] = 0; // pigment.g;
200
- //display.modelParams0[2] = 0; // pigment.b;
201
- if (!multiply)
202
- {
203
- display.modelParams0[3] = metalness;
204
- display.modelParams1[0] = diffuse;
205
- display.modelParams1[1] = specular;
206
- display.modelParams1[2] = 1 / shininess;
207
- display.modelParams1[3] = shift;
208
- display.modelParams2[0] = ambient;
209
- display.modelParams2[1] = lightarea;
210
- //System.out.println("light area = " + lightarea);
211
- display.modelParams2[2] = 1 / factor; // diffuseness
212
- display.modelParams2[3] = velvet;
213
- display.modelParams3[0] = sheen;
214
- display.modelParams3[1] = subsurface;
215
- display.modelParams3[2] = bump; // backlit
216
- display.modelParams3[3] = aniso;
217
- display.modelParams4[0] = anisoV;
218
- display.modelParams4[1] = selected ? 100 : cameralight;
219
- //System.out.println("selected = " + selected);
220
- display.modelParams4[2] = diffuseness;
221
- display.modelParams4[3] = shadow;
222
- display.modelParams5[0] = texture;
223
- display.modelParams5[1] = opacity;
224
- display.modelParams5[2] = fakedepth;
225
- display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (shadowbias - 0.005f) / 10;
226
- }
227
- else
228
- {
229
- display.modelParams0[3] *= metalness*2;
230
- display.modelParams1[0] *= diffuse*2;
231
- display.modelParams1[1] *= specular*2;
232
- display.modelParams1[2] *= shininess*2;
233
- display.modelParams1[3] *= shift*2;
234
- display.modelParams2[0] *= ambient*2;
235
- display.modelParams2[1] *= lightarea*2;
236
- display.modelParams2[2] *= factor*2;
237
- display.modelParams2[3] *= velvet*2;
238
- display.modelParams3[0] *= sheen*2;
239
- display.modelParams3[1] *= subsurface*2;
240
- display.modelParams3[2] *= bump*2;
241
- display.modelParams3[3] *= aniso*2;
242
- display.modelParams4[0] *= anisoV*2;
243
- display.modelParams4[1] *= cameralight*2;
244
- //System.out.println("selected = " + selected);
245
- display.modelParams4[2] *= diffuseness*2;
246
- display.modelParams4[3] *= shadow*2;
247
- display.modelParams5[0] *= texture*2;
248
- display.modelParams5[1] *= opacity*2;
249
- display.modelParams5[2] *= fakedepth*2;
250
- display.modelParams5[3] *= shadowbias*2;
251
- }
252
-
253
- display.modelParams6[0] = 0;
254
- display.modelParams6[1] = 0;
255
- display.modelParams6[2] = 0;
256
- display.modelParams6[3] = 0;
257
-
258
- display.modelParams7[0] = 0;
259
- display.modelParams7[1] = 1000;
260
- display.modelParams7[2] = 0;
261
- display.modelParams7[3] = 0;
262
-
263
- display.modelParams6[0] = 100; // criss de bug de bump
264
-
265
- Object3D.cVector2[] extparams = display.vector2buffer;
266
- if (extparams != null && extparams.length > 0 && extparams[0] != null)
267
- {
268
- display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
269
- display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
270
- if (extparams.length > 1)
271
- {
272
- display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
273
- display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
274
- if (extparams.length > 2)
275
- {
276
- display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
277
- float x = extparams[2].y / 1000.0f;
278
- //if (x == 0)
279
- // x = 1f;
280
- 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
281
- if (extparams[2].y > 0)
282
- {
283
- //System.out.println("extparams[1].y = " + extparams[1].y);
284
- //System.out.println("extparams[2].y = " + extparams[2].y);
285
- //System.out.println("opacity power = " + display.modelParams7[1]);
286
- }
287
- }
288
- }
289
- }
290
-
291
- //if (display.modelParams6[2] != 0)
292
- /*
293
- System.out.println("modelParams0[0] = " + display.modelParams0[0]);
294
- System.out.println("modelParams0[1] = " + display.modelParams0[1]);
295
- System.out.println("modelParams0[2] = " + display.modelParams0[2]);
296
- System.out.println("modelParams0[3] = " + display.modelParams0[3]);
297
- System.out.println("modelParams1[0] = " + display.modelParams1[0]);
298
- System.out.println("modelParams1[1] = " + display.modelParams1[1]);
299
- System.out.println("modelParams1[2] = " + display.modelParams1[2]);
300
- System.out.println("modelParams1[3] = " + display.modelParams1[3]);
301
- System.out.println("modelParams2[0] = " + display.modelParams2[0]);
302
- System.out.println("modelParams2[1] = " + display.modelParams2[1]);
303
- System.out.println("modelParams2[2] = " + display.modelParams2[2]);
304
- System.out.println("modelParams2[3] = " + display.modelParams2[3]);
305
- System.out.println("modelParams3[0] = " + display.modelParams3[0]);
306
- System.out.println("modelParams3[1] = " + display.modelParams3[1]);
307
- System.out.println("modelParams3[2] = " + display.modelParams3[2]);
308
- System.out.println("modelParams3[3] = " + display.modelParams3[3]);
309
- System.out.println("modelParams4[0] = " + display.modelParams4[0]);
310
- System.out.println("modelParams4[1] = " + display.modelParams4[1]);
311
- System.out.println("modelParams4[2] = " + display.modelParams4[2]);
312
- System.out.println("modelParams4[3] = " + display.modelParams4[3]);
313
- System.out.println("modelParams5[0] = " + display.modelParams5[0]);
314
- System.out.println("modelParams5[1] = " + display.modelParams5[1]);
315
- System.out.println("modelParams5[2] = " + display.modelParams5[2]);
316
- System.out.println("modelParams5[3] = " + display.modelParams5[3]);
317
- System.out.println("modelParams6[0] = " + display.modelParams6[0]);
318
- System.out.println("modelParams6[1] = " + display.modelParams6[1]);
319
- System.out.println("modelParams6[2] = " + display.modelParams6[2]);
320
- System.out.println("modelParams6[3] = " + display.modelParams6[3]);
321
- System.out.println("modelParams7[0] = " + display.modelParams7[0]);
322
- System.out.println("modelParams7[1] = " + display.modelParams7[1]);
323
- System.out.println("modelParams7[2] = " + display.modelParams7[2]);
324
- System.out.println("modelParams7[3] = " + display.modelParams7[3]);
325
- /**/
326
- //assert (display.modelParams6[2] == 0);
327
-
328
- //System.out.println("noise power = " + display.modelParams7[0]);
329
- //System.out.println("shadowbias = " + shadowbias);
330
-
331
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
332
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
333
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
334
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
335
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
336
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
337
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
338
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
339
-
340
- int mode = display.FP_SHADER;
341
-
342
- if (aniso != anisoV || aniso > 0.002)
343
- {
344
- mode |= display.FP_ANISO;
345
- }
346
-
347
- display.EnableProgram(mode);
348
-
349
- //System.out.println("opacity power = " + display.modelParams7[1]);
350
-
351
- if (!multiply)
352
- {
353
- if (display.drawMode == CameraPane.SHADOW)
354
- gl.glDepthMask(opacity >= 0.9 && display.modelParams7[1] > 0.1);
355
- else
356
- gl.glDepthMask(opacity >= 0.99);
357
- }
358
- }
121
+// void Draw(iCameraPane display, boolean selected)
122
+// {
123
+// //new Exception().printStackTrace();
124
+//
125
+// if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW)
126
+// {
127
+// return;
128
+// }
129
+//
130
+// javax.media.opengl.GL gl = display.GetGL();
131
+//
132
+// //Color col = Color.getHSBColor(color,modulation,1);
133
+// //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
134
+// if (!multiply)
135
+// {
136
+// display.color = color;
137
+// display.saturation = modulation;
138
+// }
139
+// else
140
+// {
141
+// display.color *= color*2;
142
+// display.saturation *= modulation*2;
143
+// }
144
+//
145
+// cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
146
+//
147
+// float[] colorV = GrafreeD.colorV;
148
+//
149
+// /**/
150
+// if (display.drawMode == display.DEFAULT) // && display.RENDERPROGRAM == 0)
151
+// {
152
+// colorV[0] = display.modelParams0[0] * diffuse;
153
+// colorV[1] = display.modelParams0[1] * diffuse;
154
+// colorV[2] = display.modelParams0[2] * diffuse;
155
+// colorV[3] = opacity;
156
+//
157
+// gl.glColor4f(colorV[0], colorV[1], colorV[2], opacity);
158
+// //System.out.println("Opacity = " + opacity);
159
+//
160
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
161
+// //color[0] /= 2; color[1] /= 2; color[2] /= 2;
162
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
163
+//
164
+// float amb = ambient;
165
+// if (amb < cameralight)
166
+// {
167
+// amb = cameralight;
168
+// }
169
+// colorV[0] = display.modelParams0[0] * diffuse * amb;
170
+// colorV[1] = display.modelParams0[1] * diffuse * amb;
171
+// colorV[2] = display.modelParams0[2] * diffuse * amb;
172
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0);
173
+// //color[0] /= 2; color[1] /= 2; color[2] /= 2;
174
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0);
175
+//
176
+// /**/
177
+// colorV[0] = ((1 - metalness) + display.modelParams0[0] * metalness) * specular;
178
+// colorV[1] = ((1 - metalness) + display.modelParams0[1] * metalness) * specular;
179
+// colorV[2] = ((1 - metalness) + display.modelParams0[2] * metalness) * specular;
180
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0);
181
+// //color[0] /= 2; color[1] /= 2; color[2] /= 2;
182
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0);
183
+// colorV[0] = 10 / shininess; // 1/0.005f;
184
+// //System.out.println("shininess = " + colorV[0]);
185
+// if (colorV[0] > 128)
186
+// {
187
+// colorV[0] = 128;
188
+// }
189
+// gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0);
190
+// gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0);
191
+// /**/
192
+// }
193
+// /**/
194
+//
195
+// //selected = false;
196
+// selected = selected && display.flash;
197
+//
198
+// //display.modelParams0[0] = 0; // pigment.r;
199
+// //display.modelParams0[1] = 0; // pigment.g;
200
+// //display.modelParams0[2] = 0; // pigment.b;
201
+// if (!multiply)
202
+// {
203
+// display.modelParams0[3] = metalness;
204
+// display.modelParams1[0] = diffuse;
205
+// display.modelParams1[1] = specular;
206
+// display.modelParams1[2] = 1 / shininess;
207
+// display.modelParams1[3] = shift;
208
+// display.modelParams2[0] = ambient;
209
+// display.modelParams2[1] = lightarea;
210
+// //System.out.println("light area = " + lightarea);
211
+// display.modelParams2[2] = 1 / factor; // diffuseness
212
+// display.modelParams2[3] = velvet;
213
+// display.modelParams3[0] = sheen;
214
+// display.modelParams3[1] = subsurface;
215
+// display.modelParams3[2] = bump; // backlit
216
+// display.modelParams3[3] = aniso;
217
+// display.modelParams4[0] = anisoV;
218
+// display.modelParams4[1] = selected ? 100 : cameralight;
219
+// //System.out.println("selected = " + selected);
220
+// display.modelParams4[2] = diffuseness;
221
+// display.modelParams4[3] = shadow;
222
+// display.modelParams5[0] = texture;
223
+// display.modelParams5[1] = opacity;
224
+// display.modelParams5[2] = fakedepth;
225
+// display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (shadowbias - 0.005f) / 10;
226
+// }
227
+// else
228
+// {
229
+// display.modelParams0[3] *= metalness*2;
230
+// display.modelParams1[0] *= diffuse*2;
231
+// display.modelParams1[1] *= specular*2;
232
+// display.modelParams1[2] *= shininess*2;
233
+// display.modelParams1[3] *= shift*2;
234
+// display.modelParams2[0] *= ambient*2;
235
+// display.modelParams2[1] *= lightarea*2;
236
+// display.modelParams2[2] *= factor*2;
237
+// display.modelParams2[3] *= velvet*2;
238
+// display.modelParams3[0] *= sheen*2;
239
+// display.modelParams3[1] *= subsurface*2;
240
+// display.modelParams3[2] *= bump*2;
241
+// display.modelParams3[3] *= aniso*2;
242
+// display.modelParams4[0] *= anisoV*2;
243
+// display.modelParams4[1] *= cameralight*2;
244
+// //System.out.println("selected = " + selected);
245
+// display.modelParams4[2] *= diffuseness*2;
246
+// display.modelParams4[3] *= shadow*2;
247
+// display.modelParams5[0] *= texture*2;
248
+// display.modelParams5[1] *= opacity*2;
249
+// display.modelParams5[2] *= fakedepth*2;
250
+// display.modelParams5[3] *= shadowbias*2;
251
+// }
252
+//
253
+// display.modelParams6[0] = 0;
254
+// display.modelParams6[1] = 0;
255
+// display.modelParams6[2] = 0;
256
+// display.modelParams6[3] = 0;
257
+//
258
+// display.modelParams7[0] = 0;
259
+// display.modelParams7[1] = 1000;
260
+// display.modelParams7[2] = 0;
261
+// display.modelParams7[3] = 0;
262
+//
263
+// display.modelParams6[0] = 100; // criss de bug de bump
264
+//
265
+// Object3D.cVector2[] extparams = display.vector2buffer;
266
+// if (extparams != null && extparams.length > 0 && extparams[0] != null)
267
+// {
268
+// display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
269
+// display.modelParams6[1] = extparams[0].y / 1000.0f; // noise
270
+// if (extparams.length > 1)
271
+// {
272
+// display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade
273
+// display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough
274
+// if (extparams.length > 2)
275
+// {
276
+// display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power
277
+// float x = extparams[2].y / 1000.0f;
278
+// //if (x == 0)
279
+// // x = 1f;
280
+// 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
281
+// if (extparams[2].y > 0)
282
+// {
283
+// //System.out.println("extparams[1].y = " + extparams[1].y);
284
+// //System.out.println("extparams[2].y = " + extparams[2].y);
285
+// //System.out.println("opacity power = " + display.modelParams7[1]);
286
+// }
287
+// }
288
+// }
289
+// }
290
+//
291
+// //if (display.modelParams6[2] != 0)
292
+// /*
293
+// System.out.println("modelParams0[0] = " + display.modelParams0[0]);
294
+// System.out.println("modelParams0[1] = " + display.modelParams0[1]);
295
+// System.out.println("modelParams0[2] = " + display.modelParams0[2]);
296
+// System.out.println("modelParams0[3] = " + display.modelParams0[3]);
297
+// System.out.println("modelParams1[0] = " + display.modelParams1[0]);
298
+// System.out.println("modelParams1[1] = " + display.modelParams1[1]);
299
+// System.out.println("modelParams1[2] = " + display.modelParams1[2]);
300
+// System.out.println("modelParams1[3] = " + display.modelParams1[3]);
301
+// System.out.println("modelParams2[0] = " + display.modelParams2[0]);
302
+// System.out.println("modelParams2[1] = " + display.modelParams2[1]);
303
+// System.out.println("modelParams2[2] = " + display.modelParams2[2]);
304
+// System.out.println("modelParams2[3] = " + display.modelParams2[3]);
305
+// System.out.println("modelParams3[0] = " + display.modelParams3[0]);
306
+// System.out.println("modelParams3[1] = " + display.modelParams3[1]);
307
+// System.out.println("modelParams3[2] = " + display.modelParams3[2]);
308
+// System.out.println("modelParams3[3] = " + display.modelParams3[3]);
309
+// System.out.println("modelParams4[0] = " + display.modelParams4[0]);
310
+// System.out.println("modelParams4[1] = " + display.modelParams4[1]);
311
+// System.out.println("modelParams4[2] = " + display.modelParams4[2]);
312
+// System.out.println("modelParams4[3] = " + display.modelParams4[3]);
313
+// System.out.println("modelParams5[0] = " + display.modelParams5[0]);
314
+// System.out.println("modelParams5[1] = " + display.modelParams5[1]);
315
+// System.out.println("modelParams5[2] = " + display.modelParams5[2]);
316
+// System.out.println("modelParams5[3] = " + display.modelParams5[3]);
317
+// System.out.println("modelParams6[0] = " + display.modelParams6[0]);
318
+// System.out.println("modelParams6[1] = " + display.modelParams6[1]);
319
+// System.out.println("modelParams6[2] = " + display.modelParams6[2]);
320
+// System.out.println("modelParams6[3] = " + display.modelParams6[3]);
321
+// System.out.println("modelParams7[0] = " + display.modelParams7[0]);
322
+// System.out.println("modelParams7[1] = " + display.modelParams7[1]);
323
+// System.out.println("modelParams7[2] = " + display.modelParams7[2]);
324
+// System.out.println("modelParams7[3] = " + display.modelParams7[3]);
325
+// /**/
326
+// //assert (display.modelParams6[2] == 0);
327
+//
328
+// //System.out.println("noise power = " + display.modelParams7[0]);
329
+// //System.out.println("shadowbias = " + shadowbias);
330
+//
331
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
332
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0);
333
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0);
334
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0);
335
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
336
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
337
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0);
338
+// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0);
339
+//
340
+// int mode = display.FP_SHADER;
341
+//
342
+// if (aniso != anisoV || aniso > 0.002)
343
+// {
344
+// mode |= display.FP_ANISO;
345
+// }
346
+//
347
+// display.EnableProgram(mode);
348
+//
349
+// //System.out.println("opacity power = " + display.modelParams7[1]);
350
+//
351
+// if (!multiply)
352
+// {
353
+// if (display.drawMode == CameraPane.SHADOW)
354
+// gl.glDepthMask(opacity >= 0.9 && display.modelParams7[1] > 0.1);
355
+// else
356
+// gl.glDepthMask(opacity >= 0.99);
357
+// }
358
+// }
359359
360360 float color = 0.5f, modulation /*SATURATION*/ = 0.001f, metalness = 0.001f;
361361 float diffuse = 0.75f, specular = 0.25f, shininess = 0.75f, shift = 1;
cMesh.java
....@@ -644,7 +644,7 @@
644644 gl.glEnable(gl.GL_LIGHTING);
645645 }
646646
647
- if (live && display.isLIVE() && display.drawMode == CameraPane.DEFAULT)
647
+ if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT)
648648 {
649649 //System.out.println("UPDATE");
650650 if (Phys == null)
cSpring.java
....@@ -10,7 +10,7 @@
1010
1111 boolean IsStatic()
1212 {
13
- return !(live && (CameraPane.isLIVE() || CameraPane.waslive));
13
+ return !(live && (Globals.isLIVE() || CameraPane.waslive));
1414 }
1515
1616 void Revert()
....@@ -569,7 +569,7 @@
569569
570570 //gl.glDisable(GL.GL_LIGHTING);
571571
572
- if (display.drawMode == display.SHADOW)
572
+ if (display.DrawMode() == display.SHADOW)
573573 {
574574 gl.glDisable(gl.GL_CULL_FACE);
575575 }
....@@ -762,7 +762,7 @@
762762 gl.glEnd();
763763 gl.glEnable(GL.GL_LIGHTING);
764764 /**/
765
- if (display.CULLFACE)
765
+ if (display.BackFaceCullMode())
766766 {
767767 gl.glEnable(gl.GL_CULL_FACE);
768768 }
....@@ -775,7 +775,7 @@
775775 // displaylist = 0; // june 2013 -1;
776776
777777 //System.out.println("DRAW " + display.drawMode);
778
- if (live && display.isLIVE() && display.drawMode == display.DEFAULT)
778
+ if (live && Globals.isLIVE() && display.DrawMode() == display.DEFAULT)
779779 {
780780 //System.out.println("UPDATE");
781781 Phys.update();
iCameraPane.java
....@@ -0,0 +1,53 @@
1
+
2
+public interface iCameraPane
3
+{
4
+ static final public int DEFAULT = 0;
5
+ static final public int SELECTION = 1;
6
+ static final public int SHADOW = 2;
7
+ static final public int OCCLUSION = 3;
8
+
9
+ void ClearDepth();
10
+
11
+ void DepthTest(boolean depthtest);
12
+
13
+ void DepthWrite(boolean depthwrite);
14
+
15
+ void BackFaceCull(boolean bfc);
16
+
17
+ boolean BackFaceCullMode();
18
+
19
+ boolean IsAmbientOcclusionOn();
20
+
21
+ boolean IsFrozen();
22
+
23
+ javax.media.opengl.GL GetGL();
24
+
25
+ // Currently in Globals
26
+ int DrawMode();
27
+
28
+ void PushMatrix(double[][] matrix, int count);
29
+ void PopMatrix(double[][] matrix);
30
+
31
+ void PushTextureMatrix(double[][] matrix, int count);
32
+ void PopTextureMatrix(double[][] matrix);
33
+
34
+ Camera EyeCamera();
35
+
36
+ Camera LightCamera();
37
+
38
+ Camera RenderCamera();
39
+
40
+ // Should be cMaterial
41
+ void PushMaterial(Object3D obj, boolean selected);
42
+ void PushMaterial2(Object3D obj, boolean selected);
43
+
44
+ void PopMaterial(Object3D obj, boolean selected);
45
+ void PopMaterial2(Object3D obj);
46
+
47
+ void DrawString(Object3D obj);
48
+
49
+ void BindTextures(cTexture tex, int resolution);
50
+ void ReleaseTextures(cTexture tex);
51
+
52
+ void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face);
53
+}