X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=tools%2Fropesim%2Fsrc%2Fmain.c;h=f300a570122aae67a42303d11a61e43beecfd4d2;hp=6345e45d25b2fd1f3b12f7de59f92453841ba239;hb=2ee531a10bad1036d2279f9b626da72e345a3b37;hpb=42675cece161caf9c65b1c944df2df4b1aacec81 diff --git a/tools/ropesim/src/main.c b/tools/ropesim/src/main.c index 6345e45..f300a57 100644 --- a/tools/ropesim/src/main.c +++ b/tools/ropesim/src/main.c @@ -31,7 +31,7 @@ cgm_vec3 gmove; /*cgm_quat grot = {0, 0, 0, 1};*/ float grot_theta, grot_phi; float ginner_xform[16], gouter_xform[16]; -cgm_vec3 ganchor[4]; +cgm_vec3 ganchor[4], manchor[4]; cgm_vec3 dbgvec[4]; @@ -64,11 +64,11 @@ int main(int argc, char **argv) return 0; } -#define ROPE_MASSES 4 +#define ROPE_MASSES 10 #define ROPE_SPRINGS (ROPE_MASSES - 1) -#define ROPE_LEN 1.0f -#define ROPE_MASSES_MASS 0.1f -#define ROPE_K 80.0f +#define ROPE_LEN 0.8f +#define ROPE_MASSES_MASS 0.01f +#define ROPE_K 180.0f int init(void) { @@ -106,6 +106,7 @@ int init(void) } rsim_init(&rsim); + rsim.damping = 0.3; ropes_tail = 0; /* anchor points on the inner gimbal */ @@ -114,14 +115,21 @@ int init(void) ganchor[i].y = (float)((i & 2) - 1) * 1.5f; ganchor[i].z = 0; + 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; jmasses[j].p = ganchor[i]; - rope->masses[j].p.y = ganchor[i].y - j * ROPE_LEN / ROPE_SPRINGS; + 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) { @@ -132,6 +140,7 @@ int init(void) } } 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; @@ -235,7 +244,7 @@ void display(void) cmesh_draw(mesh_gin); glPopMatrix(); - cmesh_draw(mesh_suz); + /*cmesh_draw(mesh_suz);*/ glPointSize(7); glBegin(GL_POINTS);