示例#1
0
	float Get(float x,float y)
	{
		float vec[2];
		vec[0] = x;
		vec[1] = y;
		return perlin_noise_2D(vec);
	}
示例#2
0
static void
render_blob (GLfloat ***data, int numstrips, int striplength, int front)
{
  int i;
  
  grab_transform ();
  
  for (i = 0; i < numstrips; i++)
    {
      int j;
      float texcoords[3 * striplength];
      GLfloat v[striplength][3];
      int all_positive = 1;
      int all_negative = 1;
      
      for (j = 0; j < striplength; j++)
        {
	  GLfloat x;
	  memcpy (&v[j], data[i][j], sizeof (float) * 3);
	  x = perlin_noise_2D (15 + 3 * v[j][1] + blob_phase * 0.3,
			       15 + 2 * v[j][0] + blob_phase * 0.4, 1) * 0.35;
	  v[j][0] += x * 0.5;
	  v[j][1] += x * 0.25;
	  v[j][2] += x * 0.15;
	  parabolic_texcoords (&texcoords[j * 3], v, data[i][j], front);
	  if (texcoords[j * 3 + 2] < 0)
	    all_positive = 0;
	  if (texcoords[j * 3 + 2] > 0)
	    all_negative = 0;
	}
      
      if ((front && !all_negative) || (!front && !all_positive))
        {
	  glBegin (GL_TRIANGLE_STRIP);
          for (j = 0; j < striplength; j++)
	    {
	      glTexCoord2f (texcoords[j * 3], texcoords[j * 3 + 1]);
	      glVertex3fv (&v[j][0]);
	    }
	  glEnd ();
	}
    }
}
示例#3
0
文件: fire.c 项目: crtc-demos/wobble
static void
draw_box (void)
{
  pvr_poly_cxt_t cxt;
  pvr_poly_hdr_t poly;
  pvr_vertex_t vert;
  int x, y;
  int ox, oy;
  float offset[21][16][2];

  pvr_poly_cxt_txr (&cxt, PVR_LIST_OP_POLY,
		    PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED, 1024, 512,
		    warp_texture[1 - warp_active], PVR_FILTER_BILINEAR);
  pvr_poly_compile (&poly, &cxt);
  
  for (oy = 0; oy <= 15; oy++)
    for (ox = 0; ox <= 20; ox++)
      {
        offset[ox][oy][0] = 2.0 * perlin_noise_2D (ox, oy + perlin_phase, 2);
	offset[ox][oy][1]
	  = -4.0 - 2.0 * perlin_noise_2D (ox + 40, oy + perlin_phase, 2);
      }
  
  for (oy = 0, y = 0; y < 480; oy++, y += 32)
    {
      pvr_prim (&poly, sizeof (poly));

      vert.flags = PVR_CMD_VERTEX;
      vert.x = offset[0][oy + 1][0];
      vert.y = y + 32 + offset[0][oy + 1][1];
      vert.z = DISTORT_DEPTH;
      vert.u = 0.0f;
      vert.v = (float) (y + 32) / 512.0f;
      vert.argb = 0xffffffff;
      vert.oargb = 0;
      pvr_prim (&vert, sizeof (vert));

      vert.x = offset[0][oy][0];
      vert.y = y + offset[0][oy][1];
      vert.v = (float) y / 512.0f;
      pvr_prim (&vert, sizeof (vert));

      for (ox = 1, x = 32; x < 640; ox++, x += 32)
        {
	  int is_last = (x == 640 - 32);

	  vert.x = x + offset[ox][oy + 1][0];
	  vert.y = y + 32 + offset[ox][oy + 1][1];
	  vert.u = (float) x / 1024.0f;
	  vert.v = (float) (y + 32) / 512.0f;
	  pvr_prim (&vert, sizeof (vert));

	  if (is_last)
	    vert.flags = PVR_CMD_VERTEX_EOL;
	    
	  vert.x = x + offset[ox][oy][0];
	  vert.y = y + offset[ox][oy][1];
	  vert.v = (float) y / 512.0f;
	  pvr_prim (&vert, sizeof (vert));
        }
    }

  rot1 += 0.005;
  if (rot1 > 2 * M_PI)
    rot1 -= 2 * M_PI;
  
  perlin_phase += 0.03;
}