Exemple #1
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetVerticalSync(true);
    ofBackground(0);
    for(int i=0;i<4; i++){
        SpringJoint sj;
        sj.pos = ofVec2f(ofGetWidth()/2,10+i*195);
        jointList.push_back(sj);
    }
    
    for(int i=0;i<jointList.size()-1; i++){
        Spring s;
        s.set(&jointList[i], &jointList[i+1], 0.05, 200);
        springList.push_back(s);
    }
    Spring s;
    s.set(&jointList[jointList.size()-1], &jointList[0], 0.05, 200);
    springList.push_back(s);
}
Exemple #2
0
void Ribbon::connectSpring(){
    // Connect
    for(int i = 0; i < myParticles.size() - 1; i++){
        ofPoint dist = myParticles[i].pos - myParticles[i + 1].pos;
        float len = dist.length();
        Spring newSpring;
        newSpring.set( &myParticles[i], &myParticles[i + 1], 0.05, len);
        springList.push_back( newSpring );
    }
}