InteractiveComputerGraphics / PositionBasedDynamics

PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.
MIT License
1.87k stars 357 forks source link

How to rotate boundary model with mass == 0.0 #103

Closed lyd405121 closed 2 years ago

lyd405121 commented 2 years ago

I am learning your pbd and rigidbody simulaiton paper now, It is really awsome. But when doing my own rigid body simulaion with your lib, I found a question: I can not rotate the boundary model which has a mass value equal to zero, The boundry model seems not rotating at all

https://user-images.githubusercontent.com/16344694/136652014-2b37c7fe-4b66-4a3b-bdb8-0c487b8feb19.mp4

Then I change the mass to infinity:

https://user-images.githubusercontent.com/16344694/136652203-e058b832-92fe-46db-9411-598a327838f3.mp4

The boundry model rotating works, but looks not stable.

So how to setup the parameter of the boundary model , so I can rotate it. Try to modify the K matrix, not work though.

chenchenc45 commented 2 years ago

Sorry, When i test collision detection between sphere and cloth, This lib can't recognize the . obj file ( sphere) I imported from other software, like solidworks, 3Dmax. How do you get your own obj file can be recognized when collision detection? Thank you

lyd405121 commented 2 years ago

Sorry, When i test collision detection between sphere and cloth, This lib can't recognize the . obj file ( sphere) I imported from other software, like solidworks, 3Dmax. How do you get your own obj file can be recognized when collision detection? Thank you

可能没有三角化吧,因为这个开源代码里面obj解析没有适配polygon,默认是三角形。我的模型都是正常的,没有处理过,你自己找找输入模型的问题吧

janbender commented 2 years ago

Are sure that the obj file is a standard obj file (https://en.wikipedia.org/wiki/Wavefront_.obj_file)? Can you use data/models/sphere.obj? Alternatively you can use: "comment": "collisionObjectType = 1: Sphere, 2: Box, 3: Cylinder, 4: Torus, 5: SDF, 6: HollowSphere, 7: HollowBox", "collisionObjectType": 1,

chenchenc45 commented 2 years ago

Are sure that the obj file is a standard obj file (https://en.wikipedia.org/wiki/Wavefront_.obj_file)? Can you use data/models/sphere.obj? Alternatively you can use: "comment": "collisionObjectType = 1: Sphere, 2: Box, 3: Cylinder, 4: Torus, 5: SDF, 6: HollowSphere, 7: HollowBox", "collisionObjectType": 1,

Thank you very much, i will have a try to write a standard obj file accroding to your website . The files in your lib you provide are useful. But This lib can't recognize the . obj file ( sphere) I imported from other 3D software,

Sorry, When i test collision detection between sphere and cloth, This lib can't recognize the . obj file ( sphere) I imported from other software, like solidworks, 3Dmax. How do you get your own obj file can be recognized when collision detection? Thank you

可能没有三角化吧,因为这个开源代码里面obj解析没有适配polygon,默认是三角形。我的模型都是正常的,没有处理过,你自己找找输入模型的问题吧

好的,非常感谢解答,我网上搜索学一下,多尝试一下呢

lyd405121 commented 2 years ago

I solve it by reset the object position and oriention in every substep. And not using mass =0.0 for boundary handling, but set it a big value like 1e30 Here is the video

https://user-images.githubusercontent.com/16344694/140003141-8ec0b7f0-fcbc-4d11-a914-4042d45c762f.mp4

As I dive into the src cdde, I found lots of if condition is doing with mass != 0.0 So it is really unfriendly for boundary handling, I deside to rewrite the rigidbody sim

janbender commented 2 years ago

I don't really get your problem since the videos don't play in my browser. Setting the mass to 0 is a simplification to avoid another boolean value. Since a mass of 0 is anyway not defined in the simulation and would lead to infinite accelerations (a=F/m), it can be reused without problems.

Do you want to animate a rigid body? Something like that is not supported yet but should not be that hard to implement. First, don't use a mass of 0 since it is NOT a static body. Second, mark the body by some flag as being animated. Finally, avoid a position correction and time integration of the animated body.

lyd405121 commented 2 years ago

I don't really get your problem since the videos don't play in my browser. Setting the mass to 0 is a simplification to avoid another boolean value. Since a mass of 0 is anyway not defined in the simulation and would lead to infinite accelerations (a=F/m), it can be reused without problems.

Do you want to animate a rigid body? Something like that is not supported yet but should not be that hard to implement. First, don't use a mass of 0 since it is NOT a static body. Second, mark the body by some flag as being animated. Finally, avoid a position correction and time integration of the animated body.

Yes,I do exactly what you say,controll the key rigid body in every substep,it works. By the way, The video can be downloaded and played by some app like VLC-Player howToDownloadVideo