Topix cloth revisited

I was playing with topix yesterday and made some improvements, mostly on the user interface side, although I did enable a few topix features that the original python module didn’t allow.

There’s gobs of explanation of what I did in the .blend file, too much probably, :). But to save those people on slow connections from downloading something they don’t want, I’ll outline the status of this here.

I exposed all topix cloth parameters to the python API now, enabled the TAGGED/pinned feature of topix, added better support for collision spheres animated via their parents, added a floor (min Z coord cloth can’t go below), put a python UI in front of everything, fixed some memory problems in topixmodule.c, put some Py_DECREFs in that I believe should have been in there, generally hacked on the code, changed the process of the simulation more or less completely and spent way too much time today putting the .blend file and these .avis together. While I was doing this, I was teaching myself the python C API, python in general and blender’s python interface. Some of these later things I expect are reflected in the code I produced, :).

I definitely didn’t make topix a completely different animal, so don’t get your hopes up that we now have a “real” cloth solution for blender. Basically all of the old limitations still exist. Only collision detection with spheres is supported, you can only apply the simulation against Grid meshes and it consumes enormous amounts of memory and still will (until the design changes) even when the memory leaks are gone. Oh, did I forget to mention those ? :slight_smile:

One of the things I changed in the process was switching from updating the mesh via a framechanged script link to having python make absolute vertex keys for each frame. This resolved the problem of subsurfaced meshes disappearing when you changed the frame and allowed you to run the simulation once, save it in your .blend file and play it back. However, I just noticed putting the examples together that I ran into a limit of 100 frames of animation this way, so 2 steps forward, one step backward.

At this point, I believe this has some use in certain situations, although the 100 frame limit is pretty tough for many purposes. I’m not sure where I want to go with this at this moment. I making it available in case it sparks some interest and is useful to someone. I plan on rewriting the C code to clean it up and look at solving some of the interactions between it and blender that are the biggest limiting factors. However, when I actually get around to working on it again is another question, so rather than let this sit collecting dust for months before I touch it again, I’m making it available as is.

Here’s the user interface I put in front of it:
http://www.visi.com/~zaz/cloth2.jpg

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

Example1.avi shows a cloth falling on a sphere.

Example2.avi is a flag waving.

Example3.avi shows pinned cloth unpinning and then falling on some moving spheres.

THE .ZIP BELOW CONTAINS A COMPILED MODULE FOR LINUX i386 AND MY EXAMPLE BLEND FILE. IF YOU NEED IT FOR A DIFFERENT CPU OR OS, YOU’LL HAVE TO COMPILE YOURSELF OR GET FROM ANOTHER PARTY. ALL SOURCE CODE AND MY MAKEFILE ARE IN THE .blend FILE. Sorry, I only have development tools under linux. You can play back and render the example animations though as they are stored in the file as vertex keys. You just won’t be able to run the simulator if you don’t have a compiled module for your computer.

Cloth2.zip is available here and contains the .blend file and topixmodule.so (compiled for linux p4). My python code (cloth2.py), C code (topixmodule.c) and Makefile are text files in the .blend file.

EDIT: Changed topixmodule.so in the .zip to i386 from p4, edited note above to reflect that.

nice. can you still use old topix.dll for windows? or is a new compile needed?

about time somebody took some interest in this script. blender could use some more dynamics

thanks

Sorry, I forgot to point that out explicitly. No, you need my new module, the interface between C and python has changed significantly.

Yeah, I’ve kicked topix around a few times in the past. This week I’ve been looking at the cloth simulation options for blender, and a few non-blender ones to see if the can be made to work with blender.

Since topix was already working, but not completely implemented, it looked like a good place to toss a little work.

Wow. Thanks for the effort.

TorQ

thx lot. I’ll try it this evening :smiley:

there’s an opensource clothsim (freecloth) http://freecloth.enigmati.ca/. just for info if you’re looking for some code.

Yeah, I looked at freecloth and will probably look at it and maybe others some more. Since topix was already working, it just made sense to push it further before spending more effort making something new work.

BTW, I just updated cloth2.zip. The topixmodule.so included in it is now compiled for linux i386. If someone on anothe platform makes the dll/so available for their system I’ll be happy to included it in the .zip.

BLENDER NEEDS BUILT_IN CLOTH!! And when the new blender is released, will it have all of the game engine bugs fixed? Like no constraints, and freezing if a scene has too much data?

hi
i compiled this one with -O3 -march=athlon -msse -mfpmath=sse
on my system work fine
edit: sorry forget the system for Linux

removed need permission to redistribuite

thanks for the script is great 8)

kino

zaz
That is already a excellent work to have revisiterd Topix.
Making an interface makes it already much more user friendly.
Removing the 100 frame limitation is the top priority, cause, you’re right it won’t be very useful with this limitation.
Anyway it’s a very good idea to put on the table again the ONLY cloth solution that Blender ever had (I don’t mention cloth features from Dynamica excellent project, cause it never made its way to the public)

Thanks a lot

Thanks guys, glad you like what you see so far.

kino - I’m cleaning up the code now and figure people can download your .so from your link at present. When I get around to releasing the next version, I’m planning on having a directory structure in the .zip to include more .sos and .dlls (if they’re available).

I’m thinking the .sos and .dlls I release have to at least cover the basic CPUS and OSes, but I’ll need someone to compile for other than x86 linux. On the x86 linux, I can also include some optimized for the higher end CPUs (p4, p3, athlon) as I can compile those. I just need to work out the naming conventions and directory structures. Thanks for posting the .zip though.

garbager - I’m going to try to put a quick solution for this into place soon. The idea I’m planning on implementing now is to put start and end frames in for the vertex keys and a frame count for between vertex keys. If this works, this will solve the problem of having to store useless vks for the pre-roll frames (to let the cloth stabilize) and its likely that storing a key every 2 to 10 frames (depending on the application) will extend that 100 frames to 200 to 1000.

We’ll see how it works, I need to finish the current round of code cleanup though and then I’ll look at implementing that. I have a feeling I’m going to run into a new issue with that though, but one problem at a time, :).

zaz,

I don’t know if you’ve seen this link before or not but I thought I’d throw it out there. It’s a paper written by some chaps at Pixar that was presented at last years Siggraph.

http://www.pixar.com/companyinfo/research/deb/untangling.pdf

Hope this is of some use.

TorQ

We want windows Dlls! We want windows Dlls! We want windows Dlls!
I someone going to compile one, or am I going to have to do it?

TorQ - interesting paper. Something to consider once other kinks, um, no pun intended, :), are worked out of this system and some serious limitations are removed or minimized.

lemmy - wish I could help ya, I figured one of the guys making windoze builds would have put something up by now.

Updated here.

The dynamica ‘one weekend cloth hack’ was never usable as a general cloth solution. It just happened to look nice for that one video. I used the Jakobson verlet method (‘Hitman’), which has a number of very nice advantages, but also some disadvantages, like big cloths needing lots of iterations and then still could look like rubber. Of course that could be solved in some other way, but the method was more intended for realtime use in games anyway.
But another advantage of that method is that you can just as easily use it to simulate rigid bodies (there is also a video of that on the old dynamica site), without all the usual calculations needed.

Anyway, nice work Zaz! I’ll try to compile the module for windows, should not be a problem though. Do you have an email address so I can send it to you?

Thanks.

It’d be great to get the .dll for windows. I might eventually break down and download cygwin sometime, but when I’ve done years ago, it was more effort than I want to expend on it now.

visi.com is the domain and zaz is the username for my email. If you generate a Makefile, project, whatever, to build under windows send that too, if you don’t mind, and I’ll keep it with the rest of the stuff.

Also, its pretty standard C code, but I haven’t written a lick of code for a micrsoft compiler for ages, if ever. If there are changes you need to make, let me know and I’ll incorporate them and keep them in mind as the coding progresses.

need windows dll. video links don’t work