+
+ manchor[i] = ganchor[i];
+ cgm_vscale(manchor + i, 0.32);
+
+
+
+ manchor[i].y += 0.15;
+
+ /* create a rope hanging from the anchor point */
+ if(!(rope = rsim_alloc_rope(ROPE_MASSES, ROPE_SPRINGS))) {
+ fprintf(stderr, "failed to allocate rope\n");
+ return -1;
+ }
+ for(j=0; j<ROPE_MASSES; j++) {
+ float t = (float)j / (float)(ROPE_MASSES - 1.0f);
+ cgm_vlerp(&rope->masses[j].p, ganchor + i, manchor + i, t);
+ rope->masses[j].m = 0.1f;
+
+ if(j < ROPE_SPRINGS) {
+ rope->springs[j].rest_len = ROPE_LEN / ROPE_SPRINGS;
+ rope->springs[j].k = ROPE_K;
+ rope->springs[j].mass[0] = rope->masses + j;
+ rope->springs[j].mass[1] = rope->masses + j + 1;
+ }
+ }
+ rsim_freeze_rope_mass(rope, rope->masses); /* freeze first mass */
+ rsim_freeze_rope_mass(rope, rope->masses + j - 1); /* freeze last mass */
+
+ if(!ropes_tail) {
+ rsim.ropes = ropes_tail = rope;
+ } else {
+ ropes_tail->next = rope;
+ ropes_tail = rope;
+ }
+ rope->next = 0;