Games [XUI2D] connection force of joints

Gunther

Active Member
Licensed User
Longtime User
From the B2Box manual chapter 8.2 joint definition: "However, these initialization functions should usually only be used for prototyping. Production code should define the geometry directly. This will
make joint behavior more robust."

I will have a look into the included project and to set the parameters not via the initialization, if possible.

Soon.... Thanks so far.
 

Gunther

Active Member
Licensed User
Longtime User
Dear Erel,

I will try that way since the "revdef.BodyA = BodyA" doesn't work due tue the 'Read Only' setting.
 
Last edited:

Gunther

Active Member
Licensed User
Longtime User
I compared the project from post #18 with the last one.

Except of gravity (0,-20)->(0,-10) and restitution (0)->(1) and boxsize (7.5, 12.5)->(16, 22) and chain links (40)->(25) are no differences.

After equalizing - no change in behaviour (= still rubber band).

Not sure why :eek:

chain equalized.PNG
 

Attachments

  • Chain equalized to ropes project.zip
    202 KB · Views: 246

ilan

Expert
Licensed User
Longtime User
I compared the project from post #18 with the last one.

Except of gravity (0,-20)->(0,-10) and restitution (0)->(1) and boxsize (7.5, 12.5)->(16, 22) and chain links (40)->(25) are no differences.

After equalizing - no change in behaviour (= still rubber band).

Not sure why :eek:

View attachment 73725

i am at work and have not b4j so i cannot try it but why dont u try to create the boxes programmatically like i do in my project.
try to put the same settings and look for the result.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check the explanation here: https://stackoverflow.com/a/24823345/971547
iforce2d is the one who wrote the very good tutorials about box2d.

You can improve the simulation by increasing the iterations per cycle:
B4X:
X2.VelocityIterations = 30
X2.PositionIterations = 30

The higher you set it the more accurate it will be. There is a performance cost. Looks negligible in B4J.

Another thing that you can do to improve it is to add linear damping to all the rope elements:
B4X:
BodyA.Body.LinearDamping = 2
 

Gunther

Active Member
Licensed User
Longtime User
Well, I will try.

iforce2d wrote also that one should know what one is doing when changing that parameters.

Not sure if informatrix did the same adjustments in his wrapper but it looks working out of the box with his wrapper.

with the itreations set to 30 and BodyA.Body.LinearDamping = 2 (better any other than default) the simulation looks not that good any more.
 

Attachments

  • Chain with iteration 30.zip
    201.1 KB · Views: 249

ilan

Expert
Licensed User
Longtime User
Well, I will try.

iforce2d wrote also that one should know what one is doing when changing that parameters.

Not sure if informatrix did the same adjustments in his wrapper but it looks working out of the box with his wrapper.

with the itreations set to 30 and BodyA.Body.LinearDamping = 2 (better any other than default) the simulation looks not that good any more.

i have tried your last example (post #27) and i dont see any issue. the chain physics simulation looks fine. although i only changed gravity to -20 on the y axisbut even with -10 its fine. what are u trying to get?? do you have an example of what u want to get?
 

Gunther

Active Member
Licensed User
Longtime User
Dear Ilan,

yes, this is fine with the iterations settings proposed by Erel. Not sure so far the possible impact to mobiles.

I am wondering that informatix version looks as expected and the one from B4x is a rubber band style.
 

ilan

Expert
Licensed User
Longtime User
Ps: i forgot to mention that i also removed the loop in the tick event where u apply force to each box. No need for that.
 

ilan

Expert
Licensed User
Longtime User
Dear Ilan,

yes, this is fine with the iterations settings proposed by Erel. Not sure so far the possible impact to mobiles.

I am wondering that informatix version looks as expected and the one from B4x is a rubber band style.

U can use libgdx that includes box2d instead if u like more informatix result. And for b4i use spritekit.
 

Gunther

Active Member
Licensed User
Longtime User
Morning,

The b4x Version is fine for me. As said it is just testing around to see what I am able to do. Still beginning in the learning process.
And I saw that the result was not as expexted for a rigid chain looks like a rubber band and joints can easily rupped. Same in the 'Joint example' when tooo much donuts are on the bridge the joints will not hold the pieces in place.

I saw a very strange ragdoll behavior of my tests when the doll is hoding the hands and feets to something. If you aply a small force to the body and the arms and legs gets dismantled I thought what I did wrong with the revjoint?

I was then taking the chain since the small problem (3 joints only) of an arm will be may be more visible in a chain with much more links than 3 in a row.
 
Last edited:

Gunther

Active Member
Licensed User
Longtime User
Ps: i forgot to mention that i also removed the loop in the tick event where u apply force to each box. No need for that.
The force is only applied to the ball. If name="ball" then...

I think this has no influence on the main outcome.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I am wondering that informatix version looks as expected and the one from B4x is a rubber band style.
As I wrote, both jbox2d and XUI2D are based on the exact same code. The only difference is in the exposed API. The physical simulation will be exactly the same if you make the exact same settings. There aren't any adjustments in the wrapper.

The chain 'angle interval' in your project is set to 5. Set it to 1 for smoother movement.
 
Top