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

Postby innovati » Mon Feb 07, 2005 6:03 pm

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!
0 x

User avatar
bal
Greenskin
Posts: 100
Joined: Thu Dec 09, 2004 7:29 pm
Location: Geluwe, Belgium

Postby bal » Mon Feb 07, 2005 6:41 pm

Isn't this more something for a physics engine?
0 x

User avatar
Antiarc
Greenskin
Posts: 120
Joined: Thu Jan 23, 2003 8:40 am
Contact:

Postby Antiarc » Mon Feb 07, 2005 8:21 pm

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.
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Mon Feb 07, 2005 10:53 pm

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
0 x

innovati
Kobold
Posts: 35
Joined: Mon Feb 07, 2005 6:01 pm
Location: Ontario Canada
Contact:

verlet simulation

Postby innovati » Tue Feb 08, 2005 5:01 am

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!
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 9:45 am

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.
0 x

User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
Contact:

Postby tuan kuranes » Tue Feb 08, 2005 11:54 am

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...
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 12:31 pm

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?
0 x

User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
Contact:

Postby tuan kuranes » Tue Feb 08, 2005 1:49 pm

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.
0 x

User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
Contact:

Postby tuan kuranes » Tue Feb 08, 2005 3:42 pm

Zip file reloaded : Added a cg per pixel lighting shader. (a lot nicer...)
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 6:50 pm

Nice, I'll have a look at in in a min :)
0 x

Fredz
Greenskin
Posts: 122
Joined: Wed May 26, 2004 1:45 pm
Location: Perpignan, France

Postby Fredz » Tue Feb 08, 2005 7:01 pm

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
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 8:09 pm

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
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 8:57 pm

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.
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 9:17 pm

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);
0 x

User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
Contact:

Postby tuan kuranes » Tue Feb 08, 2005 9:23 pm

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]
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Tue Feb 08, 2005 10:15 pm

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
0 x

User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
Contact:

Postby tuan kuranes » Tue Feb 08, 2005 10:27 pm

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.
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Wed Feb 09, 2005 1:28 am

Good idea, thanks :)

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

This prevents bending to some degree.
0 x

innovati
Kobold
Posts: 35
Joined: Mon Feb 07, 2005 6:01 pm
Location: Ontario Canada
Contact:

fast replies

Postby innovati » Sun Feb 13, 2005 2:22 am

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....
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Postby :wumpus: » Sun Feb 13, 2005 2:47 am

We're actually planning on something much cooler than a CEGUI demo launcher. More like a large building with a room for each demo.
0 x

User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Postby SpannerMan » Sun Feb 13, 2005 2:25 pm

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.
0 x

Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
Contact:

Postby Vectrex » Sun Feb 13, 2005 2:46 pm

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.
0 x

User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Postby SpannerMan » Sun Feb 13, 2005 2:53 pm

Vectrex wrote:Serious Sam has that exactly. A long corridor with rooms for the different features.


It does? Aww bugger :(
0 x

Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
Contact:

Postby Vectrex » Sun Feb 13, 2005 3:03 pm

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?
0 x


Return to “Feature Requests”

Who is online

Users browsing this forum: No registered users and 1 guest