.. | .. |
---|
15 | 15 | { |
---|
16 | 16 | this(0, 0); |
---|
17 | 17 | } |
---|
18 | | - |
---|
| 18 | + |
---|
19 | 19 | void SaveSupports() |
---|
20 | 20 | { |
---|
21 | 21 | transientsupport = support; |
---|
.. | .. |
---|
497 | 497 | return dist2; |
---|
498 | 498 | } |
---|
499 | 499 | |
---|
500 | | - static Vertex vertextemp = new Vertex(); |
---|
501 | | - static Vertex vertextemp2 = new Vertex(); |
---|
| 500 | + static Vertex vertextemp = new Vertex(true); |
---|
| 501 | + static Vertex vertextemp2 = new Vertex(true); |
---|
502 | 502 | |
---|
503 | | - static double SEUIL = 0.1; // 0.1 for rag doll; 0.07; |
---|
| 503 | + static double SEUIL = 0.1f; // 0.1 for rag doll; 0.07; |
---|
504 | 504 | |
---|
505 | 505 | // Compute weight of point w/r to this |
---|
506 | 506 | float ComputeWeight(Vertex v, double[][] toRoot, int k) |
---|
.. | .. |
---|
570 | 570 | |
---|
571 | 571 | if (dot > distmax) |
---|
572 | 572 | dot = distmax; |
---|
| 573 | + //return 0; // patch for strange behavior |
---|
573 | 574 | if (dot < -distmax) |
---|
574 | 575 | dot = -distmax; |
---|
| 576 | + //return 0; // patch for strange behavior |
---|
575 | 577 | |
---|
576 | 578 | // v3 = GetVertex(this.startvertices[subsupport] + 16); |
---|
577 | 579 | // |
---|
.. | .. |
---|
609 | 611 | |
---|
610 | 612 | float dist2 = (float)Distance2(v, v2, 1E10, toRoot, k); |
---|
611 | 613 | |
---|
612 | | - if (dist2 >= 2 * SEUIL*SEUIL) // && !CameraPane.CROWD) // weightmode |
---|
| 614 | + double seuil = SEUIL * 2; |
---|
| 615 | + |
---|
| 616 | + if (dist2 >= 2 * seuil*seuil) // && !CameraPane.CROWD) // weightmode |
---|
613 | 617 | return 0; |
---|
614 | 618 | |
---|
615 | | - dist2 /= 2 * SEUIL*SEUIL; // multiplied by two because center of support |
---|
| 619 | + dist2 /= 2 * seuil*seuil; // multiplied by two because center of support |
---|
616 | 620 | // could be far from closest point |
---|
617 | 621 | |
---|
618 | 622 | // dist2 = Math.pow(dist2, 2); |
---|
.. | .. |
---|
786 | 790 | v.weights[k] = other.ComputeWeight(v, toRoot, k); // (float)(supportsize * normalweight * nz / Math.pow(tx*tx+ty*ty+tz*tz, 1)); |
---|
787 | 791 | v.totalweight += v.weights[k]; |
---|
788 | 792 | |
---|
789 | | - if (CameraPane.CROWD) |
---|
| 793 | + if (Globals.CROWD) |
---|
790 | 794 | { |
---|
791 | 795 | // System.out.print("weight = " + v.weights[k]); |
---|
792 | 796 | // System.out.println("; totalweight = " + v.totalweight); |
---|
.. | .. |
---|
946 | 950 | |
---|
947 | 951 | int nbsupports; |
---|
948 | 952 | |
---|
949 | | - SEUIL = 0.1; // aout 2013 |
---|
| 953 | + // sept 2017 SEUIL = 0.1; // aout 2013 |
---|
950 | 954 | |
---|
951 | 955 | supports = InitConnections(other); |
---|
952 | 956 | |
---|
.. | .. |
---|
982 | 986 | |
---|
983 | 987 | int subsupports = 0; |
---|
984 | 988 | |
---|
985 | | - SEUIL = 0.1; // aout 2013 |
---|
| 989 | + // sept 2017 SEUIL = 0.1; // aout 2013 |
---|
986 | 990 | |
---|
987 | 991 | while (subsupports == 0) |
---|
988 | 992 | { |
---|
.. | .. |
---|
1006 | 1010 | |
---|
1007 | 1011 | vect.set(v); |
---|
1008 | 1012 | vect.sub(vect2); |
---|
| 1013 | + |
---|
| 1014 | +// vertextemp.x = other.averagepoints[c*3]; |
---|
| 1015 | +// vertextemp.y = other.averagepoints[c*3+1]; |
---|
| 1016 | +// vertextemp.z = other.averagepoints[c*3+2]; |
---|
| 1017 | +// |
---|
| 1018 | +// Vertex v3 = vertextemp2; |
---|
| 1019 | +// v3.x = other.extremepoints[c*3]; |
---|
| 1020 | +// v3.y = other.extremepoints[c*3+1]; |
---|
| 1021 | +// v3.z = other.extremepoints[c*3+2]; |
---|
| 1022 | +// |
---|
| 1023 | +// vect3.set(v3); // "X" axis apex |
---|
| 1024 | +// vect3.sub(vertextemp); // origin (center) |
---|
| 1025 | +// |
---|
| 1026 | +// double distmax = vect3.length(); |
---|
| 1027 | +// |
---|
| 1028 | +// vect3.set(v2); // "X" axis apex |
---|
| 1029 | +// vect3.sub(vertextemp); // origin (center) |
---|
| 1030 | +// |
---|
| 1031 | +// if (vect3.length() >= distmax) |
---|
| 1032 | +// continue; |
---|
1009 | 1033 | |
---|
1010 | 1034 | if (mindistance > vect.dot(vect)) |
---|
1011 | 1035 | { |
---|
.. | .. |
---|
1017 | 1041 | |
---|
1018 | 1042 | subsupports = v.closestsupport==-1 ? 0 : supports[v.closestsupport].Length(); |
---|
1019 | 1043 | |
---|
1020 | | - SEUIL *= 2; |
---|
| 1044 | + // previously for "contains", now for weights. |
---|
| 1045 | + assert(subsupports > 0); |
---|
| 1046 | + //SEUIL *= 2; |
---|
1021 | 1047 | } |
---|
1022 | 1048 | |
---|
1023 | 1049 | assert(subsupports > 0); |
---|
.. | .. |
---|
2163 | 2189 | // if (slow) |
---|
2164 | 2190 | // aout 2013 |
---|
2165 | 2191 | // sept 2013 merde... |
---|
2166 | | - W = 13; |
---|
| 2192 | + W = 3; // 13; |
---|
2167 | 2193 | |
---|
2168 | 2194 | // POSERATE |
---|
2169 | 2195 | if (CameraPane.tickcount > 0 || CameraPane.SLOWPOSE) |
---|
.. | .. |
---|
2635 | 2661 | if (false) // slow && stepout && onein) |
---|
2636 | 2662 | { |
---|
2637 | 2663 | // sound |
---|
2638 | | - cVector eye = CameraPane.theRenderer.eyeCamera.location; |
---|
| 2664 | + cVector eye = Globals.theRenderer.EyeCamera().location; |
---|
2639 | 2665 | |
---|
2640 | 2666 | Vertex v = GetVertex(0); |
---|
2641 | 2667 | |
---|
2642 | 2668 | tmp.set(v); |
---|
2643 | 2669 | tmp.sub(eye); |
---|
2644 | 2670 | |
---|
2645 | | - if (CameraPane.framecount - lastsoundtime > 30) // 0.25 secs |
---|
| 2671 | + if (Globals.framecount - lastsoundtime > 30) // 0.25 secs |
---|
2646 | 2672 | { |
---|
2647 | 2673 | GrafreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1); |
---|
2648 | 2674 | |
---|
2649 | | - lastsoundtime = CameraPane.framecount; |
---|
| 2675 | + lastsoundtime = Globals.framecount; |
---|
2650 | 2676 | } |
---|
2651 | 2677 | |
---|
2652 | 2678 | stepout = false; |
---|
.. | .. |
---|
3129 | 3155 | */ |
---|
3130 | 3156 | } |
---|
3131 | 3157 | |
---|
3132 | | - void GenUV() |
---|
| 3158 | + void UnfoldUV() |
---|
| 3159 | + { |
---|
| 3160 | + for (int i = 0; i < VertexCount(); i++) |
---|
| 3161 | + { |
---|
| 3162 | + Vertex v = GetVertex(i); |
---|
| 3163 | + |
---|
| 3164 | + v.x = v.s; |
---|
| 3165 | + v.y = v.t; |
---|
| 3166 | + v.z = 0; |
---|
| 3167 | + |
---|
| 3168 | + v.norm.x = 0; |
---|
| 3169 | + v.norm.y = 0; |
---|
| 3170 | + v.norm.z = 1; |
---|
| 3171 | + |
---|
| 3172 | + SetVertex(v, i); |
---|
| 3173 | + } |
---|
| 3174 | + } |
---|
| 3175 | + |
---|
| 3176 | + float power = 2; |
---|
| 3177 | + |
---|
| 3178 | + void GenUV() // float power) |
---|
3133 | 3179 | { |
---|
3134 | 3180 | Trim(); |
---|
3135 | 3181 | |
---|
.. | .. |
---|
3193 | 3239 | y -= 0.5; |
---|
3194 | 3240 | z -= 0.5; |
---|
3195 | 3241 | |
---|
| 3242 | + double ax = Math.abs(x); |
---|
| 3243 | + double ay = Math.abs(y); |
---|
| 3244 | + double max = ax; |
---|
| 3245 | + if (max < ay) |
---|
| 3246 | + { |
---|
| 3247 | + max = ay; |
---|
| 3248 | + } |
---|
| 3249 | + |
---|
| 3250 | + x /= max; |
---|
| 3251 | + y /= max; |
---|
| 3252 | + |
---|
| 3253 | + double angle = Math.acos(Math.abs(z*2)); |
---|
| 3254 | + |
---|
| 3255 | + double k = angle / Math.PI * 2; |
---|
| 3256 | + |
---|
| 3257 | + // k == 0 => uv = 0 (center) |
---|
| 3258 | + // k == 1 => uv = -1,1 (border) |
---|
| 3259 | + |
---|
| 3260 | + if (i == 0) |
---|
| 3261 | + System.out.println("power = " + power); |
---|
| 3262 | + |
---|
| 3263 | + double length1 = (ax+ay)/max; |
---|
| 3264 | + double length2 = Math.sqrt(ax*ax + ay*ay) / max; |
---|
| 3265 | + |
---|
| 3266 | + double t = k; |
---|
| 3267 | + |
---|
| 3268 | + t = Math.pow(t, 3); |
---|
| 3269 | + |
---|
| 3270 | + // Interpolate between k/length2 (center) and k (border) |
---|
| 3271 | + k = k / length2 * (1 - t) + k * t; |
---|
| 3272 | + |
---|
| 3273 | + double u = k*x; |
---|
| 3274 | + double v = k*y; |
---|
| 3275 | + |
---|
| 3276 | + u /= 2; |
---|
| 3277 | + v /= 2; |
---|
| 3278 | + u += 0.5; |
---|
| 3279 | + v += 0.5; |
---|
| 3280 | + |
---|
| 3281 | + uvmap[i2] = (float) u; |
---|
| 3282 | + uvmap[i2+1] = (float) v; |
---|
| 3283 | + } |
---|
| 3284 | + } |
---|
| 3285 | + |
---|
| 3286 | + void GenUVold(float power) |
---|
| 3287 | + { |
---|
| 3288 | + Trim(); |
---|
| 3289 | + |
---|
| 3290 | + cVector boxcenter = null; |
---|
| 3291 | + cVector minima, maxima; |
---|
| 3292 | + minima = new cVector(); |
---|
| 3293 | + maxima = new cVector(); |
---|
| 3294 | + minima.x = minima.y = minima.z = Double.MAX_VALUE; |
---|
| 3295 | + maxima.x = maxima.y = maxima.z = -Double.MAX_VALUE; |
---|
| 3296 | + for (int i = 0; i < VertexCount(); i++) |
---|
| 3297 | + { |
---|
| 3298 | + Vertex v = GetVertex(i); |
---|
| 3299 | + |
---|
| 3300 | + if (minima.x > v.x) |
---|
| 3301 | + { |
---|
| 3302 | + minima.x = v.x; |
---|
| 3303 | + } |
---|
| 3304 | + if (minima.y > v.y) |
---|
| 3305 | + { |
---|
| 3306 | + minima.y = v.y; |
---|
| 3307 | + } |
---|
| 3308 | + if (minima.z > v.z) |
---|
| 3309 | + { |
---|
| 3310 | + minima.z = v.z; |
---|
| 3311 | + } |
---|
| 3312 | + |
---|
| 3313 | + if (maxima.x < v.x) |
---|
| 3314 | + { |
---|
| 3315 | + maxima.x = v.x; |
---|
| 3316 | + } |
---|
| 3317 | + if (maxima.y < v.y) |
---|
| 3318 | + { |
---|
| 3319 | + maxima.y = v.y; |
---|
| 3320 | + } |
---|
| 3321 | + if (maxima.z < v.z) |
---|
| 3322 | + { |
---|
| 3323 | + maxima.z = v.z; |
---|
| 3324 | + } |
---|
| 3325 | + } |
---|
| 3326 | + |
---|
| 3327 | + boxcenter = new cVector((maxima.x + minima.x) / 2, (maxima.y + minima.y) / 2, (maxima.z + minima.z) / 2); |
---|
| 3328 | + int i2 = 0, i3 = 0; |
---|
| 3329 | + for (int i = 0; i < positions.length/3; i++, i3 += 3, i2 += 2) |
---|
| 3330 | + { |
---|
| 3331 | +// //uvmap[i2] = (float) normals[i3]*0.5f + 0.5f; // v.x; |
---|
| 3332 | +// //uvmap[i2 + 1] = (float) normals[i3+1]*0.5f + 0.5f; //z; |
---|
| 3333 | +// uvmap[i2] = (float) (positions[i3] - boxcenter.x); |
---|
| 3334 | +// uvmap[i2 + 1] = (float) (positions[i3+2] - boxcenter.z); |
---|
| 3335 | +// uvmap[i2] = (float) Math.atan2(positions[i3+1] - boxcenter.y, positions[i3] - boxcenter.x); |
---|
| 3336 | +// uvmap[i2 + 1] = (float)(positions[i3+2] - boxcenter.z); |
---|
| 3337 | + // box UV |
---|
| 3338 | + double x = positions[i3] - minima.x; // - Math.floor(positions[i3]); |
---|
| 3339 | + double y = positions[i3+1] - minima.y; // - Math.floor(positions[i3+1]); |
---|
| 3340 | + double z = positions[i3+2] - minima.z; // - Math.floor(positions[i3+2]); |
---|
| 3341 | + |
---|
| 3342 | + // [-1/2, 1/2] |
---|
| 3343 | + x /= maxima.x - minima.x; |
---|
| 3344 | + y /= maxima.y - minima.y; |
---|
| 3345 | + z /= maxima.z - minima.z; |
---|
| 3346 | + |
---|
| 3347 | + x -= 0.5; |
---|
| 3348 | + y -= 0.5; |
---|
| 3349 | + z -= 0.5; |
---|
| 3350 | + |
---|
3196 | 3351 | // x *= 2; |
---|
3197 | 3352 | // y *= 2; |
---|
3198 | 3353 | // z *= 2; |
---|
.. | .. |
---|
3219 | 3374 | |
---|
3220 | 3375 | z = Math.cos(angle/2); |
---|
3221 | 3376 | |
---|
| 3377 | + assert(z >= 0); |
---|
| 3378 | + assert(z <= 1); |
---|
| 3379 | + |
---|
| 3380 | + /**/ |
---|
| 3381 | + //z = Math.pow(z, power); //1.08f); |
---|
| 3382 | + |
---|
| 3383 | + if (i == 0) |
---|
| 3384 | + System.out.println("power = " + power); |
---|
| 3385 | + |
---|
3222 | 3386 | // sqrt(k2*x2 + k2*z2 + y2) = length |
---|
3223 | 3387 | // k2*x2 + k2*z2 = length2 - y2 |
---|
3224 | 3388 | // k2 = (length2 - y2) / (x2 + z2) |
---|
.. | .. |
---|
3238 | 3402 | |
---|
3239 | 3403 | x *= k; |
---|
3240 | 3404 | y *= k; |
---|
| 3405 | + /**/ |
---|
3241 | 3406 | |
---|
3242 | 3407 | double max = Math.abs(x); |
---|
3243 | 3408 | if (max < Math.abs(y)) |
---|
.. | .. |
---|
3250 | 3415 | } |
---|
3251 | 3416 | |
---|
3252 | 3417 | // max = Math.sqrt(max*2)/2; |
---|
| 3418 | +// double x2 = Math.pow(Math.abs(x), 1/power); |
---|
| 3419 | +// double y2 = Math.pow(Math.abs(y), 1/power); |
---|
| 3420 | +// double z2 = Math.pow(Math.abs(z), 1/power); |
---|
| 3421 | +// max = Math.pow(x2 + y2 + z2, power); |
---|
3253 | 3422 | |
---|
3254 | 3423 | // if (!(max > 0)) |
---|
3255 | | - assert(max > 0); |
---|
3256 | | - |
---|
| 3424 | + //assert(max > 0); |
---|
| 3425 | + assert(max >= 0); |
---|
| 3426 | + |
---|
3257 | 3427 | x /= max; |
---|
3258 | 3428 | y /= max; |
---|
3259 | 3429 | z /= max; |
---|
.. | .. |
---|
3776 | 3946 | for (int i = 0; i < VertexCount(); i++) |
---|
3777 | 3947 | { |
---|
3778 | 3948 | Vertex v = GetVertex(i); |
---|
| 3949 | + |
---|
| 3950 | + vertextemp.set(v); |
---|
| 3951 | + |
---|
3779 | 3952 | //if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
3780 | 3953 | { |
---|
3781 | | - GenerateNormal(i, v); |
---|
3782 | | - SetVertex(v, i); |
---|
| 3954 | + if (!GenerateNormal(i, vertextemp)) |
---|
| 3955 | + continue; |
---|
| 3956 | + |
---|
| 3957 | + if (v.norm.dot(vertextemp.norm) < 0) |
---|
| 3958 | + vertextemp.norm.mul(-1); |
---|
| 3959 | + |
---|
| 3960 | + if (v.norm.dot(vertextemp.norm) < 0.9) |
---|
| 3961 | + SetVertex(vertextemp, i); |
---|
3783 | 3962 | } |
---|
3784 | 3963 | } |
---|
3785 | 3964 | |
---|
.. | .. |
---|
3790 | 3969 | static cVector temp2 = new cVector(); |
---|
3791 | 3970 | static cVector temp3 = new cVector(); |
---|
3792 | 3971 | |
---|
3793 | | - void GenerateNormal(int index, Vertex v) |
---|
| 3972 | + boolean GenerateNormal(int index, Vertex v) |
---|
3794 | 3973 | { |
---|
3795 | 3974 | //System.out.println("Old normal = " + v.norm); |
---|
3796 | 3975 | LA.setVector(v.norm, 0, 0, 0); |
---|
.. | .. |
---|
3819 | 3998 | LA.vecSub(p/*.pos*/, v/*.pos*/, temp1); |
---|
3820 | 3999 | LA.vecSub(q/*.pos*/, v/*.pos*/, temp2); |
---|
3821 | 4000 | } |
---|
| 4001 | + else |
---|
| 4002 | + { |
---|
| 4003 | + continue; |
---|
| 4004 | + } |
---|
3822 | 4005 | |
---|
3823 | 4006 | //LA.vecNormalize(temp1); |
---|
3824 | 4007 | //LA.vecNormalize(temp2); |
---|
.. | .. |
---|
3829 | 4012 | double s = temp3.length(); |
---|
3830 | 4013 | //double c = temp2.dot(temp1); |
---|
3831 | 4014 | |
---|
| 4015 | + if (s == 0) |
---|
| 4016 | + return false; |
---|
| 4017 | + |
---|
3832 | 4018 | float angle = 1; // (float) Math.atan2(s, c); |
---|
3833 | 4019 | //if(angle < 0) angle = -angle; |
---|
3834 | 4020 | |
---|
3835 | 4021 | //LA.vecNormalize(temp3); |
---|
3836 | 4022 | LA.vecScale(temp3, angle / s); |
---|
3837 | 4023 | |
---|
| 4024 | +// if (temp3.dot(v.norm) < 0) |
---|
| 4025 | +// assert(temp3.dot(v.norm) >= 0); |
---|
| 4026 | + |
---|
3838 | 4027 | LA.vecAdd(temp3, v.norm, v.norm); |
---|
3839 | 4028 | } |
---|
3840 | 4029 | |
---|
3841 | 4030 | LA.vecNormalize(v.norm); |
---|
3842 | 4031 | //System.out.println("New normal = " + v.norm); |
---|
| 4032 | + |
---|
| 4033 | + return true; |
---|
3843 | 4034 | } |
---|
3844 | 4035 | |
---|
3845 | 4036 | double Arccos(double x) |
---|
.. | .. |
---|
4233 | 4424 | int count = VertexCount(); |
---|
4234 | 4425 | |
---|
4235 | 4426 | // mars 2014 |
---|
4236 | | - while (step >= count) |
---|
| 4427 | + while (step > count) |
---|
4237 | 4428 | step /= 10; |
---|
4238 | 4429 | |
---|
4239 | 4430 | for (int i = 0; i < count; i+=step) |
---|
.. | .. |
---|
4381 | 4572 | } |
---|
4382 | 4573 | } |
---|
4383 | 4574 | |
---|
4384 | | - void CullVertex(javax.media.opengl.GL gl, boolean shadow) |
---|
| 4575 | + void CullVertex(javax.media.opengl.GL glNOTUSED, boolean shadowNOTUSED) |
---|
4385 | 4576 | { |
---|
4386 | 4577 | CameraPane.glu.gluProject(vect5.x,vect5.y,vect5.z, |
---|
4387 | 4578 | CameraPane.tempmat,0, CameraPane.tempmat2,0, |
---|
.. | .. |
---|
4413 | 4604 | // june 2014 |
---|
4414 | 4605 | // Camera parentcam = cam; |
---|
4415 | 4606 | // |
---|
4416 | | -// if (cam == CameraPane.theRenderer.cameras[0]) |
---|
| 4607 | +// if (cam == Globals.theRenderer.cameras[0]) |
---|
4417 | 4608 | // { |
---|
4418 | | -// parentcam = CameraPane.theRenderer.cameras[1]; |
---|
| 4609 | +// parentcam = Globals.theRenderer.cameras[1]; |
---|
4419 | 4610 | // } |
---|
4420 | 4611 | // |
---|
4421 | | -// if (cam == CameraPane.theRenderer.cameras[1]) |
---|
| 4612 | +// if (cam == Globals.theRenderer.cameras[1]) |
---|
4422 | 4613 | // { |
---|
4423 | | -// parentcam = CameraPane.theRenderer.cameras[0]; |
---|
| 4614 | +// parentcam = Globals.theRenderer.cameras[0]; |
---|
4424 | 4615 | // } |
---|
4425 | 4616 | |
---|
4426 | 4617 | gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, CameraPane.tempmat, 0); |
---|
.. | .. |
---|
4846 | 5037 | return verticesCopy; |
---|
4847 | 5038 | } |
---|
4848 | 5039 | |
---|
4849 | | - void PreprocessOcclusion(CameraPane cp, double[][] transform) |
---|
| 5040 | + void PreprocessOcclusion(iCameraPane cp, double[][] transform) |
---|
4850 | 5041 | { |
---|
4851 | 5042 | if (//!trimmed || |
---|
4852 | 5043 | AOdone) |
---|
.. | .. |
---|
4855 | 5046 | return; |
---|
4856 | 5047 | } |
---|
4857 | 5048 | |
---|
4858 | | - Camera keep = cp.renderCamera; |
---|
4859 | | - cp.renderCamera = localcamera; |
---|
4860 | | - |
---|
4861 | | - if (trimmed) |
---|
4862 | | - { |
---|
4863 | | - float[] colors = new float[positions.length / 3]; |
---|
4864 | | - |
---|
4865 | | - int i3 = 0; |
---|
4866 | | - for (int i = 0; i < positions.length / 3; i++, i3 += 3) |
---|
4867 | | - { |
---|
4868 | | - if (normals[i3] == 0 && normals[i3+1] == 0 && normals[i3+2] == 0) |
---|
4869 | | - continue; |
---|
4870 | | - |
---|
4871 | | - from.set(positions[i3], positions[i3 + 1], positions[i3 + 2]); |
---|
4872 | | - to.set(positions[i3] + normals[i3], |
---|
4873 | | - positions[i3 + 1] + normals[i3 + 1], |
---|
4874 | | - positions[i3 + 2] + normals[i3 + 2]); |
---|
4875 | | - LA.xformPos(from, transform, from); |
---|
4876 | | - LA.xformPos(to, transform, to); // RIGID ONLY |
---|
4877 | | - localcamera.setAim(from, to); |
---|
4878 | | - |
---|
4879 | | - CameraPane.occlusionbuffer.display(); |
---|
4880 | | - |
---|
4881 | | - if (CameraPane.DEBUG_OCCLUSION) |
---|
4882 | | - cp.display(); // debug |
---|
4883 | | - |
---|
4884 | | - colors[i] = cp.vertexOcclusion.r; |
---|
4885 | | - //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
4886 | | - //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
4887 | | - |
---|
4888 | | - if ((i % 1000) == 0 && i != 0) |
---|
4889 | | - { |
---|
4890 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
4891 | | - //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
4892 | | - System.out.println((int) (100.0 * i / (positions.length / 3)) + "% (" + i + " of " + (positions.length / 3) + ")"); |
---|
4893 | | - } |
---|
4894 | | - } |
---|
4895 | | - |
---|
4896 | | - this.colors = colors; |
---|
4897 | | - } |
---|
4898 | | - else |
---|
4899 | | - { |
---|
4900 | | - for (int i = 0; i < VertexCount(); i++) |
---|
4901 | | - { |
---|
4902 | | - Vertex v = GetVertex(i); |
---|
4903 | | - |
---|
4904 | | - if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
4905 | | - continue; |
---|
4906 | | - |
---|
4907 | | - from.set(v.x, v.y, v.z); |
---|
4908 | | - to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
4909 | | - LA.xformPos(from, transform, from); |
---|
4910 | | - LA.xformPos(to, transform, to); // RIGID ONLY |
---|
4911 | | - localcamera.setAim(from, to); |
---|
4912 | | - |
---|
4913 | | - CameraPane.occlusionbuffer.display(); |
---|
4914 | | - |
---|
4915 | | - if (CameraPane.DEBUG_OCCLUSION) |
---|
4916 | | - cp.display(); // debug |
---|
4917 | | - |
---|
4918 | | - v.AO = cp.vertexOcclusion.r; |
---|
4919 | | - |
---|
4920 | | - if ((i % 1000) == 0 && i != 0) |
---|
4921 | | - { |
---|
4922 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
4923 | | - //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
4924 | | - System.out.println((int) (100.0 * i / VertexCount()) + "% (" + i + " of " + VertexCount() + ")"); |
---|
4925 | | - } |
---|
4926 | | - } |
---|
4927 | | - } |
---|
4928 | | - |
---|
4929 | | - System.out.println("done."); |
---|
4930 | | - |
---|
4931 | | - cp.renderCamera = keep; |
---|
| 5049 | + cp.PrepOcclusion(this, transform); |
---|
4932 | 5050 | |
---|
4933 | 5051 | AOdone = true; |
---|
4934 | 5052 | } |
---|
.. | .. |
---|
7075 | 7193 | assert(f2.contains(i)); |
---|
7076 | 7194 | assert(f3.contains(i)); |
---|
7077 | 7195 | |
---|
| 7196 | + // when r is the "center", p is along the boundary |
---|
7078 | 7197 | while (f0.r != i) |
---|
7079 | 7198 | { |
---|
7080 | 7199 | int t = f0.p; |
---|
.. | .. |
---|
7131 | 7250 | f0 = f3; |
---|
7132 | 7251 | f3 = t; |
---|
7133 | 7252 | } |
---|
7134 | | - atleastone = true; |
---|
7135 | 7253 | |
---|
| 7254 | + int va = f0.q; |
---|
| 7255 | + int vb = f0.r; |
---|
| 7256 | + int vc = -1; |
---|
| 7257 | + |
---|
| 7258 | + Face toremove1 = null; |
---|
| 7259 | + Face toremove2 = null; |
---|
| 7260 | + |
---|
| 7261 | + // f0 is the buffer for the first new triangle, |
---|
| 7262 | + // and otherf is the other upper one. |
---|
7136 | 7263 | Face otherf = null; |
---|
7137 | 7264 | |
---|
7138 | 7265 | if (f1.contains(f0.p)) |
---|
7139 | 7266 | { |
---|
7140 | 7267 | if (f1.p == f0.p) |
---|
7141 | 7268 | { |
---|
| 7269 | + assert(false); |
---|
7142 | 7270 | f0.r = f1.q; |
---|
7143 | 7271 | } |
---|
7144 | 7272 | else |
---|
7145 | 7273 | { |
---|
7146 | 7274 | assert(f1.q == f0.p); |
---|
7147 | | - f0.r = f1.p; |
---|
| 7275 | + vc = f1.p; |
---|
7148 | 7276 | } |
---|
7149 | 7277 | |
---|
7150 | 7278 | otherf = f2; |
---|
7151 | | - faces.remove(f1); |
---|
7152 | | - faces.remove(f3); |
---|
| 7279 | + toremove1 = f1; |
---|
| 7280 | + toremove2 = f3; |
---|
7153 | 7281 | } |
---|
7154 | 7282 | else |
---|
7155 | 7283 | if (f2.contains(f0.p)) |
---|
7156 | 7284 | { |
---|
7157 | 7285 | if (f2.p == f0.p) |
---|
7158 | 7286 | { |
---|
| 7287 | + assert(false); |
---|
7159 | 7288 | f0.r = f2.q; |
---|
7160 | 7289 | } |
---|
7161 | 7290 | else |
---|
7162 | 7291 | { |
---|
7163 | 7292 | assert(f2.q == f0.p); |
---|
7164 | | - f0.r = f2.p; |
---|
| 7293 | + vc = f2.p; |
---|
7165 | 7294 | } |
---|
7166 | 7295 | |
---|
7167 | 7296 | otherf = f3; |
---|
7168 | | - faces.remove(f1); |
---|
7169 | | - faces.remove(f2); |
---|
| 7297 | + toremove1 = f1; |
---|
| 7298 | + toremove2 = f2; |
---|
7170 | 7299 | } |
---|
7171 | 7300 | if (f3.contains(f0.p)) |
---|
7172 | 7301 | { |
---|
7173 | 7302 | if (f3.p == f0.p) |
---|
7174 | 7303 | { |
---|
| 7304 | +// assert(false); |
---|
| 7305 | + new Exception().printStackTrace(); |
---|
7175 | 7306 | f0.r = f3.q; |
---|
7176 | 7307 | } |
---|
7177 | 7308 | else |
---|
7178 | 7309 | { |
---|
7179 | 7310 | assert(f3.q == f0.p); |
---|
7180 | | - f0.r = f3.p; |
---|
| 7311 | + vc = f3.p; |
---|
7181 | 7312 | } |
---|
7182 | 7313 | |
---|
7183 | 7314 | otherf = f1; |
---|
7184 | | - faces.remove(f2); |
---|
7185 | | - faces.remove(f3); |
---|
| 7315 | + toremove1 = f2; |
---|
| 7316 | + toremove2 = f3; |
---|
7186 | 7317 | } |
---|
| 7318 | + |
---|
| 7319 | + vertextemp.set(vertices.get(va)); |
---|
| 7320 | + vertextemp.sub(vertices.get(vb)); |
---|
| 7321 | + vertextemp.normalize(); |
---|
| 7322 | + vertextemp2.set(vertices.get(vc)); |
---|
| 7323 | + vertextemp2.sub(vertices.get(vb)); |
---|
| 7324 | + vertextemp2.normalize(); |
---|
| 7325 | + |
---|
| 7326 | + if (vertextemp.dot(vertextemp2) > -0.95) |
---|
| 7327 | + { |
---|
| 7328 | + continue; |
---|
| 7329 | + } |
---|
| 7330 | + |
---|
| 7331 | + atleastone = true; |
---|
| 7332 | + |
---|
| 7333 | + f0.r = vc; |
---|
| 7334 | + |
---|
| 7335 | + faces.remove(toremove1); |
---|
| 7336 | + faces.remove(toremove2); |
---|
7187 | 7337 | |
---|
7188 | 7338 | if (!f0.contains(otherf.p)) |
---|
7189 | 7339 | { |
---|
.. | .. |
---|
7554 | 7704 | s3 = new cVector(); |
---|
7555 | 7705 | } |
---|
7556 | 7706 | |
---|
7557 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 7707 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
7558 | 7708 | |
---|
7559 | 7709 | try |
---|
7560 | 7710 | { |
---|
.. | .. |
---|
7649 | 7799 | { |
---|
7650 | 7800 | if (i++%100 == 0) |
---|
7651 | 7801 | { |
---|
7652 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 7802 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
7653 | 7803 | System.out.println("#faces = " + faces.size()); |
---|
7654 | 7804 | // if (i != 1) |
---|
7655 | 7805 | // break; |
---|
.. | .. |
---|
7693 | 7843 | //Trim(true,cJME.gennormals,true,false); // doesn't work |
---|
7694 | 7844 | Trim(true,false,false,false,false); |
---|
7695 | 7845 | |
---|
7696 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); |
---|
| 7846 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); |
---|
7697 | 7847 | } |
---|
7698 | 7848 | |
---|
7699 | 7849 | void UpdateIndices(Face face, Face minface) |
---|
.. | .. |
---|
8275 | 8425 | return "trim = " + trimmed + "; stripped = " + stripified + "; colors = " + colors + "; faces = " + (faces!=null?faces.size():null) + "; triangles = " + (triangles!=null?triangles.length:null) + "; indices = " + indices; |
---|
8276 | 8426 | } |
---|
8277 | 8427 | |
---|
8278 | | - static Camera localcamera = new Camera(); |
---|
8279 | | - static cVector from = new cVector(); |
---|
8280 | | - static cVector to = new cVector(); |
---|
8281 | 8428 | boolean trimmed = false; |
---|
8282 | 8429 | boolean stripified = false; |
---|
8283 | 8430 | transient boolean AOdone = false; |
---|
.. | .. |
---|
8285 | 8432 | /*transient*/ int maxIndexV = 0; |
---|
8286 | 8433 | /*transient*/ int bufV, bufF; |
---|
8287 | 8434 | // Raw version |
---|
8288 | | - private float[] positions; |
---|
8289 | | - private float[] normals; |
---|
| 8435 | + //private |
---|
| 8436 | + float[] positions; |
---|
| 8437 | + //private |
---|
| 8438 | + float[] normals; |
---|
8290 | 8439 | float[] colors; |
---|
8291 | 8440 | private float[] uvmap; |
---|
8292 | 8441 | private int[] triangles; |
---|