vec3_t anm_get_node_scaling(struct anm_node *node, anm_time_t tm) { vec3_t v; anm_time_t tm0 = animation_time(node, tm, 0); struct anm_animation *anim0 = anm_get_active_animation(node, 0); struct anm_animation *anim1 = anm_get_active_animation(node, 1); if(!anim0) { return v3_cons(1, 1, 1); } v.x = anm_get_value(anim0->tracks + ANM_TRACK_SCL_X, tm0); v.y = anm_get_value(anim0->tracks + ANM_TRACK_SCL_Y, tm0); v.z = anm_get_value(anim0->tracks + ANM_TRACK_SCL_Z, tm0); if(anim1) { vec3_t v1; anm_time_t tm1 = animation_time(node, tm, 1); v1.x = anm_get_value(anim1->tracks + ANM_TRACK_SCL_X, tm1); v1.y = anm_get_value(anim1->tracks + ANM_TRACK_SCL_Y, tm1); v1.z = anm_get_value(anim1->tracks + ANM_TRACK_SCL_Z, tm1); v.x = v.x + (v1.x - v.x) * node->cur_mix; v.y = v.y + (v1.y - v.y) * node->cur_mix; v.z = v.z + (v1.z - v.z) * node->cur_mix; } return v; }
void sbbut(int bn, int state) { if(state == GLUT_DOWN) { pos = v3_cons(0, 0, -6); rot = quat_cons(1, 0, 0, 0); glutPostRedisplay(); } }
scalar_t noise3(scalar_t x, scalar_t y, scalar_t z) { int i, j; int bx0, bx1, by0, by1, bz0, bz1; int b00, b10, b01, b11; scalar_t rx0, rx1, ry0, ry1, rz0, rz1; scalar_t sx, sy, sz; scalar_t u, v, a, b, c, d; if(!tables_valid) { init_noise(); tables_valid = 1; } setup(x, bx0, bx1, rx0, rx1); setup(y, by0, by1, ry0, ry1); setup(z, bz0, bz1, rz0, rz1); i = perm[bx0]; j = perm[bx1]; b00 = perm[i + by0]; b10 = perm[j + by0]; b01 = perm[i + by1]; b11 = perm[j + by1]; /* calculate hermite interpolating factors */ sx = s_curve(rx0); sy = s_curve(ry0); sz = s_curve(rz0); /* interpolate along the top slice of the cell */ u = v3_dot(grad3[b00 + bz0], v3_cons(rx0, ry0, rz0)); v = v3_dot(grad3[b10 + bz0], v3_cons(rx1, ry0, rz0)); a = lerp(u, v, sx); u = v3_dot(grad3[b01 + bz0], v3_cons(rx0, ry1, rz0)); v = v3_dot(grad3[b11 + bz0], v3_cons(rx1, ry1, rz0)); b = lerp(u, v, sx); c = lerp(a, b, sy); /* interpolate along the bottom slice of the cell */ u = v3_dot(grad3[b00 + bz0], v3_cons(rx0, ry0, rz1)); v = v3_dot(grad3[b10 + bz0], v3_cons(rx1, ry0, rz1)); a = lerp(u, v, sx); u = v3_dot(grad3[b01 + bz0], v3_cons(rx0, ry1, rz1)); v = v3_dot(grad3[b11 + bz0], v3_cons(rx1, ry1, rz1)); b = lerp(u, v, sx); d = lerp(a, b, sy); /* interpolate between slices */ return lerp(c, d, sz); }
void keyb(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: exit(0); case ' ': /* reset initial view */ pos = v3_cons(0, 0, -6); rot = quat_cons(1, 0, 0, 0); glutPostRedisplay(); default: break; } }