Library Linking Cloth Simulation Settings

I’m trying to link objects with cloth settings into scene files. If we do this presently we can’t access the cloth settings on linked objects. We can do a local bake of the cloth through a workaround explained here: http://comments.gmane.org/gmane.comp.video.blender.devel/34055
But we can’t even adjust the frame range. On Sintel they used python scripts to enable them to edit the cloth settings per scene even on linked objects, which would be really helpful, so I’m trying to find that script. (UPDATE: I found it. See post 2)

There’s some more context here in this bug tracker thread. I replied at the end because there’s actually a new bug (UPDATE: It’s fixed!) with the functionality in 2.69 where the bake button is grayed out even:https://projects.blender.org/tracker/?func=detail&aid=36382&group_id=9&atid=498

Anyone have any other solution to this working?

I think this thread was moved by mistake to the Modeling section, unless I accidentally posted there myself. This should be in the Scripts section or Python support, but either way definitely not Modeling.

An update: I found the script that was used in Sintel for this. (In Sintel production directory if you have the dvd it’s in pro->Scripts->modules->finals_config.py) Some of it, in an older version is also up on this mailing list: http://lists.blender.org/pipermail/durian-svn/2010-June/003875.html

It looks like they hard-coded 67 different presets for Sintel’s cloth sim alone, and there’s presets for each of the characters from the movie in the same file, along with hair settings and some other things. The script also sets up a preroll of a few frames for the cloth bakes as explained in this thread from the blog: http://www.sintel.org/production/wing-simulation-or-gaaaaaah/

It looks like the presets are then matched up with particular shots in the movie, also hard-coded into the script.

So this is not a workable solution for anyone.

Brecht got back to me and fixed the bug in current svn and also shared this code (or just expressions?) for allowing changing of the frame start and end:

ob = bpy.data.objects["SomeObject"]
cache = ob.modifiers["Cloth"].point_cache
cache.frame_start = ...
cache.frame_end = ...

I’m not at all familiar with python so I don’t actually know what to do with that. Would anyone like to help me out here?

Without being able to edit the settings to tweak things per shot it’s probably not going to be very useful so I’ll probably just append the cloth objects for this production, since getting the movie finished is my primary focus. However if I can reverse engineer some of this code I’d like to try to write something that would be more generic and user-friendly, and with enough interest could maybe be developed into a full-fledged add-on.

I think it could be setup to, instead of having to hard-code each of the settings changes, create an actual UI panel (or use the existing cloth settings panel if that’s possible) to input the values. And of course make it non-object specific so the script can work for anything.

Lack of linked cloth settings isn’t a showstopper really. But this would be nice to have for future productions as an add-on at least until library linking gets rewritten in Blender.

Is anyone else interested in this functionality?

I’m really interested in this functionality, I take this opportunity to ask you a question

I’m in your original situation: I can’t do a local bake for linked cloth stuff pinned to the character’s armature and I don’t know how to use the workaround that you linked
http://comments.gmane.org/gmane.comp.video.blender.devel/34055

in that page my stopper is the phrase: “You can access the bake buttons by setting the object buttons to ‘Pin’, then select the object from the dropdown below the pin button. … now you can switch the physics area and press bake.”

My questions are:

  • Is this solution still working with the 2.69?
  • Where I should set "the object buttons to ‘Pin’ " and then “select the object from the dropdown below the pin button.”?
    I tryed to substitute the object from the objects dropdown list with the cloth but it doesn’t seem to work

Any help is really appreciated!
Thankyou!

Sparazza

@sparazz: If you go to the Object properties in your linked scene, there’s a dropdown menu that allows you to select objects. Make sure the cloth object is selected. It’ll have an L next to it indicating it’s a linked object. Then you can click the little pin icon which will pin the object selected in the dropdown menu to the properties panel even if you select another object. Now switch to the Physics tab with the cloth bake settings and you should be able to press Bake.


Although in 2.69 it doesn’t look like you need to do any of that actually. It looks like you can just select the object and bake now.

The next part requires python scripting. You can bake, but only with the settings and frame range that were set in the original file. You can’t change those without writing a script with the new values.
Here’s a link where Campbell gives a more recent and thorough explanation: http://blender.stackexchange.com/questions/3251/how-can-i-bake-the-physics-cache-of-linked-objects

I can’t really help you with the scripting part because I’m not a coder. Because of the limitations I’m not even using this workaround. I’m just appending the objects in shot by shot and using tricks to minimize the cloth and particle animation needed.

I believe this functionality will be one of the things tackled with the new open movie, Project Gooseberry. Although I haven’t heard anything about this issue specifically, one of the targets is improving the asset management system, and “Efficient and high quality physics simulation systems (particles, hair, cloth, fur, massive animation)” is another, so I assume this will get looked at and fixed for the future. I can’t imagine choosing to make an entire feature without working this out.

I totally agree

Thanks! This helped a lot! I can’t figure out which is the pin option until you pointed out to me…

Now I can bake (with the 2.69 I can’t select just the cloth from the linked group, I need the pin workaround), my cache is saved into the folder of the main scene (where I link the library model): the “Disk Cache” option is enabled and the “Use Lib Path” is disabled… however, I cannot use the saved cache. Every time I close and reopen the scene file, the cache seems outdated, so if I wanna render, I first have to redo the bake every time… is there something that I miss?

Thanks again for your precious help

Sparazza

Yes, that appears to be the case that you have to re-bake every time you reload the scene. Like I said I’m not using this workflow. That could also be a “bug” technically speaking. You might try reporting it.

Just wanted to add my support for any addons or helpful scripts in this regard. Linking a character with cloth sim clothes is a pita, especially losing the cache on reload. Pretty much defeats the purpose of having it, and makes render farming no-go etc.

Bring on the library linking goodness please BF! :smiley:

Hi all,

I made a script for a member of our community. With this script you can change the cloth settings from a linked library. It is a quick script, but maybe someone else may find it useful.

You can use the script by copying it in the text editor of your blend file. Then set ALL of the settings in the script as you want them, because it will overwrite every single setting. Then hit “run script”. Some settings won’t changed instantly, but as soon as you mouse over de settings they will change.

As soon as you reload your blend file, the settings will change back. So you need to re-run the script every time you open you blend file.

I could make an add-on off it, with a gui, but as I don’t know if anybody is going to use it, I will wait with that.


#Script to modify cloth simulation setings from opbjects from Linked File
#Author: Mark van Dijk

import bpy

#######set the object you want to change cloth settings from, place the name between "s
# EXAMPLE: "My_Object"
objectname = "Cylinder"

#######Cloth Settings
QualitySteps = 5            #Quality of the simulation in steps per frame
MaterialMass = 0.3          #Mass of the cloth material
MaterialStructural = 15     #stiffness of structure
MaterialBending = 0.5       #Wrinkle Coefficent
DampingSpring = 5           #Damping of cloth velocity
DampingAir = 1              #Thickness of the air, slowing falling things
DampingVelocity = 1         #Help cloth to reach resting position faster USAGE: must between 0 and 1
Pinning = True              #Enable pinning of cloth vertices       USAGE: True or False
PinVertexGroup = 'Pin'      #Vertex group for pinning Vertices      USAGE: place groupname between ', use '' if empty
PinSpringStiffness = 1      #Pin spring stiffness
PrerollFrames = 0           #Start simulation a number of frames earlier to let the cloth set in

#Cloth Cache Settings
FrameStart = 1          #Frame on which the simulation starts.      EXAMPLE: FrameStart = 1
FrameEnd = 50           #Frame on which the simulation ends.        EXAMPLE: FrameEnd = 50
DiskCache = True        #Save cache files to disk                   USAGE: True or False
UseLibPath = False      #Use this file's path for the disk 
                        #cache when library linked into another file USAGE: True or False
Compression = 'NO'      #Compression method to be used              USAGE: 'NO' or 'LIGHT' or 'HEAVY'

#Cloth Collision
UseCollision = True         #Enable collisions with other objects
CollQuality = 2             #How many collision iterations should be done
Distance = 0.015
Repel = 0
RepelDistance = 0.001
Friction = 5
SelfCollision = True
SelfCollQuality = 1         #How many self collision iterations should be done
SelfCollDistance = 0.75
VertexGroupNoColl = ''    #Vertex group of vertices which won't collide USAGE: place groupname between ', use '' if empty
CollisionGroup = None       #Limit colliders to this group

#Cloth Stiffness Scaling
UseStiffnessScaling = False
StructuralStiffnessGroup = ''
MaxStructStiffness = 0
BendingStiffnessGroup = ''
MaxBendStiffness = 0

#Cloth Sewing Springs
UseSewingSprings = False
SewingForce = 0
ShrinkingClothGroup = ''
MinShrink = 0
MaxShrink = 0

#Cloth Field Weight
EffectorGroup = None
Gravity = 1
All = 1
Force = 1
Vortex = 1
Magnetic = 1
Wind = 1
CurveGuide = 1
Texture = 1
SmokeFlow = 1
Harmonic = 1
Charge = 1
LennardJones = 1
Turbulence = 1
Drag = 1
Boid = 1


################################################
### Don't change anything beneath this block ###
################################################

#setting the object, modifier and Cache
obj = bpy.data.objects [objectname]
Cloth = obj.modifiers["Cloth"]
ClothCache = Cloth.point_cache

#changing Settings
Cloth.settings.quality = QualitySteps
Cloth.settings.mass = MaterialMass
Cloth.settings.structural_stiffness = MaterialStructural
Cloth.settings.bending_stiffness = MaterialBending
Cloth.settings.spring_damping = DampingSpring
Cloth.settings.air_damping = DampingAir
Cloth.settings.vel_damping = DampingVelocity
Cloth.settings.use_pin_cloth = Pinning
Cloth.settings.vertex_group_mass = PinVertexGroup
Cloth.settings.pin_stiffness = PinSpringStiffness
Cloth.settings.pre_roll = PrerollFrames

ClothCache.frame_start = FrameStart
ClothCache.frame_end = FrameEnd
ClothCache.use_disk_cache = DiskCache
ClothCache.use_library_path = UseLibPath
ClothCache.compression = Compression

Cloth.collision_settings.use_collision = UseCollision
Cloth.collision_settings.collision_quality = CollQuality
Cloth.collision_settings.distance_min = Distance
Cloth.collision_settings.repel_force = Repel
Cloth.collision_settings.distance_repel = RepelDistance
Cloth.collision_settings.friction = Friction
Cloth.collision_settings.use_self_collision = SelfCollision
Cloth.collision_settings.self_collision_quality = SelfCollQuality
Cloth.collision_settings.self_distance_min = SelfCollDistance
Cloth.collision_settings.vertex_group_self_collisions = VertexGroupNoColl
Cloth.collision_settings.group = CollisionGroup

Cloth.settings.use_stiffness_scale = UseStiffnessScaling
Cloth.settings.vertex_group_structural_stiffness = StructuralStiffnessGroup
Cloth.settings.structural_stiffness_max = MaxStructStiffness
Cloth.settings.vertex_group_bending = BendingStiffnessGroup
Cloth.settings.bending_stiffness_max = MaxBendStiffness

Cloth.settings.use_sewing_springs = UseSewingSprings
Cloth.settings.sewing_force_max = SewingForce
Cloth.settings.vertex_group_shrink = ShrinkingClothGroup
Cloth.settings.shrink_min = MinShrink
Cloth.settings.shrink_max = MaxShrink

Cloth.settings.effector_weights.group = EffectorGroup
Cloth.settings.effector_weights.gravity = Gravity
Cloth.settings.effector_weights.all = All
Cloth.settings.effector_weights.force = Force
Cloth.settings.effector_weights.vortex = Vortex
Cloth.settings.effector_weights.magnetic = Magnetic
Cloth.settings.effector_weights.wind = Wind 
Cloth.settings.effector_weights.curve_guide = CurveGuide
Cloth.settings.effector_weights.texture = Texture
Cloth.settings.effector_weights.smokeflow = SmokeFlow
Cloth.settings.effector_weights.harmonic = Harmonic
Cloth.settings.effector_weights.charge = Charge
Cloth.settings.effector_weights.lennardjones = LennardJones
Cloth.settings.effector_weights.turbulence = Turbulence
Cloth.settings.effector_weights.drag = Drag
Cloth.settings.effector_weights.boid = Boid