Normand Briere
2019-04-22 ec1ab4278b2408d3b19083e530e0376f809cca44
Object3D.java
....@@ -21,6 +21,19 @@
2121
2222 ScriptNode scriptnode;
2323
24
+ void InitOthers()
25
+ {
26
+ if (projectedVertices == null || projectedVertices.length <= 2)
27
+ {
28
+ projectedVertices = new Object3D.cVector2[3];
29
+ }
30
+ for (int i = 0; i < 3; i++)
31
+ {
32
+ projectedVertices[i] = new cVector2(); // Others
33
+ }
34
+ projectedVertices[0].x = 100; // bump
35
+ }
36
+
2437 void MinMax(cVector minima, cVector maxima)
2538 {
2639 for (int xyz = 0; xyz < 3; xyz++)
....@@ -296,6 +309,8 @@
296309 boolean speedup = false;
297310 boolean rewind = false;
298311
312
+ float NORMALPUSH = 0;
313
+
299314 Object3D support;
300315
301316 Object3D GetObject()
....@@ -355,7 +370,7 @@
355370
356371 int MemorySize()
357372 {
358
- if (memorysize == 0)
373
+ if (true) // memorysize == 0)
359374 {
360375 try
361376 {
....@@ -745,7 +760,7 @@
745760
746761 int GetTransformCount()
747762 {
748
- // marde pour serialization de Texture
763
+ // patch pour serialization de Texture
749764 resetmaxcount();
750765 resettransformcount();
751766 resetstep();
....@@ -779,9 +794,12 @@
779794 // factor = CameraPane.STEP;
780795 // }
781796
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
797
+ if (marked && Globals.isLIVE() && live &&
798
+ //TEMP21aug2018
799
+ Globals.DrawMode() == iCameraPane.SHADOW &&
800
+ currentframe != Globals.framecount)
783801 {
784
- currentframe = CameraPane.framecount;
802
+ currentframe = Globals.framecount;
785803
786804 // System.err.println("transformcount = " + transformcount);
787805 // System.err.println("factor = " + factor);
....@@ -935,7 +953,7 @@
935953
936954 public Object clone()
937955 {
938
- return GraphreeD.clone(this);
956
+ return GrafreeD.clone(this);
939957 }
940958
941959 Object3D copyExpand()
....@@ -1446,7 +1464,16 @@
14461464 // if (other == null)
14471465 // return;
14481466
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1467
+ if (other != null)
1468
+ {
1469
+ BoundaryRep.SEUIL = other.material.cameralight;
1470
+
1471
+ // Set default to 0.1
1472
+ BoundaryRep.SEUIL /= 2;
1473
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1474
+ }
1475
+
1476
+ System.out.println("Link this = " + this + "; support = " + other);
14501477
14511478 //if (bRep != null)
14521479 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1728,7 @@
17011728 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021729 o.bRep = transientrep;
17031730 if (clone)
1704
- o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1731
+ o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17051732 o.CreateMaterial();
17061733 o.SetAttributes(this, -1);
17071734 //parent
....@@ -1714,7 +1741,7 @@
17141741 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151742 o.bRep = bRep;
17161743 if (clone)
1717
- o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1744
+ o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17181745 o.CreateMaterial();
17191746 //o.overwriteThis(this, -1);
17201747 o.SetAttributes(this, -1);
....@@ -1756,7 +1783,7 @@
17561783 // {
17571784 // assert(bRep == null);
17581785 // Object3D o = new Object3D("Geometry:" + this.name);
1759
-// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
1786
+// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
17601787 // o.CreateMaterial();
17611788 // parent.addChild(o);
17621789 // }
....@@ -1765,7 +1792,7 @@
17651792 // {
17661793 // assert(transientrep == null);
17671794 // Object3D o = new Object3D("Geometry:" + this.name);
1768
-// o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
1795
+// o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
17691796 // o.CreateMaterial();
17701797 // parent.addChild(o);
17711798 // }
....@@ -1816,8 +1843,9 @@
18161843 if (obj.name == null)
18171844 continue; // can't be a null one
18181845
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1846
+ String name = obj.name.split(":")[0]; // Poser generates a count
1847
+ //if (n.startsWith(obj.name))
1848
+ if (n.contains(name))
18211849 {
18221850 theobj = obj;
18231851 count++;
....@@ -2120,15 +2148,8 @@
21202148 if (/*parent != null &&*/ material == null)
21212149 {
21222150 material = new cMaterial(GetMaterial());
2123
- if (projectedVertices == null || projectedVertices.length <= 2)
2124
- {
2125
- projectedVertices = new Object3D.cVector2[3];
2126
- }
2127
- for (int i = 0; i < 3; i++)
2128
- {
2129
- projectedVertices[i] = new cVector2(); // Others
2130
- }
2131
- projectedVertices[0].x = 100; // bump
2151
+
2152
+ InitOthers();
21322153
21332154 if (this instanceof Camera)
21342155 {
....@@ -2732,6 +2753,24 @@
27322753 blockloop = false;
27332754 }
27342755
2756
+ void GenNormalsMINE()
2757
+ {
2758
+ if (blockloop)
2759
+ return;
2760
+
2761
+ blockloop = true;
2762
+ GenNormalsMINE0();
2763
+ for (int i = 0; i < Children().Size(); i++)
2764
+ {
2765
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2766
+ if (child == null)
2767
+ continue;
2768
+ child.GenNormalsMINE();
2769
+// Children().release(i);
2770
+ }
2771
+ blockloop = false;
2772
+ }
2773
+
27352774 void ClearColors()
27362775 {
27372776 if (blockloop)
....@@ -2876,6 +2915,15 @@
28762915 if (bRep != null)
28772916 {
28782917 bRep.GenerateNormals(crease);
2918
+ Touch();
2919
+ }
2920
+ }
2921
+
2922
+ void GenNormalsMINE0()
2923
+ {
2924
+ if (bRep != null)
2925
+ {
2926
+ bRep.GenerateNormalsMINE();
28792927 Touch();
28802928 }
28812929 }
....@@ -3153,7 +3201,7 @@
31533201
31543202 BoundaryRep sup = bRep.support;
31553203 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep);
3204
+ BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
31573205 // bRep.SplitInTwo(onlyone); // thread...
31583206 temprep.SplitInTwo(reduction34, onlyone);
31593207 bRep = temprep;
....@@ -3677,7 +3725,7 @@
36773725 if (child == null)
36783726 continue;
36793727
3680
- if (GraphreeD.RENDERME > 0)
3728
+ if (GrafreeD.RENDERME > 0)
36813729 {
36823730 if (child instanceof Merge)
36833731 ((Merge)child).renderme();
....@@ -3717,7 +3765,7 @@
37173765
37183766 boolean getCentroid(cVector centroid, boolean xform)
37193767 {
3720
- assert(false);
3768
+// for speaker assert(false);
37213769 if (blockloop)
37223770 return false;
37233771
....@@ -3828,7 +3876,7 @@
38283876 if (child == null)
38293877 continue;
38303878
3831
- if (GraphreeD.RENDERME > 0)
3879
+ if (GrafreeD.RENDERME > 0)
38323880 {
38333881 if (child instanceof Merge)
38343882 ((Merge)child).renderme();
....@@ -4023,7 +4071,7 @@
40234071 if (child == null)
40244072 continue;
40254073
4026
- if (GraphreeD.RENDERME > 0)
4074
+ if (GrafreeD.RENDERME > 0)
40274075 {
40284076 if (child instanceof Merge)
40294077 ((Merge)child).renderme();
....@@ -4111,7 +4159,7 @@
41114159 if (blockloop)
41124160 return;
41134161
4114
- for (int i=0; i<size(); i++)
4162
+ for (int i=0; i<Size(); i++)
41154163 {
41164164 if (get(i).parent != this)
41174165 {
....@@ -4120,6 +4168,22 @@
41204168 }
41214169 blockloop = true;
41224170 get(i).RepairParent();
4171
+ blockloop = false;
4172
+ }
4173
+ }
4174
+
4175
+ void RepairShadow()
4176
+ {
4177
+ if (blockloop)
4178
+ return;
4179
+
4180
+ if (this.material != null)
4181
+ this.InitOthers();
4182
+
4183
+ for (int i=0; i<Size(); i++)
4184
+ {
4185
+ blockloop = true;
4186
+ get(i).RepairShadow();
41234187 blockloop = false;
41244188 }
41254189 }
....@@ -4515,16 +4579,28 @@
45154579
45164580 Object3D GetFileRoot()
45174581 {
4582
+ if (overflow)
4583
+ return null;
4584
+
4585
+ overflow = true;
4586
+
4587
+ Object3D pfr = null;
4588
+
45184589 if (parent == null && fileparent == null)
4519
- return this;
4590
+ pfr = this;
45204591
45214592 if (parent == null && fileparent != null) // V4.gfd???
4522
- return fileparent;
4593
+ pfr = fileparent;
45234594
4524
- if (parent == null)
4525
- return this;
4595
+ if (pfr == null && parent == null)
4596
+ pfr = this;
45264597
4527
- return parent.GetFileRoot();
4598
+ if (pfr == null)
4599
+ pfr = parent.GetFileRoot();
4600
+
4601
+ overflow = false;
4602
+
4603
+ return pfr;
45284604 }
45294605
45304606 cTreePath GetPath()
....@@ -4925,7 +5001,8 @@
49255001 } else //
49265002 if (editWindow != null)
49275003 {
4928
- editWindow.cameraView.lighttouched = true;
5004
+ //editWindow.cameraView.lighttouched = true;
5005
+ Globals.lighttouched = true;
49295006 }
49305007 }
49315008
....@@ -5237,25 +5314,21 @@
52375314 }
52385315 }
52395316
5240
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5317
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52415318 {
52425319 Draw(display, root, selected, blocked);
52435320 }
52445321
5245
- static cMaterial[] materialstack = new cMaterial[65536];
5246
- static boolean[] selectedstack = new boolean[65536];
5247
- static int materialdepth = 0;
5248
-
52495322 boolean NeedSupport()
52505323 {
52515324 return
52525325 CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
52535326 // PROBLEM with CROWD!!
5254
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5327
+ && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
52555328 }
52565329
52575330
5258
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5331
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52595332 {
52605333 Invariants(); // june 2013
52615334
....@@ -5264,7 +5337,7 @@
52645337 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52655338 }
52665339
5267
- if (display.drawMode == CameraPane.SELECTION &&
5340
+ if (display.DrawMode() == iCameraPane.SELECTION &&
52685341 hide)
52695342 return;
52705343
....@@ -5280,10 +5353,10 @@
52805353 if (name != null && name.contains("sclera"))
52815354 name = name;
52825355
5283
- if (this instanceof CheckerIG)
5356
+ if (this instanceof Checker)
52845357 return;
52855358
5286
- if (display.drawMode == display.SHADOW && PASSTEST)
5359
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52875360 return;
52885361
52895362 if (count <= 0)
....@@ -5291,8 +5364,8 @@
52915364 return;
52925365 }
52935366
5294
- if ((//display.drawMode == CameraPane.SHADOW ||
5295
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5367
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
+ display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
52965369 {
52975370 return;
52985371 }
....@@ -5333,15 +5406,15 @@
53335406
53345407 boolean compiled = false;
53355408
5336
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5409
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
53375410
5338
- if (!selectmode && //display.drawMode != display.SELECTION &&
5411
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
53395412 (touched || (bRep != null && bRep.displaylist <= 0)))
53405413 {
5341
- display.lighttouched = true;
5414
+ Globals.lighttouched = true;
53425415 } // all panes...
5343
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5344
- 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 &&
53455418 (touched || (bRep != null && bRep.displaylist <= 0)))
53465419 {
53475420 if (!(this instanceof Composite))
....@@ -5372,7 +5445,7 @@
53725445 }
53735446 //gl.glDrawBuffer(gl.GL_BACK);
53745447 // XXX touched = false;
5375
- display.lighttouched = true; // all panes...
5448
+ Globals.lighttouched = true; // all panes...
53765449 }
53775450
53785451 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5411,12 +5484,12 @@
54115484
54125485 // frustum culling
54135486 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5414
- && display.drawMode != CameraPane.SELECTION)
5487
+ && display.DrawMode() != CameraPane.SELECTION)
54155488 {
5416
- if (display.drawMode == CameraPane.SHADOW)
5489
+ if (display.DrawMode() == CameraPane.SHADOW)
54175490 {
54185491 if (!link2master // tricky to cull in shadow mode.
5419
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5492
+ && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
54205493 {
54215494 //System.out.print("CULLED");
54225495 culled = true;
....@@ -5424,7 +5497,7 @@
54245497 }
54255498 else
54265499 //GetBRep().getBounds(v0, v1, this);
5427
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5500
+ if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
54285501 culled = true;
54295502
54305503 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5460,7 +5533,7 @@
54605533
54615534
54625535 if (!culled)
5463
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5536
+ if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
54645537 {
54655538 if (GetBRep() != null)
54665539 {
....@@ -5486,53 +5559,7 @@
54865559 color[2] /= 2;
54875560 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
54885561 */
5489
- if (material != null)
5490
- {
5491
- materialstack[materialdepth] = material;
5492
- selectedstack[materialdepth] = selected;
5493
- cStatic.objectstack[materialdepth++] = this;
5494
- //System.out.println("material " + material);
5495
- //Applet3D.tracein(this, selected);
5496
- display.vector2buffer = projectedVertices;
5497
- if (this instanceof Camera)
5498
- {
5499
- display.options1[0] = material.shift;
5500
- //System.out.println("shift " + material.shift);
5501
- display.options1[1] = material.lightarea;
5502
- display.options1[2] = material.shadowbias;
5503
- display.options1[3] = material.aniso;
5504
- display.options1[4] = material.anisoV;
5505
- display.options2[0] = material.opacity;
5506
- display.options2[1] = material.diffuse;
5507
- display.options2[2] = material.factor;
5508
-
5509
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5510
- display.options3[3] = material.cameralight/0.2f;
5511
-
5512
- // if (display.CURRENTANTIALIAS > 0)
5513
- // display.options3[3] /= 4;
5514
-
5515
- /*
5516
- System.out.println("Focus = " + display.options1[0]);
5517
- System.out.println("Aperture = " + display.options1[1]);
5518
- System.out.println("ShadowBlur = " + display.options1[2]);
5519
- System.out.println("Antialiasing = " + display.options1[3]);
5520
- System.out.println("Fog = " + display.options2[0]);
5521
- System.out.println("Intensity = " + display.options2[1]);
5522
- System.out.println("Elevation = " + display.options2[2]);
5523
- /**/
5524
- } else
5525
- {
5526
- material.Draw(display, selected);
5527
- }
5528
- } else
5529
- {
5530
- if (selected && CameraPane.flash)
5531
- {
5532
- display.modelParams4[1] = 100;
5533
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5534
- }
5535
- }
5562
+ display.PushMaterial(this, selected);
55365563
55375564 //System.out.println("call list " + list);
55385565 //System.out.println();
....@@ -5574,23 +5601,8 @@
55745601 }
55755602
55765603 display.ReleaseTextures(tex);
5577
-
5578
- //if (parent != null && parent.GetMaterial() != null)
5579
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5580
- if (material != null)
5581
- {
5582
- materialdepth -= 1;
5583
- if (materialdepth > 0)
5584
- {
5585
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5586
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5587
- }
5588
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5589
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5590
- {
5591
- display.modelParams4[1] = GetMaterial().cameralight;
5592
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5593
- }
5604
+
5605
+ display.PopMaterial(this, selected);
55945606 }
55955607
55965608 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5632,7 +5644,7 @@
56325644 // resetMasterNode();
56335645 }
56345646
5635
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5647
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56365648 {
56375649 if (GetBRep() == null)
56385650 {
....@@ -5715,7 +5727,7 @@
57155727 boolean flipV = false; // true;
57165728 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57175729
5718
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5730
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57195731 {
57205732 if (hide)
57215733 return;
....@@ -5774,16 +5786,7 @@
57745786 // // ??????????????????????????? Touch();
57755787 // }
57765788
5777
- if (material != null)
5778
- {
5779
- materialstack[materialdepth] = material;
5780
- selectedstack[materialdepth] = selected;
5781
- cStatic.objectstack[materialdepth++] = this;
5782
- //System.out.println("material " + material);
5783
- //Applet3D.tracein("selected ", selected);
5784
- display.vector2buffer = projectedVertices;
5785
- material.Draw(display, selected);
5786
- }
5789
+display.PushMaterial2(this, selected);
57875790
57885791 Object3D child;
57895792 boolean sel;
....@@ -5807,12 +5810,12 @@
58075810 if (!child.HasTransparency())
58085811 {
58095812 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
5813
+ // GrafreeD.tracein("draw ", child);
58115814 boolean wasblocked = blockdraw;
58125815 blockdraw = true;
58135816 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58145817 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
5818
+ // GrafreeD.traceout("draw ", child);
58165819 }
58175820
58185821 release(i);
....@@ -5835,19 +5838,7 @@
58355838 */
58365839 //depth += 1;
58375840
5838
- if (material != null)
5839
- {
5840
- materialdepth -= 1;
5841
- if (materialdepth > 0)
5842
- {
5843
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5844
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5845
- }
5846
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5847
- //else
5848
- //material.Draw(display, false);
5849
- }
5850
-
5841
+display.PopMaterial2(this);
58515842 /*
58525843 display.ReleaseTextures(tex);
58535844 */
....@@ -5858,9 +5849,9 @@
58585849
58595850 //static cVector min,max;
58605851
5861
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
5852
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58625853 {
5863
- 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)
58645855 return; // no shadow for transparent objects
58655856
58665857 if (hide)
....@@ -5907,7 +5898,7 @@
59075898
59085899 javax.media.opengl.GL gl = display.GetGL();
59095900
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
5901
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59115902 {
59125903 int fc = bRep.FaceCount();
59135904 int vc = bRep.VertexCount();
....@@ -5982,7 +5973,7 @@
59825973 {
59835974 //throw new Error();
59845975
5985
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5976
+ boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
59865977
59875978 int[] strips = bRep.getRawIndices();
59885979
....@@ -6226,7 +6217,7 @@
62266217 // // r.norm.dot(v3) > -0.5)
62276218 // // continue;
62286219
6229
- drawFace(p, q, r, display, face);
6220
+ display.DrawFace(this, p, q, r, face);
62306221 }
62316222 gl.glEnd();
62326223 }
....@@ -6270,7 +6261,7 @@
62706261 Vertex q = bRep.GetVertex(face.q);
62716262 Vertex r = bRep.GetVertex(face.r);
62726263
6273
- drawFace(p, q, r, display, face);
6264
+ display.DrawFace(this, p, q, r, face);
62746265 }
62756266 gl.glEnd();
62766267 }
....@@ -6410,180 +6401,6 @@
64106401
64116402 transient FaceCompare[] facescompare = null;
64126403
6413
- void SetColor(CameraPane display, Vertex p0)
6414
- {
6415
- if (display.RENDERPROGRAM == 0)
6416
- {
6417
- float r = 0;
6418
- if (bRep != null)
6419
- {
6420
- if (bRep.stripified)
6421
- {
6422
- r = 1;
6423
- }
6424
- }
6425
- float g = 0;
6426
- if (bRep != null)
6427
- {
6428
- if (bRep.trimmed)
6429
- {
6430
- g = 1;
6431
- }
6432
- }
6433
- float b = 0;
6434
- if (support != null && link2master)
6435
- {
6436
- b = 1;
6437
- }
6438
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6439
- return;
6440
- }
6441
-
6442
- if (display.drawMode != CameraPane.SHADOW)
6443
- return;
6444
-
6445
- javax.media.opengl.GL gl = display.GetGL();
6446
-// if (true) return;
6447
-// float ao = p.AO;
6448
-//
6449
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6450
-// // ao = 1;
6451
-//
6452
-// gl.glColor4f(ao, ao, ao, 1);
6453
-
6454
-// CameraPane.selectedpoint.
6455
-// getAverage(cStatic.point1, true);
6456
- if (CameraPane.pointflow == null) // !random) // live)
6457
- {
6458
- return;
6459
- }
6460
-
6461
- cStatic.point1.set(0,0,0);
6462
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6463
-
6464
- cStatic.point1.sub(p0);
6465
-
6466
-
6467
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6468
-// {
6469
-// return;
6470
-// }
6471
-
6472
- //if (true)
6473
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6474
- {
6475
- return;
6476
- }
6477
-
6478
- float[] colorV = new float[3];
6479
-
6480
- if (false) // marked)
6481
- {
6482
- // debug rigging weights
6483
- for (int object = 0; object < p0.vertexlinks.length; object++)
6484
- {
6485
- float weight = p0.weights[object] / p0.totalweight;
6486
-
6487
- // if (weight < 0.1)
6488
- // {
6489
- // assert(weight == 0);
6490
- // continue;
6491
- // }
6492
-
6493
- if (p0.vertexlinks[object] == -1)
6494
- continue;
6495
-
6496
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6497
-
6498
- int color = //1 << object; //
6499
- //p.vertexlinks.length;
6500
- support.bRep.supports[p0.closestsupport].links[object];
6501
- colorV[2] += (color & 1) * weight;
6502
- colorV[1] += ((color & 2) >> 1) * weight;
6503
- colorV[0] += ((color & 4) >> 2) * weight;
6504
- }
6505
- }
6506
- else
6507
- {
6508
- if (drawingstarted)
6509
- {
6510
- // find next point
6511
- if (bRep.GetVertex(0).faceindices == null)
6512
- {
6513
- bRep.InitFaceIndices();
6514
- }
6515
-
6516
- double ymin = p0.y;
6517
-
6518
- Vertex newp = p0;
6519
-
6520
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6521
- {
6522
- int fi = p0.faceindices[fii];
6523
-
6524
- if (fi == -1)
6525
- break;
6526
-
6527
- Face f = bRep.GetFace(fi);
6528
-
6529
- Vertex p = bRep.GetVertex(f.p);
6530
- Vertex q = bRep.GetVertex(f.q);
6531
- Vertex r = bRep.GetVertex(f.r);
6532
-
6533
- int swap = (int)(Math.random()*3);
6534
-
6535
-// for (int s=swap; --s>=0;)
6536
-// {
6537
-// Vertex t = p;
6538
-// p = q;
6539
-// q = r;
6540
-// r = t;
6541
-// }
6542
- if (ymin > p.y)
6543
- {
6544
- ymin = p.y;
6545
- newp = p;
6546
-// break;
6547
- }
6548
- if (ymin > q.y)
6549
- {
6550
- ymin = q.y;
6551
- newp = q;
6552
-// break;
6553
- }
6554
- if (ymin > r.y)
6555
- {
6556
- ymin = r.y;
6557
- newp = r;
6558
-// break;
6559
- }
6560
- }
6561
-
6562
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6563
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6564
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6565
-
6566
- drawingstarted = false;
6567
-
6568
- // return;
6569
- }
6570
-
6571
- if (false) // CameraPane.DRAW
6572
- {
6573
- p0.AO = colorV[0] = 2;
6574
- colorV[1] = 2;
6575
- colorV[2] = 2;
6576
- }
6577
-
6578
- CameraPane.pointflow.add(p0);
6579
- CameraPane.pointflow.Touch();
6580
- }
6581
-
6582
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6583
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6584
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6585
- }
6586
-
65876404 void Print(Vertex v)
65886405 {
65896406 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
....@@ -6605,152 +6422,6 @@
66056422 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
66066423 }
66076424
6608
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6609
- CameraPane display, Face face)
6610
- {
6611
- if (pv.y == -10000 ||
6612
- qv.y == -10000 ||
6613
- rv.y == -10000)
6614
- return;
6615
-
6616
-// float b = f.nbiterations & 1;
6617
-// float g = (f.nbiterations>>1) & 1;
6618
-// float r = (f.nbiterations>>2) & 1;
6619
-//
6620
-// //if (f.weight == 10000)
6621
-// //{
6622
-// // r = 1; g = b = 0;
6623
-// //}
6624
-// //else
6625
-// //{
6626
-// // assert(f.weight < 10000);
6627
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6628
-// if (r<0)
6629
-// assert(r>=0);
6630
-// //}
6631
-
6632
- javax.media.opengl.GL gl = display.GetGL();
6633
-
6634
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6635
-
6636
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6637
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6638
- {
6639
- //gl.glBegin(gl.GL_TRIANGLES);
6640
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6641
- if (!hasnorm)
6642
- {
6643
- // System.out.println("FUCK!!");
6644
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6645
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6646
- LA.vecCross(v0, v1, v2);
6647
- LA.vecNormalize(v2);
6648
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6649
- }
6650
-
6651
- if (hasnorm)
6652
- {
6653
-// if (!pv.norm.normalized())
6654
-// assert(pv.norm.normalized());
6655
-
6656
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6657
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6658
- }
6659
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6660
- SetColor(display, pv);
6661
- //gl.glColor4f(r, g, b, 1);
6662
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6663
- if (flipV)
6664
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6665
- else
6666
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6667
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6668
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6669
-// Print(pv);
6670
- if (hasnorm)
6671
- {
6672
-// assert(qv.norm.normalized());
6673
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6674
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6675
- }
6676
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6677
- // boolean locked = false;
6678
- // float eps = 0.1f;
6679
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6680
-
6681
- // int dot = 0; //*/ (int)f.dot;
6682
-
6683
- // if ((dot&1) == 0)
6684
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6685
-
6686
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6687
- if (flipV)
6688
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6689
- else
6690
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6691
- // else
6692
- // {
6693
- // locked = true;
6694
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6695
- // }
6696
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6697
- SetColor(display, qv);
6698
- //gl.glColor4f(r, g, b, 1);
6699
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6700
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6701
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6702
-// Print(qv);
6703
- if (hasnorm)
6704
- {
6705
-// assert(rv.norm.normalized());
6706
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6707
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6708
- }
6709
-
6710
- // if ((dot&4) == 0)
6711
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6712
-
6713
- // if (wrap || !locked && (dot&8) != 0)
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6716
- else
6717
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6718
- // else
6719
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6720
-
6721
- // f.dot = dot;
6722
-
6723
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6724
- SetColor(display, rv);
6725
- //gl.glColor4f(r, g, b, 1);
6726
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6727
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6728
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6729
-// Print(rv);
6730
- //gl.glEnd();
6731
- }
6732
- else
6733
- {
6734
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6735
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6736
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6737
-
6738
- }
6739
-
6740
- if (false) // (attributes & WIREFRAME) != 0)
6741
- {
6742
- gl.glDisable(gl.GL_LIGHTING);
6743
-
6744
- gl.glBegin(gl.GL_LINE_LOOP);
6745
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6746
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6747
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6748
- gl.glEnd();
6749
-
6750
- gl.glEnable(gl.GL_LIGHTING);
6751
- }
6752
- }
6753
-
67546425 void drawSelf(ClickInfo info, int level, boolean select)
67556426 {
67566427 if (bRep == null)
....@@ -7719,7 +7390,7 @@
77197390 if (parent == null)
77207391 {
77217392 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
7393
+ //new Exception().printStackTrace();
77237394 } else
77247395 {
77257396 if (parent instanceof BezierPatch)
....@@ -7735,8 +7406,15 @@
77357406 info.pane.repaint();
77367407 }
77377408
7409
+ boolean overflow = false;
7410
+
77387411 void TransformToWorld(cVector out) // , cVector out)
77397412 {
7413
+ if (overflow)
7414
+ return;
7415
+
7416
+ overflow = true;
7417
+
77407418 // june 2013 ??? assert (in == out);
77417419 cVector in = out;
77427420 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +7431,8 @@
77537431 {
77547432 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77557433 }
7434
+
7435
+ overflow = false;
77567436 }
77577437
77587438 void TransformToLocal(cVector out) //, cVector out)
....@@ -7995,19 +7675,22 @@
79957675 max = new cVector();
79967676 }
79977677
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
7678
+ if (false) // Can crawl!!
80017679 {
8002
- getBounds(min, max, true);
7680
+ Object3D sourcenode = GetFileRoot();
80037681
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7682
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80057683 {
8006
-// sourcenode.getBounds(min, max, true);
8007
- sourcenode.getBounds(v0, v1, true);
8008
-// sourcenode.toParent = sourcenode.toParent;
8009
-// get(0).toParent = get(0).toParent;
8010
-// sourcenode.GlobalTransform();
7684
+ getBounds(min, max, true);
7685
+
7686
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
7687
+ {
7688
+ // sourcenode.getBounds(min, max, true);
7689
+ sourcenode.getBounds(v0, v1, true);
7690
+ // sourcenode.toParent = sourcenode.toParent;
7691
+ // get(0).toParent = get(0).toParent;
7692
+ // sourcenode.GlobalTransform();
7693
+ }
80117694 }
80127695 }
80137696
....@@ -8016,7 +7699,8 @@
80167699 if (support != null)
80177700 {
80187701 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
7702
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
+ GrafreeD.Assert(support.bRep == bRep.support);
80207704 }
80217705 else
80227706 {
....@@ -8099,6 +7783,8 @@
80997783 {
81007784 Object3D targ = this;
81017785
7786
+ targ.NORMALPUSH = obj.NORMALPUSH;
7787
+
81027788 if (obj.material != null)
81037789 {
81047790 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))