Hello, and time for another patch (or two) a day!
I’m exploring the jit.phys.multiple system, and particularly the use of constraints and impulses within the multiple set. My first patch – AngryHuddle – I pay homage to the complete anarchy that has become of the NFL (National Football League) with the use of replacement referees. Not only are players fighting their opponents, but they’ve begun fighting each other as well. I’ve created a simple “huddle” of 11 spheres, each constrained to an overhead 6dof that keeps them in place, with impulses that cause them to “knock heads” every once in a while.
Two important points in this patch: first, the use of the @name attribute to give names to the individual bodies that are then used by the jit.phys.6dof object. By giving the name “hangers” to the multiple set, I can access bodies with a ‘hangers_n’ name, where n is the body number (starting at 0). If I was using a 2-dimensional array for multiple setup, I would use ‘hangers_x_y’ to access the row and column of the multiple set. This gives me the ability to directly access the individual bodies by my constraints.
The second interesting feature is the use of a force matrix to impulse individual bodies. This is done by creating a matrix with a single force entity, then turning it off (by zeroing out the matrix) 100 ms later. In this way, I can have the random objects properly select and pulse one of the objects, rather than impulsing them all (which is what happens when we sent an impulse message to the jit.phys.multiple).
The jit.phys.multiple can also have an embedded constraint, where these constraints are automatically connected from body to body within the multiple set. With his permission, I am including a patch by forum user matmat (Mathieu Constans): the NurbsSheet patch, which shows a simple use of 6dof constraints within the multiple set, and using nurbs rendering to create a cool, smooth sheet-in-the-wind model that is mesmerizing to watch. You can see how using a multiple-constraint makes patching a lot simpler; as long as body-to-body constrains are what you want, you will find it much easier to accomplish using the built-in multiple mechanism.
Enjoy the patches, and enjoy the series!
Sep 19, 2012 at 4:14pm #232264