Constraint network questions
2066 2 0- AndyW
- Member
- 336 posts
- Joined: Dec. 2014
- Offline
I'm building a rolodex/flipbook RBD setup and I'm running into issues with constraint networks. I need to constrain the base of each card to a cylindrical shape, I'm guessing with a hinge constraint. When this anchor is rotated the cards hopefully will collide with each other and flip convincingly. I made a bit of a hash with the file I've posted, but you can kind of see what I'm going for. Any advice is super appreciated
- mestela
- Member
- 1737 posts
- Joined: May 2006
- Online
Cool idea, had to have a few stabs at it before it'd behave. It's likely some of the changes I've made aren't necessary, but it's in a showable state now, soooo…
The main thing I changed was how the constraint network was being created. It's created directly from the packed prims rather than the connect adjacent pieces sop, and the animation is only applied to the world constraint points (ie, those points where @name doesn't match to any of the packed shapes). Not sure if it's always done this, but I found if I animated everything the rbd results would get weird. It's as if because the entire constraint line is moving together, it effectively cancels out the animation.
I then made sure the restlength was a constant number, either 0 or very small. I made the mistake initially of using a convertline sop like I normally do, but that would just update the length of the stretching lines, so the constraints would basically say ‘oh, you want me to maintain my exact length which happens to be exactly the same as the current distance from the packed shape to the target? Ie, do nothing at all? Sure.’ Making it constant fixed this.
I also duplicated the constraints so they behave as if the cards are attached at 2 points. You could probably just use a single constraint per card and use the degreesoffreedom attributes so that they can only rotate around the shaft (@condof I think), but I find that fiddly to use; duplicating constraints is more intuitive for me.
Finally I cleaned up your dopnet so its all pretty much using default values. The constraint networks update every frame so they receive the animation, the solver settings are all standard, it solves pretty quickly and is stable. I added a pop drag too just to calm down the jittering a little.
-matt
The main thing I changed was how the constraint network was being created. It's created directly from the packed prims rather than the connect adjacent pieces sop, and the animation is only applied to the world constraint points (ie, those points where @name doesn't match to any of the packed shapes). Not sure if it's always done this, but I found if I animated everything the rbd results would get weird. It's as if because the entire constraint line is moving together, it effectively cancels out the animation.
I then made sure the restlength was a constant number, either 0 or very small. I made the mistake initially of using a convertline sop like I normally do, but that would just update the length of the stretching lines, so the constraints would basically say ‘oh, you want me to maintain my exact length which happens to be exactly the same as the current distance from the packed shape to the target? Ie, do nothing at all? Sure.’ Making it constant fixed this.
I also duplicated the constraints so they behave as if the cards are attached at 2 points. You could probably just use a single constraint per card and use the degreesoffreedom attributes so that they can only rotate around the shaft (@condof I think), but I find that fiddly to use; duplicating constraints is more intuitive for me.
Finally I cleaned up your dopnet so its all pretty much using default values. The constraint networks update every frame so they receive the animation, the solver settings are all standard, it solves pretty quickly and is stable. I added a pop drag too just to calm down the jittering a little.
-matt
Edited by mestela - Oct. 14, 2017 07:02:55
- AndyW
- Member
- 336 posts
- Joined: Dec. 2014
- Offline
-
- Quick Links