Cloth2 updated

My original post on this work has more examples and a screenshot if you didn’t see it.

I updated my version of the topix cloth python interface and uploaded a new example video.

If someone compiles the module for windoze or OSX or other blender platform, let me know and I’ll get them into the .zip file.

EDIT: removed temporary links while stephern2002’s server was down.

Example4.avi - shows a cloth dropped onto a stairs and blowing down it. This is a complete hack now, but a reasonably effective one and reproducible. 1.5M download.

Cloth2.zip is smaller now at about 1/2 a meg. I removed the vks from it as I couldn’t include all of them with the file at 15M and my web space is limited to 5M. Looking for more web space now, :-). The source code and Makefile are in the .blend file within the .zip. Compiled modules for linux i386, p4 and athlon are included. READMEs, HOWTOs, Changelogs, etc are both in the .blend and in the .zip.

EDIT: The initial cloth2.zip file had a pentium4 compiled topixmodule.so in it, it now contains an i386 compiled topixmodule.so and should work for all linux intel and amd based blenderheads. Sorry for the inconvenience.

The original file is still available, but has NOT been updated. Its only interesting if you can’t run the simulator and just want to see the animations on your screen or render them. Its likely to disappear sometime in the not too distant future.

The most significant user visible changes to this release are:

  • removed 100 frame limitation by using RVKs and guiding user to convert those to absolute VKs as it can’t be done with python yet.
  • faces are now supported by generating vitual spheres, this is just a temporary hack to test viability of some other internal changes.
  • memory leaks are less, but still there. eventually, they will be eliminated.
  • added a few more options for controlling the simulation and exposed them in the UI.
  • Initialize is gone and Run Simulator does everything.

Other changes are from the changelog:

First round of C code cleanup, both readability and some
refactoring of some handling of the python references.
Hopefully, there’ll be fewer memory leaks now, although I
expect many remain as of yet. Its hard to tell with the
memory though because of garbage collection. I’m trying
to force some now in the python code to see if that stops
the heap size of the blender process from growing ad
infinitum.

Changed from adding absolute vertex keys to adding relative
vertex keys in the python code to get by the 100 frame limit.
this works pretty well, although it means the user must
hand edit the IPO themselves as python can’t do that yet
for vertex speed IPOs.

Eliminated the Initialize button as the only thing to
do after that is to run the simulator, all other actions
require you to re-initialize.

Started laying the structure down to allow for more types
of collision detection.

Exposed the collision object radius size multiplier as
a new setting in both the module and UI.

Added the ability to control the first frame vertex keys
are inserted. This allows you to pre-roll the cloth
simulation so the cloth reaches the desired state before
vertex keys are inserted.

Added support for generating spheres from faces and performing
the collisions against those.

Things that have to happen:

  • Memory leaks must be eliminated. The code is now much cleaner, hopefully a final cleanup of the code and some reworking of the internals will take care of this issue.
  • Look at the long term affects of doing the animation via the VKs, its likely that other methods of storing the result or allowing for a render time simulation may be much better methods. VKs do have some interesting benefits though, like being able to loop and abuse the other IPO/blender animation features.
  • Find someone to compile the module for non-linux x86 platforms.

Things that are under consideration:

  • Examine building a general frame work for effects/simulations of this type to work within.
  • Provide better collision support, actually using faces would be best, although there are issues of how to triangulate the quads in a way that is consistant with how blender does it.
  • deal with the animation system better. deformations, object ipos, etc. should be handled much better than they are.
  • add support to blender’s python API for speed IPOs and flipping the Relative/Absolute Key switch (only needed if simulation results continue to be stored via VKs)
  • add support to animate the parameters, possibly use Emptys and their scale, i.e. have a Wind Empty’s x, y and z scales affect the wind velocities of the simulator.
  • provide a means of storing and retrieving settings.
  • lots of other stuff I’m forgetting right now.

Moments like this make me happy I got double boot on my system :slight_smile:

I just downloaded your modified script and it does look very nice. I did not give original scipr much attention mainly because the lack of interface, now this neat script has one.

I thank you. And i am pretty sure so does everyone else using Blender. :smiley:

That looks like it was really hard work to get right, I hope someone can do a Windows dll soon id love to play with this, keep up the great work :o :smiley:

Ken

Your new version does not seem to work for me, alwas I try to run the script Blender crashes and exits.

Your previous scirpt worked fine.

I tested this under RH9, with 2.29 and official 2.31a

It crashes immediately on ALT-PKEY ? Or when you Run Simulator ?

What processor do you have and which .so are you using ?

Blender crashes when I hit the “run simulator” button.
My processor is AMD athllon 1.2Ghz

But as I said, your previous script worked fine.

Cant really say a thing about that .so thingie. What is it anyway?

I was wondering which topixmodule.so file you were using.

I think I found the problem. It appears that the topixmodule.so I put in the .zip file is the same as topixmodule-p4.so, i.e. its compiled for pentium4 instruction set.

Try copying or renaming topixmodule-athlon.so to topixmodule.so and see if that works better. I’ll update the .zip in a few minutes.

You should get a little better performance with the athlon compiled .so anyway.

EDIT: cloth2.zip has been updated, the topixmodule.so file is now properly compiled for i386 to work on intel and amd processors for linux.

:o
work great thanks 8)
kino

eeshlo just got the windows .dll to me. I’ve added it to the cloth2.zip file.

If you just want to get the .dll, its available separately now in topixwin32.zip.

Thank eeshlo nicely for taking his time to compile it, :).

Works great on my Windows system, now to read the instructions properly, This is excelent work and I hope that you feel motivated to carry on.
Your cloth sym will be a one of the best tools for Blender.

Could this be used for producing some types of hair? Maybe mixed with Beast?

Great work ZaZ :smiley: :o

Ken

Thanks zaz! This id great. Is it still limited to certain objects? This will be fun to play with.

Blend on!

kencanvey - I doubt its going to work well on hair right now, but if you were to order your vertices properly in a very specific way, it might. I haven’t looked at all at removing the requirement of the cloth being a Grid Mesh. That capability is something I would like to see though.

JA-forreal - yeah, the only limit I removed in this release is the 100 frame limit.

The limit on the cloth object being a Grid Mesh has to do with the original topix cloth code working with Cardinal patches and the way the blender version assumes a certain ordering of the vertices in the mesh which is used to determine the connectivity of the vertices to their neighbors. This connectivity is very important becuse it is used to build the springs used to run the simulation. If your vertices aren’t ordered in your mesh properly, the connectivity is incorrect and the results will be poor.

To eliminate the Grid mesh requirement is going to require the code to look at the actual geometry of the mesh. Conceptually, this isn’t that hard, but it’ll be a little tedious to get the code written properly. At that point, the cloth object should be able to be an arbitrary mesh and produce good results. It’d also likely be possible to support non-mesh objects at some point, but I haven’t looked at the internal structures of anything but a mesh, so I don’t know how applicable this really is.

As far as the collision object limitations, the only real limitation on collisions is that the collision detection implemented now is spherical. Its very efficient to do a collision test with a sphere as you only need a center point and radius to do it. Other forms of collision detection will be slower.

The collision objects themselves don’t have to be spheres. They can be any blender object that has a center/origin point and a bounding box. The bounding box limitation exists only because of the cheap hack I made in the python code. If you have another way of determining the radii for your objects, it’d be easy to make the change to the python code. If you want to do this, see where I build the rads[] list in the initializeTopix function in cloth2.py.

I’d like to support this in the python UI, say allow users to pick empties or other arbitrary objects for their collision objects and specify the effective radius for each. The current clutter of the UI and the time required to relayout all the fields is the main issue here. I think I have to steal the panel like functionality found in the beast to do something like this. One thing I did with the python UI this last release is to lay the ground work for being able to do that, but its not done yet.

My primary goals right now are to eliminate the memory leaks and insure that the blender version has no bugs when compared to the original topix version. I found a bug last night, after I released, that has been in the code from the earliest original release (in 2000) that I’m aware of (see the compare function in the C code and the missing closing comment if you want to fix and compile for yourself). So part of my work requires me to do a line by line comparison of the original topix code with the blender code to insure correctness. The memory leaks are likely caused by improper memory management and improper python reference count management.

I think I have the python reference count issue under control now, but this is my first python C API code and its very possible I misunderstand some details of this, so I need to continue to look at this some. The C memory management is very resolvable and I’m getting closer to resolving it, but some of the code needs to be re-written to insure pointers to allocated memory aren’t being lost.

Also, I’m a complete newbie at using this, like everyone else. So I am spending some time playing with it to see how it works and what it can really do. As I notice things while I do this, I’ll sometimes make changes to support something I want to do. As I notice parameters not having any effect or not causing an effect I think they should, I go back and check the code.

Just though I’d share a few of my thoughts on how to use this.

Creativity is key. The simulator, by itself, is not going to put cloths on the back of your characters, but it might if you get creative and spend a bunch of time. I’m not necessarily suggesting that you spend that time now, unless you really want to, I’m just trying to get people to think out of the box a bit.

For example, the cloth mesh has to be a Grid mesh, but that doesn’t mean that all of the faces of the cloth have to exist. You can create some pretty arbitrary shapes if you combine several grid meshes that have had some of the faces removed from them. If you do use more than one mesh, you’ll have to run the simulation separately on each mesh.

Also, don’t think you have to necessarily simulate 10,000 frames of cloth for a 10,000 frame animation. If you have something simple like a flag, use the IPO to make it loop. A few 10s to a few 100s of frames of your cloth flapping in the wind is likely to be enough. This is why the StartVK setting was added to the last release.

To do this, play around with the simulator to generate an animation of your flag that is pleasing. Note at approximately which frame the cloth initially is animating about the way you like it and set StartVK to the frame number. Then, by setting End Frame, generate enough frames beyond that so the looping isn’t obvious. Add a third point to your IPO at twice the count of the simulated frames and 0.0. Set the IPO curve Extend Mode to cyclic. This won’t be perfect for a close up, but might be good enough if the flag isn’t the primary object being animated. You also probably want to use a non-vector point for the center point and flatten the curve out some.

There are lots of other ways to play with the IPO curve. The instructions I put into the python UI only guide you in setting up an IPO that obeys the physics specified in the input parameters. You can easily generate 50 frames of simulation and play them back over 1,000 frames of your animation. Waves on water anyone ? (left as an exercise in creativity for the reader) :slight_smile:

You can also simply remove vertex keys you don’t like or run the simulation once to use one of the vertex keys to deform the mesh to a better starting position (just click on a vertex key before you start the second run of the simulation). In some ways I consider this a bug, but I don’t think I’m going to change it because of the possibilities it allows.

These raw abilities that exist by using vertex keys and IPOs make me reluctant to eliminate this way of storing simulation results from the simulator. The draw backs to this though are huge file sizes and I assume lots of memory consumed by blender. In the future, the simulator may work differently, i.e. store the simulation a different way than the vertex keys it uses now, but at this time, with blender’s current feature set, I think the vertex keys should remain an option for the user to store the simulation results.

Use multiple shots combined with short looped runs of the simulator to get the animation you want. I’m working on a new example now to show a really bad superman model flying and then landing. My plans are to run the simulation on the cape to get a nice animation of the cape flapping in the wind for when he’s flying. I’ll simply do this vertically and then when he’s flying, I’ll rotate the superman and cape models to horizontal and render one scene/shot. Then I’ll run the simulation with different parameters, probably on a different copy of the cape to save the results, to have a different animation of the cape to show him landing with the cape kind of floating out behind him like we’ve all seen in movies, etc.

I make no promises to getting this example done, but I think its entirely possible to do with the simulator in its current form, well, with that bug fix I did last night anyway, :). I found it while I was working on this. The main issue in finishing this example for me is whether I spend my time trying to get this to work, on improving the cloth simulator or doing other blender stuff I’ve sort of put on hold for the last week. I’m very confident that this can be done now if you spend enough time on it.

This raises another point. Yep, the simulator only supports spherical collision detection, but that doesn’t mean you can’t get reasonable results against non-spheres. In the superman example above, I simply put 10 or 15 spheres where his body is to more or less form the plane of his body. The Faces option added to the current release does this for you if your model has enough faces, although the more faces/spheres, the slower the simulation will be. What you use for the collision objects in your scenes really depends on the accuracy you need. In the superman example above, accuracy isn’t really necessary so a handful of spheres will provide adequate collision detection.

If you wanted the cloth to lay nicely on a flat surface, the simulator can do that, but its likely to need so many spheres it’ll get very slow. The example I did with the stairs took quite a bit of time, relative to the other simulations. I had to crank up the iterations to get the results I did and the thousands of virutal spheres combined with the 5 or so iterations made that simulation take maybe 10 secs or so a frame on my 2.8G p4.

Optionally, you can use the Floor parameter to do this. Say you want a cloth to fall onto a table. Set the Floor parameter to the height of the table and let the cloth fall to it. Several very, very, very large spheres should also work.

Another example could be done that showed a cloth dropping to a tray and then the tray being removed and the cloth falling again. Simply set the floor to the height of the tray, simulate dropping the cloth on it. Then change the floor and remove the tray and run the simulation again. That’s the basics of the idea, you’d likely need more than one cloth and use that vertex key trick above I mentioned, i.e. deforming the cloth prior to running the simulation, combined with some layer ipos on the objects if you use more than one.

Topix cloth has limitations, but it also has some significant capabilities, most of which are now exposed and available for creative abuse. If a cloth simulation is important enough to you right now to spend lots of time to creatively get around the limitations, you should be able to do some neat stuff with it. If you just want to make your characters not be naked any more or animate their hair without putting in the effort and creativity, it won’t do that for you right now and may or may not ever do that. Hard to say what the future really holds.

I was reviewing the licensing for topix cloth to insure everything was being followed and noticed that while topix released their cloth simulator under GPL, they require permission to redistribute it. Unfortunately, this is the first I noticed that part of their licensing and thus do not have that permission. I’ve removed the software from my web space until I can obtain that permission from topix. Hopefully this won’t take too long, although while writing this message, the email for the contact at topix bounced with an unknown user, :(.

If that permission fails to come through, it doesn’t necessarily mean the end of this project. The topix cloth simulation algorithm is from one paper on the subject and there are more papers as well as more implementations, like freecloth. Topix was chosen simply because it had already been integrated into blender once and I could simply extend that work rather than start from scratch.

I apologize for not noticing this, but I have to respect the rights of topix on this software and if they require permission to redistribute, I need to get that permission if I’m going to redistribute. I will do what I can to resolve this as quickly as possible.

Well, now I’m confused as to what to do. All versions of the topix source code I have, including one downloaded from their web site in the last few weeks, don’t have the requirement of obtaining permission to redistribute. In fact they specifically say the software is free and that you can redistribute and modify it under GPL version 2 or later.

However, there is that clause on the web page that requires permission to redistribute. It seems to me you can’t give an unhindered right to distribute in the software/archive that one would actually distribute and have the small print clause on the web page binding, but I haven’t even played a lawyer on TV …

Any international law lawyers, specializing in copyright, in the crowd here ? :slight_smile:

I have two emails off to topix that haven’t bounced, I need to give them a few days to respond, especially since its Saturday now.

I would be curious though as to other’s opinions on this and their reasoning behind it. With the right arguments I might be persuaded to putting the software back up.

EDIT: I just finished reading through GPL version 2.0 under which topix released the code. I interpret section 6 to read that it gives me, or anyone else, the right to further modify and redistribute the software without their permission. Especially since Tatsuya Nakamura already received permission from them long ago to redistribute and my work is a derivative of his work. However, since I already initiated contact with topix via email, I feel that its necessary to give them the chance to reply.

If I don’t get a reponse from them early next week, I expect I’ll just put the software back up for downloading. What you do with the software in the interim is your decision. Read the GPL and check out the small print at http://www.topix.com/cloth/ and decide for yourself.

um… I cant seem to download the files broken link…

Also if you need a host to host these and more files I got some to spear and I could just set up a ftp you you

See my previous two posts.

I’m willing to change my mind on this if someone has some compelling arguments or examples of similar situations to support my interpretations of the GPL. Heck, if I hadn’t sent the email to topix before I went back to read the GPL, it’d be available again. I’m in a little different position though having asked for permission now. I think so anyway.

In the mean time, I think I’ve plugged some very large holes in the memory leaks and with luck I’ll hear back from topix quickly and can release again.

I would suggest that you take this issue to the forums at Blender.org for more verification as to the true license limitations etc of Topix. You will have access to a wider base of Blender users and coders who may be able to help you to resolve this. Ton may even have some tips for you over there.

Blend on!

That’s a good idea JA, if all else fails I’ll broaden my quest to get a consenting opinion.

As it sits now, I expect the worse that would happen is that I’d release my current work through Tatsuya Nakamura, the original porter of topix to blender since he has already received permission to redistribute. This is only likely to happen if topix absolutely and without question refuses to give me permission to redistribute. Even though I feel they would be violating the GPL they released the code under, I don’t need to spend money on lawyers to prove the point, :).

I’ve been unable to locate a means on contacting Tatsuya, but assume others closer to NaN can get in touch with him it if proves necessary to go that route.

At the present time, I’m still doing a little work on topix (think I closed all the memory leaks) and am looking at some research papers on cloth, one of them referenced by topix, as well as other alternatives like freecloth. So, the project isn’t dead, but the releases are paused and the project may switch paths sooner than I expected or hoped.

EDIT: One more note here. Even if topix gives me permission to redistribute, but I can 't arrange for that permission to extend to blender.org or some other long term entity, I’m not sure how much sense it makes to continue to base this work on topix. If, on the other hand, I can get confirmation that they actually have released topix cloth under GPL version 2 as they say, then anyone can redistribute derivative works.

This becomes more of an issue as I’ve applied for a project for this at blender.org. It makes no sense to me to have me become a necessary cog in the wheel or to require someone else to pursue permission to redistribute from topix to allow this to get redistributed. The internals of the cloth simulation have to firmly and unequivocably be redistributable under an unencumbered GPL or similar license

I hope it works out. You have the makings of an excellent Blender project. Whatever happens, your efforts will always be appreciated by the Blender community.