Normand Briere
2018-12-15 6ed65dcb597fb2153cef75bf1845978f1115658c
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 {
....@@ -779,7 +794,10 @@
779794 // factor = CameraPane.STEP;
780795 // }
781796
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
797
+ if (marked && CameraPane.isLIVE() && live &&
798
+ //TEMP21aug2018
799
+ CameraPane.drawMode == CameraPane.SHADOW &&
800
+ currentframe != CameraPane.framecount)
783801 {
784802 currentframe = CameraPane.framecount;
785803
....@@ -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()
....@@ -5280,7 +5356,7 @@
52805356 if (name != null && name.contains("sclera"))
52815357 name = name;
52825358
5283
- if (this instanceof CheckerIG)
5359
+ if (this instanceof Checker)
52845360 return;
52855361
52865362 if (display.drawMode == display.SHADOW && PASSTEST)
....@@ -5507,7 +5583,9 @@
55075583 display.options2[2] = material.factor;
55085584
55095585 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5510
- display.options3[3] = material.cameralight/0.2f;
5586
+ display.options4[0] = material.cameralight/0.2f;
5587
+ display.options4[1] = material.subsurface;
5588
+ display.options4[2] = material.sheen;
55115589
55125590 // if (display.CURRENTANTIALIAS > 0)
55135591 // display.options3[3] /= 4;
....@@ -5807,12 +5885,12 @@
58075885 if (!child.HasTransparency())
58085886 {
58095887 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
5810
- // GraphreeD.tracein("draw ", child);
5888
+ // GrafreeD.tracein("draw ", child);
58115889 boolean wasblocked = blockdraw;
58125890 blockdraw = true;
58135891 child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected());
58145892 blockdraw = false;
5815
- // GraphreeD.traceout("draw ", child);
5893
+ // GrafreeD.traceout("draw ", child);
58165894 }
58175895
58185896 release(i);
....@@ -5907,7 +5985,7 @@
59075985
59085986 javax.media.opengl.GL gl = display.GetGL();
59095987
5910
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
5988
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59115989 {
59125990 int fc = bRep.FaceCount();
59135991 int vc = bRep.VertexCount();
....@@ -6648,13 +6726,26 @@
66486726 gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
66496727 }
66506728
6729
+ // P
6730
+ float x = (float)pv.x;
6731
+ float y = (float)pv.y;
6732
+ float z = (float)pv.z;
6733
+
66516734 if (hasnorm)
66526735 {
66536736 // if (!pv.norm.normalized())
66546737 // assert(pv.norm.normalized());
66556738
66566739 //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);
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);
66586749 }
66596750 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
66606751 SetColor(display, pv);
....@@ -6665,13 +6756,28 @@
66656756 else
66666757 gl.glTexCoord2f((float) pv.s, (float) pv.t);
66676758 //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);
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
+
66696767 // Print(pv);
66706768 if (hasnorm)
66716769 {
66726770 // assert(qv.norm.normalized());
66736771 //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);
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);
66756781 }
66766782 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
66776783 // boolean locked = false;
....@@ -6695,16 +6801,31 @@
66956801 // }
66966802 gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
66976803 SetColor(display, qv);
6804
+
6805
+ gl.glVertex3f(x, y, z);
66986806 //gl.glColor4f(r, g, b, 1);
66996807 //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
67006808 //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);
67026809 // Print(qv);
6810
+
6811
+ // R
6812
+ x = (float)rv.x;
6813
+ y = (float)rv.y;
6814
+ z = (float)rv.z;
6815
+
67036816 if (hasnorm)
67046817 {
67056818 // assert(rv.norm.normalized());
67066819 //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);
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);
67086829 }
67096830
67106831 // if ((dot&4) == 0)
....@@ -6725,7 +6846,7 @@
67256846 //gl.glColor4f(r, g, b, 1);
67266847 //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
67276848 //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);
6849
+ gl.glVertex3f(x, y, z);
67296850 // Print(rv);
67306851 //gl.glEnd();
67316852 }
....@@ -7719,7 +7840,7 @@
77197840 if (parent == null)
77207841 {
77217842 System.out.println("NULL PARENT");
7722
- new Exception().printStackTrace();
7843
+ //new Exception().printStackTrace();
77237844 } else
77247845 {
77257846 if (parent instanceof BezierPatch)
....@@ -7735,8 +7856,15 @@
77357856 info.pane.repaint();
77367857 }
77377858
7859
+ boolean overflow = false;
7860
+
77387861 void TransformToWorld(cVector out) // , cVector out)
77397862 {
7863
+ if (overflow)
7864
+ return;
7865
+
7866
+ overflow = true;
7867
+
77407868 // june 2013 ??? assert (in == out);
77417869 cVector in = out;
77427870 if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
....@@ -7753,6 +7881,8 @@
77537881 {
77547882 (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
77557883 }
7884
+
7885
+ overflow = false;
77567886 }
77577887
77587888 void TransformToLocal(cVector out) //, cVector out)
....@@ -7995,19 +8125,22 @@
79958125 max = new cVector();
79968126 }
79978127
7998
- Object3D sourcenode = GetFileRoot();
7999
-
8000
- if (!sourcenode.name.contains("rclab"))
8128
+ if (false) // Can crawl!!
80018129 {
8002
- getBounds(min, max, true);
8130
+ Object3D sourcenode = GetFileRoot();
80038131
8004
- if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
8132
+ if (sourcenode != null && !sourcenode.name.contains("rclab"))
80058133 {
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();
8134
+ getBounds(min, max, true);
8135
+
8136
+ if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
8137
+ {
8138
+ // sourcenode.getBounds(min, max, true);
8139
+ sourcenode.getBounds(v0, v1, true);
8140
+ // sourcenode.toParent = sourcenode.toParent;
8141
+ // get(0).toParent = get(0).toParent;
8142
+ // sourcenode.GlobalTransform();
8143
+ }
80118144 }
80128145 }
80138146
....@@ -8016,7 +8149,8 @@
80168149 if (support != null)
80178150 {
80188151 assert(bRep != null);
8019
- GraphreeD.Assert(support.bRep == bRep.support);
8152
+ if (!(support instanceof GenericJoint)) // support.bRep != null)
8153
+ GrafreeD.Assert(support.bRep == bRep.support);
80208154 }
80218155 else
80228156 {
....@@ -8099,6 +8233,8 @@
80998233 {
81008234 Object3D targ = this;
81018235
8236
+ targ.NORMALPUSH = obj.NORMALPUSH;
8237
+
81028238 if (obj.material != null)
81038239 {
81048240 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))