static void reset_floater (ModeInfo *mi, floater *f) { cow_configuration *bp = &bps[MI_SCREEN(mi)]; f->y = -BOTTOM; f->x = f->ix; f->z = f->iz; /* Yes, I know I'm varying the force of gravity instead of varying the launch velocity. That's intentional: empirical studies indicate that it's way, way funnier that way. */ f->dy = 5.0; f->dx = 0; f->dz = 0; /* -0.18 max -0.3 top -0.4 middle -0.6 bottom */ f->ddy = speed * (-0.6 + BELLRAND(0.45)); f->ddx = 0; f->ddz = 0; f->spinner_p = !(random() % (12 * bp->nfloaters)); if (! (random() % (30 * bp->nfloaters))) { f->dx = BELLRAND(1.8) * RANDSIGN(); f->dz = BELLRAND(1.8) * RANDSIGN(); } }
static void init_spin (struct disc *disc) { disc->limit = 5*64; disc->theta = RAND(360*64); disc->velocity = RAND(16) * RANDSIGN(); disc->acceleration = RAND(16) * RANDSIGN(); }
void init_gasket(ModeInfo *mi) { int screen = MI_SCREEN(mi); gasketstruct *gp; if (gasket == NULL) { if ((gasket = (gasketstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (gasketstruct))) == NULL) return; } gp = &gasket[screen]; gp->window = MI_WINDOW(mi); gp->rotx = FLOATRAND(1.0) * RANDSIGN(); gp->roty = FLOATRAND(1.0) * RANDSIGN(); gp->rotz = FLOATRAND(1.0) * RANDSIGN(); /* bell curve from 0-1.5 degrees, avg 0.75 */ gp->dx = (FLOATRAND(1) + FLOATRAND(1) + FLOATRAND(1)) / (360*2); gp->dy = (FLOATRAND(1) + FLOATRAND(1) + FLOATRAND(1)) / (360*2); gp->dz = (FLOATRAND(1) + FLOATRAND(1) + FLOATRAND(1)) / (360*2); gp->d_max = gp->dx * 2; gp->ddx = 0.00006 + FLOATRAND(0.00003); gp->ddy = 0.00006 + FLOATRAND(0.00003); gp->ddz = 0.00006 + FLOATRAND(0.00003); gp->ddx = 0.00001; gp->ddy = 0.00001; gp->ddz = 0.00001; intens_factor = intensity / 65536000.0; gp->ncolors = 255; gp->colors = (XColor *) calloc(gp->ncolors, sizeof(XColor)); make_smooth_colormap (mi, None, gp->colors, &gp->ncolors, False, (Bool *) NULL); if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_gasket(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); pinit(mi); } else { MI_CLEARWINDOW(mi); } }
static void move_blob(blob * b, int maxx, int maxy) { maxx *= SCALE; maxy *= SCALE; b->x += b->dx; b->y += b->dy; /* If we've reached the edge of the box, reverse direction. */ if ((b->x > maxx && b->dx >= 0) || (b->x < 0 && b->dx < 0)) { b->dx = -b->dx; } if ((b->y > maxy && b->dy >= 0) || (b->y < 0 && b->dy < 0)) { b->dy = -b->dy; } /* Alter velocity randomly. */ if (!(LRAND() % 10)) { b->dx += (NRAND(b->max_velocity / 2) * RANDSIGN()); b->dy += (NRAND(b->max_velocity / 2) * RANDSIGN()); /* Throttle velocity */ if (b->dx > b->max_velocity || b->dx < -b->max_velocity) b->dx /= 2; if (b->dy > b->max_velocity || b->dy < -b->max_velocity) b->dy /= 2; } { double th = b->th; double d = (b->torque == 0 ? 0 : (b->torque) * LRAND() / MAXRAND); if (th < 0) th = -(th + d); else th += d; if (th > (M_PI + M_PI)) th -= (M_PI + M_PI); else if (th < 0) th += (M_PI + M_PI); b->th = (b->th > 0 ? th : -th); } /* Alter direction of rotation randomly. */ if (!(LRAND() % 100)) b->th *= -1; }
static Bool make_blob(blob * b, int maxx, int maxy, int size) { int i; long mid; maxx *= SCALE; maxy *= SCALE; size *= SCALE; b->max_r = size / 2; b->min_r = size / 10; if (b->min_r < (5 * SCALE)) b->min_r = (5 * SCALE); mid = ((b->min_r + b->max_r) / 2); b->torque = 0.0075; /* torque init */ b->elasticity = (long) (SCALE * 1.8); /* elasticity init */ b->max_velocity = (long) (SCALE * 1.2); /* max_velocity init */ b->x = NRAND(maxx); b->y = NRAND(maxy); b->dx = NRAND(b->max_velocity) * RANDSIGN(); b->dy = NRAND(b->max_velocity) * RANDSIGN(); b->th = (2.0 * M_PI) * LRAND() / MAXRAND * RANDSIGN(); b->npoints = (int) (LRAND() % 5) + 5; b->splines = make_spline(b->npoints); if ((b->r = (long *) malloc(sizeof (*b->r) * b->npoints)) == NULL) return False; for (i = 0; i < b->npoints; i++) b->r[i] = ((LRAND() % mid) + (mid / 2)) * RANDSIGN(); return True; }
static void add_random_oscillator (ModeInfo *mi) { cube_configuration *bp = &bps[MI_SCREEN(mi)]; cube *c = bp->cubes; double s1 = speed * 0.07; double s2 = speed * 0.3; double disp = (thickness + displacement); int c1 = 1 + ((random() % 4) ? 0 : (random() % 3)); int c2 = 2; int n = random() % 6; switch (n) { case 0: add_oscillator (mi, &c->rot.x, s1, 90 * RANDSIGN(), c1); break; case 1: add_oscillator (mi, &c->rot.y, s1, 90 * RANDSIGN(), c1); break; case 2: add_oscillator (mi, &c->rot.z, s1, 90 * RANDSIGN(), c1); break; case 3: add_oscillator (mi, &c->pos.x, s2, disp * RANDSIGN(), c2); break; case 4: add_oscillator (mi, &c->pos.y, s2, disp * RANDSIGN(), c2); break; case 5: add_oscillator (mi, &c->pos.z, s2, disp * RANDSIGN(), c2); break; default: abort(); break; } }
static void build_ball (ModeInfo *mi) { ball_configuration *bp = &bps[MI_SCREEN(mi)]; int rows = MI_COUNT (mi); GLfloat tile_size = M_PI / rows; GLfloat th0, th1; struct { XYZ position; GLfloat strength; } dents[5]; int dent_count = random() % countof(dents); int i; for (i = 0; i < dent_count; i++) { GLfloat dist; dents[i].position.x = RANDSIGN() * (2 - BELLRAND(0.2)); dents[i].position.y = RANDSIGN() * (2 - BELLRAND(0.2)); dents[i].position.z = RANDSIGN() * (2 - BELLRAND(0.2)); dist = sqrt (dents[i].position.x * dents[i].position.x + dents[i].position.y * dents[i].position.y + dents[i].position.z * dents[i].position.z); dents[i].strength = dist - (1 - BELLRAND(0.3)); dents[i].strength = dist - (1 - BELLRAND(0.3)); } for (th1 = M_PI/2; th1 > -(M_PI/2 + tile_size/2); th1 -= tile_size) { GLfloat x = cos (th1); GLfloat y = sin (th1); GLfloat x0 = cos (th1 - tile_size/2); GLfloat x1 = cos (th1 + tile_size/2); GLfloat circ0 = M_PI * x0 * 2; GLfloat circ1 = M_PI * x1 * 2; GLfloat circ = (circ0 < circ1 ? circ0 : circ1); int row_tiles = floor ((circ < 0 ? 0 : circ) / tile_size); GLfloat spacing; GLfloat dropsy = 0.13 + frand(0.04); if (row_tiles <= 0) row_tiles = 1; spacing = M_PI*2 / row_tiles; for (th0 = 0; th0 < M_PI*2; th0 += spacing) { tile *t = (tile *) calloc (1, sizeof(*t)); t->size = tile_size * 0.85; t->position.x = cos (th0) * x; t->position.y = sin (th0) * x; t->position.z = y; t->normal = t->position; /* Apply pressure on position from the dents. */ for (i = 0; i < dent_count; i++) { GLfloat dist; XYZ direction; if (! (random() % 150)) /* Drop tiles randomly */ { free (t); goto SKIP; } direction.x = t->position.x - dents[i].position.x; direction.y = t->position.y - dents[i].position.y; direction.z = t->position.z - dents[i].position.z; dist = sqrt (direction.x * direction.x + direction.y * direction.y + direction.z * direction.z); if (dist < dents[i].strength) { GLfloat s = 1 - (dents[i].strength - dist) * 0.66; XYZ n2 = t->normal; GLfloat angle = vector_angle (t->position, dents[i].position); /* Drop out the tiles near the apex of the dent. */ if (angle < dropsy) { free (t); goto SKIP; } t->position.x *= s; t->position.y *= s; t->position.z *= s; direction = normalize (direction); n2.x -= direction.x; n2.y -= direction.y; n2.z -= direction.z; t->normal.x = (t->normal.x + n2.x) / 2; t->normal.y = (t->normal.y + n2.y) / 2; t->normal.z = (t->normal.z + n2.z) / 2; } } /* Skew the direction the tile is facing slightly. */ t->normal.x += 0.12 - frand(0.06); t->normal.y += 0.12 - frand(0.06); t->normal.z += 0.12 - frand(0.06); t->tilt = 4 - BELLRAND(8); t->next = bp->tiles; bp->tiles = t; SKIP: ; } } bp->nrays = 5 + BELLRAND(10); bp->rays = (ray *) calloc (bp->nrays, sizeof(*bp->rays)); for (i = 0; i < bp->nrays; i++) { GLfloat th = frand(M_PI * 2); bp->rays[i].normal.x = cos (th); bp->rays[i].normal.y = sin (th); bp->rays[i].normal.z = 1; bp->rays[i].normal = normalize (bp->rays[i].normal); bp->rays[i].color[0] = 0.9 + frand(0.1); bp->rays[i].color[1] = 0.6 + frand(0.4); bp->rays[i].color[2] = 0.6 + frand(0.2); bp->rays[i].color[3] = 1; } }
/* Returns a rotator object, which encapsulates rotation and motion state. spin_[xyz]_speed indicates the relative speed of rotation. Specify 0 if you don't want any rotation around that axis. spin_accel specifies a scaling factor for the acceleration that is randomly applied to spin: if you want the speed to change faster, make this > 1. wander_speed indicates the relative speed through space. If randomize_initial_state_p is true, then the initial position and rotation will be randomized (even if the spin speeds are 0.) If it is false, then all values will be initially zeroed. */ rotator * make_rotator (double spin_x_speed, double spin_y_speed, double spin_z_speed, double spin_accel, double wander_speed, int randomize_initial_state_p) { rotator *r = (rotator *) calloc (1, sizeof(*r)); double d, dd; if (!r) return 0; if (spin_x_speed < 0 || spin_y_speed < 0 || spin_z_speed < 0 || wander_speed < 0) abort(); r->spin_x_speed = spin_x_speed; r->spin_y_speed = spin_y_speed; r->spin_z_speed = spin_z_speed; r->wander_speed = wander_speed; if (randomize_initial_state_p) { r->rotx = FLOATRAND(1.0) * RANDSIGN(); r->roty = FLOATRAND(1.0) * RANDSIGN(); r->rotz = FLOATRAND(1.0) * RANDSIGN(); r->wander_frame = LRAND() % 0xFFFF; } else { r->rotx = r->roty = r->rotz = 0; r->wander_frame = 0; } d = 0.006; dd = 0.00006; r->dx = BELLRAND(d * r->spin_x_speed); r->dy = BELLRAND(d * r->spin_y_speed); r->dz = BELLRAND(d * r->spin_z_speed); r->d_max = r->dx * 2; r->ddx = (dd + FLOATRAND(dd+dd)) * r->spin_x_speed * spin_accel; r->ddy = (dd + FLOATRAND(dd+dd)) * r->spin_y_speed * spin_accel; r->ddz = (dd + FLOATRAND(dd+dd)) * r->spin_z_speed * spin_accel; # if 0 fprintf (stderr, "rotator:\n"); fprintf (stderr, " wander: %3d %6.2f\n", r->wander_frame, r->wander_speed); fprintf (stderr, " speed: %6.2f %6.2f %6.2f\n", r->spin_x_speed, r->spin_y_speed, r->spin_z_speed); fprintf (stderr, " rot: %6.2f %6.2f %6.2f\n", r->rotx, r->roty, r->rotz); fprintf (stderr, " d: %6.2f %6.2f %6.2f, %6.2f\n", r->dx, r->dy, r->dz, r->d_max); fprintf (stderr, " dd: %6.2f %6.2f %6.2f\n", r->ddx, r->ddy, r->ddz); # endif return r; }
static void animate (ModeInfo *mi) { lament_configuration *lc = &lcs[MI_SCREEN(mi)]; int pause = 10; int pause2 = 120; GLfloat speed = (lc->ffwdp ? 20 : 1); switch (lc->type) { case LAMENT_BOX: { lc->state++; if (lc->state >= lc->nstates) { shuffle_states (lc); lc->state = 0; } lc->type = lc->states[lc->state]; if (lc->type == LAMENT_BOX) lc->anim_pause = pause2; lc->anim_r = 0.0; lc->anim_y = 0.0; lc->anim_z = 0.0; } break; /* -------------------------------------------------------------- */ case LAMENT_STAR_OUT: lc->anim_z += 0.01 * speed; if (lc->anim_z >= 1.0) { lc->anim_z = 1.0; lc->type = LAMENT_STAR_ROT; lc->anim_pause = pause; } break; case LAMENT_STAR_ROT: lc->anim_r += 1.0 * speed; if (lc->anim_r >= 45.0) { lc->anim_r = 45.0; lc->type = LAMENT_STAR_ROT_IN; lc->anim_pause = pause; } break; case LAMENT_STAR_ROT_IN: lc->anim_z -= 0.01 * speed; if (lc->anim_z <= 0.0) { lc->anim_z = 0.0; lc->type = LAMENT_STAR_ROT_OUT; lc->anim_pause = pause2 * (1 + frand(2) + frand(2)); } break; case LAMENT_STAR_ROT_OUT: lc->anim_z += 0.01 * speed; if (lc->anim_z >= 1.0) { lc->anim_z = 1.0; lc->type = LAMENT_STAR_UNROT; lc->anim_pause = pause; } break; case LAMENT_STAR_UNROT: lc->anim_r -= 1.0 * speed; if (lc->anim_r <= 0.0) { lc->anim_r = 0.0; lc->type = LAMENT_STAR_IN; lc->anim_pause = pause; } break; case LAMENT_STAR_IN: lc->anim_z -= 0.01 * speed; if (lc->anim_z <= 0.0) { lc->anim_z = 0.0; lc->type = LAMENT_BOX; lc->anim_pause = pause2; } break; /* -------------------------------------------------------------- */ case LAMENT_TETRA_UNE: case LAMENT_TETRA_USW: case LAMENT_TETRA_DWN: case LAMENT_TETRA_DSE: lc->anim_r += 1.0 * speed; if (lc->anim_r >= 360.0) { lc->anim_r = 0.0; lc->type = LAMENT_BOX; lc->anim_pause = pause2; } else if (lc->anim_r > 119.0 && lc->anim_r <= 120.0) { lc->anim_r = 120.0; lc->anim_pause = pause; } else if (lc->anim_r > 239.0 && lc->anim_r <= 240.0) { lc->anim_r = 240.0; lc->anim_pause = pause; } break; /* -------------------------------------------------------------- */ case LAMENT_LID_OPEN: lc->anim_r += 1.0 * speed; if (lc->anim_r >= 112.0) { lc->anim_r = 112.0; lc->anim_z = 0.0; lc->anim_pause = pause2; lc->type = (lc->facing_p ? LAMENT_LID_ZOOM : LAMENT_LID_CLOSE); } break; case LAMENT_LID_CLOSE: lc->anim_r -= 1.0 * speed; if (lc->anim_r <= 0.0) { lc->anim_r = 0.0; lc->type = LAMENT_BOX; lc->anim_pause = pause2; } break; case LAMENT_LID_ZOOM: lc->anim_z += 0.01 * speed; if (lc->anim_z > 1.0) { lc->anim_r = 0.0; lc->anim_z = 0.0; lc->type = LAMENT_BOX; } break; /* -------------------------------------------------------------- */ case LAMENT_TASER_OUT: lc->anim_z += 0.005 * speed; if (lc->anim_z >= 0.5) { lc->anim_z = 0.5; lc->type = LAMENT_TASER_SLIDE; lc->anim_pause = pause * (1 + frand(5) + frand(5)); } break; case LAMENT_TASER_SLIDE: lc->anim_y += 0.005 * speed; if (lc->anim_y >= 0.255) { lc->anim_y = 0.255; lc->type = LAMENT_TASER_SLIDE_IN; lc->anim_pause = pause2 * (1 + frand(5) + frand(5)); } break; case LAMENT_TASER_SLIDE_IN: lc->anim_y -= 0.0025 * speed; if (lc->anim_y <= 0.0) { lc->anim_y = 0.0; lc->type = LAMENT_TASER_IN; lc->anim_pause = pause; } break; case LAMENT_TASER_IN: lc->anim_z -= 0.0025 * speed; if (lc->anim_z <= 0.0) { lc->anim_z = 0.0; lc->type = LAMENT_BOX; lc->anim_pause = pause2; } break; /* -------------------------------------------------------------- */ case LAMENT_PILLAR_OUT: if (lc->anim_y == 0) /* mostly in */ lc->anim_y += 0.005 * ((random() % 5) ? -1 : 1) * speed; else if (lc->anim_y > 0) lc->anim_y += 0.005 * speed; else lc->anim_y -= 0.001 * speed; if (lc->anim_z == 0) { int i = (random() % 7); /* A, B or both */ if (i == 0) lc->anim_z = 3; else if (i < 5) lc->anim_z = 2; else lc->anim_z = 1; /* We can do quarter turns, because it's radially symmetrical. */ lc->anim_r = 90.0 * (1 + frand(6)) * RANDSIGN(); } if (lc->anim_y > 0.4) { lc->anim_y = 0.4; lc->type = LAMENT_PILLAR_SPIN; lc->anim_pause = pause; } else if (lc->anim_y < -0.03) { lc->anim_y = -0.03; lc->type = LAMENT_PILLAR_SPIN; lc->anim_pause = pause; } break; case LAMENT_PILLAR_SPIN: { Bool negp = (lc->anim_r < 0); lc->anim_r += (negp ? 1 : -1) * speed; if (negp ? lc->anim_r > 0 : lc->anim_r < 0) { lc->anim_r = 0; lc->type = LAMENT_PILLAR_IN; } } break; case LAMENT_PILLAR_IN: { Bool negp = (lc->anim_y < 0); lc->anim_y += (negp ? 1 : -1) * 0.005 * speed; if (negp ? lc->anim_y > 0 : lc->anim_y < 0) { lc->anim_y = 0; lc->anim_z = 0; lc->type = LAMENT_BOX; lc->anim_pause = pause; } } break; /* -------------------------------------------------------------- */ case LAMENT_SPHERE_OUT: { lc->anim_y += 0.01 * speed; if (lc->anim_y >= 1) { lc->anim_y = 1; lc->type = LAMENT_SPHERE_IN; lc->anim_pause = pause2 * (1 + frand(1) + frand(1)); } } break; case LAMENT_SPHERE_IN: { lc->anim_y -= 0.01 * speed; if (lc->anim_y <= 0) { lc->anim_y = 0; lc->type = LAMENT_BOX; lc->anim_pause = pause; } } break; /* -------------------------------------------------------------- */ case LAMENT_LEVIATHAN_SPIN: lc->anim_r += 3.5 * speed; if (lc->anim_r >= 360 * 3) { lc->anim_r = 0; lc->type = LAMENT_LEVIATHAN_FADE; lc->anim_pause = 0; } break; case LAMENT_LEVIATHAN_FADE: lc->anim_z += 0.01 * speed; if (lc->anim_z >= 1) { lc->anim_z = 1; lc->type = LAMENT_LEVIATHAN_TWIST; lc->anim_pause = 0; } break; case LAMENT_LEVIATHAN_TWIST: lc->anim_y += 2 * speed; lc->anim_z = 1; if (lc->anim_y >= 180) { lc->anim_y = 0; lc->type = LAMENT_LEVIATHAN_COLLAPSE; lc->anim_pause = 0; } break; case LAMENT_LEVIATHAN_COLLAPSE: lc->anim_y += 0.01 * speed; if (lc->anim_y >= 1) { lc->anim_y = 1.0; lc->type = LAMENT_LEVIATHAN_EXPAND; lc->anim_pause = pause2 * 4; } break; case LAMENT_LEVIATHAN_EXPAND: lc->anim_y -= 0.005 * speed; if (lc->anim_y <= 0) { lc->anim_y = 180; lc->type = LAMENT_LEVIATHAN_UNTWIST; } break; case LAMENT_LEVIATHAN_UNTWIST: lc->anim_y -= 2 * speed; lc->anim_z = 1; if (lc->anim_y <= 0) { lc->anim_y = 0; lc->type = LAMENT_LEVIATHAN_UNFADE; lc->anim_pause = 0; } break; case LAMENT_LEVIATHAN_UNFADE: lc->anim_z -= 0.1 * speed; if (lc->anim_z <= 0) { lc->anim_z = 0; lc->type = LAMENT_LEVIATHAN_UNSPIN; lc->anim_pause = 0; } break; case LAMENT_LEVIATHAN_UNSPIN: lc->anim_r += 3.5 * speed; if (lc->anim_r >= 360 * 2) { lc->anim_r = 0; lc->type = LAMENT_BOX; lc->anim_pause = pause2; } break; default: abort(); break; } # ifdef DEBUG_MODE lc->anim_pause = 0; if (lc->type == LAMENT_BOX) lc->type = DEBUG_MODE; if (lc->ffwdp) { lc->ffwdp = 0; while (lc->type != DEBUG_MODE) animate (mi); } # else /* !DEBUG_MODE */ if (lc->ffwdp && lc->type == LAMENT_BOX) { lc->ffwdp = 0; while (lc->type == LAMENT_BOX) animate (mi); lc->anim_pause = 0; } # endif /* !DEBUG_MODE */ }
static struct starfish * make_starfish (struct state *st, int maxx, int maxy, int size) { struct starfish *s = (struct starfish *) calloc(1, sizeof(*s)); int i; s->blob_p = st->blob_p; s->elasticity = SCALE * get_float_resource (st->dpy, "thickness", "Thickness"); if (s->elasticity == 0) /* bell curve from 0-15, avg 7.5 */ s->elasticity = RAND(5*SCALE) + RAND(5*SCALE) + RAND(5*SCALE); s->rotv = get_float_resource (st->dpy, "rotation", "Rotation"); if (s->rotv == -1) /* bell curve from 0-12 degrees, avg 6 */ s->rotv = frand(4) + frand(4) + frand(4); s->rotv /= 360; /* convert degrees to ratio */ if (s->blob_p) { s->elasticity *= 3; s->rotv *= 3; } s->rot_max = s->rotv * 2; s->rota = 0.0004 + frand(0.0002); if (! (random() % 20)) size *= frand(0.35) + frand(0.35) + 0.3; { static const char skips[] = { 2, 2, 2, 2, 3, 3, 3, 6, 6, 12 }; s->skip = skips[random() % sizeof(skips)]; } if (! (random() % (s->skip == 2 ? 3 : 12))) s->mode = zoom; else s->mode = pulse; maxx *= SCALE; maxy *= SCALE; size *= SCALE; s->max_r = size; s->min_r = 0; if (s->min_r < (5*SCALE)) s->min_r = (5*SCALE); s->x = maxx/2; s->y = maxy/2; s->th = frand(M_PI+M_PI) * RANDSIGN(); { static const char sizes[] = { 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 8, 8, 8, 10, 35 }; int nsizes = sizeof(sizes); if (s->skip > 3) nsizes -= 4; s->npoints = s->skip * sizes[random() % nsizes]; } s->spline = make_spline (s->npoints); s->r = (long *) malloc (sizeof(*s->r) * s->npoints); for (i = 0; i < s->npoints; i++) s->r[i] = ((i % s->skip) == 0) ? 0 : size; return s; }
void init_molecule (ModeInfo *mi) { molecule_configuration *mc; int wire; #ifndef STANDALONE timeout = MI_CYCLES(mi); #endif if (!mcs) { mcs = (molecule_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (molecule_configuration)); if (!mcs) { return; } } mc = &mcs[MI_SCREEN(mi)]; if (mc->glx_context) { /* Free font stuff */ free_fonts (mi); } if ((mc->glx_context = init_GL(mi)) != NULL) { glDrawBuffer(GL_BACK); gl_init(); last = 0; reshape_molecule (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } if (!load_fonts (mi)) { release_molecule(mi); return; } if (firstcall) startup_blurb (mi); cur_wire = MI_IS_WIREFRAME(mi); wire = cur_wire; mc->rotx = FLOATRAND(1.0) * RANDSIGN(); mc->roty = FLOATRAND(1.0) * RANDSIGN(); mc->rotz = FLOATRAND(1.0) * RANDSIGN(); /* bell curve from 0-6 degrees, avg 3 */ mc->dx = (FLOATRAND(0.1) + FLOATRAND(0.1) + FLOATRAND(0.1)) / (360/2); mc->dy = (FLOATRAND(0.1) + FLOATRAND(0.1) + FLOATRAND(0.1)) / (360/2); mc->dz = (FLOATRAND(0.1) + FLOATRAND(0.1) + FLOATRAND(0.1)) / (360/2); mc->d_max = mc->dx * 8; mc->ddx = 0.00006 + FLOATRAND(0.00003); mc->ddy = 0.00006 + FLOATRAND(0.00003); mc->ddz = 0.00006 + FLOATRAND(0.00003); { char *s = do_spin; while (*s) { if (*s == 'x' || *s == 'X') mc->spin_x = 1; else if (*s == 'y' || *s == 'Y') mc->spin_y = 1; else if (*s == 'z' || *s == 'Z') mc->spin_z = 1; else { (void) fprintf (stderr, "molecule: spin must contain only the characters X, Y, or Z (not \"%s\")\n", do_spin); /* exit (1); */ } s++; } } mc->molecule_dlist = glGenLists(1); load_molecules (mi); mc->which = NRAND(mc->nmolecules); #ifdef STANDALONE mc->no_label_threshold = get_float_resource ("noLabelThreshold", "NoLabelThreshold"); mc->wireframe_threshold = get_float_resource ("wireframeThreshold", "WireframeThreshold"); #else mc->no_label_threshold = 30; mc->wireframe_threshold = 150; #endif if (wire) do_bonds = 1; }