Jump to content

HingeJoint - Locking


ian
 Share

Recommended Posts

If we have vertical bar and horizontal bar on top of vertical bar. and if we set joint like

horizontalBar should rotate around Y (in blender around Z). 
If I push horizontalBar, two edges of horizontalBar is rotatin around Y but edges of horizontalBar are also swinging up and down (Z). 

When horizontal bar is rotationg edges are changing Y a little bit. Edges doesn't always have Y=3 like mainAxis have it.

Can I lock hinge so that edges of horizontalBar will not swinging up and down and it will always rotate with same Y=3.

Or I push too hard horizontalBar? Or is there any other/strange problem? Should edges of horizontal bar always rotate with same Y values (in this case Y=always 3)?

var joint = new BABYLON.HingeJoint({
  mainPivot:  new BABYLON.Vector3(0, 0, 0),
  connectedPivot: new BABYLON.Vector3(0, 3, 0),
  mainAxis: new BABYLON.Vector3(0, 1, 0),
  connectedAxis: new BABYLON.Vector3(0, 1, 0)
});
verticalBar.physicsImpostor.addJoint(horizontalBar.physicsImpostor, joint);

 

Link to comment
Share on other sites

Hi Ian.  I don't think there is a way to stop that.  Remember the train wheel demo?  Remember me saying I have tried to remove wheel "wobble" and failed?  *nod*.  Same problem... too much mass... landing on leverage point of fulcrum.  Joints have some "slop"... and I have searched for ways to "tighten the bearings".  I did not find a solve.

With box mass much lower...

http://www.babylonjs-playground.com/#1UF7BM#8

Better.  Still some "bounce"... caused by hinge slop.  Sorry I have no happy answer.  Perhaps others will have ideas.

Box falling through floor, too.  Darn.  *scratch scratch*

Link to comment
Share on other sites

Well, there are ways to lock the bar... but... you were looking for native Cannon API calls to do it.

There is also foolery.  Use a timer... and fake gravity on the box. 

Start with no physics on bar and box.

Add a call in scene.registerBeforeRender to moveBoxDownSmallAmount()...  check for intersect of box and bar.  When intersecting, scene.unregisterBeforeRender moveBox...().

THEN... turn-ON physics state for bar and box.

The box will not be doing a physics fall.  It will be doing a "physics fall simulation:)  Just another idea, probably not good.

-------------------

Another idea:   Using renderLoop... constantly monitor bar.body.angularVelocity... see if bar tilt is happening.  If found, null/zero it.  Perhaps only for short time... then remove that angularVelocity-checker from renderLoop. 

Keep experimenting.  :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...