Jump to content

Physics - Hinge - Bridge


ian
 Share

Recommended Posts

@RaananW

 

Hi all,
I have some simple playground. I would like to try set up purple Bridge and red Hinge, like physics hinge joint.
I create this little scene with blender and export it with exporter 5.0.5.

Here is a playground (in comment there is also .blender and .babylon file)
http://www.babylonjs-playground.com/#MBFUI#22

Can anybody explain me how to set things right. 
Origion/Position of Hinge (cilinder) is in center of object HInge.
Origin/Position of Bridge is in center of the bottom face of Bridge.

I would like that Bridge should be vertical above Hinge. And when ball hit Bridge, the Bridge should fall down like real Bridge. 
I would like that pivot of Bridge should be at point of Bridge's origin/position. (or maybe origion/position of Hinge/red cilinder).
Axis is x-axis.

I really don't understand things?
I spend all day on this example.
If I understand right, I should Use HingeJoint. (Or should I use Hinge2Joint) ? 

mainPivot: ( I think this should be center/position/origin of Hinge 
connectedPivot: ? I don't understend why and what to set
mainAxis: (I think should be x-axis (red Hinge object)
connectedAxis: ? I don't understend why and what to set

Can anybody explain connectedPivot and connectedAxis ???

 

greetings

ian
 

Link to comment
Share on other sites

If we set joint like that. It is better but still problem. Bridge is rotate in the wrong direction. 

So mainPivot is (0,0,0) because Origin of the bridge is in center of the bottom face. MainPivot is in Local coortinate of Bridge. Y size of bridge is 20. I set connectedPivot on half of 20, so 10.
But don't understand why?
I don't know if there is any problem with blender or exporter, or my mistake in blender (ctrl a - rotation/scale/position). I think I use scale and rotation on bridge. But as I know physics should have objects scale (1,1,1) but ROTATION I'M NOT SURE WHEN TO USE IT OR NOT IN BLENDER(ctrl+a -> Rotatioon). 

And why physics of bridge doesn't work? 

 

mainPivot:  new BABYLON.Vector3(0, 0, 0),    //  hinge.position  (world coordinate of bridge origin is {X: 0 Y:-0.0119 Z:1.4725}. ORIGIN OF BRIDGE IS NOT IN THE CENTER OF BRIDGE
connectedPivot: new BABYLON.Vector3(0, 10, 0), 
mainAxis: new BABYLON.Vector3(1, 0, 0),
connectedAxis: new BABYLON.Vector3(1, 0, 0)

http://www.babylonjs-playground.com/#MBFUI#21

 

Link to comment
Share on other sites

How babylon colliders works? If we have Box and origin/pivot of Box is not in center of Box, but somewhere else. Is then collider shifted? Or is Box Collider like Box bounding?
Can anybody explain how this things works?

API of Babylon shows
new HingeJoint(jointData) and  

jointData of type PhysicsJointData 

PhysicsJointData (But can't find how this Type looks like? Which arguments can set in PhysicssJointData and what this arguments are for?)

Are here 2 different APIs One I Babylon interface API and than Cannon.js API ??? Should I use cannon's api or babylon's ???

 

Link to comment
Share on other sites

Hi Ian,

I have no idea why (and this should be debugged), but your exported scenes always have weird physics integration. When canceling the joint you added, the ball that hits the wall should cause the wall to collide against the two boxes. It should also free fall until the end of times. But it doesn't.

Here - http://www.babylonjs-playground.com/#MBFUI#2 . 

I asked you once, but never got an answer. Do you have any idea why this is happening? how are you exporting the scene? Have you tried doing that with simple boxes and spheres created by babylon?

 

About main, connected, axis and pivots - you currently can't debug it easily. it is experimenting and understanding what they mean. I started documenting, but it will be helpful for you to actually read the cannon and oimo documentation, you will probably find some answers there.

Link to comment
Share on other sites

exactly.  PROBLEM IS IN BLENDER MODEL AND THEN EXPORTED BABYLON MODEL!

The problem is because bridge have origion in center of its lower faces !!! THIS IS THE PROBLEM !! THEN BOX COLLIDER OF MESH IS SHIFTED AND IS NOT AROUND BRIDGE !!!
If we change origin of Bridge in center of bridge. and then bridge's mainPivot = -bridge.height/2. Than It's work OK!
 

Link to comment
Share on other sites

  • 9 months later...
On 9/19/2016 at 4:39 PM, adam said:

You need to fix the center position of your bridge.  I added a test box to show you where the center is.  

http://www.babylonjs-playground.com/#MBFUI#3

Applying the position of the bridge mesh in Blender might fix the issue.

fix URL to gihub .babylon file 

http://www.babylonjs-playground.com/#MBFUI#19

Link to comment
Share on other sites

On 9/19/2016 at 4:28 PM, RaananW said:

Hi Ian,

I have no idea why (and this should be debugged), but your exported scenes always have weird physics integration. When canceling the joint you added, the ball that hits the wall should cause the wall to collide against the two boxes. It should also free fall until the end of times. But it doesn't.

Here - http://www.babylonjs-playground.com/#MBFUI#2 . 

I asked you once, but never got an answer. Do you have any idea why this is happening? how are you exporting the scene? Have you tried doing that with simple boxes and spheres created by babylon?

 

About main, connected, axis and pivots - you currently can't debug it easily. it is experimenting and understanding what they mean. I started documenting, but it will be helpful for you to actually read the cannon and oimo documentation, you will probably find some answers there.

fix URL github .babylon file

http://www.babylonjs-playground.com/#MBFUI#20

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...