Dynamic cloth

What it says on the tin: a place to discuss proposed new features.
innovati
Kobold
Posts: 35
Joined: Mon Feb 07, 2005 6:01 pm
Location: Ontario Canada
Contact:

Dynamic cloth

Post 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!
User avatar
bal
Greenskin
Posts: 100
Joined: Thu Dec 09, 2004 7:29 pm
Location: Geluwe, Belgium

Post by bal »

Isn't this more something for a physics engine?
User avatar
Antiarc
Greenskin
Posts: 120
Joined: Thu Jan 23, 2003 8:40 am
Contact:

Post 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.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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
innovati
Kobold
Posts: 35
Joined: Mon Feb 07, 2005 6:01 pm
Location: Ontario Canada
Contact:

verlet simulation

Post 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!
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post 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...
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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?
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post 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...
Last edited by tuan kuranes on Tue Feb 08, 2005 3:51 pm, edited 1 time in total.
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Zip file reloaded : Added a cg per pixel lighting shader. (a lot nicer...)
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Nice, I'll have a look at in in a min :)
Fredz
Greenskin
Posts: 122
Joined: Wed May 26, 2004 1:45 pm
Location: Perpignan, France

Post 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
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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);
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post 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]
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post 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.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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.
innovati
Kobold
Posts: 35
Joined: Mon Feb 07, 2005 6:01 pm
Location: Ontario Canada
Contact:

fast replies

Post 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....
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post 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.
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Post 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.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post 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.
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Post by SpannerMan »

Vectrex wrote:Serious Sam has that exactly. A long corridor with rooms for the different features.
It does? Aww bugger :(
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post 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?
Post Reply