Repair shadow, normal push + attractor mesh.
| .. | .. |
|---|
| 68 | 68 | |
|---|
| 69 | 69 | uDivsField = AddSlider(oe.ctrlPanel, "U #", biparam.minUDivs, 250+biparam.minUDivs, biparam.uDivs); |
|---|
| 70 | 70 | 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); |
|---|
| 72 | 72 | Return(); |
|---|
| 73 | 73 | // oe.aConstraints.gridwidth = 1; |
|---|
| 74 | 74 | // oe.aConstraints.fill = GridBagConstraints.VERTICAL; |
|---|
| .. | .. |
|---|
| 205 | 205 | public void applySelf() |
|---|
| 206 | 206 | { |
|---|
| 207 | 207 | //System.out.println("Biparam :: applySelf"); |
|---|
| 208 | | - //super.applySelf(); |
|---|
| 208 | + super.applySelf(); |
|---|
| 209 | 209 | int udivs = uDivsField.getInteger(); // biparam.minUDivs, 99); |
|---|
| 210 | 210 | int vdivs = vDivsField.getInteger(); // biparam.minUDivs, 99); |
|---|
| 211 | 211 | //biparam.name = nameField.getText(); |
|---|
| .. | .. |
|---|
| 4948 | 4948 | { |
|---|
| 4949 | 4949 | Vertex v = GetVertex(i); |
|---|
| 4950 | 4950 | |
|---|
| 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) |
|---|
| 4952 | 4952 | continue; |
|---|
| 4953 | 4953 | |
|---|
| 4954 | 4954 | from.set(v.x, v.y, v.z); |
|---|
| .. | .. |
|---|
| 7444 | 7444 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
|---|
| 7445 | 7445 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
|---|
| 7446 | 7446 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
|---|
| 7447 | +// PATCH FILLE AUX JEANS |
|---|
| 7448 | + //scale *= lightCamera.shaper_fovy / 25; |
|---|
| 7447 | 7449 | gl.glScaled(2 * scale, 2 * scale, -scale); |
|---|
| 7448 | 7450 | gl.glTranslated(0, 0, lightCamera.DECAL); |
|---|
| 7449 | 7451 | |
|---|
| .. | .. |
|---|
| 9092 | 9094 | //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); |
|---|
| 9093 | 9095 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
|---|
| 9094 | 9096 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
|---|
| 9097 | +// PATCH FILLE AUX JEANS |
|---|
| 9098 | + //scale *= lightCamera.shaper_fovy / 25; |
|---|
| 9095 | 9099 | gl.glScaled(2 * scale, 2 * scale, -scale); |
|---|
| 9096 | 9100 | gl.glTranslated(0, 0, lightCamera.DECAL); |
|---|
| 9097 | 9101 | |
|---|
| .. | .. |
|---|
| 9231 | 9235 | { |
|---|
| 9232 | 9236 | //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); |
|---|
| 9233 | 9237 | double scale = lightCamera.SCALE / lightCamera.Distance(); |
|---|
| 9238 | +// PATCH FILLE AUX JEANS |
|---|
| 9239 | + //scale *= lightCamera.shaper_fovy / 25; |
|---|
| 9234 | 9240 | gl.glScaled(2 * scale, 2 * scale, -scale); |
|---|
| 9235 | 9241 | gl.glTranslated(0, 0, lightCamera.DECAL); |
|---|
| 9236 | 9242 | //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); |
|---|
| .. | .. |
|---|
| 9754 | 9760 | selectedpoint.radius = radius; |
|---|
| 9755 | 9761 | selectedpoint.recalculate(); |
|---|
| 9756 | 9762 | selectedpoint.material = new cMaterial(); |
|---|
| 9757 | | - selectedpoint.material.color = 0.15f; |
|---|
| 9763 | + selectedpoint.material.color = 0.15f; // Yellow |
|---|
| 9758 | 9764 | selectedpoint.material.modulation = 0.75f; |
|---|
| 9759 | 9765 | |
|---|
| 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; |
|---|
| 9765 | 9771 | |
|---|
| 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; |
|---|
| 9771 | 9777 | |
|---|
| 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; |
|---|
| 9777 | 9783 | |
|---|
| 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; |
|---|
| 9783 | 9789 | |
|---|
| 9784 | 9790 | InitPoints(radius); |
|---|
| 9785 | 9791 | } |
|---|
| 9786 | 9792 | 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); |
|---|
| 9791 | 9797 | // DrawPoints(this); |
|---|
| 9792 | 9798 | } |
|---|
| 9793 | 9799 | |
|---|
| .. | .. |
|---|
| 9825 | 9831 | |
|---|
| 9826 | 9832 | if (checker != null && drawMode == DEFAULT) |
|---|
| 9827 | 9833 | { |
|---|
| 9828 | | - // BindTexture(IMMORTAL_TEXTURE); |
|---|
| 9834 | + //BindTexture(IMMORTAL_TEXTURE); |
|---|
| 9835 | + BindTextures(checker.GetTextures(), checker.texres); |
|---|
| 9829 | 9836 | // NEAREST |
|---|
| 9830 | 9837 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
|---|
| 9831 | 9838 | DrawChecker(gl); |
|---|
| 9832 | 9839 | //checker.Draw(this, null, false); |
|---|
| 9833 | 9840 | // ReleaseTexture(IMMORTAL_TEXTURE); |
|---|
| 9841 | + ReleaseTextures(checker.GetTextures()); |
|---|
| 9834 | 9842 | } |
|---|
| 9835 | 9843 | |
|---|
| 9836 | 9844 | if (object.parent != null) |
|---|
| .. | .. |
|---|
| 10388 | 10396 | "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + |
|---|
| 10389 | 10397 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
|---|
| 10390 | 10398 | "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + |
|---|
| 10399 | + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + |
|---|
| 10391 | 10400 | "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + |
|---|
| 10392 | 10401 | "PARAM c256 = { 256, 256, 256, 1.0 };" + |
|---|
| 10393 | 10402 | "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + |
|---|
| .. | .. |
|---|
| 11302 | 11311 | String Shadow(String depth, String shadow) |
|---|
| 11303 | 11312 | { |
|---|
| 11304 | 11313 | return "MAX temp.x, ndotl.x, one64th.x;" + |
|---|
| 11314 | + "MIN temp.x, temp.x, ninetenth.x;" + |
|---|
| 11305 | 11315 | /**/ |
|---|
| 11306 | 11316 | // Sine |
|---|
| 11307 | 11317 | "MUL temp.y, temp.x, temp.x;" + |
|---|
| .. | .. |
|---|
| 14438 | 14448 | gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); |
|---|
| 14439 | 14449 | gl.glPushMatrix(); |
|---|
| 14440 | 14450 | gl.glLoadIdentity(); |
|---|
| 14441 | | - PushMatrix(checker.toParent); |
|---|
| 14451 | + //PushMatrix(checker.toParent); |
|---|
| 14442 | 14452 | |
|---|
| 14443 | 14453 | gl.glMatrixMode(GL.GL_TEXTURE); |
|---|
| 14444 | 14454 | gl.glPushMatrix(); |
|---|
| .. | .. |
|---|
| 14461 | 14471 | |
|---|
| 14462 | 14472 | gl.glNormal3f(0.0f, 0.0f, 1.0f); |
|---|
| 14463 | 14473 | |
|---|
| 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; |
|---|
| 14466 | 14476 | |
|---|
| 14467 | 14477 | int i0 = 0; |
|---|
| 14468 | 14478 | /* |
|---|
| .. | .. |
|---|
| 14532 | 14542 | |
|---|
| 14533 | 14543 | //float u = (i+1)/2; |
|---|
| 14534 | 14544 | //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); |
|---|
| 14536 | 14549 | gl.glVertex3f(i, j, -0.5f); |
|---|
| 14537 | 14550 | |
|---|
| 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 |
|---|
| 14538 | 14554 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); |
|---|
| 14539 | 14555 | gl.glVertex3f(i + step, j, -0.5f); |
|---|
| 14540 | 14556 | |
|---|
| 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 |
|---|
| 14541 | 14560 | gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); |
|---|
| 14542 | 14561 | gl.glVertex3f(i + step, j + stepv, -0.5f); |
|---|
| 14543 | 14562 | |
|---|
| 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 |
|---|
| 14544 | 14566 | gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); |
|---|
| 14545 | 14567 | gl.glVertex3f(i, j + stepv, -0.5f); |
|---|
| 14546 | 14568 | } |
|---|
| .. | .. |
|---|
| 14552 | 14574 | gl.glMatrixMode(GL.GL_PROJECTION); |
|---|
| 14553 | 14575 | gl.glPopMatrix(); |
|---|
| 14554 | 14576 | gl.glMatrixMode(GL.GL_MODELVIEW); |
|---|
| 14555 | | - PopMatrix(null); // checker.toParent); // null); |
|---|
| 14577 | + //PopMatrix(null); // checker.toParent); // null); |
|---|
| 14556 | 14578 | gl.glPopMatrix(); |
|---|
| 14557 | 14579 | PopTextureMatrix(checker.toParent); |
|---|
| 14558 | 14580 | gl.glMatrixMode(GL.GL_TEXTURE); |
|---|
| .. | .. |
|---|
| 15370 | 15392 | //double[] selectedpoint = new double[3]; |
|---|
| 15371 | 15393 | static Superellipsoid selectedpoint = new Superellipsoid(); |
|---|
| 15372 | 15394 | 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(); |
|---|
| 15377 | 15399 | |
|---|
| 15378 | 15400 | static Sphere debugpoints[] = new Sphere[8]; |
|---|
| 15379 | 15401 | |
|---|
| .. | .. |
|---|
| 22 | 22 | return false; // ???? false; |
|---|
| 23 | 23 | } |
|---|
| 24 | 24 | |
|---|
| 25 | | - void Reset() |
|---|
| 26 | | - { |
|---|
| 27 | | - // filecontent = null; |
|---|
| 28 | | - } |
|---|
| 25 | +// void Reset() |
|---|
| 26 | +// { |
|---|
| 27 | +// // filecontent = null; |
|---|
| 28 | +// } |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | void ClearUI() |
|---|
| 31 | 31 | { |
|---|
| .. | .. |
|---|
| 54 | 54 | else |
|---|
| 55 | 55 | { |
|---|
| 56 | 56 | filecontent = ObjEditor.ReadGFD/*z*/(name); |
|---|
| 57 | + if (filecontent != null) |
|---|
| 58 | + { |
|---|
| 57 | 59 | filecontent.parent = null; |
|---|
| 58 | 60 | filecontent.fileparent = this; |
|---|
| 59 | 61 | filecontent.RepairTexture(); |
|---|
| 62 | + } |
|---|
| 60 | 63 | // stripify on load instead? |
|---|
| 61 | 64 | // OK... |
|---|
| 62 | 65 | // filecontent.Stripify(); // fine. faster and read-only anyway |
|---|
| .. | .. |
|---|
| 1120 | 1120 | resetParentItem.addActionListener(this); |
|---|
| 1121 | 1121 | repairParentItem = menu.add(new MenuItem("Repair Parent")); |
|---|
| 1122 | 1122 | repairParentItem.addActionListener(this); |
|---|
| 1123 | + repairShadowItem = menu.add(new MenuItem("Repair Shadow")); |
|---|
| 1124 | + repairShadowItem.addActionListener(this); |
|---|
| 1123 | 1125 | menu.add(invariantsItem = new MenuItem("Invariants")); |
|---|
| 1124 | 1126 | invariantsItem.addActionListener(this); |
|---|
| 1125 | 1127 | menu.add(recompileItem = new MenuItem("Recompile")); |
|---|
| .. | .. |
|---|
| 2537 | 2539 | { |
|---|
| 2538 | 2540 | Object3D obj = (Object3D)e.nextElement(); |
|---|
| 2539 | 2541 | 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(); |
|---|
| 2540 | 2556 | // for (int i=0; i<obj.size(); i++) |
|---|
| 2541 | 2557 | // { |
|---|
| 2542 | 2558 | // obj.get(i).parent = obj; |
|---|
| .. | .. |
|---|
| 5009 | 5025 | |
|---|
| 5010 | 5026 | private MenuItem resetParentItem; |
|---|
| 5011 | 5027 | private MenuItem repairParentItem; |
|---|
| 5028 | + private MenuItem repairShadowItem; |
|---|
| 5012 | 5029 | private MenuItem sortbysizeItem; |
|---|
| 5013 | 5030 | private MenuItem sortbynameItem; |
|---|
| 5014 | 5031 | |
|---|
| .. | .. |
|---|
| 261 | 261 | |
|---|
| 262 | 262 | // LA.matConcat(toParent, hip.get(0).toParent, toParent); |
|---|
| 263 | 263 | |
|---|
| 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; |
|---|
| 267 | 267 | |
|---|
| 268 | 268 | LA.matInvert(toParent, fromParent); |
|---|
| 269 | 269 | |
|---|
| .. | .. |
|---|
| 324 | 324 | // LA.matYRotate(toParent, angleY - angleYhip); |
|---|
| 325 | 325 | // LA.matTranslate(toParent, pos.x - poship.x, pos.y - poship.y, pos.z - poship.z); |
|---|
| 326 | 326 | |
|---|
| 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; |
|---|
| 330 | 330 | |
|---|
| 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; |
|---|
| 334 | 334 | |
|---|
| 335 | 335 | poship.x = toParent[3][0]; |
|---|
| 336 | 336 | poship.y = toParent[3][1]; |
|---|
| 337 | 337 | poship.z = toParent[3][2]; |
|---|
| 338 | 338 | |
|---|
| 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; |
|---|
| 342 | 342 | |
|---|
| 343 | 343 | LA.matInvert(toParent, fromParent); |
|---|
| 344 | 344 | } |
|---|
| .. | .. |
|---|
| 477 | 477 | } |
|---|
| 478 | 478 | } |
|---|
| 479 | 479 | |
|---|
| 480 | + static cVector centroid = new cVector(); |
|---|
| 481 | + static cVector mocaporigin = new cVector(); |
|---|
| 482 | + |
|---|
| 480 | 483 | void SetHipOrientation() |
|---|
| 481 | 484 | { |
|---|
| 482 | 485 | Object3D hip = get(0); |
|---|
| 483 | 486 | |
|---|
| 484 | 487 | LA.matConcat(toParent, hip.get(0).toParent, matrix); |
|---|
| 485 | 488 | |
|---|
| 486 | | - cVector centroid = new cVector(); |
|---|
| 489 | + mocaporigin.x = matrix[3][0]; |
|---|
| 490 | + mocaporigin.y = matrix[3][1]; |
|---|
| 491 | + mocaporigin.z = matrix[3][2]; |
|---|
| 492 | + |
|---|
| 487 | 493 | centroid.x = matrix[3][0]; |
|---|
| 488 | 494 | centroid.y = matrix[3][1]; |
|---|
| 489 | 495 | 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; |
|---|
| 491 | 507 | |
|---|
| 492 | 508 | cVector goal = GetGoal(centroid); |
|---|
| 493 | 509 | if (goal != null) |
|---|
| 494 | 510 | { |
|---|
| 495 | | - System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
|---|
| 511 | + System.err.println("GOAL change (" + this + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
|---|
| 496 | 512 | |
|---|
| 497 | | - goalx = goal.x; |
|---|
| 498 | | - goalz = goal.z; |
|---|
| 499 | | - targetx = targetz = 0; |
|---|
| 513 | + goalposx = goal.x; |
|---|
| 514 | + goalposz = goal.z; |
|---|
| 515 | + targetdirx = targetdirz = 0; |
|---|
| 500 | 516 | } |
|---|
| 501 | 517 | |
|---|
| 502 | | - if (goalx == 0 && goalz == 0) |
|---|
| 518 | + if (goalposx == 0 && goalposz == 0) |
|---|
| 503 | 519 | { |
|---|
| 504 | 520 | // No target |
|---|
| 505 | 521 | if (ScriptNode.speaker != null) |
|---|
| .. | .. |
|---|
| 533 | 549 | //sourcenode.parent.TransformToLocal(dst); |
|---|
| 534 | 550 | this.parent.TransformToLocal(dst); |
|---|
| 535 | 551 | |
|---|
| 536 | | - goalx = dst.x; |
|---|
| 537 | | - goalz = dst.z; |
|---|
| 552 | + goalposx = dst.x; |
|---|
| 553 | + goalposz = dst.z; |
|---|
| 538 | 554 | } |
|---|
| 539 | 555 | else |
|---|
| 540 | 556 | return; |
|---|
| .. | .. |
|---|
| 550 | 566 | |
|---|
| 551 | 567 | double angleYhip = Math.atan2(-temp.z, temp.x); |
|---|
| 552 | 568 | |
|---|
| 553 | | - double angleYtarget = Math.atan2(goalx - centroid.x, goalz - centroid.z); |
|---|
| 569 | + double angleYtarget = Math.atan2(goalposx - centroid.x, goalposz - centroid.z); |
|---|
| 554 | 570 | |
|---|
| 555 | 571 | LA.matIdentity(matrix); |
|---|
| 556 | 572 | 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); |
|---|
| 558 | 574 | LA.matYRotate(matrix, angle); |
|---|
| 559 | 575 | LA.matTranslate(matrix, centroid.x, centroid.y, centroid.z); |
|---|
| 560 | 576 | |
|---|
| 561 | 577 | LA.matConcat(matrix, toParent, toParent); |
|---|
| 562 | 578 | |
|---|
| 563 | 579 | 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); |
|---|
| 564 | 588 | |
|---|
| 565 | 589 | CheckForAction(centroid); |
|---|
| 566 | 590 | } |
|---|
| .. | .. |
|---|
| 637 | 661 | double pinx; |
|---|
| 638 | 662 | double pinz; |
|---|
| 639 | 663 | |
|---|
| 640 | | - double targetx; |
|---|
| 641 | | - double targetz; |
|---|
| 664 | + double targetdirx; |
|---|
| 665 | + double targetdirz; |
|---|
| 642 | 666 | |
|---|
| 643 | | - double goalx = -20; |
|---|
| 644 | | - double goalz = -10; |
|---|
| 667 | + double goalposx = -20; |
|---|
| 668 | + double goalposz = -10; |
|---|
| 645 | 669 | |
|---|
| 646 | 670 | boolean followpath; |
|---|
| 647 | 671 | |
|---|
| .. | .. |
|---|
| 712 | 736 | scriptactions.clear(); |
|---|
| 713 | 737 | } |
|---|
| 714 | 738 | |
|---|
| 715 | | - static double EPSACTION = 0.1; // 0.075; // 0.1; |
|---|
| 739 | + static double EPSACTION = 0.1; // 0.075; // 0.1;Came |
|---|
| 716 | 740 | |
|---|
| 717 | 741 | void AddFromTo(cVector from, cVector to) |
|---|
| 718 | 742 | { |
|---|
| .. | .. |
|---|
| 1278 | 1302 | |
|---|
| 1279 | 1303 | void SetPosition(Object3D sourcenode, cVector floor, long floorid, cVector centroid) |
|---|
| 1280 | 1304 | { |
|---|
| 1305 | + assert(false); |
|---|
| 1281 | 1306 | //assert(CameraPane.drawMode == CameraPane.SHADOW); |
|---|
| 1282 | 1307 | |
|---|
| 1283 | 1308 | Object3D transformnode = new Object3D(); |
|---|
| .. | .. |
|---|
| 1481 | 1506 | groundid = floorid; |
|---|
| 1482 | 1507 | |
|---|
| 1483 | 1508 | // 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; |
|---|
| 1487 | 1512 | |
|---|
| 1488 | 1513 | if (true) // slow && stepout && onein) |
|---|
| 1489 | 1514 | { |
|---|
| .. | .. |
|---|
| 1560 | 1585 | |
|---|
| 1561 | 1586 | // System.out.println("Allo " + sourcenode); |
|---|
| 1562 | 1587 | // 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; |
|---|
| 1566 | 1591 | |
|---|
| 1567 | 1592 | |
|---|
| 1568 | 1593 | if (false) // dist2 > 0.1) |
|---|
| .. | .. |
|---|
| 1628 | 1653 | this.get(0).TransformToWorld(v0); |
|---|
| 1629 | 1654 | |
|---|
| 1630 | 1655 | // 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; |
|---|
| 1634 | 1659 | |
|---|
| 1635 | 1660 | LA.matConcat(sourcenode.toParent, transformnode.toParent, sourcenode.toParent); |
|---|
| 1636 | 1661 | LA.matInvert(sourcenode.toParent, sourcenode.fromParent); |
|---|
| .. | .. |
|---|
| 1640 | 1665 | this.get(0).TransformToWorld(v0); |
|---|
| 1641 | 1666 | |
|---|
| 1642 | 1667 | // 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; |
|---|
| 1646 | 1671 | } |
|---|
| 1647 | 1672 | } |
|---|
| 1648 | 1673 | |
|---|
| .. | .. |
|---|
| 1682 | 1707 | |
|---|
| 1683 | 1708 | if (goal != null) |
|---|
| 1684 | 1709 | { |
|---|
| 1685 | | - System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalx + ", " + goalz + ")"); |
|---|
| 1710 | + System.err.println("GOAL change (" + sourcenode + "): " + goal + " (was " + goalposx + ", " + goalposz + ")"); |
|---|
| 1686 | 1711 | //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; |
|---|
| 1690 | 1715 | |
|---|
| 1691 | 1716 | followpath = true; |
|---|
| 1692 | 1717 | } |
|---|
| .. | .. |
|---|
| 1737 | 1762 | // } |
|---|
| 1738 | 1763 | if (false) // !uselast) |
|---|
| 1739 | 1764 | { |
|---|
| 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; |
|---|
| 1743 | 1768 | } |
|---|
| 1744 | 1769 | } |
|---|
| 1745 | 1770 | |
|---|
| 1746 | | - if (goalx != 0 || goalz != 0) // TODO |
|---|
| 1771 | + if (goalposx != 0 || goalposz != 0) // TODO |
|---|
| 1747 | 1772 | { |
|---|
| 1748 | 1773 | // overwrite speaker orientation |
|---|
| 1749 | | - dst.set(goalx,0,goalz); |
|---|
| 1774 | + dst.set(goalposx,0,goalposz); |
|---|
| 1750 | 1775 | if (sourcenode.parent != null) // july 2014 |
|---|
| 1751 | 1776 | sourcenode.parent. |
|---|
| 1752 | 1777 | TransformToLocal(dst); |
|---|
| .. | .. |
|---|
| 1798 | 1823 | // mars 2014 |
|---|
| 1799 | 1824 | if (false) // goalx != 0 || goalz != 0) |
|---|
| 1800 | 1825 | { |
|---|
| 1801 | | - targetx = dst.x - src.x; |
|---|
| 1802 | | - targetz = dst.z - src.z; |
|---|
| 1826 | + targetdirx = dst.x - src.x; |
|---|
| 1827 | + targetdirz = dst.z - src.z; |
|---|
| 1803 | 1828 | |
|---|
| 1804 | | - if (Math.abs(targetx) > 0.1 || Math.abs(targetz) > 0.1) |
|---|
| 1829 | + if (Math.abs(targetdirx) > 0.1 || Math.abs(targetdirz) > 0.1) |
|---|
| 1805 | 1830 | { |
|---|
| 1806 | 1831 | // far enough from goal. keep the goal position. |
|---|
| 1807 | | - targetx = 0; |
|---|
| 1808 | | - targetz = 0; |
|---|
| 1832 | + targetdirx = 0; |
|---|
| 1833 | + targetdirz = 0; |
|---|
| 1809 | 1834 | } |
|---|
| 1810 | 1835 | else |
|---|
| 1811 | 1836 | { |
|---|
| 1812 | 1837 | // too close to goal. switch to target direction instead. |
|---|
| 1813 | | - goalx = 0; |
|---|
| 1814 | | - goalz = 0; |
|---|
| 1838 | + goalposx = 0; |
|---|
| 1839 | + goalposz = 0; |
|---|
| 1815 | 1840 | } |
|---|
| 1816 | 1841 | } |
|---|
| 1817 | 1842 | |
|---|
| 1818 | 1843 | //sourcenode.getCentroid(src, true); |
|---|
| 1819 | 1844 | |
|---|
| 1820 | | - if (speakernode == sourcenode && goalx == 0 && goalz == 0) |
|---|
| 1845 | + if (speakernode == sourcenode && goalposx == 0 && goalposz == 0) |
|---|
| 1821 | 1846 | { |
|---|
| 1822 | 1847 | if (ScriptNode.lastspeaker != null) |
|---|
| 1823 | 1848 | new Exception().printStackTrace(); |
|---|
| .. | .. |
|---|
| 1826 | 1851 | |
|---|
| 1827 | 1852 | // LA.xformPos(src, fromParent, src); |
|---|
| 1828 | 1853 | |
|---|
| 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) |
|---|
| 1830 | 1855 | dst.sub(src); |
|---|
| 1831 | 1856 | else |
|---|
| 1832 | 1857 | // vector mode |
|---|
| 1833 | 1858 | { |
|---|
| 1834 | | - dst.x = targetx; |
|---|
| 1835 | | - dst.z = targetz; |
|---|
| 1859 | + dst.x = targetdirx; |
|---|
| 1860 | + dst.z = targetdirz; |
|---|
| 1836 | 1861 | |
|---|
| 1837 | 1862 | // TEST TARGET |
|---|
| 1838 | 1863 | // dst.x = CameraPane.selectedpoint.toParent[3][0]; |
|---|
| .. | .. |
|---|
| 2280 | 2305 | toVector.x = LA.cos(to); |
|---|
| 2281 | 2306 | toVector.y = LA.sin(to); |
|---|
| 2282 | 2307 | |
|---|
| 2308 | + double fromA = Math.atan2(fromVector.y, fromVector.x); |
|---|
| 2309 | + double toA = Math.atan2(toVector.y, toVector.x); |
|---|
| 2310 | + |
|---|
| 2283 | 2311 | Vector2d currentVector = Slerp(fromVector, toVector, step); |
|---|
| 2284 | 2312 | |
|---|
| 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; |
|---|
| 2286 | 2318 | } |
|---|
| 2287 | 2319 | |
|---|
| 2288 | 2320 | public static Vector2d Slerp(Vector2d from, Vector2d to, double step) |
|---|
| .. | .. |
|---|
| 3191 | 3223 | |
|---|
| 3192 | 3224 | // july 2014 |
|---|
| 3193 | 3225 | // goalx = goalz = 0; |
|---|
| 3194 | | - targetx = targetz = 0; |
|---|
| 3226 | + targetdirx = targetdirz = 0; |
|---|
| 3195 | 3227 | |
|---|
| 3196 | 3228 | //SetPositionDelta(true, true, true, false); |
|---|
| 3197 | 3229 | // LoadData(); |
|---|
| .. | .. |
|---|
| 102 | 102 | |
|---|
| 103 | 103 | if (pow <= 0) |
|---|
| 104 | 104 | { |
|---|
| 105 | + // Transition between min and max |
|---|
| 105 | 106 | // value = (Math.pow(getValue()/1000.0, POW) * (max - min)) + min; |
|---|
| 106 | 107 | // value - min = Math.pow(getValue()/1000.0, POW) * (max - min); |
|---|
| 107 | 108 | // (value - min) / (max - min) = Math.pow(getValue()/1000.0, POW); |
|---|
| .. | .. |
|---|
| 160 | 160 | objEditor.ctrlPanel.remove(slowerButton); |
|---|
| 161 | 161 | objEditor.ctrlPanel.remove(fasterButton); |
|---|
| 162 | 162 | objEditor.ctrlPanel.remove(remarkButton); |
|---|
| 163 | + |
|---|
| 164 | + Remove(normalpushField); |
|---|
| 163 | 165 | } |
|---|
| 164 | 166 | |
|---|
| 165 | 167 | public ObjEditor GetEditor() |
|---|
| 166 | 168 | { |
|---|
| 167 | 169 | return objEditor; //.GetEditor(); |
|---|
| 168 | 170 | } |
|---|
| 171 | + |
|---|
| 172 | + // Sometimes myself, sometimes my callee's. |
|---|
| 169 | 173 | ObjEditor objEditor; |
|---|
| 170 | 174 | |
|---|
| 171 | 175 | /* |
|---|
| .. | .. |
|---|
| 814 | 818 | |
|---|
| 815 | 819 | aConstraints.fill = GridBagConstraints.VERTICAL; |
|---|
| 816 | 820 | jlabel.setHorizontalAlignment(SwingConstants.TRAILING); |
|---|
| 817 | | - aConstraints.gridwidth = 2; |
|---|
| 821 | + aConstraints.gridwidth = 1; |
|---|
| 818 | 822 | ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1); |
|---|
| 819 | 823 | aConstraints.gridx += 1; |
|---|
| 820 | 824 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| .. | .. |
|---|
| 983 | 987 | |
|---|
| 984 | 988 | Return(); |
|---|
| 985 | 989 | |
|---|
| 990 | + normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1); |
|---|
| 991 | + Return(); |
|---|
| 992 | + |
|---|
| 986 | 993 | // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); |
|---|
| 987 | 994 | // ObjEditor.aConstraints.gridx += 1; |
|---|
| 988 | 995 | |
|---|
| .. | .. |
|---|
| 1446 | 1453 | aConstraints.gridx += 1; |
|---|
| 1447 | 1454 | aConstraints.gridwidth = ObjEditor.GRIDWIDTH; |
|---|
| 1448 | 1455 | //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); |
|---|
| 1450 | 1457 | aConstraints.gridx = 0; |
|---|
| 1451 | 1458 | aConstraints.gridy += 1; |
|---|
| 1452 | 1459 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1456 | 1463 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1457 | 1464 | aConstraints.gridx += 1; |
|---|
| 1458 | 1465 | 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); |
|---|
| 1460 | 1467 | aConstraints.gridx = 0; |
|---|
| 1461 | 1468 | aConstraints.gridy += 1; |
|---|
| 1462 | 1469 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1466 | 1473 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1467 | 1474 | aConstraints.gridx += 1; |
|---|
| 1468 | 1475 | 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); |
|---|
| 1470 | 1477 | aConstraints.gridx = 0; |
|---|
| 1471 | 1478 | aConstraints.gridy += 1; |
|---|
| 1472 | 1479 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1476 | 1483 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1477 | 1484 | aConstraints.gridx += 1; |
|---|
| 1478 | 1485 | 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); |
|---|
| 1480 | 1487 | aConstraints.gridx = 0; |
|---|
| 1481 | 1488 | aConstraints.gridy += 1; |
|---|
| 1482 | 1489 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1486 | 1493 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1487 | 1494 | aConstraints.gridx += 1; |
|---|
| 1488 | 1495 | 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); |
|---|
| 1490 | 1497 | aConstraints.gridx = 0; |
|---|
| 1491 | 1498 | aConstraints.gridy += 1; |
|---|
| 1492 | 1499 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1555 | 1562 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1556 | 1563 | aConstraints.gridx += 1; |
|---|
| 1557 | 1564 | 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); |
|---|
| 1559 | 1566 | aConstraints.gridx = 0; |
|---|
| 1560 | 1567 | aConstraints.gridy += 1; |
|---|
| 1561 | 1568 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1624 | 1631 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1625 | 1632 | aConstraints.gridx += 1; |
|---|
| 1626 | 1633 | 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); |
|---|
| 1628 | 1635 | aConstraints.gridx = 0; |
|---|
| 1629 | 1636 | aConstraints.gridy += 1; |
|---|
| 1630 | 1637 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 1695 | 1702 | aConstraints.fill = GridBagConstraints.HORIZONTAL; |
|---|
| 1696 | 1703 | aConstraints.gridx += 1; |
|---|
| 1697 | 1704 | 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); |
|---|
| 1699 | 1706 | aConstraints.gridx = 0; |
|---|
| 1700 | 1707 | aConstraints.gridy += 1; |
|---|
| 1701 | 1708 | aConstraints.gridwidth = 1; |
|---|
| .. | .. |
|---|
| 3549 | 3556 | //System.out.println("PARENT = " + parent); |
|---|
| 3550 | 3557 | //if (parent != null) |
|---|
| 3551 | 3558 | // parent.applySelf(); |
|---|
| 3552 | | - refreshContents(); |
|---|
| 3559 | + if (e.getSource() == normalpushField) |
|---|
| 3560 | + { |
|---|
| 3561 | + objEditor.refreshContents(); |
|---|
| 3562 | + //Refresh(); |
|---|
| 3563 | + } |
|---|
| 3564 | + else |
|---|
| 3565 | + refreshContents(); |
|---|
| 3553 | 3566 | // ??? client.refreshEditWindow(); |
|---|
| 3554 | 3567 | } |
|---|
| 3555 | 3568 | //else |
|---|
| .. | .. |
|---|
| 3561 | 3574 | //group.name = nameField.getText(); |
|---|
| 3562 | 3575 | //objEditor.applySelf(); |
|---|
| 3563 | 3576 | |
|---|
| 3564 | | - assert (objEditor == this); |
|---|
| 3577 | + // OCT2018: assert (objEditor == this); |
|---|
| 3565 | 3578 | if (copy.selection == null || copy.selection.size() == 0) |
|---|
| 3566 | 3579 | //super.applySelf() |
|---|
| 3567 | 3580 | ; else |
|---|
| .. | .. |
|---|
| 3585 | 3598 | objEditor.copy = keep; |
|---|
| 3586 | 3599 | } |
|---|
| 3587 | 3600 | } |
|---|
| 3601 | + |
|---|
| 3602 | + if (normalpushField != null) |
|---|
| 3603 | + copy.NORMALPUSH = (float)normalpushField.getFloat()/1000; |
|---|
| 3588 | 3604 | } |
|---|
| 3589 | 3605 | |
|---|
| 3590 | 3606 | void SnapObject() |
|---|
| .. | .. |
|---|
| 4629 | 4645 | NumberSlider opacityPowerField; |
|---|
| 4630 | 4646 | JTree jTree; |
|---|
| 4631 | 4647 | //ObjectUI parent; |
|---|
| 4648 | + |
|---|
| 4649 | + NumberSlider normalpushField; |
|---|
| 4632 | 4650 | } |
|---|
| .. | .. |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | ScriptNode scriptnode; |
|---|
| 23 | 23 | |
|---|
| 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 | + |
|---|
| 24 | 37 | void MinMax(cVector minima, cVector maxima) |
|---|
| 25 | 38 | { |
|---|
| 26 | 39 | for (int xyz = 0; xyz < 3; xyz++) |
|---|
| .. | .. |
|---|
| 295 | 308 | boolean random = false; |
|---|
| 296 | 309 | boolean speedup = false; |
|---|
| 297 | 310 | boolean rewind = false; |
|---|
| 311 | + |
|---|
| 312 | + float NORMALPUSH = 0; |
|---|
| 298 | 313 | |
|---|
| 299 | 314 | Object3D support; |
|---|
| 300 | 315 | |
|---|
| .. | .. |
|---|
| 779 | 794 | // factor = CameraPane.STEP; |
|---|
| 780 | 795 | // } |
|---|
| 781 | 796 | |
|---|
| 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) |
|---|
| 783 | 801 | { |
|---|
| 784 | 802 | currentframe = CameraPane.framecount; |
|---|
| 785 | 803 | |
|---|
| .. | .. |
|---|
| 2130 | 2148 | if (/*parent != null &&*/ material == null) |
|---|
| 2131 | 2149 | { |
|---|
| 2132 | 2150 | 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(); |
|---|
| 2142 | 2153 | |
|---|
| 2143 | 2154 | if (this instanceof Camera) |
|---|
| 2144 | 2155 | { |
|---|
| .. | .. |
|---|
| 4161 | 4172 | } |
|---|
| 4162 | 4173 | } |
|---|
| 4163 | 4174 | |
|---|
| 4175 | + void RepairShadow() |
|---|
| 4176 | + { |
|---|
| 4177 | + if (blockloop) |
|---|
| 4178 | + return; |
|---|
| 4179 | + |
|---|
| 4180 | + if (this.material != null) |
|---|
| 4181 | + this.InitOthers(); |
|---|
| 4182 | + |
|---|
| 4183 | + for (int i=0; i<Size(); i++) |
|---|
| 4184 | + { |
|---|
| 4185 | + blockloop = true; |
|---|
| 4186 | + get(i).RepairShadow(); |
|---|
| 4187 | + blockloop = false; |
|---|
| 4188 | + } |
|---|
| 4189 | + } |
|---|
| 4190 | + |
|---|
| 4164 | 4191 | void RepairTexture() |
|---|
| 4165 | 4192 | { |
|---|
| 4166 | 4193 | if (this instanceof FileObject || blockloop) |
|---|
| .. | .. |
|---|
| 5958 | 5985 | |
|---|
| 5959 | 5986 | javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 5960 | 5987 | |
|---|
| 5961 | | - if (CameraPane.BOXMODE) // || CameraPane.movingcamera) |
|---|
| 5988 | + if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
|---|
| 5962 | 5989 | { |
|---|
| 5963 | 5990 | int fc = bRep.FaceCount(); |
|---|
| 5964 | 5991 | int vc = bRep.VertexCount(); |
|---|
| .. | .. |
|---|
| 6699 | 6726 | gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z); |
|---|
| 6700 | 6727 | } |
|---|
| 6701 | 6728 | |
|---|
| 6729 | + // P |
|---|
| 6730 | + float x = (float)pv.x; |
|---|
| 6731 | + float y = (float)pv.y; |
|---|
| 6732 | + float z = (float)pv.z; |
|---|
| 6733 | + |
|---|
| 6702 | 6734 | if (hasnorm) |
|---|
| 6703 | 6735 | { |
|---|
| 6704 | 6736 | // if (!pv.norm.normalized()) |
|---|
| 6705 | 6737 | // assert(pv.norm.normalized()); |
|---|
| 6706 | 6738 | |
|---|
| 6707 | 6739 | //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); |
|---|
| 6709 | 6749 | } |
|---|
| 6710 | 6750 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
|---|
| 6711 | 6751 | SetColor(display, pv); |
|---|
| .. | .. |
|---|
| 6716 | 6756 | else |
|---|
| 6717 | 6757 | gl.glTexCoord2f((float) pv.s, (float) pv.t); |
|---|
| 6718 | 6758 | //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 | + |
|---|
| 6720 | 6767 | // Print(pv); |
|---|
| 6721 | 6768 | if (hasnorm) |
|---|
| 6722 | 6769 | { |
|---|
| 6723 | 6770 | // assert(qv.norm.normalized()); |
|---|
| 6724 | 6771 | //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); |
|---|
| 6726 | 6781 | } |
|---|
| 6727 | 6782 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
|---|
| 6728 | 6783 | // boolean locked = false; |
|---|
| .. | .. |
|---|
| 6746 | 6801 | // } |
|---|
| 6747 | 6802 | gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
|---|
| 6748 | 6803 | SetColor(display, qv); |
|---|
| 6804 | + |
|---|
| 6805 | + gl.glVertex3f(x, y, z); |
|---|
| 6749 | 6806 | //gl.glColor4f(r, g, b, 1); |
|---|
| 6750 | 6807 | //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
|---|
| 6751 | 6808 | //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); |
|---|
| 6753 | 6809 | // Print(qv); |
|---|
| 6810 | + |
|---|
| 6811 | + // R |
|---|
| 6812 | + x = (float)rv.x; |
|---|
| 6813 | + y = (float)rv.y; |
|---|
| 6814 | + z = (float)rv.z; |
|---|
| 6815 | + |
|---|
| 6754 | 6816 | if (hasnorm) |
|---|
| 6755 | 6817 | { |
|---|
| 6756 | 6818 | // assert(rv.norm.normalized()); |
|---|
| 6757 | 6819 | //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); |
|---|
| 6759 | 6829 | } |
|---|
| 6760 | 6830 | |
|---|
| 6761 | 6831 | // if ((dot&4) == 0) |
|---|
| .. | .. |
|---|
| 6776 | 6846 | //gl.glColor4f(r, g, b, 1); |
|---|
| 6777 | 6847 | //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
|---|
| 6778 | 6848 | //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); |
|---|
| 6780 | 6850 | // Print(rv); |
|---|
| 6781 | 6851 | //gl.glEnd(); |
|---|
| 6782 | 6852 | } |
|---|
| .. | .. |
|---|
| 8163 | 8233 | { |
|---|
| 8164 | 8234 | Object3D targ = this; |
|---|
| 8165 | 8235 | |
|---|
| 8236 | + targ.NORMALPUSH = obj.NORMALPUSH; |
|---|
| 8237 | + |
|---|
| 8166 | 8238 | if (obj.material != null) |
|---|
| 8167 | 8239 | { |
|---|
| 8168 | 8240 | if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL)) |
|---|
| .. | .. |
|---|
| 972 | 972 | |
|---|
| 973 | 973 | if (command.equals("targetx")) |
|---|
| 974 | 974 | { |
|---|
| 975 | | - ((Mocap) object).targetx = Float.parseFloat(strs[index+2]); |
|---|
| 975 | + ((Mocap) object).targetdirx = Float.parseFloat(strs[index+2]); |
|---|
| 976 | 976 | return; |
|---|
| 977 | 977 | } |
|---|
| 978 | 978 | |
|---|
| 979 | 979 | if (command.equals("targetz")) |
|---|
| 980 | 980 | { |
|---|
| 981 | | - ((Mocap) object).targetz = Float.parseFloat(strs[index+2]); |
|---|
| 981 | + ((Mocap) object).targetdirz = Float.parseFloat(strs[index+2]); |
|---|
| 982 | 982 | return; |
|---|
| 983 | 983 | } |
|---|
| 984 | 984 | |
|---|
| 985 | 985 | if (command.equals("goalx")) |
|---|
| 986 | 986 | { |
|---|
| 987 | | - ((Mocap) object).goalx = Float.parseFloat(strs[index+2]); |
|---|
| 987 | + ((Mocap) object).goalposx = Float.parseFloat(strs[index+2]); |
|---|
| 988 | 988 | return; |
|---|
| 989 | 989 | } |
|---|
| 990 | 990 | |
|---|
| 991 | 991 | if (command.equals("goalz")) |
|---|
| 992 | 992 | { |
|---|
| 993 | | - ((Mocap) object).goalz = Float.parseFloat(strs[index+2]); |
|---|
| 993 | + ((Mocap) object).goalposz = Float.parseFloat(strs[index+2]); |
|---|
| 994 | 994 | return; |
|---|
| 995 | 995 | } |
|---|
| 996 | 996 | |
|---|
| .. | .. |
|---|
| 10 | 10 | public class Texture extends Composite implements java.io.Serializable |
|---|
| 11 | 11 | { |
|---|
| 12 | 12 | // deprecated due to serial problems |
|---|
| 13 | | - static final long serialVersionUID = // -5280151442948961597L; // new java |
|---|
| 13 | + static final long serialVersionUID = //-5280151442948961597L; // new java |
|---|
| 14 | 14 | 7695543694999681408L; // old java !!! |
|---|
| 15 | 15 | |
|---|
| 16 | 16 | // default = -8076744133104150348L |
|---|
| .. | .. |
|---|
| 82 | 82 | |
|---|
| 83 | 83 | // timestep |
|---|
| 84 | 84 | double timestep = 1; |
|---|
| 85 | | - double normalpusH = 0; // 1; |
|---|
| 85 | + double normalpush = 0; // 1; |
|---|
| 86 | 86 | static float H0 = 1E1f; // aucune importance... |
|---|
| 87 | 87 | // mass |
|---|
| 88 | 88 | double M = 1; |
|---|
| .. | .. |
|---|
| 967 | 967 | for (int i = 0; i < allNodes.size(); i++) |
|---|
| 968 | 968 | { |
|---|
| 969 | 969 | DynamicNode dn = allNodes.get(i); |
|---|
| 970 | + dn.linked = false; |
|---|
| 970 | 971 | dn.closestpoint = null; |
|---|
| 971 | 972 | } |
|---|
| 972 | 973 | } |
|---|
| .. | .. |
|---|
| 1416 | 1417 | //transient double rotangle; // Z of axis |
|---|
| 1417 | 1418 | transient boolean reverse = false; |
|---|
| 1418 | 1419 | |
|---|
| 1420 | + transient boolean linked = false; |
|---|
| 1419 | 1421 | transient Vertex closestpoint = null; |
|---|
| 1420 | 1422 | |
|---|
| 1421 | 1423 | //Point3D lastForce = new Point3D(); |
|---|
| .. | .. |
|---|
| 1491 | 1493 | otherForce.add(f.forceOn(this)); |
|---|
| 1492 | 1494 | } |
|---|
| 1493 | 1495 | } |
|---|
| 1496 | + } |
|---|
| 1497 | + |
|---|
| 1498 | + if (Double.isNaN(springForce.y)) |
|---|
| 1499 | + { |
|---|
| 1500 | + springForce.x = springForce.y = springForce.z = 0; |
|---|
| 1494 | 1501 | } |
|---|
| 1495 | 1502 | } |
|---|
| 1496 | 1503 | |
|---|
| .. | .. |
|---|
| 2339 | 2346 | return this; |
|---|
| 2340 | 2347 | } |
|---|
| 2341 | 2348 | |
|---|
| 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; |
|---|
| 2364 | 2350 | |
|---|
| 2365 | 2351 | void ResetGlobalTransform() |
|---|
| 2366 | 2352 | { |
|---|
| .. | .. |
|---|
| 2372 | 2358 | |
|---|
| 2373 | 2359 | transient double[][] toRoot; // = new double[4][4]; |
|---|
| 2374 | 2360 | |
|---|
| 2375 | | - //Vector<Vertex> sortedcollider; |
|---|
| 2376 | | - Object3D avoider; |
|---|
| 2377 | | - Vector<Double> parameters = new Vector<Double>(); // serial issue |
|---|
| 2378 | | - |
|---|
| 2379 | 2361 | Vertex ClosestPoint(Vector<Vertex> collider, DynamicNode N, int startindex, int endindex, int sortaxis) |
|---|
| 2380 | 2362 | { |
|---|
| 2381 | 2363 | if (startindex == endindex) |
|---|
| .. | .. |
|---|
| 2469 | 2451 | |
|---|
| 2470 | 2452 | for (int i=collider.size(); --i>=0;) |
|---|
| 2471 | 2453 | { |
|---|
| 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) |
|---|
| 2473 | 2456 | continue; |
|---|
| 2474 | 2457 | |
|---|
| 2475 | 2458 | temp.set(N.position); |
|---|
| .. | .. |
|---|
| 2487 | 2470 | } |
|---|
| 2488 | 2471 | } |
|---|
| 2489 | 2472 | |
|---|
| 2490 | | - return cp; |
|---|
| 2473 | + return mindist2 < 1 ? cp : null; |
|---|
| 2491 | 2474 | } |
|---|
| 2492 | 2475 | |
|---|
| 2493 | | - Point3D forceOn(DynamicNode N) |
|---|
| 2476 | + class Avoider extends Force |
|---|
| 2477 | + { |
|---|
| 2478 | + static final long serialVersionUID = -8657094699711594990L; |
|---|
| 2479 | + |
|---|
| 2480 | + Avoider() |
|---|
| 2494 | 2481 | { |
|---|
| 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 | + { |
|---|
| 2527 | 2491 | temp.set(N.position); |
|---|
| 2528 | 2492 | if (avoider != This()) |
|---|
| 2529 | 2493 | { |
|---|
| .. | .. |
|---|
| 2531 | 2495 | temp2.mul(0.001); |
|---|
| 2532 | 2496 | temp.sub(temp2); // push outside because of mesh artifacts |
|---|
| 2533 | 2497 | } |
|---|
| 2534 | | - |
|---|
| 2498 | + |
|---|
| 2535 | 2499 | vect1.set(N.closestpoint); |
|---|
| 2536 | | - |
|---|
| 2500 | + |
|---|
| 2537 | 2501 | LA.xformPos(vect1,toRoot,vect1); |
|---|
| 2538 | 2502 | //avoider.TransformToWorld(vect1, vect1); |
|---|
| 2539 | | - |
|---|
| 2503 | + |
|---|
| 2540 | 2504 | temp.sub(vect1); |
|---|
| 2541 | | - |
|---|
| 2505 | + |
|---|
| 2542 | 2506 | double distance = Math.sqrt(temp.length2()); |
|---|
| 2543 | | - |
|---|
| 2507 | + |
|---|
| 2544 | 2508 | if (distance < 0.01) |
|---|
| 2545 | 2509 | { |
|---|
| 2546 | 2510 | temp2.set(N.closestpoint.norm); |
|---|
| .. | .. |
|---|
| 2554 | 2518 | if (IsAutoFreeze()) |
|---|
| 2555 | 2519 | dot = -dot; |
|---|
| 2556 | 2520 | |
|---|
| 2557 | | - temp.mul(normalpusH/*/distance*/*-dot/Math.sqrt(distance)); |
|---|
| 2521 | + temp.mul(normalpush/*/distance*/*-dot/Math.sqrt(distance)); |
|---|
| 2558 | 2522 | force.add(temp); |
|---|
| 2559 | 2523 | } |
|---|
| 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); |
|---|
| 2560 | 2613 | } |
|---|
| 2561 | 2614 | |
|---|
| 2562 | 2615 | if (parameters.size() > 0) |
|---|
| .. | .. |
|---|
| 2590 | 2643 | totalforce = new Point3D(); |
|---|
| 2591 | 2644 | |
|---|
| 2592 | 2645 | totalforce.set(0,0,0); |
|---|
| 2646 | + |
|---|
| 2593 | 2647 | if (forces.size() == 0) |
|---|
| 2594 | 2648 | totalforce.set(super.forceOn(N)); |
|---|
| 2595 | 2649 | |
|---|
| .. | .. |
|---|
| 2660 | 2714 | force.y = 0; |
|---|
| 2661 | 2715 | force.z = 0; |
|---|
| 2662 | 2716 | |
|---|
| 2663 | | - if (normalpusH != 0) // speed == 0) // Now normal force |
|---|
| 2717 | + if (normalpush != 0) // speed == 0) // Now normal force |
|---|
| 2664 | 2718 | { |
|---|
| 2665 | 2719 | // temp.set(N.position); |
|---|
| 2666 | 2720 | // temp.sub(Phys.reference); |
|---|
| .. | .. |
|---|
| 2668 | 2722 | |
|---|
| 2669 | 2723 | // normal pushing |
|---|
| 2670 | 2724 | temp.set(N.normal); |
|---|
| 2671 | | - temp.mul(normalpusH/distance); |
|---|
| 2725 | + temp.mul(normalpush/distance); |
|---|
| 2672 | 2726 | force.add(temp); |
|---|
| 2673 | 2727 | } |
|---|
| 2674 | 2728 | |
|---|
| .. | .. |
|---|
| 2900 | 2954 | return force; |
|---|
| 2901 | 2955 | } |
|---|
| 2902 | 2956 | } |
|---|
| 2957 | + |
|---|
| 2903 | 2958 | static int TABLESAC = 1024; |
|---|
| 2904 | 2959 | static double[] tablesac = new double[TABLESAC]; |
|---|
| 2905 | 2960 | |
|---|
| .. | .. |
|---|
| 2993 | 3048 | // mass = M; |
|---|
| 2994 | 3049 | } // ??? |
|---|
| 2995 | 3050 | |
|---|
| 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 | + |
|---|
| 2996 | 3085 | force.x = 0; |
|---|
| 2997 | 3086 | force.y = (float) (-acceleration * mass); |
|---|
| 2998 | 3087 | force.z = 0; // -acceleration * mass * 1000 * Math.cos(time/234.0 + framecount*100); // (Math.random()*2 - 1); // |
|---|
| .. | .. |
|---|
| 3189 | 3278 | } |
|---|
| 3190 | 3279 | if (false) // isHandle) |
|---|
| 3191 | 3280 | { |
|---|
| 3192 | | - double K = Math.exp(-displacement*normalpusH); |
|---|
| 3281 | + double K = Math.exp(-displacement*normalpush); |
|---|
| 3193 | 3282 | magnitude /= (displacement*(1-K) + K); |
|---|
| 3194 | 3283 | } |
|---|
| 3195 | 3284 | |
|---|
| .. | .. |
|---|
| 133 | 133 | // ObjEditor.aConstraints.gridwidth = 1; |
|---|
| 134 | 134 | // //ObjEditor.aConstraints.fill = 0; |
|---|
| 135 | 135 | // 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); |
|---|
| 137 | 137 | Return(); |
|---|
| 138 | 138 | |
|---|
| 139 | 139 | /**/ |
|---|
| .. | .. |
|---|
| 472 | 472 | |
|---|
| 473 | 473 | spring.W.AddForce(spring.new Avoider(GetEditor().copy.selection.get(0))); |
|---|
| 474 | 474 | } |
|---|
| 475 | | -// else |
|---|
| 475 | + else |
|---|
| 476 | + { |
|---|
| 477 | + if (spring.W instanceof cSpring.ActingForces) |
|---|
| 478 | + ((cSpring.ActingForces)spring.W).forces.clear(); |
|---|
| 479 | + } |
|---|
| 476 | 480 | /* |
|---|
| 477 | 481 | if (spring.Phys == null) // || spring.IsAutoFreeze()) |
|---|
| 478 | 482 | spring.InitPhysics(); |
|---|
| .. | .. |
|---|
| 564 | 568 | spring.K = k; |
|---|
| 565 | 569 | spring.M = m; |
|---|
| 566 | 570 | spring.G.acceleration = g; |
|---|
| 567 | | - spring.normalpusH = d; // * Math.sqrt(m/k); |
|---|
| 571 | + spring.normalpush = d; // * Math.sqrt(m/k); |
|---|
| 568 | 572 | spring.limit = L; |
|---|
| 569 | 573 | spring.restlengthFactor = t; |
|---|
| 570 | 574 | spring.W.wind = v; |
|---|