Example #1
0
/**
 * Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs.
 * Probably for speed reasons, the coefficients are evaluated as
 * siiiibiiiisiiiibiiiisiiiibiiiisiiiibiiiis ...
 * where s is an evaluated value, i is a value interpolated from the others
 * and b might be either calculated or interpolated, depending on an
 * unexplained condition.
 *
 * @param step the size of a block "siiiibiiii"
 * @param in the cosine of the LSP data
 * @param part is 0 for 0...PI (positive cosine values) and 1 for PI...2PI
 *        (negative cosine values)
 * @param size the size of the whole output
 */
static inline void eval_lpcenv_or_interp(TwinVQContext *tctx,
                                         enum TwinVQFrameType ftype,
                                         float *out, const float *in,
                                         int size, int step, int part)
{
    int i;
    const TwinVQModeTab *mtab = tctx->mtab;
    const float *cos_tab      = tctx->cos_tabs[ftype];

    // Fill the 's'
    for (i = 0; i < size; i += step)
        out[i] =
            eval_lpc_spectrum(in,
                              get_cos(i, part, cos_tab, size),
                              mtab->n_lsp);

    // Fill the 'iiiibiiii'
    for (i = step; i <= size - 2 * step; i += step) {
        if (out[i + step] + out[i - step] > 1.95 * out[i] ||
            out[i + step]                 >= out[i - step]) {
            interpolate(out + i - step + 1, out[i], out[i - step], step - 1);
        } else {
            out[i - step / 2] =
                eval_lpc_spectrum(in,
                                  get_cos(i - step / 2, part, cos_tab, size),
                                  mtab->n_lsp);
            interpolate(out + i - step + 1, out[i - step / 2],
                        out[i - step], step / 2 - 1);
            interpolate(out + i - step / 2 + 1, out[i],
                        out[i - step / 2], step / 2 - 1);
        }
    }

    interpolate(out + size - 2 * step + 1, out[size - step],
                out[size - 2 * step], step - 1);
}
t_rgb		light_color(t_mesh *pov, t_llist *mesh, t_llist *spot, t_ray *l)
{
  float		cos;
  t_rgb		color;
  float		bright;

  bright = mesh->obj.color.bright;
  color = mesh->obj.color;

  cos = get_cos(mesh, l);
  color.r = color.r * (1 - bright) + spot->obj.color.r * bright;
  color.g = color.g * (1 - bright) + spot->obj.color.g * bright;
  color.b = color.b * (1 - bright) + spot->obj.color.b * bright;
  color.r = color.r * cos;
  color.g = color.g * cos;
  color.b = color.b * cos;
  color.rgb = compose(&color);
  return (color);
}
Example #3
0
void obj::camera::move(int direction) {
    int modifier = modifier_for_direction(direction);

    float auxAngle = angle / 180 * M_PI - (M_PI / 2);

    switch (direction) {
        case left:
        case right:
            i[0] += speed * std::cos(auxAngle) * modifier;
            i[2] += speed * std::sin(auxAngle) * modifier;

            break;
        case front:
        case back:
            i[0] += speed * modifier * get_cos();
            i[1] += speed * modifier * d[1];
            i[2] += speed * modifier * get_sin();

            break;
    }

    refresh_direction();
    refresh_look_at();
}
Example #4
0
/* updates positions of fires and also checks for collisions */
void update_fire(void) {
	int i, j;

	/* first loop to update all fires */
	for (i = 0; i < MAX_FIRES; i++) {
		if (fires[i].surface) {
			/* if the laser has expired, free the surface and set it as off, otherwise, update its information */
			if (current_time > fires[i].expire_time) {
				/* fire has expired */
				free_fire(i);
			} else {
				float factor = (((float)loop_length / 1000.0f) * (float)fires[i].velocity);
				fires[i].world_x += get_cos(fires[i].angle) * factor;
				fires[i].world_y += get_neg_sin(fires[i].angle) * factor;

				/* update the fire, hasnt expired yet */
				fires[i].screen_x = (short int)((int)fires[i].world_x - camera_x);
				fires[i].screen_y = (short int)((int)fires[i].world_y - camera_y);
			}
		}
	}

	/* second loop to check for collisions */
	for (i = 0; i < MAX_FIRES; i++) {
		if (fires[i].surface) {
			for (j = 0; j < MAX_SHIPS; j++) {
				if (ships[j]) {
					if ((current_time >= ships[j]->creation_delay) && (!ships[j]->landed) && (ships[j]->hull_strength > 0)) {
						if (fires[i].owner != ships[j]) {
							if (get_distance_sqrd(fires[i].world_x, fires[i].world_y, ships[j]->world_x, ships[j]->world_y) < (ships[j]->model->radius * ships[j]->model->radius)) {
								/* collision has occured */
								damage_ship(ships[j], &fires[i]);
								free_fire(i);
								/* do a check, it's possible the ship was destroyed and freed (and now null) in damage_ship() */
								if (ships[j])
									ship_was_fired_upon(ships[j]);
								j = num_ships; /* dont need to continue checking for more collisions, one is enough */
							}
						}
					}
				}
			}
		}
		/* need to recheck as a destroyed fire could have occured and 'i' may have been incremented */
		if (fires[i].surface) {
			for (j = 0; j < MAX_ASTEROIDS; j++) {
				if (asteroids[j].on) {
					if (get_distance_sqrd(fires[i].world_x, fires[i].world_y, asteroids[j].x, asteroids[j].y) < 2500) {
						/* collision has occured */
						damage_asteroid(j, fires[i].weapon->strength);
						free_fire(i);
						j = MAX_SHIPS; /* dont need to continue checking for more collisions, one is enough */
					}
				}
			}
		}
		/* need to recheck as a destroyed fire could have occured and 'i' may have been incremented */
		if (fires[i].surface) {
			if (fires[i].owner != player.ship) {
				if (get_distance_from_player_sqrd(fires[i].world_x, fires[i].world_y) < (player.ship->model->radius * player.ship->model->radius)) {
					damage_ship(player.ship, &fires[i]);
					free_fire(i);
				}
			}
		}
	}
}
Example #5
0
void obj::camera::refresh_direction() {
    d[0] =  get_cos() + i[0];
    d[2] =  get_sin() + i[2];
}