Connect points on a grid for cloth/mass spring system

Started by
1 comment, last by WhiskyJoe 11 years, 6 months ago
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.
Advertisement

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).


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 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).


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 :)

This topic is closed to new replies.

Advertisement