Sign in to follow this  
WhiskyJoe

Connect points on a grid for cloth/mass spring system

Recommended Posts

Hey guys,

I'm trying to create a sort of cloth simulation through a mass spring system and well, it's not the mass spring system I got a problem with (I have a sphere and a rope that behaves correctly) but I am stuck on creating a grid!

I started off with thinking simple, just go through all the points and connect them, this however will never work as every point will be connected to every other.
What I want to achieve is to connect all the neighboring points to each other, but I can't seem to wrap my head around how to do this efficiently! I keep on bumping on the problem that I don't want the end of one row connect to the beginning of the next row, or vice versa and I don't want hardcode every exception (imagine doing that for a 100 x 100 grid).

Can someone give me some pointers on how to efficiently connect all neighboring points on a grid? Or if this isn't the way to simulate cloth through a mass spring system (in my head it is) point me in the right direction for that.

Share this post


Link to post
Share on other sites
[quote name='Rld_' timestamp='1348087458' post='4981822']
I keep on bumping on the problem that I don't want the end of one row connect to the beginning of the next row, or vice versa and I don't want hardcode every exception (imagine doing that for a 100 x 100 grid).
[/quote]

Just don't connect the end of one row to the beginning of the next row. I don't think this is a hard problem: The solution looks like two nested loops.

Try some more. If you still can't solve it, post some code and maybe I can fix it.

Share this post


Link to post
Share on other sites
[quote name='alvaro' timestamp='1348089581' post='4981833']
[quote name='Rld_' timestamp='1348087458' post='4981822']
I keep on bumping on the problem that I don't want the end of one row connect to the beginning of the next row, or vice versa and I don't want hardcode every exception (imagine doing that for a 100 x 100 grid).
[/quote]

Just don't connect the end of one row to the beginning of the next row. I don't think this is a hard problem: The solution looks like two nested loops.

Try some more. If you still can't solve it, post some code and maybe I can fix it.
[/quote]

Yeah.. It was getting late and I over-complicated things for myself :P

I had in mind that I had to connect every point I meet to every neighbor, but obviously I would end up with double connections which aren't needed and in that case I would need to make a lot of exceptions for every side, up, down and diagonal when getting to a corner :)

I figured it out, but thanks anyway :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this