Esempio n. 1
0
File: sun.c Progetto: Ngoguey42/scop
void			sp_sunskin_update_autotess(t_env *e)
{
	int		i;
	float	dist;

	dist = v3_dist(e->sunpos_cartesian, e->cpos);
	i = 0;
	while (1)
	{
		if (dist < g_sun_tess[i][0])
		{
			e->sunskin_tessin = g_sun_tess[i][1];
			e->sunskin_tessout[0] = g_sun_tess[i][2];
			e->sunskin_tessout[1] = g_sun_tess[i][2];
			e->sunskin_tessout[2] = g_sun_tess[i][2];
			return ;
		}
		i++;
	}
	return ;
}
Esempio n. 2
0
File: sim.c Progetto: piotrm0/progs
GLvoid sample_world() {
  //  int timing;
  u_int i,j,d;
  //  float t0,t1,t2;

  v3* temp;
  v3* disp;
  //  v3* disp2;
  float dot;
  float dm;

  char* temp_s1;
  char* temp_s2;

  for (i = 0; i < PARTICLES; i++) {
    //    printf("adding g %d,%f\n", i,ps[i].v[1]);
    v3_add(ps[i].v, gr);
    //    ps[i].v->v[1] -= g;

    v3_mult(ps[i].v, LOSS_V);
    for (d = 0; d < D; d++) {
      v3_mult_add(ps[i].c, ps[i].v, 1 / (float) SPS); //  ps[i].c[d] += ps[i].v[d] / (float) SPS;
      if (ps[i].c->v[d] < -B + RADIUS) {

	disp = v3_new(0,0,0);
	disp->v[d] = ps[i].c->v[d] + B;
	dm = 1 / (1 - (RADIUS - v3_mag(disp)) / RADIUS);
	v3_unit(disp);

	v3_mult_add(ps[i].v, disp, dm * LOSS_WALL * dt);

	//	ps[i].c->v[d] = -B + RADIUS;
	//	ps[i].v->v[d] *= -1 * LOSS_WALL;

      }
      if (ps[i].c->v[d] > B - RADIUS) {

	disp = v3_new(0,0,0);
	disp->v[d] = ps[i].c->v[d] - B;
	//	dm = (RADIUS - v3_mag(disp)) / RADIUS;
	dm = 1 / (1 - (RADIUS - v3_mag(disp)) / RADIUS);
	v3_unit(disp);

	v3_mult_add(ps[i].v, disp, dm * LOSS_WALL * dt);

	//	ps[i].c->v[d] = B - RADIUS;
	//	ps[i].v->v[d] *= -1 * LOSS_WALL;
      }
    }
  }
  for (i = 0; i < PARTICLES; i++) {
    for (j = 0; j < PARTICLES; j++) {
      if (i == j) continue;
      if (v3_dist(ps[i].c, ps[j].c) >= RADIUS * 2) continue;

      /*      temp_s1 = v3_str(ps[i].c);
      temp_s2 = v3_str(ps[j].c);
      printf("collision pos: %s %s\n", temp_s1, temp_s2);
      free(temp_s1);
      free(temp_s2);*/

      /*
      temp_s1 = v3_str(ps[i].v);
      temp_s2 = v3_str(ps[j].v);
      printf("collision vel: %s %s\n", temp_s1, temp_s2);
      free(temp_s1);
      free(temp_s2);
      */

      temp = v3_copy(ps[i].v);
      v3_sub(temp, ps[j].v);

      /*
      temp_s1 = v3_str(temp);
      printf("temp = %s\n", temp_s1);
      free(temp_s1);
      */

      disp = v3_copy(ps[i].c);
      v3_sub(disp, ps[j].c);

      //      disp2 = v3_copy(disp);

      dm = RADIUS - v3_mag(disp) / 2;

      /*
      temp_s1 = v3_str(disp);
      printf("disp = %s\n", temp_s1);
      free(temp_s1);
      */

      v3_unit(disp);

      /*
      temp_s1 = v3_str(disp);
      printf("disp unit = %s\n", temp_s1);
      free(temp_s1);
      */

      dot = v3_dot(temp, disp);

      /*
      printf("dot = %f\n", dot);
      */

      v3_mult_add(ps[i].v, disp, dm*LOSS_COL*dt);
      v3_mult_sub(ps[j].v, disp, dm*LOSS_COL*dt);

      //      v3_mult_add(ps[i].c, disp, dm);
      //      v3_mult_sub(ps[j].c, disp, dm);

      v3_del(disp);
      v3_del(temp);
    }
  }
}