Rope of CircleParticle and SpringContraint is stretching.

2 views
Skip to first unread message

Celar

unread,
Jun 26, 2008, 6:03:34 AM6/26/08
to APE General
Hello,

I created a chain of CircleParticles connected to each other with
SpringContraints. One CircleParticle is draggable. I want the chain
(rope) to hold his length. Now is stretches out according how far you
would drag the circleparticle.

I build is with Flash CS3 so this code can be placed on the first
frame. No extra classes build yet. I added one extra class
"DragableCircleParticle" which can be found in the files from this
group (http://groups.google.com/group/ape-general/files).

import org.cove.ape.*;

APEngine.init(1/4);
APEngine.container = this;
APEngine.addMasslessForce(new Vector(0,8));


var color1:uint = 0x00ff00;
var color2:uint = 0xff00ff;

var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;

var anker:CircleParticle = new CircleParticle(240,0,10, true);
defaultGroup.addParticle(anker);

var cp1:CircleParticle = new CircleParticle(250,10,1);
defaultGroup.addParticle(cp1);

var sc1:SpringConstraint = new SpringConstraint(anker, cp1, 0.5,
false, 1);
sc1.restLength = 10;
sc1.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc1);

var cp2:CircleParticle = new CircleParticle(250,20,1);
defaultGroup.addParticle(cp2);

var sc2:SpringConstraint = new SpringConstraint(cp1, cp2, 0.5, false,
1);
sc2.restLength = 10;
sc2.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc2);

var cp3:DragableCircleParticle = new DragableCircleParticle(250,30,5);
defaultGroup.addParticle(cp3);

var sc3:SpringConstraint = new SpringConstraint(cp2, cp3, 0.5, false,
1);
sc3.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc3);

var cp4:CircleParticle = new CircleParticle(250,20,1);
defaultGroup.addParticle(cp4);

var sc4:SpringConstraint = new SpringConstraint(cp3, cp4, 0.5, false,
1);
sc4.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc4);

var cp5:CircleParticle = new CircleParticle(250,10,1);
defaultGroup.addParticle(cp5);

var sc5:SpringConstraint = new SpringConstraint(cp4, cp5, 0.5, false,
1);
sc5.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc5);

var sc6:SpringConstraint = new SpringConstraint(cp5, anker, 0.5,
false, 1);
sc6.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc6);


APEngine.addGroup(defaultGroup);


addEventListener(Event.ENTER_FRAME, run);

function run(evt:Event):void {
APEngine.step();
APEngine.paint();
}

function mouseDownHandler(evt:Event):void {
trace("click");
}

ben

unread,
Jul 7, 2008, 8:37:57 AM7/7/08
to APE General
Hello !

I'm not sure but what you're seraching for is create a chain with
constraints but no elasticity, and that can move where you drag it ???
Is it ????

Celar

unread,
Jul 7, 2008, 11:30:52 AM7/7/08
to APE General
Yes I want to create a chain with an object (label with text) attached
to it. But in the normal world the chain won't stretch (for example an
metal chain can't stretch).
The main problem is the stretching of the SpringConstraint. I want the
length to be an fixed length.

Jaye

unread,
Sep 2, 2008, 1:18:08 PM9/2/08
to APE General
What if you set the Stiffness value to 1...would that keep it from
stretching?

Sorry if this is an obvious wrong answer, I just started using APE. I
am searching for a solution to curved surfaces and have been toying
with the idea of making the curve or arc with a section of stiff
spring objects. Imagine taking the bridge example from the car demo
and laying it in an arc, placing the circle particles in a fixed
position and setting the spring value to the stiffest setting to
prevent stretching.

In your case, Celar, you would leave the circle particles' position
unfixed.
Reply all
Reply to author
Forward
0 new messages