Normand Briere
2018-12-15 6ed65dcb597fb2153cef75bf1845978f1115658c
Repair shadow, normal push + attractor mesh.
13 files modified
680 ■■■■■ changed files
BiparamEditor.java 4 ●●●● patch | view | raw | blame | history
BoundaryRep.java 2 ●●● patch | view | raw | blame | history
CameraPane.java 92 ●●●●● patch | view | raw | blame | history
FileObject.java 11 ●●●●● patch | view | raw | blame | history
GroupEditor.java 17 ●●●●● patch | view | raw | blame | history
Mocap.java 156 ●●●●● patch | view | raw | blame | history
NumberSlider.java 1 ●●●● patch | view | raw | blame | history
ObjEditor.java 40 ●●●● patch | view | raw | blame | history
Object3D.java 106 ●●●● patch | view | raw | blame | history
ScriptNode.java 8 ●●●● patch | view | raw | blame | history
Texture.java 2 ●●● patch | view | raw | blame | history
cSpring.java 231 ●●●●● patch | view | raw | blame | history
cSpringEditor.java 10 ●●●● patch | view | raw | blame | history
BiparamEditor.java
....@@ -68,7 +68,7 @@
6868
6969 uDivsField = AddSlider(oe.ctrlPanel, "U #", biparam.minUDivs, 250+biparam.minUDivs, biparam.uDivs);
7070 Return();
71
- vDivsField = AddSlider(oe.ctrlPanel, "V #", biparam.minVDivs, (int)(250/6.28)+biparam.minVDivs, biparam.vDivs);
71
+ vDivsField = AddSlider(oe.ctrlPanel, "V #", biparam.minVDivs, (int)(500/3.14)+biparam.minVDivs, biparam.vDivs);
7272 Return();
7373 // oe.aConstraints.gridwidth = 1;
7474 // oe.aConstraints.fill = GridBagConstraints.VERTICAL;
....@@ -205,7 +205,7 @@
205205 public void applySelf()
206206 {
207207 //System.out.println("Biparam :: applySelf");
208
- //super.applySelf();
208
+ super.applySelf();
209209 int udivs = uDivsField.getInteger(); // biparam.minUDivs, 99);
210210 int vdivs = vDivsField.getInteger(); // biparam.minUDivs, 99);
211211 //biparam.name = nameField.getText();
BoundaryRep.java
....@@ -4948,7 +4948,7 @@
49484948 {
49494949 Vertex v = GetVertex(i);
49504950
4951
- if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
4951
+ if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
49524952 continue;
49534953
49544954 from.set(v.x, v.y, v.z);
CameraPane.java
....@@ -7444,6 +7444,8 @@
74447444 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
74457445 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
74467446 double scale = lightCamera.SCALE / lightCamera.Distance();
7447
+// PATCH FILLE AUX JEANS
7448
+ //scale *= lightCamera.shaper_fovy / 25;
74477449 gl.glScaled(2 * scale, 2 * scale, -scale);
74487450 gl.glTranslated(0, 0, lightCamera.DECAL);
74497451
....@@ -9092,6 +9094,8 @@
90929094 //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100);
90939095 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
90949096 double scale = lightCamera.SCALE / lightCamera.Distance();
9097
+// PATCH FILLE AUX JEANS
9098
+ //scale *= lightCamera.shaper_fovy / 25;
90959099 gl.glScaled(2 * scale, 2 * scale, -scale);
90969100 gl.glTranslated(0, 0, lightCamera.DECAL);
90979101
....@@ -9231,6 +9235,8 @@
92319235 {
92329236 //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar);
92339237 double scale = lightCamera.SCALE / lightCamera.Distance();
9238
+// PATCH FILLE AUX JEANS
9239
+ //scale *= lightCamera.shaper_fovy / 25;
92349240 gl.glScaled(2 * scale, 2 * scale, -scale);
92359241 gl.glTranslated(0, 0, lightCamera.DECAL);
92369242 //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE);
....@@ -9754,40 +9760,40 @@
97549760 selectedpoint.radius = radius;
97559761 selectedpoint.recalculate();
97569762 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.15f;
9763
+ selectedpoint.material.color = 0.15f; // Yellow
97589764 selectedpoint.material.modulation = 0.75f;
97599765
9760
- debugpoint.radius = radius;
9761
- debugpoint.recalculate();
9762
- debugpoint.material = new cMaterial();
9763
- debugpoint.material.color = 0.25f;
9764
- debugpoint.material.modulation = 0.75f;
9766
+ debugpointG.radius = radius;
9767
+ debugpointG.recalculate();
9768
+ debugpointG.material = new cMaterial();
9769
+ debugpointG.material.color = 0.25f; // Green
9770
+ debugpointG.material.modulation = 0.75f;
97659771
9766
- debugpoint2.radius = radius;
9767
- debugpoint2.recalculate();
9768
- debugpoint2.material = new cMaterial();
9769
- debugpoint2.material.color = 0.75f;
9770
- debugpoint2.material.modulation = 0.75f;
9772
+ debugpointP.radius = radius;
9773
+ debugpointP.recalculate();
9774
+ debugpointP.material = new cMaterial();
9775
+ debugpointP.material.color = 0.75f; // Purple
9776
+ debugpointP.material.modulation = 0.75f;
97719777
9772
- debugpoint3.radius = radius;
9773
- debugpoint3.recalculate();
9774
- debugpoint3.material = new cMaterial();
9775
- debugpoint3.material.color = 0.5f;
9776
- debugpoint3.material.modulation = 0.75f;
9778
+ debugpointC.radius = radius;
9779
+ debugpointC.recalculate();
9780
+ debugpointC.material = new cMaterial();
9781
+ debugpointC.material.color = 0.5f; // Cyan
9782
+ debugpointC.material.modulation = 0.75f;
97779783
9778
- debugpoint4.radius = radius;
9779
- debugpoint4.recalculate();
9780
- debugpoint4.material = new cMaterial();
9781
- debugpoint4.material.color = 0f;
9782
- debugpoint4.material.modulation = 0.75f;
9784
+ debugpointR.radius = radius;
9785
+ debugpointR.recalculate();
9786
+ debugpointR.material = new cMaterial();
9787
+ debugpointR.material.color = 0f; // Red
9788
+ debugpointR.material.modulation = 0.75f;
97839789
97849790 InitPoints(radius);
97859791 }
97869792 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9787
- debugpoint.draw(this, /*(Composite)*/ null, false,false);
9788
- debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9789
- debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9790
- debugpoint4.draw(this, /*(Composite)*/ null, false,false);
9793
+ debugpointG.draw(this, /*(Composite)*/ null, false,false);
9794
+ debugpointP.draw(this, /*(Composite)*/ null, false,false);
9795
+ debugpointC.draw(this, /*(Composite)*/ null, false,false);
9796
+ debugpointR.draw(this, /*(Composite)*/ null, false,false);
97919797 // DrawPoints(this);
97929798 }
97939799
....@@ -9825,12 +9831,14 @@
98259831
98269832 if (checker != null && drawMode == DEFAULT)
98279833 {
9828
- // BindTexture(IMMORTAL_TEXTURE);
9834
+ //BindTexture(IMMORTAL_TEXTURE);
9835
+ BindTextures(checker.GetTextures(), checker.texres);
98299836 // NEAREST
98309837 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
98319838 DrawChecker(gl);
98329839 //checker.Draw(this, null, false);
98339840 // ReleaseTexture(IMMORTAL_TEXTURE);
9841
+ ReleaseTextures(checker.GetTextures());
98349842 }
98359843
98369844 if (object.parent != null)
....@@ -10388,6 +10396,7 @@
1038810396 "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" +
1038910397 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
1039010398 "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" +
10399
+ "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" +
1039110400 "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" +
1039210401 "PARAM c256 = { 256, 256, 256, 1.0 };" +
1039310402 "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" +
....@@ -11302,6 +11311,7 @@
1130211311 String Shadow(String depth, String shadow)
1130311312 {
1130411313 return "MAX temp.x, ndotl.x, one64th.x;" +
11314
+ "MIN temp.x, temp.x, ninetenth.x;" +
1130511315 /**/
1130611316 // Sine
1130711317 "MUL temp.y, temp.x, temp.x;" +
....@@ -14438,7 +14448,7 @@
1443814448 gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
1443914449 gl.glPushMatrix();
1444014450 gl.glLoadIdentity();
14441
- PushMatrix(checker.toParent);
14451
+ //PushMatrix(checker.toParent);
1444214452
1444314453 gl.glMatrixMode(GL.GL_TEXTURE);
1444414454 gl.glPushMatrix();
....@@ -14461,8 +14471,8 @@
1446114471
1446214472 gl.glNormal3f(0.0f, 0.0f, 1.0f);
1446314473
14464
- float step = 0.1666f; //0.25f;
14465
- float stepv = step * 1652 / 998;
14474
+ float step = 2; // 0.1666f; //0.25f;
14475
+ float stepv = 2; // step * 1652 / 998;
1446614476
1446714477 int i0 = 0;
1446814478 /*
....@@ -14532,15 +14542,27 @@
1453214542
1453314543 //float u = (i+1)/2;
1453414544 //float v = (j+1)/2;
14535
- gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
14545
+ if (checker.flipV)
14546
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2);
14547
+ else
14548
+ gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2);
1453614549 gl.glVertex3f(i, j, -0.5f);
1453714550
14551
+ if (checker.flipV)
14552
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
14553
+ else
1453814554 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2);
1453914555 gl.glVertex3f(i + step, j, -0.5f);
1454014556
14557
+ if (checker.flipV)
14558
+ gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
14559
+ else
1454114560 gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2);
1454214561 gl.glVertex3f(i + step, j + stepv, -0.5f);
1454314562
14563
+ if (checker.flipV)
14564
+ gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
14565
+ else
1454414566 gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2);
1454514567 gl.glVertex3f(i, j + stepv, -0.5f);
1454614568 }
....@@ -14552,7 +14574,7 @@
1455214574 gl.glMatrixMode(GL.GL_PROJECTION);
1455314575 gl.glPopMatrix();
1455414576 gl.glMatrixMode(GL.GL_MODELVIEW);
14555
- PopMatrix(null); // checker.toParent); // null);
14577
+ //PopMatrix(null); // checker.toParent); // null);
1455614578 gl.glPopMatrix();
1455714579 PopTextureMatrix(checker.toParent);
1455814580 gl.glMatrixMode(GL.GL_TEXTURE);
....@@ -15370,10 +15392,10 @@
1537015392 //double[] selectedpoint = new double[3];
1537115393 static Superellipsoid selectedpoint = new Superellipsoid();
1537215394 static Sphere previousselectedpoint = null;
15373
- static Sphere debugpoint = new Sphere();
15374
- static Sphere debugpoint2 = new Sphere();
15375
- static Sphere debugpoint3 = new Sphere();
15376
- static Sphere debugpoint4 = new Sphere();
15395
+ static Sphere debugpointG = new Sphere();
15396
+ static Sphere debugpointP = new Sphere();
15397
+ static Sphere debugpointC = new Sphere();
15398
+ static Sphere debugpointR = new Sphere();
1537715399
1537815400 static Sphere debugpoints[] = new Sphere[8];
1537915401
FileObject.java
....@@ -22,10 +22,10 @@
2222 return false; // ???? false;
2323 }
2424
25
- void Reset()
26
- {
27
- // filecontent = null;
28
- }
25
+// void Reset()
26
+// {
27
+// // filecontent = null;
28
+// }
2929
3030 void ClearUI()
3131 {
....@@ -54,9 +54,12 @@
5454 else
5555 {
5656 filecontent = ObjEditor.ReadGFD/*z*/(name);
57
+ if (filecontent != null)
58
+ {
5759 filecontent.parent = null;
5860 filecontent.fileparent = this;
5961 filecontent.RepairTexture();
62
+ }
6063 // stripify on load instead?
6164 // OK...
6265 // filecontent.Stripify(); // fine. faster and read-only anyway
GroupEditor.java
....@@ -1120,6 +1120,8 @@
11201120 resetParentItem.addActionListener(this);
11211121 repairParentItem = menu.add(new MenuItem("Repair Parent"));
11221122 repairParentItem.addActionListener(this);
1123
+ repairShadowItem = menu.add(new MenuItem("Repair Shadow"));
1124
+ repairShadowItem.addActionListener(this);
11231125 menu.add(invariantsItem = new MenuItem("Invariants"));
11241126 invariantsItem.addActionListener(this);
11251127 menu.add(recompileItem = new MenuItem("Recompile"));
....@@ -2537,6 +2539,20 @@
25372539 {
25382540 Object3D obj = (Object3D)e.nextElement();
25392541 obj.RepairParent();
2542
+// for (int i=0; i<obj.size(); i++)
2543
+// {
2544
+// obj.get(i).parent = obj;
2545
+// }
2546
+ }
2547
+
2548
+ refreshContents();
2549
+ } else
2550
+ if (event.getSource() == repairShadowItem)
2551
+ {
2552
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
2553
+ {
2554
+ Object3D obj = (Object3D)e.nextElement();
2555
+ obj.RepairShadow();
25402556 // for (int i=0; i<obj.size(); i++)
25412557 // {
25422558 // obj.get(i).parent = obj;
....@@ -5009,6 +5025,7 @@
50095025
50105026 private MenuItem resetParentItem;
50115027 private MenuItem repairParentItem;
5028
+ private MenuItem repairShadowItem;
50125029 private MenuItem sortbysizeItem;
50135030 private MenuItem sortbynameItem;
50145031
Mocap.java
....@@ -261,9 +261,9 @@
261261
262262 // LA.matConcat(toParent, hip.get(0).toParent, toParent);
263263
264
- CameraPane.debugpoint.toParent[3][0] = poship.x;
265
- CameraPane.debugpoint.toParent[3][1] = poship.y;
266
- CameraPane.debugpoint.toParent[3][2] = poship.z;
264
+ CameraPane.debugpointG.toParent[3][0] = poship.x;
265
+ CameraPane.debugpointG.toParent[3][1] = poship.y;
266
+ CameraPane.debugpointG.toParent[3][2] = poship.z;
267267
268268 LA.matInvert(toParent, fromParent);
269269
....@@ -324,21 +324,21 @@
324324 // LA.matYRotate(toParent, angleY - angleYhip);
325325 // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z);
326326
327
- CameraPane.debugpoint2.toParent[3][0] = pos.x;
328
- CameraPane.debugpoint2.toParent[3][1] = pos.y;
329
- CameraPane.debugpoint2.toParent[3][2] = pos.z;
327
+ CameraPane.debugpointP.toParent[3][0] = pos.x;
328
+ CameraPane.debugpointP.toParent[3][1] = pos.y;
329
+ CameraPane.debugpointP.toParent[3][2] = pos.z;
330330
331
- CameraPane.debugpoint3.toParent[3][0] = poship.x;
332
- CameraPane.debugpoint3.toParent[3][1] = poship.y;
333
- CameraPane.debugpoint3.toParent[3][2] = poship.z;
331
+ CameraPane.debugpointC.toParent[3][0] = poship.x;
332
+ CameraPane.debugpointC.toParent[3][1] = poship.y;
333
+ CameraPane.debugpointC.toParent[3][2] = poship.z;
334334
335335 poship.x = toParent[3][0];
336336 poship.y = toParent[3][1];
337337 poship.z = toParent[3][2];
338338
339
- CameraPane.debugpoint4.toParent[3][0] = poship.x;
340
- CameraPane.debugpoint4.toParent[3][1] = poship.y;
341
- CameraPane.debugpoint4.toParent[3][2] = poship.z;
339
+ CameraPane.debugpointR.toParent[3][0] = poship.x;
340
+ CameraPane.debugpointR.toParent[3][1] = poship.y;
341
+ CameraPane.debugpointR.toParent[3][2] = poship.z;
342342
343343 LA.matInvert(toParent, fromParent);
344344 }
....@@ -477,29 +477,45 @@
477477 }
478478 }
479479
480
+ static cVector centroid = new cVector();
481
+ static cVector mocaporigin = new cVector();
482
+
480483 void SetHipOrientation()
481484 {
482485 Object3D hip = get(0);
483486
484487 LA.matConcat(toParent, hip.get(0).toParent, matrix);
485488
486
- cVector centroid = new cVector();
489
+ mocaporigin.x = matrix[3][0];
490
+ mocaporigin.y = matrix[3][1];
491
+ mocaporigin.z = matrix[3][2];
492
+
487493 centroid.x = matrix[3][0];
488494 centroid.y = matrix[3][1];
489495 centroid.z = matrix[3][2];
490
- this.getCentroid(centroid, true);
496
+// this.getCentroid(centroid, true);
497
+
498
+ CameraPane.debugpointG.name = "";
499
+ CameraPane.debugpointG.toParent[3][0] = mocaporigin.x;
500
+ CameraPane.debugpointG.toParent[3][1] = mocaporigin.y;
501
+ CameraPane.debugpointG.toParent[3][2] = mocaporigin.z;
502
+
503
+ CameraPane.debugpointP.name = "";
504
+ CameraPane.debugpointP.toParent[3][0] = centroid.x;
505
+ CameraPane.debugpointP.toParent[3][1] = centroid.y;
506
+ CameraPane.debugpointP.toParent[3][2] = centroid.z;
491507
492508 cVector goal = GetGoal(centroid);
493509 if (goal != null)
494510 {
495
- System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")");
511
+ System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
496512
497
- goalx = goal.x;
498
- goalz = goal.z;
499
- targetx = targetz = 0;
513
+ goalposx = goal.x;
514
+ goalposz = goal.z;
515
+ targetdirx = targetdirz = 0;
500516 }
501517
502
- if (goalx == 0 && goalz == 0)
518
+ if (goalposx == 0 && goalposz == 0)
503519 {
504520 // No target
505521 if (ScriptNode.speaker != null)
....@@ -533,8 +549,8 @@
533549 //sourcenode.parent.TransformToLocal(dst);
534550 this.parent.TransformToLocal(dst);
535551
536
- goalx = dst.x;
537
- goalz = dst.z;
552
+ goalposx = dst.x;
553
+ goalposz = dst.z;
538554 }
539555 else
540556 return;
....@@ -550,17 +566,25 @@
550566
551567 double angleYhip = Math.atan2(-temp.z, temp.x);
552568
553
- double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z);
569
+ double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z);
554570
555571 LA.matIdentity(matrix);
556572 LA.matTranslate(matrix, -centroid.x, -centroid.y, -centroid.z);
557
- double angle = CurveAngle(0, angleYtarget - angleYhip, 1); // 0.1f);
573
+ double angle = CurveAngle(0, angleYtarget - angleYhip, 0.1f);
558574 LA.matYRotate(matrix, angle);
559575 LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z);
560576
561577 LA.matConcat(matrix, toParent, toParent);
562578
563579 LA.matInvert(toParent, fromParent);
580
+
581
+ LA.matConcat(toParent, hip.get(0).toParent, matrix);
582
+
583
+ centroid.x = matrix[3][0];
584
+ centroid.y = matrix[3][1];
585
+ centroid.z = matrix[3][2];
586
+
587
+ double dist = LA.distance(centroid, mocaporigin);
564588
565589 CheckForAction(centroid);
566590 }
....@@ -637,11 +661,11 @@
637661 double pinx;
638662 double pinz;
639663
640
- double targetx;
641
- double targetz;
664
+ double targetdirx;
665
+ double targetdirz;
642666
643
- double goalx = -20;
644
- double goalz = -10;
667
+ double goalposx = -20;
668
+ double goalposz = -10;
645669
646670 boolean followpath;
647671
....@@ -712,7 +736,7 @@
712736 scriptactions.clear();
713737 }
714738
715
- static double EPSACTION = 0.1; // 0.075; // 0.1;
739
+ static double EPSACTION = 0.1; // 0.075; // 0.1;Came
716740
717741 void AddFromTo(cVector from, cVector to)
718742 {
....@@ -1278,6 +1302,7 @@
12781302
12791303 void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid)
12801304 {
1305
+ assert(false);
12811306 //assert(CameraPane.drawMode == CameraPane.SHADOW);
12821307
12831308 Object3D transformnode = new Object3D();
....@@ -1481,9 +1506,9 @@
14811506 groundid = floorid;
14821507
14831508 // green
1484
- CameraPane.debugpoint.toParent[3][0] = groundx;
1485
- CameraPane.debugpoint.toParent[3][1] = floor.y;
1486
- CameraPane.debugpoint.toParent[3][2] = groundz;
1509
+ CameraPane.debugpointG.toParent[3][0] = groundx;
1510
+ CameraPane.debugpointG.toParent[3][1] = floor.y;
1511
+ CameraPane.debugpointG.toParent[3][2] = groundz;
14871512
14881513 if (true) // slow && stepout && onein)
14891514 {
....@@ -1560,9 +1585,9 @@
15601585
15611586 // System.out.println("Allo " + sourcenode);
15621587 // purple
1563
- CameraPane.debugpoint2.toParent[3][0] = floor.x;// + posx;
1564
- CameraPane.debugpoint2.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1];
1565
- CameraPane.debugpoint2.toParent[3][2] = floor.z;// + posz;
1588
+ CameraPane.debugpointP.toParent[3][0] = floor.x;// + posx;
1589
+ CameraPane.debugpointP.toParent[3][1] = ground; // floor.y;// + sourcenode.parent.toParent[3][1];
1590
+ CameraPane.debugpointP.toParent[3][2] = floor.z;// + posz;
15661591
15671592
15681593 if (false) // dist2 > 0.1)
....@@ -1628,9 +1653,9 @@
16281653 this.get(0).TransformToWorld(v0);
16291654
16301655 // cyan
1631
- CameraPane.debugpoint3.toParent[3][0] = v0.x;
1632
- CameraPane.debugpoint3.toParent[3][1] = ground;
1633
- CameraPane.debugpoint3.toParent[3][2] = v0.z;
1656
+ CameraPane.debugpointC.toParent[3][0] = v0.x;
1657
+ CameraPane.debugpointC.toParent[3][1] = ground;
1658
+ CameraPane.debugpointC.toParent[3][2] = v0.z;
16341659
16351660 LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent);
16361661 LA.matInvert(sourcenode.toParent, sourcenode.fromParent);
....@@ -1640,9 +1665,9 @@
16401665 this.get(0).TransformToWorld(v0);
16411666
16421667 // red
1643
- CameraPane.debugpoint4.toParent[3][0] = v0.x;
1644
- CameraPane.debugpoint4.toParent[3][1] = ground;
1645
- CameraPane.debugpoint4.toParent[3][2] = v0.z;
1668
+ CameraPane.debugpointR.toParent[3][0] = v0.x;
1669
+ CameraPane.debugpointR.toParent[3][1] = ground;
1670
+ CameraPane.debugpointR.toParent[3][2] = v0.z;
16461671 }
16471672 }
16481673
....@@ -1682,11 +1707,11 @@
16821707
16831708 if (goal != null)
16841709 {
1685
- System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")");
1710
+ System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")");
16861711 //sourcenode.parent.parent.Dump();
1687
- goalx = goal.x;
1688
- goalz = goal.z;
1689
- targetx = targetz = 0;
1712
+ goalposx = goal.x;
1713
+ goalposz = goal.z;
1714
+ targetdirx = targetdirz = 0;
16901715
16911716 followpath = true;
16921717 }
....@@ -1737,16 +1762,16 @@
17371762 // }
17381763 if (false) // !uselast)
17391764 {
1740
- CameraPane.debugpoint.toParent[3][0] = dst.x;
1741
- CameraPane.debugpoint.toParent[3][1] = dst.y;
1742
- CameraPane.debugpoint.toParent[3][2] = dst.z;
1765
+ CameraPane.debugpointG.toParent[3][0] = dst.x;
1766
+ CameraPane.debugpointG.toParent[3][1] = dst.y;
1767
+ CameraPane.debugpointG.toParent[3][2] = dst.z;
17431768 }
17441769 }
17451770
1746
- if (goalx != 0 || goalz != 0) // TODO
1771
+ if (goalposx != 0 || goalposz != 0) // TODO
17471772 {
17481773 // overwrite speaker orientation
1749
- dst.set(goalx,0,goalz);
1774
+ dst.set(goalposx,0,goalposz);
17501775 if (sourcenode.parent != null) // july 2014
17511776 sourcenode.parent.
17521777 TransformToLocal(dst);
....@@ -1798,26 +1823,26 @@
17981823 // mars 2014
17991824 if (false) // goalx != 0 || goalz != 0)
18001825 {
1801
- targetx = dst.x - src.x;
1802
- targetz = dst.z - src.z;
1826
+ targetdirx = dst.x - src.x;
1827
+ targetdirz = dst.z - src.z;
18031828
1804
- if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1)
1829
+ if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1)
18051830 {
18061831 // far enough from goal. keep the goal position.
1807
- targetx = 0;
1808
- targetz = 0;
1832
+ targetdirx = 0;
1833
+ targetdirz = 0;
18091834 }
18101835 else
18111836 {
18121837 // too close to goal. switch to target direction instead.
1813
- goalx = 0;
1814
- goalz = 0;
1838
+ goalposx = 0;
1839
+ goalposz = 0;
18151840 }
18161841 }
18171842
18181843 //sourcenode.getCentroid(src, true);
18191844
1820
- if (speakernode == sourcenode && goalx == 0 && goalz == 0)
1845
+ if (speakernode == sourcenode && goalposx == 0 && goalposz == 0)
18211846 {
18221847 if (ScriptNode.lastspeaker != null)
18231848 new Exception().printStackTrace();
....@@ -1826,13 +1851,13 @@
18261851
18271852 // LA.xformPos(src, fromParent, src);
18281853
1829
- if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalx != 0 || goalz != 0) && targetx == 0 && targetz == 0)
1854
+ if ((ScriptNode.speaker != null && CameraPane.SPEAKERMOCAP || goalposx != 0 || goalposz != 0) && targetdirx == 0 && targetdirz == 0)
18301855 dst.sub(src);
18311856 else
18321857 // vector mode
18331858 {
1834
- dst.x = targetx;
1835
- dst.z = targetz;
1859
+ dst.x = targetdirx;
1860
+ dst.z = targetdirz;
18361861
18371862 // TEST TARGET
18381863 // dst.x = CameraPane.selectedpoint.toParent[3][0];
....@@ -2280,9 +2305,16 @@
22802305 toVector.x = LA.cos(to);
22812306 toVector.y = LA.sin(to);
22822307
2308
+ double fromA = Math.atan2(fromVector.y, fromVector.x);
2309
+ double toA = Math.atan2(toVector.y, toVector.x);
2310
+
22832311 Vector2d currentVector = Slerp(fromVector, toVector, step);
22842312
2285
- return Math.atan2(currentVector.y, currentVector.x);
2313
+ double angle = Math.atan2(currentVector.y, currentVector.x);
2314
+
2315
+ double angle2 = (1-step) * fromA + step * toA;
2316
+
2317
+ return angle;
22862318 }
22872319
22882320 public static Vector2d Slerp(Vector2d from, Vector2d to, double step)
....@@ -3191,7 +3223,7 @@
31913223
31923224 // july 2014
31933225 // goalx = goalz = 0;
3194
- targetx = targetz = 0;
3226
+ targetdirx = targetdirz = 0;
31953227
31963228 //SetPositionDelta(true, true, true, false);
31973229 // LoadData();
NumberSlider.java
....@@ -102,6 +102,7 @@
102102
103103 if (pow <= 0)
104104 {
105
+ // Transition between min and max
105106 // value = (Math.pow(getValue()/1000.0, POW) * (max - min)) + min;
106107 // value - min = Math.pow(getValue()/1000.0, POW) * (max - min);
107108 // (value - min) / (max - min) = Math.pow(getValue()/1000.0, POW);
ObjEditor.java
....@@ -160,12 +160,16 @@
160160 objEditor.ctrlPanel.remove(slowerButton);
161161 objEditor.ctrlPanel.remove(fasterButton);
162162 objEditor.ctrlPanel.remove(remarkButton);
163
+
164
+ Remove(normalpushField);
163165 }
164166
165167 public ObjEditor GetEditor()
166168 {
167169 return objEditor; //.GetEditor();
168170 }
171
+
172
+ // Sometimes myself, sometimes my callee's.
169173 ObjEditor objEditor;
170174
171175 /*
....@@ -814,7 +818,7 @@
814818
815819 aConstraints.fill = GridBagConstraints.VERTICAL;
816820 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
817
- aConstraints.gridwidth = 2;
821
+ aConstraints.gridwidth = 1;
818822 ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
819823 aConstraints.gridx += 1;
820824 aConstraints.fill = GridBagConstraints.HORIZONTAL;
....@@ -983,6 +987,9 @@
983987
984988 Return();
985989
990
+ normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
991
+ Return();
992
+
986993 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
987994 // ObjEditor.aConstraints.gridx += 1;
988995
....@@ -1446,7 +1453,7 @@
14461453 aConstraints.gridx += 1;
14471454 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
14481455 //aConstraints.weightx = 0;
1449
- ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1456
+ ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14501457 aConstraints.gridx = 0;
14511458 aConstraints.gridy += 1;
14521459 aConstraints.gridwidth = 1;
....@@ -1456,7 +1463,7 @@
14561463 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14571464 aConstraints.gridx += 1;
14581465 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1459
- ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1466
+ ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14601467 aConstraints.gridx = 0;
14611468 aConstraints.gridy += 1;
14621469 aConstraints.gridwidth = 1;
....@@ -1466,7 +1473,7 @@
14661473 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14671474 aConstraints.gridx += 1;
14681475 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1469
- ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1476
+ ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14701477 aConstraints.gridx = 0;
14711478 aConstraints.gridy += 1;
14721479 aConstraints.gridwidth = 1;
....@@ -1476,7 +1483,7 @@
14761483 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14771484 aConstraints.gridx += 1;
14781485 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1479
- ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1486
+ ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14801487 aConstraints.gridx = 0;
14811488 aConstraints.gridy += 1;
14821489 aConstraints.gridwidth = 1;
....@@ -1486,7 +1493,7 @@
14861493 aConstraints.fill = GridBagConstraints.HORIZONTAL;
14871494 aConstraints.gridx += 1;
14881495 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1489
- ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1496
+ ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.5), aConstraints);
14901497 aConstraints.gridx = 0;
14911498 aConstraints.gridy += 1;
14921499 aConstraints.gridwidth = 1;
....@@ -1555,7 +1562,7 @@
15551562 aConstraints.fill = GridBagConstraints.HORIZONTAL;
15561563 aConstraints.gridx += 1;
15571564 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1558
- ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1565
+ ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.5), aConstraints);
15591566 aConstraints.gridx = 0;
15601567 aConstraints.gridy += 1;
15611568 aConstraints.gridwidth = 1;
....@@ -1624,7 +1631,7 @@
16241631 aConstraints.fill = GridBagConstraints.HORIZONTAL;
16251632 aConstraints.gridx += 1;
16261633 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1627
- ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1634
+ ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.5), aConstraints);
16281635 aConstraints.gridx = 0;
16291636 aConstraints.gridy += 1;
16301637 aConstraints.gridwidth = 1;
....@@ -1695,7 +1702,7 @@
16951702 aConstraints.fill = GridBagConstraints.HORIZONTAL;
16961703 aConstraints.gridx += 1;
16971704 aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1698
- ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1705
+ ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.5), aConstraints);
16991706 aConstraints.gridx = 0;
17001707 aConstraints.gridy += 1;
17011708 aConstraints.gridwidth = 1;
....@@ -3549,7 +3556,13 @@
35493556 //System.out.println("PARENT = " + parent);
35503557 //if (parent != null)
35513558 // parent.applySelf();
3552
- refreshContents();
3559
+ if (e.getSource() == normalpushField)
3560
+ {
3561
+ objEditor.refreshContents();
3562
+ //Refresh();
3563
+ }
3564
+ else
3565
+ refreshContents();
35533566 // ??? client.refreshEditWindow();
35543567 }
35553568 //else
....@@ -3561,7 +3574,7 @@
35613574 //group.name = nameField.getText();
35623575 //objEditor.applySelf();
35633576
3564
- assert (objEditor == this);
3577
+ // OCT2018: assert (objEditor == this);
35653578 if (copy.selection == null || copy.selection.size() == 0)
35663579 //super.applySelf()
35673580 ; else
....@@ -3585,6 +3598,9 @@
35853598 objEditor.copy = keep;
35863599 }
35873600 }
3601
+
3602
+ if (normalpushField != null)
3603
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
35883604 }
35893605
35903606 void SnapObject()
....@@ -4629,4 +4645,6 @@
46294645 NumberSlider opacityPowerField;
46304646 JTree jTree;
46314647 //ObjectUI parent;
4648
+
4649
+ NumberSlider normalpushField;
46324650 }
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++)
....@@ -295,6 +308,8 @@
295308 boolean random = false;
296309 boolean speedup = false;
297310 boolean rewind = false;
311
+
312
+ float NORMALPUSH = 0;
298313
299314 Object3D support;
300315
....@@ -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
....@@ -2130,15 +2148,8 @@
21302148 if (/*parent != null &&*/ material == null)
21312149 {
21322150 material = new cMaterial(GetMaterial());
2133
- if (projectedVertices == null || projectedVertices.length <= 2)
2134
- {
2135
- projectedVertices = new Object3D.cVector2[3];
2136
- }
2137
- for (int i = 0; i < 3; i++)
2138
- {
2139
- projectedVertices[i] = new cVector2(); // Others
2140
- }
2141
- projectedVertices[0].x = 100; // bump
2151
+
2152
+ InitOthers();
21422153
21432154 if (this instanceof Camera)
21442155 {
....@@ -4161,6 +4172,22 @@
41614172 }
41624173 }
41634174
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();
4187
+ blockloop = false;
4188
+ }
4189
+ }
4190
+
41644191 void RepairTexture()
41654192 {
41664193 if (this instanceof FileObject || blockloop)
....@@ -5958,7 +5985,7 @@
59585985
59595986 javax.media.opengl.GL gl = display.GetGL();
59605987
5961
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
5988
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59625989 {
59635990 int fc = bRep.FaceCount();
59645991 int vc = bRep.VertexCount();
....@@ -6699,13 +6726,26 @@
66996726 gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
67006727 }
67016728
6729
+ // P
6730
+ float x = (float)pv.x;
6731
+ float y = (float)pv.y;
6732
+ float z = (float)pv.z;
6733
+
67026734 if (hasnorm)
67036735 {
67046736 // if (!pv.norm.normalized())
67056737 // assert(pv.norm.normalized());
67066738
67076739 //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6708
- 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);
67096749 }
67106750 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
67116751 SetColor(display, pv);
....@@ -6716,13 +6756,28 @@
67166756 else
67176757 gl.glTexCoord2f((float) pv.s, (float) pv.t);
67186758 //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6719
- 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
+
67206767 // Print(pv);
67216768 if (hasnorm)
67226769 {
67236770 // assert(qv.norm.normalized());
67246771 //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6725
- 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);
67266781 }
67276782 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
67286783 // boolean locked = false;
....@@ -6746,16 +6801,31 @@
67466801 // }
67476802 gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
67486803 SetColor(display, qv);
6804
+
6805
+ gl.glVertex3f(x, y, z);
67496806 //gl.glColor4f(r, g, b, 1);
67506807 //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
67516808 //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6752
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
67536809 // Print(qv);
6810
+
6811
+ // R
6812
+ x = (float)rv.x;
6813
+ y = (float)rv.y;
6814
+ z = (float)rv.z;
6815
+
67546816 if (hasnorm)
67556817 {
67566818 // assert(rv.norm.normalized());
67576819 //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6758
- 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);
67596829 }
67606830
67616831 // if ((dot&4) == 0)
....@@ -6776,7 +6846,7 @@
67766846 //gl.glColor4f(r, g, b, 1);
67776847 //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
67786848 //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6779
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6849
+ gl.glVertex3f(x, y, z);
67806850 // Print(rv);
67816851 //gl.glEnd();
67826852 }
....@@ -8163,6 +8233,8 @@
81638233 {
81648234 Object3D targ = this;
81658235
8236
+ targ.NORMALPUSH = obj.NORMALPUSH;
8237
+
81668238 if (obj.material != null)
81678239 {
81688240 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))
ScriptNode.java
....@@ -972,25 +972,25 @@
972972
973973 if (command.equals("targetx"))
974974 {
975
- ((Mocap) object).targetx = Float.parseFloat(strs[index+2]);
975
+ ((Mocap) object).targetdirx = Float.parseFloat(strs[index+2]);
976976 return;
977977 }
978978
979979 if (command.equals("targetz"))
980980 {
981
- ((Mocap) object).targetz = Float.parseFloat(strs[index+2]);
981
+ ((Mocap) object).targetdirz = Float.parseFloat(strs[index+2]);
982982 return;
983983 }
984984
985985 if (command.equals("goalx"))
986986 {
987
- ((Mocap) object).goalx = Float.parseFloat(strs[index+2]);
987
+ ((Mocap) object).goalposx = Float.parseFloat(strs[index+2]);
988988 return;
989989 }
990990
991991 if (command.equals("goalz"))
992992 {
993
- ((Mocap) object).goalz = Float.parseFloat(strs[index+2]);
993
+ ((Mocap) object).goalposz = Float.parseFloat(strs[index+2]);
994994 return;
995995 }
996996
Texture.java
....@@ -10,7 +10,7 @@
1010 public class Texture extends Composite implements java.io.Serializable
1111 {
1212 // deprecated due to serial problems
13
- static final long serialVersionUID = // -5280151442948961597L; // new java
13
+ static final long serialVersionUID = //-5280151442948961597L; // new java
1414 7695543694999681408L; // old java !!!
1515
1616 // default = -8076744133104150348L
cSpring.java
....@@ -82,7 +82,7 @@
8282
8383 // timestep
8484 double timestep = 1;
85
- double normalpusH = 0; // 1;
85
+ double normalpush = 0; // 1;
8686 static float H0 = 1E1f; // aucune importance...
8787 // mass
8888 double M = 1;
....@@ -967,6 +967,7 @@
967967 for (int i = 0; i < allNodes.size(); i++)
968968 {
969969 DynamicNode dn = allNodes.get(i);
970
+ dn.linked = false;
970971 dn.closestpoint = null;
971972 }
972973 }
....@@ -1416,6 +1417,7 @@
14161417 //transient double rotangle; // Z of axis
14171418 transient boolean reverse = false;
14181419
1420
+ transient boolean linked = false;
14191421 transient Vertex closestpoint = null;
14201422
14211423 //Point3D lastForce = new Point3D();
....@@ -1491,6 +1493,11 @@
14911493 otherForce.add(f.forceOn(this));
14921494 }
14931495 }
1496
+ }
1497
+
1498
+ if (Double.isNaN(springForce.y))
1499
+ {
1500
+ springForce.x = springForce.y = springForce.z = 0;
14941501 }
14951502 }
14961503
....@@ -2339,28 +2346,7 @@
23392346 return this;
23402347 }
23412348
2342
- class Avoider extends Force
2343
- {
2344
- static final long serialVersionUID = -8657094699711594990L;
2345
-
2346
- Avoider()
2347
- {
2348
- }
2349
-
2350
- Avoider(Object3D col)
2351
- {
2352
- SetAvoider(col);
2353
- }
2354
-
2355
- void SetParameter(int index, double value)
2356
- {
2357
- parameters.setElementAt(new Double(value), index);
2358
- }
2359
-
2360
- void SetAvoider(Object3D col)
2361
- {
2362
- avoider = col;
2363
- }
2349
+ Object3D avoider;
23642350
23652351 void ResetGlobalTransform()
23662352 {
....@@ -2372,10 +2358,6 @@
23722358
23732359 transient double[][] toRoot; // = new double[4][4];
23742360
2375
- //Vector<Vertex> sortedcollider;
2376
- Object3D avoider;
2377
- Vector<Double> parameters = new Vector<Double>(); // serial issue
2378
-
23792361 Vertex ClosestPoint(Vector<Vertex> collider, DynamicNode N, int startindex, int endindex, int sortaxis)
23802362 {
23812363 if (startindex == endindex)
....@@ -2469,7 +2451,8 @@
24692451
24702452 for (int i=collider.size(); --i>=0;)
24712453 {
2472
- if (collider.get(i).norm.dot(((Vertex)N.position).norm) < 0)
2454
+ // Why? 3 dec 2018
2455
+ if (collider.get(i).norm.dot(((Vertex)N.position).norm) < 0.5)
24732456 continue;
24742457
24752458 temp.set(N.position);
....@@ -2487,43 +2470,24 @@
24872470 }
24882471 }
24892472
2490
- return cp;
2473
+ return mindist2 < 1 ? cp : null;
24912474 }
24922475
2493
- Point3D forceOn(DynamicNode N)
2476
+ class Avoider extends Force
2477
+ {
2478
+ static final long serialVersionUID = -8657094699711594990L;
2479
+
2480
+ Avoider()
24942481 {
2495
- force.x = 0;
2496
- force.y = 0;
2497
- force.z = 0;
2498
-
2499
- if (avoider.transientrep == null)
2500
- avoider.Revert();
2501
-
2502
- if (avoider.transientrep == null || avoider.transientrep.VertexCount() == 0 || avoider.transientrep.trimmed)
2503
- return force;
2504
-
2505
- ResetGlobalTransform();
2506
- if (N.closestpoint == null)
2507
- {
2508
- //avoider.bRep.GetVertex(0); // "sort"
2509
-
2510
- ResetGlobalTransform();
2511
-
2512
- N.closestpoint = ClosestPoint(avoider.transientrep./*sortedV*/vertices, N, 0,avoider.transientrep./*sortedV*/vertices.size(), 0);
2513
-
2514
- if (N.closestpoint == null) // ????
2515
- return force;
2516
- }
2517
-
2518
- if (avoider == This())
2519
- {
2520
- // good but must freeze the order first... not really...
2521
- // if (cp.index < ((Vertex)N.position).index)
2522
- // return force;
2523
- }
2524
-
2525
- if (normalpusH != 0) // && cp == null /*???*/) // speed == 0)
2526
- {
2482
+ }
2483
+
2484
+ Avoider(Object3D col)
2485
+ {
2486
+ SetAvoider(col);
2487
+ }
2488
+
2489
+ void Avoidance(DynamicNode N)
2490
+ {
25272491 temp.set(N.position);
25282492 if (avoider != This())
25292493 {
....@@ -2531,16 +2495,16 @@
25312495 temp2.mul(0.001);
25322496 temp.sub(temp2); // push outside because of mesh artifacts
25332497 }
2534
-
2498
+
25352499 vect1.set(N.closestpoint);
2536
-
2500
+
25372501 LA.xformPos(vect1,toRoot,vect1);
25382502 //avoider.TransformToWorld(vect1, vect1);
2539
-
2503
+
25402504 temp.sub(vect1);
2541
-
2505
+
25422506 double distance = Math.sqrt(temp.length2());
2543
-
2507
+
25442508 if (distance < 0.01)
25452509 {
25462510 temp2.set(N.closestpoint.norm);
....@@ -2554,9 +2518,98 @@
25542518 if (IsAutoFreeze())
25552519 dot = -dot;
25562520
2557
- temp.mul(normalpusH/*/distance*/*-dot/Math.sqrt(distance));
2521
+ temp.mul(normalpush/*/distance*/*-dot/Math.sqrt(distance));
25582522 force.add(temp);
25592523 }
2524
+ }
2525
+
2526
+ void Attraction(DynamicNode N)
2527
+ {
2528
+ temp.set(N.position);
2529
+ if (avoider != This())
2530
+ {
2531
+ temp2.set(N.closestpoint.norm);
2532
+ temp2.mul(0.001);
2533
+ temp.sub(temp2); // push outside because of mesh artifacts
2534
+ }
2535
+
2536
+ vect1.set(N.closestpoint);
2537
+
2538
+ LA.xformPos(vect1,toRoot,vect1);
2539
+ //avoider.TransformToWorld(vect1, vect1);
2540
+
2541
+ temp.sub(vect1);
2542
+
2543
+ double distance = Math.sqrt(temp.length2());
2544
+
2545
+ //if (distance < 0.01)
2546
+ {
2547
+ temp2.set(N.closestpoint.norm);
2548
+ double dot = temp2.dot(temp);
2549
+
2550
+// if (dot > 0)
2551
+// dot = 0;
2552
+
2553
+ // normal pushing
2554
+ temp.set(N.closestpoint.norm);
2555
+// if (IsAutoFreeze())
2556
+// dot = -dot;
2557
+
2558
+ temp.mul(normalpush/*/distance*/ * -dot * distance);
2559
+ force.add(temp);
2560
+ }
2561
+ }
2562
+
2563
+ void SetParameter(int index, double value)
2564
+ {
2565
+ parameters.setElementAt(new Double(value), index);
2566
+ }
2567
+
2568
+ void SetAvoider(Object3D col)
2569
+ {
2570
+ avoider = col;
2571
+ }
2572
+
2573
+ //Vector<Vertex> sortedcollider;
2574
+ Vector<Double> parameters = new Vector<Double>(); // serial issue
2575
+
2576
+ Point3D forceOn(DynamicNode N)
2577
+ {
2578
+ force.x = 0;
2579
+ force.y = 0;
2580
+ force.z = 0;
2581
+
2582
+ if (avoider.transientrep == null)
2583
+ avoider.Revert();
2584
+
2585
+ if (avoider.transientrep == null || avoider.transientrep.VertexCount() == 0 || avoider.transientrep.trimmed)
2586
+ return force;
2587
+
2588
+ ResetGlobalTransform();
2589
+ if (!N.linked)
2590
+ {
2591
+ //avoider.bRep.GetVertex(0); // "sort"
2592
+
2593
+ ResetGlobalTransform();
2594
+
2595
+ N.closestpoint = ClosestPoint(avoider.transientrep.vertices, N, 0,avoider.transientrep.vertices.size(), 0);
2596
+ N.linked = true;
2597
+ }
2598
+
2599
+ if (avoider == This())
2600
+ {
2601
+ // good but must freeze the order first... not really...
2602
+ // if (cp.index < ((Vertex)N.position).index)
2603
+ // return force;
2604
+ }
2605
+
2606
+ if (normalpush != 0) // && cp == null /*???*/) // speed == 0)
2607
+ {
2608
+ if (N.closestpoint == null)
2609
+ return force;
2610
+
2611
+ //Avoidance(N);
2612
+ Attraction(N);
25602613 }
25612614
25622615 if (parameters.size() > 0)
....@@ -2590,6 +2643,7 @@
25902643 totalforce = new Point3D();
25912644
25922645 totalforce.set(0,0,0);
2646
+
25932647 if (forces.size() == 0)
25942648 totalforce.set(super.forceOn(N));
25952649
....@@ -2660,7 +2714,7 @@
26602714 force.y = 0;
26612715 force.z = 0;
26622716
2663
- if (normalpusH != 0) // speed == 0) // Now normal force
2717
+ if (normalpush != 0) // speed == 0) // Now normal force
26642718 {
26652719 // temp.set(N.position);
26662720 // temp.sub(Phys.reference);
....@@ -2668,7 +2722,7 @@
26682722
26692723 // normal pushing
26702724 temp.set(N.normal);
2671
- temp.mul(normalpusH/distance);
2725
+ temp.mul(normalpush/distance);
26722726 force.add(temp);
26732727 }
26742728
....@@ -2900,6 +2954,7 @@
29002954 return force;
29012955 }
29022956 }
2957
+
29032958 static int TABLESAC = 1024;
29042959 static double[] tablesac = new double[TABLESAC];
29052960
....@@ -2993,6 +3048,40 @@
29933048 // mass = M;
29943049 } // ???
29953050
3051
+ if (avoider != null)
3052
+ {
3053
+ if (avoider.transientrep == null)
3054
+ avoider.Revert();
3055
+
3056
+ if (avoider.transientrep == null || avoider.transientrep.VertexCount() == 0 || avoider.transientrep.trimmed)
3057
+ return force;
3058
+
3059
+ ResetGlobalTransform();
3060
+ if (!N.linked)
3061
+ {
3062
+ //avoider.bRep.GetVertex(0); // "sort"
3063
+
3064
+ //ResetGlobalTransform();
3065
+
3066
+ N.closestpoint = ClosestPoint(avoider.transientrep.vertices, N, 0,avoider.transientrep.vertices.size(), 0);
3067
+ N.linked = true;
3068
+ }
3069
+
3070
+ if (N.closestpoint != null)
3071
+ {
3072
+ temp.set(N.position);
3073
+ vect1.set(N.closestpoint);
3074
+ LA.xformPos(vect1,toRoot,vect1);
3075
+ temp.sub(vect1);
3076
+
3077
+ temp2.set(N.closestpoint.norm);
3078
+ double dot = temp2.dot(temp);
3079
+
3080
+ if (dot < 0)
3081
+ mass = Float.NaN;
3082
+ }
3083
+ }
3084
+
29963085 force.x = 0;
29973086 force.y = (float) (-acceleration * mass);
29983087 force.z = 0; // -acceleration * mass * 1000 * Math.cos(time/234.0 + framecount*100); // (Math.random()*2 - 1); //
....@@ -3189,7 +3278,7 @@
31893278 }
31903279 if (false) // isHandle)
31913280 {
3192
- double K = Math.exp(-displacement*normalpusH);
3281
+ double K = Math.exp(-displacement*normalpush);
31933282 magnitude /= (displacement*(1-K) + K);
31943283 }
31953284
cSpringEditor.java
....@@ -133,7 +133,7 @@
133133 // ObjEditor.aConstraints.gridwidth = 1;
134134 // //ObjEditor.aConstraints.fill = 0;
135135 // ObjEditor.aConstraints.gridx -= 1;
136
- normalField = AddSlider(oe.ctrlPanel, "Normal:", 0, 20.0, Math.log(spring.normalpusH+1), 1);
136
+ normalField = AddSlider(oe.ctrlPanel, "Normal:", 0, 20.0, Math.log(spring.normalpush+1), 1);
137137 Return();
138138
139139 /**/
....@@ -472,7 +472,11 @@
472472
473473 spring.W.AddForce(spring.new Avoider(GetEditor().copy.selection.get(0)));
474474 }
475
-// else
475
+ else
476
+ {
477
+ if (spring.W instanceof cSpring.ActingForces)
478
+ ((cSpring.ActingForces)spring.W).forces.clear();
479
+ }
476480 /*
477481 if (spring.Phys == null) // || spring.IsAutoFreeze())
478482 spring.InitPhysics();
....@@ -564,7 +568,7 @@
564568 spring.K = k;
565569 spring.M = m;
566570 spring.G.acceleration = g;
567
- spring.normalpusH = d; // * Math.sqrt(m/k);
571
+ spring.normalpush = d; // * Math.sqrt(m/k);
568572 spring.limit = L;
569573 spring.restlengthFactor = t;
570574 spring.W.wind = v;