/******************************************************************************\ Computes tile vectors for the parameter array. \******************************************************************************/ static void compute_tile_vectors(int i) { c_vec3_t ab, ac; /* Set tile normal vector */ ab = C_vec3_sub(r_globe_verts[3 * i].v.co, r_globe_verts[3 * i + 1].v.co); ac = C_vec3_sub(r_globe_verts[3 * i].v.co, r_globe_verts[3 * i + 2].v.co); r_tiles[i].normal = C_vec3_norm(C_vec3_cross(ab, ac)); r_globe_verts[3 * i].v.no = r_tiles[i].normal; r_globe_verts[3 * i + 1].v.no = r_tiles[i].normal; r_globe_verts[3 * i + 2].v.no = r_tiles[i].normal; /* Centroid */ r_tiles[i].origin = C_vec3_add(r_globe_verts[3 * i].v.co, r_globe_verts[3 * i + 1].v.co); r_tiles[i].origin = C_vec3_add(r_tiles[i].origin, r_globe_verts[3 * i + 2].v.co); r_tiles[i].origin = C_vec3_divf(r_tiles[i].origin, 3.f); /* Forward vector */ r_tiles[i].forward = C_vec3_sub(r_globe_verts[3 * i].v.co, r_tiles[i].origin); r_tiles[i].forward = C_vec3_norm(r_tiles[i].forward); }
/******************************************************************************\ Begin a gradual rotation to the target normal. \******************************************************************************/ void R_rotate_cam_to(c_vec3_t pos) { c_vec3_t norm_origin; if (!pos.x && !pos.y && !pos.z) return; norm_origin = C_vec3_norm(r_cam_origin); pos = C_vec3_norm(pos); gradual_axis = C_vec3_norm(C_vec3_cross(pos, norm_origin)); gradual_angle = acosf(C_vec3_dot(pos, norm_origin)); if (gradual_angle < 0.f) { gradual_angle = -gradual_angle; gradual_axis = C_vec3_scalef(gradual_axis, -1.f); } R_grab_cam(); cam_gradual = TRUE; }