I don't know if anyone is interested, but I have a video of my current progress:
https://youtu.be/-qHT1R8aXM4 Thanks! Luke On Tue, Jun 9, 2015 at 9:30 PM, Luke Magill <[email protected]> wrote: > Hi there! > > My name is Luke and I've been an amateur Blender user for a few years and > I love it! Recently, I had a cool idea where I wanted to try to emulate > muscles of the human body to create a more realistic style of animation. > This was mostly to satisfy personal curiosity and perhaps to create an > interesting new style of art. However, at some point I hit a snag where I > wasn't able to move forward. > > The problem can be summarized as follows: the built in soft body engine of > Blender is great, but what I really needed was to have more than one soft > body setting per object. This was to allow me to sort of pin different > things together, like pinning skin to muscle. Skin and muscle have very > different levels of softness but sometimes the skin and muscle for one > person may need to share points (be connected or glued together). What I > needed was to have one edge connected to a point with a certain push/pull > value and a different edge connected to the same point with a different > push/pull value (this is just an example, the idea is that any soft body > setting for which you can select a vertex group would be able to have > multiple settings). > > I couldn't figure out any way to do this or properly emulate this within > blender. True, there are ways to copy data from one point to another but > the soft body forces wouldn't transfer which would leave me with an > unrealistic result. > > To solve this problem, I decided to break open the internal C code to try > and add this capability myself. Now before I get into details I want to > tell you a little about myself. I got my bachelor's in computer science 6 > years ago and since then I have been a professional web programmer. The > vast majority of my experience with programming has been c#/Java and > scripting languages like PHP/Python, etc. I also do front end stuff like > html, css, and javascript. I don't have a lot of experience with very low > level code like c or c++. However, I'm always eager to try new things and, > to be honest, I was surprised at how approachable the blender code base > was! In any case, please be patient with me if I have any trivial > misconceptions about c coding. > > This email/document is meant to be a project proposal and specification. I > will include as many details as I can and I invite everyone and anyone to > provide feedback and criticism. > > Feature Description > > This section describes the feature without discussing any implementation > details. Implementation will be covered in the next section. > > In general, blender soft body settings can be split into two different > groups, general settings and vertex group specific settings. The vertex > group specific settings allow you to select a vertex group (or no vertex > group indicating all vertices) to apply the settings to. All vertices not > part of the specified vertex group will not have the settings, and will not > be part of this animation. This has a disadvantage if you are trying to > simulate heterogeneous soft bodies for which part of the body may have > different settings than another part. > > To alleviate this problem, I propose allowing MULTIPLE soft body settings > for the vertex-group type of setting. For reference, here is a list of the > different settings associated with vertex groups > > Vertex Group Specific Settings: > Soft Body: Friction, Speed, Mass > Soft Body Goal: > Goal Strength: Default, Minimum, Maximum > Goal Settings: Stiffness, Damping > Soft Body Edges: > Settings: Pull, Push, Damp, Plastic, Bending, Length > Stiff Quads: Stiff Quads, Shear > Aerodynamics: Simple|Lift Force, Factor > Collision: Edge, Face > > All of the remaining settings are general settings and will not be > affected by this change. > > The question naturally arises what will the soft body settings be of a > vertex that is a member of multiple groups? If we imagine trying to emulate > jello that is very jiggly on one side but rigid on the other with a smooth > transition, the most intuitive way to do this would be to have a "rigid" > vertex group and a "soft" vertex group. Then using weight painting, you can > smoothly transition between the two groups to create a nice effect. > > To enable this, we institute the following rule: a vertex's specific value > for any setting listed above will be the weighted average of all of the > settings for all of the vertex groups that apply to it, including the "all > group" if there is a setting for that. > > Now let's talk about how the UI will enable the user to control this > feature. There are already multiple examples in the blender UI of having a > list of settings that the user is allowed to modify on a per-item basis. > Some examples are render layers, textures and materials. The soft body > settings will work the same way. > > First, we will move all of the General soft body settings to the top so > that the user does not get confused thinking that it applies only to a > vertex group. Then, we will have a list selector. For an example list > selector, see the render layers list selector. In the list selector panel > there will be a vertex group selector so that each item in the panel can > have a vertex group. The only change in the UI to the vertex group specific > settings panels will be that they will no longer contain individual vertex > group selectors. > > Required Code Changes > > This section describes what I will be changing to enable this feature. The > DNA, RNA, and Python UI features will be modeled after existing list type > code that exists within blender, particularly the RenderLayer object. > > DNA changes: The settings associated with the aforementioned Vertex Group > Specific Settings will be removed from SoftBody (DNA_object_force.h) and > added to a new struct called SoftBodyVertexSettings. The > SoftBodyVertexSettings will be a linked list, in which the first element > has a *prev and a *next link (based on ListBase linked list). Methods will > be added to softbody.c called SoftBodyVertexSettings_add() and > SoftBodyVertexSettings_remove() to add and remove items to this list. These > _add and _remove functions will be similar to BKE_scene_add_render_layer. > > RNA changes: These new DNA changes will be exposed through RNA. In > renderlayer, these are exposed through SCENE_OT_render_layer_add and > rna_RenderLayer_new. I will create two similar functions to expose my new > DNA. All of the RNA which currently modifies the "Vertex Group Specific > Settings" will have to be changed to modify the RNA for the currently > selected setting, rather than trying to modify the SoftBody itself. > > Python UI changes: Again relying heavily on RenderLayers as an example, > RENDERLAYER_PT_layers class is responsible for showing the list selector > panel in the UI and RENDERLAYER_UL_renderlayers is resonsible for setting > up the individual items in the selector table. I will have to add similar > classes for soft body and also a vertex group selector to this panel. > > Softbody.c changes: The most extensive changes will have to be made to > this file, because this is where the soft body settings are actually used. > In general, the soft body system works by converting a soft body setting > and a mesh (or lattice or curve) into a set of BodyX objects: either > BodyPoint, BodySpring, or BodyFace. These objects contain the information > required to compute each step of the SB animation. > > To make soft body have multiple settings, each individual item of these > will have to be expanded to contain more information. To pick an example, > inspring (pull in the UI), is currently only stored in the SB object > itself, like this: > iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants > function */ > > In the new system, BodySpring would have to have it's own inspring, so > this line would look like this > iks = 1.0f/(1.0f-bs->inspring)-1.0f ;/* inner spring constants > function */ > (It's somewhat confusing, but sb in this function is SoftBody and bs is > the BodySpring) > > In addition to utilising these new fields in computation, I would have to > actually add methods for converting the soft body settings into a set of > BodySprings. This will be done using an averaging algorithm described above. > > Filesystem changes: I haven't researched this yet but since I will be > removing items from the DNA I will need to make changes to the file > read/write systems both so that the new setting system can be saved/loaded > but also so that legacy soft body systems can be dealt with in a reasonable > way. I am hoping to write the core parts described above first, as a proof > of concept, before delving into details like how these settings are to be > saved. > > Conclusion > > Thank you for reading my proposal. At this point I would appreciate > criticism but I'm also kind of fishing for interest in this feature. If I > were to implement this would it be possible to have the change integrated > back to main? I would like to contribute this new functionality if possible. > > Thanks! > > Luke > _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
