Poor man's cloth

Posted By: jumpman

Poor man's cloth - 11/11/16 19:35

Hi everyone

For a poor man's cloth simulation, how would you iterate through each vertex of a 3d model, then assign each vertex "neighbors" to push and pull? Is there any function or way to see if one vertex is the neighbor of another? if they share the same edge, or same triangle?

this is more of a just for fun thing instead of something that is important. I have done very simple cloth before in A6, but it was very inefficient and I dont dare to use the code again. What I did was just create an object for every single vertex of a 3d model, then cause these objects to move the mesh with vec_for_mesh. These objects had no neighbors/links.

Getting a single vertex to have "links" to other vertexes are the crux of cloth simulation, and I was wondering if you had any ideas laugh
Posted By: 3run

Re: Poor man's cloth - 11/11/16 20:09

Hi!

I remember Superku made something similar for his game. He used shader as far as I remember, look at his project's thread, or maybe you could PM him (or maybe he will see this topic, and will answer here grin ). Anyway, you could recreate your code from A6 in A8, but use 2d array intead (just a wild idea), something similar to fluidfill algorithm, where everything is seperated into the cells, and they are all connected between each other... Anyway, I'm just guessing laugh

Best regards!

Edit: here is the video I was talking about:
Superku 17.02.2012 - Cape Physics
Posted By: Superku

Re: Poor man's cloth - 11/12/16 10:57

Yeah, I don't think a sophisticated cloth simulation is useful for game development.
I watched this guy a few times on twitch: http://stoutgames.com/:cheongsam
He developed a physics based cloth simulation for his lady character. It was months of work, and from both a (CPU) resource and time perspective not worth the effort for any other normal game.

I've recently remade my cape physics because that old one was a little antiquated with a few drawbacks. The basic principle stayed the same, except no ent_animate anymore, just vertex shader rotations and deformations, based on lite-C parameters.
Posted By: rojart

Re: Poor man's cloth - 11/13/16 20:07

Why not to use the pXent_cloth function?
Posted By: jumpman

Re: Poor man's cloth - 11/14/16 21:22

hi friends!

I didnt want a cloth sim that was comprehensive, usually because its never done this way in games. Even at the tail end of a coat or skirt, the simulation is so bareboned and has so many things to prevent it from exploding. But I was just curious to see if it was possible, mainly to get a network of particles to tug on each other. Using vec_dist, you can make spherical collision forms to push the particle out and etc laugh
Posted By: jumpman

Re: Poor man's cloth - 11/14/16 22:50

by the way, anytime I run a physX cloth sample, either the flag sample that came with A8, or someone else's physX cloth, the cloth just disappears! Its like its a glitch. I can see that the other physics objects like the ball works and bounces around, but the cloth disappears. Any idea as to what could be happening? Ive included the correct includes and phys open and etc.
Posted By: 3run

Re: Poor man's cloth - 11/15/16 00:01

Originally Posted By: jumpman
by the way, anytime I run a physX cloth sample, either the flag sample that came with A8, or someone else's physX cloth, the cloth just disappears! Its like its a glitch. I can see that the other physics objects like the ball works and bounces around, but the cloth disappears. Any idea as to what could be happening? Ive included the correct includes and phys open and etc.
Same happens on my new PC... It disappears (I guess it's drawn by forces or something like that). GeForce GTX 750 Ti. I'm also interested to find out why this happens grin

Best regards!
Posted By: WretchedSid

Re: Poor man's cloth - 11/15/16 00:48

Originally Posted By: jumpman
Using vec_dist, you can make spherical collision forms to push the particle out and etc laugh

You would probably have more success running some form of Verlet integration on your vertices. I have to admit, I've only ever done ropes doing that, but you should still get very good looking results with it.

As to finding neighbours, the easiest way is to probably iterate over every vertex and figure out which ones are within X distant and storing that in some kind of lookup table so that you can quickly iterate over your nodes afterwards. The easiest (and least efficient, but who cares if you only ever do it once) method is to just iterate over every vertex and then have an inner loop going over every vertex again checking their distance.
Posted By: jumpman

Re: Poor man's cloth - 11/15/16 00:54

hey wretchedSid!

I have actually done 2 verlet particles that were actually able to pull on each other! The problem was that I didnt know how to get them running in time_step, as well as getting a chain of them linked to each other frown
© 2024 lite-C Forums