Page 1 of 2

Dynamic cloth

Posted: Mon Feb 07, 2005 6:03 pm
by innovati
Hey all, I'm new to the community, and I must say I'm very impressed and will try to use this great engine for my next project. I was wondering, Ogre has many of the features we wanted that our programmer would have had to add to another engine himself, but one feature I didn't see while browsing was dynamic cloth.

Has anybody made this yet? If not, could somebody who know how make it or let me know how it could be done?

Thanx a lot, great work everybody!

Posted: Mon Feb 07, 2005 6:41 pm
by bal
Isn't this more something for a physics engine?

Posted: Mon Feb 07, 2005 8:21 pm
by Antiarc
Personally, I'd look at a stick-particle setup with Verlet integration. If I remember correctly, it's a pretty fast method for simulating cloth (among other things), and is quite simple to set up.

Posted: Mon Feb 07, 2005 10:53 pm
by :wumpus:
Verlet integration works very well for cloth simulation, you basically just have a grid of springs that you simulate with very basic force integration.

http://members.shaw.ca/chahal/clothpaper.htm

We're thinking of putting in a demo doing basic cloth simulation for an 'OGRE logo' flag, but I don't know when

verlet simulation

Posted: Tue Feb 08, 2005 5:01 am
by innovati
how would this work with wind? Could we have a set wind direction and force, then set certain objects to differen levels of movement? Cotton and canvas wouldn't react the same to the same wind as canvas is heavier material - thicker and heavier.

A demo would be nice indeed!

Posted: Tue Feb 08, 2005 9:45 am
by :wumpus:
did you read the link? There are three types of springs/interconnections: structural, shear and flexion. The relative spring constant of those springs sets the kind of material.

Too stiff materials might not work with the verlet integrator though, due to numerical integration issues.

You can 'simulate' wind easily with a slight constant force in some direction as I've heard.

Posted: Tue Feb 08, 2005 11:54 am
by tuan kuranes
Here is my demo of a flag in the wind, with gravity but no collision.

Todo :
- I didn't find a way to prevent self-intersection, apart from finding tweaked spring and wind forces...
- Shaders support (per pixel light)
- Lod support (not only reducing vertex count but also reducing spring and normals calculations.)
- collision (at least with a sphere...)

I didn't release it before because of the self-intersection bug... and the bad feeling when looking at Humus flag and cloth demo...

Posted: Tue Feb 08, 2005 12:31 pm
by :wumpus:
tuan kuranes wrote: - I didn't find a way to prevent self-intersection, apart from finding tweaked spring and wind forces...
Too expensive to do in real time, even with theoretically really low bound algorithms, and often not needed if you tweak the environment well. (especially for things as flags)
- Shaders support (per pixel light)
That's a matter of providing the right material I suppose?
- Lod support (not only reducing vertex count but also reducing spring and normals calculations.)
Cool idea. and not that hard if you use a grid
- collision (at least with a sphere...)
not really a matter for me, I don't want to collide my flags against anything, it must not get crumpled against the flagpole or something :)

What's the licensing on your flag demo? Would it be OK to use parts of it in an Ogre demo?

Posted: Tue Feb 08, 2005 1:49 pm
by tuan kuranes
Would it be OK to use parts of it in an Ogre demo?
Would be an honor !
(And will at least demonstrate use of my vector2 patch ;) )
it's an Ogre Demo license.

The good thing in my demo is speed. Didn't find a faster 40x40 flag demo out there, at least in d3d9, as opengl does have 40 fps less here (ati 9600 catalyst 5.1)).

Too expensive, that's the word. I tried many things to prevent self intersection, getting fps as high as 0.5 fps final results ! (using orientation, normals, cross prod and so on...)
But I can't stop thinking there must be a simple concept that handle it...

- It's a grid, so it should be Ok.

Forgot to point that the bounding box calculation is somewhat... flawed.
Need a min, max calculation somewhere in a the flagmesh::update final damping loop.

Was hoping to find a "free software patents" flag somewhere, to cycle with Ogre flag but cannot find one...

Posted: Tue Feb 08, 2005 3:42 pm
by tuan kuranes
Zip file reloaded : Added a cg per pixel lighting shader. (a lot nicer...)

Posted: Tue Feb 08, 2005 6:50 pm
by :wumpus:
Nice, I'll have a look at in in a min :)

Posted: Tue Feb 08, 2005 7:01 pm
by Fredz
Was hoping to find a "free software patents" flag somewhere, to cycle with Ogre flag but cannot find one...
Something like that ?
http://nomasis.com/nomablog/blogimages/no_epatents.png
http://www.itzgrund.net/data/logos/noepatents.gif

Posted: Tue Feb 08, 2005 8:09 pm
by :wumpus:
There's an overflow somewhere; I get some fairly strange behaviour at the sides of the flags under Linux, maybe it's something to do with a boundary condition?

On shutdown, ogre seems entirely corrupted (log turns to pure gibberish, heap overwrite?)

I didn't find out yet where's the culprit. I do know it happens somewhere in the initialisation of the FlagMesh, as commenting out update() doesn't help.

Edit: the problem is probably local here, still searching, I don't think it's your code at all

Posted: Tue Feb 08, 2005 8:57 pm
by :wumpus:
I fixed the weird crash (it was indeed no issue with your program), but am still getting display corruption :(

It seems to all occur in the lowest row of the cloth; maybe this is a non-initialized-vertex-buffer issue; NVidia clears those to 0, ATI leaves them at a random value.

Posted: Tue Feb 08, 2005 9:17 pm
by :wumpus:
Got it! You set mIndexCount too high on creation of the buffer

Change line 267 to:

Code: Select all

mIndexCount = 3 * 2 * (mNumvertX-1)*(mNumvertY-1);

Posted: Tue Feb 08, 2005 9:23 pm
by tuan kuranes
This comes from a bug...
mIndexCount should be

Code: Select all

 3 * 2 * (mNumvertX-1)*(mNumvertY-1);
in initbuffers, 6 is just too much, and will surely cause ATI bugs...
[edit]Too late, you spotted it. Well it's a common bug in my code.. thinking I must write 3*2 to make it clear that it's 2 group of 3 indexes... But my mind cannot prevent himself to gladly compute 3*2=6 in a mind loop and I end up write 6*2 :oops: Sorry ! [/edit]

Posted: Tue Feb 08, 2005 10:15 pm
by :wumpus:
Thanks :)

I wonder if it would be possible to make the flag cast a shadow? I see no option of converting it to a closed manifold mesh. Nah, a better option is to use texture shadows, but that rules out self-shadowing.

Btw, I replaced the image with this logo (just the logo, sans the "powered by ogre" etc):
Image

Looks real good on a flag

Posted: Tue Feb 08, 2005 10:27 pm
by tuan kuranes
A box with a very small depth could do the trick, no ?

A new side would just be a matter of "vertex winding + slight shift" thing. Vertex culling would make it as effecient as actual one.
(except when looking two sides at once, rare case)

But that would also means edge calculations each frame to get stencil shadows to work... That would be a costly thing.

Posted: Wed Feb 09, 2005 1:28 am
by :wumpus:
Good idea, thanks :)

Btw, it might be interesting to add flexion springs too (these skip one):
Image

This prevents bending to some degree.

fast replies

Posted: Sun Feb 13, 2005 2:22 am
by innovati
hey guys - wow, amazed at your fast replies....I bet some of you sit at home, firefox up, hitting the refresh page continually for hours just so you can be the first to reply to a new post ;)

Well, I appreciate your ideas - I can't say I fully understand them, but that'll come with time I'm sure.

I'll keep looking down the path you guys have pointed me in - thanx for the giudance and code - and above all, your willingness to help others.

Some demo ideas besides Dynamic cloth in future (by the way, could the GUI demo not be used to launch the other demos? This way the demo program would be all in one exe - consolidate) might be soft-shadowing, ogreODE (maybe too big/not-applicable), a 3D model that could be manipulated in real-time....

Posted: Sun Feb 13, 2005 2:47 am
by :wumpus:
We're actually planning on something much cooler than a CEGUI demo launcher. More like a large building with a room for each demo.

Posted: Sun Feb 13, 2005 2:25 pm
by SpannerMan
That sounds cool :)

How about a long, eerie corridor (like some sort of asylum ward) with dingy lighting and rusty walls. There are doors on either side all along the length of the corridor. On the doors are little signs, like 'Smoke' or 'Terrain'. You can move up and down the corridor, and can go in and out of the doors into the different 'rooms' where the different demos show off the different functionality.

Posted: Sun Feb 13, 2005 2:46 pm
by Vectrex
Serious Sam has that exactly. A long corridor with rooms for the different features.
The Serious Sam engine is truly awesome and runs so well on crap hardware. The editor kicks arse too.

Posted: Sun Feb 13, 2005 2:53 pm
by SpannerMan
Vectrex wrote:Serious Sam has that exactly. A long corridor with rooms for the different features.
It does? Aww bugger :(

Posted: Sun Feb 13, 2005 3:03 pm
by Vectrex
hehe, no that's good :D Proves that it's a cool idea. Anyway we can do better than a corridor... how about a sideshow alley?