Monthly Archives: September 2013

Grab Zones

One of the features of the new version of the Cloth Deformer is Grab Zones.  Interaction with hands and other moving objects that need to grab the cloth can be faked by using a spherical zone(s) at the start of the simulation to grab any number of vertices of the cloth.  When the grab object is moved the held vertices move with it to maintain the same local position in the zone, so they rotate as well as translate.


This animation shows a Michael 5 figure for Genesis trying to get attention by waving a slightly ripped t-shirt.  The cloth was given 4 seconds of animation to drape before starting to wave it about.  Some proxy objects were used on his arms and hand to prevent any possible collisions with him and get a very fast simulation result.  The shirts self-collisions all work well – but moving at that speed it’s hard to see any poke-thrus anyway.

In future I’d like to be able to have the grab zones turn off somehow to release their held vertices.  Also to be able to grab vertices during the simulation would be important.  That will be easy to code but a special ‘zone’ primitive is something I’ll need first so that it can have the right on/off switches in the properties interface.

Genesis 2 in a Long Green Dress

More demanding simulations, such as a full length dress, push my plugin to its limits.  That doesn’t mean it can’t get results though.  While also trying out Carrara 8.5’s stability with a Genesis 2 figure this simulation took about 2 hours to run, allowing about 5 seconds to go from a zeroed pose to being seated and then drape.  Again it is the still image that I am very happy with here, worth spending some extra time to do a little embroidery on the dress.


What is hidden in this render is that the collar of the dress sort of broke when the character’s neck bent.  The bent elbow is also a dangerous area for any practical simulation because the cloth can end up with nowhere to go.  Use of simple primitives under the skin is a good safety precaution.  Unlike certain other simulators, when mine goes wrong it doesn’t end up in a disaster.

The current code looks at all of the possible collisions of a thick vertex with an assumed convex surface – an elbow pit or neck is a concave surface.  The treatment of more complex surface interactions is what I hope to code next.  When viewed as an animation the fabric actually twitches a lot between frames, here and there.  If the surface collisions can be processed with more consistent results this should diminish.  With simple primitives there is never any twitch.

The arbor prop was not used for collisions, a few cubes were placed into the scene and then hidden for the bench seat and arm rest.

The conforming hair is not dynamic but morphed to get it out of the way for the render.  Such a hair style could possible work with draping too.  The simulation can handle layered cloth over cloth.  Internal cloth to cloth collisions are still treated as particle to particle hits to push them apart.

What is also on display here is the new Subdivider plugin.  You can get this in my Laboratory to try out.  It implements Loop(s) subdivision which is optimized for a triangular mesh.  Carrara uses Catmull-Clark subdivision which works with quads.  The Subdivider can be applied at the end of the Modifier stack when the simulation is finished to get 4 times the facets while smoothing out the cloth.

My plan for the plugin was always to expect that where it was to fit the figure’s torso to keep it as a conforming actor then allow for dynamics when it came to capes and dresses etc.  Again this simulation example did break but maybe the next version and my theories about concave and convex surfaces will work…The good thing now is that with the simulation timeout problem fixed I can run many more of them than before.

Time Killer

As I started to try out more complex simulations with full figures and drop cloths and costumes a serious issue with the Cloth Deformer emerged.  A task switch in windows or a screen saver timeout would totally kill the simulation.  The only way to keep it going was to start the simulation and then make sure to give the mouse a shake every few minutes.  If I was away for too long then hitting escape to stop the simulation would immediately bring up my blank screen saver letting me know it had died.

I could not find an answer or get much help with this and had to try and carry on without being able to run longer simulations then walk away or leave them overnight.  I had to be there at the desktop or nearby and keep an eye on the clock.

I was looking for a solution in the wrong places and wasting precious time too.  I assumed it was a Carrara SDK issue and that I was doing something wrong.  It was really only when I noticed that after running a big demanding render on multiple cores that upon returning to a word document, after leaving it open on the desktop untouched for an hour, that as I typed there was no response to my keystrokes.  After more than a few seconds I could start to type okay.

So I seem to have finally understood and hopefully fixed this problem.  Windows is deciding that despite it working hard and doing millions of calculations that my simulation is not important or not responding and then making it, or the system, idle after a certain time period.  Only by calling WINAPI SetThreadExecutionState(…) with the right flags, very frequently, in all of the simulation loops, can the plugin now be left to run on its own.

Simple Cloth Deformer

Once again I’m going to attempt to continue my work on a Cloth plugin for Carrara and release a new version.

I’ve been working on and off on this project for the last few years (mostly off)…

Where I left off in 2011 the released plugin worked with fast primitive draping and collisions.  These results were very reliable for a proxy figure covered with cylinders, spheres and capsules, also with floors, seats and stairs using scaled cubes and planes.  The problem was that the underlying primitive shapes would show through.

I had higher hopes for the Bullet Softbody physics simulator added to Carrara 8 but I’ve never been able to get any sort of reliable results from it to match my own amateurish attempt.  I also held out working on my own code for the release of a stable version of Carrara 8.5.

I picked up the project again in early 2013 and tried out lots of ideas but the best results started to come from testing the collision of thick vertices against facets.  I then realized that the flaw in this simple method was that too many face hits were occurring and that I needed to find the best surface collision.  It was at the corners or bumps, such as a knee, that things were obviously going wrong.

Cloth Simulation

Cloth Simulation

This simulation uses code that treats all of the possible detected collisions as though they were part of a convex surface.  The figure uses a DAZ Genesis character with the model’s subdivision level set to 0, which gives a low and manageable polygon count.

Animations were okay but rippled and twitched over the mesh surface where they would slide smoothly over a primitive volume.  Once I started to get results like the above for still images I was already exceeding my own demands, but I wanted to keep trying to push it just that bit further.