need advice for stretchable segment
Posted: Tue Aug 09, 2011 3:42 pm
I would like to create a series of circles connected by lines. The line lengths, however, should behave as damped spring constraints. Each segment has a circle at both ends. The segments must react to collisions with all circles other than the two at its ends.
Think of it as a stretchy chain that looks like ._._._._._._._
A bullet (.) that crosses this string should collide with it.
I know how to do this as a chain with fixed-length segments, but I need the segments to behave like damped springs. This is important because later I will connect the segments to create structures, and I need to control the spring constant so that the structures are rigid or soft.
How should I approach this in Chipmunk? I have two ideas, but not sure which approach to try first:
(1) Implement each line as a constraint that also reacts to collision detection.
or
(2) Implement each line as a stretchable segment body+shape that changes it's length based on the forces applied through the circle ends. Create a damped spring constraint between the circle ends to maintain the length of the segment.
Thoughts? What would be the simplest way to do this?
Think of it as a stretchy chain that looks like ._._._._._._._
A bullet (.) that crosses this string should collide with it.
I know how to do this as a chain with fixed-length segments, but I need the segments to behave like damped springs. This is important because later I will connect the segments to create structures, and I need to control the spring constant so that the structures are rigid or soft.
How should I approach this in Chipmunk? I have two ideas, but not sure which approach to try first:
(1) Implement each line as a constraint that also reacts to collision detection.
or
(2) Implement each line as a stretchable segment body+shape that changes it's length based on the forces applied through the circle ends. Create a damped spring constraint between the circle ends to maintain the length of the segment.
Thoughts? What would be the simplest way to do this?