A simple Cloth sceneNode for Irrlicht!

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
fmx

A simple Cloth sceneNode for Irrlicht!

Post by fmx »

Hi everyone!

this is my first REAL contribution to the Irrlicht community: a CClothSceneNode to simulate Simple Cloth Physics!

Quick Screenshot of my demo in action:

Image


Get the Demo and Sources here:
(link removed, sortof died, need to reupload)



What is it?

It allows you to create a Cloth entity from any Irrlicht IMesh, and then after setting a few simple parameters, you can make it behave like Cloth (well, almost ;) its very fast considering the results it can achieve).

I'm not very good at explanations, so I'll just say that try out the demo to see what its all about (source included)

A picture can tell a thousand words, so check out my MSPaint skillz:

Image


How to use it?

Check out the sources I've included: its a simple 3 step process really

1: Create the CClothSceneNode
2: Apply Pinners
3: Apply Forces


How does it work?

I've used a very simple Verlet integration method (somewhat similar to the Cal 3D approach) to manipulate a set of Springs created based on the Polygon data of the IMesh which you pass in.

Mathamatically speaking, its not at all 100% fail-safe, because it should be using very accuratly calculated timed steps, but it gets the job done the way it is...


Known Limitations, Bugs, stuff still To Do

-Doesn't work with all Model Formats?!
I tested it with an OBJ format file, but it gave very odd results; X files seem to work fine though... still need to do a lot of testing.

-Only uses the FIRST Mesh-Buffer of an IMESH!
which means, its practically useless for large, complex meshes. But should be good enough for simple things.

-Pinner shapes
only uses Spherical Pinners for now, but Box and Cylindrical Pinners can be more helpful sometimes too

-Collisions!
self-collisions dont occur so you can sometimes endup with strange behaviour, like corners folded over, etc.
and offcourse, collisions with OTHER objects would be nice to have too...

-Cloth parts for IAnimatedMeshes
wouldn't that be cool... :wink:


OK, I admit it.

I've made a premature public release; a lot of things simply haven't been implemented which should have been;

but I have my own reasons.
Simply put, I just won't have the free time after this week, so I figured I'd just make it public ASAP and let everyone help out to make this as useful as it can be for the future... the potential is immense.

I'd love to see Irrlicht become more recognised - Niko and the team deserve more credit than they are given, and only by sharing these kinds of implementations, we can ALL help to achieve that, and make Irrlicht better for everyone at the same time.

The spring system is more-or-less complete and can be used for other things; as I said before, i'm interested in creating a FastLSM softbody implementation for irrlicht, and an implementation could be build using this spring-system instead of the stuff outlined in their paper.

oh
sorry for using the GB-flag, but the Irrlicht Logo just didn't feel right... well, you get the point.

Any problems, Ideas, improvements, Tests, etc, let them loose in this topic so its easier to keep track of.

Have fun!

:D
Last edited by fmx on Sat Feb 23, 2008 3:14 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Sounds very interesting :) And with pretty much potential, still!
The problem with .obj might be the vertex duplication occuring in the loader. There's a patch available which will make its way into the core sometimes. So now you might have overlapping vertices which will hence get wrong forces. same holds for several mesh buffers, because they don't have any information about inter-vertex relations anymore. So I guess it's reasonable to make such stuff per buffer.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Hehe nice work, i haven't looked at the code in detail here are a few points:

I accelerated some water nodes i had via some tricks like using non square root distance(good for high resolution meshes since the error decreases while being faster). For low res meshes where vertices are far apart this method becomes less accurate.

Your spring system is constructed only once which is very good (not regenerated every iteration), however a memcopy here might yield a speed increase(maybe compiler spots this)

Code: Select all

for( u32 n = 0;  n < NumNodes;  n ++ )

        {	

        	 Vertices [ n ].Pos = NODE[ n ].Pos;

        }
Time corrected verlet might come useful (only a tiny change to the verlet equation) if you have a variable frame rate.

As for collisions i have tried impulse based methods (but didn't seem to very reliable or fast) :cry: . so i made my own method where i moved the particle during a collision to its final position after a collision using reflection of velocity vector and simple vector math, verlet has implicit velocity so my position modification didn't ruin the physics. I dont really think you need to add collision since this will be dependent on the user's coll detect solution.

The LSM technique was using spring bound cubes, vertices's inside the cube were affected by the cube's transformation (their technique gives a smooth effect so maybe also other neighboring cubes had an effect). So this can be like lsm (infact here 1 "bounding box" = "1 vertex").

As for obj strangeness, it maybe duplicate vertices, i have some code that removes them via hashing vertex positions and tcoords. (or use blender and rem doubles.

Thanks for the contrib. I also have something baking but
I just won't have the free time after this week
hehe because of studying.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

The problem with .obj might be the vertex duplication occuring in the loader
Damn beaten :lol:
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Most physics stuff also precalculates inverse mass to save on real time divides

Code: Select all

 NODE[ n ].Force / NODE[ n ].Weight
, however the code is very clean and nicely commented :D
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
fmx

Post by fmx »

thanks hybrid for that info about the duplicate faces: that's *exactly* the problem I experienced. Hopefully Irrlicht-1.4 will have it fixed by default.

and wow, thanks so much for your tips and useful bits of advice omaremad :D !

I knew there were ways to optimise it, but just doing this much made me lose focus a bit... I'll try them for the next release.

regarding collisions, I've already got a simple sphere-sphere implentation working with one of my older trials (sounds similar to what you did); it doesn't affect the physics at all, but I'm not sure how CPU intensive it will prove.

yup, best to leave it till later. I don't want to complicate things yet, still too early.

You seem to have quite some experience with spring-based systems... I'm greatful that you're willing to share your experience and help improve this. thanks a lot.


I'll make another release just before the weekend, maybe adding in the collision-system i was talking about,
but feel free to add / improve / criticise at will!

:D
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

so cool !
________
How To Roll Joints
Last edited by koller202 on Thu Feb 17, 2011 1:18 am, edited 1 time in total.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

Nice!!
IPv6
Posts: 188
Joined: Tue Aug 08, 2006 11:58 am

Post by IPv6 »

Nice stuff!!! Worth experimenting :)
GameRotor-Games and more...
Wiredplane-Shareware utilities...
lester
Posts: 86
Joined: Mon Jan 29, 2007 3:33 pm

Post by lester »

Ma-a-an, you're da Ma-a-an!

Now there is a problem how to integrate your cloth with existing physics engines, such as ODE, Newton, Bullet etc.
JPulham
Posts: 320
Joined: Sat Nov 19, 2005 12:06 pm

Post by JPulham »

wow :shock: now I have to find an excuses to put this into my project :D
pushpork
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

Great Work :D
Now if I could only get breasts to bounce like in Neverwinters hack :)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You can do bouncy breasts using Physx!
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Very Cool.

PS: I was like 10-15 minutes playing with it and I just couldn't stop!
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Very nice
Post Reply