Soft Body Object -Attach vertexes using Groups/Weight OR an easy way to create Joints

Hello there!

I want to use softbodies to make jiggly/wobbly boobs for my human characters :wink: and I need a practical way to “pin” some vertexes of the objects. I could make a Rigid Body Joint for each of them, but that would take days because they aren’t low-poly and I need to pin a bunch of vertexes otherwise the physics looks strange.

Any way to do that? Like a script that allows me to add RGJ using the mouse to move the pivot, or some way to make vertex groups pinned.

Thank in advance.

Thanks, but I’m no genius. Oh, and try to stay low-poly with soft-body objects - they eat up a lot of FPS, even without being high-poly. I’m not sure about how to optimize this - even getting a high-poly mesh to be a ‘proxy’ to a lower-poly soft-body shape isn’t exactly possible… Perhaps you could make a series of control points for the soft body shape, and then split the graphical representation up into separate pieces and move them to be where the vertices of the soft body shape are…

EDIT: It currently creates a pivot for each vertex in the controller object for each vertex in the soft body object. I’m not sure if this has a bad effect on performance or not (I could make it so that it will only create a pivot for controller object vertices within a reasonable (adjustable) margin from each soft body vertex).

here: http://youtu.be/cJeFE2eVuag

A video showing a preliminary version of the bouncing boob feature :).

Oh, my bad. I thought the softbody modifier worked in the game engine for some reason.

I had seen that bouncing belly tutorial before a while ago, but I actually forgot about it. Nice one SolarLune for scripting an implementation of the pinning algorithm. :slight_smile:

There is an alternative that has occurred to me that probably produces less “squishy” looking breasts but will stil give them bounce and should be a lot more efficient than softbodies, but it will take a bit of work since no part of the setup process is currently automated.

  • Create bones for each of the breasts, parented to the chest bone.
  • Create an invisible non-colliding object that is bone parented to the chest bone.
  • Create rigid body objects for each of the breasts and connect them to the bone parented chest object using rigid body joints.
  • Create copyRot bone constraints for each of the breast bones so they copy the rotation of the rigid body objects.
  • Now you need to set spring parameters to the rigid body joints, but this can only be done at runtime through Python using the setParam function of the rigid body joint constraint.

This should use the springy rigid body joints to drive the breast bones so that they bounce. Since it requires only two rigid body joints and two bone constraints it should be a lot more efficient than a softbody.

See http://www.tutorialsforblender3d.com/GameModule/ClassKX_PyConstraintBinding_1f.html for information about the 6DoF joint and the setParam parameters. The code is for Blender 2.49, but if you make adjustments to the 2.5x syntax (such as using bge.constraints instead of PhysicsConstraints) then all of the functions and parameters are still usable.

Edit:

Forgot to say, That’s a sweet looking test, Repgahroll. :slight_smile:

Thanks FunkyWyrm.

I think the bouncing belly tutorial was not for the game engine… at least the one i saw some time ago wasn’t.

Your alternative is a good one but I need something that interacts with the environment, like when she’s hiding behind a wall facing it, or hugging someone, the boobs should interact :slight_smile: I already tested it and after increasing the physics refresh rate and configuring correct collision bounds and margins to the objects the thing works perfectly. No tunneling at all.

Also, the thing has to be real-time because when she shoots the recoil should make the boobs bounce, and a lot of actions also, like jumping, running, etc. A bone could do here, but I want a lot of ‘wobbliness’ that would be hard to do with bones.

@SolarLune: You script is amazing, but i couldn’t figure out a way to disable collision between the linked objects… i see that after the angles parameters there’s a “flag” parameter (int) but i’ve played a lot of it and it seems to have no effect. (http://www.blender.org/documentation/blender_python_api_2_59_0/bge.constraints.html?highlight=createconstraint#bge.constraints.createConstraint)

Thanks :).

The thing with using bone constraints to copy the rotation of rigid body objects is that the rigid body objects handle all of the physics, including collisions and character motion. The bone is animated in real time by the physics object. The bone animation deforms the mesh. So the physics objects that are moving the bones will react with the environment much as you want them to, including collision and realtime reaction to the motion of the character. Think of it as a partial ragdoll with the character animating using actions, but with rigid body objects stuck to the character’s chest and responding to the actions of the rest of the body with physics.

This sounds like quite a long way around, but rigid body physics is highly optimised, bone deformation of meshes is highly optimised and bone constraints are quite efficient. Contrast this with calculating the stretchiness and forces of all edges in the softbody mesh and the efficiency savings are quite clear.

Having said all this the efficiency comes with a price. You need to set the system up to work as you want it to. This involves handling a lot of different objects and settings compared to the softbody solution. If you only want dynamic breasts on a single character then softbodies are a good solution that is fast to implement. If you want an Amazon Warrior army then softbodies might be too expensive in processor cycles. Only you know what the demands of your game are going to be.

Most important in a hobby project is to have fun and don’t let details bog you down until you find yourself up to the waist and need to look for alternative solutions. :slight_smile:

Hmmm. Interesting. It’s like creating collision points to deform the mesh. Very interesting.

Is there a way to disable collision between two (or more) specific rigid bodies (like a group)? If yes, then I might be able to use this technique instead of soft bodies.

Thank you.

I don’t believe there is, but Kupoman was working on something like this in his GSoC branch… Which still hasn’t gotten merged… :I

Okay.
So I need to know how to disable collision between objects sharing the same rigid body joint for the joints created with python.
Thanks.

You can disable collision between objects linked by rigid body joints by hitting the “linked collision” button in the constraint panel. Alternatively specify the number 128 as the last parameter when creating the constraint using Python.
http://www.tutorialsforblender3d.com/GameModule/ClassKX_PyConstraintBinding_1f.html

Oh, the flag number is 128… I thought it would be something like 0 or 1 :). Thank you. It’s a pity that site isn’t updated for version 2.5 though. The documentation for the GE is a problem…

Also, I couldn’t get a working result after reproducing the steps you posted on #7.

Say for example, i want a cylinder mesh with 2 bones that bends on game engine… How can i link the individual bones to different objects?

Thank you.

Nevermind…
Single armature, Bone Constraints (Pose Mode to create), Game Logic: Always>And>Armature(Run).
Thanks.

I just finished putting it together as a personal exercise and find you’ve sorted it. Lol.

At least I’m not gonna have to explain how it works. :wink:

Oh well. Here’s my *.blend anyway:
Bouncing_boobs_rigidbody.blend (88.3 KB)

Nice one FunkyWyrm. Amazing.
Blender really needs some easy graphical way to add joints though, some point&click interface updated and accessible. Entering numbers to determine the joints positions is absurdly obsolete, but doing everything through script is even worse imho.

New version using rigid bodies (much faster). http://youtu.be/lNDs66HdhLI
Thanks FunkyWyrm.

@Repgahroll: Nice test video. You’ve managed to get it working really well :slight_smile:

I agree about the lack of gui for the 6 degree of freedom rigid body joint linear/angular springs and motors. When the joint is added you can toggle the joint to be visible which helps with setting it up.

Rigid body joint constraints can be added from the constraints panel, but the options are limited. Also, I haven’t found a way to obtain a reference to a constraint from within the game unless the constraint is actually created in the game. This means that the joint can’t be added from the constraints panel and then have parameters set from within the game. Everything has to be done within the game using Python if you want to make use of springs or motors.

I’d have a go at implementing these features myself, but my knowledge of C and C++ is pretty much at the level of “hello world” and the implementation is probably not going to be straightforward. Blender’s rigid body data structure would need to be updated to allow for the new parameters, the convertor would need to be updated to convert the additional Blender data into bge data and the ui would need to be scripted in Python, and Python bindings would need to be added to the api for all the relevant functions.

It’s mainly an issue of data management though since the joints are fully supported in the game engine, but there’s just no way to define parameters from the gui.

Perhaps you could make a function or a class to do this / set up a constraint in this manner, Funky. It could run in a single line of code, or be a class that you can modify the values for, e.g.

obj['dof'] = Funky.DOF()
obj['dof'].maxrot = [15, 0, 0]
obj['dof'].apply() # May be necessary, since you've got to set the physics constraint's settings to be this, and then apply it (create the actual usable constraint)

You could also expose the necessary variables out to the end user through object properties, even checking to see if these properties exist first, and if not, using default values.

EDIT: If you make a class, you can store the returned constraint ID (?) in the class in a variable.

SolarLune, that’s a really good idea.

A list or dictionary on game objects obj[“constraints”] could be used to store instances of the class and the class could have properties that contain the joint name, type, reference, etc. and expose methods that allow for changing the parameters in a more intuitive way rather than using many obscure setParam(val1, val2, val3) commands.

I’m currently thinking through a more object oriented approach to my ragdolls addon and having a custom class for the joints would be a good addition to this since many rigid body joints will need to be created and stored, and possibly broken.

In my addon, I read the available parameters from the constraint data set in the gui. I then write all the joint data to a text file. At runtime I then read the text file in order to recreate the joints at runtime using this data, but my implementation is a bit messy and this information could be used just as easily to create instances of a class. I don’t use springs or motors, but spawning objects connected by rigid body joints breaks the joint so I still need to have the data available in order to recreate the joint.

It’s unfortunate that object properties set in Blender are not transferred to bge so the external data file is required.

Hello all,

Found this thread looking for a solution same as Repgahroll (not boobs but long hair and some cloth…) and SolarLune your SoftBodyPin function is awesome. Once I mostly recovered from my flu I played around with it a bit and experimented with making it only create pivots at specific vertices. I made a duplicate of the mesh I wanted to pin, vertex painted the appropriate verts full red and the ones to be excluded full blue. The changes I made look only for verts on the duplicated mesh (that you hide during the game) that have a high red value and make the pivots at those points only. Dunno if it saves anything performance wise but I thought it should be contributed back for anybody else who wants it. (And my python is still crap since I’ve only been dabbling in it a bit so if anything is odd… oh well.)


def SoftBodyPinSelective(softbodyobj, vertselectobj, controls):

    vsmesh = vertselectobj.meshes[0]
    softid = softbodyobj.getPhysicsId()
    ctype = 2 # Constraint type, 1 = edge; 0 = point, 2 = angular?
    for c in controls:
        cid = c.getPhysicsId()
        for v in range(vsmesh.getVertexArrayLength(0)):
            vert = vsmesh.getVertex(0, v)
            if vert.r > 0.9:
                vpos = vert.getXYZ()
                constraints.createConstraint(softid, cid, ctype, vpos[0], vpos[1], vpos[2], 8, -1, 0.5)