I’ve implemented a SpringSystem and have implemented Cloth on top of this. The cloth is implemented as ClothPatch and CollidingClothPatch with the second one having the built in ability to handle object collision. You can make custom forces to act on the cloth at the node level by extending SpringNodeForce. Simple wind, gravity and drag versions are obtainable via the ClothUtils class.
I’m pretty happy with it. In my demo class I have a cloth with 2,500 nodes and ~29,000 springs. A ball floats from front to back, colliding with the cloth. The scene is 5,522 tris. Even with all that going on, I still get 800+ FPS!
There’s about 8 new classes and I also made some updates to OBBTree to clean up the heaps of new objects created there if you have to update the collisionTree every frame. (You do in this case because the trimesh is constantly changing.)
All that said, I know much more work is left to do to make it robust enough for everyone, but here’s a start anyhow.
Here’s a shot, code to follow as a link to a zip.
looks great. Can’t wait to see that in action.
Here’s the source zip
When this thread is locked, that link will go bad.
- The cloth springs are a bit elastic. Some of the params should help with that. The Spring class may need some more tweaking to help with that, maybe use actual force, although I went this way based on suggestions from the Hitman paper referenced in another jme thread.
- It seems like in the test, the ball does not collide well with the cloth when approaching from the back side. Can anyone figure out why?
- Probably a lot more.
I’m thinking of making a “Cloth editor” similar to my Particle editor, so you can tweak the settings in real time and get code to use quickly.
One thing I failed to mention… The Spring code is seperate for a reason… You can use it for other things, like swaying grass or jello cubes. I’ll try to put together examples in the future as time permits.
Can these classes be used in conjunction with DP’s physics tool? The screen shot looks good.
The physics stuff DP and Per were working on was basically using ODE and I don’t see any reason why it couldn’t be in the same scene… I’m not sure ODE could take over the cloth-object interactions though.
PS, the object creation issues I fixed in OBBTree is already comitted to CVS as it was more of a patch than new code.
I found a possible bug in the code that I will post soon. (I need to boot up the computer I program on).
I do not understand why you are increasing the acceleration for gravity. When an object is affected by gravity then it’s acceleration is consent, only it’s velocity changes. My guess as to how to stop the cloth from looking so elastic is make the Spring pull header when a force is acting on a SpringNode.
When I run the program the cloth dose not appear. When I add the line
Into the constructer everything works fine. I am using a 1.5 week old cvs snap shot so that may be the problem.
Gravitational acceleration is constant but acceleration is added up from zero on each round. So no, it’s no bug.
As far as the reconstruct, or other bugs, etc. please update from cvs before you call them
works well, and I think it should be committed. Can you comment it some though? Once that’s done, it can go in.
Yup, I’ll clean and comment, then commit… sometime tonight or tomorrow
PS, this is all clean and in.