Studio Physics Demo + Constraint Strings (+Mouse Grab)

link 2 blend is dead… was that on purpose?

In the link_constraints.py script of the Studio Physics Demo, two keys are referenced: ‘chain_cyclic’ and ‘chain_pitch’. I am trying to determine where these come from or how the values are initially set.

After a list has been created of all the objects included in a particular group, the list is sorted by object name, and then this code follows:

if ccgroup[‘chain_cyclic’]:
links.append(links[0]) # close loop

chain_pitch = ccgroup[‘chain_pitch’]

Using print(ccgroup.items()) reveals the following in the console window:

[(‘chain_pitch’, 0.725), (‘chain_cyclic’, 0)]
[(‘chain_pitch’, 1.75), (‘chain_cyclic’, 0)]
[(‘chain_pitch’, 0.375), (‘chain_cyclic’, 1)]

These would be with respect to the ConstraintChain, ConstraintChain.001, and ConstraintChain.002 groups. I understand why these are the values used (‘chain_pitch’ is the distance between two objects in the group, and ‘chain_cyclic’ must return True to close the ConstraintChain.002 loop), but I cannot find how these values are initiated and set.

This script is one of the first to run, and no other scripts reference these (as far as I can see). It also does not appear that link_constraints.py initiates or sets these values. This leads me to think they are some sort of custom group properties, but I do not see these in the UI anywhere.

Any thoughts/insight would be much appreciated!!! I feel like I’m missing something obvious :spin:

In the link_constraints.py script of the Studio Physics Demo, two keys are referenced: ‘chain_cyclic’ and ‘chain_pitch’. I am trying to determine where these come from or how the values are initially set.

After a list has been created of all the objects included in a particular group, the list is sorted by object name, and then this code follows:

if ccgroup['chain_cyclic']:
links.append(links[0]) # close loop


chain_pitch = ccgroup['chain_pitch']

Using print(ccgroup.items()) reveals the following in the console window:

[(‘chain_pitch’, 0.725), (‘chain_cyclic’, 0)]
[(‘chain_pitch’, 1.75), (‘chain_cyclic’, 0)]
[(‘chain_pitch’, 0.375), (‘chain_cyclic’, 1)]

These would be with respect to the ConstraintChain, ConstraintChain.001, and ConstraintChain.002 groups. I understand why these are the values used (‘chain_pitch’ is the distance between two objects in the group, and ‘chain_cyclic’ must return True to close the ConstraintChain.002 loop), but I cannot find how these values are initiated and set.

This script is one of the first to run, and no other scripts reference these (as far as I can see). It also does not appear that link_constraints.py initiates or sets these values. This leads me to think they are some sort of custom group properties, but I do not see these in the UI anywhere.

Any thoughts/insight would be much appreciated!!! I feel like I’m missing something obvious

@Aestatis: I was playing a while with the file “link_constraints.py”. I really like the way it makes the chains…

You wrote your last comment in march of 2016, but maybe there’s someone that it is wanting to know how to do a chain with this method:

  • Create an object like the chain-links in the demo (setting it to Rigid Body, setting the correct Collision Bounds type, etc)
  • Add this object to a group that starts with “ConstraintChain” (can be “ConstraintChain.new”, etc).
  • Duplicate with Alt-D (to make links).
  • Using Python Console, set two keys called “chain_pitch” and “chain_cyclic” to the group, like:
     bpy.data.groups["ConstraintChain.new"]["chain_pitch"] = 0.725
bpy.data.groups["ConstraintChain.new"]["chain_cycle"] = False
  • Start Game Engine.

All the links constraints are created at the beggining.

If “chain_cycle” is True, it means that the chain is closed. You can play with “chain_pitch” to set the links separation.

By looking at the code, I realized that there’re the functions to create ANY kind of constraint. Also, you can play with that! (I would like to know where these functions came from…)

Thank you very much, Phymec.

EDIT: there’s something that I would change in “link_constraint.py”: the way it select the bones by group and the values of “chain_pitch” and “chain_cycle”. BPY is not available with BlenderPlayer by default. I would put them in the first (or any) link of the chain as object properties, and separate the chains with the second part of the name (being “ConstraintChain” the first part, separated by dots). For example:

  • One chain: [‘ConstraintChain.metal.000’, ‘ConstraintChain.metal.001’, ‘ConstraintChain.metal.002’]
  • Another chain: [‘ConstraintChain.wood.000’, ‘ConstraintChain.wood.001’, ‘ConstraintChain.wood.002’, ‘ConstraintChain.wood.003’]
  • Etc.
    Now, I don’t have the time… but it is not difficult.