Normand Briere
2019-06-03 e24558ddeacfc945b9e9ba0a32b552d04e2ed4dd
Selectable mode + new mesh reduction.
16 files modified
708 ■■■■ changed files
BoundaryRep.java 423 ●●●● patch | view | raw | blame | history
CameraPane.java 45 ●●●● patch | view | raw | blame | history
Composite.java 9 ●●●● patch | view | raw | blame | history
Face.java 2 ●●●●● patch | view | raw | blame | history
GenericJoint.java 11 ●●●●● patch | view | raw | blame | history
Globals.java 3 ●●●● patch | view | raw | blame | history
Grafreed.java 2 ●●●●● patch | view | raw | blame | history
Grid.java 2 ●●● patch | view | raw | blame | history
GroupEditor.java 25 ●●●●● patch | view | raw | blame | history
LA.java 3 ●●●●● patch | view | raw | blame | history
Merge.java 80 ●●●●● patch | view | raw | blame | history
ObjEditor.java 13 ●●●● patch | view | raw | blame | history
Object3D.java 43 ●●●● patch | view | raw | blame | history
Vertex.java 25 ●●●● patch | view | raw | blame | history
cVector.java 18 ●●●● patch | view | raw | blame | history
iCameraPane.java 4 ●●●● patch | view | raw | blame | history
BoundaryRep.java
....@@ -161,6 +161,7 @@
161161 || FaceCount() != other.FaceCount()
162162 || !(indices == null ^ other.indices != null)) // july 2014
163163 {
164
+ // The meshes have different structures.
164165 //new Exception().printStackTrace();
165166 trimmed = other.trimmed;
166167 stripified = other.stripified;
....@@ -239,9 +240,16 @@
239240 }
240241 }
241242
242
- Support[] InitConnections(BoundaryRep other)
243
+ transient Support[] cachesupports = null;
244
+
245
+ Support[] InitConnections()
243246 {
244
- int n = other.startvertices.length-1;
247
+ if (cachesupports != null)
248
+ {
249
+ return cachesupports;
250
+ }
251
+
252
+ int n = this.startvertices.length-1;
245253
246254 Support[] supports = new Support[n];
247255
....@@ -253,38 +261,60 @@
253261
254262 for (int object=1; object<=n; object++)
255263 {
256
- int start = other.startvertices[object-1];
257
- int end = other.startvertices[object];
264
+ int start = this.startvertices[object-1];
265
+ int end = this.startvertices[object];
258266
259267 if (start == end)
260268 continue; // ??
261269
270
+ /**
271
+ Vertex v2 = vertextemp;
272
+ v2.x = averagepoints[object*3];
273
+ v2.y = averagepoints[object*3+1];
274
+ v2.z = averagepoints[object*3+2];
275
+
276
+ //v2.set(GetVertex(this.startvertices[subsupport]));
277
+
278
+ // projected point
279
+ Vertex v3 = vertextemp2;
280
+ //GetVertex(this.startvertices[subsupport]);
281
+ v3.x = extremepoints[object*3];
282
+ v3.y = extremepoints[object*3+1];
283
+ v3.z = extremepoints[object*3+2];
284
+
285
+ vect3.set(v3); // "X" axis apex
286
+ vect3.sub(v2); // origin (center)
287
+ vect3.normalize();
288
+ /**/
289
+
262290 int linkcount = 0;
263291
264292 int objectinlist = -1;
293
+
294
+ Support subsupport = supports[object-1];
265295
266296 for (int object2=1; object2<=n; object2++)
267297 {
268298 for (int i = start; i < end; i++)
269299 {
270
- Vertex v = other.GetVertex(i);
300
+ Vertex v = this.GetVertex(i);
271301
272
- //
273
- if (other.Contains(v, object2))
302
+ // Check if v is close enough from any vertex of the given subobject.
303
+ if (this.Contains(v, object2))
274304 {
275
- if (linkcount == supports[object-1].links.length)
305
+ if (linkcount == subsupport.links.length)
276306 break;
277307
278308 if (object2 == object)
279309 objectinlist = linkcount;
280310
281
- supports[object-1].links[linkcount++] = object2;
311
+ subsupport.links[linkcount++] = object2;
282312 break;
283313 }
284314 }
285315 }
286316
287
- supports[object-1].links[linkcount] = -1;
317
+ subsupport.links[linkcount] = -1;
288318
289319 if (objectinlist == -1)
290320 assert(objectinlist != -1);
....@@ -293,9 +323,9 @@
293323 // assert(linkcount > 1);
294324
295325 // show main support as blue
296
- int first = supports[object-1].links[0];
297
- supports[object-1].links[0] = supports[object-1].links[objectinlist];
298
- supports[object-1].links[objectinlist] = first;
326
+ int first = subsupport.links[0];
327
+ subsupport.links[0] = subsupport.links[objectinlist];
328
+ subsupport.links[objectinlist] = first;
299329 }
300330
301331 for (int loop = 0; --loop>=0;)
....@@ -353,7 +383,7 @@
353383 supports = supports2;
354384 }
355385
356
- return supports;
386
+ return cachesupports = supports;
357387 }
358388
359389 double Distance2(Vertex v, Vertex v2, double dist2beat, double[][] toRoot, int k)
....@@ -598,7 +628,7 @@
598628 // ;
599629 //
600630
601
- supportsize = supportsizes[subsupport];
631
+ supportsize = supportminsize[subsupport];
602632
603633 double K = supportsize / distmax;
604634
....@@ -650,7 +680,8 @@
650680 // if (supportsize * fadefactor > 1)
651681 // return 1;
652682
653
- return supportsize * fadefactor;
683
+ return //supportsize *
684
+ supportsize * fadefactor;
654685 }
655686
656687 void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v)
....@@ -952,7 +983,7 @@
952983
953984 // sept 2017 SEUIL = 0.1; // aout 2013
954985
955
- supports = InitConnections(other);
986
+ supports = other.InitConnections();
956987
957988 other.supports = supports; // should be the other way around...
958989
....@@ -1895,7 +1926,7 @@
18951926 return;
18961927 }
18971928
1898
- // System.exit(0);
1929
+ // System.exit(0);
18991930
19001931 cVector vect = new cVector();
19011932 cVector normal = new cVector();
....@@ -1966,7 +1997,7 @@
19661997 if (v.vertexlinks == null)
19671998 continue;
19681999
1969
- if (v.weights != null && v.weights[j] == 0) // < 0.01 * v.totalweight) // == 0)
2000
+ if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
19702001 {
19712002 //testweight += v.weights[j-1];
19722003 continue;
....@@ -2247,6 +2278,8 @@
22472278
22482279 transient int lastsoundtime;
22492280
2281
+ transient boolean once = false;
2282
+
22502283 void setMasterThis0(BoundaryRep other, double[][] toRoot, boolean smooth, boolean marked)
22512284 {
22522285 if (LA.isIdentity(toRoot))
....@@ -2302,7 +2335,11 @@
23022335
23032336 if (v.totalweight == 0)
23042337 {
2305
- System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2338
+ if (!once)
2339
+ {
2340
+ System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2341
+ once = true;
2342
+ }
23062343 continue;
23072344 }
23082345
....@@ -3098,6 +3135,7 @@
30983135 //
30993136 // transient VertexCompare[] vertexcompare = null;
31003137
3138
+ // Check if v0 is close enough from any vertex of the given subobject of this.
31013139 boolean Contains(Vertex v0, int object)
31023140 {
31033141 int start = startvertices[object-1];
....@@ -3696,6 +3734,111 @@
36963734 */
36973735 }
36983736
3737
+ void GenerateNormals2(boolean crease)
3738
+ {
3739
+ cVector tempVector = new cVector();
3740
+
3741
+// java.util.HashMap<cVector, cVector> tableBase = new java.util.HashMap<cVector, cVector>();
3742
+//
3743
+//
3744
+// for (int i=0; i<this.VertexCount(); i++)
3745
+// {
3746
+// Vertex v = this.GetVertex(i);
3747
+//
3748
+// tempVector.set(v);
3749
+//
3750
+// cVector n = tableBase.get(tempVector.ToFloat());
3751
+//
3752
+// if (n != null)
3753
+// {
3754
+// continue;
3755
+// }
3756
+//
3757
+// tableBase.put(new cVector(tempVector), new cVector(v.norm));
3758
+// }
3759
+
3760
+ BoundaryRep tempSupport = this.support;
3761
+
3762
+ this.support = null;
3763
+
3764
+ BoundaryRep tempRep = (BoundaryRep)Grafreed.clone(this);
3765
+
3766
+ this.support = tempSupport;
3767
+
3768
+ //tempRep.Unstripify();
3769
+
3770
+ tempRep.GenerateNormals2(crease);
3771
+
3772
+ boolean keepnormal = Vertex.normalmode;
3773
+ boolean epsequal = Grafreed.epsequal;
3774
+
3775
+ Vertex.normalmode = false;
3776
+ Grafreed.epsequal = false; // A bit strange
3777
+
3778
+ // No need to have a match for vertex counts.
3779
+
3780
+ java.util.HashMap<cVector, cVector> table = new java.util.HashMap<cVector, cVector>();
3781
+
3782
+ for (int i=0; i<tempRep.VertexCount(); i++)
3783
+ {
3784
+ Vertex v = tempRep.GetVertex(i);
3785
+
3786
+ cVector n = table.get(tempVector.ToFloat());
3787
+
3788
+ if (v.norm.x == 1 && v.norm.y == 0 && v.norm.z == 0)
3789
+ {
3790
+ //continue;
3791
+ }
3792
+
3793
+ tempVector.set(v);
3794
+
3795
+ //cVector nBase = tableBase.get(tempVector);
3796
+
3797
+ //if (v.norm.dot(nBase) < 0.9)
3798
+ //{
3799
+ // continue;
3800
+ //}
3801
+
3802
+ if (n != null && n.x == 1 && n.y == 0 && n.z == 0)
3803
+ {
3804
+ //continue;
3805
+ }
3806
+
3807
+ if (n != null)
3808
+ {
3809
+// if (n.dot(v.norm) < 0)
3810
+// n.sub(v.norm);
3811
+// else
3812
+// n.add(v.norm);
3813
+//
3814
+// n.normalize();
3815
+ continue;
3816
+ }
3817
+
3818
+ table.put(new cVector(tempVector), new cVector(v.norm));
3819
+ }
3820
+
3821
+ for (int i=0; i<this.VertexCount(); i++)
3822
+ {
3823
+ Vertex v = this.GetVertex(i);
3824
+
3825
+ tempVector.set(v);
3826
+
3827
+ cVector n = table.get(tempVector.ToFloat());
3828
+
3829
+ //if (n.dot(v.norm) < 0)
3830
+ if (n == null)
3831
+ continue;
3832
+
3833
+ LA.vecCopy(n, v.norm);
3834
+
3835
+ this.SetVertex(v, i);
3836
+ }
3837
+
3838
+ Grafreed.epsequal = epsequal;
3839
+ Vertex.normalmode = keepnormal;
3840
+ }
3841
+
36993842 void GenerateNormals(boolean crease)
37003843 {
37013844 boolean wastrim = trimmed;
....@@ -3869,6 +4012,9 @@
38694012 {
38704013 triangles[i] = i;
38714014 }
4015
+
4016
+ Untrim();
4017
+ MergeNormals();
38724018 }
38734019 }
38744020
....@@ -3929,6 +4075,9 @@
39294075 triangles = new int[1];
39304076 triangles[0] = 3;
39314077 }
4078
+
4079
+ Untrim();
4080
+ MergeNormals();
39324081 }
39334082
39344083 /*
....@@ -3978,6 +4127,40 @@
39784127 }
39794128
39804129 Vertex.normalmode = false;
4130
+ }
4131
+
4132
+ void MergeNormals()
4133
+ {
4134
+ boolean smooth = Grafreed.smoothmode;
4135
+ boolean link = Grafreed.linkUV;
4136
+ Grafreed.smoothmode = true;
4137
+ Grafreed.linkUV = true;
4138
+
4139
+ System.out.println("#Vertex = " + VertexCount());
4140
+ System.out.println("#Face = " + FaceCount());
4141
+
4142
+ java.util.HashSet<Vertex> table = new java.util.HashSet<Vertex>();
4143
+
4144
+ for (int i = 0; i < VertexCount(); i++)
4145
+ {
4146
+ Vertex v = GetVertex(i);
4147
+
4148
+ if (!table.contains(v))
4149
+ {
4150
+ table.add(v);
4151
+ }
4152
+ }
4153
+
4154
+ Grafreed.smoothmode = smooth;
4155
+ Grafreed.linkUV = link;
4156
+
4157
+// for (int i = 0; i < VertexCount(); i++)
4158
+// {
4159
+// Vertex v = GetVertex(i);
4160
+//
4161
+// table.add(v);
4162
+// }
4163
+
39814164 }
39824165
39834166 static cVector temp1 = new cVector();
....@@ -4752,7 +4935,7 @@
47524935 {
47534936 i3 = positions.length-3;
47544937 i2 = uvmap.length - 2;
4755
- new Exception().printStackTrace();
4938
+ //new Exception().printStackTrace();
47564939 }
47574940
47584941 v./*pos.*/x = positions[i3];
....@@ -5476,17 +5659,27 @@
54765659
54775660 transient int nbbadfaces; // ?? = 1000000;
54785661
5479
- int ChooseTriangle()
5662
+ /*
5663
+ */
5664
+ int ChooseTriangle(boolean firstEquilateral)
54805665 {
54815666 int chosen = -1;
54825667
54835668 double minweight = 1E10;
54845669
5670
+ int step = 8; // ?
5671
+
5672
+ if (firstEquilateral)
5673
+ step = 1;
5674
+
54855675 nbbadfaces = 0;
5486
- for (int i=0; i<faces.size(); i+=8)
5676
+ for (int i=0; i<faces.size(); i+=step)
54875677 // for (int i=faces.size(); (i-=8)>=0;)
54885678 {
54895679 Face face = (Face) faces.get(i);
5680
+
5681
+ if (face.used)
5682
+ continue;
54905683
54915684 if (!Valid(face))
54925685 {
....@@ -5496,6 +5689,15 @@
54965689
54975690 if (Boundary(face))
54985691 continue;
5692
+
5693
+// if (Boundary(face.p))
5694
+// continue;
5695
+//
5696
+// if (Boundary(face.q))
5697
+// continue;
5698
+//
5699
+// if (Boundary(face.r))
5700
+// continue;
54995701
55005702 if (!ValidValence(face))
55015703 continue;
....@@ -5508,22 +5710,55 @@
55085710 //?? if (face.weight < 0)
55095711 // continue;
55105712
5511
- double K = 1; // 0.01; // .25;
5512
-
5513
- double factor = (1-K)*face.nbiterations + K; //*face.weight;
5514
-
5515
- double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5516
-
5517
- if (minweight > weight)
5713
+ if (firstEquilateral)
55185714 {
5519
- minweight = weight;
5715
+ if (OneFaceUsed(links.get(face.p)))
5716
+ continue;
5717
+
5718
+ if (OneFaceUsed(links.get(face.q)))
5719
+ continue;
5720
+
5721
+ if (OneFaceUsed(links.get(face.r)))
5722
+ continue;
5723
+
55205724 chosen = i;
5521
- if (minweight == 0)
5522
- break;
5725
+ break;
5726
+ }
5727
+ else
5728
+ {
5729
+ double K = 1; // 0.01; // .25;
5730
+
5731
+ double factor = (1-K)*face.nbiterations + K; //*face.weight;
5732
+
5733
+ double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5734
+
5735
+ if (minweight > weight)
5736
+ {
5737
+ minweight = weight;
5738
+ chosen = i;
5739
+ if (minweight == 0)
5740
+ break;
5741
+ }
55235742 }
55245743 }
55255744
55265745 return chosen;
5746
+ }
5747
+
5748
+ private boolean OneFaceUsed(Vector<Face> faces)
5749
+ {
5750
+ if (faces.size() != 6)
5751
+ return true;
5752
+
5753
+ for (int i=0; i<6; i+=1)
5754
+ {
5755
+ if (faces.get(i).used)
5756
+ {
5757
+ return true;
5758
+ }
5759
+ }
5760
+
5761
+ return false;
55275762 }
55285763
55295764 static boolean remove3valence = true;
....@@ -5559,7 +5794,7 @@
55595794 }
55605795 else
55615796 {
5562
- assert(links.size() == vertices.size());
5797
+ // TODO Grafreed.Assert(links.size() == vertices.size());
55635798
55645799 links.setSize(vertices.size());
55655800 for (int i=vertices.size(); --i>=0;)
....@@ -5567,6 +5802,7 @@
55675802 // linkstouched[i] = false;
55685803 if (links.get(i) == null) // ??
55695804 {
5805
+ new Exception().printStackTrace();
55705806 links.set(i, new Vector(8));
55715807 // linkstouched[i] = true;
55725808 }
....@@ -5577,6 +5813,8 @@
55775813 }
55785814 }
55795815
5816
+ boolean once = false;
5817
+
55805818 for (int i=faces.size(); --i>=0;)
55815819 {
55825820 Face face = (Face) faces.get(i);
....@@ -5588,6 +5826,9 @@
55885826 //if (linkstouched[face.r])
55895827 links.get(face.r).add(face);
55905828
5829
+ if (face.used)
5830
+ once = true;
5831
+
55915832 face.good = 1;
55925833 face.boundary = -1;
55935834 }
....@@ -6953,6 +7194,10 @@
69537194 return (face.boundary = 1) == 1;
69547195 }
69557196
7197
+ // June 2019
7198
+ if (true)
7199
+ return (face.boundary = 0) == 1;
7200
+
69567201 // reverse triangle test
69577202 q1.set(p);
69587203 q2.set(q);
....@@ -7402,7 +7647,7 @@
74027647 //InitWeights();
74037648 }
74047649
7405
- int chosen = ChooseTriangle(); // Best is slow and not really better
7650
+ int chosen = ChooseTriangle(true); // Best is slow and not really better
74067651
74077652 if (chosen == -1)
74087653 {
....@@ -7416,7 +7661,7 @@
74167661 //remove3valence = false;
74177662 // InitWeights();
74187663
7419
- chosen = ChooseTriangle();
7664
+ chosen = ChooseTriangle(true);
74207665 }
74217666 }
74227667
....@@ -7692,7 +7937,7 @@
76927937
76937938 // boolean lock;
76947939
7695
- void SplitInTwo(boolean reduction34, boolean onlyone)
7940
+ boolean SplitInTwo(boolean reduction34, boolean onlyone)
76967941 {
76977942 if (stripified)
76987943 {
....@@ -7729,12 +7974,12 @@
77297974 {
77307975 System.err.println("EXCEPTION CAUGHT");
77317976 e.printStackTrace();
7732
- return;
7977
+ return false;
77337978 } catch (Error e)
77347979 {
77357980 System.err.println("ERROR CAUGHT");
77367981 e.printStackTrace();
7737
- return;
7982
+ return false;
77387983 }
77397984
77407985 System.out.println("# faces = " + faces.size());
....@@ -7744,6 +7989,7 @@
77447989 {
77457990 Face face = (Face) faces.get(i);
77467991
7992
+ face.used = false;
77477993 face.nbiterations = 1;
77487994 face.weight = -1;
77497995 face.boundary = -1;
....@@ -7795,6 +8041,11 @@
77958041 nbbadfaces = faces.size();
77968042 //remove3valence = true;
77978043
8044
+ int count = 2;
8045
+
8046
+ if (onlyone)
8047
+ count = 1;
8048
+
77988049 firstpass = true;
77998050
78008051 int n = faces.size();
....@@ -7810,8 +8061,9 @@
78108061 System.out.print('.');
78118062 }
78128063 System.out.println();
8064
+ boolean atleastone = false;
78138065 int i = 0;
7814
- while (reduction34 || faces.size() > n/2)
8066
+ while (true) // reduction34 || faces.size() > n/2)
78158067 {
78168068 if (i++%100 == 0)
78178069 {
....@@ -7833,6 +8085,8 @@
78338085 {
78348086 if (!RemoveOneTriangle())
78358087 break;
8088
+
8089
+ atleastone = true;
78368090 }
78378091 // if (iterationcount == 0)
78388092 // break;
....@@ -7843,8 +8097,8 @@
78438097 break;
78448098 }
78458099 firstpass = false;
7846
- if (onlyone)
7847
- break; // one triangle only
8100
+// if (--count<0 && !reduction34)
8101
+// break; // one triangle only
78488102 }
78498103
78508104 InitLinks(false); // for further display
....@@ -7860,6 +8114,8 @@
78608114 Trim(true,false,false,false,false);
78618115
78628116 Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
8117
+
8118
+ return atleastone;
78638119 }
78648120
78658121 void UpdateIndices(Face face, Face minface)
....@@ -7872,18 +8128,21 @@
78728128 face.p = minface.p;
78738129 //if (leafweights)
78748130 face.good = 0; // false;
8131
+ face.used = true;
78758132 }
78768133 if (face.q == minface.p || face.q == minface.q || face.q == minface.r)
78778134 {
78788135 face.q = minface.p;
78798136 //if (leafweights)
78808137 face.good = 0; // false;
8138
+ face.used = true;
78818139 }
78828140 if (face.r == minface.p || face.r == minface.q || face.r == minface.r)
78838141 {
78848142 face.r = minface.p;
78858143 //if (leafweights)
78868144 face.good = 0; // false;
8145
+ face.used = true;
78878146 }
78888147
78898148 if (face.p >/*=*/ minface.q && face.p < minface.r)
....@@ -7943,50 +8202,50 @@
79438202 if (v == 2)
79448203 vert = minface.r;
79458204 // Face face = (Face) faces.get(i);
7946
- Vector<Face> vertfaces = links.get(vert);
7947
- for (int i=vertfaces.size(); --i>=0;)
7948
- {
7949
- Face face = (Face) vertfaces.get(i);
7950
-
7951
- // if (face.weight == 10000)
7952
- // continue;
7953
-
7954
- if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
7955
- face.p == minface.q || face.q == minface.q || face.r == minface.q ||
7956
- face.p == minface.r || face.q == minface.r || face.r == minface.r)
8205
+ Vector<Face> vertfaces = links.get(vert);
8206
+ for (int i=vertfaces.size(); --i>=0;)
79578207 {
7958
- if (!leafweights)
8208
+ Face face = (Face) vertfaces.get(i);
8209
+
8210
+ // if (face.weight == 10000)
8211
+ // continue;
8212
+
8213
+ if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
8214
+ face.p == minface.q || face.q == minface.q || face.r == minface.q ||
8215
+ face.p == minface.r || face.q == minface.r || face.r == minface.r)
79598216 {
7960
-// if(minfaceweight <= 0)
7961
-// assert(minfaceweight > 0);
7962
-//
7963
-// //FaceWeight(face);
7964
-// if(face.weight < 0)
7965
-// assert(face.weight >= 0);
7966
-
7967
- face.weight += minfaceweight;
7968
-
7969
-// if (face.weight >= 10000)
7970
-// assert(face.weight < 10000);
8217
+ if (!leafweights)
8218
+ {
8219
+ // if(minfaceweight <= 0)
8220
+ // assert(minfaceweight > 0);
8221
+ //
8222
+ // //FaceWeight(face);
8223
+ // if(face.weight < 0)
8224
+ // assert(face.weight >= 0);
8225
+
8226
+ face.weight += minfaceweight;
8227
+
8228
+ // if (face.weight >= 10000)
8229
+ // assert(face.weight < 10000);
8230
+ }
8231
+ else
8232
+ face.weight = -1;
8233
+
8234
+ face.nbiterations += 1;
8235
+ face.boundary = -1;
8236
+
8237
+ Vertex p = (Vertex)vertices.get(face.p);
8238
+ Vertex q = (Vertex)vertices.get(face.q);
8239
+ Vertex r = (Vertex)vertices.get(face.r);
8240
+
8241
+ p.boundary = -1;
8242
+ q.boundary = -1;
8243
+ r.boundary = -1;
79718244 }
79728245 else
7973
- face.weight = -1;
7974
-
7975
- face.nbiterations += 1;
7976
- face.boundary = -1;
7977
-
7978
- Vertex p = (Vertex)vertices.get(face.p);
7979
- Vertex q = (Vertex)vertices.get(face.q);
7980
- Vertex r = (Vertex)vertices.get(face.r);
7981
-
7982
- p.boundary = -1;
7983
- q.boundary = -1;
7984
- r.boundary = -1;
8246
+ assert(false);
79858247 }
7986
- else
7987
- assert(false);
79888248 }
7989
- }
79908249
79918250 // TouchVertex(minface.p);
79928251 // TouchVertex(minface.q);
....@@ -8187,6 +8446,7 @@
81878446 for (int i=vertfaces.size(); --i>=0;)
81888447 {
81898448 Face face = (Face) vertfaces.get(i);
8449
+ face.used = true;
81908450 face.good = 0; // false;
81918451 if (leafweights)
81928452 face.weight = -1;
....@@ -8465,7 +8725,8 @@
84658725 int[] startvertices;
84668726 float[] averagepoints;
84678727 float[] extremepoints;
8468
- float[] supportsizes; // distance of closest point
8728
+ float[] supportminsize; // distance of closest point
8729
+ float[] supportmaxsize; // distance of fartest point
84698730
84708731 transient Hashtable vertextable;
84718732 /*transient*/ private Vertex[] verticesCopy;
CameraPane.java
....@@ -8022,7 +8022,7 @@
80228022 }
80238023 }
80248024
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8025
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268026 {
80278027 if (// DrawMode() != 0 || /*tex == null ||*/
80288028 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8067,7 @@
80678067 return; // true;
80688068 }
80698069
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8070
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718071 {
80728072 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738073
....@@ -8184,7 +8184,9 @@
81848184 texturedata = GetFileTexture(cachename, processbump, resolution);
81858185
81868186
8187
- if (texturedata != null)
8187
+ if (texturedata == null)
8188
+ throw new Exception();
8189
+
81888190 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81898191 //texture = GetTexture(tex, bump);
81908192 }
....@@ -8306,7 +8308,7 @@
83068308 return texture;
83078309 }
83088310
8309
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8311
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83108312 {
83118313 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83128314
....@@ -8324,14 +8326,14 @@
83248326 return texture!=null?texture.texture:null;
83258327 }
83268328
8327
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8329
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83288330 {
83298331 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83308332
83318333 return texture!=null?texture.texturedata:null;
83328334 }
83338335
8334
- boolean BindTexture(String tex, boolean bump, int resolution)
8336
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83358337 {
83368338 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378339 {
....@@ -10798,7 +10800,16 @@
1079810800 // Bump noise
1079910801 gl.glActiveTexture(GL.GL_TEXTURE6);
1080010802 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10801
- BindTexture(NOISE_TEXTURE, false, 2);
10803
+
10804
+ try
10805
+ {
10806
+ BindTexture(NOISE_TEXTURE, false, 2);
10807
+ }
10808
+ catch (Exception e)
10809
+ {
10810
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10811
+ }
10812
+
1080210813
1080310814 gl.glActiveTexture(GL.GL_TEXTURE0);
1080410815 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -11354,7 +11365,14 @@
1135411365
1135511366 usedtextures.clear();
1135611367
11357
- BindTextures(DEFAULT_TEXTURES, 2);
11368
+ try
11369
+ {
11370
+ BindTextures(DEFAULT_TEXTURES, 2);
11371
+ }
11372
+ catch (Exception e)
11373
+ {
11374
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11375
+ }
1135811376 }
1135911377 //System.out.println("--> " + stackdepth);
1136011378 // GrafreeD.traceon();
....@@ -11445,7 +11463,14 @@
1144511463 if (checker != null && DrawMode() == DEFAULT)
1144611464 {
1144711465 //BindTexture(IMMORTAL_TEXTURE);
11448
- BindTextures(checker.GetTextures(), checker.texres);
11466
+ try
11467
+ {
11468
+ BindTextures(checker.GetTextures(), checker.texres);
11469
+ }
11470
+ catch (Exception e)
11471
+ {
11472
+ System.err.println("FAILED: " + checker.GetTextures());
11473
+ }
1144911474 // NEAREST
1145011475 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1145111476 DrawChecker(gl);
....@@ -16602,7 +16627,7 @@
1660216627 //gl.glColorMask(false, false, false, false);
1660316628
1660416629 //render_scene_from_light_view(gl, drawable, 0, 0);
16605
- if (Globals.RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16630
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660616631 {
1660716632 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660816633
Composite.java
....@@ -866,7 +866,14 @@
866866 tex = GetTextures();
867867 }
868868
869
- display.BindTextures(tex, texres);
869
+ try
870
+ {
871
+ display.BindTextures(tex, texres);
872
+ }
873
+ catch (Exception e)
874
+ {
875
+ System.err.println("FAILED: " + this);
876
+ }
870877
871878 if (//true) // new NORMAND
872879 touched || softtouched)
Face.java
....@@ -31,6 +31,8 @@
3131 //cVector norm;
3232 //short flags;
3333
34
+ transient boolean used;
35
+
3436 transient float weight; // face weight using normals if leaf or maximum of all recursive elements
3537 transient int good; // vertex links broken
3638 transient int boundary;
GenericJoint.java
....@@ -557,7 +557,8 @@
557557 bRep.startvertices = new int[numObjects];
558558 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3];
559559 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3];
560
- bRep.supportsizes = new float[(bRep.startvertices.length-1)];
560
+ bRep.supportminsize = new float[(bRep.startvertices.length-1)];
561
+ bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];
561562 buildrep = true;
562563
563564 initialmatrices = new ObjectArrayList<Transform>();
....@@ -1225,11 +1226,12 @@
12251226 }
12261227 else
12271228 {
1228
- if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportsizes == null)
1229
+ if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportminsize == null || bRep.supportmaxsize == null)
12291230 {
12301231 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3];
12311232 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3];
1232
- bRep.supportsizes = new float[(bRep.startvertices.length-1)];
1233
+ bRep.supportminsize = new float[(bRep.startvertices.length-1)];
1234
+ bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];
12331235 }
12341236
12351237 float averagex = 0;
....@@ -1299,7 +1301,8 @@
12991301 }
13001302 }
13011303
1302
- bRep.supportsizes[currentobject-1] = (float)Math.sqrt(mindist2);
1304
+ bRep.supportminsize[currentobject-1] = (float)Math.sqrt(mindist2);
1305
+ bRep.supportmaxsize[currentobject-1] = (float)Math.sqrt(maxdist2);
13031306 }
13041307
13051308 // if (hull.numTriangles() > 0)
Globals.java
....@@ -1,12 +1,13 @@
11
22 public class Globals
33 {
4
- public static boolean ADVANCED = false;
4
+ public static boolean ADVANCED = true; //false;
55
66 static iCameraPane theRenderer;
77
88 private static boolean LIVE = false;
99 public static boolean RENDERSHADOW = true;
10
+ public static boolean FREEZEONMOVE = false; // true;
1011
1112 static boolean CROWD = false;
1213 static public int drawMode = iCameraPane.DEFAULT; // WARNING
Grafreed.java
....@@ -23,6 +23,8 @@
2323 static float epsvertex2 = 0.001f;
2424 static boolean linkUV = false; // not uniform at load time
2525
26
+ static boolean smoothmode = false;
27
+
2628 static Wav wav = new Wav("/Users/nbriere/0ut/wavs/monoformat"); // output");
2729 static boolean hassound = false;
2830 static boolean savesound = false;
Grid.java
....@@ -4,7 +4,7 @@
44
55 Grid()
66 {
7
- this(35, 34);
7
+ this(36, 36);
88 }
99
1010 Grid(int u, int v)
GroupEditor.java
....@@ -210,10 +210,6 @@
210210 oe.menuBar.add(menu = new Menu("Setting"));
211211 if (Globals.ADVANCED)
212212 {
213
- resetMeshItem = menu.add(new MenuItem("Reset All"));
214
- resetMeshItem.addActionListener(this);
215
- stepAllItem = menu.add(new MenuItem("Step All"));
216
- stepAllItem.addActionListener(this);
217213 revertMeshItem = menu.add(new MenuItem("Revert Meshes"));
218214 revertMeshItem.addActionListener(this);
219215 resetreferencesItem = menu.add(new MenuItem("Reset Mesh References"));
....@@ -372,6 +368,10 @@
372368 oe.menuBar.add(menu = new Menu("Attributes"));
373369 clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
374370 clearMaterialsItem.addActionListener(this);
371
+ resetAllItem = menu.add(new MenuItem("Reset All"));
372
+ resetAllItem.addActionListener(this);
373
+ stepAllItem = menu.add(new MenuItem("Step All"));
374
+ stepAllItem.addActionListener(this);
375375 menu.add("-");
376376 liveleavesItem = menu.add(new MenuItem("Live Leaves"));
377377 liveleavesItem.addActionListener(this);
....@@ -493,7 +493,7 @@
493493 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
494494
495495 oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints);
496
- liveCB.setToolTipText("Enabled animation");
496
+ liveCB.setToolTipText("Enable animation");
497497 liveCB.addItemListener(this);
498498
499499 oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -2281,7 +2281,7 @@
22812281 {
22822282 RevertMeshes();
22832283 } else
2284
- if (source == resetMeshItem)
2284
+ if (source == resetAllItem)
22852285 {
22862286 ResetAll();
22872287 } else
....@@ -3652,7 +3652,16 @@
36523652 String pigment = Object3D.GetPigment(tex);
36533653 //String bump = Object3D.GetBump(tex);
36543654
3655
- com.sun.opengl.util.texture.TextureData texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
3655
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3656
+
3657
+ try
3658
+ {
3659
+ texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
3660
+ }
3661
+ catch (Exception e)
3662
+ {
3663
+ System.err.println("FAIL: " + node);
3664
+ }
36563665
36573666 double s = v.s;
36583667
....@@ -5131,7 +5140,7 @@
51315140 private MenuItem linkverticesItem;
51325141 private MenuItem relinkverticesItem;
51335142 private MenuItem setMasterItem;
5134
- private MenuItem resetMeshItem;
5143
+ private MenuItem resetAllItem;
51355144 private MenuItem stepAllItem;
51365145 private MenuItem revertMeshItem;
51375146 private MenuItem poseMeshItem;
LA.java
....@@ -88,6 +88,9 @@
8888
8989 static void vecCopy(cVector a, cVector b)
9090 {
91
+ Grafreed.Assert (a != null);
92
+ assert (b != null);
93
+
9194 b.x = a.x;
9295 b.y = a.y;
9396 b.z = a.z;
Merge.java
....@@ -134,6 +134,7 @@
134134 transient cVector maxima = new cVector();
135135
136136 // ObjectArrayList<Transform> initialmatrices;
137
+ transient boolean rendered = false;
137138
138139 void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
139140 {
....@@ -153,6 +154,8 @@
153154 {
154155 e.printStackTrace();
155156 }
157
+
158
+ rendered = true;
156159 }
157160
158161 super.DrawNode(display, root, selected);
....@@ -260,7 +263,8 @@
260263 bRep.startvertices = new int[NumGeometries(GetObject()) + 1];
261264 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3];
262265 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3];
263
- bRep.supportsizes = new float[(bRep.startvertices.length-1)];
266
+ bRep.supportminsize = new float[(bRep.startvertices.length-1)];
267
+ bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];
264268 buildrep = true;
265269
266270 // initialmatrices = new ObjectArrayList<Transform>();
....@@ -686,11 +690,12 @@
686690 }
687691 else
688692 {
689
- if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportsizes == null)
693
+ if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportminsize == null || bRep.supportmaxsize == null)
690694 {
691695 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3];
692696 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3];
693
- bRep.supportsizes = new float[(bRep.startvertices.length-1)];
697
+ bRep.supportminsize = new float[(bRep.startvertices.length-1)];
698
+ bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];
694699 }
695700
696701 float averagex = 0;
....@@ -731,42 +736,47 @@
731736 v.norm.normalize();
732737 }
733738
734
- int index3 = currentobject-1;
735
- index3 *= 3;
736
-
737
- bRep.averagepoints[index3] = averagex/count;
738
- bRep.averagepoints[index3+1] = averagey/count;
739
- bRep.averagepoints[index3+2] = averagez/count;
740
-
741
- double mindist2 = 1E10f;
742
- double maxdist2 = -1E10f;
743
-
744
- for (int i=bRep.startvertices[currentobject-1]; i<bRep.startvertices[currentobject]; i++)
739
+ if (!rendered)
745740 {
746
- Vertex v = bRep.GetVertex(i);
747
-
748
- double x = v.x - bRep.averagepoints[index3];
749
- double y = v.y - bRep.averagepoints[index3+1];
750
- double z = v.z - bRep.averagepoints[index3+2];
751
-
752
- double dist2 = x*x + y*y + z*z;
753
-
754
- if (mindist2 > dist2)
755
- mindist2 = dist2;
756
- if (maxdist2 < dist2)
741
+ int index3 = currentobject-1;
742
+ index3 *= 3;
743
+
744
+ bRep.averagepoints[index3] = averagex/count;
745
+ bRep.averagepoints[index3+1] = averagey/count;
746
+ bRep.averagepoints[index3+2] = averagez/count;
747
+
748
+ double mindist2 = 1E10f;
749
+ double maxdist2 = -1E10f;
750
+
751
+ for (int i=bRep.startvertices[currentobject-1]; i<bRep.startvertices[currentobject]; i++)
757752 {
758
- maxdist2 = dist2;
759
- bRep.extremepoints[index3] = (float)v.x;
760
- bRep.extremepoints[index3+1] = (float)v.y;
761
- bRep.extremepoints[index3+2] = (float)v.z;
753
+ Vertex v = bRep.GetVertex(i);
754
+
755
+ double x = v.x - bRep.averagepoints[index3];
756
+ double y = v.y - bRep.averagepoints[index3+1];
757
+ double z = v.z - bRep.averagepoints[index3+2];
758
+
759
+ double dist2 = x*x + y*y + z*z;
760
+
761
+ if (mindist2 > dist2)
762
+ mindist2 = dist2;
763
+
764
+ if (maxdist2 < dist2)
765
+ {
766
+ maxdist2 = dist2;
767
+ bRep.extremepoints[index3] = (float)v.x;
768
+ bRep.extremepoints[index3+1] = (float)v.y;
769
+ bRep.extremepoints[index3+2] = (float)v.z;
770
+ }
762771 }
772
+
773
+ bRep.supportminsize[currentobject-1] = (float)Math.sqrt(mindist2);
774
+ bRep.supportmaxsize[currentobject-1] = (float)Math.sqrt(maxdist2);
775
+ // for (int i = 0; i < hull.numVertices(); i++)
776
+ // {
777
+ //
778
+ // }
763779 }
764
-
765
- bRep.supportsizes[currentobject-1] = (float)Math.sqrt(mindist2);
766
-// for (int i = 0; i < hull.numVertices(); i++)
767
-// {
768
-//
769
-// }
770780 }
771781
772782 // if (hull.numTriangles() > 0)
ObjEditor.java
....@@ -784,6 +784,7 @@
784784 // NumberSlider vDivsField;
785785 // JCheckBox endcaps;
786786 JCheckBox liveCB;
787
+ JCheckBox selectCB;
787788 JCheckBox hideCB;
788789 JCheckBox link2masterCB;
789790 JCheckBox markCB;
....@@ -986,9 +987,11 @@
986987
987988 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
988989 liveCB.setToolTipText("Animate object");
990
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
991
+ selectCB.setToolTipText("Make object selectable");
992
+// Return();
989993 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
990994 hideCB.setToolTipText("Hide object");
991
-// Return();
992995 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
993996 markCB.setToolTipText("Set the animation target transform");
994997
....@@ -1028,7 +1031,7 @@
10281031 oe.ctrlPanel.add(commandsPanel);
10291032 oe.ctrlPanel.Return();
10301033
1031
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1034
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10321035 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10331036 //Return();
10341037
....@@ -3007,6 +3010,10 @@
30073010 {
30083011 copy.live ^= true;
30093012 return;
3013
+ } else if (event.getSource() == selectCB)
3014
+ {
3015
+ copy.dontselect ^= true;
3016
+ return;
30103017 } else if (event.getSource() == hideCB)
30113018 {
30123019 copy.hide ^= true;
....@@ -3588,7 +3595,7 @@
35883595 }
35893596
35903597 if (normalpushField != null)
3591
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3598
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35923599 }
35933600
35943601 void SnapObject()
Object3D.java
....@@ -300,6 +300,7 @@
300300 }
301301
302302 boolean live = false;
303
+ boolean dontselect = false;
303304 boolean hide = false;
304305 boolean link2master = false; // performs reset support/master at each frame
305306 boolean marked = false; // animation node
....@@ -1834,12 +1835,15 @@
18341835 if (obj.name == null)
18351836 continue; // can't be a null one
18361837
1838
+ // Try perfect match first.
18371839 if (n.equals(obj.name))
18381840 {
18391841 theobj = obj;
18401842 count++;
18411843 }
18421844 }
1845
+
1846
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18431847
18441848 if (count != 1)
18451849 for (int i=Size(); --i>=0;)
....@@ -3002,8 +3006,10 @@
30023006 v.fromParent = LA.newMatrix();
30033007 }
30043008
3005
- LA.matConcat(v.toParent, toParent, v.toParent);
3006
- LA.matConcat(fromParent, v.fromParent, v.fromParent);
3009
+// LA.matConcat(v.toParent, toParent, v.toParent);
3010
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3011
+ LA.matConcat(toParent, v.toParent, v.toParent);
3012
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
30073013 }
30083014
30093015 toParent = null; // LA.matIdentity(toParent);
....@@ -3236,7 +3242,9 @@
32363242 bRep.support = null;
32373243 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32383244 // bRep.SplitInTwo(onlyone); // thread...
3239
- temprep.SplitInTwo(reduction34, onlyone);
3245
+
3246
+ while(temprep.SplitInTwo(reduction34, onlyone));
3247
+
32403248 bRep = temprep;
32413249 bRep.support = sup;
32423250 Touch();
....@@ -4711,7 +4719,7 @@
47114719
47124720 cTreePath SelectLeaf(int indexcount, boolean deselect)
47134721 {
4714
- if (hide)
4722
+ if (hide || dontselect)
47154723 return null;
47164724
47174725 if (count <= 0)
....@@ -4737,7 +4745,7 @@
47374745
47384746 cTreePath Select(int indexcount, boolean deselect)
47394747 {
4740
- if (hide)
4748
+ if (hide || dontselect)
47414749 return null;
47424750
47434751 if (count <= 0)
....@@ -5407,7 +5415,7 @@
54075415 boolean NeedSupport()
54085416 {
54095417 return
5410
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5418
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
54115419 // PROBLEM with CROWD!!
54125420 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54135421 }
....@@ -5424,7 +5432,7 @@
54245432 }
54255433
54265434 if (display.DrawMode() == iCameraPane.SELECTION &&
5427
- hide)
5435
+ (hide || dontselect))
54285436 return;
54295437
54305438 if (name != null && name.contains("sclera"))
....@@ -5666,7 +5674,17 @@
56665674 tex = GetTextures();
56675675 }
56685676
5669
- display.BindTextures(tex, texres);
5677
+ boolean failed = false;
5678
+
5679
+ try
5680
+ {
5681
+ display.BindTextures(tex, texres);
5682
+ }
5683
+ catch (Exception e)
5684
+ {
5685
+ System.err.println("FAILED: " + this);
5686
+ failed = true;
5687
+ }
56705688
56715689 if (!compiled)
56725690 {
....@@ -5688,7 +5706,8 @@
56885706 }
56895707 }
56905708
5691
- display.ReleaseTextures(tex);
5709
+ if (!failed)
5710
+ display.ReleaseTextures(tex);
56925711
56935712 display.PopMaterial(this, selected);
56945713 }
....@@ -5817,6 +5836,9 @@
58175836
58185837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
58195838 {
5839
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5840
+ return;
5841
+
58205842 if (hide)
58215843 return;
58225844 // shadow optimisation
....@@ -5942,6 +5964,9 @@
59425964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59435965 return; // no shadow for transparent objects
59445966
5967
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5968
+ return;
5969
+
59455970 if (hide)
59465971 return;
59475972
Vertex.java
....@@ -112,7 +112,6 @@
112112 {
113113 //if (normalmode) // pos == null)
114114 // return 0;
115
-
116115 if (norm == null || !normalmode)
117116 {
118117 return /*pos.*/ super.hashCode();
....@@ -129,12 +128,26 @@
129128 Vertex vert = (Vertex) o;
130129
131130 //System.out.println("pos = " + pos + "; vert.pos = " + vert/*.pos*/);
131
+
132
+ double tolerance = 0.00001;
133
+
134
+ if (!Grafreed.epsequal)
135
+ tolerance = 0;
132136
133
- return Math.abs(/*pos.*/x - vert./*pos.*/x) +
134
- Math.abs(/*pos.*/y - vert./*pos.*/y) +
135
- Math.abs(/*pos.*/z - vert./*pos.*/z) < 0.00001 && // GrafreeD.epsvertex2 && // WARNING: USE 0.0001 for serial issues
136
- (Grafreed.linkUV || Math.abs(s - vert.s) + Math.abs(t - vert.t) < 0.00001)
137
- ; // GrafreeD.epsvertex2;
137
+ boolean samepos = Math.abs(/*pos.*/x - vert./*pos.*/x) +
138
+ Math.abs(/*pos.*/y - vert./*pos.*/y) +
139
+ Math.abs(/*pos.*/z - vert./*pos.*/z) <= tolerance && // GrafreeD.epsvertex2 && // WARNING: USE 0.0001 for serial issues
140
+ (Grafreed.linkUV || Math.abs(s - vert.s) + Math.abs(t - vert.t) <= tolerance)
141
+ ; // GrafreeD.epsvertex2;
142
+
143
+ if (samepos && Grafreed.smoothmode)
144
+ {
145
+ norm.add(vert.norm);
146
+ norm.normalize();
147
+ vert.norm.set(norm);
148
+ }
149
+
150
+ return samepos;
138151 }
139152 /*
140153 public boolean isSame(Object o)
cVector.java
....@@ -63,6 +63,15 @@
6363 }
6464 }
6565
66
+ cVector ToFloat()
67
+ {
68
+ x = (float)x;
69
+ y = (float)y;
70
+ z = (float)z;
71
+
72
+ return this;
73
+ }
74
+
6675 void set(cVector v)
6776 {
6877 x = v.x;
....@@ -247,18 +256,21 @@
247256 return "[" + x0 + ", " + y0 + ", " + z0 + "]";
248257 }
249258
250
- /*
251259 public boolean equals(Object o)
252260 {
253261 //if (true) return false;
254262
255263 cVector vert = (cVector) o;
256264
265
+ double tolerance = 0.00001;
266
+
267
+ if (!Grafreed.epsequal)
268
+ tolerance = 0;
269
+
257270 return Math.abs(x - vert.x) +
258271 Math.abs(y - vert.y) +
259
- Math.abs(z - vert.z) < 0.01;
272
+ Math.abs(z - vert.z) <= tolerance;
260273 }
261
- */
262274
263275 public int hashCode()
264276 {
iCameraPane.java
....@@ -55,7 +55,7 @@
5555
5656 void DrawString(Object3D obj);
5757
58
- void BindTextures(cTexture tex, int resolution);
58
+ void BindTextures(cTexture tex, int resolution) throws Exception;
5959 void ReleaseTextures(cTexture tex);
6060
6161 void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face);
....@@ -82,7 +82,7 @@
8282
8383 void setCursor(java.awt.Cursor cursor);
8484
85
- com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution);
85
+ com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception;
8686
8787 void repaint();
8888